bd63485
--- cups-1.2.5/config-scripts/cups-common.m4.eggcups	2006-10-20 16:11:40.000000000 +0100
bd63485
+++ cups-1.2.5/config-scripts/cups-common.m4	2006-11-03 09:55:31.000000000 +0000
bd63485
@@ -191,6 +191,7 @@
bd63485
 dnl Extra platform-specific libraries...
bd63485
 BACKLIBS=""
bd63485
 CUPSDLIBS=""
bd63485
+DBUSLIBS=""
bd63485
 DBUSDIR=""
bd63485
 
bd63485
 AC_ARG_ENABLE(dbus, [  --enable-dbus           enable DBUS support, default=auto])
bd63485
@@ -234,7 +235,8 @@
bd63485
 					AC_MSG_RESULT(yes)
bd63485
 					AC_DEFINE(HAVE_DBUS)
bd63485
 					CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
bd63485
-					CUPSDLIBS="`$PKGCONFIG --libs dbus-1`"
bd63485
+					DBUSLIBS="`$PKGCONFIG --libs dbus-1`"
bd63485
+					CUPSDLIBS="$DBUSLIBS"
bd63485
 					DBUSDIR="/etc/dbus-1/system.d"
bd63485
 					AC_CHECK_LIB(dbus-1,
bd63485
 					    dbus_message_iter_init_append,
bd63485
@@ -256,6 +258,7 @@
bd63485
 
bd63485
 AC_SUBST(BACKLIBS)
bd63485
 AC_SUBST(CUPSDLIBS)
bd63485
+AC_SUBST(DBUSLIBS)
bd63485
 AC_SUBST(DBUSDIR)
bd63485
 
bd63485
 dnl New default port definition for IPP...
188c365
--- cups-1.2.5/scheduler/subscriptions.c.eggcups	2006-09-29 03:26:29.000000000 +0100
bd63485
+++ cups-1.2.5/scheduler/subscriptions.c	2006-11-03 09:59:16.000000000 +0000
4a4ac22
@@ -1321,13 +1321,13 @@
188c365
     what = "PrinterAdded";
188c365
   else if (event & CUPSD_EVENT_PRINTER_DELETED)
188c365
     what = "PrinterRemoved";
188c365
-  else if (event & CUPSD_EVENT_PRINTER_CHANGED)
bd63485
-    what = "QueueChanged";
188c365
   else if (event & CUPSD_EVENT_JOB_CREATED)
188c365
     what = "JobQueuedLocal";
bd63485
   else if ((event & CUPSD_EVENT_JOB_STATE) && job &&
4a4ac22
            job->state_value == IPP_JOB_PROCESSING)
bd63485
     what = "JobStartedLocal";
bd63485
+  else if (event & (CUPSD_EVENT_PRINTER_CHANGED|CUPSD_EVENT_JOB_STATE_CHANGED))
bd63485
+    what = "QueueChanged";
bd63485
   else
bd63485
     return;
bd63485
 
4a4ac22
@@ -1363,7 +1363,7 @@
bd63485
   dbus_message_append_iter_init(message, &iter);
bd63485
   if (dest)
bd63485
     dbus_message_iter_append_string(&iter, &(dest->name));
bd63485
-  if (job)
bd63485
+  if (job && strcmp (what, "QueueChanged") != 0)
bd63485
   {
bd63485
     dbus_message_iter_append_uint32(&iter, &(job->id));
bd63485
     dbus_message_iter_append_string(&iter, &(job->username));
bd63485
--- cups-1.2.5/backend/ipp.c.eggcups	2006-09-13 19:22:34.000000000 +0100
bd63485
+++ cups-1.2.5/backend/ipp.c	2006-11-03 10:02:04.000000000 +0000
bd63485
@@ -54,6 +54,70 @@
bd63485
 #include <signal.h>
bd63485
 #include <sys/wait.h>
bd63485
 
bd63485
+#if HAVE_DBUS
bd63485
+#include <dbus/dbus.h>
bd63485
+
bd63485
+static DBusConnection *dbus_connection = NULL;
bd63485
+
bd63485
+static int
bd63485
+init_dbus (void)
bd63485
+{
bd63485
+  DBusConnection *connection;
bd63485
+  DBusError error;
bd63485
+
bd63485
+  if (dbus_connection &&
bd63485
+      !dbus_connection_get_is_connected (dbus_connection)) {
bd63485
+    dbus_connection_unref (dbus_connection);
bd63485
+    dbus_connection = NULL;
bd63485
+  }
bd63485
+  
bd63485
+  dbus_error_init (&error);
bd63485
+  connection = dbus_bus_get (getuid () ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error);
bd63485
+  if (connection == NULL) {
bd63485
+    dbus_error_free (&error);
bd63485
+    return -1;
bd63485
+  }
bd63485
+
bd63485
+  dbus_connection = connection;
bd63485
+  return 0;
bd63485
+}
bd63485
+
bd63485
+int
bd63485
+dbus_broadcast_queued_remote (const char *printer_uri,
bd63485
+			      ipp_status_t status,
bd63485
+			      unsigned int local_job_id,
bd63485
+			      unsigned int remote_job_id,
bd63485
+			      const char *username,
bd63485
+			      const char *printer_name)
bd63485
+{
bd63485
+  DBusMessage *message;
bd63485
+  DBusMessageIter iter;
bd63485
+  const char *errstr;
bd63485
+
bd63485
+  if (!dbus_connection || !dbus_connection_get_is_connected (dbus_connection)) {
bd63485
+    if (init_dbus () || !dbus_connection)
bd63485
+      return -1;
bd63485
+  }
bd63485
+
bd63485
+  errstr = ippErrorString (status);
bd63485
+  message = dbus_message_new_signal ("/com/redhat/PrinterSpooler",
bd63485
+				     "com.redhat.PrinterSpooler",
bd63485
+				     "JobQueuedRemote");
bd63485
+  dbus_message_iter_init_append (message, &iter);
bd63485
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_uri);
bd63485
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &errstr);
bd63485
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &local_job_id);
bd63485
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &remote_job_id);
bd63485
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &username);
bd63485
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_name);
bd63485
+
bd63485
+  dbus_connection_send (dbus_connection, message, NULL);
bd63485
+  dbus_connection_flush (dbus_connection);
bd63485
+  dbus_message_unref (message);
bd63485
+  
bd63485
+  return 0;
bd63485
+}
bd63485
+#endif /* HAVE_DBUS */
bd63485
 
bd63485
 /*
bd63485
  * Globals...
bd63485
@@ -936,6 +1000,15 @@
bd63485
       fprintf(stderr, "NOTICE: Print file accepted - job ID %d.\n", job_id);
bd63485
     }
bd63485
 
bd63485
+#if HAVE_DBUS
bd63485
+    dbus_broadcast_queued_remote (argv[0],
bd63485
+				  ipp_status,
bd63485
+				  atoi (argv[1]),
bd63485
+				  job_id,
bd63485
+				  argv[2],
bd63485
+				  getenv ("PRINTER"));
bd63485
+#endif /* HAVE_DBUS */
bd63485
+
bd63485
     ippDelete(response);
bd63485
 
bd63485
     if (job_cancelled)
bd63485
--- cups-1.2.5/backend/Makefile.eggcups	2006-05-26 20:51:59.000000000 +0100
bd63485
+++ cups-1.2.5/backend/Makefile	2006-11-03 09:55:31.000000000 +0000
bd63485
@@ -134,7 +134,7 @@
bd63485
 
bd63485
 ipp:	ipp.o ../cups/$(LIBCUPS)
bd63485
 	echo Linking $@...
bd63485
-	$(CC) $(LDFLAGS) -o ipp ipp.o $(LIBS)
bd63485
+	$(CC) $(LDFLAGS) -o ipp ipp.o $(LIBS) $(DBUSLIBS)
bd63485
 	$(RM) http
bd63485
 	$(LN) ipp http
bd63485
 
bd63485
--- cups-1.2.5/Makedefs.in.eggcups	2006-11-03 09:55:31.000000000 +0000
bd63485
+++ cups-1.2.5/Makedefs.in	2006-11-03 09:55:31.000000000 +0000
bd63485
@@ -124,6 +124,7 @@
bd63485
 			@LARGEFILE@ @PTHREAD_FLAGS@ $(OPTIONS)
bd63485
 COMMONLIBS	=	@LIBS@
bd63485
 CUPSDLIBS	=	@CUPSDLIBS@
bd63485
+DBUSLIBS	=	@DBUSLIBS@
bd63485
 CXXFLAGS	=	-I.. $(SSLFLAGS) @CPPFLAGS@ @CXXFLAGS@ \
bd63485
 			@LARGEFILE@ @PTHREAD_FLAGS@ $(OPTIONS)
bd63485
 CXXLIBS		=	@CXXLIBS@