diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-10-17 17:38:53 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-10-17 17:38:53 +0000 |
commit | 1e0dd58661c9097fb41218ee7e3515f2d8ba8dac (patch) | |
tree | a263b4ad0c1f7fba6013f5d9854db4cb4962df82 /knetworkmanager-0.8/src/knetworkmanager-vpn_plugin.cpp | |
download | knetworkmanager8-1e0dd58661c9097fb41218ee7e3515f2d8ba8dac.tar.gz knetworkmanager8-1e0dd58661c9097fb41218ee7e3515f2d8ba8dac.zip |
Add dead-ended knetworkmanager 0.8 source
Add copy of same for knetworkmanager 0.9 starting point
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knetworkmanager8@1259314 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'knetworkmanager-0.8/src/knetworkmanager-vpn_plugin.cpp')
-rw-r--r-- | knetworkmanager-0.8/src/knetworkmanager-vpn_plugin.cpp | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/knetworkmanager-0.8/src/knetworkmanager-vpn_plugin.cpp b/knetworkmanager-0.8/src/knetworkmanager-vpn_plugin.cpp new file mode 100644 index 0000000..f56b221 --- /dev/null +++ b/knetworkmanager-0.8/src/knetworkmanager-vpn_plugin.cpp @@ -0,0 +1,132 @@ +/*************************************************************************** + * + * knetworkmanager-vpn_plugin.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa <[email protected]>, <[email protected]> + * Author: Timothy Pearson <[email protected]> + * + * 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 + * + **************************************************************************/ + +// KDE 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> + +// KNM includes +#include "knetworkmanager.h" +#include "knetworkmanager-tray.h" +#include "knetworkmanager-vpn_plugin.h" +#include "dbus/vpnpluginproxy.h" +#include "knetworkmanager-hal_device_proxy.h" +#include "knetworkmanager-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 "knetworkmanager-vpn_plugin.moc" |