Reactivate basic VPN support

pull/1/head
Timothy Pearson 12 years ago
parent 2df5ea4aaf
commit 475d08942f

@ -50,8 +50,7 @@ tde_add_tdeinit_executable( tdenetworkmanager AUTOMOC
SOURCES SOURCES
connection_editor.ui connection_editor.ui
vpnauthentication.ui main.cpp tdenetman.cpp tdenetman-tray.cpp vpnauthentication.ui main.cpp tdenetman.cpp tdenetman-tray.cpp
#tdenetman-vpn_plugin.cpp tdenetman-cellular_device_tray.cpp
tdenetman-cellular_device_tray.cpp #tdenetman-device_tray.cpp
tdenetman-wired_device_tray.cpp tdenetman-wireless_device_tray.cpp tdenetman-wired_device_tray.cpp tdenetman-wireless_device_tray.cpp
tdenetman-wireless_menuitem.cpp tdenetman-menuitem.cpp tdenetman-wireless_menuitem.cpp tdenetman-menuitem.cpp
tdenetman-menu_subhead.cpp tdenetman-menu_subhead.cpp
@ -59,10 +58,10 @@ tde_add_tdeinit_executable( tdenetworkmanager AUTOMOC
tdenetman-wireless_network.cpp tdenetman-wireless_manager.cpp tdenetman-wireless_network.cpp tdenetman-wireless_manager.cpp
tdenetman-connection_editor.cpp tdenetman-connection_editor.cpp
devicetraycomponent.cpp traycomponent.cpp devicetraycomponent.cpp traycomponent.cpp
#tdenetman-plugin.cpp tdenetman-vpnplugin.cpp tdenetman-plugin.cpp tdenetman-vpnplugin.cpp
#tdenetman-pluginmanager.cpp tdenetman-vpnservice.cpp tdenetman-vpnmanager.cpp tdenetman-pluginmanager.cpp tdenetman-vpnservice.cpp tdenetman-vpnmanager.cpp
#tdenetman-vpnauthenticationdialog.cpp tdenetman-vpnauthenticationdialog.cpp
#vpn_tray_component.cpp vpn_tray_component.cpp
EMBED tdenetwork-connection-configwidgets-static #tdenetwork-connection-settings-static EMBED tdenetwork-connection-configwidgets-static #tdenetwork-connection-settings-static
LINK tdecore-shared tdeui-shared kutils-shared ${DBUS_TQT_LIBRARIES} LINK tdecore-shared tdeui-shared kutils-shared ${DBUS_TQT_LIBRARIES}
) )

@ -66,10 +66,12 @@
#include "tdenetman-wired_device_tray.h" #include "tdenetman-wired_device_tray.h"
#include "tdenetman-wireless_device_tray.h" #include "tdenetman-wireless_device_tray.h"
#include "tdenetman-cellular_device_tray.h" #include "tdenetman-cellular_device_tray.h"
#include "vpn_tray_component.h"
#include <stdio.h> #include <stdio.h>
TDENetworkConnectionStatus::TDENetworkConnectionStatus nm_device_state_global; TDENetworkConnectionStatus::TDENetworkConnectionStatus nm_device_state_global = TDENetworkConnectionStatus::Invalid;
TDENetworkConnectionStatus::TDENetworkConnectionStatus current_vpn_state = TDENetworkConnectionStatus::Invalid;
NewSecretsDialog::NewSecretsDialog(TDENetworkConnection *connection, TQWidget * parent, const char * name, bool modal, TQt::WFlags f) NewSecretsDialog::NewSecretsDialog(TDENetworkConnection *connection, TQWidget * parent, const char * name, bool modal, TQt::WFlags f)
: TQDialog(parent, name, modal, f) : TQDialog(parent, name, modal, f)
@ -189,6 +191,23 @@ void Tray::slotOnlineMode()
nm->enableNetworking(true); nm->enableNetworking(true);
} }
void Tray::slotNewVPNConnection()
{
printf("Creating new VPN connection\n\r");
// create a new VPN connection
TDEVPNConnection* conn = new TDEVPNConnection();
// edit the new connection
ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, TQByteArray(), this, "connect_something", false, TQt::WDestructiveClose);
dlg->show();
}
void Tray::slotVPNBannerShow(const TQString& vpnbanner)
{
printf("VPN banner: %s\n\r", vpnbanner.ascii());
KNotifyClient::event(winId(), "knm-nm-vpn-banner", vpnbanner);
}
void Tray::contextMenuAboutToShow (KPopupMenu* menu) void Tray::contextMenuAboutToShow (KPopupMenu* menu)
{ {
TDEGlobalNetworkManager* nm = KGlobal::networkManager(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
@ -243,6 +262,13 @@ void Tray::contextMenuAboutToShow (KPopupMenu* menu)
newConnActionMenu->insert(deviceNewConnAction); newConnActionMenu->insert(deviceNewConnAction);
} }
} }
// New VPN connection option
++it;
KAction * deviceNewConnAction = 0;
TQString menuCaption = "VPN Connection";
TQString actionName = TQString("new_connection_%1").arg("vpn");
deviceNewConnAction = new KAction (menuCaption, 0, TQT_TQOBJECT(this), TQT_SLOT(slotNewVPNConnection()), actionCollection(), actionName);
newConnActionMenu->insert(deviceNewConnAction);
} }
else if ( devices == 1 ) { else if ( devices == 1 ) {
newConnAction = actionCollection ()->action ("new_connection"); newConnAction = actionCollection ()->action ("new_connection");
@ -470,6 +496,33 @@ void Tray::createDeviceTrayComponent(TQString dev)
} }
} }
void Tray::createVPNTrayComponent()
{
bool trayExists = false;
// check if we have already a trayicon for this device
for (TQValueList<TrayComponent*>::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it)
{
VPNTrayComponent* vpn_comp = dynamic_cast<VPNTrayComponent*> (*it);
if (vpn_comp)
{
trayExists = true;
break;
}
}
// create the appropriate device tray icon
if (!trayExists)
{
TrayComponent* devTray = new VPNTrayComponent(this, "vpn_device_tray");
if(devTray)
{
d->trayComponents.append(devTray);
//WILLTODO: sort
}
}
}
void Tray::updateDeviceTrays() void Tray::updateDeviceTrays()
{ {
// create one tray-icon for each device // create one tray-icon for each device
@ -486,6 +539,9 @@ void Tray::updateDeviceTrays()
kdWarning() << k_funcinfo << "got a NULL-Device" << endl; kdWarning() << k_funcinfo << "got a NULL-Device" << endl;
} }
} }
// add the VPN componenet as it is not associated with a device
createVPNTrayComponent();
} }
void Tray::mousePressEvent( TQMouseEvent *e ) void Tray::mousePressEvent( TQMouseEvent *e )
@ -618,13 +674,37 @@ void Tray::trayUiChanged()
void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
{ {
// Get all active connections // Get all active connections
char active_vpn=0;
char found_any_active_connection=0; char found_any_active_connection=0;
TDEGlobalNetworkManager* nm = KGlobal::networkManager(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionList* allconmap;
// get all available VPN Connections
active_vpn = 0;
allconmap = nm->connections();
for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) {
TDEVPNConnection* conn = dynamic_cast<TDEVPNConnection*>(*it);
if (!conn) {
continue;
}
TDENetworkConnectionStatus::TDENetworkConnectionStatus connStatus = nm->checkConnectionStatus(conn->UUID);
if ((connStatus & TDENetworkConnectionStatus::Connected)
|| (connStatus & TDENetworkConnectionStatus::EstablishingLink)
|| (connStatus & TDENetworkConnectionStatus::ConfiguringProtocols)
|| (connStatus & TDENetworkConnectionStatus::Reconnecting)
|| (connStatus & TDENetworkConnectionStatus::VerifyingProtocols)
|| (connStatus & TDENetworkConnectionStatus::NeedAuthorization)
|| (connStatus & TDENetworkConnectionStatus::DependencyWait)) {
// This VPN connection is active!
active_vpn = 1;
}
}
found_any_active_connection = 0; found_any_active_connection = 0;
// Get all active connections // Get all active connections
TDENetworkConnectionList* allconmap = nm->connections(); allconmap = nm->connections();
for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) { for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) {
TDENetworkConnection* conn = (*it); TDENetworkConnection* conn = (*it);
@ -645,6 +725,10 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
// printf("Active connection found\n\r"); // printf("Active connection found\n\r");
// } // }
if ((current_vpn_state & TDENetworkConnectionStatus::Failed) || (current_vpn_state & TDENetworkConnectionStatus::Disconnected)) {
active_vpn = 0;
}
// stop the old movie to avoid unnecessary wakups // stop the old movie to avoid unnecessary wakups
DeviceTrayComponent * dtc = d->foregroundTrayComponent; DeviceTrayComponent * dtc = d->foregroundTrayComponent;
@ -652,35 +736,77 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
movie()->pause(); movie()->pause();
} }
if ((dtc) && (found_any_active_connection == 1)) { if (active_vpn == 0) {
if (!dtc->movieForState(state).isNull()) if ((dtc) && (found_any_active_connection == 1)) {
{ if (!dtc->movieForState(state).isNull())
// animation desired {
int frame = -1; // animation desired
if (movie()) { int frame = -1;
frame = movie()->frameNumber(); if (movie()) {
frame = movie()->frameNumber();
}
// set the movie
setMovie(dtc->movieForState(state));
// start at the same frame as the movie before
if (frame > 0) {
movie()->step(frame);
}
// start the animation
movie()->unpause();
} }
else if (!dtc->pixmapForState(state).isNull()) {
// set the movie setPixmap(dtc->pixmapForState(state));
setMovie(dtc->movieForState(state)); }
else {
// start at the same frame as the movie before setPixmap(loadIcon("tdenetworkmanager"));
if (frame > 0) {
movie()->step(frame);
} }
// start the animation
movie()->unpause();
}
else if (!dtc->pixmapForState(state).isNull()) {
setPixmap(dtc->pixmapForState(state));
} }
else { else {
setPixmap(loadIcon("tdenetworkmanager")); setPixmap(loadIcon("tdenetworkmanager"));
} }
} }
else { else {
setPixmap(loadIcon("tdenetworkmanager")); printf("VPN state: %d\n\r", current_vpn_state);
//printf("Activated is: %d\n\r", TDENetworkConnectionStatus::Connected);
// stop the old movie to avoid unnecessary wakups
DeviceTrayComponent * dtc = d->foregroundTrayComponent;
if (movie())
movie()->pause();
if (dtc) {
if (current_vpn_state & TDENetworkConnectionStatus::Connected) {
setPixmap(loadIcon("nm_device_vpn"));
}
if ((current_vpn_state & TDENetworkConnectionStatus::EstablishingLink)
|| (current_vpn_state & TDENetworkConnectionStatus::NeedAuthorization)
|| (current_vpn_state & TDENetworkConnectionStatus::ConfiguringProtocols)
|| (current_vpn_state & TDENetworkConnectionStatus::VerifyingProtocols)) {
int frame = -1;
if (movie())
frame = movie()->frameNumber();
// set the movie
if ((current_vpn_state & TDENetworkConnectionStatus::EstablishingLink)
|| (current_vpn_state & TDENetworkConnectionStatus::NeedAuthorization)) {
setMovie(TQMovie(KGlobal::iconLoader()->moviePath("nm_stage02_connecting_vpn", KIcon::Panel)));
}
if ((current_vpn_state & TDENetworkConnectionStatus::ConfiguringProtocols)
|| (current_vpn_state & TDENetworkConnectionStatus::VerifyingProtocols)) {
setMovie(TQMovie(KGlobal::iconLoader()->moviePath("nm_stage03_connecting_vpn", KIcon::Panel)));
}
// start at the same frame as the movie before
if (frame > 0)
movie()->step(frame);
// start the animation
movie()->unpause();
}
}
} }
nm_device_state_global = state; nm_device_state_global = state;

@ -94,6 +94,9 @@ class Tray : public KSystemTray
void slotUpdateDeviceState(); void slotUpdateDeviceState();
void slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TDENetworkConnectionStatus::TDENetworkConnectionStatus prevState, TQString hwAddress); void slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TDENetworkConnectionStatus::TDENetworkConnectionStatus prevState, TQString hwAddress);
void slotNewVPNConnection();
void slotVPNBannerShow(const TQString& vpnbanner);
protected slots: protected slots:
void updateDeviceTrays(); void updateDeviceTrays();
void slotAddDeviceTrayComponent(TQString); void slotAddDeviceTrayComponent(TQString);
@ -112,6 +115,7 @@ class Tray : public KSystemTray
void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus); void updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus); void updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus);
void mousePressEvent(TQMouseEvent *e); void mousePressEvent(TQMouseEvent *e);
void createVPNTrayComponent();
void createDeviceTrayComponent(TQString); void createDeviceTrayComponent(TQString);
void enterEvent(TQEvent*); void enterEvent(TQEvent*);
void connectTrayDeviceManager(); void connectTrayDeviceManager();

@ -1,132 +0,0 @@
/***************************************************************************
*
* tdenetman-vpn_plugin.cpp - A NetworkManager frontend for TDE
*
* Copyright (C) 2005, 2006 Novell, Inc.
*
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
* Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
**************************************************************************/
// TDE includes
#include <kdebug.h>
// TQt includes
#include <tqhostaddress.h>
// TQT_DBus includes
#include <tqdbuserror.h>
#include <tqdbusconnection.h>
#include <tqdbusobjectpath.h>
// NM includes
#include <NetworkManager.h>
#include <NetworkManagerVPN.h>
// TDENM includes
#include "tdenetman.h"
#include "tdenetman-tray.h"
#include "tdenetman-vpn_plugin.h"
#include "dbus/vpnpluginproxy.h"
#include "tdenetman-hal_device_proxy.h"
#include "tdenetman-nm_proxy.h"
#if !defined(NM_CHECK_VERSION)
#define NM_CHECK_VERSION(x,y,z) 0
#endif
unsigned int current_vpn_state = 0;
extern NMDeviceState nm_device_state_global;
extern TQT_DBusObjectPath vpn_attempt_this_conn;
unsigned char vpn_new_credentials_needed = 0;
class VPNDBUSPluginPrivate
{
public:
VPNDBUSPluginPrivate(TQString service, TQString obj_path)
: nmVPNDBUS(service, obj_path)
{}
~VPNDBUSPluginPrivate() {}
DBus::VPNPluginProxy nmVPNDBUS;
};
TQ_UINT32 VPNDBUSPlugin::getState()
{
TQT_DBusError err;
return d->nmVPNDBUS.getState(err);
}
void VPNDBUSPlugin::slotStateChanged(TQ_UINT32 state)
{
current_vpn_state = state+1;
Tray* tray = Tray::getInstance();
tray->slotUpdateDeviceState(nm_device_state_global);
//emit StateChanged((NMDeviceState)state);
}
void VPNDBUSPlugin::slotLoginBanner(const TQString& banner)
{
Tray* tray = Tray::getInstance();
tray->slotVPNBannerShow(banner);
}
void VPNDBUSPlugin::slotFailure(TQ_UINT32 failure_reason)
{
printf("VPN failure code %d\n\r", failure_reason);
if ((failure_reason == 0) || (failure_reason == 1) || (failure_reason == 2)) {
// Try to connect again using cached information; request new login though
printf("Reactivate VPN connection on default device\n\r");
vpn_new_credentials_needed = 1;
int id;
TQT_DBusError err;
NMProxy* nm = NMProxy::getInstance();
TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection();
TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn);
#if NM_CHECK_VERSION(0,8,992)
nm->ActivateConnectionAsync(id,"org.freedesktop.NetworkManagerUserSettings", vpn_attempt_this_conn, device, act_conn, err);
#else
nm->ActivateConnectionAsync(id,NM_DBUS_SERVICE_USER_SETTINGS, vpn_attempt_this_conn, device, act_conn, err);
#endif
}
}
VPNDBUSPlugin::VPNDBUSPlugin ()
: TQObject()
{
d = new VPNDBUSPluginPrivate(NM_VPN_DBUS_PLUGIN_INTERFACE, NM_VPN_DBUS_PLUGIN_PATH);
d->nmVPNDBUS.setConnection(TQT_DBusConnection::systemBus());
// Connect the state changed signal to the handler
connect(&(d->nmVPNDBUS), TQT_SIGNAL(StateChanged(TQ_UINT32)), this, TQT_SLOT(slotStateChanged(TQ_UINT32)));
// Connect the failure signal to the handler
connect(&(d->nmVPNDBUS), TQT_SIGNAL(Failure(TQ_UINT32)), this, TQT_SLOT(slotFailure(TQ_UINT32)));
// And the banner signal
connect(&(d->nmVPNDBUS), TQT_SIGNAL(LoginBanner(const TQString&)), this, TQT_SLOT(slotLoginBanner(const TQString&)));
}
VPNDBUSPlugin::~VPNDBUSPlugin ()
{
delete d;
}
#include "tdenetman-vpn_plugin.moc"

@ -1,62 +0,0 @@
/***************************************************************************
*
* tdenetman-wired_device.h - A NetworkManager frontend for TDE
*
* Copyright (C) 2005, 2006 Novell, Inc.
*
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
* Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
**************************************************************************/
#ifndef KNETWORKMANAGER_VPNDBUSPLUGIN_H
#define KNETWORKMANAGER_VPNDBUSPLUGIN_H
// std includes
#include <stdint.h>
// TDENM includes
#include "tdenetman.h"
class TDENetworkManager;
class VPNDBUSPluginPrivate;
class VPNDBUSPlugin : public TQObject
{
Q_OBJECT
public:
VPNDBUSPlugin ();
~VPNDBUSPlugin ();
TQ_UINT32 getState();
private:
VPNDBUSPluginPrivate * d;
// signals:
// void StateChanged(NMDeviceState);
public slots:
void slotFailure(TQ_UINT32);
void slotStateChanged(TQ_UINT32);
void slotLoginBanner(const TQString&);
// void slotDeactivate();
};
#endif /* KNETWORKMANAGER_VPNDBUSPLUGIN_H */

@ -38,32 +38,20 @@
#include <kiconloader.h> #include <kiconloader.h>
#include <tqmap.h> #include <tqmap.h>
#include <tqdbusobjectpath.h>
#include <tqdbuserror.h>
#include "tdenetman-vpnservice.h" #include "tdenetman-vpnservice.h"
#include "tdenetman-vpnmanager.h" #include "tdenetman-vpnmanager.h"
#include "tdenetman-vpnauthenticationdialog.h" #include "tdenetman-vpnauthenticationdialog.h"
#include "tdenetman-vpn_connection.h"
#include "tdenetman-nm_proxy.h"
#include "tdenetman-connection_setting_vpn.h"
#include "tdenetman-connection_setting_info.h"
extern TQT_DBusObjectPath vpn_attempt_this_conn;
using namespace ConnectionSettings;
/* /*
* class VPNAuthenticationDialog * class VPNAuthenticationDialog
* *
*/ */
VPNAuthenticationDialog::VPNAuthenticationDialog(VPNConnection* conn, TQWidget* parent, const char* name, bool modal, WFlags fl) VPNAuthenticationDialog::VPNAuthenticationDialog(TDEVPNConnection* conn, TQWidget* parent, const char* name, bool modal, WFlags fl)
: AuthenticationDialog(parent, name, modal, fl) : AuthenticationDialog(parent, name, modal, fl)
, _conn(conn) , _conn(conn)
{ {
this->setIcon(SmallIcon("encrypted", TQIconSet::Automatic)); this->setIcon(SmallIcon("encrypted", TQIconSet::Automatic));
this->setCaption(i18n("VPN Authentication for %1").arg(conn->getInfoSetting()->getName())); this->setCaption(i18n("VPN Authentication for %1").arg(conn->friendlyName));
labelPixmap->setPixmap(KGlobal::instance()->iconLoader()->loadIcon("encrypted", KIcon::Small, 32)); labelPixmap->setPixmap(KGlobal::instance()->iconLoader()->loadIcon("encrypted", KIcon::Small, 32));
// nice icons // nice icons
@ -74,8 +62,8 @@ VPNAuthenticationDialog::VPNAuthenticationDialog(VPNConnection* conn, TQWidget*
TQFocusData* foc = focusData(); TQFocusData* foc = focusData();
TQWidget* lastFocusWidget = foc->last(); TQWidget* lastFocusWidget = foc->last();
VPN* vpn = conn->getVPNSetting(); TDEVPNConnection* vpn = conn;
VPNService* vpnservice = VPNManager::getVPNService(vpn->getServiceType()); VPNService* vpnservice = VPNManager::getVPNService(vpn->vpnPluginID);
// get the appropriate plugin and create the authentication widget // get the appropriate plugin and create the authentication widget
VPNPlugin* vpnPlugin = vpnservice->getVPNPlugin(); VPNPlugin* vpnPlugin = vpnservice->getVPNPlugin();
@ -84,7 +72,7 @@ VPNAuthenticationDialog::VPNAuthenticationDialog(VPNConnection* conn, TQWidget*
_vpnAuthWidget = vpnPlugin->CreateAuthenticationWidget(widgetStack); _vpnAuthWidget = vpnPlugin->CreateAuthenticationWidget(widgetStack);
if (_vpnAuthWidget) if (_vpnAuthWidget)
{ {
_vpnAuthWidget->setVPNData(conn->getVPNSetting()->getRoutes(), conn->getVPNSetting()->getData()); _vpnAuthWidget->setVPNData(conn->ipConfig.routeConfigurations, conn->pluginData, conn->pluginSecrets);
widgetStack->raiseWidget(_vpnAuthWidget); widgetStack->raiseWidget(_vpnAuthWidget);
} }
} }
@ -119,37 +107,11 @@ VPNAuthenticationDialog::~VPNAuthenticationDialog()
bool VPNAuthenticationDialog::close(bool alsoDelete) bool VPNAuthenticationDialog::close(bool alsoDelete)
{ {
// no secrets provided, tell NM
_conn->slotSecretsError();
return AuthenticationDialog::close(alsoDelete); return AuthenticationDialog::close(alsoDelete);
} }
void VPNAuthenticationDialog::ok() void VPNAuthenticationDialog::ok()
{ {
// Good, we have new secrets now, update the settings
TQMap<TQString, TQString> mypwds;
mypwds = _vpnAuthWidget->getPasswords();
ConnectionSetting* propcore = _conn->getVPNSettingConnectionCore();
SettingsMap othersettingsmap = propcore->toMap();
// Pull the username and gateway out of mypwds to stuff in the NM standard settings matrix
othersettingsmap.insert("user", TQT_DBusData::fromString(mypwds["user"]));
mypwds.erase("user");
othersettingsmap.insert("domain", TQT_DBusData::fromString(mypwds["domain"]));
mypwds.erase("domain");
// othersettingsmap.erase("Commit to disk");
// if (chkStorePasswordsPermanent->isChecked() == true) {
// othersettingsmap.insert("Commit to disk", TQT_DBusData::fromString("true"));
// }
// else {
// othersettingsmap.insert("Commit to disk", TQT_DBusData::fromString("false"));
// }
propcore->fromMap(othersettingsmap);
VPN* prop = dynamic_cast<VPN*>(propcore);
prop->setSecrets(mypwds);
_conn->slotSecretsProvided(prop);
TQDialog::done(0); TQDialog::done(0);
} }
@ -169,9 +131,6 @@ void VPNAuthenticationDialog::cancel()
printf("Attempting to deactivate VPN connection...\n\r"); printf("Attempting to deactivate VPN connection...\n\r");
// Disconnect the attempted connection
_conn->slotSecretsError();
// Quit the dialog // Quit the dialog
TQDialog::done(1); TQDialog::done(1);
} }

@ -30,6 +30,9 @@
#include <kprocess.h> #include <kprocess.h>
#include <kconfig.h> #include <kconfig.h>
#include <tdehardwaredevices.h>
#include <tdenetworkconnections.h>
#include "tdenetman.h" #include "tdenetman.h"
#include "vpnauthentication.h" #include "vpnauthentication.h"
#include "tdenetman-vpnplugin.h" #include "tdenetman-vpnplugin.h"
@ -39,17 +42,12 @@ class TDENetworkManager;
class ManageConnectionsDialog; class ManageConnectionsDialog;
class VPNService; class VPNService;
namespace ConnectionSettings
{
class VPNConnection;
}
class VPNAuthenticationDialog : public AuthenticationDialog class VPNAuthenticationDialog : public AuthenticationDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
VPNAuthenticationDialog(ConnectionSettings::VPNConnection* conn = NULL, TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); VPNAuthenticationDialog(TDEVPNConnection* conn = NULL, TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0);
~VPNAuthenticationDialog(); ~VPNAuthenticationDialog();
void setPasswords(TQString name, TQString value); void setPasswords(TQString name, TQString value);
virtual bool close(bool); virtual bool close(bool);
@ -60,7 +58,7 @@ class VPNAuthenticationDialog : public AuthenticationDialog
private: private:
VPNAuthenticationWidget* _vpnAuthWidget; VPNAuthenticationWidget* _vpnAuthWidget;
ConnectionSettings::VPNConnection* _conn; TDEVPNConnection* _conn;
signals: signals:
void done(bool, TQStringList &, bool, bool); void done(bool, TQStringList &, bool, bool);

@ -41,22 +41,20 @@
VPNServiceList VPNServiceList
VPNManager::getVPNServices () VPNManager::getVPNServices ()
{ {
bool status = false;
VPNServiceList list; VPNServiceList list;
TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files); TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files);
TQStringList services = serviceDir.entryList ().grep (".name", true); TQStringList services = serviceDir.entryList ().grep (".name", true);
if (services.count () > 0) if (services.count () > 0)
{ {
status = true;
// read in all available Services // read in all available Services
for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) { for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) {
TQString service = SERVICE_DIR + TQString ("/") + *i; TQString service = SERVICE_DIR + TQString ("/") + *i;
KConfig* kconfig = new KConfig (service, true, true, "config"); KConfig* kconfig = new KConfig (service, true, true, "config");
kconfig->setGroup ("VPN Connection"); kconfig->setGroup ("VPN Connection");
kdDebug() << "VPN Service " << kconfig->readEntry ("name", TQString()).ascii() << endl; kdDebug() << "VPN Service " << kconfig->readEntry ("name", TQString()).ascii() << endl;
// create new VPNService Object // create new VPNService Object
VPNService* vpnservice = new VPNService(kconfig->readEntry ("name", TQString()), kconfig->readEntry ("service", TQString()), TQT_TQOBJECT(TDENetworkManager::getInstance())); VPNService* vpnservice = new VPNService(kconfig->readEntry ("name", TQString()), kconfig->readEntry ("service", TQString()), TQT_TQOBJECT(TDENetworkManager::getInstance()));
@ -74,15 +72,13 @@ kdDebug() << "VPN Service " << kconfig->readEntry ("name", TQString()).ascii() <
VPNService* VPNService*
VPNManager::getVPNService(TQString service_type) VPNManager::getVPNService(TQString service_type)
{ {
bool status = false;
VPNServiceList list; VPNServiceList list;
TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files); TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files);
TQStringList services = serviceDir.entryList ().grep (".name", true); TQStringList services = serviceDir.entryList ().grep (".name", true);
if (services.count () > 0) if (services.count () > 0)
{ {
status = true;
// read in all available Services // read in all available Services
for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) { for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) {
TQString service = SERVICE_DIR + TQString ("/") + *i; TQString service = SERVICE_DIR + TQString ("/") + *i;

@ -26,9 +26,6 @@
#ifndef KNETWORKMANAGER_VPNMANAGER_H #ifndef KNETWORKMANAGER_VPNMANAGER_H
#define KNETWORKMANAGER_VPNMANAGER_H #define KNETWORKMANAGER_VPNMANAGER_H
#include <NetworkManager/NetworkManager.h>
#include <NetworkManager/NetworkManagerVPN.h>
#include <tqobject.h> #include <tqobject.h>
#include <tqguardedptr.h> #include <tqguardedptr.h>

@ -41,7 +41,7 @@ VPNConfigWidget::VPNConfigWidget(TQWidget* parent, const char* name)
} }
void VPNConfigWidget::setVPNData(const TQStringList& /*routes*/, const TQMap<TQString, TQString>& /*properties*/) void VPNConfigWidget::setVPNData(TDENetworkSingleRouteConfigurationList& /*routes*/, TDENetworkSettingsMap& /*properties*/, TDENetworkSettingsMap& /*secrets*/)
{ {
} }
@ -91,7 +91,7 @@ void VPNAuthenticationWidget::setPasswords(TQString name, TQString value)
} }
void VPNAuthenticationWidget::setVPNData(const TQStringList& /*routes*/, const TQMap<TQString, TQString>& /*properties*/) void VPNAuthenticationWidget::setVPNData(TDENetworkSingleRouteConfigurationList& /*routes*/, TDENetworkSettingsMap& /*properties*/, TDENetworkSettingsMap& /*secrets*/)
{ {
} }

@ -27,8 +27,10 @@
#include <tqwidget.h> #include <tqwidget.h>
#include <tqmap.h> #include <tqmap.h>
#include <tqdbusdata.h>
#include <tqdbusvariant.h> #include <tdehardwaredevices.h>
#include <tdenetworkconnections.h>
#include "tdenetman-plugin.h" #include "tdenetman-plugin.h"
#define KNETWORKMANAGER_VPNPLUGIN "TDENetworkManager/VPNPlugin" #define KNETWORKMANAGER_VPNPLUGIN "TDENetworkManager/VPNPlugin"
@ -41,7 +43,7 @@ class VPNConfigWidget : public TQWidget
virtual ~VPNConfigWidget(); virtual ~VPNConfigWidget();
VPNConfigWidget(TQWidget* parent = NULL, const char* name = NULL); VPNConfigWidget(TQWidget* parent = NULL, const char* name = NULL);
virtual void setVPNData(const TQStringList&, const TQMap<TQString,TQString>&); virtual void setVPNData(TDENetworkSingleRouteConfigurationList&, TDENetworkSettingsMap&, TDENetworkSettingsMap&);
virtual TQMap<TQString, TQString> getVPNProperties(); virtual TQMap<TQString, TQString> getVPNProperties();
virtual TQStringList getVPNRoutes(); virtual TQStringList getVPNRoutes();
virtual bool hasChanged(); virtual bool hasChanged();
@ -56,7 +58,7 @@ class VPNAuthenticationWidget : public TQWidget
virtual ~VPNAuthenticationWidget(); virtual ~VPNAuthenticationWidget();
VPNAuthenticationWidget(TQWidget* parent = NULL, const char* name = NULL); VPNAuthenticationWidget(TQWidget* parent = NULL, const char* name = NULL);
virtual void setVPNData(const TQStringList&, const TQMap<TQString, TQString>&); virtual void setVPNData(TDENetworkSingleRouteConfigurationList&, TDENetworkSettingsMap&, TDENetworkSettingsMap&);
virtual TQMap<TQString, TQString> getPasswords(); virtual TQMap<TQString, TQString> getPasswords();
virtual void setPasswords(TQString value, TQString data); virtual void setPasswords(TQString value, TQString data);
virtual bool needsUserInteraction(); virtual bool needsUserInteraction();

@ -26,9 +26,6 @@
#ifndef KNETWORKMANAGER_VPN_SERVICE_H #ifndef KNETWORKMANAGER_VPN_SERVICE_H
#define KNETWORKMANAGER_VPN_SERVICE_H #define KNETWORKMANAGER_VPN_SERVICE_H
#include <NetworkManager/NetworkManager.h>
#include <NetworkManager/NetworkManagerVPN.h>
#include <tqobject.h> #include <tqobject.h>
#include <tqguardedptr.h> #include <tqguardedptr.h>

@ -35,12 +35,7 @@
#include "vpn_tray_component.h" #include "vpn_tray_component.h"
#include "tdenetman-menuitem.h" #include "tdenetman-menuitem.h"
#include "tdenetman-menu_subhead.h" #include "tdenetman-menu_subhead.h"
#include "tdenetman-connection_store.h"
#include "tdenetman-vpn_connection.h"
#include "tdenetman-nm_proxy.h"
#include "tdenetman-connection_setting_info.h"
#include "tdenetman-connection_setting_vpn.h"
#include "tdenetman-connection_settings_dialog.h" #include "tdenetman-connection_settings_dialog.h"
#include <stdio.h> #include <stdio.h>
@ -48,11 +43,14 @@ using namespace ConnectionSettings;
void VPNTrayComponent::slotShowNewConnectionDialog() void VPNTrayComponent::slotShowNewConnectionDialog()
{ {
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
// create a new VPN connection // create a new VPN connection
Connection* conn = new VPNConnection(); TDEVPNConnection* conn = new TDEVPNConnection();
nm->loadConnectionAllowedValues(conn);
// edit the new connection // edit the new connection
ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, NULL, tray(), "connect_something", false, TQt::WDestructiveClose); ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, true, TQByteArray(), tray(), "connect_something", false, TQt::WDestructiveClose);
dlg->show(); dlg->show();
} }
@ -60,70 +58,80 @@ void VPNTrayComponent::slotShowNewConnectionDialog()
void VPNTrayComponent::addMenuItems(KPopupMenu* menu) void VPNTrayComponent::addMenuItems(KPopupMenu* menu)
{ {
int inactive_vpn_connections = 0; int inactive_vpn_connections = 0;
char vpn_found; char vpn_found = 0;
char any_vpn_found = 0; char any_vpn_found = 0;
ConnectionStore* connectionStore = ConnectionStore::getInstance();
// Get all active connections // Get all active connections
NMProxy* nm = NMProxy::getInstance(); TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TQValueList<TQPair<ConnectionSettings::Connection*, Device*> > map = nm->getActiveConnectionsMap();
// get all available VPN Connections // get all available VPN Connections
TQValueList<Connection*> connections = connectionStore->getConnections(NM_SETTING_VPN_SETTING_NAME); TQPopupMenu* popup = NULL;
if (!connections.empty()) TDENetworkConnectionList* allconmap = nm->connections();
{ for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) {
TQPopupMenu* popup = new TQPopupMenu(menu); TDEVPNConnection* conn = dynamic_cast<TDEVPNConnection*>(*it);
for (TQValueList<Connection*>::iterator it = connections.begin(); it != connections.end(); ++it) if (!conn) {
{ continue;
VPNConnection* vpnconn = dynamic_cast<VPNConnection*>(*it); }
if (vpnconn)
{ if (!popup) {
// VPN connection found :) popup = new TQPopupMenu(menu);
Info* info = vpnconn->getInfoSetting(); }
// lets create a nice name for this connection TQString title = conn->friendlyName;
if (info)
{
TQString title = info->getName();
NetworkMenuItem* item = new NetworkMenuItem(NULL, vpnconn, TQT_TQOBJECT(menu)); NetworkMenuItem* item = new NetworkMenuItem(NULL, conn->UUID, TQT_TQOBJECT(menu));
vpn_found = 0; vpn_found = 0;
for (TQValueList<TQPair<ConnectionSettings::Connection*, Device*> >::Iterator it = map.begin(); it != map.end(); ++it) TDENetworkConnectionStatus::TDENetworkConnectionStatus connStatus = nm->checkConnectionStatus(conn->UUID);
{ if ((connStatus & TDENetworkConnectionStatus::Connected)
ConnectionSettings::GenericConnection* conn = dynamic_cast<ConnectionSettings::GenericConnection*>((*it).first); || (connStatus & TDENetworkConnectionStatus::EstablishingLink)
|| (connStatus & TDENetworkConnectionStatus::ConfiguringProtocols)
if (conn) { || (connStatus & TDENetworkConnectionStatus::Reconnecting)
if (strcmp(info->getName(), conn->getInfoSetting()->getName()) == 0) { || (connStatus & TDENetworkConnectionStatus::VerifyingProtocols)
vpn_found = 1; || (connStatus & TDENetworkConnectionStatus::NeedAuthorization)
any_vpn_found = 1; || (connStatus & TDENetworkConnectionStatus::DependencyWait)) {
} // This VPN connection is active!
} vpn_found = 1;
} any_vpn_found = 1;
}
if (vpn_found == 1) {
printf("Active VPN connection found\n\r"); if (vpn_found == 1) {
} printf("Active VPN connection found\n\r");
else { }
int id = popup->insertItem(SmallIcon ("encrypted", TQIconSet::Automatic), title, item, TQT_SLOT(slotActivate())); else {
inactive_vpn_connections++; popup->insertItem(SmallIcon ("encrypted", TQIconSet::Automatic), title, item, TQT_SLOT(slotActivate()));
} inactive_vpn_connections++;
//menu->setItemChecked(id, ((*it) == active_conn));
}
}
} }
TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection(); //menu->setItemChecked(id, ((*it) == active_conn));
TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); }
if (popup) {
// At least one VPN connection is defined on this system
if (any_vpn_found == 1) { if (any_vpn_found == 1) {
inactive_vpn_connections = 0; inactive_vpn_connections = 0;
} }
if (device.isNull()) { #if 0
// FIXME
// NetworkManager is rather stupid and won't let us activate a VPN connection if it doesn't manage the backend connection (!?!?!?)
// When/if this limitation is removed, uncomment the following code block!
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags backendStatus = nm->backendStatus();
if ((backendStatus & TDENetworkGlobalManagerFlags::Connected)
|| (backendStatus & TDENetworkGlobalManagerFlags::LinkLocalAccess)
|| (backendStatus & TDENetworkGlobalManagerFlags::SiteLocalAccess)
|| (backendStatus & TDENetworkGlobalManagerFlags::GlobalAccess)) {
// We have network access of some kind
}
else {
inactive_vpn_connections = 0;
}
#else
TQStringList defaultNetworkDevices = nm->defaultNetworkDevices();
if (defaultNetworkDevices.count() <= 0) {
inactive_vpn_connections = 0; inactive_vpn_connections = 0;
} }
#endif
if (inactive_vpn_connections > 0) { if (inactive_vpn_connections > 0) {
menu->insertItem(SmallIcon ("encrypted", TQIconSet::Automatic), i18n("Start VPN connection"), popup); menu->insertItem(SmallIcon ("encrypted", TQIconSet::Automatic), i18n("Start VPN connection"), popup);

Loading…
Cancel
Save