[packagekit] packagekit: Branch 'master' - 14 commits

Richard Hughes hughsient at kemper.freedesktop.org
Mon Mar 31 18:33:11 PDT 2008


 backends/conary/helpers/conaryBackend.py |   19 ++-
 backends/conary/helpers/update.py        |    4 
 backends/poldek/pk-backend-poldek.c      |   53 ++++++--
 backends/yum/helpers/yumBackend.py       |   22 ++-
 backends/yum2/helpers/yumDBUSBackend.py  |    2 
 backends/zypp/pk-backend-zypp.cpp        |    4 
 libgbus/libgbus.c                        |   67 +++++++---
 libgbus/libgbus.h                        |    1 
 libpackagekit/pk-notify.c                |   34 +++++
 libpackagekit/pk-notify.h                |    1 
 src/Makefile.am                          |    4 
 src/pk-engine.c                          |   28 ++++
 src/pk-interface-notify.xml              |    2 
 src/pk-notify.c                          |   21 +++
 src/pk-notify.h                          |    1 
 src/pk-restart.c                         |  190 +++++++++++++++++++++++++++++++
 src/pk-restart.h                         |   54 ++++++++
 src/pk-self-test.c                       |    2 
 18 files changed, 465 insertions(+), 44 deletions(-)

New commits:
commit a8dfd3e1db37b0d2cfd6d46d3aa80ef2565f04b7
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Apr 1 02:11:50 2008 +0100

    make libgbus send a signal when we are replaced on the bus

diff --git a/libgbus/libgbus.c b/libgbus/libgbus.c
index bb0310e..ce91b6b 100644
--- a/libgbus/libgbus.c
+++ b/libgbus/libgbus.c
@@ -42,11 +42,12 @@ struct LibGBusPrivate
 	gchar			*service;
 	DBusGProxy		*proxy;
 	DBusGConnection		*connection;
-	gboolean		 connected;
+	const gchar		*unique_name;
 };
 
 enum {
 	CONNECTION_CHANGED,
+	CONNECTION_REPLACED,
 	LAST_SIGNAL
 };
 
@@ -64,24 +65,43 @@ name_owner_changed_cb (DBusGProxy     *proxy,
 		       const gchar    *new,
 		       LibGBus	      *libgbus)
 {
+	guint new_len;
+	guint prev_len;
+
 	g_return_if_fail (IS_LIBGBUS (libgbus));
 	if (libgbus->priv->proxy == NULL) {
 		return;
 	}
 
-	if (strcmp (name, libgbus->priv->service) == 0) {
-		/* ITS4: ignore, not used for allocation */
-		if (strlen (prev) != 0 && strlen (new) == 0 && libgbus->priv->connected == TRUE) {
-			libgbus->priv->connected = FALSE;
-			g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, libgbus->priv->connected);
-			return;
-		}
-		/* ITS4: ignore, not used for allocation */
-		if (strlen (prev) == 0 && strlen (new) != 0 && libgbus->priv->connected == FALSE) {
-			libgbus->priv->connected = TRUE;
-			g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, libgbus->priv->connected);
-			return;
+	/* not us */
+	if (strcmp (name, libgbus->priv->service) != 0) {
+		return;
+	}
+
+	/* ITS4: ignore, not used for allocation */
+	new_len = strlen (new);
+	/* ITS4: ignore, not used for allocation */
+	prev_len = strlen (prev);
+
+	/* something --> nothing */
+	if (prev_len != 0 && new_len == 0) {
+		g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, FALSE);
+		return;
+	}
+
+	/* nothing --> something */
+	if (prev_len == 0 && new_len != 0) {
+		g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, TRUE);
+		return;
+	}
+
+	/* something --> something (we've replaced the old process) */
+	if (prev_len != 0 && new_len != 0) {
+		/* only send this to the prev client */
+		if (strcmp (libgbus->priv->unique_name, prev) == 0) {
+			g_signal_emit (libgbus, signals [CONNECTION_REPLACED], 0);
 		}
+		return;
 	}
 }
 
@@ -101,6 +121,8 @@ libgbus_assign (LibGBus      *libgbus,
 		const gchar  *service)
 {
 	GError *error = NULL;
+	gboolean connected;
+	DBusConnection *conn;
 
 	g_return_val_if_fail (IS_LIBGBUS (libgbus), FALSE);
 	g_return_val_if_fail (service != NULL, FALSE);
@@ -141,10 +163,14 @@ libgbus_assign (LibGBus      *libgbus,
 				     libgbus, NULL);
 
 	/* coldplug */
-	libgbus->priv->connected = libgbus_is_connected (libgbus);
-	if (libgbus->priv->connected == TRUE) {
+	connected = libgbus_is_connected (libgbus);
+	if (connected == TRUE) {
 		g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, TRUE);
 	}
+
+	/* save this for the replaced check */
+	conn = dbus_g_connection_get_connection (libgbus->priv->connection);
+	libgbus->priv->unique_name = dbus_bus_get_unique_name (conn);
 	return TRUE;
 }
 
@@ -186,13 +212,16 @@ libgbus_class_init (LibGBusClass *klass)
 
 	signals [CONNECTION_CHANGED] =
 		g_signal_new ("connection-changed",
-			      G_TYPE_FROM_CLASS (object_class),
-			      G_SIGNAL_RUN_LAST,
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (LibGBusClass, connection_changed),
-			      NULL,
-			      NULL,
-			      g_cclosure_marshal_VOID__BOOLEAN,
+			      NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
 			      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+	signals [CONNECTION_REPLACED] =
+		g_signal_new ("connection-replaced",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (LibGBusClass, connection_replaced),
+			      NULL, NULL, g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
 }
 
 /**
diff --git a/libgbus/libgbus.h b/libgbus/libgbus.h
index 2037ab1..78697ab 100644
--- a/libgbus/libgbus.h
+++ b/libgbus/libgbus.h
@@ -47,6 +47,7 @@ typedef struct
 	GObjectClass	parent_class;
 	void		(* connection_changed)	(LibGBus	*watch,
 						 gboolean	 connected);
+	void		(* connection_replaced)	(LibGBus	*watch);
 } LibGBusClass;
 
 typedef enum {
commit 4726afffc17528214e831ccbdcfffa85e7898383
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Apr 1 00:33:08 2008 +0100

    trivial change to libgbus

diff --git a/libgbus/libgbus.c b/libgbus/libgbus.c
index 119db8b..bb0310e 100644
--- a/libgbus/libgbus.c
+++ b/libgbus/libgbus.c
@@ -72,13 +72,15 @@ name_owner_changed_cb (DBusGProxy     *proxy,
 	if (strcmp (name, libgbus->priv->service) == 0) {
 		/* ITS4: ignore, not used for allocation */
 		if (strlen (prev) != 0 && strlen (new) == 0 && libgbus->priv->connected == TRUE) {
-			g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, FALSE);
 			libgbus->priv->connected = FALSE;
+			g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, libgbus->priv->connected);
+			return;
 		}
 		/* ITS4: ignore, not used for allocation */
 		if (strlen (prev) == 0 && strlen (new) != 0 && libgbus->priv->connected == FALSE) {
-			g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, TRUE);
 			libgbus->priv->connected = TRUE;
+			g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, libgbus->priv->connected);
+			return;
 		}
 	}
 }
commit 0948c0183ae29eff6468efc1ed745adc1badfb18
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Mar 31 23:06:56 2008 +0100

    actually emit the RestartSchedule from the daemon

diff --git a/src/pk-interface-notify.xml b/src/pk-interface-notify.xml
index b0281a9..7a879cb 100644
--- a/src/pk-interface-notify.xml
+++ b/src/pk-interface-notify.xml
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <node name="/">
   <interface name="org.freedesktop.PackageKit.Notify">
+    <signal name="RestartSchedule">
+    </signal>
     <signal name="RepoListChanged">
       <arg type="s" name="tid" direction="out"/>
     </signal>
commit a17cc5975b0f5857691e655878519e280d63893c
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Mar 31 22:53:05 2008 +0100

    only send the client restart_schedule when we are actually shutting down the daemon

diff --git a/src/pk-engine.c b/src/pk-engine.c
index dd50ad8..ee1ca99 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -2914,6 +2914,7 @@ pk_engine_get_seconds_idle (PkEngine *engine)
 	/* have we been updated? */
 	if (engine->priv->restart_schedule) {
 		pk_debug ("need to restart daemon *NOW*");
+		pk_notify_restart_schedule (engine->priv->notify);
 		return G_MAXUINT;
 	}
 
diff --git a/src/pk-restart.c b/src/pk-restart.c
index 2151235..64b924c 100644
--- a/src/pk-restart.c
+++ b/src/pk-restart.c
@@ -39,7 +39,6 @@
 #include <pk-common.h>
 #include <pk-debug.h>
 #include "pk-restart.h"
-#include "pk-notify.h"
 
 static void     pk_restart_class_init	(PkRestartClass *klass);
 static void     pk_restart_init		(PkRestart      *restart);
@@ -51,7 +50,6 @@ static void     pk_restart_finalize	(GObject       *object);
 struct PkRestartPrivate
 {
 	GString			*stdout_buf;
-	PkNotify		*notify;
 	GFileMonitor		*monitor;
 	GFile			*file;
 };
@@ -97,7 +95,6 @@ pk_restart_monitor_changed (GFileMonitor *monitor, GFile *file, GFile *other_fil
 	}
 	pk_debug ("emit: restart-schedule");
 	g_signal_emit (restart, signals [PK_RESTART_SCHEDULE], 0);
-	pk_notify_restart_schedule (restart->priv->notify);
 }
 
 /**
@@ -110,9 +107,6 @@ pk_restart_init (PkRestart *restart)
 	GError *error = NULL;
 	restart->priv = PK_RESTART_GET_PRIVATE (restart);
 
-	/* notify from dbus to the client programs */
-	restart->priv->notify = pk_notify_new ();
-
 	/* this is the file we are interested in */
 	restart->priv->file = g_file_new_for_path (PK_RESTART_FILE_TO_WATCH);
 
@@ -146,7 +140,6 @@ pk_restart_finalize (GObject *object)
 
 	g_file_monitor_cancel (restart->priv->monitor);
 
-	g_object_unref (restart->priv->notify);
 	g_object_unref (restart->priv->file);
 	g_object_unref (restart->priv->monitor);
 
commit 8b3ef36e766508b0b13383f2bfa7ad6f3b6d51ad
Merge: 3594f0c... a5f0856...
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Mar 31 22:44:57 2008 +0100

    Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit

commit 3594f0c983b227c8c6643b9c487c66b4e87a1d08
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Mar 31 22:40:33 2008 +0100

    add restart-schedule into the PkNotify GObject

diff --git a/libpackagekit/pk-notify.c b/libpackagekit/pk-notify.c
index 30adb30..7535efd 100644
--- a/libpackagekit/pk-notify.c
+++ b/libpackagekit/pk-notify.c
@@ -65,6 +65,7 @@ struct _PkNotifyPrivate
 };
 
 typedef enum {
+	PK_NOTIFY_RESTART_SCHEDULE,
 	PK_NOTIFY_UPDATES_CHANGED,
 	PK_NOTIFY_REPO_LIST_CHANGED,
 	PK_NOTIFY_LAST_SIGNAL
@@ -75,6 +76,20 @@ static guint signals [PK_NOTIFY_LAST_SIGNAL] = { 0 };
 G_DEFINE_TYPE (PkNotify, pk_notify, G_TYPE_OBJECT)
 
 /**
+ * pk_notify_restart_schedule_cb:
+ */
+static void
+pk_notify_restart_schedule_cb (DBusGProxy *proxy, PkNotify *notify)
+{
+	g_return_if_fail (notify != NULL);
+	g_return_if_fail (PK_IS_NOTIFY (notify));
+
+	pk_debug ("emitting restart-schedule");
+	g_signal_emit (notify, signals [PK_NOTIFY_RESTART_SCHEDULE], 0);
+
+}
+
+/**
  * pk_notify_updates_changed_cb:
  */
 static void
@@ -138,6 +153,19 @@ pk_notify_class_init (PkNotifyClass *klass)
 			      G_STRUCT_OFFSET (PkNotifyClass, repo_list_changed),
 			      NULL, NULL, g_cclosure_marshal_VOID__VOID,
 			      G_TYPE_NONE, 0);
+	/**
+	 * PkNotify::restart_schedule:
+	 * @notify: the #PkNotify instance that emitted the signal
+	 *
+	 * The ::restart_schedule signal is emitted when the service has been
+	 * restarted. Client programs should reload themselves.
+	 **/
+	signals [PK_NOTIFY_RESTART_SCHEDULE] =
+		g_signal_new ("restart-schedule",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (PkNotifyClass, restart_schedule),
+			      NULL, NULL, g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
 
 	g_type_class_add_private (klass, sizeof (PkNotifyPrivate));
 }
@@ -176,6 +204,10 @@ pk_notify_init (PkNotify *notify)
 				 G_TYPE_STRING, G_TYPE_INVALID);
 	dbus_g_proxy_connect_signal (notify->priv->proxy, "RepoListChanged",
 				     G_CALLBACK (pk_notify_repo_list_changed_cb), notify, NULL);
+
+	dbus_g_proxy_add_signal (notify->priv->proxy, "RestartSchedule", G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (notify->priv->proxy, "RestartSchedule",
+				     G_CALLBACK (pk_notify_restart_schedule_cb), notify, NULL);
 }
 
 /**
@@ -195,6 +227,8 @@ pk_notify_finalize (GObject *object)
 				        G_CALLBACK (pk_notify_updates_changed_cb), notify);
 	dbus_g_proxy_disconnect_signal (notify->priv->proxy, "RepoListChanged",
 				        G_CALLBACK (pk_notify_repo_list_changed_cb), notify);
+	dbus_g_proxy_disconnect_signal (notify->priv->proxy, "RestartSchedule",
+				        G_CALLBACK (pk_notify_restart_schedule_cb), notify);
 
 	/* free the proxy */
 	g_object_unref (G_OBJECT (notify->priv->proxy));
diff --git a/libpackagekit/pk-notify.h b/libpackagekit/pk-notify.h
index 84c57c0..4dbb9cb 100644
--- a/libpackagekit/pk-notify.h
+++ b/libpackagekit/pk-notify.h
@@ -54,6 +54,7 @@ struct _PkNotifyClass
 	/* signals */
 	void		(* updates_changed)		(PkNotify	*notify);
 	void		(* repo_list_changed)		(PkNotify	*notify);
+	void		(* restart_schedule)		(PkNotify	*notify);
 	/* padding for future expansion */
 	void (*_pk_reserved1) (void);
 	void (*_pk_reserved2) (void);
commit be3087179233e9eeeabaace17a31edb86598367f
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Mar 31 22:34:40 2008 +0100

    the daemon will quit when it has cleared all
    transactions, rather than waiting for the timeout when the packagekitd file has changed

diff --git a/src/Makefile.am b/src/Makefile.am
index 79f55d6..46d9a2a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,6 +18,7 @@ INCLUDES =						\
 	$(SQLITE_CFLAGS)				\
 	$(POLKIT_CFLAGS)				\
 	-DBINDIR=\"$(bindir)\"			 	\
+	-DSBINDIR=\"$(sbindir)\"		 	\
 	-DDATADIR=\"$(datadir)\"			\
 	-DPREFIX=\""$(prefix)"\" 			\
 	-DSYSCONFDIR=\""$(sysconfdir)"\" 		\
@@ -160,6 +161,7 @@ pk_self_test_LDADD =					\
 	$(LIBNM_LIBS)					\
 	$(PK_LIBS)					\
 	$(POLKIT_LIBS)					\
+	$(GIO_LIBS)					\
 	$(NULL)
 
 TESTS = pk-self-test
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 7f91d6a..dd50ad8 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -56,6 +56,7 @@
 #include "pk-inhibit.h"
 #include "pk-marshal.h"
 #include "pk-notify.h"
+#include "pk-restart.h"
 #include "pk-security.h"
 #include "pk-interface-notify.h"
 
@@ -81,6 +82,7 @@ static void     pk_engine_finalize	(GObject       *object);
 struct PkEnginePrivate
 {
 	GTimer			*timer;
+	gboolean		 restart_schedule;
 	PkTransactionList	*transaction_list;
 	PkTransactionDb		*transaction_db;
 	PkTransactionItem	*sync_item;
@@ -90,6 +92,7 @@ struct PkEnginePrivate
 	PkNetwork		*network;
 	PkSecurity		*security;
 	PkNotify		*notify;
+	PkRestart		*restart;
 	PkEnumList		*actions;
 	PkEnumList		*groups;
 	PkEnumList		*filters;
@@ -2908,6 +2911,12 @@ pk_engine_get_seconds_idle (PkEngine *engine)
 		return 0;
 	}
 
+	/* have we been updated? */
+	if (engine->priv->restart_schedule) {
+		pk_debug ("need to restart daemon *NOW*");
+		return G_MAXUINT;
+	}
+
 	idle = (guint) g_timer_elapsed (engine->priv->timer, NULL);
 	pk_debug ("engine idle=%i", idle);
 	return idle;
@@ -3020,6 +3029,18 @@ pk_engine_class_init (PkEngineClass *klass)
 }
 
 /**
+ * pk_engine_restart_schedule_cb:
+ **/
+static void
+pk_engine_restart_schedule_cb (PkRestart *restart, PkEngine *engine)
+{
+	g_return_if_fail (engine != NULL);
+	g_return_if_fail (PK_IS_ENGINE (engine));
+	pk_debug ("setting restart_schedule TRUE");
+	engine->priv->restart_schedule = TRUE;
+}
+
+/**
  * pk_engine_init:
  **/
 static void
@@ -3030,6 +3051,7 @@ pk_engine_init (PkEngine *engine)
 	gboolean ret;
 
 	engine->priv = PK_ENGINE_GET_PRIVATE (engine);
+	engine->priv->restart_schedule = FALSE;
 
 	/* setup the backend backend */
 	engine->priv->backend = pk_backend_new ();
@@ -3105,6 +3127,11 @@ pk_engine_init (PkEngine *engine)
 	dbus_g_connection_register_g_object (connection, PK_DBUS_PATH_NOTIFY,
 					     G_OBJECT (engine->priv->notify));
 
+	/* add the interface */
+	engine->priv->restart = pk_restart_new ();
+	g_signal_connect (engine->priv->restart, "restart-schedule",
+			  G_CALLBACK (pk_engine_restart_schedule_cb), engine);
+
 	engine->priv->transaction_list = pk_transaction_list_new ();
 	g_signal_connect (engine->priv->transaction_list, "changed",
 			  G_CALLBACK (pk_engine_transaction_list_changed_cb), engine);
diff --git a/src/pk-notify.c b/src/pk-notify.c
index a39cf57..d9885d2 100644
--- a/src/pk-notify.c
+++ b/src/pk-notify.c
@@ -48,6 +48,7 @@ struct PkNotifyPrivate
 
 enum {
 	PK_NOTIFY_REPO_LIST_CHANGED,
+	PK_NOTIFY_RESTART_SCHEDULE,
 	PK_NOTIFY_UPDATES_CHANGED,
 	PK_NOTIFY_LAST_SIGNAL
 };
@@ -58,6 +59,20 @@ static guint signals [PK_NOTIFY_LAST_SIGNAL] = { 0 };
 G_DEFINE_TYPE (PkNotify, pk_notify, G_TYPE_OBJECT)
 
 /**
+ * pk_notify_restart_schedule:
+ **/
+gboolean
+pk_notify_restart_schedule (PkNotify *notify)
+{
+	g_return_val_if_fail (notify != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_NOTIFY (notify), FALSE);
+
+	pk_debug ("emitting restart-schedule");
+	g_signal_emit (notify, signals [PK_NOTIFY_RESTART_SCHEDULE], 0);
+	return TRUE;
+}
+
+/**
  * pk_notify_repo_list_changed:
  **/
 gboolean
@@ -151,6 +166,12 @@ pk_notify_class_init (PkNotifyClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 	object_class->finalize = pk_notify_finalize;
+
+	signals [PK_NOTIFY_RESTART_SCHEDULE] =
+		g_signal_new ("restart-schedule",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
 	signals [PK_NOTIFY_REPO_LIST_CHANGED] =
 		g_signal_new ("repo-list-changed",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-notify.h b/src/pk-notify.h
index 03c219e..c978596 100644
--- a/src/pk-notify.h
+++ b/src/pk-notify.h
@@ -56,6 +56,7 @@ gboolean	 pk_notify_updates_changed	(PkNotify	*notify,
 gboolean	 pk_notify_wait_updates_changed	(PkNotify	*notify,
 						 const gchar	*tid,
 						 guint		 timeout);
+gboolean	 pk_notify_restart_schedule	(PkNotify	*notify);
 
 G_END_DECLS
 
diff --git a/src/pk-restart.c b/src/pk-restart.c
index cfd3e06..2151235 100644
--- a/src/pk-restart.c
+++ b/src/pk-restart.c
@@ -39,16 +39,21 @@
 #include <pk-common.h>
 #include <pk-debug.h>
 #include "pk-restart.h"
+#include "pk-notify.h"
 
 static void     pk_restart_class_init	(PkRestartClass *klass);
 static void     pk_restart_init		(PkRestart      *restart);
 static void     pk_restart_finalize	(GObject       *object);
 
 #define PK_RESTART_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_RESTART, PkRestartPrivate))
+#define	PK_RESTART_FILE_TO_WATCH	 SBINDIR "/packagekitd"
 
 struct PkRestartPrivate
 {
 	GString			*stdout_buf;
+	PkNotify		*notify;
+	GFileMonitor		*monitor;
+	GFile			*file;
 };
 
 enum {
@@ -71,7 +76,7 @@ pk_restart_class_init (PkRestartClass *klass)
 	object_class->finalize = pk_restart_finalize;
 
 	signals [PK_RESTART_SCHEDULE] =
-		g_signal_new ("schedule",
+		g_signal_new ("restart-schedule",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
 			      0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
 			      G_TYPE_NONE, 0);
@@ -80,13 +85,48 @@ pk_restart_class_init (PkRestartClass *klass)
 }
 
 /**
+ * pk_restart_monitor_changed:
+ * @restart: This class instance
+ **/
+static void
+pk_restart_monitor_changed (GFileMonitor *monitor, GFile *file, GFile *other_file,
+			    GFileMonitorEvent event_type, PkRestart *restart)
+{
+	if (event_type != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) {
+		return;
+	}
+	pk_debug ("emit: restart-schedule");
+	g_signal_emit (restart, signals [PK_RESTART_SCHEDULE], 0);
+	pk_notify_restart_schedule (restart->priv->notify);
+}
+
+/**
  * pk_restart_init:
  * @restart: This class instance
  **/
 static void
 pk_restart_init (PkRestart *restart)
 {
+	GError *error = NULL;
 	restart->priv = PK_RESTART_GET_PRIVATE (restart);
+
+	/* notify from dbus to the client programs */
+	restart->priv->notify = pk_notify_new ();
+
+	/* this is the file we are interested in */
+	restart->priv->file = g_file_new_for_path (PK_RESTART_FILE_TO_WATCH);
+
+	/* watch this */
+	restart->priv->monitor = g_file_monitor_file (restart->priv->file, G_FILE_MONITOR_NONE, NULL, &error);
+	if (restart->priv->monitor == NULL) {
+		pk_warning ("failed to setup watch: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+	pk_debug ("watching for changes: %s", PK_RESTART_FILE_TO_WATCH);
+	g_file_monitor_set_rate_limit (restart->priv->monitor, 1000);
+	g_signal_connect (restart->priv->monitor, "changed",
+			  G_CALLBACK (pk_restart_monitor_changed), restart);
 }
 
 /**
@@ -104,6 +144,12 @@ pk_restart_finalize (GObject *object)
 	restart = PK_RESTART (object);
 	g_return_if_fail (restart->priv != NULL);
 
+	g_file_monitor_cancel (restart->priv->monitor);
+
+	g_object_unref (restart->priv->notify);
+	g_object_unref (restart->priv->file);
+	g_object_unref (restart->priv->monitor);
+
 	G_OBJECT_CLASS (pk_restart_parent_class)->finalize (object);
 }
 
@@ -129,10 +175,22 @@ pk_restart_new (void)
 void
 libst_restart (LibSelfTest *test)
 {
+	PkRestart *restart;
+
 	if (libst_start (test, "PkRestart", CLASS_AUTO) == FALSE) {
 		return;
 	}
 
+	/************************************************************/
+	libst_title (test, "get a restart");
+	restart = pk_restart_new ();
+	if (restart != NULL) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, NULL);
+	}
+	g_object_unref (restart);
+
 	libst_end (test);
 }
 #endif
diff --git a/src/pk-self-test.c b/src/pk-self-test.c
index 55fb8ef..d0aace7 100644
--- a/src/pk-self-test.c
+++ b/src/pk-self-test.c
@@ -37,6 +37,7 @@ void libst_backend (LibSelfTest *test);
 void libst_backend_spawn (LibSelfTest *test);
 void libst_backend_thread (LibSelfTest *test);
 void libst_backend_dbus (LibSelfTest *test);
+void libst_restart (LibSelfTest *test);
 void libst_engine (LibSelfTest *test);
 
 int
@@ -52,6 +53,7 @@ main (int argc, char **argv)
 	pk_debug_init (TRUE);
 
 	/* components */
+	libst_restart (&test);
 	libst_security (&test);
 	libst_time (&test);
 	libst_conf (&test);
commit a5f0856bb11b73227be7e95946e1b1f03baea1f5
Author: Ken VanDine <ken at vandine.org>
Date:   Mon Mar 31 17:01:13 2008 -0400

    added update

diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 7cf067f..f0e8e46 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -258,6 +258,23 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
         cache.populate_database()
 
     @ExceptionHandler
+    def update(self, packages):
+        '''
+        Implement the {backend}-update functionality
+        '''
+        self.allow_cancel(True);
+        self.percentage(0)
+        self.status(STATUS_RUNNING)
+
+        for package in packages.split(" "):
+            name, version, flavor, installed = self._findPackage(package)
+            if name:
+                self._do_package_update(name, version, flavor, apply=True)
+            else:
+                self.error(ERROR_PACKAGE_ALREADY_INSTALLED,
+                    'No available updates')
+
+    @ExceptionHandler
     def install(self, package_id):
         '''
         Implement the {backend}-install functionality
@@ -265,7 +282,7 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
         name, version, flavor, installed = self._findPackage(package_id)
 
         self.allow_cancel(True)
-        self.percentage(None)
+        self.percentage(0)
         self.status(STATUS_INSTALL)
 
         if name:
diff --git a/backends/conary/helpers/update.py b/backends/conary/helpers/update.py
index 5e5ead7..75b852a 100755
--- a/backends/conary/helpers/update.py
+++ b/backends/conary/helpers/update.py
@@ -12,7 +12,7 @@
 import sys
 from conaryBackend import PackageKitConaryBackend
 
-package = sys.argv[1]
+packages = sys.argv[1]
 backend = PackageKitConaryBackend(sys.argv[1:])
-backend.install(package)
+backend.update(packages)
 sys.exit(0)
commit 1c86ac98e9661dd569241c150d23ecf382aaf44d
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Mar 31 20:02:02 2008 +0100

    add a stub gobject for restart detection. more to come

diff --git a/src/Makefile.am b/src/Makefile.am
index cff2004..79f55d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,6 +56,8 @@ shared_SOURCES =					\
 	pk-notify.h					\
 	pk-spawn.c					\
 	pk-spawn.h					\
+	pk-restart.c					\
+	pk-restart.h					\
 	pk-engine.h					\
 	pk-engine.c					\
 	pk-inhibit.h					\
diff --git a/src/pk-restart.c b/src/pk-restart.c
new file mode 100644
index 0000000..cfd3e06
--- /dev/null
+++ b/src/pk-restart.c
@@ -0,0 +1,139 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <errno.h>
+#include <signal.h>
+
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+#include <pk-common.h>
+#include <pk-debug.h>
+#include "pk-restart.h"
+
+static void     pk_restart_class_init	(PkRestartClass *klass);
+static void     pk_restart_init		(PkRestart      *restart);
+static void     pk_restart_finalize	(GObject       *object);
+
+#define PK_RESTART_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_RESTART, PkRestartPrivate))
+
+struct PkRestartPrivate
+{
+	GString			*stdout_buf;
+};
+
+enum {
+	PK_RESTART_SCHEDULE,
+	PK_RESTART_LAST_SIGNAL
+};
+
+static guint	     signals [PK_RESTART_LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (PkRestart, pk_restart, G_TYPE_OBJECT)
+
+/**
+ * pk_restart_class_init:
+ * @klass: The PkRestartClass
+ **/
+static void
+pk_restart_class_init (PkRestartClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = pk_restart_finalize;
+
+	signals [PK_RESTART_SCHEDULE] =
+		g_signal_new ("schedule",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
+
+	g_type_class_add_private (klass, sizeof (PkRestartPrivate));
+}
+
+/**
+ * pk_restart_init:
+ * @restart: This class instance
+ **/
+static void
+pk_restart_init (PkRestart *restart)
+{
+	restart->priv = PK_RESTART_GET_PRIVATE (restart);
+}
+
+/**
+ * pk_restart_finalize:
+ * @object: The object to finalize
+ **/
+static void
+pk_restart_finalize (GObject *object)
+{
+	PkRestart *restart;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (PK_IS_RESTART (object));
+
+	restart = PK_RESTART (object);
+	g_return_if_fail (restart->priv != NULL);
+
+	G_OBJECT_CLASS (pk_restart_parent_class)->finalize (object);
+}
+
+/**
+ * pk_restart_new:
+ *
+ * Return value: a new PkRestart object.
+ **/
+PkRestart *
+pk_restart_new (void)
+{
+	PkRestart *restart;
+	restart = g_object_new (PK_TYPE_RESTART, NULL);
+	return PK_RESTART (restart);
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+libst_restart (LibSelfTest *test)
+{
+	if (libst_start (test, "PkRestart", CLASS_AUTO) == FALSE) {
+		return;
+	}
+
+	libst_end (test);
+}
+#endif
+
diff --git a/src/pk-restart.h b/src/pk-restart.h
new file mode 100644
index 0000000..ef29d28
--- /dev/null
+++ b/src/pk-restart.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __PK_RESTART_H
+#define __PK_RESTART_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PK_TYPE_RESTART		(pk_restart_get_type ())
+#define PK_RESTART(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_RESTART, PkRestart))
+#define PK_RESTART_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_RESTART, PkRestartClass))
+#define PK_IS_RESTART(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_RESTART))
+#define PK_IS_RESTART_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_RESTART))
+#define PK_RESTART_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_RESTART, PkRestartClass))
+
+typedef struct PkRestartPrivate PkRestartPrivate;
+
+typedef struct
+{
+	 GObject		 parent;
+	 PkRestartPrivate	*priv;
+} PkRestart;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+} PkRestartClass;
+
+GType		 pk_restart_get_type		  	(void);
+PkRestart	*pk_restart_new				(void);
+
+G_END_DECLS
+
+#endif /* __PK_RESTART_H */
commit 1dbe1c56b236e6c0df9317745e9274a6616e4624
Author: Scott Reeves <sreeves at novell.com>
Date:   Mon Mar 31 11:34:22 2008 -0600

    match the new get_repo_list(filter)

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 2cc1467..7c3cd73 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -1411,8 +1411,10 @@ backend_search_file (PkBackend *backend, const gchar *filter, const gchar *searc
  * backend_get_repo_list:
  */
 static void
-backend_get_repo_list (PkBackend *backend)
+backend_get_repo_list (PkBackend *backend, const gchar *filter)
 {
+	//Fixme - use the new param - filter
+	
 	g_return_if_fail (backend != NULL);
 
 	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
commit a70532c2fb3bcec8d10fcaa41dd276626b986b1b
Author: Luke Macken <lmacken at redhat.com>
Date:   Mon Mar 31 12:31:11 2008 -0400

    yum(2): Replace unicode decoding errors with question marks (fixes rh#439764)

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 40de71a..b0fb1d2 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -257,7 +257,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
     def _to_unicode(self, txt, encoding='utf-8'):
         if isinstance(txt, basestring):
             if not isinstance(txt, unicode):
-                txt = unicode(txt, encoding)
+                txt = unicode(txt, encoding, errors='replace')
         return txt
 
     def doLock(self):
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index a5f7fd2..8578375 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -310,7 +310,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
     def _to_unicode(self, txt, encoding='utf-8'):
         if isinstance(txt, basestring):
             if not isinstance(txt, unicode):
-                txt = unicode(txt, encoding)
+                txt = unicode(txt, encoding, errors='replace')
         return txt
 
     def _pkg_to_id(self,pkg):
commit bfd311775e832a2dc4bb5751923f852a1b987302
Merge: 58c6534... a4435f4...
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Mon Mar 31 18:26:46 2008 +0200

    Merge branch 'master' of git+ssh://megabajt@git.packagekit.org/srv/git/PackageKit

commit 58c65342acd1964ca6a1dad0e56f8068543e71d3
Author: Marcin Banasiak <megabajt at pld-linux.org>
Date:   Mon Mar 31 18:24:07 2008 +0200

    poldek: implement 'newest' filter

diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index 7a63ba8..8b1fc94 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -564,6 +564,28 @@ poldek_get_installed_packages (void)
 	return arr;
 }
 
+static void
+do_newest (tn_array *pkgs)
+{
+	guint	i = 1;
+
+	if (!n_array_is_sorted (pkgs))
+		n_array_sort_ex (pkgs, (tn_fn_cmp)pkg_cmp_name_evr_rev_recno);
+
+	while (i < pkgs->items) {
+		if (pkg_cmp_name (pkgs->data[i - 1], pkgs->data[i]) == 0) {
+			struct pkg	*pkg = n_array_nth (pkgs, i);
+
+			if (!poldek_pkg_is_installed (pkg)) {
+				n_array_remove_nth (pkgs, i);
+				continue;
+			}
+		}
+
+		i++;
+	}
+}
+
 /**
  * do_requires:
  */
@@ -762,8 +784,12 @@ poldek_backend_package (const struct pkg *pkg, gint status)
 
 	evr = poldek_pkg_evr (pkg);
 
-	if (!(poldek_pkg_is_installed(pkg)))
-	{
+	if (poldek_pkg_is_installed(pkg)) {
+		if (status == PK_INFO_ENUM_UNKNOWN)
+			status = PK_INFO_ENUM_INSTALLED;
+
+		poldek_dir = g_strdup ("installed");
+	} else {
 		if (status == PK_INFO_ENUM_UNKNOWN)
 			status = PK_INFO_ENUM_AVAILABLE;
 
@@ -771,11 +797,6 @@ poldek_backend_package (const struct pkg *pkg, gint status)
 			poldek_dir = g_strdup (pkg->pkgdir->name);
 		else
 			poldek_dir = g_strdup ("all-avail");
-	} else {
-		if (status == PK_INFO_ENUM_UNKNOWN)
-			status = PK_INFO_ENUM_INSTALLED;
-
-		poldek_dir = g_strdup ("installed");
 	}
 
 	package_id = pk_package_id_build (pkg->name,
@@ -949,6 +970,7 @@ search_package (PkBackendThread *thread, gpointer data)
 			}
 
 			n_array_sort_ex(pkgs, (tn_fn_cmp)pkg_cmp_name_evr_rev_recno);
+
 			n_array_free (available);
 		} else if (!d->filter->installed || available) {
 			gint	i;
@@ -966,6 +988,9 @@ search_package (PkBackendThread *thread, gpointer data)
 		if (pkgs) {
 			gint	i;
 
+			if (d->filter->not_newest == FALSE)
+				do_newest (pkgs);
+
 			for (i = 0; i < n_array_size (pkgs); i++) {
 				struct pkg	*pkg = n_array_nth (pkgs, i);
 
@@ -1046,8 +1071,8 @@ do_poldek_init (void) {
 
 	poldek_log_set_appender ("PackageKit", NULL, NULL, 0, (poldek_vlog_fn)poldek_backend_log);
 
-	/* unique package names */
-	poldek_configure (ctx, POLDEK_CONF_OPT, POLDEK_OP_UNIQN, 1);
+	/* disable unique package names */
+	poldek_configure (ctx, POLDEK_CONF_OPT, POLDEK_OP_UNIQN, 0);
 
 	/* poldek has to ask. Otherwise callbacks won't be used */
 	poldek_configure (ctx, POLDEK_CONF_OPT, POLDEK_OP_CONFIRM_INST, 1);
@@ -1113,10 +1138,11 @@ backend_get_filters (PkBackend *backend, PkEnumList *elist)
 	g_return_if_fail (backend != NULL);
 
 	pk_enum_list_append_multiple (elist,
+				      PK_FILTER_ENUM_DEVELOPMENT,
 				      PK_FILTER_ENUM_GUI,
 				      PK_FILTER_ENUM_INSTALLED,
-				      PK_FILTER_ENUM_DEVELOPMENT,
-				    /*  PK_FILTER_ENUM_FREE,*/
+				      PK_FILTER_ENUM_NEWEST,
+				    /* PK_FILTER_ENUM_FREE, */
 				      -1);
 }
 
@@ -1494,6 +1520,9 @@ backend_get_updates_thread (PkBackendThread *thread, gpointer data)
 
 			pkgs = poclidek_rcmd_get_packages (rcmd);
 
+			/* GetUpdates returns only the newest packages */
+			do_newest (pkgs);
+
 			for (i = 0; i < n_array_size (pkgs); i++) {
 				struct pkg	*pkg = n_array_nth (pkgs, i);
 
@@ -1935,7 +1964,7 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
  * backend_get_repo_list:
  */
 static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter
+backend_get_repo_list (PkBackend *backend, const gchar *filter)
 {
 	tn_array	*sources = NULL;
 
commit a4435f4d8a672504819aa2c389983cc6e97a838c
Author: Tim Lauridsen <tim at naboo.local>
Date:   Mon Mar 31 17:30:32 2008 +0200

    yum: fixed Traceback in install_file (rhbz #439728)

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 404b528..40de71a 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -850,14 +850,18 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         pkgs_to_inst = []
         self.yumbase.conf.gpgcheck=0
         txmbr = self.yumbase.installLocal(inst_file)
-        self._checkForNewer(txmbr[0].po)
-        try:
-            # Added the package to the transaction set
-            if len(self.yumbase.tsInfo) > 0:
-                self._runYumTransaction()
-        except yum.Errors.InstallError,e:
-            msgs = ';'.join(e)
-            self.error(ERROR_PACKAGE_ALREADY_INSTALLED,msgs)
+        if txmbr:
+            self._checkForNewer(txmbr[0].po)
+            try:
+                # Added the package to the transaction set
+                if len(self.yumbase.tsInfo) > 0:
+                    self._runYumTransaction()
+            except yum.Errors.InstallError,e:
+                msgs = ';'.join(e)
+                self.error(ERROR_PACKAGE_ALREADY_INSTALLED,msgs)
+        else:
+            self.error(ERROR_PACKAGE_ALREADY_INSTALLED,"Can't install %s " % install_file)
+            
 
     def update(self, packages):
         '''



More information about the PackageKit mailing list