00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 <kseparator.h>
00037
#include <kdebug.h>
00038
#include <kpushbutton.h>
00039
#include <kstdguiitem.h>
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 KPushButton(KStdGuiItem::cont(),
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