20#include "cupsdsecuritypage.h" 
   22#include "qdirlineedit.h" 
   24#include "locationdialog.h" 
   27#include <tqlineedit.h> 
   29#include <tqwhatsthis.h> 
   32#include <kiconloader.h> 
   33#include <tdemessagebox.h> 
   35CupsdSecurityPage::CupsdSecurityPage(TQWidget *parent, 
const char *name)
 
   36    : CupsdPage(parent, name)
 
   38    setPageLabel(i18n(
"Security"));
 
   39    setHeader(i18n(
"Security Settings"));
 
   40    setPixmap(
"password");
 
   41    locs_.setAutoDelete(
true);
 
   43    remoteroot_ = 
new TQLineEdit(
this);
 
   44    systemgroup_ = 
new TQLineEdit(
this);
 
   45    encryptcert_ = 
new QDirLineEdit(
true, 
this);
 
   46    encryptkey_ = 
new QDirLineEdit(
true, 
this);
 
   47    locations_ = 
new EditList(
this);
 
   49    TQLabel *l1 = 
new TQLabel(i18n(
"Remote root user:"), 
this);
 
   50    TQLabel *l2 = 
new TQLabel(i18n(
"System group:"), 
this);
 
   51    TQLabel *l3 = 
new TQLabel(i18n(
"Encryption certificate:"), 
this);
 
   52    TQLabel *l4 = 
new TQLabel(i18n(
"Encryption key:"), 
this);
 
   53    TQLabel *l5 = 
new TQLabel(i18n(
"Locations:"), 
this);
 
   55    TQGridLayout    *m1 = 
new TQGridLayout(
this, 6, 2, 10, 7);
 
   56    m1->setRowStretch(5, 1);
 
   57    m1->setColStretch(1, 1);
 
   58    m1->addWidget(l1, 0, 0, TQt::AlignRight);
 
   59    m1->addWidget(l2, 1, 0, TQt::AlignRight);
 
   60    m1->addWidget(l3, 2, 0, TQt::AlignRight);
 
   61    m1->addWidget(l4, 3, 0, TQt::AlignRight);
 
   62    m1->addWidget(l5, 4, 0, TQt::AlignRight|TQt::AlignTop);
 
   63    m1->addWidget(remoteroot_, 0, 1);
 
   64    m1->addWidget(systemgroup_, 1, 1);
 
   65    m1->addWidget(encryptcert_, 2, 1);
 
   66    m1->addWidget(encryptkey_, 3, 1);
 
   67    m1->addWidget(locations_, 4, 1);
 
   69    connect(locations_, TQ_SIGNAL(add()), TQ_SLOT(slotAdd()));
 
   70    connect(locations_, TQ_SIGNAL(edit(
int)), TQ_SLOT(slotEdit(
int)));
 
   71    connect(locations_, TQ_SIGNAL(defaultList()), TQ_SLOT(slotDefaultList()));
 
   72    connect(locations_, TQ_SIGNAL(deleted(
int)), TQ_SLOT(slotDeleted(
int)));
 
   75bool CupsdSecurityPage::loadConfig(CupsdConf *conf, TQString&)
 
   78    remoteroot_->setText(conf_->remoteroot_);
 
   79    systemgroup_->setText(conf_->systemgroup_);
 
   80    encryptcert_->setURL(conf_->encryptcert_);
 
   81    encryptkey_->setURL(conf_->encryptkey_);
 
   83    TQPtrListIterator<CupsLocation> it(conf_->locations_);
 
   84    for (;it.current();++it)
 
   86        locs_.append(
new CupsLocation(*(it.current())));
 
   87        if (it.current()->resource_)
 
   88            locations_->insertItem(SmallIcon(CupsResource::typeToIconName(it.current()->resource_->type_)), it.current()->resource_->text_);
 
   90            locations_->insertItem(it.current()->resourcename_);
 
   96bool CupsdSecurityPage::saveConfig(CupsdConf *conf, TQString&)
 
   98    conf->remoteroot_ = remoteroot_->text();
 
   99    conf->systemgroup_ = systemgroup_->text();
 
  100    conf->encryptcert_ = encryptcert_->url();
 
  101    conf->encryptkey_ = encryptkey_->url();
 
  102    conf->locations_.clear();
 
  103    TQPtrListIterator<CupsLocation> it(locs_);
 
  104    for (;it.current();++it)
 
  105        conf->locations_.append(
new CupsLocation(*(it.current())));
 
  110void CupsdSecurityPage::setInfos(CupsdConf *conf)
 
  112    TQWhatsThis::add(remoteroot_, conf->comments_.toolTip(
"remoteroot"));
 
  113    TQWhatsThis::add(systemgroup_, conf->comments_.toolTip(
"systemgroup"));
 
  114    TQWhatsThis::add(encryptcert_, conf->comments_.toolTip(
"servercertificate"));
 
  115    TQWhatsThis::add(encryptkey_, conf->comments_.toolTip(
"serverkey"));
 
  116    TQWhatsThis::add(locations_, conf->comments_.toolTip(
"locationsshort"));
 
  119void CupsdSecurityPage::slotAdd()
 
  121    CupsLocation    *loc = 
new CupsLocation;
 
  122    if (LocationDialog::newLocation(loc, 
this, conf_))
 
  125        for (locs_.first(); locs_.current(); locs_.next())
 
  126            if (locs_.current()->resource_ == loc->resource_)
 
  128                if (KMessageBox::warningContinueCancel(
this, i18n(
"This location is already defined. Do you want to replace the existing one?"),TQString::null,i18n(
"Replace")) == KMessageBox::Continue)
 
  142            index = locs_.count();
 
  143        locs_.insert(index, loc);
 
  144        locations_->insertItem(SmallIcon(loc->resource_->typeToIconName(loc->resource_->type_)), loc->resource_->text_);
 
  150void CupsdSecurityPage::slotEdit(
int index)
 
  152    CupsLocation *loc = locs_.at(index);
 
  153    LocationDialog::editLocation(loc, 
this, conf_);
 
  156void CupsdSecurityPage::slotDefaultList()
 
  162void CupsdSecurityPage::slotDeleted(
int index)
 
  164    if (index >= 0 && index < (
int)(locs_.count()))
 
  168#include "cupsdsecuritypage.moc"