diff options
author | Thomas Haller <thaller@redhat.com> | 2020-01-04 07:58:58 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-01-08 18:33:10 +0100 |
commit | 900af25263b8ea502a070549eb863c945de41940 (patch) | |
tree | 5a41f57cfb6ace82da3fa467dc39ed767f4c71bd /libnm/nm-client.c | |
parent | 5080dfa46fc6496be110d743ce233d2ca6b9977f (diff) | |
download | NetworkManager-900af25263b8ea502a070549eb863c945de41940.tar.gz |
client: add nm_client_get_object_by_path() and nm_object_get_client() API
When iterating the GMainContext of the NMClient instance, D-Bus events
get processed. That means, every time you iterate the context (or "return to
the main loop"), the content of the cache might change completely.
It makes sense to keep a reference to an NMObject instance, do something,
and afterwards check whether the instance can still be found in the cache.
Add an API for that. nm_object_get_client() allows to know whether the
object is still cached.
Likewise, while NMClient abstracts D-Bus, it should still provide a way
to look up an NMObject by D-Bus path. Add nm_client_get_object_by_path()
for that.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/384
Diffstat (limited to 'libnm/nm-client.c')
-rw-r--r-- | libnm/nm-client.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libnm/nm-client.c b/libnm/nm-client.c index 02a5b002f5..7e2cacc673 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -3914,6 +3914,26 @@ nm_client_get_nm_running (NMClient *client) } /** + * nm_client_get_object_by_path: + * @client: the #NMClient instance + * @dbus_path: the D-Bus path of the object to look up + * + * Returns: (transfer none): the #NMObject instance that is + * cached under @dbus_path, or %NULL if no such object exists. + * + * Since: 1.24 + */ +NMObject * +nm_client_get_object_by_path (NMClient *client, + const char *dbus_path) +{ + g_return_val_if_fail (NM_IS_CLIENT (client), NULL); + g_return_val_if_fail (dbus_path, NULL); + + return _dbobjs_get_nmobj_unpack_visible (client, dbus_path, G_TYPE_NONE); +} + +/** * nm_client_get_metered: * @client: a #NMClient * |