diff options
Diffstat (limited to 'libnm/nm-object.c')
-rw-r--r-- | libnm/nm-object.c | 401 |
1 files changed, 223 insertions, 178 deletions
diff --git a/libnm/nm-object.c b/libnm/nm-object.c index 072fdc0c16..724d7d1ef9 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -29,7 +29,6 @@ #include "nm-object.h" #include "nm-object-cache.h" #include "nm-object-private.h" -#include "nm-dbus-glib-types.h" #include "nm-glib-compat.h" #include "nm-types.h" #include "nm-dbus-helpers-private.h" @@ -61,12 +60,13 @@ typedef struct { static void reload_complete (NMObject *object); typedef struct { - DBusGConnection *connection; - DBusGProxy *bus_proxy; + GDBusConnection *connection; + gboolean private_connection; gboolean nm_running; + guint bus_nameownerchanged_id; char *path; - DBusGProxy *properties_proxy; + GDBusProxy *properties_proxy; GSList *property_interfaces; GSList *property_tables; NMObject *parent; @@ -115,27 +115,36 @@ nm_object_error_quark (void) } static void -proxy_name_owner_changed (DBusGProxy *proxy, - const char *name, - const char *old_owner, - const char *new_owner, - gpointer user_data) +on_name_owner_changed (GDBusConnection *connection, + const char *sender_name, + const char *object_path, + const char *interface_name, + const char *signal_name, + GVariant *parameters, + gpointer user_data) { NMObject *self = NM_OBJECT (user_data); NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self); + const char *name; + const char *old_owner; + const char *new_owner; + gboolean old_good, new_good; + + g_variant_get (parameters, + "(&s&s&s)", + &name, + &old_owner, + &new_owner); + + old_good = (old_owner && old_owner[0]); + new_good = (new_owner && new_owner[0]); + if (!old_good && new_good) + priv->nm_running = TRUE; + else if (old_good && !new_good) + priv->nm_running = FALSE; - if (g_strcmp0 (name, NM_DBUS_SERVICE) == 0) { - gboolean old_good = (old_owner && old_owner[0]); - gboolean new_good = (new_owner && new_owner[0]); - - if (!old_good && new_good) - priv->nm_running = TRUE; - else if (old_good && !new_good) - priv->nm_running = FALSE; - - if (old_good != new_good) - g_object_notify (G_OBJECT (self), NM_OBJECT_NM_RUNNING); - } + if (old_good != new_good) + g_object_notify (G_OBJECT (self), NM_OBJECT_NM_RUNNING); } static void @@ -160,22 +169,21 @@ init_common (NMObject *self, GError **error) priv->properties_proxy = _nm_object_new_proxy (self, NULL, "org.freedesktop.DBus.Properties"); - if (_nm_object_is_connection_private (self)) + if (_nm_object_is_connection_private (self)) { + priv->private_connection = TRUE; priv->nm_running = TRUE; - else { - priv->bus_proxy = dbus_g_proxy_new_for_name (priv->connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - g_assert (priv->bus_proxy); - - dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->bus_proxy, - "NameOwnerChanged", - G_CALLBACK (proxy_name_owner_changed), - self, NULL); + } else { + /* FIXME: use gdbusnamewatching? But it has no sync API */ + priv->bus_nameownerchanged_id = + g_dbus_connection_signal_subscribe (priv->connection, + "org.freedesktop.DBus", + "org.freedesktop.DBus", + "NameOwnerChanged", + "/org/freedesktop/DBus", + NM_DBUS_SERVICE, + G_DBUS_SIGNAL_FLAGS_NONE, + on_name_owner_changed, + self, NULL); } return TRUE; @@ -200,14 +208,24 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) if (!init_common (self, error)) return FALSE; - if (priv->bus_proxy) { - if (!dbus_g_proxy_call (priv->bus_proxy, - "NameHasOwner", error, - G_TYPE_STRING, NM_DBUS_SERVICE, - G_TYPE_INVALID, - G_TYPE_BOOLEAN, &priv->nm_running, - G_TYPE_INVALID)) + if (!priv->private_connection) { + GVariant *ret; + + ret = g_dbus_connection_call_sync (priv->connection, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + "NameHasOwner", + g_variant_new ("(s)", NM_DBUS_SERVICE), + G_VARIANT_TYPE ("(b)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, error); + if (!ret) return FALSE; + + g_variant_get (ret, "(b)", &priv->nm_running); + g_variant_unref (ret); } return _nm_object_reload_properties (self, error); @@ -237,28 +255,32 @@ init_async_got_properties (GObject *object, GAsyncResult *result, gpointer user_ } static void -init_async_got_nm_running (DBusGProxy *proxy, DBusGProxyCall *call, - gpointer user_data) +init_async_got_nm_running (GObject *object, GAsyncResult *result, gpointer user_data) { GSimpleAsyncResult *simple = user_data; NMObject *self; NMObjectPrivate *priv; + GVariant *ret; GError *error = NULL; self = NM_OBJECT (g_async_result_get_source_object (G_ASYNC_RESULT (simple))); + /* g_async_result_get_source_object() adds a ref */ + g_object_unref (self); priv = NM_OBJECT_GET_PRIVATE (self); - if (!dbus_g_proxy_end_call (proxy, call, &error, - G_TYPE_BOOLEAN, &priv->nm_running, - G_TYPE_INVALID)) { + ret = g_dbus_connection_call_finish (G_DBUS_CONNECTION (object), result, &error); + if (!ret) { init_async_complete (simple, error); - } else if (!priv->nm_running) + return; + } + + g_variant_get (ret, "(b)", &priv->nm_running); + g_variant_unref (ret); + + if (!priv->nm_running) init_async_complete (simple, NULL); else _nm_object_reload_properties_async (self, init_async_got_properties, simple); - - /* g_async_result_get_source_object() adds a ref */ - g_object_unref (self); } static void @@ -293,11 +315,18 @@ init_async (GAsyncInitable *initable, int io_priority, _nm_object_reload_properties_async (self, init_async_got_properties, simple); else { /* Check if NM is running */ - dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner", - init_async_got_nm_running, - simple, NULL, - G_TYPE_STRING, NM_DBUS_SERVICE, - G_TYPE_INVALID); + g_dbus_connection_call (priv->connection, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + "NameHasOwner", + g_variant_new ("(s)", NM_DBUS_SERVICE), + G_VARIANT_TYPE ("(b)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + init_async_got_nm_running, + simple); } } @@ -329,12 +358,12 @@ dispose (GObject *object) priv->property_interfaces = NULL; g_clear_object (&priv->properties_proxy); - g_clear_object (&priv->bus_proxy); - if (priv->connection) { - dbus_g_connection_unref (priv->connection); - priv->connection = NULL; + if (priv->bus_nameownerchanged_id) { + g_dbus_connection_signal_unsubscribe (priv->connection, priv->bus_nameownerchanged_id); + priv->bus_nameownerchanged_id = 0; } + g_clear_object (&priv->connection); G_OBJECT_CLASS (nm_object_parent_class)->dispose (object); } @@ -359,7 +388,7 @@ set_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_DBUS_CONNECTION: /* Construct only */ - priv->connection = g_value_dup_boxed (value); + priv->connection = g_value_dup_object (value); break; case PROP_DBUS_PATH: /* Construct only */ @@ -379,7 +408,7 @@ get_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_DBUS_CONNECTION: - g_value_set_boxed (value, priv->connection); + g_value_set_object (value, priv->connection); break; case PROP_DBUS_PATH: g_value_set_string (value, priv->path); @@ -413,15 +442,15 @@ nm_object_class_init (NMObjectClass *nm_object_class) /** * NMObject:connection: * - * The #DBusGConnection of the object. + * The #GDBusConnection of the object. **/ g_object_class_install_property (object_class, PROP_DBUS_CONNECTION, - g_param_spec_boxed (NM_OBJECT_DBUS_CONNECTION, "", "", - DBUS_TYPE_G_CONNECTION, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + g_param_spec_object (NM_OBJECT_DBUS_CONNECTION, "", "", + G_TYPE_DBUS_CONNECTION, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); /** * NMObject:path: @@ -488,11 +517,11 @@ nm_object_async_initable_iface_init (GAsyncInitableIface *iface) * nm_object_get_connection: * @object: a #NMObject * - * Gets the #NMObject's DBusGConnection. + * Gets the #NMObject's GDBusConnection. * * Returns: (transfer none): the connection **/ -DBusGConnection * +GDBusConnection * nm_object_get_connection (NMObject *object) { g_return_val_if_fail (NM_IS_OBJECT (object), NULL); @@ -583,7 +612,7 @@ _nm_object_register_type_func (GType base_type, NMObjectTypeFunc type_func, } static GObject * -_nm_object_create (GType type, DBusGConnection *connection, const char *path) +_nm_object_create (GType type, GDBusConnection *connection, const char *path) { NMObjectTypeFunc type_func; GObject *object; @@ -612,7 +641,7 @@ _nm_object_create (GType type, DBusGConnection *connection, const char *path) typedef void (*NMObjectCreateCallbackFunc) (GObject *, const char *, gpointer); typedef struct { - DBusGConnection *connection; + GDBusConnection *connection; char *path; NMObjectCreateCallbackFunc callback; gpointer user_data; @@ -686,7 +715,7 @@ async_got_type (GType type, gpointer user_data) } static void -_nm_object_create_async (GType type, DBusGConnection *connection, const char *path, +_nm_object_create_async (GType type, GDBusConnection *connection, const char *path, NMObjectCreateCallbackFunc callback, gpointer user_data) { NMObjectTypeAsyncFunc type_async_func; @@ -912,7 +941,7 @@ object_created (GObject *obj, const char *path, gpointer user_data) } static gboolean -handle_object_property (NMObject *self, const char *property_name, GValue *value, +handle_object_property (NMObject *self, const char *property_name, GVariant *value, PropertyInfo *pi, gboolean synchronously) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self); @@ -931,7 +960,7 @@ handle_object_property (NMObject *self, const char *property_name, GValue *value if (priv->reload_results) priv->reload_remaining++; - path = g_value_get_boxed (value); + path = g_variant_get_string (value, NULL); if (!strcmp (path, "/")) { object_created (NULL, path, odata); @@ -955,37 +984,37 @@ handle_object_property (NMObject *self, const char *property_name, GValue *value } static gboolean -handle_object_array_property (NMObject *self, const char *property_name, GValue *value, +handle_object_array_property (NMObject *self, const char *property_name, GVariant *value, PropertyInfo *pi, gboolean synchronously) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self); GObject *obj; - GPtrArray *paths; + GVariantIter iter; + gsize npaths; GPtrArray **array = pi->field; const char *path; ObjectCreatedData *odata; - int i; - paths = g_value_get_boxed (value); + npaths = g_variant_n_children (value); odata = g_slice_new (ObjectCreatedData); odata->self = g_object_ref (self); odata->pi = pi; - odata->objects = g_new0 (GObject *, paths->len); - odata->length = odata->remaining = paths->len; + odata->objects = g_new0 (GObject *, npaths); + odata->length = odata->remaining = npaths; odata->array = TRUE; odata->property_name = property_name; if (priv->reload_results) priv->reload_remaining++; - if (paths->len == 0) { + if (npaths == 0) { object_property_complete (odata); return TRUE; } - for (i = 0; i < paths->len; i++) { - path = paths->pdata[i]; + g_variant_iter_init (&iter, value); + while (g_variant_iter_next (&iter, "&o", &path)) { if (!strcmp (path, "/")) { /* FIXME: can't happen? */ continue; @@ -1008,11 +1037,12 @@ handle_object_array_property (NMObject *self, const char *property_name, GValue return TRUE; } - return *array && ((*array)->len == paths->len); + return *array && ((*array)->len == npaths); } static void -handle_property_changed (NMObject *self, const char *dbus_name, GValue *value, gboolean synchronously) +handle_property_changed (NMObject *self, const char *dbus_name, + GVariant *value, gboolean synchronously) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self); char *prop_name; @@ -1053,7 +1083,7 @@ handle_property_changed (NMObject *self, const char *dbus_name, GValue *value, g if (G_UNLIKELY (debug)) { char *s; - s = g_strdup_value_contents (value); + s = g_variant_print (value, FALSE); dbgmsg ("PC: (%p) %s::%s => '%s' (%s%s%s)", self, G_OBJECT_TYPE_NAME (self), prop_name, @@ -1065,9 +1095,9 @@ handle_property_changed (NMObject *self, const char *dbus_name, GValue *value, g } if (pi->object_type) { - if (G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) + if (g_variant_is_of_type (value, G_VARIANT_TYPE_OBJECT_PATH)) success = handle_object_property (self, pspec->name, value, pi, synchronously); - else if (G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH)) + else if (g_variant_is_of_type (value, G_VARIANT_TYPE ("ao"))) success = handle_object_array_property (self, pspec->name, value, pi, synchronously); else { g_warn_if_reached (); @@ -1088,39 +1118,43 @@ out: } static void -process_properties_changed (NMObject *self, GHashTable *properties, gboolean synchronously) +process_properties_changed (NMObject *self, GVariant *properties, gboolean synchronously) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self); - GHashTableIter iter; - gpointer name, value; + GVariantIter iter; + const char *name; + GVariant *value; if (priv->suppress_property_updates) return; - g_hash_table_iter_init (&iter, properties); - while (g_hash_table_iter_next (&iter, &name, &value)) { - if (value) - handle_property_changed (self, name, value, synchronously); - else { - dbgmsg ("%s:%d %s(): object %s property '%s' value is unexpectedly NULL", - __FILE__, __LINE__, __func__, G_OBJECT_TYPE_NAME (self), (const char *) name); - } - } + g_variant_iter_init (&iter, properties); + while (g_variant_iter_next (&iter, "{sv}", &name, &value)) + handle_property_changed (self, name, value, synchronously); } static void -properties_changed_proxy (DBusGProxy *proxy, - GHashTable *properties, - gpointer user_data) +property_proxy_signal (GDBusProxy *proxy, + const char *sender_name, + const char *signal_name, + GVariant *parameters, + gpointer user_data) { + GVariant *properties; + + if (strcmp (signal_name, "PropertiesChanged") != 0) + return; + + properties = g_variant_get_child_value (parameters, 0); process_properties_changed (NM_OBJECT (user_data), properties, FALSE); + g_variant_unref (properties); } -#define HANDLE_TYPE(ucase, lcase, getter) \ - } else if (pspec->value_type == G_TYPE_##ucase) { \ - if (G_VALUE_HOLDS_##ucase (value)) { \ - g##lcase *param = (g##lcase *) field; \ - *param = g_value_get_##getter (value); \ +#define HANDLE_TYPE(gtype, vtype, ctype, getter) \ + } else if (pspec->value_type == gtype) { \ + if (g_variant_is_of_type (value, vtype)) { \ + ctype *param = (ctype *) field; \ + *param = getter (value); \ } else { \ success = FALSE; \ goto done; \ @@ -1129,20 +1163,20 @@ properties_changed_proxy (DBusGProxy *proxy, static gboolean demarshal_generic (NMObject *object, GParamSpec *pspec, - GValue *value, + GVariant *value, gpointer field) { gboolean success = TRUE; if (pspec->value_type == G_TYPE_STRING) { - if (G_VALUE_HOLDS_STRING (value)) { + if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) { char **param = (char **) field; g_free (*param); - *param = g_value_dup_string (value); - } else if (G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) { + *param = g_variant_dup_string (value, NULL); + } else if (g_variant_is_of_type (value, G_VARIANT_TYPE_OBJECT_PATH)) { char **param = (char **) field; g_free (*param); - *param = g_strdup (g_value_get_boxed (value)); + *param = g_variant_dup_string (value, NULL); /* Handle "NULL" object paths */ if (g_strcmp0 (*param, "/") == 0) { g_free (*param); @@ -1156,24 +1190,25 @@ demarshal_generic (NMObject *object, char ***param = (char ***)field; if (*param) g_strfreev (*param); - *param = g_value_dup_boxed (value); + *param = g_variant_dup_strv (value, NULL); } else if (pspec->value_type == G_TYPE_BYTES) { GBytes **param = (GBytes **)field; - GByteArray *val; + gconstpointer val; + gsize length; + if (*param) g_bytes_unref (*param); - val = g_value_get_boxed (value); - *param = g_bytes_new (val->data, val->len); - HANDLE_TYPE(BOOLEAN, boolean, boolean) - HANDLE_TYPE(CHAR, char, schar) - HANDLE_TYPE(UCHAR, uchar, uchar) - HANDLE_TYPE(DOUBLE, double, double) - HANDLE_TYPE(INT, int, int) - HANDLE_TYPE(UINT, uint, uint) - HANDLE_TYPE(INT64, int, int) - HANDLE_TYPE(UINT64, uint, uint) - HANDLE_TYPE(LONG, long, long) - HANDLE_TYPE(ULONG, ulong, ulong) + val = g_variant_get_fixed_array (value, &length, 1); + *param = g_bytes_new (val, length); + HANDLE_TYPE (G_TYPE_BOOLEAN, G_VARIANT_TYPE_BOOLEAN, gboolean, g_variant_get_boolean) + HANDLE_TYPE (G_TYPE_UCHAR, G_VARIANT_TYPE_BYTE, guchar, g_variant_get_byte) + HANDLE_TYPE (G_TYPE_DOUBLE, G_VARIANT_TYPE_DOUBLE, gdouble, g_variant_get_double) + HANDLE_TYPE (G_TYPE_INT, G_VARIANT_TYPE_INT32, gint, g_variant_get_int32) + HANDLE_TYPE (G_TYPE_UINT, G_VARIANT_TYPE_UINT32, guint, g_variant_get_uint32) + HANDLE_TYPE (G_TYPE_INT64, G_VARIANT_TYPE_INT64, gint, g_variant_get_int64) + HANDLE_TYPE (G_TYPE_UINT64, G_VARIANT_TYPE_UINT64, guint, g_variant_get_uint64) + HANDLE_TYPE (G_TYPE_LONG, G_VARIANT_TYPE_INT64, glong, g_variant_get_int64) + HANDLE_TYPE (G_TYPE_ULONG, G_VARIANT_TYPE_UINT64, gulong, g_variant_get_uint64) } else { dbgmsg ("%s: %s/%s unhandled type %s.", __func__, @@ -1196,7 +1231,7 @@ done: void _nm_object_register_properties (NMObject *object, - DBusGProxy *proxy, + GDBusProxy *proxy, const NMPropertiesInfo *info) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); @@ -1217,14 +1252,10 @@ _nm_object_register_properties (NMObject *object, } priv->property_interfaces = g_slist_prepend (priv->property_interfaces, - g_strdup (dbus_g_proxy_get_interface (proxy))); + g_strdup (g_dbus_proxy_get_interface_name (proxy))); - dbus_g_proxy_add_signal (proxy, "PropertiesChanged", DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (proxy, - "PropertiesChanged", - G_CALLBACK (properties_changed_proxy), - object, - NULL); + g_signal_connect (proxy, "g-signal", + G_CALLBACK (property_proxy_signal), object); instance = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); priv->property_tables = g_slist_prepend (priv->property_tables, instance); @@ -1250,22 +1281,25 @@ gboolean _nm_object_reload_properties (NMObject *object, GError **error) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); - GHashTable *props = NULL; + GVariant *ret, *props; GSList *p; if (!priv->property_interfaces || !priv->nm_running) return TRUE; for (p = priv->property_interfaces; p; p = p->next) { - if (!dbus_g_proxy_call (priv->properties_proxy, "GetAll", error, - G_TYPE_STRING, p->data, - G_TYPE_INVALID, - DBUS_TYPE_G_MAP_OF_VARIANT, &props, - G_TYPE_INVALID)) + ret = g_dbus_proxy_call_sync (priv->properties_proxy, + "GetAll", + g_variant_new ("(s)", p->data), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, error); + if (!ret) return FALSE; + props = g_variant_get_child_value (ret, 0); process_properties_changed (object, props, TRUE); - g_hash_table_destroy (props); + g_variant_unref (props); + g_variant_unref (ret); } return TRUE; @@ -1285,7 +1319,7 @@ _nm_object_reload_property (NMObject *object, const char *interface, const char *prop_name) { - GValue value = G_VALUE_INIT; + GVariant *ret, *value; GError *err = NULL; g_return_if_fail (NM_IS_OBJECT (object)); @@ -1295,13 +1329,12 @@ _nm_object_reload_property (NMObject *object, if (!NM_OBJECT_GET_PRIVATE (object)->nm_running) return; - if (!dbus_g_proxy_call_with_timeout (NM_OBJECT_GET_PRIVATE (object)->properties_proxy, - "Get", 15000, &err, - G_TYPE_STRING, interface, - G_TYPE_STRING, prop_name, - G_TYPE_INVALID, - G_TYPE_VALUE, &value, - G_TYPE_INVALID)) { + ret = g_dbus_proxy_call_sync (NM_OBJECT_GET_PRIVATE (object)->properties_proxy, + "Get", + g_variant_new ("(ss)", interface, prop_name), + G_DBUS_CALL_FLAGS_NONE, 15000, + NULL, &err); + if (!ret) { dbgmsg ("%s: Error getting '%s' for %s: (%d) %s\n", __func__, prop_name, @@ -1312,35 +1345,43 @@ _nm_object_reload_property (NMObject *object, return; } - handle_property_changed (object, prop_name, &value, TRUE); - g_value_unset (&value); + value = g_variant_get_child_value (ret, 0); + handle_property_changed (object, prop_name, value, TRUE); + g_variant_unref (value); + g_variant_unref (ret); } void _nm_object_set_property (NMObject *object, const char *interface, const char *prop_name, - GValue *value) + const char *format_string, + ...) { + GVariant *val, *ret; + va_list ap; + g_return_if_fail (NM_IS_OBJECT (object)); g_return_if_fail (interface != NULL); g_return_if_fail (prop_name != NULL); - g_return_if_fail (G_IS_VALUE (value)); + g_return_if_fail (format_string != NULL); if (!NM_OBJECT_GET_PRIVATE (object)->nm_running) return; - if (!dbus_g_proxy_call_with_timeout (NM_OBJECT_GET_PRIVATE (object)->properties_proxy, - "Set", 2000, NULL, - G_TYPE_STRING, interface, - G_TYPE_STRING, prop_name, - G_TYPE_VALUE, value, - G_TYPE_INVALID)) { - - /* Ignore errors. dbus_g_proxy_call_with_timeout() is called instead of - * dbus_g_proxy_call_no_reply() to give NM chance to authenticate the caller. - */ - } + va_start (ap, format_string); + val = g_variant_new_va (format_string, NULL, &ap); + va_end (ap); + g_return_if_fail (val != NULL); + + ret = g_dbus_proxy_call_sync (NM_OBJECT_GET_PRIVATE (object)->properties_proxy, + "Set", + g_variant_new ("(ssv)", interface, prop_name, val), + G_DBUS_CALL_FLAGS_NONE, 2000, + NULL, NULL); + /* Ignore errors. */ + if (ret) + g_variant_unref (ret); } static void @@ -1372,19 +1413,21 @@ reload_complete (NMObject *object) } static void -reload_got_properties (DBusGProxy *proxy, DBusGProxyCall *call, +reload_got_properties (GObject *proxy, + GAsyncResult *result, gpointer user_data) { NMObject *object = user_data; NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); - GHashTable *props = NULL; + GVariant *ret, *props; GError *error = NULL; - if (dbus_g_proxy_end_call (proxy, call, &error, - DBUS_TYPE_G_MAP_OF_VARIANT, &props, - G_TYPE_INVALID)) { + ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), result, &error); + if (ret) { + props = g_variant_get_child_value (ret, 0); process_properties_changed (object, props, FALSE); - g_hash_table_destroy (props); + g_variant_unref (props); + g_variant_unref (ret); } else { if (priv->reload_error) g_error_free (error); @@ -1423,10 +1466,12 @@ _nm_object_reload_properties_async (NMObject *object, GAsyncReadyCallback callba for (p = priv->property_interfaces; p; p = p->next) { priv->reload_remaining++; - dbus_g_proxy_begin_call (priv->properties_proxy, "GetAll", - reload_got_properties, object, NULL, - G_TYPE_STRING, p->data, - G_TYPE_INVALID); + g_dbus_proxy_call (priv->properties_proxy, + "GetAll", + g_variant_new ("(s)", p->data), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, + reload_got_properties, object); } } @@ -1445,7 +1490,7 @@ _nm_object_reload_properties_finish (NMObject *object, GAsyncResult *result, GEr return g_simple_async_result_get_op_res_gboolean (simple); } -DBusGProxy * +GDBusProxy * _nm_object_new_proxy (NMObject *self, const char *path, const char *interface) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self); |