• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KIO

  • sources
  • kde-4.14
  • kdelibs
  • kio
  • kssl
ksslcertdialog.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2001-2003 George Staikos <staikos@kde.org>
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 as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #include "ksslcertdialog.h"
22 
23 #include <kssl.h>
24 
25 #include <QtGui/QLayout>
26 #include <QtGui/QRadioButton>
27 #include <QtGui/QCheckBox>
28 #include <QtGui/QFrame>
29 #include <QtGui/QLabel>
30 #include <QtGui/QListWidget>
31 
32 #include <klocale.h>
33 #include <kglobalsettings.h>
34 #include <kpushbutton.h>
35 #include <kseparator.h>
36 #include <kdebug.h>
37 
38 
39 class KSSLCertDialog::KSSLCertDialogPrivate {
40 private:
41  friend class KSSLCertDialog;
42  QLabel *p_message;
43  QPushButton *p_pb_dontsend;
44  bool p_send_flag;
45 };
46 
47 KSSLCertDialog::KSSLCertDialog(QWidget *parent, const char *name, bool modal)
48  : KDialog(parent), d(new KSSLCertDialogPrivate) {
49  setObjectName(name);
50  setModal(modal);
51 
52  QBoxLayout * grid = new QVBoxLayout( this );
53 
54  d->p_message = new QLabel(QString(), this);
55  grid->addWidget(d->p_message);
56  setHost(_host);
57 
58  QLabel* lblCertificate = new QLabel(i18n("Certificate"));
59  grid->addWidget(lblCertificate);
60 
61  _certs = new QListWidget(this);
62  QFontMetrics fm( KGlobalSettings::generalFont() );
63  _certs->setMinimumHeight(4*fm.height());
64  grid->addWidget(_certs);
65 
66  _save = new QCheckBox(i18n("Save selection for this host."), this);
67  grid->addWidget(_save);
68 
69  grid->addWidget(new KSeparator(Qt::Horizontal, this));
70 
71  QBoxLayout * h = new QHBoxLayout(this);
72  h->insertStretch(0);
73  grid->addLayout(h);
74 
75  _ok = new KPushButton(i18n("Send certificate"), this);
76  h->addWidget(_ok);
77  connect(_ok, SIGNAL(clicked()), SLOT(slotSend()));
78 
79  d->p_pb_dontsend = new KPushButton(i18n("Do not send a certificate"), this);
80  h->addWidget(d->p_pb_dontsend);
81  connect(d->p_pb_dontsend, SIGNAL(clicked()), SLOT(slotDont()));
82 
83 #ifndef QT_NO_WIDGET_TOPEXTRA
84  setCaption(i18n("KDE SSL Certificate Dialog"));
85 #endif
86 }
87 
88 
89 KSSLCertDialog::~KSSLCertDialog() {
90  delete d;
91 }
92 
93 
94 #ifndef KDE_NO_DEPRECATED
95 void KSSLCertDialog::setup(QStringList certs, bool saveChecked, bool sendChecked) {
96  setupDialog(certs, saveChecked, sendChecked);
97 }
98 #endif
99 
100 void KSSLCertDialog::setupDialog(const QStringList& certs, bool saveChecked, bool sendChecked) {
101  _save->setChecked(saveChecked);
102  d->p_send_flag = sendChecked;
103 
104  if (sendChecked)
105  _ok->setDefault(true); // "do send" is the "default action".
106  else
107  d->p_pb_dontsend->setDefault(true); // "do not send" is the "default action".
108 
109  for (QStringList::ConstIterator i = certs.begin(); i != certs.end(); ++i) {
110  if ((*i).isEmpty())
111  continue;
112 
113  new QListWidgetItem(*i, _certs);
114  }
115 
116  _certs->setCurrentItem(_certs->item(0));
117 }
118 
119 
120 bool KSSLCertDialog::saveChoice() {
121  return _save->isChecked();
122 }
123 
124 
125 bool KSSLCertDialog::wantsToSend() {
126  return d->p_send_flag;
127 }
128 
129 
130 QString KSSLCertDialog::getChoice() {
131  QListWidgetItem *selected = _certs->currentItem();
132  if (selected && d->p_send_flag)
133  return selected->text();
134  else
135  return QString();
136 }
137 
138 
139 void KSSLCertDialog::setHost(const QString& host) {
140  _host = host;
141  d->p_message->setText(i18n("The server <b>%1</b> requests a certificate.<br /><br />"
142  "Select a certificate to use from the list below:",
143  _host));
144 }
145 
146 
147 void KSSLCertDialog::slotSend() {
148  d->p_send_flag = true;
149  accept();
150 }
151 
152 
153 void KSSLCertDialog::slotDont() {
154  d->p_send_flag = false;
155  reject();
156 }
157 
158 
159 QDataStream& operator<<(QDataStream& s, const KSSLCertDialogRet& r) {
160  s << qint8(r.ok?1:0) << r.choice << qint8(r.save?1:0) << qint8(r.send?1:0);
161  return s;
162 }
163 
164 
165 QDataStream& operator>>(QDataStream& s, KSSLCertDialogRet& r) {
166  qint8 tmp;
167  s >> tmp; r.ok = (tmp == 1);
168  s >> r.choice;
169  s >> tmp; r.save = (tmp == 1);
170  s >> tmp; r.send = (tmp == 1);
171  return s;
172 }
173 
174 
175 #include "ksslcertdialog.moc"
176 
i18n
QString i18n(const char *text)
KPushButton
QWidget
QDialog::reject
virtual void reject()
QListWidget::currentItem
QListWidgetItem * currentItem() const
QDialog::modal
modal
QBoxLayout::insertStretch
void insertStretch(int index, int stretch)
kdebug.h
KSSLCertDialog::~KSSLCertDialog
virtual ~KSSLCertDialog()
Destroy this object and close the dialog.
Definition: ksslcertdialog.cpp:89
kglobalsettings.h
QDataStream
KSSLCertDialog::KSSLCertDialog
KSSLCertDialog(QWidget *parent=0L, const char *name=0L, bool modal=false)
Construct a KSSL certificate dialog.
Definition: ksslcertdialog.cpp:47
QListWidgetItem
QHBoxLayout
KDialog
QFontMetrics
KSSLCertDialogRet::ok
bool ok
Definition: ksslcertdialog.h:135
QListWidget
klocale.h
KSSLCertDialogRet::save
bool save
Definition: ksslcertdialog.h:137
KSSLCertDialogRet::send
bool send
Definition: ksslcertdialog.h:136
KSeparator
QObject::name
const char * name() const
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QCheckBox
QObject::setObjectName
void setObjectName(const QString &name)
KSSLCertDialog::saveChoice
bool saveChoice()
Determine if the user wants to save the choice for the future.
Definition: ksslcertdialog.cpp:120
QVBoxLayout
QListWidget::setCurrentItem
void setCurrentItem(QListWidgetItem *item)
QString
QListWidget::item
QListWidgetItem * item(int row) const
QDialog::accept
virtual void accept()
QStringList
KSSLCertDialog::setupDialog
void setupDialog(const QStringList &certs, bool saveChecked=false, bool sendChecked=true)
Setup the dialog.
Definition: ksslcertdialog.cpp:100
KSSLCertDialog::setup
void setup(QStringList certs, bool saveChecked=false, bool sendChecked=true)
Setup the dialog.
Definition: ksslcertdialog.cpp:95
KSSLCertDialog
KDE X.509 Certificate Dialog.
Definition: ksslcertdialog.h:45
QList::end
iterator end()
kpushbutton.h
kseparator.h
QAbstractButton::setChecked
void setChecked(bool)
KSSLCertDialog::setHost
void setHost(const QString &host)
Set the hostname that we are connecting to.
Definition: ksslcertdialog.cpp:139
KSSLCertDialogRet::choice
QString choice
Definition: ksslcertdialog.h:134
operator>>
QDataStream & operator>>(QDataStream &s, KSSLCertDialogRet &r)
Definition: ksslcertdialog.cpp:165
KGlobalSettings::generalFont
static QFont generalFont()
KSSLCertDialogRet
This class is used in the internal DCOP communication between TPCSlaveBase and kuiserver.
Definition: ksslcertdialog.h:132
operator<<
QDataStream & operator<<(QDataStream &s, const KSSLCertDialogRet &r)
Definition: ksslcertdialog.cpp:159
QList::ConstIterator
typedef ConstIterator
QFontMetrics::height
int height() const
QWidget::setCaption
void setCaption(const QString &c)
QWidget::setMinimumHeight
void setMinimumHeight(int minh)
QPushButton
ksslcertdialog.h
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QLabel
QObject::parent
QObject * parent() const
KSSLCertDialog::wantsToSend
bool wantsToSend()
Determine if the user wants to send a certificate.
Definition: ksslcertdialog.cpp:125
KSSLCertDialog::getChoice
QString getChoice()
Obtain the name of the certificate the user wants to send.
Definition: ksslcertdialog.cpp:130
QPushButton::setDefault
void setDefault(bool)
QBoxLayout
QList::begin
iterator begin()
QListWidgetItem::text
QString text() const
QBoxLayout::addLayout
void addLayout(QLayout *layout, int stretch)
kssl.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal