summaryrefslogtreecommitdiff
path: root/src/nm-dbus-utils.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-03-29 11:04:37 +0200
committerThomas Haller <thaller@redhat.com>2018-04-04 14:02:13 +0200
commitb0f02075deb02d91361bdd53c31469b3b2b98618 (patch)
tree4487a529ff6f51a99460fdaf081490180160c6f0 /src/nm-dbus-utils.c
parentcc1920d71470042c4e0837848da9183526b663d0 (diff)
downloadNetworkManager-b0f02075deb02d91361bdd53c31469b3b2b98618.tar.gz
core: add nm_dbus_utils_g_value_set_object_path_from_hash() helper
Diffstat (limited to 'src/nm-dbus-utils.c')
-rw-r--r--src/nm-dbus-utils.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/nm-dbus-utils.c b/src/nm-dbus-utils.c
index eab6cb6125..f9c70e4953 100644
--- a/src/nm-dbus-utils.c
+++ b/src/nm-dbus-utils.c
@@ -147,6 +147,36 @@ nm_dbus_utils_g_value_set_object_path_array (GValue *value,
g_value_take_boxed (value, paths);
}
-/*****************************************************************************/
+void
+nm_dbus_utils_g_value_set_object_path_from_hash (GValue *value,
+ GHashTable *hash /* has keys of NMDBusObject type. */,
+ gboolean expect_all_exported)
+{
+ NMDBusObject *obj;
+ char **strv;
+ guint i, n;
+ GHashTableIter iter;
+
+ nm_assert (value);
+ nm_assert (hash);
+
+ n = g_hash_table_size (hash);
+ strv = g_new (char *, n + 1);
+ i = 0;
+ g_hash_table_iter_init (&iter, hash);
+ while (g_hash_table_iter_next (&iter, (gpointer *) &obj, NULL)) {
+ const char *path;
+ path = nm_dbus_object_get_path (obj);
+ if (!path) {
+ nm_assert (!expect_all_exported);
+ continue;
+ }
+ strv[i++] = g_strdup (path);
+ }
+ nm_assert (i <= n);
+ strv[i] = NULL;
+ g_value_take_boxed (value, strv);
+}
+/*****************************************************************************/