[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#260246: marked as done (Please, add D-BUS support patch)



Your message dated Sun, 18 Jun 2006 21:23:55 +0900
with message-id <20060618122355.4BE8623EEF3@mail.topstudio.co.jp>
and subject line #260246: Please, add D-BUS support patch
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: cupsys
Version: 1.1.20final+rc1-1
Severity: wishlist
Tags: patch

Here is the patch that adds D-BUS messaging bus support for CUPS. It's
taken from GNOME CVS, from eggcups module. Eggcups (and probably some
other new desktop software, that loves D-BUS) won't work without it, so
please, apply it! Thanks for your work! Bye.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (990, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.7-1-k7
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8

Versions of packages cupsys depends on:
ii  adduser                3.57              Add and remove users and groups
ii  debconf                1.4.29            Debian configuration management sy
ii  gs-esp                 7.07.1-8          The Ghostscript PostScript interpr
ii  libc6                  2.3.2.ds1-13      GNU C Library: Shared libraries an
ii  libcupsimage2          1.1.20final+rc1-1 Common UNIX Printing System(tm) - 
ii  libcupsys2-gnutls10    1.1.20final+rc1-1 Common UNIX Printing System(tm) - 
ii  libgnutls10            1.0.4-3           GNU TLS library - runtime library
ii  libpam0g               0.76-22           Pluggable Authentication Modules l
ii  libpaper1              1.1.14            Library for handling paper charact
ii  libslp1                1.0.11-7          OpenSLP libraries
ii  zlib1g                 1:1.2.1.1-5       compression library - runtime

-- debconf information excluded
--- cups-1.1.20/scheduler/main.c	2004-05-26 17:00:34.933763512 -0400
+++ cups-1.1.20/scheduler/main.c	2004-06-01 11:45:20.040522200 -0400
@@ -48,6 +48,8 @@
 #include <syslog.h>
 #include <grp.h>
 
+#include <dbus/dbus.h>
+
 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
 #  include <malloc.h>
 #endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
@@ -78,6 +80,79 @@
 static int	stop_scheduler = 0;	/* Should the scheduler stop? */
 
 
+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 (DBUS_BUS_SYSTEM, &error);
+  if (connection == NULL) {
+    dbus_error_free (&error);
+    return -1;
+  }
+
+  dbus_connection = connection;
+  return 0;
+}
+
+int dbus_broadcast_local_queue_change (void)
+{
+  DBusMessage *message;
+
+  if (!dbus_connection || !dbus_connection_get_is_connected (dbus_connection)) {
+    if (init_dbus () || !dbus_connection)
+      return -1;
+  }
+
+  message = dbus_message_new_signal ("/com/redhat/PrinterSpooler",
+				     "com.redhat.PrinterSpooler",
+				     "QueueChanged");
+  dbus_connection_send (dbus_connection, message, NULL);
+  dbus_connection_flush (dbus_connection);
+  dbus_message_unref (message);
+  
+  return 0;
+}
+
+int dbus_broadcast_queued_local (const char *printer_name,
+				 int is_remote,
+				 unsigned int job_id,
+				 const char *username)
+{
+  DBusMessage *message;
+  DBusMessageIter iter;
+
+  if (!dbus_connection || !dbus_connection_get_is_connected (dbus_connection)) {
+    if (init_dbus () || !dbus_connection)
+      return -1;
+  }
+
+  message = dbus_message_new_signal ("/com/redhat/PrinterSpooler",
+				     "com.redhat.PrinterSpooler",
+				     "JobQueuedLocal");
+  dbus_message_append_iter_init (message, &iter);
+  dbus_message_iter_append_string (&iter, printer_name);
+  dbus_message_iter_append_boolean (&iter, is_remote == 0 ? FALSE : TRUE);
+  dbus_message_iter_append_uint32 (&iter, job_id);
+  dbus_message_iter_append_string (&iter, username);
+
+  dbus_connection_send (dbus_connection, message, NULL);
+  dbus_connection_flush (dbus_connection);
+  dbus_message_unref (message);
+  
+  return 0;
+}
+
 /*
  * 'main()' - Main entry for the CUPS scheduler.
  */
@@ -383,6 +458,8 @@
   if (only_ppds)
     return 0;
 
+  init_dbus ();
+
 #ifdef __sgi
  /*
   * Try to create a fake lpsched lock file if one is not already there.
--- cups-1.1.20/scheduler/cupsd.h	2004-05-26 16:49:11.847608392 -0400
+++ cups-1.1.20/scheduler/cupsd.h	2004-06-01 11:44:55.149306240 -0400
@@ -207,6 +207,11 @@
 extern void	StartServer(void);
 extern void	StopServer(void);
 
+extern int dbus_broadcast_local_queue_change (void);
+extern int dbus_broadcast_queued_local (const char *printer_name,
+					int is_remote,
+					unsigned int job_id,
+					const char *username);
 
 /*
  * End of "$Id: cups-dbus.patch,v 1.1 2004/07/15 17:53:58 walters Exp $".
--- cups-1.1.20/scheduler/Makefile.dbus	2004-02-10 10:58:52.000000000 +0000
+++ cups-1.1.20/scheduler/Makefile	2004-02-10 10:58:52.000000000 +0000
@@ -27,6 +27,9 @@
 CFLAGS += -fpie
 LDFLAGS += -pie
 
+CFLAGS += `pkg-config --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE
+DBUS_LDFLAGS += `pkg-config --libs dbus-1`
+
 CUPSDOBJS =	auth.o banners.o cert.o classes.o client.o conf.o devices.o \
 		dirsvc.o main.o ipp.o listen.o job.o log.o network.o \
 		ppds.o printers.o quotas.o server.o
@@ -85,7 +88,7 @@
 	echo Linking $@...
 	$(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) libmime.a \
 		$(LIBZ) $(SSLLIBS) $(LIBSLP) $(PAMLIBS) $(LIBS) \
-		$(LIBPAPER) $(LIBMALLOC)
+		$(LIBPAPER) $(LIBMALLOC) $(DBUS_LDFLAGS)
 
 
 #
--- cups-1.1.20/scheduler/job.c	2004-02-10 10:58:52.000000000 +0000
+++ cups-1.1.20/scheduler/job.c	2004-05-26 16:52:04.849308136 -0400
@@ -122,6 +122,7 @@
   else
     Jobs = job;
 
+  dbus_broadcast_local_queue_change ();
   return (job);
 }
 
@@ -222,8 +223,11 @@
 	NumJobs --;
       }
 
+      dbus_broadcast_local_queue_change ();
       return;
     }
+
+  dbus_broadcast_local_queue_change ();
 }
 
 
--- cups-1.1.20.pristine/backend/ipp.c	2003-10-09 15:13:27.000000000 -0400
+++ cups-1.1.20/backend/ipp.c	2004-05-26 17:29:32.552605296 -0400
@@ -50,6 +50,64 @@
 #include <signal.h>
 #include <sys/wait.h>
 
+#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 (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_name,
+			      ipp_status_t status,
+			      unsigned int local_job_id,
+			      unsigned int remote_job_id,
+			      const char *username)
+{
+  DBusMessage *message;
+  DBusMessageIter iter;
+
+  if (!dbus_connection || !dbus_connection_get_is_connected (dbus_connection)) {
+    if (init_dbus () || !dbus_connection)
+      return -1;
+  }
+
+  message = dbus_message_new_signal ("/com/redhat/PrinterSpooler",
+				     "com.redhat.PrinterSpooler",
+				     "JobQueuedRemote");
+  dbus_message_append_iter_init (message, &iter);
+  dbus_message_iter_append_string (&iter, printer_name);
+  dbus_message_iter_append_string (&iter, ippErrorString (status));
+  dbus_message_iter_append_uint32 (&iter, local_job_id);
+  dbus_message_iter_append_uint32 (&iter, remote_job_id);
+  dbus_message_iter_append_string (&iter, username);
+
+  dbus_connection_send (dbus_connection, message, NULL);
+  dbus_connection_flush (dbus_connection);
+  dbus_message_unref (message);
+  
+  return 0;
+}
 
 /*
  * Globals...
@@ -692,6 +750,12 @@
       fprintf(stderr, "INFO: Print file accepted - job ID %d.\n", job_id);
     }
 
+    dbus_broadcast_queued_remote (argv[0],
+				  ipp_status,
+				  atoi (argv[1]),
+				  job_id,
+				  argv[2]);
+
     if (response)
       ippDelete(response);
 
--- cups-1.1.20.pristine/backend/Makefile	2002-12-17 13:56:33.000000000 -0500
+++ cups-1.1.20/backend/Makefile	2004-05-26 16:58:30.282713352 -0400
@@ -26,6 +26,9 @@
 
 include ../Makedefs
 
+CFLAGS += `pkg-config --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE
+DBUS_LDFLAGS += `pkg-config --libs dbus-1`
+
 BACKENDS =	ipp lpd parallel scsi serial socket usb
 TARGETS	=	betest $(BACKENDS)
 OBJS	=	betest.o ipp.o lpd.o parallel.o scsi.o serial.o socket.o usb.o
@@ -82,7 +85,7 @@
 
 ipp:	ipp.o ../cups/$(LIBCUPS)
 	echo Linking $@...
-	$(CC) $(LDFLAGS) -o ipp ipp.o $(LIBS)
+	$(CC) $(LDFLAGS) -o ipp ipp.o $(LIBS) $(DBUS_LDFLAGS)
 	$(RM) http
 	$(LN) ipp http
 
--- cups-1.1.20/scheduler/ipp.c	2004-05-26 17:21:56.141990256 -0400
+++ cups-1.1.20/scheduler/ipp.c	2004-06-01 11:46:33.160406288 -0400
@@ -5049,6 +5049,10 @@
 
   SaveJob(job->id);
 
+  dbus_broadcast_queued_local (printer->name,
+			       printer->type & CUPS_PRINTER_REMOTE ? TRUE : FALSE,
+			       job->id, job->username);
+
  /*
   * Start the job if possible...
   */
--- cups-1.1.21rc1/scheduler/cupsd.h~	2004-06-04 13:49:17.687331768 -0400
+++ cups-1.1.21rc1/scheduler/cupsd.h	2004-06-04 13:54:51.864529112 -0400
@@ -209,9 +209,11 @@
 
 extern int dbus_broadcast_local_queue_change (void);
 extern int dbus_broadcast_queued_local (const char *printer_name,
-					int is_remote,
 					unsigned int job_id,
 					const char *username);
+extern int dbus_broadcast_started_local (const char *printer_name,
+					 unsigned int job_id,
+					 const char *username);
 
 /*
  * End of "$Id: cups-dbus.patch,v 1.1 2004/07/15 17:53:58 walters Exp $".
--- cups-1.1.21rc1/scheduler/ipp.c~	2004-06-04 13:49:17.707328728 -0400
+++ cups-1.1.21rc1/scheduler/ipp.c	2004-06-04 13:55:04.537602512 -0400
@@ -5054,9 +5054,7 @@
   rename(con->filename, filename);
   ClearString(&con->filename);
 
-  dbus_broadcast_queued_local (printer->name,
-			       printer->type & CUPS_PRINTER_REMOTE ? TRUE : FALSE,
-			       job->id, job->username);
+  dbus_broadcast_queued_local (printer->name, job->id, job->username);
 
  /*
   * See if we need to add the ending sheet...
--- cups-1.1.21rc1/scheduler/job.c~	2004-06-04 13:49:17.691331160 -0400
+++ cups-1.1.21rc1/scheduler/job.c	2004-06-04 13:57:55.165663104 -0400
@@ -1931,10 +1931,16 @@
  /*
   * Finally, pipe the final output into a backend process if needed...
   */
+  sscanf(printer->device_uri, "%254[^:]", method);
+  if (strcmp(method, "ipp") != 0)
+    {
+      dbus_broadcast_started_local (printer->name,
+				    current->id,
+				    current->username);
+    }
 
-  if (strncmp(printer->device_uri, "file:", 5) != 0)
+  if (strcmp(method, "file") != 0)
   {
-    sscanf(printer->device_uri, "%254[^:]", method);
     snprintf(command, sizeof(command), "%s/backend/%s", ServerBin, method);
 
 #ifdef __APPLE__
--- cups-1.1.21rc1/scheduler/main.c~	2004-06-04 14:39:53.729783160 -0400
+++ cups-1.1.21rc1/scheduler/main.c	2004-06-04 14:42:05.509749560 -0400
@@ -127,7 +127,6 @@
 }
 
 int dbus_broadcast_queued_local (const char *printer_name,
-				 int is_remote,
 				 unsigned int job_id,
 				 const char *username)
 {
@@ -144,7 +143,6 @@
 				     "JobQueuedLocal");
   dbus_message_append_iter_init (message, &iter);
   dbus_message_iter_append_string (&iter, printer_name);
-  dbus_message_iter_append_boolean (&iter, is_remote == 0 ? FALSE : TRUE);
   dbus_message_iter_append_uint32 (&iter, job_id);
   dbus_message_iter_append_string (&iter, username);
 
@@ -155,6 +153,32 @@
   return 0;
 }
 
+int dbus_broadcast_started_local (const char *printer_name,
+				  unsigned int job_id,
+				  const char *username)
+{
+  DBusMessage *message;
+  DBusMessageIter iter;
+
+  if (!dbus_connection || !dbus_connection_get_is_connected (dbus_connection)) {
+    if (init_dbus () || !dbus_connection)
+      return -1;
+  }
+
+  message = dbus_message_new_signal ("/com/redhat/PrinterSpooler",
+				     "com.redhat.PrinterSpooler",
+				     "JobStartedLocal");
+  dbus_message_append_iter_init (message, &iter);
+  dbus_message_iter_append_string (&iter, printer_name);
+  dbus_message_iter_append_uint32 (&iter, job_id);
+  dbus_message_iter_append_string (&iter, username);
+
+  dbus_connection_send (dbus_connection, message, NULL);
+  dbus_connection_flush (dbus_connection);
+  dbus_message_unref (message);
+  
+  return 0;
+}
 /*
  * 'main()' - Main entry for the CUPS scheduler.
  */

--- End Message ---
--- Begin Message ---
Version: 1.2.1-1
tags 260246 + fixed
tags 260246 - wontfix
thanks

D-BUS support is included from CUPS 1.2 series.

Thanks,
-- 
Kenshi Muto
kmuto@debian.org

--- End Message ---

Reply to: