static void
fetch_connections_done (DBusGProxy *proxy,
                        GPtrArray *connections,
                        GError *error,
                        gpointer user_data)
{
	NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
	NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);	
	int i;

	if (error) {
		g_warning ("%s: error fetching %s connections: (%d) %s.",
		           __func__,
		           priv->scope == NM_CONNECTION_SCOPE_USER ? "user" : "system",
		           error->code,
		           error->message ? error->message : "(unknown)");
		g_clear_error (&error);
		return;
	}

	/* Let listeners know we are done getting connections */
	if (connections->len == 0) {
		g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CONNECTIONS_READ);
		return;
	}

	for (i = 0; connections && (i < connections->len); i++) {
		char *path = g_ptr_array_index (connections, i);

		new_connection_cb (proxy, path, user_data);
		g_free (path);
	}
	g_ptr_array_free (connections, TRUE);
}
Пример #2
0
static void
fetch_connections_done (DBusGProxy *proxy,
                        GPtrArray *connections,
                        GError *error,
                        gpointer user_data)
{
	BMRemoteSettings *self = BM_REMOTE_SETTINGS (user_data);
	BMRemoteSettingsPrivate *priv = BM_REMOTE_SETTINGS_GET_PRIVATE (self);	
	int i;

	if (error) {
		gboolean is_spawn_error = FALSE;

		/* Don't warn if the user settings service wasn't running since that's
		 * just annoying when running headless.
		 */
		if (   g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN)
		    || g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NAME_HAS_NO_OWNER))
			is_spawn_error = TRUE;

		if (!is_spawn_error || priv->scope == BM_CONNECTION_SCOPE_SYSTEM) {
			g_warning ("%s: error fetching %s connections: (%d) %s.",
				       __func__,
				       priv->scope == BM_CONNECTION_SCOPE_USER ? "user" : "system",
				       error->code,
				       error->message ? error->message : "(unknown)");
		}
		g_clear_error (&error);

		/* We tried to read connections and failed */
		g_signal_emit_by_name (self, BM_SETTINGS_INTERFACE_CONNECTIONS_READ);
		return;
	}

	/* Let listeners know we are done getting connections */
	if (connections->len == 0) {
		g_signal_emit_by_name (self, BM_SETTINGS_INTERFACE_CONNECTIONS_READ);
		return;
	}

	for (i = 0; connections && (i < connections->len); i++) {
		char *path = g_ptr_array_index (connections, i);

		new_connection_cb (proxy, path, user_data);
		g_free (path);
	}
	g_ptr_array_free (connections, TRUE);
}
Пример #3
0
static void
add_connection_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
{
	AddConnectionInfo *info = user_data;
	GError *error = NULL;
	char *path = NULL;

	if (dbus_g_proxy_end_call (proxy, call, &error, DBUS_TYPE_G_OBJECT_PATH, &path, G_TYPE_INVALID)) {
		info->connection = new_connection_cb (proxy, path, info->self);
		g_assert (info->connection);
		/* Wait until this connection is fully initialized before calling the callback */
		g_free (path);
	} else
		add_connection_info_complete (info->self, info, error);

	g_clear_error (&error);
}
Пример #4
0
static void
fetch_connections_done (DBusGProxy *proxy,
                        GPtrArray *connections,
                        GError *error,
                        gpointer user_data)
{
	NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
	NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
	int i;

	if (error) {
		/* Ignore settings service spawn errors */
		if (   !g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN)
		    && !g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NAME_HAS_NO_OWNER)) {
			g_warning ("%s: error fetching connections: (%d) %s.",
			           __func__,
				       error->code,
				       error->message ? error->message : "(unknown)");
		}
		g_clear_error (&error);

		/* We tried to read connections and failed */
		g_signal_emit (self, signals[CONNECTIONS_READ], 0);
		return;
	}

	/* Let listeners know we are done getting connections */
	if (connections->len == 0)
		g_signal_emit (self, signals[CONNECTIONS_READ], 0);
	else {
		priv->init_left = connections->len;
		for (i = 0; i < connections->len; i++) {
			char *path = g_ptr_array_index (connections, i);

			new_connection_cb (proxy, path, user_data);
			g_free (path);
		}
	}

	g_ptr_array_free (connections, TRUE);
}