kio Library API Documentation

ksslcertdlg.cc

00001 /* This file is part of the KDE project
00002  *
00003  * Copyright (C) 2001 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   _save->setChecked(saveChecked);
00085   _send->setChecked(sendChecked);
00086   _dont->setChecked(!sendChecked);
00087   _certs->setEnabled(saveChecked);
00088 
00089   for (QStringList::Iterator i = certs.begin();
00090                              i != certs.end();
00091                              ++i) {
00092     if ((*i).isEmpty()) continue;
00093 
00094     new QListViewItem(_certs, *i);
00095   }
00096 
00097   _certs->setSelected(_certs->firstChild(), true);
00098 }
00099 
00100 
00101 bool KSSLCertDlg::saveChoice() {
00102   return _save->isChecked();
00103 }
00104 
00105 
00106 bool KSSLCertDlg::wantsToSend() {
00107   return _send->isChecked();
00108 }
00109 
00110 
00111 QString KSSLCertDlg::getChoice() {
00112    return _certs->selectedItem()->text(0);
00113 }
00114 
00115 
00116 void KSSLCertDlg::setHost(const QString& host) {
00117    _host = host;
00118 #ifndef QT_NO_WIDGET_TOPEXTRA
00119    setCaption(i18n("KDE SSL Certificate Dialog")+" - "+host);
00120 #endif
00121 }
00122 
00123 
00124 void KSSLCertDlg::slotSend() {
00125    _dont->setChecked(false);
00126    _send->setChecked(true);
00127    _certs->setEnabled(true);
00128 }
00129 
00130 
00131 void KSSLCertDlg::slotDont() {
00132    _send->setChecked(false);
00133    _dont->setChecked(true);
00134    _certs->setEnabled(false);
00135 }
00136 
00137 
00138 QDataStream& operator<<(QDataStream& s, const KSSLCertDlgRet& r) {
00139    s << Q_INT8(r.ok?1:0) <<  r.choice << Q_INT8(r.save?1:0) << Q_INT8(r.send?1:0);
00140    return s;
00141 }
00142 
00143 
00144 QDataStream& operator>>(QDataStream& s, KSSLCertDlgRet& r) {
00145 Q_INT8 tmp;
00146    s >> tmp; r.ok = (tmp == 1);
00147    s >> r.choice;
00148    s >> tmp; r.save = (tmp == 1);
00149    s >> tmp; r.send = (tmp == 1);
00150    return s;
00151 }
00152 
00153 
00154 #include "ksslcertdlg.moc"
00155 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:32 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001