libnm: inline NMManager's get_permissions_sync()

Synchrnous initialization is problmatic and needs cleanup.

get_permissions_sync() is an internal function, that has only one
caller. We need to keep track of functions that make synchronous D-Bus
calls. Move the synchronous call into the caller, so that it's clearer
who calls such API.
This commit is contained in:
Thomas Haller
2019-09-04 14:17:17 +02:00
parent 0f9157f07b
commit 7db00be6b7

View File

@@ -369,26 +369,6 @@ update_permissions (NMManager *self, GVariant *permissions)
g_list_free (keys); g_list_free (keys);
} }
static gboolean
get_permissions_sync (NMManager *self, GError **error)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
GVariant *permissions;
if (nmdbus_manager_call_get_permissions_sync (priv->proxy,
&permissions,
NULL, error)) {
update_permissions (self, permissions);
g_variant_unref (permissions);
return TRUE;
} else {
if (error && *error)
g_dbus_error_strip_remote_error (*error);
update_permissions (self, NULL);
return FALSE;
}
}
static void static void
get_permissions_reply (GObject *object, get_permissions_reply (GObject *object,
GAsyncResult *result, GAsyncResult *result,
@@ -1756,19 +1736,25 @@ constructed (GObject *object)
static gboolean static gboolean
init_sync (GInitable *initable, GCancellable *cancellable, GError **error) init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
{ {
NMManager *manager = NM_MANAGER (initable); NMManager *self = NM_MANAGER (initable);
GError *local_error = NULL; NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
gs_free_error GError *local_error = NULL;
gs_unref_variant GVariant *permissions = NULL;
if (!nm_manager_parent_initable_iface->init (initable, cancellable, error)) { if (!nm_manager_parent_initable_iface->init (initable, cancellable, error)) {
/* Never happens. */ /* Never happens. */
g_return_val_if_reached (FALSE); g_return_val_if_reached (FALSE);
} }
if (!get_permissions_sync (manager, &local_error)) { if (!nmdbus_manager_call_get_permissions_sync (priv->proxy,
&permissions,
NULL,
&local_error)) {
g_dbus_error_strip_remote_error (local_error);
g_warning ("Unable to get permissions: %s\n", local_error->message); g_warning ("Unable to get permissions: %s\n", local_error->message);
g_error_free (local_error);
} }
update_permissions (self, permissions);
return TRUE; return TRUE;
} }