[packagekit] packagekit: Branch 'master'

Richard Hughes hughsient at kemper.freedesktop.org
Sat Oct 13 09:34:01 PDT 2007


 libpackagekit/pk-client.c |   26 ++++++++++++++++++++++++++
 src/pk-engine.c           |   25 +++++++++++++++++++++++++
 src/pk-inhibit.c          |   19 ++++++++++++++++---
 src/pk-interface.xml      |    3 +++
 4 files changed, 70 insertions(+), 3 deletions(-)

New commits:
diff-tree d03576b966664299169148eb4819952d80a03882 (from 7aefc11eb53729e4e2bda9d7d9433550625460f2)
Author: Richard Hughes <richard at hughsie.com>
Date:   Sat Oct 13 17:31:50 2007 +0100

    export locked out onto the system bus

diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 88b2b5d..4e625c4 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_LOCKED,
 	PK_CLIENT_LAST_SIGNAL
 } PkSignals;
 
@@ -544,6 +545,16 @@ pk_client_error_code_cb (DBusGProxy  *pr
 }
 
 /**
+ * pk_client_locked_cb:
+ */
+static void
+pk_client_locked_cb (DBusGProxy *proxy, gboolean is_locked, PkClient *client)
+{
+	pk_debug ("emit locked %i", is_locked);
+	g_signal_emit (client , signals [PK_CLIENT_LOCKED], 0, is_locked);
+}
+
+/**
  * pk_client_require_restart_cb:
  */
 static void
@@ -2050,6 +2061,11 @@ pk_client_class_init (PkClientClass *kla
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
 			      0, NULL, NULL, pk_marshal_VOID__UINT_STRING,
 			      G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+	signals [PK_CLIENT_LOCKED] =
+		g_signal_new ("locked",
+			      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,
@@ -2133,6 +2149,10 @@ pk_client_init (PkClient *client)
 	dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_UINT,
 					   G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
 
+	/* Locked */
+	dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOOLEAN,
+					   G_TYPE_NONE, G_TYPE_BOOLEAN, G_TYPE_INVALID);
+
 	/* TransactionStatusChanged */
 	dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING,
 					   G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
@@ -2238,6 +2258,10 @@ pk_client_init (PkClient *client)
 				 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
 	dbus_g_proxy_connect_signal (proxy, "RequireRestart",
 				     G_CALLBACK (pk_client_require_restart_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);
 }
 
 /**
@@ -2284,6 +2308,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, "Locked",
+				        G_CALLBACK (pk_client_locked_cb), client);
 
 	/* free the proxy */
 	g_object_unref (G_OBJECT (client->priv->proxy));
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 0531486..40a57f4 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -50,6 +50,7 @@
 #include "pk-engine.h"
 #include "pk-transaction-db.h"
 #include "pk-transaction-list.h"
+#include "pk-inhibit.h"
 #include "pk-marshal.h"
 
 static void     pk_engine_class_init	(PkEngineClass *klass);
@@ -68,6 +69,7 @@ struct PkEnginePrivate
 	PkTransactionDb		*transaction_db;
 	PkTransactionItem	*sync_item;
 	PkPackageList		*updates_cache;
+	PkInhibit		*inhibit;
 };
 
 enum {
@@ -86,6 +88,7 @@ enum {
 	PK_ENGINE_UPDATE_DETAIL,
 	PK_ENGINE_DESCRIPTION,
 	PK_ENGINE_ALLOW_INTERRUPT,
+	PK_ENGINE_LOCKED,
 	PK_ENGINE_LAST_SIGNAL
 };
 
@@ -177,6 +180,18 @@ pk_engine_transaction_list_changed_cb (P
 }
 
 /**
+ * pk_engine_inhibit_locked_cb:
+ **/
+static void
+pk_engine_inhibit_locked_cb (PkInhibit *inhibit, gboolean is_locked, PkEngine *engine)
+{
+	g_return_if_fail (engine != NULL);
+	g_return_if_fail (PK_IS_ENGINE (engine));
+	pk_debug ("emitting locked %i", is_locked);
+	g_signal_emit (engine, signals [PK_ENGINE_LOCKED], 0, is_locked);
+}
+
+/**
  * pk_engine_transaction_status_changed_cb:
  **/
 static void
@@ -2147,6 +2162,11 @@ pk_engine_class_init (PkEngineClass *kla
 			      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,
+			      0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+			      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
 	signals [PK_ENGINE_TRANSACTION] =
 		g_signal_new ("transaction",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
@@ -2179,6 +2199,10 @@ pk_engine_init (PkEngine *engine)
 	g_signal_connect (engine->priv->transaction_list, "changed",
 			  G_CALLBACK (pk_engine_transaction_list_changed_cb), engine);
 
+	engine->priv->inhibit = pk_inhibit_new ();
+	g_signal_connect (engine->priv->inhibit, "locked",
+			  G_CALLBACK (pk_engine_inhibit_locked_cb), engine);
+
 	/* we use a trasaction db to store old transactions and to do rollbacks */
 	engine->priv->transaction_db = pk_transaction_db_new ();
 	g_signal_connect (engine->priv->transaction_db, "transaction",
@@ -2221,6 +2245,7 @@ pk_engine_finalize (GObject *object)
 	g_timer_destroy (engine->priv->timer);
 	g_free (engine->priv->backend);
 	polkit_context_unref (engine->priv->pk_context);
+	g_object_unref (engine->priv->inhibit);
 	g_object_unref (engine->priv->transaction_list);
 	g_object_unref (engine->priv->transaction_db);
 
diff --git a/src/pk-inhibit.c b/src/pk-inhibit.c
index 2c21fa5..317d204 100644
--- a/src/pk-inhibit.c
+++ b/src/pk-inhibit.c
@@ -50,8 +50,15 @@ struct PkInhibitPrivate
 	DBusGProxy		*proxy;
 };
 
-G_DEFINE_TYPE (PkInhibit, pk_inhibit, G_TYPE_OBJECT)
+enum {
+	PK_INHIBIT_LOCKED,
+	PK_INHIBIT_LAST_SIGNAL
+};
+
 static gpointer pk_inhibit_object = NULL;
+static guint signals [PK_INHIBIT_LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE (PkInhibit, pk_inhibit, G_TYPE_OBJECT)
 
 /**
  * pk_inhibit_locked:
@@ -98,7 +105,8 @@ pk_inhibit_lock (PkInhibit *inhibit)
 	}
 	if (ret == TRUE) {
 		inhibit->priv->is_locked = TRUE;
-		pk_debug ("setting is_locked %i", inhibit->priv->is_locked);
+		pk_debug ("emit lock %i", inhibit->priv->is_locked);
+		g_signal_emit (inhibit, signals [PK_INHIBIT_LOCKED], 0, inhibit->priv->is_locked);
 	}
 
 	return ret;
@@ -138,7 +146,8 @@ pk_inhibit_unlock (PkInhibit *inhibit)
 	}
 	if (ret == TRUE) {
 		inhibit->priv->is_locked = FALSE;
-		pk_debug ("setting is_locked %i", inhibit->priv->is_locked);
+		pk_debug ("emit lock %i", inhibit->priv->is_locked);
+		g_signal_emit (inhibit, signals [PK_INHIBIT_LOCKED], 0, inhibit->priv->is_locked);
 	}
 
 	return ret;
@@ -222,6 +231,10 @@ pk_inhibit_class_init (PkInhibitClass *k
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 	object_class->finalize = pk_inhibit_finalize;
+	signals [PK_INHIBIT_LOCKED] =
+		g_signal_new ("locked", 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);
 	g_type_class_add_private (klass, sizeof (PkInhibitPrivate));
 }
 
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index c762735..1d8e63e 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -146,6 +146,9 @@
     <signal name="UpdatesChanged">
       <arg type="s" name="tid" direction="out"/>
     </signal>
+    <signal name="Locked">
+      <arg type="b" name="is_locked" direction="out"/>
+    </signal>
     <signal name="RepoSignatureRequired">
       <arg type="s" name="tid" direction="out"/>
       <arg type="s" name="repository_name" direction="out"/>



More information about the PackageKit mailing list