diff --git a/ChangeLog b/ChangeLog index 54d255a3de..6ee406f558 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,46 @@ +2007-09-28 Tambet Ingo + + * src/nm-manager.c: + * src/nm-manager.h: + Implement device activation through NMManager. + Implement "pending device activation" here - If the connection isn't found, + we try to wait for up to 5 seconds for the connection to be provided. + Add NMConnectionType argument to "connection-added" and "connection-removed" + signals. + (nm_manager_get): Remove. Finally. + + * src/nm-activation-request.c: + * src/nm-activation-request.h: + Remove all the deferred activation code. + + * src/nm-device.c: Remove all the deferred activation code. Once the device + activation is started, it's started. Update the activation virtual function + signature. + + * src/nm-device-interface.c: + * src/nm-device-interface.h: + Device activation now takes only NMActRequest argument. + Don't expose device activation directly on dbus, it's supposed to go through + NMManager now. + + * src/NetworkManagerPolicy.c (nm_policy_device_change_check): Make the code + a bit more compact. + Use the new device activation methods through NMManager. + + * introspection/nm-manager-client.xml: + * introspection/nm-manager.xml: + * libnm-glib/nm-client.c: + * libnm-glib/nm-client.h: + Add device activation method. + + * libnm-glib/nm-device.c: + * libnm-glib/nm-device.h: + * introspection/nm-device.xml: + Remove device activation method. It's done through NMManager now. + + * src/vpn-manager/nm-vpn-manager.c (impl_vpn_manager_connect): Use the shiny + new (nm_manager_get_device_by_path) function, get rid of our own )find_device). + 2007-09-28 Dan Williams * libnm-glib/nm-vpn-connection.c diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml index 22d8f583b7..c3f3fe56a5 100644 --- a/introspection/nm-device.xml +++ b/introspection/nm-device.xml @@ -2,12 +2,6 @@ - - - - - - diff --git a/introspection/nm-manager-client.xml b/introspection/nm-manager-client.xml index 99d499cade..66e76e82d8 100644 --- a/introspection/nm-manager-client.xml +++ b/introspection/nm-manager-client.xml @@ -14,6 +14,15 @@ + + + + + + + + + diff --git a/introspection/nm-manager.xml b/introspection/nm-manager.xml index 4151768d6e..5020343eac 100644 --- a/introspection/nm-manager.xml +++ b/introspection/nm-manager.xml @@ -14,6 +14,15 @@ + + + + + + + + + diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index 04d1fd7e0b..73c896f567 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -1,3 +1,5 @@ +/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ + #include #include #include "nm-client.h" @@ -5,6 +7,7 @@ #include "nm-device-802-11-wireless.h" #include "nm-device-private.h" #include "nm-marshal.h" +#include #include "nm-client-bindings.h" @@ -392,6 +395,55 @@ nm_client_get_device_by_path (NMClient *client, const char *object_path) return device; } +typedef struct { + NMClientActivateDeviceFn fn; + gpointer user_data; +} ActivateDeviceInfo; + +static void +activate_cb (DBusGProxy *proxy, GError *err, gpointer user_data) +{ + ActivateDeviceInfo *info = (ActivateDeviceInfo *) user_data; + + if (info->fn) + info->fn (info->user_data, err); + else + nm_warning ("Device activation failed: %s", err->message); + + /* FIXME: Free err as well? */ + + g_slice_free (ActivateDeviceInfo, info); +} + +void +nm_client_activate_device (NMClient *client, + NMDevice *device, + const char *service_name, + const char *connection_path, + const char *specific_object, + NMClientActivateDeviceFn callback, + gpointer user_data) +{ + ActivateDeviceInfo *info; + + g_return_if_fail (NM_IS_CLIENT (client)); + g_return_if_fail (NM_IS_DEVICE (device)); + g_return_if_fail (service_name != NULL); + g_return_if_fail (connection_path != NULL); + + info = g_slice_new (ActivateDeviceInfo); + info->fn = callback; + info->user_data = user_data; + + org_freedesktop_NetworkManager_activate_device_async (NM_CLIENT_GET_PRIVATE (client)->client_proxy, + nm_object_get_path (NM_OBJECT (device)), + service_name, + connection_path, + specific_object, + activate_cb, + info); +} + gboolean nm_client_wireless_get_enabled (NMClient *client) { diff --git a/libnm-glib/nm-client.h b/libnm-glib/nm-client.h index 2df065a828..bb410ff21a 100644 --- a/libnm-glib/nm-client.h +++ b/libnm-glib/nm-client.h @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ #ifndef NM_CLIENT_H #define NM_CLIENT_H 1 @@ -40,7 +41,17 @@ NMClient *nm_client_new (void); gboolean nm_client_manager_is_running (NMClient *client); GSList *nm_client_get_devices (NMClient *client); NMDevice *nm_client_get_device_by_path (NMClient *client, - const char *object_path); + const char *object_path); + +typedef void (*NMClientActivateDeviceFn) (gpointer user_data, GError *error); + +void nm_client_activate_device (NMClient *client, + NMDevice *device, + const char *service_name, + const char *connection_path, + const char *specific_object, + NMClientActivateDeviceFn callback, + gpointer user_data); gboolean nm_client_wireless_get_enabled (NMClient *client); void nm_client_wireless_set_enabled (NMClient *client, gboolean enabled); diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index 77b1490ed6..5e82054253 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -155,28 +155,6 @@ nm_device_new (DBusGConnection *connection, const char *path) NULL); } -void -nm_device_activate (NMDevice *device, - const char *service_name, - const char *connection_path, - const char *specific_object) -{ - GError *err = NULL; - - g_return_if_fail (NM_IS_DEVICE (device)); - g_return_if_fail (service_name != NULL); - g_return_if_fail (connection_path != NULL); - - if (!org_freedesktop_NetworkManager_Device_activate (NM_DEVICE_GET_PRIVATE (device)->device_proxy, - service_name, - connection_path, - specific_object ? specific_object : "/", - &err)) { - g_warning ("Cannot activate device: %s", err->message); - g_error_free (err); - } -} - void nm_device_deactivate (NMDevice *device) { diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h index 758fc76ad7..d8aa3f49c5 100644 --- a/libnm-glib/nm-device.h +++ b/libnm-glib/nm-device.h @@ -35,11 +35,6 @@ GType nm_device_get_type (void); NMDevice *nm_device_new (DBusGConnection *connection, const char *path); -void nm_device_activate (NMDevice *device, - const char *service_name, - const char *connection_path, - const char *specific_object); - void nm_device_deactivate (NMDevice *device); char *nm_device_get_iface (NMDevice *device); diff --git a/src/NetworkManager.c b/src/NetworkManager.c index 20567af5ed..e8b9c5cfa4 100644 --- a/src/NetworkManager.c +++ b/src/NetworkManager.c @@ -326,7 +326,7 @@ main (int argc, char *argv[]) goto done; } - manager = nm_manager_get (); + manager = nm_manager_new (); if (manager == NULL) { nm_error ("Failed to initialize the network manager."); goto done; diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c index b9309d3d10..9760f775ea 100644 --- a/src/NetworkManagerPolicy.c +++ b/src/NetworkManagerPolicy.c @@ -204,6 +204,7 @@ nm_policy_device_change_check (gpointer user_data) { NMPolicy *policy = (NMPolicy *) user_data; GSList *iter; + guint32 caps; NMConnection * connection = NULL; char * specific_object = NULL; NMDevice * new_dev = NULL; @@ -213,54 +214,40 @@ nm_policy_device_change_check (gpointer user_data) switch (nm_manager_get_state (policy->manager)) { case NM_STATE_CONNECTED: old_dev = nm_manager_get_active_device (policy->manager); - break; - case NM_STATE_CONNECTING: - for (iter = nm_manager_get_devices (policy->manager); iter; iter = iter->next) { - if (nm_device_is_activating (NM_DEVICE (iter->data))) { - old_dev = NM_DEVICE (iter->data); - break; - } - } - break; - case NM_STATE_DISCONNECTED: - /* Check for devices that have deferred activation requests */ - for (iter = nm_manager_get_devices (policy->manager); iter; iter = iter->next) { - NMActRequest *req = nm_device_get_act_request (NM_DEVICE (iter->data)); + caps = nm_device_get_capabilities (old_dev); - if (req && nm_act_request_is_deferred (req)) { - old_dev = NM_DEVICE (iter->data); - break; - } - } - break; - default: - break; - } - - if (old_dev) { - guint32 caps = nm_device_get_capabilities (old_dev); - NMActRequest *req = nm_device_get_act_request (old_dev); - - /* Don't interrupt a currently activating device automatically. */ - if ( (nm_device_is_activating (old_dev) - && !nm_device_can_interrupt_activation (old_dev)) - || nm_act_request_is_deferred (req)) { - nm_info ("Old device '%s' activating, won't change.", - nm_device_get_iface (old_dev)); - goto out; - } - - /* Don't interrupt semi-supported devices either. If the user chose + /* Don't interrupt semi-supported devices. If the user chose * one, they must explicitly choose to move to another device, we're not * going to move for them. */ - if ( (NM_IS_DEVICE_802_3_ETHERNET (old_dev) - && !(caps & NM_DEVICE_CAP_CARRIER_DETECT))) { + if ((NM_IS_DEVICE_802_3_ETHERNET (old_dev) && !(caps & NM_DEVICE_CAP_CARRIER_DETECT))) { nm_info ("Old device '%s' was semi-supported and user chosen, won't" " change unless told to.", nm_device_get_iface (old_dev)); goto out; } + break; + case NM_STATE_CONNECTING: + for (iter = nm_manager_get_devices (policy->manager); iter; iter = iter->next) { + NMDevice *d = NM_DEVICE (iter->data); + + if (nm_device_is_activating (d)) { + if (nm_device_can_interrupt_activation (d)) { + old_dev = d; + break; + } else + goto out; + } + } + break; + case NM_STATE_DISCONNECTED: + if (nm_manager_activation_pending (policy->manager)) { + nm_info ("There is a pending activation, won't change."); + goto out; + } + break; + default: + break; } new_dev = nm_policy_auto_get_best_device (policy, &connection, &specific_object); @@ -321,14 +308,8 @@ nm_policy_device_change_check (gpointer user_data) /* Don't interrupt activation of a wireless device by * trying to auto-activate any connection on that device. */ - if (old_dev == new_dev) { - NMActRequest *req = nm_device_get_act_request (new_dev); - - if (nm_device_is_activating (new_dev)) - same_activating = TRUE; - else if (req && nm_act_request_is_deferred (req)) - same_activating = TRUE; - } + if (old_dev == new_dev && nm_device_is_activating (new_dev)) + same_activating = TRUE; if (!same_activating && !old_has_link && (old_mode != IW_MODE_ADHOC)) { NMSettingConnection * new_sc = (NMSettingConnection *) nm_connection_get_setting (connection, NM_SETTING_CONNECTION); @@ -358,12 +339,7 @@ nm_policy_device_change_check (gpointer user_data) } if (new_dev) { - nm_device_interface_activate (NM_DEVICE_INTERFACE (new_dev), - NULL, - NULL, - connection, - specific_object, - FALSE); + nm_manager_activate_device (policy->manager, new_dev, connection, specific_object, FALSE); } } @@ -500,6 +476,7 @@ state_changed (NMManager *manager, NMState state, gpointer user_data) static void connection_added (NMManager *manager, NMConnection *connection, + NMConnectionType connection_type, gpointer user_data) { NMPolicy *policy = (NMPolicy *) user_data; @@ -510,6 +487,7 @@ connection_added (NMManager *manager, static void connection_removed (NMManager *manager, NMConnection *connection, + NMConnectionType connection_type, gpointer user_data) { NMPolicy *policy = (NMPolicy *) user_data; diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index 17df426882..856d1a1d58 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -20,11 +20,13 @@ */ #include +#include #include "nm-activation-request.h" #include "nm-marshal.h" -#include "nm-manager.h" #include "nm-utils.h" +#include "nm-manager.h" /* FIXME! */ + #define CONNECTION_GET_SECRETS_CALL_TAG "get-secrets-call" G_DEFINE_TYPE (NMActRequest, nm_act_request, G_TYPE_OBJECT) @@ -34,8 +36,6 @@ G_DEFINE_TYPE (NMActRequest, nm_act_request, G_TYPE_OBJECT) enum { CONNECTION_SECRETS_UPDATED, CONNECTION_SECRETS_FAILED, - DEFERRED_ACTIVATION_TIMEOUT, - DEFERRED_ACTIVATION_START, LAST_SIGNAL }; @@ -44,11 +44,6 @@ static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { - char *deferred_service_name; - char *deferred_connection_path; - gulong deferred_connection_id; - guint32 deferred_timeout_id; - NMConnection *connection; char *specific_object; gboolean user_requested; @@ -59,35 +54,11 @@ nm_act_request_init (NMActRequest *req) { } -static void -clear_deferred_stuff (NMActRequest *req) -{ - NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (req); - - g_free (priv->deferred_service_name); - priv->deferred_service_name = NULL; - g_free (priv->deferred_connection_path); - priv->deferred_connection_path = NULL; - - if (priv->deferred_connection_id) { - NMManager *manager = nm_manager_get (); - g_signal_handler_disconnect (manager, priv->deferred_connection_id); - g_object_unref (manager); - priv->deferred_connection_id = 0; - } - - if (priv->deferred_timeout_id) { - g_source_remove (priv->deferred_timeout_id); - priv->deferred_timeout_id = 0; - } -} - static void dispose (GObject *object) { NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object); - clear_deferred_stuff (NM_ACT_REQUEST (object)); if (priv->connection) { DBusGProxy *proxy; @@ -112,8 +83,6 @@ finalize (GObject *object) { NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object); - g_free (priv->deferred_service_name); - g_free (priv->deferred_connection_path); g_free (priv->specific_object); G_OBJECT_CLASS (nm_act_request_parent_class)->finalize (object); @@ -149,26 +118,6 @@ nm_act_request_class_init (NMActRequestClass *req_class) nm_marshal_VOID__OBJECT_STRING, G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_STRING); - - signals[DEFERRED_ACTIVATION_TIMEOUT] = - g_signal_new ("deferred-activation-timeout", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMActRequestClass, deferred_activation_timeout), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, - G_TYPE_NONE); - - signals[DEFERRED_ACTIVATION_START] = - g_signal_new ("deferred-activation-start", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMActRequestClass, deferred_activation_start), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, - G_TYPE_NONE); } NMActRequest * @@ -195,106 +144,6 @@ nm_act_request_new (NMConnection *connection, return NM_ACT_REQUEST (obj); } -static gboolean -deferred_timeout_cb (gpointer data) -{ - NMActRequest *self = NM_ACT_REQUEST (data); - NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self); - - priv->deferred_timeout_id = 0; - clear_deferred_stuff (self); - - g_signal_emit (self, signals[DEFERRED_ACTIVATION_TIMEOUT], 0); - return FALSE; -} - -static void -connection_added_cb (NMManager *manager, - NMConnection *connection, - gpointer user_data) -{ - NMActRequest *self; - NMActRequestPrivate *priv; - const char *service_name; - const char *path; - - g_return_if_fail (NM_IS_ACT_REQUEST (user_data)); - g_return_if_fail (NM_IS_CONNECTION (connection)); - g_return_if_fail (NM_IS_MANAGER (manager)); - - self = NM_ACT_REQUEST (user_data); - - service_name = nm_manager_get_connection_service_name (manager, connection); - path = nm_manager_get_connection_dbus_path (manager, connection); - if (!service_name || !path) { - nm_warning ("Couldn't get connection service name or path (%s, %s)", - service_name, path); - return; - } - - priv = NM_ACT_REQUEST_GET_PRIVATE (self); - if ( strcmp (service_name, priv->deferred_service_name) - || strcmp (path, priv->deferred_connection_path)) - return; - - clear_deferred_stuff (self); - priv->connection = g_object_ref (connection); - - g_signal_emit (self, signals[DEFERRED_ACTIVATION_START], 0); -} - -NMActRequest * -nm_act_request_new_deferred (const char *service_name, - const char *connection_path, - const char *specific_object, - gboolean user_requested) -{ - GObject *obj; - NMManager *manager; - NMActRequestPrivate *priv; - gulong id; - - g_return_val_if_fail (service_name != NULL, NULL); - g_return_val_if_fail (connection_path != NULL, NULL); - - obj = g_object_new (NM_TYPE_ACT_REQUEST, NULL); - if (!obj) - return NULL; - - priv = NM_ACT_REQUEST_GET_PRIVATE (obj); - - priv->deferred_service_name = g_strdup (service_name); - priv->deferred_connection_path = g_strdup (connection_path); - priv->user_requested = user_requested; - if (specific_object) - priv->specific_object = g_strdup (specific_object); - - id = g_timeout_add (5000, deferred_timeout_cb, NM_ACT_REQUEST (obj)); - priv->deferred_timeout_id = id; - - manager = nm_manager_get (); - id = g_signal_connect (manager, - "connection-added", - G_CALLBACK (connection_added_cb), - NM_ACT_REQUEST (obj)); - priv->deferred_connection_id = id; - g_object_unref (manager); - - return NM_ACT_REQUEST (obj); -} - -gboolean -nm_act_request_is_deferred (NMActRequest *req) -{ - NMActRequestPrivate *priv; - - g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE); - - priv = NM_ACT_REQUEST_GET_PRIVATE (req); - - return priv->deferred_connection_path ? TRUE : FALSE; -} - typedef struct GetSecretsInfo { NMActRequest *req; char *setting_name; diff --git a/src/nm-activation-request.h b/src/nm-activation-request.h index 60ccc14a54..8059729490 100644 --- a/src/nm-activation-request.h +++ b/src/nm-activation-request.h @@ -47,8 +47,6 @@ typedef struct { void (*connection_secrets_failed) (NMActRequest *req, NMConnection *connection, const char * setting); - void (*deferred_activation_timeout) (NMActRequest *req); - void (*deferred_activation_start) (NMActRequest *req); } NMActRequestClass; GType nm_act_request_get_type (void); @@ -57,13 +55,6 @@ NMActRequest *nm_act_request_new (NMConnection *connection, const char *specific_object, gboolean user_requested); -NMActRequest *nm_act_request_new_deferred (const char *service_name, - const char *connection_path, - const char *specific_object, - gboolean user_requested); - -gboolean nm_act_request_is_deferred (NMActRequest *req); - NMConnection *nm_act_request_get_connection (NMActRequest *req); gboolean nm_act_request_request_connection_secrets (NMActRequest *req, const char *setting_name, diff --git a/src/nm-device-interface.c b/src/nm-device-interface.c index c8f6b02a09..a2bb770856 100644 --- a/src/nm-device-interface.c +++ b/src/nm-device-interface.c @@ -4,12 +4,6 @@ #include "nm-ip4-config.h" #include "nm-utils.h" -static gboolean impl_device_activate (NMDeviceInterface *device, - const char *service_name, - const char *connection_path, - const char *specific_object, - GError **err); - static gboolean impl_device_deactivate (NMDeviceInterface *device, GError **err); #include "nm-device-interface-glue.h" @@ -186,27 +180,6 @@ nm_device_interface_get_type (void) return device_interface_type; } -/* Pass _either_ connection_path or connection. Passing 'connection' is - * meant for internal use only. - */ -void -nm_device_interface_activate (NMDeviceInterface *device, - const char *service_name, - const char *connection_path, - NMConnection *connection, - const char *specific_object, - gboolean user_requested) -{ - g_return_if_fail (NM_IS_DEVICE_INTERFACE (device)); - - NM_DEVICE_INTERFACE_GET_INTERFACE (device)->activate (device, - service_name, - connection_path, - connection, - specific_object, - user_requested); -} - /* FIXME: This should be public and nm_device_get_iface() should be removed. */ static const char * nm_device_interface_get_iface (NMDeviceInterface *device) @@ -220,21 +193,15 @@ nm_device_interface_get_iface (NMDeviceInterface *device) return iface; } -static gboolean -impl_device_activate (NMDeviceInterface *device, - const char *service_name, - const char *connection_path, - const char *specific_object, - GError **err) +gboolean +nm_device_interface_activate (NMDeviceInterface *device, + NMActRequest *req) { - nm_info ("User request for activation of %s.", nm_device_interface_get_iface (device)); - nm_device_interface_activate (device, - service_name, - connection_path, - NULL, - specific_object, - TRUE); - return TRUE; + g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), FALSE); + g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE); + + nm_info ("Activating device %s", nm_device_interface_get_iface (device)); + return NM_DEVICE_INTERFACE_GET_INTERFACE (device)->activate (device, req); } void diff --git a/src/nm-device-interface.h b/src/nm-device-interface.h index c1026ddc5e..b33ad79f41 100644 --- a/src/nm-device-interface.h +++ b/src/nm-device-interface.h @@ -5,6 +5,7 @@ #include #include "NetworkManager.h" #include "nm-connection.h" +#include "nm-activation-request.h" #define NM_TYPE_DEVICE_INTERFACE (nm_device_interface_get_type ()) #define NM_DEVICE_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_INTERFACE, NMDeviceInterface)) @@ -52,12 +53,9 @@ struct _NMDeviceInterface { GTypeInterface g_iface; /* Methods */ - void (*activate) (NMDeviceInterface *device, - const char *service_name, - const char *connection_path, - NMConnection *connection, - const char *specific_object, - gboolean user_requested); + gboolean (*activate) (NMDeviceInterface *device, + NMActRequest *req); + void (*deactivate) (NMDeviceInterface *device); /* Signals */ @@ -70,12 +68,8 @@ GType nm_device_interface_error_get_type (void); GType nm_device_interface_get_type (void); -void nm_device_interface_activate (NMDeviceInterface *device, - const char *service_name, - const char *connection_path, - NMConnection *connection, - const char *specific_object, - gboolean user_requested); +gboolean nm_device_interface_activate (NMDeviceInterface *device, + NMActRequest *req); void nm_device_interface_deactivate (NMDeviceInterface *device); diff --git a/src/nm-device.c b/src/nm-device.c index 1eb458e6ad..fcaabd1add 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ /* NetworkManager -- Network link manager * * Dan Williams @@ -69,8 +70,6 @@ struct _NMDevicePrivate struct in6_addr ip6_address; NMActRequest * act_request; - gulong act_deferred_timeout_id; - gulong act_deferred_start_id; guint act_source_id; gulong secrets_updated_id; gulong secrets_failed_id; @@ -83,12 +82,8 @@ struct _NMDevicePrivate gulong dhcp_timeout_sigid; }; -static void nm_device_activate (NMDeviceInterface *device, - const char *service_name, - const char *connection_path, - NMConnection *connection, - const char *specific_object, - gboolean user_requested); +static gboolean nm_device_activate (NMDeviceInterface *device, + NMActRequest *req); static void nm_device_activate_schedule_stage5_ip_config_commit (NMDevice *self); static void nm_device_deactivate (NMDeviceInterface *device); @@ -126,8 +121,6 @@ nm_device_init (NMDevice * self) self->priv->ip4_address = 0; memset (&self->priv->ip6_address, 0, sizeof (struct in6_addr)); - self->priv->act_deferred_timeout_id = 0; - self->priv->act_deferred_start_id = 0; self->priv->act_source_id = 0; self->priv->system_config_data = NULL; @@ -960,18 +953,6 @@ clear_act_request (NMDevice *self) if (!priv->act_request) return; - if (priv->act_deferred_timeout_id) { - g_signal_handler_disconnect (priv->act_request, - priv->act_deferred_timeout_id); - priv->act_deferred_timeout_id = 0; - } - - if (priv->act_deferred_start_id) { - g_signal_handler_disconnect (priv->act_request, - priv->act_deferred_start_id); - priv->act_deferred_start_id = 0; - } - if (priv->secrets_updated_id) { g_signal_handler_disconnect (priv->act_request, priv->secrets_updated_id); @@ -1132,21 +1113,6 @@ connection_secrets_failed_cb (NMActRequest *req, nm_device_interface_deactivate (NM_DEVICE_INTERFACE (self)); } -static void -deferred_activation_timeout_cb (NMActRequest *req, gpointer user_data) -{ - NMDevice *self = NM_DEVICE (user_data); - - if (nm_device_get_act_request (self) != req) - return; - - nm_info ("%s: didn't receive connection details soon enough for activation.", - nm_device_get_iface (self)); - - clear_act_request (self); - nm_device_state_changed (self, NM_DEVICE_STATE_DISCONNECTED); -} - static gboolean device_activation_precheck (NMDevice *self, NMConnection *connection) { @@ -1173,24 +1139,25 @@ device_activation_precheck (NMDevice *self, NMConnection *connection) return TRUE; } -static void -device_activation_go (NMDevice *self) +static gboolean +nm_device_activate (NMDeviceInterface *device, + NMActRequest *req) { - NMDevicePrivate * priv; - gulong id; + NMDevice *self = NM_DEVICE (device); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - priv = NM_DEVICE_GET_PRIVATE (self); - id = g_signal_connect (priv->act_request, - "connection-secrets-updated", - G_CALLBACK (connection_secrets_updated_cb), - self); - priv->secrets_updated_id = id; + if (!device_activation_precheck (self, nm_act_request_get_connection (req))) + return FALSE; - id = g_signal_connect (priv->act_request, - "connection-secrets-failed", - G_CALLBACK (connection_secrets_failed_cb), - self); - priv->secrets_failed_id = id; + priv->act_request = g_object_ref (req); + priv->secrets_updated_id = g_signal_connect (req, + "connection-secrets-updated", + G_CALLBACK (connection_secrets_updated_cb), + device); + priv->secrets_failed_id = g_signal_connect (req, + "connection-secrets-failed", + G_CALLBACK (connection_secrets_failed_cb), + device); /* HACK: update the state a bit early to avoid a race between the * scheduled stage1 handler and nm_policy_device_change_check() thinking @@ -1198,107 +1165,9 @@ device_activation_go (NMDevice *self) * gets cleared a bit too early, when the connection becomes valid. */ nm_device_state_changed (self, NM_DEVICE_STATE_PREPARE); - nm_device_activate_schedule_stage1_device_prepare (self); -} -static void -deferred_activation_start_cb (NMActRequest *req, gpointer user_data) -{ - NMDevice *self = NM_DEVICE (user_data); - NMDevicePrivate * priv; - NMConnection *connection; - - if (nm_device_get_act_request (self) != req) - return; - - priv = NM_DEVICE_GET_PRIVATE (self); - g_signal_handler_disconnect (priv->act_request, - priv->act_deferred_start_id); - priv->act_deferred_start_id = 0; - - connection = nm_act_request_get_connection (req); - if (device_activation_precheck (self, connection) == FALSE) - return; - - nm_info ("%s: connection details received, will start activation.", - nm_device_get_iface (self)); - - device_activation_go (self); -} - -static void -nm_device_activate (NMDeviceInterface *device, - const char *service_name, - const char *connection_path, - NMConnection *connection, - const char *specific_object, - gboolean user_requested) -{ - NMDevice *self = NM_DEVICE (device); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - - /* Only one of: - * - connection - * - service_name AND connection_path - * is valid. - */ - if (!connection) { - g_return_if_fail (service_name != NULL); - g_return_if_fail (connection_path != NULL); - } else if (connection) { - g_return_if_fail (service_name == NULL); - g_return_if_fail (connection_path == NULL); - } - - if (!connection) { - NMManager *mgr = nm_manager_get (); - NMConnectionType type = NM_CONNECTION_TYPE_UNKNOWN; - - if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS)) - type = NM_CONNECTION_TYPE_USER; - else if (!strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS)) - type = NM_CONNECTION_TYPE_SYSTEM; - - if (type != NM_CONNECTION_TYPE_UNKNOWN) - connection = nm_manager_get_connection_by_object_path (mgr, type, connection_path); - - g_object_unref (mgr); - } - - nm_info ("Activating device %s", nm_device_get_iface (self)); - if (connection) { - if (device_activation_precheck (self, connection) == FALSE) - return; - - priv->act_request = nm_act_request_new (connection, - specific_object, - user_requested); - device_activation_go (self); - } else { - gulong id; - - /* Don't have the connection quite yet, probably created by - * the client on-the-fly. Defer the activation until we have it - */ - priv->act_request = nm_act_request_new_deferred (service_name, - connection_path, - specific_object, - user_requested); - - id = g_signal_connect (priv->act_request, "deferred-activation-timeout", - G_CALLBACK (deferred_activation_timeout_cb), - self); - priv->act_deferred_timeout_id = id; - - id = g_signal_connect (priv->act_request, "deferred-activation-start", - G_CALLBACK (deferred_activation_start_cb), - self); - priv->act_deferred_start_id = id; - - nm_info ("%s: Deferring activation until connection information is " - "received.", nm_device_get_iface (self)); - } + return TRUE; } /* diff --git a/src/nm-manager.c b/src/nm-manager.c index 5fcb36b840..4ef24a457b 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -8,8 +8,16 @@ #include "nm-device-interface.h" #include "nm-device-802-11-wireless.h" #include "NetworkManagerSystem.h" +#include "nm-marshal.h" static gboolean impl_manager_get_devices (NMManager *manager, GPtrArray **devices, GError **err); +static void impl_manager_activate_device (NMManager *manager, + char *device_path, + char *service_name, + char *connection_path, + char *specific_object_path, + DBusGMethodInvocation *context); + static gboolean impl_manager_sleep (NMManager *manager, gboolean sleep, GError **err); /* Legacy 0.6 compatibility interface */ @@ -23,6 +31,20 @@ static gboolean impl_manager_legacy_state (NMManager *manager, guint32 *state, G static void nm_manager_connections_destroy (NMManager *manager, NMConnectionType type); static void manager_set_wireless_enabled (NMManager *manager, gboolean enabled); +static void connection_added_default_handler (NMManager *manager, + NMConnection *connection, + NMConnectionType connection_type); + + +typedef struct { + DBusGMethodInvocation *context; + NMDevice *device; + NMConnectionType connection_type; + char *connection_path; + char *specific_object_path; + guint timeout_id; +} PendingConnectionInfo; + typedef struct { GSList *devices; NMState state; @@ -33,6 +55,7 @@ typedef struct { GHashTable *system_connections; DBusGProxy *system_proxy; + PendingConnectionInfo *pending_connection_info; gboolean wireless_enabled; gboolean sleeping; } NMManagerPrivate; @@ -122,12 +145,34 @@ nm_manager_update_state (NMManager *manager) } } +static void +pending_connection_info_destroy (NMManager *manager) +{ + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); + PendingConnectionInfo *info = priv->pending_connection_info; + + if (!info) + return; + + if (info->timeout_id) + g_source_remove (info->timeout_id); + + g_free (info->connection_path); + g_free (info->specific_object_path); + g_object_unref (info->device); + + g_slice_free (PendingConnectionInfo, info); + priv->pending_connection_info = NULL; +} + static void finalize (GObject *object) { NMManager *manager = NM_MANAGER (object); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); + pending_connection_info_destroy (manager); + nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_USER); g_hash_table_destroy (priv->user_connections); priv->user_connections = NULL; @@ -184,6 +229,8 @@ nm_manager_class_init (NMManagerClass *manager_class) g_type_class_add_private (manager_class, sizeof (NMManagerPrivate)); /* virtual methods */ + manager_class->connection_added = connection_added_default_handler; + object_class->set_property = set_property; object_class->get_property = get_property; object_class->finalize = finalize; @@ -242,9 +289,9 @@ nm_manager_class_init (NMManagerClass *manager_class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (NMManagerClass, connection_added), NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - G_TYPE_OBJECT); + nm_marshal_VOID__OBJECT_UINT, + G_TYPE_NONE, 2, + G_TYPE_OBJECT, G_TYPE_UINT); signals[CONNECTION_REMOVED] = g_signal_new ("connection-removed", @@ -252,9 +299,9 @@ nm_manager_class_init (NMManagerClass *manager_class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (NMManagerClass, connection_removed), NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - G_TYPE_OBJECT); + nm_marshal_VOID__OBJECT_UINT, + G_TYPE_NONE, 2, + G_TYPE_OBJECT, G_TYPE_UINT); dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (manager_class), &dbus_glib_nm_manager_object_info); @@ -294,6 +341,7 @@ connection_get_settings_cb (DBusGProxy *proxy, GError *err = NULL; GHashTable *settings = NULL; NMConnection *connection; + NMConnectionType connection_type; NMManager *manager; g_return_if_fail (info != NULL); @@ -324,10 +372,12 @@ connection_get_settings_cb (DBusGProxy *proxy, priv = NM_MANAGER_GET_PRIVATE (manager); if (strcmp (bus_name, NM_DBUS_SERVICE_USER_SETTINGS) == 0) { + connection_type = NM_CONNECTION_TYPE_USER; g_hash_table_insert (priv->user_connections, g_strdup (path), connection); } else if (strcmp (bus_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS) == 0) { + connection_type = NM_CONNECTION_TYPE_SYSTEM; g_hash_table_insert (priv->system_connections, g_strdup (path), connection); @@ -336,7 +386,7 @@ connection_get_settings_cb (DBusGProxy *proxy, g_assert_not_reached (); } - g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection); + g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection, connection_type); } else { // FIXME: merge settings? or just replace? nm_warning ("%s (#%d): implement merge settings", __func__, __LINE__); @@ -355,12 +405,15 @@ connection_removed_cb (DBusGProxy *proxy, gpointer user_data) const char *path = dbus_g_proxy_get_path (proxy); const char *bus_name = dbus_g_proxy_get_bus_name (proxy); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); + NMConnectionType connection_type; NMConnection *connection = NULL; GHashTable *hash = NULL; if (strcmp (bus_name, NM_DBUS_SERVICE_USER_SETTINGS) == 0) { + connection_type = NM_CONNECTION_TYPE_USER; hash = priv->user_connections; } else if (strcmp (bus_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS) == 0) { + connection_type = NM_CONNECTION_TYPE_SYSTEM; hash = priv->system_connections; } @@ -375,7 +428,7 @@ connection_removed_cb (DBusGProxy *proxy, gpointer user_data) */ g_object_ref (connection); g_hash_table_remove (hash, path); - g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection); + g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, connection_type); g_object_unref (connection); } @@ -562,7 +615,7 @@ initial_get_connections (gpointer user_data) } -static NMManager * +NMManager * nm_manager_new (void) { GObject *object; @@ -587,20 +640,6 @@ nm_manager_new (void) return NM_MANAGER (object); } -NMManager * -nm_manager_get (void) -{ - static NMManager *singleton = NULL; - - if (!singleton) - singleton = nm_manager_new (); - else - g_object_ref (singleton); - - g_assert (singleton); - return singleton; -} - static void nm_manager_connections_destroy (NMManager *manager, NMConnectionType type) @@ -747,40 +786,23 @@ impl_manager_get_devices (NMManager *manager, GPtrArray **devices, GError **err) } NMDevice * -nm_manager_get_device_by_iface (NMManager *manager, const char *iface) +nm_manager_get_device_by_path (NMManager *manager, const char *path) { GSList *iter; g_return_val_if_fail (NM_IS_MANAGER (manager), NULL); + g_return_val_if_fail (path != NULL, NULL); for (iter = NM_MANAGER_GET_PRIVATE (manager)->devices; iter; iter = iter->next) { NMDevice *device = NM_DEVICE (iter->data); - if (!strcmp (nm_device_get_iface (device), iface)) + if (!strcmp (nm_device_get_dbus_path (device), path)) return device; } return NULL; } -NMDevice * -nm_manager_get_device_by_index (NMManager *manager, int idx) -{ - GSList *iter; - - g_return_val_if_fail (NM_IS_MANAGER (manager), NULL); - - for (iter = NM_MANAGER_GET_PRIVATE (manager)->devices; iter; iter = iter->next) { - NMDevice *device = NM_DEVICE (iter->data); - - if (nm_device_get_index (device) == idx) - return device; - } - - return NULL; -} - - NMDevice * nm_manager_get_device_by_udi (NMManager *manager, const char *udi) { @@ -798,6 +820,170 @@ nm_manager_get_device_by_udi (NMManager *manager, const char *udi) return NULL; } +gboolean +nm_manager_activate_device (NMManager *manager, + NMDevice *device, + NMConnection *connection, + const char *specific_object, + gboolean user_requested) +{ + NMActRequest *req; + gboolean success; + + g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE); + g_return_val_if_fail (NM_IS_DEVICE (device), FALSE); + g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); + + req = nm_act_request_new (connection, specific_object, user_requested); + success = nm_device_interface_activate (NM_DEVICE_INTERFACE (device), req); + g_object_unref (req); + + return success; +} + +gboolean +nm_manager_activation_pending (NMManager *manager) +{ + g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE); + + return NM_MANAGER_GET_PRIVATE (manager)->pending_connection_info != NULL; +} + +static GError * +nm_manager_error_new (const gchar *format, ...) +{ + GError *err; + va_list args; + gchar *msg; + static GQuark domain_quark = 0; + + if (domain_quark == 0) + domain_quark = g_quark_from_static_string ("nm_manager_error"); + + va_start (args, format); + msg = g_strdup_vprintf (format, args); + va_end (args); + + err = g_error_new_literal (domain_quark, 1, (const gchar *) msg); + + g_free (msg); + + return err; +} + +static gboolean +wait_for_connection_expired (gpointer data) +{ + NMManager *manager = NM_MANAGER (data); + PendingConnectionInfo *info = NM_MANAGER_GET_PRIVATE (manager)->pending_connection_info; + GError *err; + + nm_info ("%s: didn't receive connection details soon enough for activation.", + nm_device_get_iface (info->device)); + + err = nm_manager_error_new ("Could not find connection"); + dbus_g_method_return_error (info->context, err); + g_error_free (err); + + info->timeout_id = 0; + pending_connection_info_destroy (manager); + + return FALSE; +} + +static void +connection_added_default_handler (NMManager *manager, + NMConnection *connection, + NMConnectionType connection_type) +{ + PendingConnectionInfo *info; + const char *path; + + if (!nm_manager_activation_pending (manager)) + return; + + info = NM_MANAGER_GET_PRIVATE (manager)->pending_connection_info; + if (connection_type != info->connection_type) + return; + + path = nm_manager_get_connection_dbus_path (manager, connection); + if (strcmp (info->connection_path, path)) + return; + + if (nm_manager_activate_device (manager, info->device, connection, info->specific_object_path, TRUE)) { + dbus_g_method_return (info->context, TRUE); + } else { + GError *err; + + err = nm_manager_error_new ("Error in device activation"); + dbus_g_method_return_error (info->context, err); + g_error_free (err); + } + + pending_connection_info_destroy (manager); +} + +static void +impl_manager_activate_device (NMManager *manager, + char *device_path, + char *service_name, + char *connection_path, + char *specific_object_path, + DBusGMethodInvocation *context) +{ + NMDevice *device; + NMConnectionType connection_type; + NMConnection *connection; + GError *err = NULL; + + device = nm_manager_get_device_by_path (manager, device_path); + if (!device) { + err = nm_manager_error_new ("Could not find device"); + goto err; + } + + nm_info ("User request for activation of %s.", nm_device_get_iface (device)); + + if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS)) + connection_type = NM_CONNECTION_TYPE_USER; + else if (!strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS)) + connection_type = NM_CONNECTION_TYPE_SYSTEM; + else { + err = nm_manager_error_new ("Invalid service name"); + goto err; + } + + connection = nm_manager_get_connection_by_object_path (manager, connection_type, connection_path); + if (connection) { + if (!nm_manager_activate_device (manager, device, connection, specific_object_path, TRUE)) { + err = nm_manager_error_new ("Error in device activation"); + goto err; + } + } else { + PendingConnectionInfo *info; + + /* Don't have the connection quite yet, probably created by + * the client on-the-fly. Defer the activation until we have it + */ + + info = g_slice_new0 (PendingConnectionInfo); + info->context = context; + info->device = g_object_ref (device); + info->connection_type = connection_type; + info->connection_path = g_strdup (connection_path); + info->specific_object_path = g_strdup (specific_object_path); + info->timeout_id = g_timeout_add (5000, wait_for_connection_expired, manager); + + NM_MANAGER_GET_PRIVATE (manager)->pending_connection_info = info; + } + + err: + if (err) { + dbus_g_method_return_error (context, err); + g_error_free (err); + } +} + gboolean nm_manager_wireless_enabled (NMManager *manager) { @@ -949,24 +1135,6 @@ nm_manager_get_connection_by_object_path (NMManager *manager, return connection; } -const char * -nm_manager_get_connection_service_name (NMManager *manager, - NMConnection *connection) -{ - DBusGProxy *proxy; - - g_return_val_if_fail (NM_IS_MANAGER (manager), NULL); - g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); - - proxy = g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_PROXY_TAG); - if (!DBUS_IS_G_PROXY (proxy)) { - nm_warning ("Couldn't get dbus proxy for connection."); - return NULL; - } - - return dbus_g_proxy_get_bus_name (proxy); -} - const char * nm_manager_get_connection_dbus_path (NMManager *manager, NMConnection *connection) diff --git a/src/nm-manager.h b/src/nm-manager.h index 80f912c99c..b7275eca7e 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -19,6 +19,12 @@ #define NM_MANAGER_CONNECTION_PROXY_TAG "dbus-proxy" +typedef enum { + NM_CONNECTION_TYPE_UNKNOWN = 0, + NM_CONNECTION_TYPE_SYSTEM, + NM_CONNECTION_TYPE_USER, +} NMConnectionType; + typedef struct { GObject parent; } NMManager; @@ -30,26 +36,37 @@ typedef struct { void (*device_added) (NMManager *manager, NMDevice *device); void (*device_removed) (NMManager *manager, NMDevice *device); void (*state_change) (NMManager *manager, guint state); + void (*connection_added) (NMManager *manager, + NMConnection *connection, + NMConnectionType connection_type); - void (*connection_added) (NMManager *manager, NMConnection *connection); - void (*connection_removed) (NMManager *manager, NMConnection *connection); + void (*connection_removed) (NMManager *manager, + NMConnection *connection, + NMConnectionType connection_type); } NMManagerClass; GType nm_manager_get_type (void); -NMManager *nm_manager_get (void); +NMManager *nm_manager_new (void); /* Device handling */ void nm_manager_add_device (NMManager *manager, NMDevice *device); void nm_manager_remove_device (NMManager *manager, NMDevice *device); GSList *nm_manager_get_devices (NMManager *manager); -NMDevice *nm_manager_get_device_by_iface (NMManager *manager, const char *iface); -NMDevice *nm_manager_get_device_by_index (NMManager *manager, int idx); +NMDevice *nm_manager_get_device_by_path (NMManager *manager, const char *path); NMDevice *nm_manager_get_device_by_udi (NMManager *manager, const char *udi); NMDevice *nm_manager_get_active_device (NMManager *manager); +gboolean nm_manager_activate_device (NMManager *manager, + NMDevice *device, + NMConnection *connection, + const char *specific_object, + gboolean user_requested); + +gboolean nm_manager_activation_pending (NMManager *manager); + /* State handling */ NMState nm_manager_get_state (NMManager *manager); @@ -57,11 +74,6 @@ gboolean nm_manager_wireless_enabled (NMManager *manager); void nm_manager_sleep (NMManager *manager, gboolean sleep); /* Connections */ -typedef enum { - NM_CONNECTION_TYPE_UNKNOWN = 0, - NM_CONNECTION_TYPE_SYSTEM, - NM_CONNECTION_TYPE_USER, -} NMConnectionType; GSList *nm_manager_get_connections (NMManager *manager, NMConnectionType type); void nm_manager_update_connections (NMManager *manager, @@ -73,9 +85,6 @@ NMConnection * nm_manager_get_connection_by_object_path (NMManager *manager, NMConnectionType type, const char *path); -const char * nm_manager_get_connection_service_name (NMManager *manager, - NMConnection *connection); - const char * nm_manager_get_connection_dbus_path (NMManager *manager, NMConnection *connection); diff --git a/src/nm-marshal.list b/src/nm-marshal.list index d747e0b8d2..850295388f 100644 --- a/src/nm-marshal.list +++ b/src/nm-marshal.list @@ -1,5 +1,6 @@ VOID:OBJECT VOID:OBJECT,STRING +VOID:OBJECT,UINT VOID:POINTER VOID:STRING,STRING,STRING VOID:UINT,UINT diff --git a/src/vpn-manager/nm-vpn-manager.c b/src/vpn-manager/nm-vpn-manager.c index 2387a98ae9..2ff14d6a91 100644 --- a/src/vpn-manager/nm-vpn-manager.c +++ b/src/vpn-manager/nm-vpn-manager.c @@ -97,24 +97,6 @@ nm_vpn_manager_connect (NMVPNManager *manager, return NULL; } -static NMDevice * -find_device (NMVPNManager *manager, const char *device_path) -{ - GSList *devices; - GSList *iter; - - devices = nm_manager_get_devices (NM_VPN_MANAGER_GET_PRIVATE (manager)->nm_manager); - - for (iter = devices; iter; iter = iter->next) { - NMDevice *device = NM_DEVICE (iter->data); - - if (!strcmp (device_path, nm_device_get_dbus_path (device))) - return device; - } - - return NULL; -} - static GError * new_vpn_error (const gchar *format, ...) { @@ -151,7 +133,7 @@ impl_vpn_manager_connect (NMVPNManager *manager, *vpn_connection_path = NULL; - device = find_device (manager, device_path); + device = nm_manager_get_device_by_path (manager, device_path); if (!device) { *err = new_vpn_error ("%s.%d: No active device was found.", __FILE__, __LINE__);