• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KDEPrint

cupsdsecuritypage.cpp

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, 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 <QtGui/QLabel>
00027 #include <QtGui/QLineEdit>
00028 #include <QtGui/QLayout>
00029 
00030 #include <klocale.h>
00031 #include <kiconloader.h>
00032 #include <kmessagebox.h>
00033 
00034 CupsdSecurityPage::CupsdSecurityPage(QWidget *parent)
00035         : CupsdPage(parent)
00036 {
00037     setPageLabel(i18n("Security"));
00038     setHeader(i18n("Security Settings"));
00039     setPixmap("password");
00040 
00041     remoteroot_ = new QLineEdit(this);
00042     systemgroup_ = new QLineEdit(this);
00043     encryptcert_ = new QDirLineEdit(true, this);
00044     encryptkey_ = new QDirLineEdit(true, this);
00045     locations_ = new EditList(this);
00046 
00047     QLabel *l1 = new QLabel(i18n("Remote root user:"), this);
00048     QLabel *l2 = new QLabel(i18n("System group:"), this);
00049     QLabel *l3 = new QLabel(i18n("Encryption certificate:"), this);
00050     QLabel *l4 = new QLabel(i18n("Encryption key:"), this);
00051     QLabel *l5 = new QLabel(i18n("Locations:"), this);
00052 
00053     QGridLayout *m1 = new QGridLayout(this);
00054     m1->setMargin(10);
00055     m1->setSpacing(7);
00056     m1->setRowStretch(5, 1);
00057     m1->setColumnStretch(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 CupsdSecurityPage::~CupsdSecurityPage()
00076 {
00077     qDeleteAll(locs_);
00078 }
00079 
00080 bool CupsdSecurityPage::loadConfig(CupsdConf *conf, QString&)
00081 {
00082     conf_ = conf;
00083     remoteroot_->setText(conf_->remoteroot_);
00084     systemgroup_->setText(conf_->systemgroup_);
00085     encryptcert_->setUrl(conf_->encryptcert_);
00086     encryptkey_->setUrl(conf_->encryptkey_);
00087     locs_.clear();
00088     QListIterator<CupsLocation*> it(conf_->locations_);
00089     while (it.hasNext()) {
00090         CupsLocation *location(it.next());
00091         locs_.append(new CupsLocation(*location));
00092         if (location->resource_)
00093             locations_->insertItem(SmallIcon(CupsResource::typeToIconName(location->resource_->type_)), location->resource_->text_);
00094         else
00095             locations_->insertItem(location->resourcename_);
00096     }
00097 
00098     return true;
00099 }
00100 
00101 bool CupsdSecurityPage::saveConfig(CupsdConf *conf, QString&)
00102 {
00103     conf->remoteroot_ = remoteroot_->text();
00104     conf->systemgroup_ = systemgroup_->text();
00105     conf->encryptcert_ = encryptcert_->url();
00106     conf->encryptkey_ = encryptkey_->url();
00107     conf->locations_.clear();
00108     QListIterator<CupsLocation*> it(locs_);
00109     while (it.hasNext())
00110         conf->locations_.append(new CupsLocation(*(it.next())));
00111 
00112     return true;
00113 }
00114 
00115 void CupsdSecurityPage::setInfos(CupsdConf *conf)
00116 {
00117     remoteroot_->setWhatsThis(conf->comments_.toolTip("remoteroot"));
00118     systemgroup_->setWhatsThis(conf->comments_.toolTip("systemgroup"));
00119     encryptcert_->setWhatsThis(conf->comments_.toolTip("servercertificate"));
00120     encryptkey_->setWhatsThis(conf->comments_.toolTip("serverkey"));
00121     locations_->setWhatsThis(conf->comments_.toolTip("locationsshort"));
00122 }
00123 
00124 void CupsdSecurityPage::slotAdd()
00125 {
00126     CupsLocation *loc = new CupsLocation;
00127     if (LocationDialog::newLocation(loc, this, conf_)) {
00128         int index(-1);
00129         QListIterator<CupsLocation*> it(locs_);
00130         while (it.hasNext()) {
00131             CupsLocation *location(it.next());
00132             if (location->resource_ == loc->resource_) {
00133                 if (KMessageBox::warningContinueCancel(this, i18n("This location is already defined. Do you want to replace the existing one?"), QString(), KGuiItem(i18n("Replace"))) == KMessageBox::Continue) {
00134                     index = locs_.indexOf(location);
00135                     locs_.removeAll(location);
00136                     delete location;
00137                     break;
00138                 } else {
00139                     delete loc;
00140                     return;
00141                 }
00142             }
00143         }
00144 
00145         if (index == -1)
00146             index = locs_.count();
00147         locs_.insert(index, loc);
00148         locations_->insertItem(SmallIcon(loc->resource_->typeToIconName(loc->resource_->type_)), loc->resource_->text_);
00149     } else
00150         delete loc;
00151 }
00152 
00153 void CupsdSecurityPage::slotEdit(int index)
00154 {
00155     CupsLocation *loc = locs_.at(index);
00156     LocationDialog::editLocation(loc, this, conf_);
00157 }
00158 
00159 void CupsdSecurityPage::slotDefaultList()
00160 {
00161     locs_.clear();
00162     locations_->clear();
00163 }
00164 
00165 void CupsdSecurityPage::slotDeleted(int index)
00166 {
00167     if (index >= 0 && index < (int)(locs_.count()))
00168         delete locs_.takeAt(index);
00169 }
00170 
00171 #include "cupsdsecuritypage.moc"

KDEPrint

Skip menu "KDEPrint"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  •   KDEPrint
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal