diff --git a/ChangeLog b/ChangeLog index f28aa3dc6f..a85d27c717 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,43 @@ +2007-09-09 Dan Williams + + * introspection/nm-device.xml + - The 'Activate' method now takes 3 arguments, a service name for the + settings service (user or system), the object path of the connection + to activate, and the specific object to activate, if any + + * src/nm-device-interface.c + - (nm_device_interface_error_quark, nm_device_interface_error_get_type): + Add error bits + - (impl_device_activate): adapt to new Activate arguments; validate + the service name and get the Connection object from the NMManager + before starting to activate the device with the specified connection + + * src/nm-device-802-3-ethernet.c + - (real_get_best_connection): find the best connection, or create a + default one if no existing connections can be used + + * src/NetworkManagerPolicy.c + - (nm_policy_auto_get_best_device): Get the device's best connection + and only pick the device if it has one + - (nm_policy_device_change_check): disable wireless bits for now until + wireless get_best_connection() can be implemented (replacing "best_ap"); + don't create a default connection here as the device subclass will do + that if needed + + * src/nm-manager.h + src/nm-manager.c + - (nm_manager_get): make NMManager a singleton and expose the getter + internally + - Rework internal NMManager connection handling to use the same + routines for both the system and user settings services. Most calls + take a new NMConnectionType argument specifying either system or user + connections + - (nm_manager_get_connection_by_object_path): new function; get a + connection keyed on its object path + + * src/NetworkManager.c + - (main): use nm_manager_get() + 2007-09-09 Dan Williams * src/nm-device.h diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml index 03b6649dfc..938f50aa2d 100644 --- a/introspection/nm-device.xml +++ b/introspection/nm-device.xml @@ -4,7 +4,7 @@ - + diff --git a/src/NetworkManager.c b/src/NetworkManager.c index 439a5a8191..d0ce08cac3 100644 --- a/src/NetworkManager.c +++ b/src/NetworkManager.c @@ -325,7 +325,7 @@ main (int argc, char *argv[]) goto done; } - manager = nm_manager_new (); + manager = nm_manager_get (); if (manager == NULL) { nm_error ("Failed to initialize the network manager."); goto done; diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c index 0fbd4bbc1c..bfe26ef727 100644 --- a/src/NetworkManagerPolicy.c +++ b/src/NetworkManagerPolicy.c @@ -64,48 +64,50 @@ static NMPolicy *global_policy; * "locked" on one device at this time. * */ -static NMDevice * nm_policy_auto_get_best_device (NMPolicy *policy, NMAccessPoint **ap) +static NMDevice * +nm_policy_auto_get_best_device (NMPolicy *policy, + NMConnection **connection) { GSList * elt; NMDevice8023Ethernet * best_wired_dev = NULL; guint best_wired_prio = 0; + NMConnection * best_wired_connection = NULL; NMDevice80211Wireless * best_wireless_dev = NULL; guint best_wireless_prio = 0; + NMConnection * best_wireless_connection = NULL; NMDevice * highest_priority_dev = NULL; - g_return_val_if_fail (ap != NULL, NULL); + g_return_val_if_fail (connection != NULL, NULL); + g_return_val_if_fail (*connection == NULL, NULL); if (nm_manager_get_state (policy->manager) == NM_STATE_ASLEEP) return NULL; for (elt = nm_manager_get_devices (policy->manager); elt; elt = elt->next) { - gboolean link_active; - guint prio = 0; - NMDevice * dev = (NMDevice *)(elt->data); - guint32 caps; + NMConnection *tmp_con = NULL; + gboolean link_active; + guint prio = 0; + NMDevice * dev = (NMDevice *)(elt->data); + guint32 caps; link_active = nm_device_has_active_link (dev); caps = nm_device_get_capabilities (dev); - /* Don't use devices that SUCK */ - if (!(caps & NM_DEVICE_CAP_NM_SUPPORTED)) + tmp_con = nm_device_get_best_connection (dev); + if (tmp_con == NULL) continue; if (NM_IS_DEVICE_802_3_ETHERNET (dev)) { - /* We never automatically choose devices that don't support carrier detect */ - if (!(caps & NM_DEVICE_CAP_CARRIER_DETECT)) - continue; - if (link_active) prio += 1; if (nm_device_get_act_request (dev) && link_active) prio += 1; - if (prio > best_wired_prio) - { + if (prio > best_wired_prio) { best_wired_dev = NM_DEVICE_802_3_ETHERNET (dev); best_wired_prio = prio; + best_wired_connection = tmp_con; } } else if (NM_IS_DEVICE_802_11_WIRELESS (dev) && @@ -119,40 +121,46 @@ static NMDevice * nm_policy_auto_get_best_device (NMPolicy *policy, NMAccessPoin if (nm_device_get_act_request (dev) && link_active) prio += 3; - if (prio > best_wireless_prio) - { + if (prio > best_wireless_prio) { best_wireless_dev = NM_DEVICE_802_11_WIRELESS (dev); best_wireless_prio = prio; + best_wireless_connection = tmp_con; } } } - if (best_wired_dev) + if (best_wired_dev) { highest_priority_dev = NM_DEVICE (best_wired_dev); - else if (best_wireless_dev) - { + *connection = best_wired_connection; + } else if (best_wireless_dev) { gboolean can_activate; can_activate = nm_device_802_11_wireless_can_activate (best_wireless_dev); - - *ap = nm_device_802_11_wireless_get_best_ap (best_wireless_dev); - /* If the device doesn't have a "best" ap, then we can't use it */ - if (!*ap) - highest_priority_dev = NULL; - else if (can_activate == TRUE) + if (can_activate) { highest_priority_dev = NM_DEVICE (best_wireless_dev); + *connection = best_wireless_connection; + } } +out: if (FALSE) { - const GByteArray * ssid = (best_wireless_dev && *ap) ? nm_ap_get_ssid (*ap) : NULL; + char * con_name = g_strdup ("(none)"); - nm_info ("AUTO: Best wired device = %s, best wireless device = %s (%s)", + if (*connection) { + NMSettingConnection * s_con; + + s_con = (NMSettingConnection *) nm_connection_get_setting (*connection, "connection"); + con_name = g_strdup (s_con->name); + } + + nm_info ("AUTO: Best wired device = %s, best wireless device = %s, best connection name = '%s'", best_wired_dev ? nm_device_get_iface (NM_DEVICE (best_wired_dev)) : "(null)", best_wireless_dev ? nm_device_get_iface (NM_DEVICE (best_wireless_dev)) : "(null)", - ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "null" ); + con_name); + g_free (con_name); } - return highest_priority_dev; + return *connection ? highest_priority_dev : NULL; } static NMConnection * @@ -214,10 +222,10 @@ nm_policy_device_change_check (gpointer user_data) { NMPolicy *policy = (NMPolicy *) user_data; GSList *iter; - NMAccessPoint * ap = NULL; - NMDevice * new_dev = NULL; - NMDevice * old_dev = NULL; - gboolean do_switch = FALSE; + NMConnection * connection = NULL; + NMDevice * new_dev = NULL; + NMDevice * old_dev = NULL; + gboolean do_switch = FALSE; switch (nm_manager_get_state (policy->manager)) { case NM_STATE_CONNECTED: @@ -258,7 +266,7 @@ nm_policy_device_change_check (gpointer user_data) } } - new_dev = nm_policy_auto_get_best_device (policy, &ap); + new_dev = nm_policy_auto_get_best_device (policy, &connection); /* Four cases here: * @@ -306,6 +314,7 @@ nm_policy_device_change_check (gpointer user_data) do_switch = TRUE; } } else if (NM_IS_DEVICE_802_11_WIRELESS (old_dev)) { +#if 0 /* Only switch if the old device's wireless config is invalid */ if (NM_IS_DEVICE_802_11_WIRELESS (new_dev)) { NMAccessPoint *old_ap = nm_device_802_11_wireless_get_activation_ap (NM_DEVICE_802_11_WIRELESS (old_dev)); @@ -352,6 +361,7 @@ nm_policy_device_change_check (gpointer user_data) if (!old_user_requested) do_switch = TRUE; } +#endif } } @@ -361,18 +371,11 @@ nm_policy_device_change_check (gpointer user_data) } if (new_dev) { - NMConnection *connection; - - connection = create_connection (new_dev, ap); - if (connection) - nm_device_interface_activate (NM_DEVICE_INTERFACE (new_dev), - connection, NULL, FALSE); + nm_device_interface_activate (NM_DEVICE_INTERFACE (new_dev), + connection, NULL, FALSE); } } - if (ap) - g_object_unref (ap); - out: return FALSE; } diff --git a/src/nm-device-802-3-ethernet.c b/src/nm-device-802-3-ethernet.c index 5e8fd376f8..4c18a7e876 100644 --- a/src/nm-device-802-3-ethernet.c +++ b/src/nm-device-802-3-ethernet.c @@ -34,6 +34,7 @@ #include "nm-supplicant-manager.h" #include "nm-netlink-monitor.h" #include "nm-utils.h" +#include "nm-manager.h" #include "nm-device-802-3-ethernet-glue.h" @@ -344,6 +345,95 @@ real_check_connection (NMDevice *dev, NMConnection *connection) return TRUE; } +typedef struct BestConnectionInfo { + NMDevice8023Ethernet * self; + NMConnection * found; +} BestConnectionInfo; + +static void +find_best_connection (gpointer data, gpointer user_data) +{ + BestConnectionInfo * info = (BestConnectionInfo *) user_data; + NMConnection *connection = NM_CONNECTION (data); + NMSettingConnection * s_con; + NMSettingWired * s_wired; + + if (info->found) + return; + + s_con = (NMSettingConnection *) nm_connection_get_setting (connection, "connection"); + if (s_con == NULL) + return; + if (strcmp (s_con->devtype, "802-3-ethernet")) + return; + if (!s_con->autoconnect) + return; + + s_wired = (NMSettingWired *) nm_connection_get_setting (connection, "802-3-ethernet"); + if (s_wired == NULL) + return; + + info->found = connection; +} + +static NMConnection * +real_get_best_connection (NMDevice *dev) +{ + NMDevice8023Ethernet * self = NM_DEVICE_802_3_ETHERNET (dev); + NMManager *manager = nm_manager_get (); + GSList *connections = NULL; + BestConnectionInfo find_info; + guint32 caps; + gboolean link_active; + + caps = nm_device_get_capabilities (dev); + + /* FIXME: for now, non-carrier-detect devices don't have a best connection, + * the user needs to pick one. In the near-future, we want to instead + * honor the first 'autoconnect':True connection we find that applies + * to this device. + */ + if (!(caps & NM_DEVICE_CAP_CARRIER_DETECT)) + return NULL; + + /* System connections first */ + connections = nm_manager_get_connections (manager, NM_CONNECTION_TYPE_SYSTEM); + memset (&find_info, 0, sizeof (BestConnectionInfo)); + find_info.self = self; + g_slist_foreach (connections, find_best_connection, &find_info); + g_slist_free (connections); + + /* Then user connections */ + if (!find_info.found) { + connections = nm_manager_get_connections (manager, NM_CONNECTION_TYPE_USER); + find_info.self = self; + g_slist_foreach (connections, find_best_connection, &find_info); + g_slist_free (connections); + } + + /* Wired devices autoconnect with DHCP by default if they have a link */ + link_active = nm_device_has_active_link (dev); + if (!find_info.found && link_active) { + NMConnection *connection; + NMSetting *setting; + NMSettingConnection *scon; + + connection = nm_connection_new (); + setting = nm_setting_wired_new (); + nm_connection_add_setting (connection, setting); + + scon = (NMSettingConnection *) nm_setting_connection_new (); + scon->name = g_strdup ("Auto"); + scon->devtype = g_strdup (setting->name); + nm_connection_add_setting (connection, (NMSetting *) scon); + + find_info.found = connection; + } + + return find_info.found; +} + + static void nm_device_802_3_ethernet_finalize (GObject *object) { @@ -400,6 +490,7 @@ nm_device_802_3_ethernet_class_init (NMDevice8023EthernetClass *klass) parent_class->can_interrupt_activation = real_can_interrupt_activation; parent_class->set_hw_address = real_set_hw_address; parent_class->check_connection = real_check_connection; + parent_class->get_best_connection = real_get_best_connection; /* properties */ g_object_class_install_property diff --git a/src/nm-device-interface.c b/src/nm-device-interface.c index ff4a579591..213e5c57e4 100644 --- a/src/nm-device-interface.c +++ b/src/nm-device-interface.c @@ -1,16 +1,46 @@ #include "nm-device-interface.h" #include "nm-ip4-config.h" +#include "nm-manager.h" static gboolean impl_device_activate (NMDeviceInterface *device, - GHashTable *connection_hash, - const char *specific_object, - GError **err); + 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" +GQuark +nm_device_interface_error_quark (void) +{ + static GQuark quark = 0; + if (!quark) + quark = g_quark_from_static_string ("nm_device_interface_error"); + return quark; +} + +/* This should really be standard. */ +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } + +GType +nm_device_interface_error_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) { + static const GEnumValue values[] = { + ENUM_ENTRY (NM_DEVICE_INTERFACE_ERROR_UNKNOWN_CONNECTION, "UnknownConnection"), + { 0, 0, 0 } + }; + etype = g_enum_register_static ("NMDeviceInterfaceError", values); + } + return etype; +} + + static void nm_device_interface_init (gpointer g_iface) { @@ -164,18 +194,41 @@ nm_device_interface_activate (NMDeviceInterface *device, static gboolean impl_device_activate (NMDeviceInterface *device, - GHashTable *connection_hash, - const char *specific_object, - GError **err) + const char *service_name, + const char *connection_path, + const char *specific_object, + GError **err) { + NMManager *manager; NMConnection *connection; + gboolean success = FALSE; + + manager = nm_manager_get (); + if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS)) { + connection = nm_manager_get_connection_by_object_path (manager, + NM_CONNECTION_TYPE_USER, + connection_path); + } else if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS)) { + connection = nm_manager_get_connection_by_object_path (manager, + NM_CONNECTION_TYPE_SYSTEM, + connection_path); + } + + if (connection == NULL) { + g_set_error (err, + NM_DEVICE_INTERFACE_ERROR, + NM_DEVICE_INTERFACE_ERROR_UNKNOWN_CONNECTION, + "%s", + "Connection object or service unknown"); + goto out; + } - connection = nm_connection_new_from_hash (connection_hash); nm_connection_dump (connection); - nm_device_interface_activate (device, connection, specific_object, TRUE); + success = TRUE; - return TRUE; +out: + return success; } void diff --git a/src/nm-manager.c b/src/nm-manager.c index 52c2053d69..ebc5893939 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -20,14 +20,19 @@ static gboolean impl_manager_legacy_state (NMManager *manager, GError **err); #include "nm-manager-glue.h" -static void nm_manager_user_connections_destroy (NMManager *manager); +static void nm_manager_connections_destroy (NMManager *manager, NMConnectionType type); static void manager_state_changed (NMManager *manager); static void manager_set_wireless_enabled (NMManager *manager, gboolean enabled); typedef struct { GSList *devices; + GHashTable *user_connections; DBusGProxy *user_proxy; + + GHashTable *system_connections; + DBusGProxy *system_proxy; + gboolean wireless_enabled; gboolean sleeping; } NMManagerPrivate; @@ -68,6 +73,11 @@ nm_manager_init (NMManager *manager) g_str_equal, g_free, g_object_unref); + + priv->system_connections = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_object_unref); } static void @@ -76,10 +86,14 @@ finalize (GObject *object) NMManager *manager = NM_MANAGER (object); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); - nm_manager_user_connections_destroy (manager); + nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_USER); g_hash_table_destroy (priv->user_connections); priv->user_connections = NULL; + nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_SYSTEM); + g_hash_table_destroy (priv->system_connections); + priv->system_connections = NULL; + while (g_slist_length (priv->devices)) nm_manager_remove_device (manager, NM_DEVICE (priv->devices->data)); @@ -400,43 +414,57 @@ out: } static void -query_user_connections (NMManager *manager) +query_connections (NMManager *manager, + NMConnectionType type) { NMManagerPrivate *priv; DBusGProxyCall *call; + DBusGProxy ** proxy; + const char * service; g_return_if_fail (NM_IS_MANAGER (manager)); + if (type == NM_CONNECTION_TYPE_USER) { + proxy = &priv->user_proxy; + service = NM_DBUS_SERVICE_USER_SETTINGS; + } else if (type == NM_CONNECTION_TYPE_SYSTEM) { + proxy = &priv->system_proxy; + service = NM_DBUS_SERVICE_SYSTEM_SETTINGS; + } else { + nm_warning ("Unknown NMConnectionType %d", type); + return; + } + priv = NM_MANAGER_GET_PRIVATE (manager); - if (!priv->user_proxy) { + if (!*proxy) { NMDBusManager * dbus_mgr; DBusGConnection * g_connection; dbus_mgr = nm_dbus_manager_get (); g_connection = nm_dbus_manager_get_connection (dbus_mgr); - priv->user_proxy = dbus_g_proxy_new_for_name (g_connection, - NM_DBUS_SERVICE_USER_SETTINGS, - NM_DBUS_PATH_SETTINGS, - NM_DBUS_IFACE_SETTINGS); + *proxy = dbus_g_proxy_new_for_name (g_connection, + service, + NM_DBUS_PATH_SETTINGS, + NM_DBUS_IFACE_SETTINGS); g_object_unref (dbus_mgr); - if (!priv->user_proxy) { - nm_warning ("Error: could not init user settings proxy"); + if (!*proxy) { + nm_warning ("Error: could not init settings proxy"); return; } - dbus_g_proxy_add_signal (priv->user_proxy, + dbus_g_proxy_add_signal (*proxy, "NewConnection", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->user_proxy, "NewConnection", + dbus_g_proxy_connect_signal (*proxy, "NewConnection", G_CALLBACK (new_connection_cb), manager, NULL); } /* grab connections */ - call = dbus_g_proxy_begin_call (priv->user_proxy, "ListConnections", + call = dbus_g_proxy_begin_call (*proxy, "ListConnections", list_connections_cb, manager, NULL, @@ -457,10 +485,18 @@ nm_manager_name_owner_changed (NMDBusManager *mgr, if (strcmp (name, NM_DBUS_SERVICE_USER_SETTINGS) == 0) { if (!old_owner_good && new_owner_good) { /* User Settings service appeared, update stuff */ - query_user_connections (manager); + query_connections (manager, NM_CONNECTION_TYPE_USER); } else { /* User Settings service disappeared, throw them away (?) */ - nm_manager_user_connections_destroy (manager); + nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_USER); + } + } else if (strcmp (name, NM_DBUS_SERVICE_SYSTEM_SETTINGS) == 0) { + if (!old_owner_good && new_owner_good) { + /* System Settings service appeared, update stuff */ + query_connections (manager, NM_CONNECTION_TYPE_SYSTEM); + } else { + /* System Settings service disappeared, throw them away (?) */ + nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_SYSTEM); } } } @@ -472,13 +508,17 @@ initial_get_connections (gpointer user_data) if (nm_dbus_manager_name_has_owner (nm_dbus_manager_get (), NM_DBUS_SERVICE_USER_SETTINGS)) - query_user_connections (manager); + query_connections (manager, NM_CONNECTION_TYPE_USER); + + if (nm_dbus_manager_name_has_owner (nm_dbus_manager_get (), + NM_DBUS_SERVICE_SYSTEM_SETTINGS)) + query_connections (manager, NM_CONNECTION_TYPE_SYSTEM); return FALSE; } -NMManager * +static NMManager * nm_manager_new (void) { GObject *object; @@ -503,17 +543,44 @@ 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_user_connections_destroy (NMManager *manager) +nm_manager_connections_destroy (NMManager *manager, + NMConnectionType type) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); - if (priv->user_connections) - g_hash_table_remove_all (priv->user_connections); + if (type == NM_CONNECTION_TYPE_USER) { + if (priv->user_connections) + g_hash_table_remove_all (priv->user_connections); - if (priv->user_proxy) { - g_object_unref (priv->user_proxy); - priv->user_proxy = NULL; + if (priv->user_proxy) { + g_object_unref (priv->user_proxy); + priv->user_proxy = NULL; + } + } else if (type == NM_CONNECTION_TYPE_SYSTEM) { + if (priv->system_connections) + g_hash_table_remove_all (priv->system_connections); + + if (priv->system_proxy) { + g_object_unref (priv->system_proxy); + priv->system_proxy = NULL; + } + } else { + nm_warning ("Unknown NMConnectionType %d", type); } } @@ -837,7 +904,8 @@ connections_to_slist (gpointer key, gpointer value, gpointer user_data) * unref the connections in the list and destroy the list. */ GSList * -nm_manager_get_user_connections (NMManager *manager) +nm_manager_get_connections (NMManager *manager, + NMConnectionType type) { NMManagerPrivate *priv; GSList *list = NULL; @@ -845,18 +913,45 @@ nm_manager_get_user_connections (NMManager *manager) g_return_val_if_fail (NM_IS_MANAGER (manager), NULL); priv = NM_MANAGER_GET_PRIVATE (manager); - g_hash_table_foreach (priv->user_connections, connections_to_slist, &list); + if (type == NM_CONNECTION_TYPE_USER) + g_hash_table_foreach (priv->user_connections, connections_to_slist, &list); + else if (type == NM_CONNECTION_TYPE_SYSTEM) + g_hash_table_foreach (priv->system_connections, connections_to_slist, &list); + else + nm_warning ("Unknown NMConnectionType %d", type); return list; } +NMConnection * +nm_manager_get_connection_by_object_path (NMManager *manager, + NMConnectionType type, + const char *path) +{ + NMManagerPrivate *priv; + NMConnection *connection = NULL; + + g_return_val_if_fail (NM_IS_MANAGER (manager), NULL); + g_return_val_if_fail (path != NULL, NULL); + + priv = NM_MANAGER_GET_PRIVATE (manager); + if (type == NM_CONNECTION_TYPE_USER) + connection = (NMConnection *) g_hash_table_lookup (priv->user_connections, path); + else if (type == NM_CONNECTION_TYPE_SYSTEM) + connection = (NMConnection *) g_hash_table_lookup (priv->system_connections, path); + else + nm_warning ("Unknown NMConnectionType %d", type); + return connection; +} + void -nm_manager_update_user_connections (NMManager *manager, - GSList *connections, - gboolean reset) +nm_manager_update_connections (NMManager *manager, + NMConnectionType type, + GSList *connections, + gboolean reset) { g_return_if_fail (NM_IS_MANAGER (manager)); if (reset) - nm_manager_user_connections_destroy (manager); + nm_manager_connections_destroy (manager, type); } diff --git a/src/nm-manager.h b/src/nm-manager.h index 733ba3d7f6..133e5fdc63 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -34,7 +34,7 @@ typedef struct { GType nm_manager_get_type (void); -NMManager *nm_manager_new (void); +NMManager *nm_manager_get (void); /* Device handling */ @@ -54,15 +54,19 @@ gboolean nm_manager_wireless_enabled (NMManager *manager); void nm_manager_sleep (NMManager *manager, gboolean sleep); /* Connections */ +typedef enum { + NM_CONNECTION_TYPE_SYSTEM = 0, + NM_CONNECTION_TYPE_USER, +} NMConnectionType; -GSList *nm_manager_get_user_connections (NMManager *manager); -void nm_manager_update_user_connections (NMManager *manager, - GSList *connections, - gboolean reset); +GSList *nm_manager_get_connections (NMManager *manager, NMConnectionType type); +void nm_manager_update_connections (NMManager *manager, + NMConnectionType type, + GSList *connections, + gboolean reset); -GSList *nm_manager_get_system_connections (NMManager *manager); -void nm_manager_update_system_connections (NMManager *manager, - GSList *connections, - gboolean reset); +NMConnection * nm_manager_get_connection_by_object_path (NMManager *manager, + NMConnectionType type, + const char *path); #endif /* NM_MANAGER_H */