Blame SOURCES/cups-eggcups.patch

87cf9a
diff -up cups-1.5.3/backend/ipp.c.eggcups cups-1.5.3/backend/ipp.c
87cf9a
--- cups-1.5.3/backend/ipp.c.eggcups	2012-05-05 01:00:01.000000000 +0200
87cf9a
+++ cups-1.5.3/backend/ipp.c	2012-05-15 16:50:41.142868986 +0200
87cf9a
@@ -138,6 +138,70 @@ static cups_array_t	*state_reasons;	/* A
87cf9a
 static char		tmpfilename[1024] = "";
87cf9a
 					/* Temporary spool file name */
87cf9a
 
87cf9a
+#if HAVE_DBUS
87cf9a
+#include <dbus/dbus.h>
87cf9a
+
87cf9a
+static DBusConnection *dbus_connection = NULL;
87cf9a
+
87cf9a
+static int
87cf9a
+init_dbus (void)
87cf9a
+{
87cf9a
+  DBusConnection *connection;
87cf9a
+  DBusError error;
87cf9a
+
87cf9a
+  if (dbus_connection &&
87cf9a
+      !dbus_connection_get_is_connected (dbus_connection)) {
87cf9a
+    dbus_connection_unref (dbus_connection);
87cf9a
+    dbus_connection = NULL;
87cf9a
+  }
87cf9a
+  
87cf9a
+  dbus_error_init (&error);
87cf9a
+  connection = dbus_bus_get (getuid () ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error);
87cf9a
+  if (connection == NULL) {
87cf9a
+    dbus_error_free (&error);
87cf9a
+    return -1;
87cf9a
+  }
87cf9a
+
87cf9a
+  dbus_connection = connection;
87cf9a
+  return 0;
87cf9a
+}
87cf9a
+
87cf9a
+int
87cf9a
+dbus_broadcast_queued_remote (const char *printer_uri,
87cf9a
+			      ipp_status_t status,
87cf9a
+			      unsigned int local_job_id,
87cf9a
+			      unsigned int remote_job_id,
87cf9a
+			      const char *username,
87cf9a
+			      const char *printer_name)
87cf9a
+{
87cf9a
+  DBusMessage *message;
87cf9a
+  DBusMessageIter iter;
87cf9a
+  const char *errstr;
87cf9a
+
87cf9a
+  if (!dbus_connection || !dbus_connection_get_is_connected (dbus_connection)) {
87cf9a
+    if (init_dbus () || !dbus_connection)
87cf9a
+      return -1;
87cf9a
+  }
87cf9a
+
87cf9a
+  errstr = ippErrorString (status);
87cf9a
+  message = dbus_message_new_signal ("/com/redhat/PrinterSpooler",
87cf9a
+				     "com.redhat.PrinterSpooler",
87cf9a
+				     "JobQueuedRemote");
87cf9a
+  dbus_message_iter_init_append (message, &iter);
87cf9a
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_uri);
87cf9a
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &errstr);
87cf9a
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &local_job_id);
87cf9a
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &remote_job_id);
87cf9a
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &username);
87cf9a
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_name);
87cf9a
+
87cf9a
+  dbus_connection_send (dbus_connection, message, NULL);
87cf9a
+  dbus_connection_flush (dbus_connection);
87cf9a
+  dbus_message_unref (message);
87cf9a
+  
87cf9a
+  return 0;
87cf9a
+}
87cf9a
+#endif /* HAVE_DBUS */
87cf9a
 
87cf9a
 /*
87cf9a
  * Local functions...
87cf9a
@@ -1520,6 +1584,15 @@ main(int  argc,				/* I - Number of comm
87cf9a
                            _("Print file accepted - job ID %d."), job_id);
87cf9a
     }
87cf9a
 
87cf9a
+#if HAVE_DBUS
87cf9a
+    dbus_broadcast_queued_remote (argv[0],
87cf9a
+				  ipp_status,
87cf9a
+				  atoi (argv[1]),
87cf9a
+				  job_id,
87cf9a
+				  argv[2],
87cf9a
+				  getenv ("PRINTER"));
87cf9a
+#endif /* HAVE_DBUS */
87cf9a
+
87cf9a
     fprintf(stderr, "DEBUG: job-id=%d\n", job_id);
87cf9a
     ippDelete(response);
87cf9a
 
87cf9a
diff -up cups-1.5.3/backend/Makefile.eggcups cups-1.5.3/backend/Makefile
87cf9a
--- cups-1.5.3/backend/Makefile.eggcups	2012-04-23 19:42:12.000000000 +0200
87cf9a
+++ cups-1.5.3/backend/Makefile	2012-05-15 16:48:17.253871982 +0200
87cf9a
@@ -212,7 +212,7 @@ dnssd:	dnssd.o ../cups/$(LIBCUPS) libbac
87cf9a
 
87cf9a
 ipp:	ipp.o ../cups/$(LIBCUPS) libbackend.a
87cf9a
 	echo Linking $@...
87cf9a
-	$(CC) $(LDFLAGS) -o ipp ipp.o libbackend.a $(LIBS)
87cf9a
+	$(CC) $(LDFLAGS) -o ipp ipp.o libbackend.a $(LIBS) $(SERVERLIBS)
87cf9a
 	$(RM) http
87cf9a
 	$(LN) ipp http
87cf9a
 
87cf9a
diff -up cups-1.5.3/scheduler/subscriptions.c.eggcups cups-1.5.3/scheduler/subscriptions.c
87cf9a
--- cups-1.5.3/scheduler/subscriptions.c.eggcups	2012-02-12 06:48:09.000000000 +0100
87cf9a
+++ cups-1.5.3/scheduler/subscriptions.c	2012-05-15 16:48:17.253871982 +0200
87cf9a
@@ -1314,13 +1314,13 @@ cupsd_send_dbus(cupsd_eventmask_t event,
87cf9a
     what = "PrinterAdded";
87cf9a
   else if (event & CUPSD_EVENT_PRINTER_DELETED)
87cf9a
     what = "PrinterRemoved";
87cf9a
-  else if (event & CUPSD_EVENT_PRINTER_CHANGED)
87cf9a
-    what = "QueueChanged";
87cf9a
   else if (event & CUPSD_EVENT_JOB_CREATED)
87cf9a
     what = "JobQueuedLocal";
87cf9a
   else if ((event & CUPSD_EVENT_JOB_STATE) && job &&
87cf9a
            job->state_value == IPP_JOB_PROCESSING)
87cf9a
     what = "JobStartedLocal";
87cf9a
+  else if (event & (CUPSD_EVENT_PRINTER_CHANGED|CUPSD_EVENT_JOB_STATE_CHANGED|CUPSD_EVENT_PRINTER_STATE_CHANGED))
87cf9a
+    what = "QueueChanged";
87cf9a
   else
87cf9a
     return;
87cf9a
 
87cf9a
@@ -1356,7 +1356,7 @@ cupsd_send_dbus(cupsd_eventmask_t event,
87cf9a
   dbus_message_append_iter_init(message, &iter);
87cf9a
   if (dest)
87cf9a
     dbus_message_iter_append_string(&iter, dest->name);
87cf9a
-  if (job)
87cf9a
+  if (job && strcmp (what, "QueueChanged") != 0)
87cf9a
   {
87cf9a
     dbus_message_iter_append_uint32(&iter, job->id);
87cf9a
     dbus_message_iter_append_string(&iter, job->username);