Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 154538 Details for
Bug 237662
CUPS D-Bus notifier
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
cups-dbus-notifier.patch
cups-dbus-notifier.patch (text/plain), 15.01 KB, created by
Tim Waugh
on 2007-05-11 13:07:40 UTC
(
hide
)
Description:
cups-dbus-notifier.patch
Filename:
MIME Type:
Creator:
Tim Waugh
Created:
2007-05-11 13:07:40 UTC
Size:
15.01 KB
patch
obsolete
>--- /dev/null 2007-05-11 09:00:11.711700397 +0100 >+++ cups-1.2.10/notifier/dbus.c 2007-05-11 14:04:52.000000000 +0100 >@@ -0,0 +1,524 @@ >+/* >+ * D-Bus notifier for the Common UNIX Printing System (CUPS). >+ * >+ * Copyright (C) 2007 Red Hat, Inc. >+ * Copyright (C) 2007 Tim Waugh <twaugh@redhat.com> >+ * Copyright 1997-2005 by Easy Software Products. >+ * >+ * These coded instructions, statements, and computer programs are the >+ * property of Easy Software Products and are protected by Federal >+ * copyright law. Distribution and use rights are outlined in the file >+ * "LICENSE.txt" which should have been included with this file. If this >+ * file is missing or damaged please contact Easy Software Products >+ * at: >+ * >+ * Attn: CUPS Licensing Information >+ * Easy Software Products >+ * 44141 Airport View Drive, Suite 204 >+ * Hollywood, Maryland 20636 USA >+ * >+ * Voice: (301) 373-9600 >+ * EMail: cups-info@cups.org >+ * WWW: http://www.cups.org >+ */ >+ >+/* >+ * D-Bus object: org.cups.cupsd.Notifier >+ * D-Bus object path: /org/cups/cupsd/Notifier >+ * >+ * D-Bus interface name: org.cups.cupsd.Notifier >+ * >+ * Signals: >+ * >+ * ServerRestarted(STRING text) >+ * Server has restarted. >+ * >+ * ServerStarted(STRING text) >+ * Server has started. >+ * >+ * ServerStopped(STRING text) >+ * Server has stopped. >+ * >+ * ServerAudit(STRING text) >+ * Security-related event. >+ * >+ * PrinterRestarted(STRING text, >+ * STRING printer-uri, >+ * STRING printer-name, >+ * UINT32 printer-state, >+ * STRING printer-state-reasons, >+ * BOOLEAN printer-is-accepting-jobs) >+ * Printer has restarted. >+ * >+ * PrinterShutdown(STRING text, >+ * STRING printer-uri, >+ * STRING printer-name, >+ * UINT32 printer-state, >+ * STRING printer-state-reasons, >+ * BOOLEAN printer-is-accepting-jobs) >+ * Printer has shutdown. >+ * >+ * PrinterStopped(STRING text, >+ * STRING printer-uri, >+ * STRING printer-name, >+ * UINT32 printer-state, >+ * STRING printer-state-reasons, >+ * BOOLEAN printer-is-accepting-jobs) >+ * Printer has stopped. >+ * >+ * PrinterStateChanged(STRING text, >+ * STRING printer-uri, >+ * STRING printer-name, >+ * UINT32 printer-state, >+ * STRING printer-state-reasons, >+ * BOOLEAN printer-is-accepting-jobs) >+ * Printer state has changed. >+ * >+ * PrinterFinishingsChanged(STRING text, >+ * STRING printer-uri, >+ * STRING printer-name, >+ * UINT32 printer-state, >+ * STRING printer-state-reasons, >+ * BOOLEAN printer-is-accepting-jobs) >+ * Printer's finishings-supported attribute has changed. >+ * >+ * PrinterMediaChanged(STRING text, >+ * STRING printer-uri, >+ * STRING printer-name, >+ * UINT32 printer-state, >+ * STRING printer-state-reasons, >+ * BOOLEAN printer-is-accepting-jobs) >+ * Printer's media-supported attribute has changed. >+ * >+ * PrinterAdded(STRING text, >+ * STRING printer-uri, >+ * STRING printer-name, >+ * UINT32 printer-state, >+ * STRING printer-state-reasons, >+ * BOOLEAN printer-is-accepting-jobs) >+ * Printer has been added. >+ * >+ * PrinterDeleted(STRING text, >+ * STRING printer-uri, >+ * STRING printer-name, >+ * UINT32 printer-state, >+ * STRING printer-state-reasons, >+ * BOOLEAN printer-is-accepting-jobs) >+ * Printer has been deleted. >+ * >+ * PrinterModified(STRING text, >+ * STRING printer-uri, >+ * STRING printer-name, >+ * UINT32 printer-state, >+ * STRING printer-state-reasons, >+ * BOOLEAN printer-is-accepting-jobs) >+ * Printer has been modified. >+ * >+ * text describes the event. >+ * printer-state-reasons is a comma-separated list. >+ * If printer-uri is "" in a Job* signal, the other printer-* parameters >+ * must be ignored. >+ * If the job name is not know, job-name will be "". >+ */ >+ >+#include <cups/cups.h> >+#include <cups/string.h> >+#include <fcntl.h> >+#include <signal.h> >+#include <sys/stat.h> >+#include <sys/types.h> >+#include <unistd.h> >+ >+#ifdef HAVE_DBUS >+# include <dbus/dbus.h> >+# ifdef HAVE_DBUS_MESSAGE_ITER_INIT_APPEND >+# define dbus_message_append_iter_init dbus_message_iter_init_append >+# define dbus_message_iter_append_string(i,v) dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, v) >+# define dbus_message_iter_append_uint32(i,v) dbus_message_iter_append_basic(i, DBUS_TYPE_UINT32, v) >+# define dbus_message_iter_append_boolean(i,v) dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, v) >+# endif /* HAVE_DBUS_MESSAGE_ITER_INIT_APPEND */ >+#endif /* HAVE_DBUS */ >+ >+#ifndef HAVE_DBUS >+int >+main(int argc, >+ char *argv[]) >+{ >+ return (1); >+} >+ >+#else /* HAVE_DBUS */ >+ >+#define LOCKFILE "/var/spool/cups/tmp/cups-dbus-notifier-lockfile" >+static int >+acquire_lock (int *fd) >+{ >+ int f; >+ int r; >+ struct flock fl; >+ >+ f = open (LOCKFILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); >+ if (f < 0) >+ { >+ /* Fail. */ >+ return (1); >+ } >+ >+ fl.l_type = F_WRLCK; >+ fl.l_whence = SEEK_SET; >+ fl.l_start = 0; >+ fl.l_len = 0; >+ r = fcntl (f, F_SETLK, &fl); >+ if (r == 0) >+ *fd = f; >+ else >+ close (f); >+ >+ return r; >+} >+ >+int >+main(int argc, >+ char *argv[]) >+{ >+ ipp_t *msg = NULL; /* Event message from scheduler */ >+ ipp_state_t state; /* IPP event state */ >+#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) >+ struct sigaction action; /* POSIX sigaction data */ >+#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ >+ DBusConnection *con = NULL; /* Connection to DBUS server */ >+ DBusError error; /* Error, if any */ >+ DBusMessage *message; /* Message to send */ >+ DBusMessageIter iter; /* Iterator for message data */ >+ int lock_fd = -1; /* Lock file descriptor */ >+ >+ /* >+ * Don't buffer stderr... >+ */ >+ >+ setbuf(stderr, NULL); >+ >+ /* >+ * Ignore SIGPIPE signals... >+ */ >+ >+#ifdef HAVE_SIGSET >+ sigset(SIGPIPE, SIG_IGN); >+#elif defined(HAVE_SIGACTION) >+ memset(&action, 0, sizeof(action)); >+ action.sa_handler = SIG_IGN; >+ sigaction(SIGPIPE, &action, NULL); >+#else >+ signal(SIGPIPE, SIG_IGN); >+#endif /* HAVE_SIGSET */ >+ >+ /* >+ * Validate command-line options... >+ */ >+ >+ if (argc != 3) >+ { >+ fputs("Usage: dbus dbus: notify-user-data\n", stderr); >+ return (1); >+ } >+ >+ if (strcmp(argv[1], "dbus:")) >+ { >+ fprintf(stderr, "ERROR: Bad URI \"%s\"!\n", argv[1]); >+ return (1); >+ } >+ >+ /* >+ * Loop forever until we run out of events... >+ */ >+ >+ for (;;) >+ { >+ ipp_attribute_t *attr; >+ const char *event; >+ const char *signame = NULL; >+ char *printer_reasons = NULL; >+ const char *nul = ""; >+ int no = 0; >+ enum { >+ PARAMS_NONE, >+ PARAMS_PRINTER, >+ PARAMS_JOB >+ } params = PARAMS_NONE; >+ >+ /* >+ * Free the memory used for the last event... >+ */ >+ >+ if (msg) >+ ippDelete(msg); >+ >+ /* >+ * Get the next event... >+ */ >+ >+ msg = ippNew(); >+ while ((state = ippReadFile(0, msg)) != IPP_DATA) >+ { >+ if (state <= IPP_IDLE) >+ break; >+ } >+ >+ fprintf(stderr, "DEBUG: state=%d\n", state); >+ >+ if (state == IPP_ERROR) >+ fputs("DEBUG: ippReadFile() returned IPP_ERROR!\n", stderr); >+ >+ if (state <= IPP_IDLE) >+ { >+ /* >+ * Out of messages, free memory and then exit... >+ */ >+ >+ ippDelete(msg); >+ return (0); >+ } >+ >+ /* >+ * Verify connection to DBUS server... >+ */ >+ if (con && !dbus_connection_get_is_connected(con)) >+ { >+ dbus_connection_unref(con); >+ con = NULL; >+ } >+ >+ if (!con) >+ { >+ dbus_error_init(&error); >+ >+ con = dbus_bus_get(DBUS_BUS_SYSTEM, &error); >+ if (!con) >+ { >+ dbus_error_free (&error); >+ } >+ else >+ fprintf(stderr, "DEBUG: connected to D-BUS\n", state); >+ } >+ >+ if (!con) >+ continue; >+ >+ if (lock_fd == -1 && >+ acquire_lock (&lock_fd)) >+ continue; >+ >+ attr = ippFindAttribute (msg, "notify-subscribed-event", >+ IPP_TAG_KEYWORD); >+ if (!attr) >+ continue; >+ >+ event = attr->values[0].string.text; >+ if (!strncmp (event, "server-", 7)) >+ { >+ const char *word2 = event + 7; >+ if (!strcmp (word2, "restarted")) >+ signame = "ServerRestarted"; >+ else if (!strcmp (word2, "started")) >+ signame = "ServerStarted"; >+ else if (!strcmp (word2, "stopped")) >+ signame = "ServerStopped"; >+ else if (!strcmp (word2, "audit")) >+ signame = "ServerAudit"; >+ else >+ continue; >+ } >+ else if (!strncmp (event, "printer-", 8)) >+ { >+ const char *word2 = event + 8; >+ params = PARAMS_PRINTER; >+ if (!strcmp (word2, "restarted")) >+ signame = "PrinterRestarted"; >+ else if (!strcmp (word2, "shutdown")) >+ signame = "PrinterShutdown"; >+ else if (!strcmp (word2, "stopped")) >+ signame = "PrinterStopped"; >+ else if (!strcmp (word2, "state-changed")) >+ signame = "PrinterStateChanged"; >+ else if (!strcmp (word2, "finishings-changed")) >+ signame = "PrinterFinishingsChanged"; >+ else if (!strcmp (word2, "media-changed")) >+ signame = "PrinterMediaChanged"; >+ else if (!strcmp (word2, "added")) >+ signame = "PrinterAdded"; >+ else if (!strcmp (word2, "deleted")) >+ signame = "PrinterDeleted"; >+ else if (!strcmp (word2, "modified")) >+ signame = "PrinterModified"; >+ else >+ continue; >+ } >+ else if (!strncmp (event, "job-", 4)) >+ { >+ const char *word2 = event + 4; >+ params = PARAMS_JOB; >+ if (!strcmp (word2, "state")) >+ signame = "JobState"; >+ else if (!strcmp (word2, "created")) >+ signame = "JobCreated"; >+ else if (!strcmp (word2, "completed")) >+ signame = "JobCompleted"; >+ else if (!strcmp (word2, "stopped")) >+ signame = "JobStopped"; >+ else if (!strcmp (word2, "config-changed")) >+ signame = "JobConfigChanged"; >+ else if (!strcmp (word2, "progress")) >+ signame = "JobProgress"; >+ else >+ continue; >+ } >+ else >+ continue; >+ >+ /* >+ * Create and send the new message... >+ */ >+ >+ fprintf(stderr, "DEBUG: %s\n", signame); >+ message = dbus_message_new_signal("/org/cups/cupsd/Notifier", >+ "org.cups.cupsd.Notifier", >+ signame); >+ >+ dbus_message_append_iter_init(message, &iter); >+ attr = ippFindAttribute (msg, "notify-text", IPP_TAG_TEXT); >+ if (!attr) >+ goto bail; >+ dbus_message_iter_append_string(&iter, &(attr->values[0].string.text)); >+ >+ if (params >= PARAMS_PRINTER) >+ { >+ char *p; >+ size_t reasons_length; >+ int i; >+ int have_printer_params = 1; >+ >+ /* STRING printer-uri or "" */ >+ attr = ippFindAttribute (msg, "notify-printer-uri", IPP_TAG_URI); >+ if (attr) >+ dbus_message_iter_append_string(&iter, &(attr->values[0].string.text)); >+ else >+ { >+ have_printer_params = 0; >+ dbus_message_iter_append_string(&iter, &nul); >+ } >+ >+ /* STRING printer-name */ >+ if (have_printer_params) >+ { >+ attr = ippFindAttribute (msg, "printer-name", IPP_TAG_NAME); >+ if (attr) >+ dbus_message_iter_append_string(&iter, >+ &(attr->values[0].string.text)); >+ else >+ goto bail; >+ } >+ else >+ dbus_message_iter_append_string(&iter, &nul); >+ >+ /* UINT32 printer-state */ >+ if (have_printer_params) >+ { >+ attr = ippFindAttribute (msg, "printer-state", IPP_TAG_ENUM); >+ if (attr) >+ dbus_message_iter_append_uint32(&iter, &(attr->values[0].integer)); >+ else >+ goto bail; >+ } >+ else >+ dbus_message_iter_append_uint32(&iter, &no); >+ >+ /* STRING printer-state-reasons */ >+ if (have_printer_params) >+ { >+ attr = ippFindAttribute (msg, "printer-state-reasons", >+ IPP_TAG_KEYWORD); >+ if (attr) >+ { >+ for (reasons_length = 0, i = 0; i < attr->num_values; i++) >+ /* All need commas except the last, which needs a nul byte. */ >+ reasons_length += 1 + strlen (attr->values[i].string.text); >+ printer_reasons = malloc (reasons_length); >+ if (printer_reasons == NULL) >+ goto bail; >+ p = printer_reasons; >+ for (i = 0; i < attr->num_values; i++) >+ { >+ reasons_length = strlen (attr->values[i].string.text); >+ strcpy (p, attr->values[i].string.text); >+ p += reasons_length; >+ if (i) >+ *p++ = ','; >+ } >+ dbus_message_iter_append_string(&iter, &printer_reasons); >+ } >+ else >+ goto bail; >+ } >+ else >+ dbus_message_iter_append_string(&iter, &nul); >+ >+ /* BOOL printer-is-accepting-jobs */ >+ if (have_printer_params) >+ { >+ attr = ippFindAttribute (msg, "printer-is-accepting-jobs", >+ IPP_TAG_BOOLEAN); >+ if (attr) >+ dbus_message_iter_append_boolean(&iter, &(attr->values[0].boolean)); >+ else >+ goto bail; >+ } >+ else >+ dbus_message_iter_append_boolean(&iter, &no); >+ } >+ >+ if (params >= PARAMS_JOB) >+ { >+ /* UINT32 job-id */ >+ attr = ippFindAttribute (msg, "notify-job-id", IPP_TAG_INTEGER); >+ if (!attr) >+ goto bail; >+ dbus_message_iter_append_uint32(&iter, &(attr->values[0].integer)); >+ >+ /* UINT32 job-state */ >+ attr = ippFindAttribute (msg, "job-state", IPP_TAG_ENUM); >+ if (!attr) >+ goto bail; >+ dbus_message_iter_append_uint32(&iter, &(attr->values[0].integer)); >+ >+ /* STRING job-state-reasons */ >+ attr = ippFindAttribute (msg, "job-state-reasons", IPP_TAG_KEYWORD); >+ if (!attr) >+ goto bail; >+ dbus_message_iter_append_string(&iter, &(attr->values[0].string.text)); >+ >+ /* STRING job-name or "" */ >+ attr = ippFindAttribute (msg, "job-name", IPP_TAG_NAME); >+ if (attr) >+ dbus_message_iter_append_string(&iter, &(attr->values[0].string.text)); >+ else >+ dbus_message_iter_append_string(&iter, &nul); >+ >+ /* UINT32 job-impressions-completed */ >+ attr = ippFindAttribute (msg, "job-impressions-completed", >+ IPP_TAG_INTEGER); >+ if (!attr) >+ goto bail; >+ dbus_message_iter_append_uint32(&iter, &(attr->values[0].integer)); >+ } >+ >+ dbus_connection_send(con, message, NULL); >+ dbus_connection_flush(con); >+ >+ bail: >+ if (printer_reasons) >+ free (printer_reasons); >+ dbus_message_unref(message); >+ } >+} >+ >+#endif /* HAVE_DBUS */ >--- cups-1.2.10/notifier/Makefile.dbus-notifier 2006-03-05 16:48:12.000000000 +0000 >+++ cups-1.2.10/notifier/Makefile 2007-05-11 14:03:53.000000000 +0100 >@@ -25,8 +25,8 @@ > include ../Makedefs > > >-TARGETS = mailto testnotify >-OBJS = mailto.o testnotify.o >+TARGETS = mailto testnotify dbus >+OBJS = mailto.o testnotify.o dbus.o > > > # >@@ -85,6 +85,21 @@ > > > # >+# dbus >+# >+ >+dbus.h: dbus-notifier.xml >+ dbus-binding-tool --mode=glib-server $< >$@ >+ >+dbus.o: CFLAGS += `pkg-config glib-2.0 --cflags` >+dbus.o: dbus.h >+ >+dbus: dbus.o ../cups/$(LIBCUPS) >+ echo Linking $@... >+ $(CC) $(LDFLAGS) -o dbus dbus.o $(LIBS) $(DBUSLIBS) `pkg-config glib-2.0 --libs` `pkg-config dbus-glib-1 --libs` >+ >+ >+# > # testnotify > # >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 237662
:
153536
|
153613
|
153707
| 154538