summaryrefslogtreecommitdiffstats
path: root/cups-eggcups.patch
blob: de413f9178a67f3170b0ced330dae82118aff78c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
diff -up cups-1.5b1/backend/ipp.c.eggcups cups-1.5b1/backend/ipp.c
--- cups-1.5b1/backend/ipp.c.eggcups	2011-05-21 06:02:41.000000000 +0200
+++ cups-1.5b1/backend/ipp.c	2011-05-23 18:07:45.000000000 +0200
@@ -133,6 +133,70 @@ static cups_array_t	*state_reasons;	/* A
 static char		tmpfilename[1024] = "";
 					/* Temporary spool file name */
 
+#if HAVE_DBUS
+#include <dbus/dbus.h>
+
+static DBusConnection *dbus_connection = NULL;
+
+static int
+init_dbus (void)
+{
+  DBusConnection *connection;
+  DBusError error;
+
+  if (dbus_connection &&
+      !dbus_connection_get_is_connected (dbus_connection)) {
+    dbus_connection_unref (dbus_connection);
+    dbus_connection = NULL;
+  }
+  
+  dbus_error_init (&error);
+  connection = dbus_bus_get (getuid () ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error);
+  if (connection == NULL) {
+    dbus_error_free (&error);
+    return -1;
+  }
+
+  dbus_connection = connection;
+  return 0;
+}
+
+int
+dbus_broadcast_queued_remote (const char *printer_uri,
+			      ipp_status_t status,
+			      unsigned int local_job_id,
+			      unsigned int remote_job_id,
+			      const char *username,
+			      const char *printer_name)
+{
+  DBusMessage *message;
+  DBusMessageIter iter;
+  const char *errstr;
+
+  if (!dbus_connection || !dbus_connection_get_is_connected (dbus_connection)) {
+    if (init_dbus () || !dbus_connection)
+      return -1;
+  }
+
+  errstr = ippErrorString (status);
+  message = dbus_message_new_signal ("/com/redhat/PrinterSpooler",
+				     "com.redhat.PrinterSpooler",
+				     "JobQueuedRemote");
+  dbus_message_iter_init_append (message, &iter);
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_uri);
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &errstr);
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &local_job_id);
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &remote_job_id);
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &username);
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_name);
+
+  dbus_connection_send (dbus_connection, message, NULL);
+  dbus_connection_flush (dbus_connection);
+  dbus_message_unref (message);
+  
+  return 0;
+}
+#endif /* HAVE_DBUS */
 
 /*
  * Local functions...
@@ -1461,6 +1525,15 @@ main(int  argc,				/* I - Number of comm
                            _("Print file accepted - job ID %d."), job_id);
     }
 
+#if HAVE_DBUS
+    dbus_broadcast_queued_remote (argv[0],
+				  ipp_status,
+				  atoi (argv[1]),
+				  job_id,
+				  argv[2],
+				  getenv ("PRINTER"));
+#endif /* HAVE_DBUS */
+
     ippDelete(response);
 
     if (job_canceled)
diff -up cups-1.5b1/backend/Makefile.eggcups cups-1.5b1/backend/Makefile
--- cups-1.5b1/backend/Makefile.eggcups	2011-05-04 06:28:00.000000000 +0200
+++ cups-1.5b1/backend/Makefile	2011-05-23 18:03:22.000000000 +0200
@@ -212,7 +212,7 @@ dnssd:	dnssd.o ../cups/$(LIBCUPS) libbac
 
 ipp:	ipp.o ../cups/$(LIBCUPS) libbackend.a
 	echo Linking $@...
-	$(CC) $(LDFLAGS) -o ipp ipp.o libbackend.a $(LIBS)
+	$(CC) $(LDFLAGS) -o ipp ipp.o libbackend.a $(LIBS) $(SERVERLIBS)
 	$(RM) http
 	$(LN) ipp http
 
diff -up cups-1.5b1/scheduler/subscriptions.c.eggcups cups-1.5b1/scheduler/subscriptions.c
--- cups-1.5b1/scheduler/subscriptions.c.eggcups	2011-05-20 05:49:49.000000000 +0200
+++ cups-1.5b1/scheduler/subscriptions.c	2011-05-23 18:03:22.000000000 +0200
@@ -1310,13 +1310,13 @@ cupsd_send_dbus(cupsd_eventmask_t event,
     what = "PrinterAdded";
   else if (event & CUPSD_EVENT_PRINTER_DELETED)
     what = "PrinterRemoved";
-  else if (event & CUPSD_EVENT_PRINTER_CHANGED)
-    what = "QueueChanged";
   else if (event & CUPSD_EVENT_JOB_CREATED)
     what = "JobQueuedLocal";
   else if ((event & CUPSD_EVENT_JOB_STATE) && job &&
            job->state_value == IPP_JOB_PROCESSING)
     what = "JobStartedLocal";
+  else if (event & (CUPSD_EVENT_PRINTER_CHANGED|CUPSD_EVENT_JOB_STATE_CHANGED|CUPSD_EVENT_PRINTER_STATE_CHANGED))
+    what = "QueueChanged";
   else
     return;
 
@@ -1352,7 +1352,7 @@ cupsd_send_dbus(cupsd_eventmask_t event,
   dbus_message_append_iter_init(message, &iter);
   if (dest)
     dbus_message_iter_append_string(&iter, dest->name);
-  if (job)
+  if (job && strcmp (what, "QueueChanged") != 0)
   {
     dbus_message_iter_append_uint32(&iter, job->id);
     dbus_message_iter_append_string(&iter, job->username);