diff options
Diffstat (limited to 'libnm-glib/nm-remote-connection.c')
| -rw-r--r-- | libnm-glib/nm-remote-connection.c | 76 |
1 files changed, 69 insertions, 7 deletions
diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c index 64df586e..ebb6a7b6 100644 --- a/libnm-glib/nm-remote-connection.c +++ b/libnm-glib/nm-remote-connection.c @@ -33,6 +33,8 @@ #include "nm-glib-compat.h" #define NM_REMOTE_CONNECTION_BUS "bus" +#define NM_REMOTE_CONNECTION_DBUS_CONNECTION "dbus-connection" +#define NM_REMOTE_CONNECTION_DBUS_PATH "dbus-path" static void nm_remote_connection_initable_iface_init (GInitableIface *iface); static void nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface); @@ -45,6 +47,8 @@ G_DEFINE_TYPE_WITH_CODE (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNE enum { PROP_0, PROP_BUS, + PROP_DBUS_CONNECTION, + PROP_DBUS_PATH, LAST_PROP }; @@ -385,9 +389,8 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) GHashTable *settings; if (!dbus_g_proxy_call (priv->proxy, "GetSettings", error, - G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS, G_TYPE_INVALID, - DBUS_TYPE_G_MAP_OF_VARIANT, &settings, + DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings, G_TYPE_INVALID)) return FALSE; @@ -464,6 +467,43 @@ nm_remote_connection_init (NMRemoteConnection *self) { } +static GObject * +constructor (GType type, guint n_construct_properties, + GObjectConstructParam *construct_properties) +{ + static GParamSpec *nm_connection_path = NULL; + static GParamSpec *nm_remote_connection_dbus_path = NULL; + int i, path_index = -1, dbus_path_index = -1; + + if (!nm_connection_path) { + nm_connection_path = + g_object_class_find_property (g_type_class_peek (NM_TYPE_CONNECTION), + NM_CONNECTION_PATH); + nm_remote_connection_dbus_path = + g_object_class_find_property (g_type_class_peek (NM_TYPE_REMOTE_CONNECTION), + NM_REMOTE_CONNECTION_DBUS_PATH); + } + + /* Find the two properties */ + for (i = 0; i < n_construct_properties; i++) { + if (construct_properties[i].pspec == nm_connection_path) + path_index = i; + else if (construct_properties[i].pspec == nm_remote_connection_dbus_path) + dbus_path_index = i; + } + g_assert (path_index != -1 && dbus_path_index != -1); + + /* If NMRemoteConnection:dbus-path is set, and NMConnection:path + * is not, then copy the value of the former to the latter. + */ + if (g_value_get_string (construct_properties[dbus_path_index].value) && + !g_value_get_string (construct_properties[path_index].value)) + construct_properties[path_index].value = construct_properties[dbus_path_index].value; + + return G_OBJECT_CLASS (nm_remote_connection_parent_class)-> + constructor (type, n_construct_properties, construct_properties); +} + static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) @@ -472,8 +512,13 @@ set_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_BUS: + case PROP_DBUS_CONNECTION: /* Construct only */ - priv->bus = dbus_g_connection_ref ((DBusGConnection *) g_value_get_boxed (value)); + if (g_value_get_boxed (value)) + priv->bus = dbus_g_connection_ref ((DBusGConnection *) g_value_get_boxed (value)); + break; + case PROP_DBUS_PATH: + /* Don't need to do anything; see constructor(). */ break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -508,6 +553,7 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class) g_type_class_add_private (object_class, sizeof (NMRemoteConnectionPrivate)); /* virtual methods */ + object_class->constructor = constructor; object_class->set_property = set_property; object_class->dispose = dispose; object_class->constructed = constructed; @@ -516,10 +562,26 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class) g_object_class_install_property (object_class, PROP_BUS, g_param_spec_boxed (NM_REMOTE_CONNECTION_BUS, - "DBusGConnection", - "DBusGConnection", - DBUS_TYPE_G_CONNECTION, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + "DBusGConnection", + "DBusGConnection", + DBUS_TYPE_G_CONNECTION, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + + /* These are needed so _nm_object_create() can create NMRemoteConnections */ + g_object_class_install_property + (object_class, PROP_DBUS_CONNECTION, + g_param_spec_boxed (NM_REMOTE_CONNECTION_DBUS_CONNECTION, + "DBusGConnection", + "DBusGConnection", + DBUS_TYPE_G_CONNECTION, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property + (object_class, PROP_DBUS_PATH, + g_param_spec_string (NM_REMOTE_CONNECTION_DBUS_PATH, + "Object Path", + "DBus Object Path", + NULL, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); /* Signals */ /** |