summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-10-31 15:18:33 -0400
committerDan Winship <danw@gnome.org>2013-11-15 13:38:48 -0500
commita52ebc74b53b545e734eacb1e1e940dd62a3df7b (patch)
tree4006e9d6ac1b9281bdc7be31d513da12e9e3af6f
parent51c6269d46b8b7eee9d7eae322fb6bfe6db913dd (diff)
downloadNetworkManager-a52ebc74b53b545e734eacb1e1e940dd62a3df7b.tar.gz
libnm-glib: add nm_remote_settings_load_connections()
https://bugzilla.gnome.org/show_bug.cgi?id=709830
-rw-r--r--libnm-glib/libnm-glib.ver1
-rw-r--r--libnm-glib/nm-remote-settings.c66
-rw-r--r--libnm-glib/nm-remote-settings.h10
3 files changed, 77 insertions, 0 deletions
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver
index 416b782c0a..ac784cce54 100644
--- a/libnm-glib/libnm-glib.ver
+++ b/libnm-glib/libnm-glib.ver
@@ -244,6 +244,7 @@ global:
nm_remote_settings_get_connection_by_uuid;
nm_remote_settings_get_type;
nm_remote_settings_list_connections;
+ nm_remote_settings_load_connections;
nm_remote_settings_new;
nm_remote_settings_new_async;
nm_remote_settings_new_finish;
diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c
index 1dbbbb832b..0226e999c0 100644
--- a/libnm-glib/nm-remote-settings.c
+++ b/libnm-glib/nm-remote-settings.c
@@ -630,6 +630,72 @@ nm_remote_settings_add_connection_unsaved (NMRemoteSettings *settings,
}
/**
+ * nm_remote_settings_load_connections:
+ * @settings: the %NMRemoteSettings
+ * @filenames: %NULL-terminated array of filenames to load
+ * @failures: (out) (transfer full): on return, a %NULL-terminated array of
+ * filenames that failed to load
+ * @error: return location for #GError
+ *
+ * Requests that the remote settings service load or reload the given files,
+ * adding or updating the connections described within.
+ *
+ * The changes to the indicated files will not yet be reflected in
+ * @settings's connections array when the function returns.
+ *
+ * If all of the indicated files were successfully loaded, the
+ * function will return %TRUE, and @failures will be set to %NULL. If
+ * NetworkManager tried to load the files, but some (or all) failed,
+ * then @failures will be set to a %NULL-terminated array of the
+ * filenames that failed to load.
+
+ * Returns: %TRUE if NetworkManager at least tried to load @filenames,
+ * %FALSE if an error occurred (eg, permission denied).
+ *
+ * Since: 0.9.10
+ **/
+gboolean
+nm_remote_settings_load_connections (NMRemoteSettings *settings,
+ char **filenames,
+ char ***failures,
+ GError **error)
+{
+ NMRemoteSettingsPrivate *priv;
+ char **my_failures = NULL;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
+ g_return_val_if_fail (filenames != NULL, NULL);
+
+ priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
+
+ _nm_remote_settings_ensure_inited (settings);
+
+ if (!priv->service_running) {
+ g_set_error_literal (error, NM_REMOTE_SETTINGS_ERROR,
+ NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE,
+ "NetworkManager is not running.");
+ return FALSE;
+ }
+
+ dbus_g_proxy_call (priv->proxy, "LoadConnections", error,
+ G_TYPE_STRV, filenames,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &ret,
+ G_TYPE_STRV, &my_failures,
+ G_TYPE_INVALID);
+
+ if (failures) {
+ if (my_failures && !*my_failures)
+ g_clear_pointer (&my_failures, g_free);
+ *failures = my_failures;
+ } else
+ g_strfreev (my_failures);
+
+ return ret;
+}
+
+/**
* nm_remote_settings_reload_connections:
* @settings: the #NMRemoteSettings
* @error: return location for #GError
diff --git a/libnm-glib/nm-remote-settings.h b/libnm-glib/nm-remote-settings.h
index 1bef4a7edb..e361dc04be 100644
--- a/libnm-glib/nm-remote-settings.h
+++ b/libnm-glib/nm-remote-settings.h
@@ -79,6 +79,11 @@ typedef void (*NMRemoteSettingsAddConnectionFunc) (NMRemoteSettings *settings,
GError *error,
gpointer user_data);
+typedef void (*NMRemoteSettingsLoadConnectionsFunc) (NMRemoteSettings *settings,
+ char **failures,
+ GError *error,
+ gpointer user_data);
+
typedef void (*NMRemoteSettingsSaveHostnameFunc) (NMRemoteSettings *settings,
GError *error,
gpointer user_data);
@@ -135,6 +140,11 @@ gboolean nm_remote_settings_add_connection_unsaved (NMRemoteSettings *settings,
NMRemoteSettingsAddConnectionFunc callback,
gpointer user_data);
+gboolean nm_remote_settings_load_connections (NMRemoteSettings *settings,
+ char **filenames,
+ char ***failures,
+ GError **error);
+
gboolean nm_remote_settings_reload_connections (NMRemoteSettings *settings,
GError **error);