kdeprint Library API Documentation

cupsdsecuritypage.cpp

00001 /* 00002 * This file is part of the KDE libraries 00003 * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License version 2 as published by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 * Boston, MA 02111-1307, USA. 00018 **/ 00019 00020 #include "cupsdsecuritypage.h" 00021 #include "cupsdconf.h" 00022 #include "qdirlineedit.h" 00023 #include "editlist.h" 00024 #include "locationdialog.h" 00025 00026 #include <qlabel.h> 00027 #include <qlineedit.h> 00028 #include <qlayout.h> 00029 #include <qwhatsthis.h> 00030 00031 #include <klocale.h> 00032 #include <kiconloader.h> 00033 #include <kmessagebox.h> 00034 00035 CupsdSecurityPage::CupsdSecurityPage(QWidget *parent, const char *name) 00036 : CupsdPage(parent, name) 00037 { 00038 setPageLabel(i18n("Security")); 00039 setHeader(i18n("Security Settings")); 00040 setPixmap("password"); 00041 locs_.setAutoDelete(true); 00042 00043 remoteroot_ = new QLineEdit(this); 00044 systemgroup_ = new QLineEdit(this); 00045 encryptcert_ = new QDirLineEdit(true, this); 00046 encryptkey_ = new QDirLineEdit(true, this); 00047 locations_ = new EditList(this); 00048 00049 QLabel *l1 = new QLabel(i18n("Remote root user:"), this); 00050 QLabel *l2 = new QLabel(i18n("System group:"), this); 00051 QLabel *l3 = new QLabel(i18n("Encryption certificate:"), this); 00052 QLabel *l4 = new QLabel(i18n("Encryption key:"), this); 00053 QLabel *l5 = new QLabel(i18n("Locations:"), this); 00054 00055 QGridLayout *m1 = new QGridLayout(this, 6, 2, 10, 7); 00056 m1->setRowStretch(5, 1); 00057 m1->setColStretch(1, 1); 00058 m1->addWidget(l1, 0, 0, Qt::AlignRight); 00059 m1->addWidget(l2, 1, 0, Qt::AlignRight); 00060 m1->addWidget(l3, 2, 0, Qt::AlignRight); 00061 m1->addWidget(l4, 3, 0, Qt::AlignRight); 00062 m1->addWidget(l5, 4, 0, Qt::AlignRight|Qt::AlignTop); 00063 m1->addWidget(remoteroot_, 0, 1); 00064 m1->addWidget(systemgroup_, 1, 1); 00065 m1->addWidget(encryptcert_, 2, 1); 00066 m1->addWidget(encryptkey_, 3, 1); 00067 m1->addWidget(locations_, 4, 1); 00068 00069 connect(locations_, SIGNAL(add()), SLOT(slotAdd())); 00070 connect(locations_, SIGNAL(edit(int)), SLOT(slotEdit(int))); 00071 connect(locations_, SIGNAL(defaultList()), SLOT(slotDefaultList())); 00072 connect(locations_, SIGNAL(deleted(int)), SLOT(slotDeleted(int))); 00073 } 00074 00075 bool CupsdSecurityPage::loadConfig(CupsdConf *conf, QString&) 00076 { 00077 conf_ = conf; 00078 remoteroot_->setText(conf_->remoteroot_); 00079 systemgroup_->setText(conf_->systemgroup_); 00080 encryptcert_->setURL(conf_->encryptcert_); 00081 encryptkey_->setURL(conf_->encryptkey_); 00082 locs_.clear(); 00083 QPtrListIterator<CupsLocation> it(conf_->locations_); 00084 for (;it.current();++it) 00085 { 00086 locs_.append(new CupsLocation(*(it.current()))); 00087 if (it.current()->resource_) 00088 locations_->insertItem(SmallIcon(CupsResource::typeToIconName(it.current()->resource_->type_)), it.current()->resource_->text_); 00089 else 00090 locations_->insertItem(it.current()->resourcename_); 00091 } 00092 00093 return true; 00094 } 00095 00096 bool CupsdSecurityPage::saveConfig(CupsdConf *conf, QString&) 00097 { 00098 conf->remoteroot_ = remoteroot_->text(); 00099 conf->systemgroup_ = systemgroup_->text(); 00100 conf->encryptcert_ = encryptcert_->url(); 00101 conf->encryptkey_ = encryptkey_->url(); 00102 conf->locations_.clear(); 00103 QPtrListIterator<CupsLocation> it(locs_); 00104 for (;it.current();++it) 00105 conf->locations_.append(new CupsLocation(*(it.current()))); 00106 00107 return true; 00108 } 00109 00110 void CupsdSecurityPage::setInfos(CupsdConf *conf) 00111 { 00112 QWhatsThis::add(remoteroot_, conf->comments_.toolTip("remoteroot")); 00113 QWhatsThis::add(systemgroup_, conf->comments_.toolTip("systemgroup")); 00114 QWhatsThis::add(encryptcert_, conf->comments_.toolTip("servercertificate")); 00115 QWhatsThis::add(encryptkey_, conf->comments_.toolTip("serverkey")); 00116 QWhatsThis::add(locations_, conf->comments_.toolTip("locationsshort")); 00117 } 00118 00119 void CupsdSecurityPage::slotAdd() 00120 { 00121 CupsLocation *loc = new CupsLocation; 00122 if (LocationDialog::newLocation(loc, this, conf_)) 00123 { 00124 int index(-1); 00125 for (locs_.first(); locs_.current(); locs_.next()) 00126 if (locs_.current()->resource_ == loc->resource_) 00127 { 00128 if (KMessageBox::warningYesNo(this, i18n("This location is already defined. Do you want to replace the existing one?")) == KMessageBox::Yes) 00129 { 00130 index = locs_.at(); 00131 locs_.remove(); 00132 break; 00133 } 00134 else 00135 { 00136 delete loc; 00137 return; 00138 } 00139 } 00140 00141 if (index == -1) 00142 index = locs_.count(); 00143 locs_.insert(index, loc); 00144 locations_->insertItem(SmallIcon(loc->resource_->typeToIconName(loc->resource_->type_)), loc->resource_->text_); 00145 } 00146 else 00147 delete loc; 00148 } 00149 00150 void CupsdSecurityPage::slotEdit(int index) 00151 { 00152 CupsLocation *loc = locs_.at(index); 00153 LocationDialog::editLocation(loc, this, conf_); 00154 } 00155 00156 void CupsdSecurityPage::slotDefaultList() 00157 { 00158 locs_.clear(); 00159 locations_->clear(); 00160 } 00161 00162 void CupsdSecurityPage::slotDeleted(int index) 00163 { 00164 if (index >= 0 && index < (int)(locs_.count())) 00165 locs_.remove(index); 00166 } 00167 00168 #include "cupsdsecuritypage.moc"
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Aug 30 22:55:47 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003