Commit 5c46be71 authored by Dan Williams's avatar Dan Williams
Browse files

2005-09-07 Dan Williams <dcbw@redhat.com>

	* The great VPN Manager rewrite of 2005


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@946 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 88e3591a
2005-09-07 Dan Williams <dcbw@redhat.com>
* The great VPN Manager rewrite of 2005
2005-09-07 Christopher Aillon <caillon@redhat.com>
* gnome/applet/menu-items.c:
......
......@@ -192,6 +192,22 @@ typedef enum NMVPNState
} NMVPNState;
/*
* VPN connection activation stages
*/
typedef enum NMVPNActStage
{
NM_VPN_ACT_STAGE_UNKNOWN = 0,
NM_VPN_ACT_STAGE_DISCONNECTED,
NM_VPN_ACT_STAGE_PREPARE,
NM_VPN_ACT_STAGE_CONNECT,
NM_VPN_ACT_STAGE_IP_CONFIG_GET,
NM_VPN_ACT_STAGE_ACTIVATED,
NM_VPN_ACT_STAGE_FAILED,
NM_VPN_ACT_STAGE_CANCELED
} NMVPNActStage;
/*
* Device activation stages
*/
......
......@@ -36,43 +36,19 @@
static void nmwa_free_vpn_connections (NMWirelessApplet *applet);
/*
* nmwa_dbus_vpn_get_active_vpn_connection
*
* Get the active VPN connection from the dbus side of the applet
*
*/
VPNConnection *nmwa_dbus_vpn_get_active_vpn_connection (NMWirelessApplet *applet)
{
GSList *elt;
g_return_val_if_fail (applet != NULL, NULL);
for (elt = applet->vpn_connections; elt; elt = g_slist_next (elt))
{
VPNConnection *vpn = (VPNConnection*) elt->data;
NMVPNState vpn_state = nmwa_vpn_connection_get_state (vpn);
if (vpn_state == NM_VPN_STATE_STARTED)
return vpn;
}
return NULL;
}
/*
* nmwa_dbus_vpn_update_vpn_connection_state
*
* Sets the state for a dbus vpn connection and schedules a copy to the applet gui.
*/
void nmwa_dbus_vpn_update_vpn_connection_state (NMWirelessApplet *applet, const char *vpn_name, NMVPNState vpn_state)
void nmwa_dbus_vpn_update_vpn_connection_state (NMWirelessApplet *applet, const char *vpn_name, NMVPNActStage vpn_state)
{
VPNConnection *vpn;
g_return_if_fail (applet != NULL);
vpn = nmwa_vpn_connection_find_by_name (applet->vpn_connections, vpn_name);
if (vpn != NULL)
if ((vpn = nmwa_vpn_connection_find_by_name (applet->vpn_connections, vpn_name)))
nmwa_vpn_connection_set_state (vpn, vpn_state);
}
......@@ -106,7 +82,7 @@ static void nmwa_dbus_vpn_properties_cb (DBusPendingCall *pcall, void *user_data
const char * name;
const char * user_name;
const char * service;
NMVPNState state;
NMVPNActStage state;
dbus_uint32_t state_int;
g_return_if_fail (pcall != NULL);
......@@ -130,7 +106,7 @@ static void nmwa_dbus_vpn_properties_cb (DBusPendingCall *pcall, void *user_data
{
VPNConnection * vpn;
state = (NMVPNState) state_int;
state = (NMVPNActStage) state_int;
/* If its already there, update the service, otherwise add it to the list */
if ((vpn = nmwa_vpn_connection_find_by_name (applet->vpn_connections, name)))
......@@ -167,7 +143,7 @@ void nmwa_dbus_vpn_update_one_vpn_connection (NMWirelessApplet *applet, const ch
g_return_if_fail (applet != NULL);
g_return_if_fail (vpn_name != NULL);
nmwa_dbus_vpn_get_active_vpn_connection (applet);
nmwa_get_first_active_vpn_connection (applet);
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "getVPNConnectionProperties")))
{
......@@ -241,7 +217,7 @@ void nmwa_dbus_vpn_update_vpn_connections (NMWirelessApplet *applet)
nmwa_free_vpn_connections (applet);
nmwa_dbus_vpn_get_active_vpn_connection (applet);
nmwa_get_first_active_vpn_connection (applet);
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "getVPNConnections")))
{
......
......@@ -33,6 +33,6 @@ void nmwa_dbus_vpn_remove_one_vpn_connection (NMWirelessApplet *applet, const
void nmwa_dbus_vpn_activate_connection (DBusConnection *connection, const char *name, GSList *passwords);
void nmwa_dbus_vpn_deactivate_connection (DBusConnection *connection);
void nmwa_dbus_vpn_update_vpn_connection_state (NMWirelessApplet *applet, const char *vpn_name, NMVPNState vpn_state);
void nmwa_dbus_vpn_update_vpn_connection_state (NMWirelessApplet *applet, const char *vpn_name, NMVPNActStage vpn_state);
#endif
......@@ -224,12 +224,13 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
}
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, "VPNConnectionStateChange")) /* Active VPN connection changed */
{
char *name = NULL;
NMVPNState vpn_state;
dbus_uint32_t vpn_state_int;
char * name = NULL;
NMVPNActStage vpn_state;
dbus_uint32_t vpn_state_int;
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_UINT32, &vpn_state_int, DBUS_TYPE_INVALID))
{
vpn_state = (NMVPNState) vpn_state_int;
vpn_state = (NMVPNActStage) vpn_state_int;
nmwa_dbus_vpn_update_vpn_connection_state (applet, name, vpn_state);
}
}
......
......@@ -869,19 +869,23 @@ out:
}
VPNConnection* nmwa_get_active_vpn_connection (NMWirelessApplet *applet)
/*
* nmwa_get_first_active_vpn_connection
*
* Return the first active VPN connection, if any.
*
*/
VPNConnection *nmwa_get_first_active_vpn_connection (NMWirelessApplet *applet)
{
VPNConnection *vpn;
NMVPNState vpn_state;
GSList *elt;
elt = applet->vpn_connections;
VPNConnection * vpn;
NMVPNActStage vpn_state;
GSList * elt;
for (; elt; elt = g_slist_next (elt))
for (elt = applet->vpn_connections; elt; elt = g_slist_next (elt))
{
vpn = (VPNConnection*) elt->data;
vpn_state = nmwa_vpn_connection_get_state (vpn);
if (vpn_state == NM_VPN_STATE_STARTED)
if (vpn_state == NM_VPN_ACT_STAGE_ACTIVATED)
return vpn;
}
......@@ -899,7 +903,7 @@ static void nmwa_set_icon (NMWirelessApplet *applet, GdkPixbuf *new_icon)
composite = gdk_pixbuf_copy (new_icon);
vpn = nmwa_get_active_vpn_connection (applet);
vpn = nmwa_get_first_active_vpn_connection (applet);
if (vpn)
{
......@@ -1132,8 +1136,9 @@ done:
if (!applet->tooltips)
applet->tooltips = gtk_tooltips_new ();
vpn = nmwa_get_active_vpn_connection (applet);
if (vpn != NULL) {
vpn = nmwa_get_first_active_vpn_connection (applet);
if (vpn != NULL)
{
char *newtip;
char *vpntip;
......@@ -1313,8 +1318,8 @@ static void nmwa_menu_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
VPNConnection *vpn = (VPNConnection *)tag;
const char *name = nmwa_vpn_connection_get_name (vpn);
GSList *passwords;
VPNConnection *active_vpn = nmwa_get_first_active_vpn_connection (applet);
VPNConnection *active_vpn = nmwa_get_active_vpn_connection (applet);
if (vpn != active_vpn)
{
char *gconf_key;
......@@ -1687,7 +1692,7 @@ static void nmwa_menu_add_vpn_menu (GtkWidget *menu, NMWirelessApplet *applet)
item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_VPN Connections")));
vpn_menu = GTK_MENU (gtk_menu_new ());
active_vpn = nmwa_get_active_vpn_connection (applet);
active_vpn = nmwa_get_first_active_vpn_connection (applet);
for (elt = applet->vpn_connections; elt; elt = g_slist_next (elt))
{
......
......@@ -146,6 +146,7 @@ void nmwa_schedule_vpn_failure_dialog (NMWirelessApplet *applet, const char
void nmwa_schedule_vpn_login_banner_dialog (NMWirelessApplet *applet, const char *vpn_name, const char *banner);
NetworkDevice * nmwa_get_first_active_device (GSList *dev_list);
VPNConnection * nmwa_get_first_active_vpn_connection (NMWirelessApplet *applet);
NMWirelessScanMethod nmwa_gconf_get_wireless_scan_method (NMWirelessApplet *applet);
......
......@@ -25,10 +25,10 @@
struct VPNConnection
{
int refcount;
char *name;
char *service;
NMVPNState state;
int refcount;
char * name;
char * service;
NMVPNActStage state;
};
......@@ -136,14 +136,14 @@ VPNConnection *nmwa_vpn_connection_find_by_name (GSList *list, const char *name)
return vpn;
}
NMVPNState nmwa_vpn_connection_get_state (VPNConnection *vpn)
NMVPNActStage nmwa_vpn_connection_get_state (VPNConnection *vpn)
{
g_return_val_if_fail (vpn != NULL, NM_VPN_STATE_UNKNOWN);
g_return_val_if_fail (vpn != NULL, NM_VPN_ACT_STAGE_UNKNOWN);
return vpn->state;
}
void nmwa_vpn_connection_set_state (VPNConnection *vpn, NMVPNState state)
void nmwa_vpn_connection_set_state (VPNConnection *vpn, NMVPNActStage state)
{
g_return_if_fail (vpn != NULL);
......
......@@ -34,8 +34,8 @@ const char * nmwa_vpn_connection_get_name (VPNConnection *vpn);
const char * nmwa_vpn_connection_get_service (VPNConnection *vpn);
void nmwa_vpn_connection_set_service (VPNConnection *vpn, const char *service);
NMVPNState nmwa_vpn_connection_get_state (VPNConnection *vpn);
void nmwa_vpn_connection_set_state (VPNConnection *vpn, NMVPNState state);
NMVPNActStage nmwa_vpn_connection_get_state (VPNConnection *vpn);
void nmwa_vpn_connection_set_state (VPNConnection *vpn, NMVPNActStage state);
VPNConnection * nmwa_vpn_connection_find_by_name (GSList *list, const char *name);
......
......@@ -166,8 +166,6 @@ nmwa_vpn_request_password (NMWirelessApplet *applet, const char *name, const cha
if (!retry)
argv[5] = NULL;
nm_debug ("retry = %d", retry);
child_status = -1;
if (!g_spawn_async_with_pipes (NULL, /* working_directory */
......
......@@ -459,7 +459,7 @@ static void nm_data_free (NMData *data)
g_return_if_fail (data != NULL);
/* Kill any active VPN connection */
if (nm_vpn_manager_get_active_vpn_connection (data->vpn_manager))
if (nm_vpn_manager_get_vpn_act_request (data->vpn_manager))
nm_vpn_manager_deactivate_vpn_connection (data->vpn_manager);
/* Stop and destroy all devices */
......
......@@ -46,6 +46,7 @@ typedef enum NMIntState
typedef struct NMDbusMethodList NMDbusMethodList;
typedef struct NMActRequest NMActRequest;
typedef struct NMVPNActRequest NMVPNActRequest;
typedef struct NMVPNManager NMVPNManager;
typedef struct NMDHCPManager NMDHCPManager;
......
......@@ -413,10 +413,12 @@ static gboolean nm_policy_device_change_check (NMData *data)
/* Schedule new activation if the currently associated access point is not the "best" one
* or we've lost the link to the old access point.
*/
if ((strcmp (old_essid, new_essid) != 0) || !nm_device_has_active_link (old_dev))
gboolean es = (strcmp (old_essid, new_essid) != 0);
gboolean link = nm_device_has_active_link (old_dev);
if (es || !link)
{
nm_info ("SWITCH: found better connection '%s/%s' than current connection '%s/%s'.", nm_device_get_iface (new_dev),
new_essid, nm_device_get_iface (old_dev), old_essid);
nm_info ("SWITCH: found better connection '%s/%s' than current connection '%s/%s'. essid=%d, link=%d", nm_device_get_iface (new_dev),
new_essid, nm_device_get_iface (old_dev), old_essid, es, link);
do_switch = TRUE;
}
}
......
......@@ -9,7 +9,9 @@ libvpn_manager_la_SOURCES = nm-dbus-vpn.c \
nm-vpn-manager.c \
nm-vpn-manager.h \
nm-vpn-service.c \
nm-vpn-service.h
nm-vpn-service.h \
nm-vpn-act-request.c \
nm-vpn-act-request.h
libvpn_manager_la_CPPFLAGS = $(DBUS_CFLAGS) \
$(GTHREAD_CFLAGS) \
......
......@@ -28,6 +28,8 @@
#include "nm-dbus-vpn.h"
#include "nm-vpn-manager.h"
#include "nm-vpn-connection.h"
#include "nm-vpn-service.h"
#include "nm-vpn-act-request.h"
#include "nm-utils.h"
......@@ -64,12 +66,11 @@ void nm_dbus_vpn_signal_vpn_connection_update (DBusConnection *con, NMVPNConnect
*
* Notifies the bus that a VPN connection's state has changed.
*/
void nm_dbus_vpn_signal_vpn_connection_state_change (DBusConnection *con, NMVPNConnection *vpn)
void nm_dbus_vpn_signal_vpn_connection_state_change (DBusConnection *con, NMVPNConnection *vpn, NMVPNActStage new_stage)
{
DBusMessage *message;
const char *vpn_name;
NMVPNService *service;
NMVPNState vpn_state;
DBusMessage * message;
const char * vpn_name;
dbus_uint32_t int_stage = (dbus_uint32_t) new_stage;
g_return_if_fail (con != NULL);
g_return_if_fail (vpn != NULL);
......@@ -81,10 +82,7 @@ void nm_dbus_vpn_signal_vpn_connection_state_change (DBusConnection *con, NMVPNC
}
vpn_name = nm_vpn_connection_get_name (vpn);
service = nm_vpn_connection_get_service (vpn);
vpn_state = nm_vpn_service_get_state (service);
dbus_message_append_args (message, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_UINT32, &vpn_state, DBUS_TYPE_INVALID);
dbus_message_append_args (message, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_UINT32, &int_stage, DBUS_TYPE_INVALID);
if (!dbus_connection_send (con, message, NULL))
nm_warning ("Could not raise the VPNConnectionStateChange signal!");
......@@ -358,12 +356,16 @@ static void nm_dbus_vpn_update_one_connection_cb (DBusPendingCall *pcall, void *
if (dbus_message_is_error (reply, "BadVPNConnectionData"))
{
NMVPNConnection *vpn = nm_vpn_manager_find_connection_by_name (cb_data->data->vpn_manager, cb_data->vpn);
NMVPNConnection *vpn;
nm_vpn_connection_ref (vpn);
nm_vpn_manager_remove_connection (cb_data->data->vpn_manager, vpn);
nm_dbus_vpn_signal_vpn_connection_update (cb_data->data->dbus_connection, vpn, "VPNConnectionRemoved");
nm_vpn_connection_unref (vpn);
/* Bad VPN, remove it from our VPN connection list */
if ((vpn = nm_vpn_manager_find_connection_by_name (cb_data->data->vpn_manager, cb_data->vpn)))
{
nm_vpn_connection_ref (vpn);
nm_vpn_manager_remove_connection (cb_data->data->vpn_manager, vpn);
nm_dbus_vpn_signal_vpn_connection_update (cb_data->data->dbus_connection, vpn, "VPNConnectionRemoved");
nm_vpn_connection_unref (vpn);
}
goto out;
}
......@@ -375,11 +377,19 @@ static void nm_dbus_vpn_update_one_connection_cb (DBusPendingCall *pcall, void *
if ((vpn = nm_vpn_manager_find_connection_by_name (cb_data->data->vpn_manager, con_name)))
{
nm_vpn_manager_remove_connection (cb_data->data->vpn_manager, vpn);
new = FALSE;
const char *vpn_service_name = nm_vpn_connection_get_service_name (vpn);
/* If all attributes of the existing connection are the same as the one we get from NMI,
* don't do anything.
*/
if (strcmp (vpn_service_name, service_name) || strcmp (nm_vpn_connection_get_user_name (vpn), user_name))
nm_vpn_manager_remove_connection (cb_data->data->vpn_manager, vpn);
else
new = FALSE;
}
vpn = nm_vpn_manager_add_connection (cb_data->data->vpn_manager, con_name, service_name, user_name);
if (new)
vpn = nm_vpn_manager_add_connection (cb_data->data->vpn_manager, con_name, service_name, user_name);
nm_dbus_vpn_signal_vpn_connection_update (cb_data->data->dbus_connection, vpn, new ? "VPNConnectionAdded" : "VPNConnectionUpdate");
}
dbus_message_unref (reply);
......@@ -389,6 +399,9 @@ out:
}
/* Should only be used by nm_dbus_vpn_connections_update_cb() */
GSList *nm_vpn_manager_vpn_connection_list_copy (NMVPNManager *manager);
/*
* nm_dbus_vpn_connections_update_cb
*
......@@ -400,6 +413,8 @@ static void nm_dbus_vpn_connections_update_cb (DBusPendingCall *pcall, void *use
NMData * data = (NMData *) user_data;
DBusMessage * reply;
DBusMessageIter iter, array_iter;
GSList * remove_list = NULL;
GSList * elt;
g_return_if_fail (pcall);
g_return_if_fail (data != NULL);
......@@ -417,20 +432,27 @@ static void nm_dbus_vpn_connections_update_cb (DBusPendingCall *pcall, void *use
nm_info ("Updating VPN Connections...");
remove_list = nm_vpn_manager_vpn_connection_list_copy (data->vpn_manager);
dbus_message_iter_init (reply, &iter);
dbus_message_iter_recurse (&iter, &array_iter);
while (dbus_message_iter_get_arg_type (&array_iter) == DBUS_TYPE_STRING)
{
DBusMessage * message;
const char * value;
DBusMessage * message;
const char * con_name;
NMVPNConnection * vpn;
dbus_message_iter_get_basic (&array_iter, &con_name);
dbus_message_iter_get_basic (&array_iter, &value);
/* If the connection already exists, remove it from the remove list */
if ((vpn = nm_vpn_manager_find_connection_by_name (data->vpn_manager, con_name)))
remove_list = g_slist_remove (remove_list, vpn);
if ((message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getVPNConnectionProperties")))
{
DBusPendingCall * vpn_pcall = NULL;
dbus_message_append_args (message, DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID);
dbus_message_append_args (message, DBUS_TYPE_STRING, &con_name, DBUS_TYPE_INVALID);
dbus_connection_send_with_reply (data->dbus_connection, message, &vpn_pcall, -1);
dbus_message_unref (message);
if (vpn_pcall)
......@@ -438,7 +460,7 @@ static void nm_dbus_vpn_connections_update_cb (DBusPendingCall *pcall, void *use
UpdateOneVPNCBData * vpn_cb_data = g_malloc0 (sizeof (UpdateOneVPNCBData));
vpn_cb_data->data = data;
vpn_cb_data->vpn = g_strdup (value);
vpn_cb_data->vpn = g_strdup (con_name);
dbus_pending_call_set_notify (vpn_pcall, nm_dbus_vpn_update_one_connection_cb, vpn_cb_data, (DBusFreeFunction) free_update_one_vpn_cb_data);
}
}
......@@ -446,6 +468,15 @@ static void nm_dbus_vpn_connections_update_cb (DBusPendingCall *pcall, void *use
}
dbus_message_unref (reply);
/* VPN connections left in the remove list aren't known by NMI, therefore we delete them */
for (elt = remove_list; elt; elt = g_slist_next (elt))
{
nm_vpn_manager_remove_connection (data->vpn_manager, elt->data);
nm_vpn_connection_unref (elt->data);
}
g_slist_free (remove_list);
out:
dbus_pending_call_unref (pcall);
}
......@@ -501,9 +532,6 @@ static gboolean nm_dbus_vpn_connections_update_from_nmi (NMData *data)
g_return_val_if_fail (data->dbus_connection != NULL, FALSE);
g_return_val_if_fail (data->vpn_manager != NULL, FALSE);
/* Clear all existing connections in preparation for new ones */
nm_vpn_manager_clear_connections (data->vpn_manager);
if (!(message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getVPNConnections")))
{
nm_warning ("nm_dbus_vpn_connections_update (): Couldn't allocate the dbus message");
......@@ -596,19 +624,19 @@ out:
*/
static DBusMessage *nm_dbus_vpn_get_vpn_connection_properties (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
{
DBusMessage *reply = NULL;
DBusError error;
const char *name;
gboolean good = FALSE;
NMVPNConnection *vpn_con;
DBusMessage * reply = NULL;
DBusError error;
const char * name;
gboolean good = FALSE;
NMVPNManager * manager;
NMVPNConnection * vpn;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (data->data != NULL, NULL);
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (data->data != NULL, NULL); g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL);
/* Check for no VPN Manager */
if (!data->data->vpn_manager)
if (!(manager = data->data->vpn_manager))
return nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_VPN, "NoVPNConnections", "There are no available VPN connections.");
if (!(reply = dbus_message_new_method_return (message)))
......@@ -617,20 +645,26 @@ static DBusMessage *nm_dbus_vpn_get_vpn_connection_properties (DBusConnection *c
dbus_error_init (&error);
if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
{
if ((vpn_con = nm_vpn_manager_find_connection_by_name (data->data->vpn_manager, name)))
if ((vpn = nm_vpn_manager_find_connection_by_name (manager, name)))
{
const char *user_name;
const char *service_name;
NMVPNService *service;
NMVPNState state;
user_name = nm_vpn_connection_get_user_name (vpn_con);
service = nm_vpn_connection_get_service (vpn_con);
service_name = nm_vpn_service_get_service_name (service);
state = nm_vpn_service_get_state (service);
dbus_message_append_args (reply, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &user_name, DBUS_TYPE_STRING, &service_name, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID);
good = TRUE;
const char * user_name;
const char * service_name;
NMVPNService * service;
user_name = nm_vpn_connection_get_user_name (vpn);
service_name = nm_vpn_connection_get_service_name (vpn);
if ((service = nm_vpn_manager_find_service_by_name (data->data->vpn_manager, service_name)))
{
NMVPNActRequest * req = nm_vpn_manager_get_vpn_act_request (manager);
dbus_uint32_t stage = (dbus_uint32_t) NM_VPN_ACT_STAGE_DISCONNECTED;
if (req && (nm_vpn_act_request_get_connection (req) == vpn))
stage = nm_vpn_act_request_get_stage (req);
dbus_message_append_args (reply, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &user_name,
DBUS_TYPE_STRING, &service_name, DBUS_TYPE_UINT32, &stage, DBUS_TYPE_INVALID);
good = TRUE;
}
}
}
......@@ -649,22 +683,21 @@ static DBusMessage *nm_dbus_vpn_get_vpn_connection_properties (DBusConnection *c
*/
static DBusMessage *nm_dbus_vpn_activate_connection (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
{
DBusError error;
const char *name;
char **passwords;
int num_passwords;
NMVPNConnection *vpn;
DBusError error;
const char * name;
char ** passwords;
int num_passwords;
NMVPNConnection * vpn;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (data->data != NULL, NULL);
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL);
nm_info ("Entering");
dbus_error_init (&error);
if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &passwords, &num_passwords, DBUS_TYPE_INVALID)) {
if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &passwords, &num_passwords, DBUS_TYPE_INVALID))
{
if ((vpn = nm_vpn_manager_find_connection_by_name (data->data->vpn_manager, name)))
{
int item_count = -1;
......@@ -672,21 +705,20 @@ static DBusMessage *nm_dbus_vpn_activate_connection (DBusConnection *connection,
if ((items = nm_dbus_vpn_get_vpn_data (connection, vpn, &item_count)))
{
char *joined_string = g_strjoinv (" / ", items);
NMVPNService *service = nm_vpn_connection_get_service (vpn);;
char * joined_string = g_strjoinv (" / ", items);
nm_info ("Will activate VPN connection '%s', service '%s', user_name '%s', vpn_data '%s'.",
name, nm_vpn_service_get_service_name (service), nm_vpn_connection_get_user_name (vpn), joined_string);
name, nm_vpn_connection_get_service_name (vpn), nm_vpn_connection_get_user_name (vpn), joined_string);
nm_vpn_manager_activate_vpn_connection (data->data->vpn_manager, vpn, passwords, num_passwords, items, item_count);
g_free (joined_string);
g_strfreev (items);
}
} else {
nm_warning ("Cannot find name '%s'", name);
nm_warning ("nm_dbus_vpn_activate_connection(): cannot find VPN connection '%s'", name);
}
} else {
nm_warning ("Syntax error receiving nm_dbus_vpn_activate_connection");
nm_warning ("nm_dbus_vpn_activate_connection(): syntax error in method arguments");
}