kio Library API Documentation

ksslcertdlg.cc

00001 /* This file is part of the KDE project
00002  *
00003  * Copyright (C) 2001-2003 George Staikos <staikos@kde.org>
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 as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public License
00016  * along with this library; see the file COPYING.LIB.  If not, write to
00017  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018  * Boston, MA 02111-1307, USA.
00019  */
00020 
00021 #include "ksslcertdlg.h"
00022 
00023 #include <kssl.h>
00024 
00025 #include <qlayout.h>
00026 #include <qpushbutton.h>
00027 #include <qradiobutton.h>
00028 #include <qcheckbox.h>
00029 #include <qlistview.h>
00030 #include <qframe.h>
00031 #include <qlabel.h>
00032 
00033 #include <kapplication.h>
00034 #include <kglobal.h>
00035 #include <klocale.h>
00036 #include <kglobalsettings.h>
00037 #include <kseparator.h>
00038 #include <kdebug.h>
00039 
00040 
00041 class KSSLCertDlg::KSSLCertDlgPrivate {
00042 private:
00043     friend class KSSLCertDlg;
00044 };
00045 
00046 KSSLCertDlg::KSSLCertDlg(QWidget *parent, const char *name, bool modal)
00047  : KDialog(parent, name, modal), d(new KSSLCertDlgPrivate) {
00048    QGridLayout *grid = new QGridLayout(this, 8, 6, KDialog::marginHint(),
00049                                                    KDialog::spacingHint() );
00050 
00051    _send = new QRadioButton(i18n("Send certificate..."), this);
00052    grid->addMultiCellWidget(_send, 0, 0, 0, 2);
00053    connect(_send, SIGNAL(clicked()), SLOT(slotSend()));
00054 
00055    _dont = new QRadioButton(i18n("Do not send a certificate"), this);
00056    grid->addMultiCellWidget(_dont, 1, 1, 0, 2);
00057    connect(_dont, SIGNAL(clicked()), SLOT(slotDont()));
00058 
00059    _certs = new QListView(this);
00060    grid->addMultiCellWidget(_certs, 0, 4, 3, 5);
00061    _certs->addColumn(i18n("Certificate"));
00062 
00063    _save = new QCheckBox(i18n("Save selection for this host."), this);
00064    grid->addMultiCellWidget(_save, 5, 5, 0, 3);
00065 
00066    grid->addMultiCellWidget(new KSeparator(KSeparator::HLine, this), 6, 6, 0, 5);
00067 
00068    _ok = new QPushButton(i18n("&Continue"), this);
00069    grid->addWidget(_ok, 7, 5);
00070    connect(_ok, SIGNAL(clicked()), SLOT(accept()));
00071 
00072 #ifndef QT_NO_WIDGET_TOPEXTRA
00073    setCaption(i18n("KDE SSL Certificate Dialog"));
00074 #endif
00075 }
00076 
00077 
00078 KSSLCertDlg::~KSSLCertDlg() {
00079     delete d;
00080 }
00081 
00082 
00083 void KSSLCertDlg::setup(QStringList certs, bool saveChecked, bool sendChecked) {
00084     setupDialog(certs, saveChecked, sendChecked);
00085 }
00086 
00087 void KSSLCertDlg::setupDialog(const QStringList& certs, bool saveChecked, bool sendChecked) {
00088   _save->setChecked(saveChecked);
00089   _send->setChecked(sendChecked);
00090   _dont->setChecked(!sendChecked);
00091   _certs->setEnabled(saveChecked);
00092 
00093   for (QStringList::ConstIterator i = certs.begin(); i != certs.end(); ++i) {
00094     if ((*i).isEmpty())
00095       continue;
00096 
00097     new QListViewItem(_certs, *i);
00098   }
00099 
00100   _certs->setSelected(_certs->firstChild(), true);
00101 }
00102 
00103 
00104 bool KSSLCertDlg::saveChoice() {
00105   return _save->isChecked();
00106 }
00107 
00108 
00109 bool KSSLCertDlg::wantsToSend() {
00110   return _send->isChecked();
00111 }
00112 
00113 
00114 QString KSSLCertDlg::getChoice() {
00115    return _certs->selectedItem()->text(0);
00116 }
00117 
00118 
00119 void KSSLCertDlg::setHost(const QString& host) {
00120    _host = host;
00121 #ifndef QT_NO_WIDGET_TOPEXTRA
00122    setCaption(i18n("KDE SSL Certificate Dialog")+" - "+host);
00123 #endif
00124 }
00125 
00126 
00127 void KSSLCertDlg::slotSend() {
00128    _dont->setChecked(false);
00129    _send->setChecked(true);
00130    _certs->setEnabled(true);
00131 }
00132 
00133 
00134 void KSSLCertDlg::slotDont() {
00135    _send->setChecked(false);
00136    _dont->setChecked(true);
00137    _certs->setEnabled(false);
00138 }
00139 
00140 
00141 QDataStream& operator<<(QDataStream& s, const KSSLCertDlgRet& r) {
00142    s << Q_INT8(r.ok?1:0) <<  r.choice << Q_INT8(r.save?1:0) << Q_INT8(r.send?1:0);
00143    return s;
00144 }
00145 
00146 
00147 QDataStream& operator>>(QDataStream& s, KSSLCertDlgRet& r) {
00148 Q_INT8 tmp;
00149    s >> tmp; r.ok = (tmp == 1);
00150    s >> r.choice;
00151    s >> tmp; r.save = (tmp == 1);
00152    s >> tmp; r.send = (tmp == 1);
00153    return s;
00154 }
00155 
00156 
00157 #include "ksslcertdlg.moc"
00158 
KDE Logo
This file is part of the documentation for kio Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Jan 21 09:57:56 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003