libnm: add nm_client_get_main_context() function

The NMClient is associated with a certain context. Add a getter
function to give the context.

The context is really not internal API of NMClient, that is because
the user must iterate this context and be aware of it.
This commit is contained in:
Thomas Haller 2019-11-26 13:31:11 +01:00
parent 812ad586dd
commit 81bd50874b
3 changed files with 30 additions and 0 deletions

View file

@ -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;

View file

@ -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.

View file

@ -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);