summary refs log tree commit diff
path: root/libnm-glib
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-glib')
-rw-r--r--libnm-glib/Makefile.am2
-rw-r--r--libnm-glib/Makefile.in2
-rw-r--r--libnm-glib/libnm-glib-vpn.pc.in2
-rw-r--r--libnm-glib/libnm-glib.pc.in2
-rw-r--r--libnm-glib/libnm-glib.ver1
-rw-r--r--libnm-glib/nm-client.c36
-rw-r--r--libnm-glib/nm-client.h1
-rw-r--r--libnm-glib/nm-device-wifi.c10
-rw-r--r--libnm-glib/nm-device-wimax.c10
-rw-r--r--libnm-glib/nm-device.c43
-rw-r--r--libnm-glib/nm-object.c10
-rw-r--r--libnm-glib/nm-remote-settings.c9
-rw-r--r--libnm-glib/nm-vpn-plugin-ui-interface.c16
-rw-r--r--libnm-glib/nm-vpn-plugin-ui-interface.h14
14 files changed, 93 insertions, 65 deletions
diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am
index 08a61cc2..4eec4016 100644
--- a/libnm-glib/Makefile.am
+++ b/libnm-glib/Makefile.am
@@ -139,7 +139,7 @@ libnm_glib_la_LIBADD = \
 SYMBOL_VIS_FILE=$(srcdir)/libnm-glib.ver
 
 libnm_glib_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \
-	-version-info "5:0:1"
+	-version-info "6:0:2"
 
 noinst_PROGRAMS = libnm-glib-test
 
diff --git a/libnm-glib/Makefile.in b/libnm-glib/Makefile.in
index 98280865..9728f7d9 100644
--- a/libnm-glib/Makefile.in
+++ b/libnm-glib/Makefile.in
@@ -599,7 +599,7 @@ libnm_glib_la_LIBADD = \
 
 SYMBOL_VIS_FILE = $(srcdir)/libnm-glib.ver
 libnm_glib_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \
-	-version-info "5:0:1"
+	-version-info "6:0:2"
 
 libnm_glib_test_SOURCES = libnm-glib-test.c
 libnm_glib_test_CFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS)
diff --git a/libnm-glib/libnm-glib-vpn.pc.in b/libnm-glib/libnm-glib-vpn.pc.in
index 5f341594..046f5b07 100644
--- a/libnm-glib/libnm-glib-vpn.pc.in
+++ b/libnm-glib/libnm-glib-vpn.pc.in
@@ -6,7 +6,7 @@ includedir=@includedir@
 Name: libnm-glib-vpn
 Description: Convenience library for NetworkManager VPN plugins
 Version: @VERSION@
-Requires: NetworkManager >= 0.8.995 glib-2.0 dbus-glib-1
+Requires: NetworkManager >= @VERSION@ glib-2.0 dbus-glib-1
 Cflags: -I${includedir}/libnm-glib
 Libs: -L${libdir} -lnm-glib-vpn
 
diff --git a/libnm-glib/libnm-glib.pc.in b/libnm-glib/libnm-glib.pc.in
index 2668b4e5..754c43da 100644
--- a/libnm-glib/libnm-glib.pc.in
+++ b/libnm-glib/libnm-glib.pc.in
@@ -6,7 +6,7 @@ includedir=@includedir@
 Name: libnm-glib
 Description: Convenience library for clients of NetworkManager
 Version: @VERSION@
-Requires: NetworkManager >= 0.8.995 gobject-2.0 dbus-glib-1
+Requires: NetworkManager >= @VERSION@ gobject-2.0 dbus-glib-1
 Cflags: -I${includedir}/libnm-glib
 Libs: -L${libdir} -lnm-glib
 
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver
index f42368b8..1a4a68cf 100644
--- a/libnm-glib/libnm-glib.ver
+++ b/libnm-glib/libnm-glib.ver
@@ -32,6 +32,7 @@ global:
 	nm_client_add_and_activate_connection;
 	nm_client_deactivate_connection;
 	nm_client_get_active_connections;
+	nm_client_get_device_by_iface;
 	nm_client_get_device_by_path;
 	nm_client_get_devices;
 	nm_client_get_manager_running;
diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c
index 644af3e4..0769de1a 100644
--- a/libnm-glib/nm-client.c
+++ b/libnm-glib/nm-client.c
@@ -557,6 +557,40 @@ nm_client_get_device_by_path (NMClient *client, const char *object_path)
 	return device;
 }
 
+/**
+ * nm_client_get_device_by_iface:
+ * @client: a #NMClient
+ * @iface: the interface name to search for
+ *
+ * Gets a #NMDevice from a #NMClient.
+ *
+ * Returns: (transfer none): the #NMDevice for the given @iface or %NULL if none is found.
+ **/
+NMDevice *
+nm_client_get_device_by_iface (NMClient *client, const char *iface)
+{
+	const GPtrArray *devices;
+	int i;
+	NMDevice *device = NULL;
+
+	g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
+	g_return_val_if_fail (iface, NULL);
+
+	devices = nm_client_get_devices (client);
+	if (!devices)
+		return NULL;
+
+	for (i = 0; i < devices->len; i++) {
+		NMDevice *candidate = g_ptr_array_index (devices, i);
+		if (!strcmp (nm_device_get_iface (candidate), iface)) {
+			device = candidate;
+			break;
+		}
+	}
+
+	return device;
+}
+
 typedef struct {
 	NMClient *client;
 	NMClientActivateFn act_fn;
@@ -763,7 +797,7 @@ nm_client_add_and_activate_connection (NMClient *client,
 
 	if (partial)
 		hash = nm_connection_to_hash (partial, NM_SETTING_HASH_FLAG_ALL);
-	else
+	if (!hash)
 		hash = g_hash_table_new (g_str_hash, g_str_equal);
 
 	priv = NM_CLIENT_GET_PRIVATE (client);
diff --git a/libnm-glib/nm-client.h b/libnm-glib/nm-client.h
index 450c0947..c9fd7c10 100644
--- a/libnm-glib/nm-client.h
+++ b/libnm-glib/nm-client.h
@@ -108,6 +108,7 @@ NMClient *nm_client_new (void);
 
 const GPtrArray *nm_client_get_devices    (NMClient *client);
 NMDevice *nm_client_get_device_by_path    (NMClient *client, const char *object_path);
+NMDevice *nm_client_get_device_by_iface   (NMClient *client, const char *iface);
 
 typedef void (*NMClientActivateFn) (NMClient *client,
                                     NMActiveConnection *active_connection,
diff --git a/libnm-glib/nm-device-wifi.c b/libnm-glib/nm-device-wifi.c
index 9877f94f..7d0e1b9f 100644
--- a/libnm-glib/nm-device-wifi.c
+++ b/libnm-glib/nm-device-wifi.c
@@ -637,12 +637,10 @@ demarshal_active_ap (NMObject *object, GParamSpec *pspec, GValue *value, gpointe
 	NMAccessPoint *ap = NULL;
 	DBusGConnection *connection;
 
-	if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
-		return FALSE;
-
-	priv->got_active_ap = TRUE;
-
 	if (value) {
+		if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
+			return FALSE;
+
 		path = g_value_get_boxed (value);
 		if (path) {
 			ap = NM_ACCESS_POINT (_nm_object_cache_get (path));
@@ -653,6 +651,8 @@ demarshal_active_ap (NMObject *object, GParamSpec *pspec, GValue *value, gpointe
 		}
 	}
 
+	priv->got_active_ap = TRUE;
+
 	if (priv->active_ap) {
 		g_object_unref (priv->active_ap);
 		priv->active_ap = NULL;
diff --git a/libnm-glib/nm-device-wimax.c b/libnm-glib/nm-device-wimax.c
index a889583d..4844a0e2 100644
--- a/libnm-glib/nm-device-wimax.c
+++ b/libnm-glib/nm-device-wimax.c
@@ -628,12 +628,10 @@ demarshal_active_nsp (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
 	NMWimaxNsp *nsp = NULL;
 	DBusGConnection *connection;
 
-	if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
-		return FALSE;
-
-	priv->got_active_nsp = TRUE;
-
 	if (value) {
+		if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
+			return FALSE;
+
 		path = g_value_get_boxed (value);
 		if (path) {
 			nsp = NM_WIMAX_NSP (_nm_object_cache_get (path));
@@ -644,6 +642,8 @@ demarshal_active_nsp (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
 		}
 	}
 
+	priv->got_active_nsp = TRUE;
+
 	if (priv->active_nsp) {
 		g_object_unref (priv->active_nsp);
 		priv->active_nsp = NULL;
diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c
index 3b39c9ec..f06c1e4a 100644
--- a/libnm-glib/nm-device.c
+++ b/libnm-glib/nm-device.c
@@ -120,12 +120,10 @@ demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
 	NMIP4Config *config = NULL;
 	DBusGConnection *connection;
 
-	if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
-		return FALSE;
-
-	priv->got_ip4_config = TRUE;
-
 	if (value) {
+		if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
+			return FALSE;
+
 		path = g_value_get_boxed (value);
 		if (path) {
 			config = NM_IP4_CONFIG (_nm_object_cache_get (path));
@@ -136,6 +134,8 @@ demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
 		}
 	}
 
+	priv->got_ip4_config = TRUE;
+
 	if (priv->ip4_config) {
 		g_object_unref (priv->ip4_config);
 		priv->ip4_config = NULL;
@@ -156,12 +156,10 @@ demarshal_dhcp4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi
 	NMDHCP4Config *config = NULL;
 	DBusGConnection *connection;
 
-	if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
-		return FALSE;
-
-	priv->got_dhcp4_config = TRUE;
-
 	if (value) {
+		if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
+			return FALSE;
+
 		path = g_value_get_boxed (value);
 		if (path) {
 			config = NM_DHCP4_CONFIG (_nm_object_cache_get (path));
@@ -172,6 +170,8 @@ demarshal_dhcp4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi
 		}
 	}
 
+	priv->got_dhcp4_config = TRUE;
+
 	if (priv->dhcp4_config) {
 		g_object_unref (priv->dhcp4_config);
 		priv->dhcp4_config = NULL;
@@ -192,12 +192,10 @@ demarshal_ip6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
 	NMIP6Config *config = NULL;
 	DBusGConnection *connection;
 
-	if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
-		return FALSE;
-
-	priv->got_ip6_config = TRUE;
-
 	if (value) {
+		if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
+			return FALSE;
+
 		path = g_value_get_boxed (value);
 		if (path) {
 			config = NM_IP6_CONFIG (_nm_object_cache_get (path));
@@ -208,6 +206,8 @@ demarshal_ip6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
 		}
 	}
 
+	priv->got_ip6_config = TRUE;
+
 	if (priv->ip6_config) {
 		g_object_unref (priv->ip6_config);
 		priv->ip6_config = NULL;
@@ -228,12 +228,10 @@ demarshal_dhcp6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi
 	NMDHCP6Config *config = NULL;
 	DBusGConnection *connection;
 
-	if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
-		return FALSE;
-
-	priv->got_dhcp6_config = TRUE;
-
 	if (value) {
+		if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
+			return FALSE;
+
 		path = g_value_get_boxed (value);
 		if (path) {
 			config = NM_DHCP6_CONFIG (_nm_object_cache_get (path));
@@ -244,6 +242,8 @@ demarshal_dhcp6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi
 		}
 	}
 
+	priv->got_dhcp6_config = TRUE;
+
 	if (priv->dhcp6_config) {
 		g_object_unref (priv->dhcp6_config);
 		priv->dhcp6_config = NULL;
@@ -1217,7 +1217,8 @@ nm_device_get_state (NMDevice *device)
  *
  * Gets the #NMActiveConnection object which owns this device during activation.
  *
- * Returns: the #NMActiveConnection
+ * Returns: (transfer none): the #NMActiveConnection or %NULL if the device is
+ * not part of an active connection
  **/
 NMActiveConnection *
 nm_device_get_active_connection (NMDevice *device)
diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c
index 614f6afc..cbcf2919 100644
--- a/libnm-glib/nm-object.c
+++ b/libnm-glib/nm-object.c
@@ -79,8 +79,6 @@ constructor (GType type,
 	if (!object)
 		return NULL;
 
-	_nm_object_cache_add (NM_OBJECT (object));
-
 	priv = NM_OBJECT_GET_PRIVATE (object);
 
 	if (priv->connection == NULL || priv->path == NULL) {
@@ -94,6 +92,8 @@ constructor (GType type,
 														priv->path,
 														"org.freedesktop.DBus.Properties");
 
+	_nm_object_cache_add (NM_OBJECT (object));
+
 	return object;
 }
 
@@ -140,11 +140,15 @@ set_property (GObject *object, guint prop_id,
 			  const GValue *value, GParamSpec *pspec)
 {
 	NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
+	DBusGConnection *connection;
 
 	switch (prop_id) {
 	case PROP_CONNECTION:
 		/* Construct only */
-		priv->connection = dbus_g_connection_ref ((DBusGConnection *) g_value_get_boxed (value));
+		connection = (DBusGConnection *) g_value_get_boxed (value);
+		if (!connection)
+			connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+		priv->connection = dbus_g_connection_ref (connection);
 		break;
 	case PROP_PATH:
 		/* Construct only */
diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c
index 70befd9e..b6aaabb0 100644
--- a/libnm-glib/nm-remote-settings.c
+++ b/libnm-glib/nm-remote-settings.c
@@ -736,9 +736,6 @@ get_all_cb  (DBusGProxy *proxy,
 NMRemoteSettings *
 nm_remote_settings_new (DBusGConnection *bus)
 {
-	if (bus == NULL)
-		bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
-
 	return (NMRemoteSettings *) g_object_new (NM_TYPE_REMOTE_SETTINGS,
 	                                          NM_REMOTE_SETTINGS_BUS, bus,
 	                                          NULL);
@@ -887,11 +884,15 @@ set_property (GObject *object, guint prop_id,
               const GValue *value, GParamSpec *pspec)
 {
 	NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
+	DBusGConnection *connection;
 
 	switch (prop_id) {
 	case PROP_BUS:
 		/* Construct only */
-		priv->bus = dbus_g_connection_ref ((DBusGConnection *) g_value_get_boxed (value));
+		connection = (DBusGConnection *) g_value_get_boxed (value);
+		if (!connection)
+			connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+		priv->bus = dbus_g_connection_ref (connection);
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
diff --git a/libnm-glib/nm-vpn-plugin-ui-interface.c b/libnm-glib/nm-vpn-plugin-ui-interface.c
index f4b844c8..f82c1270 100644
--- a/libnm-glib/nm-vpn-plugin-ui-interface.c
+++ b/libnm-glib/nm-vpn-plugin-ui-interface.c
@@ -150,12 +150,8 @@ nm_vpn_plugin_ui_interface_delete_connection (NMVpnPluginUiInterface *iface,
                                               NMConnection *connection,
                                               GError **error)
 {
-	g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_INTERFACE (iface), FALSE);
-
-	if (error)
-		g_return_val_if_fail (*error == NULL, FALSE);
-
-	return NM_VPN_PLUGIN_UI_INTERFACE_GET_INTERFACE (iface)->delete_connection (iface, connection, error);
+	/* Deprecated and no longer used */
+	return TRUE;
 }
 
 
@@ -235,11 +231,7 @@ nm_vpn_plugin_ui_widget_interface_save_secrets (NMVpnPluginUiWidgetInterface *if
                                                 NMConnection *connection,
                                                 GError **error)
 {
-	g_return_val_if_fail (NM_IS_VPN_PLUGIN_UI_WIDGET_INTERFACE (iface), FALSE);
-
-	if (error)
-		g_return_val_if_fail (*error == NULL, FALSE);
-
-	return NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (iface)->save_secrets (iface, connection, error);
+	/* Deprecated and no longer used */
+	return TRUE;
 }
 
diff --git a/libnm-glib/nm-vpn-plugin-ui-interface.h b/libnm-glib/nm-vpn-plugin-ui-interface.h
index 2ab13f00..93c5659b 100644
--- a/libnm-glib/nm-vpn-plugin-ui-interface.h
+++ b/libnm-glib/nm-vpn-plugin-ui-interface.h
@@ -111,11 +111,7 @@ struct _NMVpnPluginUiInterface {
 	 */
 	char * (*get_suggested_name) (NMVpnPluginUiInterface *iface, NMConnection *connection);
 
-	/* Called when the user has chosen to remove the connection (for user
-	 * connections only; system connections are handled by the system
-	 * settings service).  Should clear out any VPN-specific secrets or data
-	 * related to the connection.
-	 */
+	/* Deprecated and no longer used */
 	gboolean (*delete_connection) (NMVpnPluginUiInterface *iface, NMConnection *connection, GError **error);
 
 	/* Padding for future expansion */
@@ -147,6 +143,7 @@ gboolean nm_vpn_plugin_ui_interface_export (NMVpnPluginUiInterface *iface,
 char *nm_vpn_plugin_ui_interface_get_suggested_name (NMVpnPluginUiInterface *iface,
                                                      NMConnection *connection);
 
+/* Deprecated and no longer used */
 gboolean nm_vpn_plugin_ui_interface_delete_connection (NMVpnPluginUiInterface *iface,
                                                        NMConnection *connection,
                                                        GError **error);
@@ -178,11 +175,7 @@ struct _NMVpnPluginUiWidgetInterface {
 	                               NMConnection *connection,
 	                               GError **error);
 
-	/* Called when the user has chosen to save the connection (for user
-	 * connections only; system connections are handled by the system
-	 * settings service).  Should save VPN-specific connection secrets in
-	 * a way that the auth-dialog can read them.
-	 */
+	/* Deprecated and no longer used */
 	gboolean (*save_secrets) (NMVpnPluginUiWidgetInterface *iface,
 	                          NMConnection *connection,
 	                          GError **error);
@@ -200,6 +193,7 @@ gboolean nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidge
                                                               NMConnection *connection,
                                                               GError **error);
 
+/* Deprecated and no longer used */
 gboolean nm_vpn_plugin_ui_widget_interface_save_secrets (NMVpnPluginUiWidgetInterface *iface,
                                                          NMConnection *connection,
                                                          GError **error);