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

kio

ksslcertdlg.cc

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #include "ksslcertdlg.h"
00022 
00023 #include <kssl.h>
00024 
00025 #include <qlayout.h>
00026 #include <qradiobutton.h>
00027 #include <qcheckbox.h>
00028 #include <qlistview.h>
00029 #include <qframe.h>
00030 #include <qlabel.h>
00031 
00032 #include <kapplication.h>
00033 #include <kglobal.h>
00034 #include <klocale.h>
00035 #include <kglobalsettings.h>
00036 #include <kpushbutton.h>
00037 #include <kstdguiitem.h>
00038 #include <kseparator.h>
00039 #include <kdebug.h>
00040 
00041 
00042 class KSSLCertDlg::KSSLCertDlgPrivate {
00043 private:
00044     friend class KSSLCertDlg;
00045     QLabel *p_message;
00046     QPushButton *p_pb_dontsend;
00047     bool p_send_flag;
00048 };
00049 
00050 KSSLCertDlg::KSSLCertDlg(QWidget *parent, const char *name, bool modal)
00051  : KDialog(parent, name, modal), d(new KSSLCertDlgPrivate) {
00052 
00053    QBoxLayout * grid = new QVBoxLayout( this, KDialog::marginHint(),
00054                                               KDialog::spacingHint() );
00055 
00056    d->p_message = new QLabel(QString::null, this);
00057    grid->addWidget(d->p_message);
00058    setHost(_host);
00059 
00060    _certs = new QListView(this);
00061    _certs->addColumn(i18n("Certificate"));
00062    _certs->setResizeMode(QListView::LastColumn);
00063    QFontMetrics fm( KGlobalSettings::generalFont() );
00064    _certs->setMinimumHeight(4*fm.height());
00065    grid->addWidget(_certs);
00066 
00067    _save = new QCheckBox(i18n("Save selection for this host."), this);
00068    grid->addWidget(_save);
00069 
00070    grid->addWidget(new KSeparator(KSeparator::HLine, this));
00071 
00072    QBoxLayout * h = new QHBoxLayout( grid );
00073    h->insertStretch(0);
00074 
00075    _ok = new KPushButton(i18n("Send certificate"), this);
00076    h->addWidget(_ok);
00077    connect(_ok, SIGNAL(clicked()), SLOT(slotSend()));
00078 
00079    d->p_pb_dontsend = new KPushButton(i18n("Do not send a certificate"), this);
00080    h->addWidget(d->p_pb_dontsend);
00081    connect(d->p_pb_dontsend, SIGNAL(clicked()), SLOT(slotDont()));
00082 
00083 #ifndef QT_NO_WIDGET_TOPEXTRA
00084    setCaption(i18n("KDE SSL Certificate Dialog"));
00085 #endif
00086 }
00087 
00088 
00089 KSSLCertDlg::~KSSLCertDlg() {
00090     delete d;
00091 }
00092 
00093 
00094 void KSSLCertDlg::setup(QStringList certs, bool saveChecked, bool sendChecked) {
00095     setupDialog(certs, saveChecked, sendChecked);
00096 }
00097 
00098 void KSSLCertDlg::setupDialog(const QStringList& certs, bool saveChecked, bool sendChecked) {
00099   _save->setChecked(saveChecked);
00100   d->p_send_flag = sendChecked;
00101 
00102   if (sendChecked)
00103     _ok->setDefault(true); // "do send" is the "default action".
00104   else
00105     d->p_pb_dontsend->setDefault(true); // "do not send" is the "default action".
00106 
00107   for (QStringList::ConstIterator i = certs.begin(); i != certs.end(); ++i) {
00108     if ((*i).isEmpty())
00109       continue;
00110 
00111     new QListViewItem(_certs, *i);
00112   }
00113 
00114   _certs->setSelected(_certs->firstChild(), true);
00115 }
00116 
00117 
00118 bool KSSLCertDlg::saveChoice() {
00119   return _save->isChecked();
00120 }
00121 
00122 
00123 bool KSSLCertDlg::wantsToSend() {
00124   return d->p_send_flag;
00125 }
00126 
00127 
00128 QString KSSLCertDlg::getChoice() {
00129    QListViewItem *selected = _certs->selectedItem();
00130    if (selected && d->p_send_flag)
00131     return selected->text(0);
00132    else
00133     return QString::null;
00134 }
00135 
00136 
00137 void KSSLCertDlg::setHost(const QString& host) {
00138    _host = host;
00139    d->p_message->setText(i18n("The server <b>%1</b> requests a certificate.<p>"
00140                  "Select a certificate to use from the list below:")
00141              .arg(_host));
00142 }
00143 
00144 
00145 void KSSLCertDlg::slotSend() {
00146    d->p_send_flag = true;
00147    accept();
00148 }
00149 
00150 
00151 void KSSLCertDlg::slotDont() {
00152    d->p_send_flag = false;
00153    reject();
00154 }
00155 
00156 
00157 QDataStream& operator<<(QDataStream& s, const KSSLCertDlgRet& r) {
00158    s << Q_INT8(r.ok?1:0) <<  r.choice << Q_INT8(r.save?1:0) << Q_INT8(r.send?1:0);
00159    return s;
00160 }
00161 
00162 
00163 QDataStream& operator>>(QDataStream& s, KSSLCertDlgRet& r) {
00164 Q_INT8 tmp;
00165    s >> tmp; r.ok = (tmp == 1);
00166    s >> r.choice;
00167    s >> tmp; r.save = (tmp == 1);
00168    s >> tmp; r.send = (tmp == 1);
00169    return s;
00170 }
00171 
00172 
00173 #include "ksslcertdlg.moc"
00174 

kio

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
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