summaryrefslogtreecommitdiff
path: root/libnm/nm-remote-connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm/nm-remote-connection.c')
-rw-r--r--libnm/nm-remote-connection.c98
1 files changed, 39 insertions, 59 deletions
diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c
index 6ad5e5f506..d73f7764ef 100644
--- a/libnm/nm-remote-connection.c
+++ b/libnm/nm-remote-connection.c
@@ -628,15 +628,9 @@ init_dbus (NMObject *object)
NM_OBJECT_CLASS (nm_remote_connection_parent_class)->init_dbus (object);
- priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (object, NM_DBUS_INTERFACE_SETTINGS_CONNECTION));
- g_assert (priv->proxy);
-
_nm_object_register_properties (object,
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
property_info);
-
- g_signal_connect (priv->proxy, "updated",
- G_CALLBACK (updated_cb), object);
}
static gboolean
@@ -646,20 +640,20 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable);
GVariant *settings;
- if (!nm_remote_connection_parent_initable_iface->init (initable, cancellable, error))
- return FALSE;
+ priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (NM_OBJECT (initable), NM_DBUS_INTERFACE_SETTINGS_CONNECTION));
+ g_signal_connect (priv->proxy, "updated", G_CALLBACK (updated_cb), initable);
- if (!nmdbus_settings_connection_call_get_settings_sync (priv->proxy,
- &settings,
- cancellable, error)) {
- if (error && *error)
- g_dbus_error_strip_remote_error (*error);
- return FALSE;
+ if (nmdbus_settings_connection_call_get_settings_sync (priv->proxy,
+ &settings,
+ cancellable,
+ NULL)) {
+ priv->visible = TRUE;
+ replace_settings (self, settings);
+ g_variant_unref (settings);
}
- priv->visible = TRUE;
- replace_settings (self, settings);
- g_variant_unref (settings);
+ if (!nm_remote_connection_parent_initable_iface->init (initable, cancellable, error))
+ return FALSE;
return TRUE;
}
@@ -668,6 +662,8 @@ typedef struct {
NMRemoteConnection *connection;
GCancellable *cancellable;
GSimpleAsyncResult *result;
+ GAsyncInitable *initable;
+ int io_priority;
} NMRemoteConnectionInitData;
static void
@@ -685,44 +681,35 @@ init_async_complete (NMRemoteConnectionInitData *init_data, GError *error)
}
static void
-init_get_settings_cb (GObject *proxy,
- GAsyncResult *result,
- gpointer user_data)
+init_async_parent_inited (GObject *source, GAsyncResult *result, gpointer user_data)
{
NMRemoteConnectionInitData *init_data = user_data;
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->connection);
- GVariant *settings;
GError *error = NULL;
- if (!nmdbus_settings_connection_call_get_settings_finish (priv->proxy, &settings,
- result, &error)) {
- g_dbus_error_strip_remote_error (error);
- init_async_complete (init_data, error);
- return;
- }
-
- priv->visible = TRUE;
- replace_settings (init_data->connection, settings);
- g_variant_unref (settings);
-
- init_async_complete (init_data, NULL);
+ init_async_complete (init_data, error);
}
static void
-init_async_parent_inited (GObject *source, GAsyncResult *result, gpointer user_data)
+init_get_settings_cb (GObject *proxy,
+ GAsyncResult *result,
+ gpointer user_data)
{
NMRemoteConnectionInitData *init_data = user_data;
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->connection);
+ NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->initable);
+ GVariant *settings;
GError *error = NULL;
- if (!nm_remote_connection_parent_async_initable_iface->init_finish (G_ASYNC_INITABLE (source), result, &error)) {
- init_async_complete (init_data, error);
- return;
+ if (!nmdbus_settings_connection_call_get_settings_finish (priv->proxy, &settings,
+ result, &error)) {
+ g_error_free (error);
+ } else {
+ priv->visible = TRUE;
+ replace_settings (NM_REMOTE_CONNECTION (init_data->initable), settings);
+ g_variant_unref (settings);
}
- nmdbus_settings_connection_call_get_settings (priv->proxy,
- init_data->cancellable,
- init_get_settings_cb, init_data);
+ nm_remote_connection_parent_async_initable_iface->
+ init_async (init_data->initable, init_data->io_priority, init_data->cancellable, init_async_parent_inited, init_data);
}
static void
@@ -731,26 +718,24 @@ init_async (GAsyncInitable *initable, int io_priority,
gpointer user_data)
{
NMRemoteConnectionInitData *init_data;
+ NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable);
init_data = g_slice_new0 (NMRemoteConnectionInitData);
- init_data->connection = NM_REMOTE_CONNECTION (initable);
init_data->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
user_data, init_async);
+ init_data->initable = initable;
+ init_data->io_priority = io_priority;
- nm_remote_connection_parent_async_initable_iface->
- init_async (initable, io_priority, cancellable, init_async_parent_inited, init_data);
-}
+ priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (NM_OBJECT (initable),
+ NM_DBUS_INTERFACE_SETTINGS_CONNECTION));
-static gboolean
-init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ g_signal_connect (priv->proxy, "updated",
+ G_CALLBACK (updated_cb), initable);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- else
- return TRUE;
+ nmdbus_settings_connection_call_get_settings (NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->initable)->proxy,
+ init_data->cancellable,
+ init_get_settings_cb, init_data);
}
static void
@@ -790,10 +775,6 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class)
g_type_class_add_private (object_class, sizeof (NMRemoteConnectionPrivate));
- _nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_SETTINGS_CONNECTION);
- _nm_dbus_register_proxy_type (NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
- NMDBUS_TYPE_SETTINGS_CONNECTION_PROXY);
-
/* virtual methods */
object_class->constructed = constructed;
object_class->get_property = get_property;
@@ -852,5 +833,4 @@ nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface)
nm_remote_connection_parent_async_initable_iface = g_type_interface_peek_parent (iface);
iface->init_async = init_async;
- iface->init_finish = init_finish;
}