diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 4eeea730bf..5d37c5e71c 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1639,6 +1639,7 @@ global: nm_client_get_context_busy_watcher; nm_client_get_dbus_connection; nm_client_get_dbus_name_owner; + nm_client_get_main_context; nm_client_get_metered; nm_client_reload; nm_client_reload_finish; diff --git a/libnm/nm-client.c b/libnm/nm-client.c index 2330c4f4a4..4e5ad4598c 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -928,6 +928,32 @@ _nm_client_get_context_dbus (NMClient *self) return NM_CLIENT_GET_PRIVATE (self)->dbus_context; } +/** + * nm_client_get_main_context: + * @self: the #NMClient instance + * + * The #NMClient instance is permanently associated with the current + * thread default #GMainContext, referenced the time when the instance + * was created. To receive events, the user must iterate this context + * and can use it to synchronize access to the client. + * + * Note that even after #NMClient instance got destroyed, there might + * still be pending sources registered in the context. That means, to fully + * clean up, the user must continue iterating the context as long as + * the nm_client_get_context_busy_watcher() object is alive. + * + * Returns: (transfer none): the #GMainContext of the client. + * + * Since: 1.22 + */ +GMainContext * +nm_client_get_main_context (NMClient *self) +{ + g_return_val_if_fail (NM_IS_CLIENT (self), NULL); + + return _nm_client_get_context_main (self); +} + /** * nm_client_get_context_busy_watcher: * @self: the NMClient instance. diff --git a/libnm/nm-client.h b/libnm/nm-client.h index cc71ff5bed..ad17bf3892 100644 --- a/libnm/nm-client.h +++ b/libnm/nm-client.h @@ -217,6 +217,9 @@ NMClient *nm_client_new_finish (GAsyncResult *result, NM_AVAILABLE_IN_1_22 GDBusConnection *nm_client_get_dbus_connection (NMClient *client); +NM_AVAILABLE_IN_1_22 +GMainContext *nm_client_get_main_context (NMClient *self); + NM_AVAILABLE_IN_1_22 GObject *nm_client_get_context_busy_watcher (NMClient *self);