diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2018-07-04 12:16:23 +0200 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2019-07-04 11:32:53 +0100 |
commit | 6e2bf2616f1e926a57ac766a4fbfc1b76710d7d4 (patch) | |
tree | e978b1f6b50c85262c953753f04d3ee072055aec /lib | |
parent | c51c9f4801b8ddc28ae7c69a88b1a271ab0d36cc (diff) |
packagekit-glib2: Add pk_client_helper_is_active()
This function enables code to check whether a client helper has
accepted connections.
A connection is considered active if one of its sources has not
been removed yet, even if it's just blocking waiting for data.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/packagekit-glib2/pk-client-helper.c | 28 | ||||
-rw-r--r-- | lib/packagekit-glib2/pk-client-helper.h | 3 |
2 files changed, 31 insertions, 0 deletions
diff --git a/lib/packagekit-glib2/pk-client-helper.c b/lib/packagekit-glib2/pk-client-helper.c index 0916b5301..944644084 100644 --- a/lib/packagekit-glib2/pk-client-helper.c +++ b/lib/packagekit-glib2/pk-client-helper.c @@ -499,6 +499,34 @@ pk_client_helper_start (PkClientHelper *client_helper, return TRUE; } +/** + * pk_client_helper_is_active: + * @client_helper: a valid #PkClientHelper instance + * + * Return value: TRUE if there is an accepted connection, FALSE + * otherwise. + * + * Since: 1.1.13 + */ +gboolean +pk_client_helper_is_active (PkClientHelper *client_helper) +{ + PkClientHelperPrivate *priv; + + g_return_val_if_fail (PK_IS_CLIENT_HELPER (client_helper), FALSE); + + priv = client_helper->priv; + + for (guint i = 0; i < priv->children->len; i++) { + PkClientHelperChild *child = g_ptr_array_index (priv->children, i); + if (!g_source_is_destroyed (child->socket_channel_source) && + !g_source_is_destroyed (child->stdout_channel_source)) + return TRUE; + } + + return FALSE; +} + /* * pk_client_helper_class_init: **/ diff --git a/lib/packagekit-glib2/pk-client-helper.h b/lib/packagekit-glib2/pk-client-helper.h index 9b09f831b..112840e41 100644 --- a/lib/packagekit-glib2/pk-client-helper.h +++ b/lib/packagekit-glib2/pk-client-helper.h @@ -72,6 +72,9 @@ gboolean pk_client_helper_start (PkClientHelper *client_helper, gchar **envp, GError **error); + +gboolean pk_client_helper_is_active (PkClientHelper *client_helper); + G_END_DECLS #endif /* __PK_CLIENT_HELPER_H */ |