50551d0
--- cups-1.3b1/backend/ipp.c.eggcups	2007-07-11 22:46:42.000000000 +0100
50551d0
+++ cups-1.3b1/backend/ipp.c	2007-07-18 11:34:16.000000000 +0100
50551d0
@@ -57,6 +57,70 @@
50551d0
 static char	tmpfilename[1024] = "";	/* Temporary spool file name */
50551d0
 static int	job_cancelled = 0;	/* Job cancelled? */
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
 /*
50551d0
  * Local functions...
50551d0
@@ -974,6 +1038,15 @@
50551d0
       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)
50551d0
--- cups-1.3b1/backend/Makefile.eggcups	2007-07-11 22:46:42.000000000 +0100
50551d0
+++ cups-1.3b1/backend/Makefile	2007-07-18 11:36:35.000000000 +0100
50551d0
@@ -131,7 +131,7 @@
11255c8
 
11255c8
 ipp:	ipp.o ../cups/$(LIBCUPS)
11255c8
 	echo Linking $@...
11255c8
-	$(CC) $(LDFLAGS) -o ipp ipp.o $(LIBS)
50551d0
+	$(CC) $(LDFLAGS) -o ipp ipp.o $(LIBS) $(CUPSDLIBS)
11255c8
 	$(RM) http
11255c8
 	$(LN) ipp http
11255c8
 
50551d0
--- cups-1.3b1/scheduler/subscriptions.c.eggcups	2007-07-11 22:46:42.000000000 +0100
50551d0
+++ cups-1.3b1/scheduler/subscriptions.c	2007-07-18 11:34:16.000000000 +0100
50551d0
@@ -1292,13 +1292,13 @@
78ddcc4
     what = "PrinterAdded";
78ddcc4
   else if (event & CUPSD_EVENT_PRINTER_DELETED)
78ddcc4
     what = "PrinterRemoved";
78ddcc4
-  else if (event & CUPSD_EVENT_PRINTER_CHANGED)
78ddcc4
-    what = "QueueChanged";
78ddcc4
   else if (event & CUPSD_EVENT_JOB_CREATED)
78ddcc4
     what = "JobQueuedLocal";
78ddcc4
   else if ((event & CUPSD_EVENT_JOB_STATE) && job &&
78ddcc4
            job->state_value == IPP_JOB_PROCESSING)
78ddcc4
     what = "JobStartedLocal";
78ddcc4
+  else if (event & (CUPSD_EVENT_PRINTER_CHANGED|CUPSD_EVENT_JOB_STATE_CHANGED|CUPSD_EVENT_PRINTER_STATE_CHANGED))
78ddcc4
+    what = "QueueChanged";
78ddcc4
   else
78ddcc4
     return;
78ddcc4
 
50551d0
@@ -1334,7 +1334,7 @@
78ddcc4
   dbus_message_append_iter_init(message, &iter);
78ddcc4
   if (dest)
78ddcc4
     dbus_message_iter_append_string(&iter, dest->name);
78ddcc4
-  if (job)
78ddcc4
+  if (job && strcmp (what, "QueueChanged") != 0)
78ddcc4
   {
78ddcc4
     dbus_message_iter_append_uint32(&iter, job->id);
78ddcc4
     dbus_message_iter_append_string(&iter, job->username);