kdeprint Library API Documentation

cupsdserverencryptpage.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 "cupsdserverencryptpage.h"
00021 
00022 #include "qdirlineedit.h"
00023 #include <klocale.h>
00024 #include <qlayout.h>
00025 #include <qlabel.h>
00026 #include <qwhatsthis.h>
00027 
00028 #include "cupsdconf.h"
00029 #include "cupsdoption.h"
00030 
00031 CupsdServerEncryptPage::CupsdServerEncryptPage(QWidget *parent, const char *name)
00032     : CupsdPage(parent, name)
00033 {
00034     path_.append(i18n("Server"));
00035     path_.append(i18n("Encryption"));
00036     header_ = i18n("Server Encryption Support Configuration");
00037 
00038     for (int i=0;i<2;i++)
00039         opt_[i] = new CupsdOption(this);
00040 
00041     servercertificate_ = new QDirLineEdit(opt_[0]);
00042     serverkey_ = new QDirLineEdit(opt_[1]);
00043 
00044     QLabel  *l1 = new QLabel(i18n("Server certificate:"), this);
00045     QLabel  *l2 = new QLabel(i18n("Server key:"), this);
00046 
00047     QGridLayout *main_ = new QGridLayout(this, 4, 2, 10, 10);
00048     main_->addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter);
00049     main_->addWidget(l1, 1, 0);
00050     main_->addWidget(l2, 2, 0);
00051     main_->addWidget(opt_[0], 1, 1);
00052     main_->addWidget(opt_[1], 2, 1);
00053     main_->setRowStretch(3, 1);
00054 }
00055 
00056 CupsdServerEncryptPage::~CupsdServerEncryptPage()
00057 {
00058 }
00059 
00060 bool CupsdServerEncryptPage::loadConfig(CupsdConf *conf, QString&)
00061 {
00062     conf_ = conf;
00063     if (!conf->servercertificate_.isNull())
00064     {
00065         opt_[0]->setDefault(false);
00066         servercertificate_->setText(conf->servercertificate_);
00067     }
00068     if (!conf->serverkey_.isNull())
00069     {
00070         opt_[1]->setDefault(false);
00071         serverkey_->setText(conf->serverkey_);
00072     }
00073     return true;
00074 }
00075 
00076 bool CupsdServerEncryptPage::saveConfig(CupsdConf *conf, QString&)
00077 {
00078     if (!opt_[0]->isDefault() && !servercertificate_->text().isNull()) conf->servercertificate_ = servercertificate_->text();
00079     if (!opt_[1]->isDefault() && !serverkey_->text().isNull()) conf->serverkey_ = serverkey_->text();
00080     return true;
00081 }
00082 
00083 void CupsdServerEncryptPage::setDefaults()
00084 {
00085     servercertificate_->setText("/etc/cups/ssl/server.crt");
00086     serverkey_->setText("/etc/cups/ssl/server.key");
00087 }
00088 
00089 void CupsdServerEncryptPage::setInfos(CupsdConf *conf)
00090 {
00091         QWhatsThis::add(servercertificate_, conf->comments_.toolTip(SERVERCERTIFICATE_COMM));
00092         QWhatsThis::add(serverkey_, conf->comments_.toolTip(SERVERKEY_COMM));
00093 }
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 Thu Sep 30 05:20:48 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003