~ubuntu-branches/ubuntu/lucid/knetworkmanager/lucid

« back to all changes in this revision

Viewing changes to knetworkmanager/src/knetworkmanager-vpnauthenticationdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-09-26 12:40:26 UTC
  • mfrom: (1.2.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080926124026-t5fr920l4lf2l6hz
Tags: 1:0.7svn864988-0ubuntu1
New upstream snapshot, now works with current NM API, 
closes LP: #259278

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *
3
 
 * knetworkmanager-vpnauthenticationdialog.cpp - A NetworkManager frontend for KDE 
4
 
 *
5
 
 * Copyright (C) 2006 Novell, Inc.
6
 
 *
7
 
 * Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
8
 
 *
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.
13
 
 *
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.
18
 
 * 
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
22
 
 *
23
 
 **************************************************************************/
24
 
 
25
 
#include <stdlib.h>
26
 
#include <kpushbutton.h>
27
 
#include <qbuttongroup.h>
28
 
#include <qcombobox.h>
29
 
#include <qmessagebox.h>
30
 
#include <qwidgetstack.h>
31
 
#include <klineedit.h>
32
 
#include <qlabel.h>
33
 
#include <klocale.h>
34
 
#include <kdebug.h>
35
 
#include <qobjectlist.h>
36
 
#include <qcheckbox.h>
37
 
#include <qfocusdata.h>
38
 
#include <kiconloader.h>
39
 
 
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"
47
 
 
48
 
using namespace ConnectionSettings;
49
 
 
50
 
 
51
 
/*
52
 
 * class VPNAuthenticationDialog
53
 
 *
54
 
 */
55
 
VPNAuthenticationDialog::VPNAuthenticationDialog(VPNConnection* conn, QWidget* parent, const char* name, bool modal, WFlags fl)
56
 
        : AuthenticationDialog(parent, name, modal, fl)
57
 
        , _conn(conn)
58
 
{
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));
62
 
 
63
 
        // nice icons
64
 
        pushOK->setIconSet(SmallIcon("button_ok", QIconSet::Automatic));
65
 
        pushCancel->setIconSet(SmallIcon("button_cancel", QIconSet::Automatic));
66
 
 
67
 
        // we need the last widget in the focus queue
68
 
        QFocusData* foc = focusData();
69
 
        QWidget* lastFocusWidget = foc->last();
70
 
 
71
 
        VPN* vpn = conn->getVPNSetting();
72
 
        VPNService* vpnservice = VPNManager::getVPNService(vpn->getServiceType());
73
 
        
74
 
        // get the appropriate plugin and create the authentication widget
75
 
        VPNPlugin* vpnPlugin = vpnservice->getVPNPlugin();
76
 
        if (vpnPlugin)
77
 
        {
78
 
                _vpnAuthWidget = vpnPlugin->CreateAuthenticationWidget(widgetStack);
79
 
                if (_vpnAuthWidget)
80
 
                {
81
 
                        _vpnAuthWidget->setVPNData(conn->getVPNSetting()->getRoutes(), conn->getVPNPropertiesSetting()->getData());
82
 
                        widgetStack->raiseWidget(_vpnAuthWidget);
83
 
                }
84
 
        }
85
 
        
86
 
        /*
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
90
 
        */
91
 
        QWidget* widget = foc->home();
92
 
        for (int i = 0; i < foc->count(); ++i)
93
 
        {
94
 
                if (widget == lastFocusWidget)
95
 
                {
96
 
                        // the next one is the first widget inside the authwidget
97
 
                        widget = foc->next();
98
 
                        break;
99
 
                }
100
 
                widget = foc->next();
101
 
        }
102
 
        if (widget)
103
 
                widget->setFocus();
104
 
 
105
 
        // resize
106
 
        this->resize(minimumSizeHint());
107
 
}
108
 
 
109
 
VPNAuthenticationDialog::~VPNAuthenticationDialog()
110
 
{
111
 
        
112
 
}
113
 
 
114
 
bool VPNAuthenticationDialog::close(bool alsoDelete)
115
 
{
116
 
        // no secrets provided, tell NM
117
 
        _conn->slotSecretsError();
118
 
        return AuthenticationDialog::close(alsoDelete);
119
 
}
120
 
 
121
 
void VPNAuthenticationDialog::ok()
122
 
{
123
 
        // good, we have new secrets now, update the setting
124
 
        VPNProperties* prop = _conn->getVPNPropertiesSetting();
125
 
        prop->setSecrets(_vpnAuthWidget->getPasswords());
126
 
        _conn->slotSecretsProvided(prop);
127
 
        QDialog::done(0);
128
 
}
129
 
 
130
 
void VPNAuthenticationDialog::cancel()
131
 
{
132
 
/*
133
 
        QStringList x;
134
 
        emit done (true, x, false, false);
135
 
        QDialog::done(1);*/
136
 
}
137