summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2007-11-14 22:20:32 +0000
committerRichard Hughes <richard@hughsie.com>2007-11-14 22:20:32 +0000
commitfa8920eb0bd01e530b55cf8ffffde886639c5f17 (patch)
treea7983001ee230001e68efccfa043d440d527009a
parent07677677ad5842fc07341f7e1d1b61876aec3488 (diff)
add IsCallerActive method and CallerActiveChanged signal so we know if the calling application is present on the bus or not
-rw-r--r--libpackagekit/pk-client.c62
-rw-r--r--libpackagekit/pk-client.h3
-rw-r--r--src/pk-engine.c16
-rw-r--r--src/pk-engine.h4
-rw-r--r--src/pk-interface.xml8
5 files changed, 92 insertions, 1 deletions
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 45819ba6..bb4cb3b9 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -84,6 +84,7 @@ typedef enum {
PK_CLIENT_TRANSACTION_STATUS_CHANGED,
PK_CLIENT_UPDATE_DETAIL,
PK_CLIENT_REPO_SIGNATURE_REQUIRED,
+ PK_CLIENT_CALLER_ACTIVE_CHANGED,
PK_CLIENT_REPO_DETAIL,
PK_CLIENT_LOCKED,
PK_CLIENT_LAST_SIGNAL
@@ -661,6 +662,27 @@ pk_client_locked_cb (DBusGProxy *proxy, gboolean is_locked, PkClient *client)
}
/**
+ * pk_client_caller_active_changed_cb:
+ */
+static void
+pk_client_caller_active_changed_cb (DBusGProxy *proxy,
+ const gchar *tid,
+ gboolean is_active,
+ PkClient *client)
+{
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (PK_IS_CLIENT (client));
+
+ /* not us, ignore */
+ if (pk_client_should_proxy (client, tid) == FALSE) {
+ return;
+ }
+
+ pk_debug ("emit caller-active-changed %i", is_active);
+ g_signal_emit (client , signals [PK_CLIENT_CALLER_ACTIVE_CHANGED], 0, is_active);
+}
+
+/**
* pk_client_require_restart_cb:
*/
static void
@@ -2155,6 +2177,30 @@ pk_client_get_backend_detail (PkClient *client, gchar **name, gchar **author)
}
/**
+ * pk_client_is_caller_active:
+ **/
+gboolean
+pk_client_is_caller_active (PkClient *client, gboolean *is_active)
+{
+ gboolean ret;
+ GError *error;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "IsCallerActive", &error,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, is_active,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ pk_warning ("IsCallerActive failed :%s", error->message);
+ g_error_free (error);
+ }
+ return ret;
+}
+
+/**
* pk_client_get_groups:
**/
PkEnumList *
@@ -2422,6 +2468,11 @@ pk_client_class_init (PkClientClass *klass)
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ signals [PK_CLIENT_CALLER_ACTIVE_CHANGED] =
+ g_signal_new ("caller-active-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
signals [PK_CLIENT_FINISHED] =
g_signal_new ("finished",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
@@ -2522,6 +2573,10 @@ pk_client_init (PkClient *client)
dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ /* CallerActiveChanged */
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_BOOLEAN,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID);
+
/* Description */
dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING_UINT64,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
@@ -2626,6 +2681,11 @@ pk_client_init (PkClient *client)
dbus_g_proxy_connect_signal (proxy, "RequireRestart",
G_CALLBACK (pk_client_require_restart_cb), client, NULL);
+ dbus_g_proxy_add_signal (proxy, "CallerActiveChanged",
+ G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "CallerActiveChanged",
+ G_CALLBACK (pk_client_caller_active_changed_cb), client, NULL);
+
dbus_g_proxy_add_signal (proxy, "Locked", G_TYPE_BOOLEAN, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "Locked",
G_CALLBACK (pk_client_locked_cb), client, NULL);
@@ -2674,6 +2734,8 @@ pk_client_finalize (GObject *object)
G_CALLBACK (pk_client_error_code_cb), client);
dbus_g_proxy_disconnect_signal (client->priv->proxy, "RequireRestart",
G_CALLBACK (pk_client_require_restart_cb), client);
+ dbus_g_proxy_disconnect_signal (client->priv->proxy, "CallerActiveChanged",
+ G_CALLBACK (pk_client_caller_active_changed_cb), client);
dbus_g_proxy_disconnect_signal (client->priv->proxy, "Locked",
G_CALLBACK (pk_client_locked_cb), client);
diff --git a/libpackagekit/pk-client.h b/libpackagekit/pk-client.h
index e5c1cbec..844c910a 100644
--- a/libpackagekit/pk-client.h
+++ b/libpackagekit/pk-client.h
@@ -152,7 +152,8 @@ gboolean pk_client_get_old_transactions (PkClient *client,
gboolean pk_client_get_backend_detail (PkClient *client,
gchar **name,
gchar **author);
-
+gboolean pk_client_is_caller_active (PkClient *client,
+ gboolean *is_active);
G_END_DECLS
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 4b87c31f..ac966a38 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -90,6 +90,7 @@ enum {
PK_ENGINE_DESCRIPTION,
PK_ENGINE_FILES,
PK_ENGINE_ALLOW_INTERRUPT,
+ PK_ENGINE_CALLER_ACTIVE_CHANGED,
PK_ENGINE_LOCKED,
PK_ENGINE_REPO_DETAIL,
PK_ENGINE_LAST_SIGNAL
@@ -2423,6 +2424,16 @@ pk_engine_get_backend_detail (PkEngine *engine, gchar **name, gchar **author, GE
}
/**
+ * pk_engine_is_caller_active:
+ **/
+gboolean
+pk_engine_is_caller_active (PkEngine *engine, const gchar *tid, gboolean *is_active, GError **error)
+{
+ //FIXME: handle NOC
+ return TRUE;
+}
+
+/**
* pk_engine_transaction_cb:
**/
static void
@@ -2544,6 +2555,11 @@ pk_engine_class_init (PkEngineClass *klass)
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
0, NULL, NULL, pk_marshal_VOID__STRING_BOOL,
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ signals [PK_ENGINE_CALLER_ACTIVE_CHANGED] =
+ g_signal_new ("caller-active-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, pk_marshal_VOID__STRING_BOOL,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
signals [PK_ENGINE_LOCKED] =
g_signal_new ("locked",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-engine.h b/src/pk-engine.h
index 26a166ad..2ef3aaa0 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -198,6 +198,10 @@ gboolean pk_engine_get_groups (PkEngine *engine,
gboolean pk_engine_get_filters (PkEngine *engine,
gchar **filters,
GError **error);
+gboolean pk_engine_is_caller_active (PkEngine *engine,
+ const gchar *tid,
+ gboolean *is_active,
+ GError **error);
guint pk_engine_get_seconds_idle (PkEngine *engine);
gboolean pk_engine_get_progress (PkEngine *engine,
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index 8734fdd6..c4a90cd0 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -261,6 +261,14 @@
<method name="GetFilters">
<arg type="s" name="filters" direction="out"/> <!-- list of supported filters -->
</method>
+ <method name="IsCallerActive">
+ <arg type="s" name="tid" direction="in"/>
+ <arg type="b" name="is_active" direction="out"/>
+ </method>
+ <signal name="CallerActiveChanged">
+ <arg type="s" name="tid" direction="out"/>
+ <arg type="b" name="is_active" direction="out"/>
+ </signal>
</interface>
</node>