• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
  • cups
  • cupsdconf2
cupsdsecuritypage.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 
20 #include "cupsdsecuritypage.h"
21 #include "cupsdconf.h"
22 #include "qdirlineedit.h"
23 #include "editlist.h"
24 #include "locationdialog.h"
25 
26 #include <tqlabel.h>
27 #include <tqlineedit.h>
28 #include <tqlayout.h>
29 #include <tqwhatsthis.h>
30 
31 #include <tdelocale.h>
32 #include <kiconloader.h>
33 #include <tdemessagebox.h>
34 
35 CupsdSecurityPage::CupsdSecurityPage(TQWidget *parent, const char *name)
36  : CupsdPage(parent, name)
37 {
38  setPageLabel(i18n("Security"));
39  setHeader(i18n("Security Settings"));
40  setPixmap("password");
41  locs_.setAutoDelete(true);
42 
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);
48 
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);
54 
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);
68 
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)));
73 }
74 
75 bool CupsdSecurityPage::loadConfig(CupsdConf *conf, TQString&)
76 {
77  conf_ = conf;
78  remoteroot_->setText(conf_->remoteroot_);
79  systemgroup_->setText(conf_->systemgroup_);
80  encryptcert_->setURL(conf_->encryptcert_);
81  encryptkey_->setURL(conf_->encryptkey_);
82  locs_.clear();
83  TQPtrListIterator<CupsLocation> it(conf_->locations_);
84  for (;it.current();++it)
85  {
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_);
89  else
90  locations_->insertItem(it.current()->resourcename_);
91  }
92 
93  return true;
94 }
95 
96 bool CupsdSecurityPage::saveConfig(CupsdConf *conf, TQString&)
97 {
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())));
106 
107  return true;
108 }
109 
110 void CupsdSecurityPage::setInfos(CupsdConf *conf)
111 {
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"));
117 }
118 
119 void CupsdSecurityPage::slotAdd()
120 {
121  CupsLocation *loc = new CupsLocation;
122  if (LocationDialog::newLocation(loc, this, conf_))
123  {
124  int index(-1);
125  for (locs_.first(); locs_.current(); locs_.next())
126  if (locs_.current()->resource_ == loc->resource_)
127  {
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)
129  {
130  index = locs_.at();
131  locs_.remove();
132  break;
133  }
134  else
135  {
136  delete loc;
137  return;
138  }
139  }
140 
141  if (index == -1)
142  index = locs_.count();
143  locs_.insert(index, loc);
144  locations_->insertItem(SmallIcon(loc->resource_->typeToIconName(loc->resource_->type_)), loc->resource_->text_);
145  }
146  else
147  delete loc;
148 }
149 
150 void CupsdSecurityPage::slotEdit(int index)
151 {
152  CupsLocation *loc = locs_.at(index);
153  LocationDialog::editLocation(loc, this, conf_);
154 }
155 
156 void CupsdSecurityPage::slotDefaultList()
157 {
158  locs_.clear();
159  locations_->clear();
160 }
161 
162 void CupsdSecurityPage::slotDeleted(int index)
163 {
164  if (index >= 0 && index < (int)(locs_.count()))
165  locs_.remove(index);
166 }
167 
168 #include "cupsdsecuritypage.moc"

tdeprint

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

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.1
This website is maintained by Timothy Pearson.