3a3657f
--- cups-1.2.11/backend/ipp.c.eggcups	2007-04-30 18:18:21.000000000 +0100
3a3657f
+++ cups-1.2.11/backend/ipp.c	2007-06-13 16:47:06.000000000 +0100
11255c8
@@ -54,6 +54,70 @@
11255c8
 #include <signal.h>
11255c8
 #include <sys/wait.h>
11255c8
 
11255c8
+#if HAVE_DBUS
11255c8
+#include <dbus/dbus.h>
11255c8
+
11255c8
+static DBusConnection *dbus_connection = NULL;
11255c8
+
11255c8
+static int
11255c8
+init_dbus (void)
11255c8
+{
11255c8
+  DBusConnection *connection;
11255c8
+  DBusError error;
11255c8
+
11255c8
+  if (dbus_connection &&
11255c8
+      !dbus_connection_get_is_connected (dbus_connection)) {
11255c8
+    dbus_connection_unref (dbus_connection);
11255c8
+    dbus_connection = NULL;
11255c8
+  }
11255c8
+  
11255c8
+  dbus_error_init (&error);
11255c8
+  connection = dbus_bus_get (getuid () ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error);
11255c8
+  if (connection == NULL) {
11255c8
+    dbus_error_free (&error);
11255c8
+    return -1;
11255c8
+  }
11255c8
+
11255c8
+  dbus_connection = connection;
11255c8
+  return 0;
11255c8
+}
11255c8
+
11255c8
+int
11255c8
+dbus_broadcast_queued_remote (const char *printer_uri,
11255c8
+			      ipp_status_t status,
11255c8
+			      unsigned int local_job_id,
11255c8
+			      unsigned int remote_job_id,
11255c8
+			      const char *username,
11255c8
+			      const char *printer_name)
11255c8
+{
11255c8
+  DBusMessage *message;
11255c8
+  DBusMessageIter iter;
11255c8
+  const char *errstr;
11255c8
+
11255c8
+  if (!dbus_connection || !dbus_connection_get_is_connected (dbus_connection)) {
11255c8
+    if (init_dbus () || !dbus_connection)
11255c8
+      return -1;
11255c8
+  }
11255c8
+
11255c8
+  errstr = ippErrorString (status);
11255c8
+  message = dbus_message_new_signal ("/com/redhat/PrinterSpooler",
11255c8
+				     "com.redhat.PrinterSpooler",
11255c8
+				     "JobQueuedRemote");
11255c8
+  dbus_message_iter_init_append (message, &iter);
11255c8
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_uri);
11255c8
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &errstr);
11255c8
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &local_job_id);
11255c8
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &remote_job_id);
11255c8
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &username);
11255c8
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_name);
11255c8
+
11255c8
+  dbus_connection_send (dbus_connection, message, NULL);
11255c8
+  dbus_connection_flush (dbus_connection);
11255c8
+  dbus_message_unref (message);
11255c8
+  
11255c8
+  return 0;
11255c8
+}
11255c8
+#endif /* HAVE_DBUS */
11255c8
 
11255c8
 /*
11255c8
  * Globals...
3a3657f
@@ -955,6 +1019,15 @@
11255c8
       fprintf(stderr, "NOTICE: Print file accepted - job ID %d.\n", job_id);
11255c8
     }
11255c8
 
11255c8
+#if HAVE_DBUS
11255c8
+    dbus_broadcast_queued_remote (argv[0],
11255c8
+				  ipp_status,
11255c8
+				  atoi (argv[1]),
11255c8
+				  job_id,
11255c8
+				  argv[2],
11255c8
+				  getenv ("PRINTER"));
11255c8
+#endif /* HAVE_DBUS */
11255c8
+
11255c8
     ippDelete(response);
11255c8
 
11255c8
     if (job_cancelled)
3a3657f
--- cups-1.2.11/backend/Makefile.eggcups	2006-10-23 01:26:52.000000000 +0100
3a3657f
+++ cups-1.2.11/backend/Makefile	2007-06-13 16:47:06.000000000 +0100
11255c8
@@ -134,7 +134,7 @@
11255c8
 
11255c8
 ipp:	ipp.o ../cups/$(LIBCUPS)
11255c8
 	echo Linking $@...
11255c8
-	$(CC) $(LDFLAGS) -o ipp ipp.o $(LIBS)
11255c8
+	$(CC) $(LDFLAGS) -o ipp ipp.o $(LIBS) $(DBUSLIBS)
11255c8
 	$(RM) http
11255c8
 	$(LN) ipp http
11255c8
 
3a3657f
--- cups-1.2.11/config-scripts/cups-common.m4.eggcups	2007-05-08 22:11:23.000000000 +0100
3a3657f
+++ cups-1.2.11/config-scripts/cups-common.m4	2007-06-13 16:47:06.000000000 +0100
3a3657f
@@ -188,6 +188,7 @@
3a3657f
 dnl Extra platform-specific libraries...
3a3657f
 BACKLIBS=""
3a3657f
 CUPSDLIBS=""
3a3657f
+DBUSLIBS=""
3a3657f
 DBUSDIR=""
3a3657f
 
3a3657f
 AC_ARG_ENABLE(dbus, [  --enable-dbus           enable DBUS support, default=auto])
3a3657f
@@ -231,7 +232,8 @@
3a3657f
 					AC_MSG_RESULT(yes)
3a3657f
 					AC_DEFINE(HAVE_DBUS)
3a3657f
 					CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE"
3a3657f
-					CUPSDLIBS="`$PKGCONFIG --libs dbus-1`"
3a3657f
+					DBUSLIBS="`$PKGCONFIG --libs dbus-1`"
3a3657f
+					CUPSDLIBS="$DBUSLIBS"
3a3657f
 					DBUSDIR="/etc/dbus-1/system.d"
3a3657f
 					AC_CHECK_LIB(dbus-1,
3a3657f
 					    dbus_message_iter_init_append,
3a3657f
@@ -253,6 +255,7 @@
3a3657f
 
3a3657f
 AC_SUBST(BACKLIBS)
3a3657f
 AC_SUBST(CUPSDLIBS)
3a3657f
+AC_SUBST(DBUSLIBS)
3a3657f
 AC_SUBST(DBUSDIR)
3a3657f
 
3a3657f
 dnl New default port definition for IPP...
3a3657f
--- cups-1.2.11/scheduler/subscriptions.c.eggcups	2007-04-10 19:24:19.000000000 +0100
3a3657f
+++ cups-1.2.11/scheduler/subscriptions.c	2007-06-13 16:48:10.000000000 +0100
3a3657f
@@ -1321,13 +1321,13 @@
3a3657f
     what = "PrinterAdded";
3a3657f
   else if (event & CUPSD_EVENT_PRINTER_DELETED)
3a3657f
     what = "PrinterRemoved";
3a3657f
-  else if (event & CUPSD_EVENT_PRINTER_CHANGED)
3a3657f
-    what = "QueueChanged";
3a3657f
   else if (event & CUPSD_EVENT_JOB_CREATED)
3a3657f
     what = "JobQueuedLocal";
3a3657f
   else if ((event & CUPSD_EVENT_JOB_STATE) && job &&
3a3657f
            job->state_value == IPP_JOB_PROCESSING)
3a3657f
     what = "JobStartedLocal";
3a3657f
+  else if (event & (CUPSD_EVENT_PRINTER_CHANGED|CUPSD_EVENT_JOB_STATE_CHANGED|CUPSD_EVENT_PRINTER_STATE_CHANGED))
3a3657f
+    what = "QueueChanged";
3a3657f
   else
3a3657f
     return;
3a3657f
 
3a3657f
@@ -1363,7 +1363,7 @@
3a3657f
   dbus_message_append_iter_init(message, &iter);
3a3657f
   if (dest)
3a3657f
     dbus_message_iter_append_string(&iter, dest->name);
3a3657f
-  if (job)
3a3657f
+  if (job && strcmp (what, "QueueChanged") != 0)
3a3657f
   {
3a3657f
     dbus_message_iter_append_uint32(&iter, job->id);
3a3657f
     dbus_message_iter_append_string(&iter, job->username);
3a3657f
--- cups-1.2.11/Makedefs.in.eggcups	2007-06-13 16:47:06.000000000 +0100
3a3657f
+++ cups-1.2.11/Makedefs.in	2007-06-13 16:47:06.000000000 +0100
11255c8
@@ -124,6 +124,7 @@
11255c8
 			@LARGEFILE@ @PTHREAD_FLAGS@ $(OPTIONS)
11255c8
 COMMONLIBS	=	@LIBS@
11255c8
 CUPSDLIBS	=	@CUPSDLIBS@
11255c8
+DBUSLIBS	=	@DBUSLIBS@
11255c8
 CXXFLAGS	=	-I.. $(SSLFLAGS) @CPPFLAGS@ @CXXFLAGS@ \
11255c8
 			@LARGEFILE@ @PTHREAD_FLAGS@ $(OPTIONS)
11255c8
 CXXLIBS		=	@CXXLIBS@