1
/***************************************************************************
3
* knetworkmanager-vpnauthenticationdialog.cpp - A NetworkManager frontend for KDE
5
* Copyright (C) 2006 Novell, Inc.
7
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
**************************************************************************/
26
#include <kpushbutton.h>
27
#include <qbuttongroup.h>
28
#include <qcombobox.h>
29
#include <qmessagebox.h>
30
#include <qwidgetstack.h>
31
#include <klineedit.h>
35
#include <qobjectlist.h>
36
#include <qcheckbox.h>
37
#include <qfocusdata.h>
38
#include <kiconloader.h>
40
#include "knetworkmanager-vpnservice.h"
41
#include "knetworkmanager-vpnmanager.h"
42
#include "knetworkmanager-vpnauthenticationdialog.h"
43
#include "knetworkmanager-vpn_connection.h"
44
#include "knetworkmanager-connection_setting_vpn.h"
45
#include "knetworkmanager-connection_setting_info.h"
46
#include "knetworkmanager-connection_setting_vpn_properties.h"
48
using namespace ConnectionSettings;
52
* class VPNAuthenticationDialog
55
VPNAuthenticationDialog::VPNAuthenticationDialog(VPNConnection* conn, QWidget* parent, const char* name, bool modal, WFlags fl)
56
: AuthenticationDialog(parent, name, modal, fl)
59
this->setIcon(SmallIcon("encrypted", QIconSet::Automatic));
60
this->setCaption(i18n("VPN Authentication for %1").arg(conn->getInfoSetting()->getName()));
61
labelPixmap->setPixmap(KGlobal::instance()->iconLoader()->loadIcon("encrypted", KIcon::Small, 32));
64
pushOK->setIconSet(SmallIcon("button_ok", QIconSet::Automatic));
65
pushCancel->setIconSet(SmallIcon("button_cancel", QIconSet::Automatic));
67
// we need the last widget in the focus queue
68
QFocusData* foc = focusData();
69
QWidget* lastFocusWidget = foc->last();
71
VPN* vpn = conn->getVPNSetting();
72
VPNService* vpnservice = VPNManager::getVPNService(vpn->getServiceType());
74
// get the appropriate plugin and create the authentication widget
75
VPNPlugin* vpnPlugin = vpnservice->getVPNPlugin();
78
_vpnAuthWidget = vpnPlugin->CreateAuthenticationWidget(widgetStack);
81
_vpnAuthWidget->setVPNData(conn->getVPNSetting()->getRoutes(), conn->getVPNPropertiesSetting()->getData());
82
widgetStack->raiseWidget(_vpnAuthWidget);
87
the widgets inside the authenticationwidget are now in the focus queue
88
==> we can now search the first widget inside the authenticationwidget
89
which has to get the focus
91
QWidget* widget = foc->home();
92
for (int i = 0; i < foc->count(); ++i)
94
if (widget == lastFocusWidget)
96
// the next one is the first widget inside the authwidget
100
widget = foc->next();
106
this->resize(minimumSizeHint());
109
VPNAuthenticationDialog::~VPNAuthenticationDialog()
114
bool VPNAuthenticationDialog::close(bool alsoDelete)
116
// no secrets provided, tell NM
117
_conn->slotSecretsError();
118
return AuthenticationDialog::close(alsoDelete);
121
void VPNAuthenticationDialog::ok()
123
// good, we have new secrets now, update the setting
124
VPNProperties* prop = _conn->getVPNPropertiesSetting();
125
prop->setSecrets(_vpnAuthWidget->getPasswords());
126
_conn->slotSecretsProvided(prop);
130
void VPNAuthenticationDialog::cancel()
134
emit done (true, x, false, false);