2011-10-03 11:30:59 +00:00
|
|
|
From db29c24e3ff75938775aa1f4072e346aeb7f6a9c Mon Sep 17 00:00:00 2001
|
2011-05-31 16:25:38 +00:00
|
|
|
From: Richard Hughes <richard@hughsie.com>
|
|
|
|
Date: Tue, 1 Mar 2011 16:05:48 +0000
|
|
|
|
Subject: [PATCH] Add colord support to CUPS which allows Linux printers to be
|
|
|
|
color managed
|
|
|
|
|
2011-06-04 15:13:25 +00:00
|
|
|
This functionality is possible because of lots of help from Tim Waugh -- thanks!
|
2011-05-31 16:25:38 +00:00
|
|
|
---
|
|
|
|
scheduler/Makefile | 1 +
|
2011-10-03 11:30:59 +00:00
|
|
|
scheduler/colord.c | 784 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
scheduler/colord.h | 41 +++
|
|
|
|
scheduler/ipp.c | 18 +-
|
2011-05-31 16:25:38 +00:00
|
|
|
scheduler/printers.c | 69 +++++
|
|
|
|
scheduler/printers.h | 4 +
|
2011-10-03 11:30:59 +00:00
|
|
|
6 files changed, 914 insertions(+), 3 deletions(-)
|
2011-05-31 16:25:38 +00:00
|
|
|
create mode 100644 scheduler/colord.c
|
|
|
|
create mode 100644 scheduler/colord.h
|
|
|
|
|
|
|
|
diff --git a/scheduler/Makefile b/scheduler/Makefile
|
|
|
|
index 3c7da8e..b9c47d3 100644
|
2011-03-07 13:40:36 +00:00
|
|
|
--- a/scheduler/Makefile
|
|
|
|
+++ b/scheduler/Makefile
|
2011-05-31 16:25:38 +00:00
|
|
|
@@ -27,6 +27,7 @@ CUPSDOBJS = \
|
|
|
|
file.o \
|
2011-03-07 13:40:36 +00:00
|
|
|
main.o \
|
|
|
|
ipp.o \
|
|
|
|
+ colord.o \
|
|
|
|
listen.o \
|
|
|
|
job.o \
|
|
|
|
log.o \
|
2011-05-31 16:25:38 +00:00
|
|
|
diff --git a/scheduler/colord.c b/scheduler/colord.c
|
|
|
|
new file mode 100644
|
2011-10-03 11:30:59 +00:00
|
|
|
index 0000000..bd06e1c
|
2011-05-31 16:25:38 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/scheduler/colord.c
|
2011-10-03 11:30:59 +00:00
|
|
|
@@ -0,0 +1,784 @@
|
2011-03-07 13:40:36 +00:00
|
|
|
+/*
|
|
|
|
+ * "$Id$"
|
|
|
|
+ *
|
|
|
|
+ * colord integration for the CUPS scheduler.
|
|
|
|
+ *
|
2011-10-03 11:30:59 +00:00
|
|
|
+ * Copyright 2011 Red Hat, Inc.
|
2011-03-07 13:40:36 +00:00
|
|
|
+ *
|
2011-10-03 11:30:59 +00:00
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
|
+ * modification, are permitted provided that the following conditions
|
|
|
|
+ * are met:
|
|
|
|
+ *
|
|
|
|
+ * Redistributions of source code must retain the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer.
|
|
|
|
+ *
|
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
|
+ *
|
|
|
|
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
|
|
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
|
|
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
|
2011-03-07 13:40:36 +00:00
|
|
|
+ *
|
|
|
|
+ * Contents:
|
|
|
|
+ *
|
|
|
|
+ * colordRegisterPrinter() - Register profiles for a printer.
|
|
|
|
+ * colordUnregisterPrinter() - Unregister profiles for a printer.
|
|
|
|
+ * colordStart() - Get a connection to the system bus.
|
|
|
|
+ * colordStop() - Release any connection to the system bus
|
|
|
|
+ * so that added profiles and devices are
|
|
|
|
+ * automatically removed.
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+/*
|
|
|
|
+ * Include necessary headers...
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+#include "cupsd.h"
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+#ifdef HAVE_DBUS
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+#include <dbus/dbus.h>
|
|
|
|
+#include <cups/ppd-private.h>
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+/*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * Defines used by colord. See the reference docs for further details:
|
|
|
|
+ * http://colord.hughsie.com/api/ref-dbus.html
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
2011-03-07 13:40:36 +00:00
|
|
|
+#define COLORD_SCOPE_NORMAL "normal" /* System scope */
|
|
|
|
+#define COLORD_SCOPE_TEMP "temp" /* Process scope */
|
|
|
|
+#define COLORD_SCOPE_DISK "disk" /* Lives forever, as stored in DB */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+#define COLORD_RELATION_SOFT "soft" /* Mapping is not default */
|
|
|
|
+#define COLORD_RELATION_HARD "hard" /* Explicitly mapped profile */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+#define COLORD_SPACE_RGB "rgb" /* RGB colorspace */
|
|
|
|
+#define COLORD_SPACE_CMYK "cmyk" /* CMYK colorspace */
|
2011-05-17 08:43:15 +00:00
|
|
|
+#define COLORD_SPACE_GRAY "gray" /* Gray colorspace */
|
2011-05-19 08:27:39 +00:00
|
|
|
+#define COLORD_SPACE_UNKNOWN "unknown" /* Unknown colorspace */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+#define COLORD_MODE_PHYSICAL "physical" /* Actual device */
|
|
|
|
+#define COLORD_MODE_VIRTUAL "virtual" /* Virtual device with no hardware */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+#define COLORD_KIND_PRINTER "printer" /* printing output device */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-05-17 08:43:15 +00:00
|
|
|
+/* the timeout for connecting to colord */
|
|
|
|
+#define COLORD_DBUS_TIMEOUT 5000 /* ms */
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+/* This is static */
|
|
|
|
+static DBusConnection *con = NULL;
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+/*
|
|
|
|
+ * 'colordStart()' - Get a connection to the system bus.
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+void
|
|
|
|
+colordStart(void)
|
|
|
|
+{
|
|
|
|
+ if (con)
|
|
|
|
+ return;
|
|
|
|
+ con = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
|
2011-01-06 16:21:12 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * 'colordStop()' - Release any connection to the system bus so that
|
|
|
|
+ * added profiles and devices are automatically removed.
|
2011-01-12 16:14:35 +00:00
|
|
|
+ */
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+void
|
|
|
|
+colordStop(void)
|
|
|
|
+{
|
|
|
|
+ if (con == NULL)
|
|
|
|
+ return;
|
|
|
|
+ dbus_connection_unref(con);
|
|
|
|
+ con = NULL;
|
2011-01-12 16:14:35 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * 'message_dict_add_strings()' - add two strings to a dictionary.
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
2011-03-07 13:40:36 +00:00
|
|
|
+
|
2011-01-12 16:14:35 +00:00
|
|
|
+static void
|
2011-03-07 13:40:36 +00:00
|
|
|
+message_dict_add_strings (DBusMessageIter *dict,
|
|
|
|
+ const char *key,
|
|
|
|
+ const char *value)
|
2011-01-12 16:14:35 +00:00
|
|
|
+{
|
2011-03-07 13:40:36 +00:00
|
|
|
+ DBusMessageIter entry;
|
|
|
|
+ dbus_message_iter_open_container(dict,
|
|
|
|
+ DBUS_TYPE_DICT_ENTRY,
|
|
|
|
+ NULL,
|
|
|
|
+ &entry);
|
|
|
|
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
|
|
|
|
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &value);
|
|
|
|
+ dbus_message_iter_close_container(dict, &entry);
|
2011-01-12 16:14:35 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * 'colordCreateProfile()' - Create a color profile for a printer.
|
|
|
|
+ *
|
|
|
|
+ * Notes: When creating the device, we can create
|
2011-01-12 16:14:35 +00:00
|
|
|
+ */
|
2011-03-07 13:40:36 +00:00
|
|
|
+
|
2011-01-06 16:21:12 +00:00
|
|
|
+static void
|
2011-03-07 13:40:36 +00:00
|
|
|
+colordCreateProfile (cups_array_t *profiles, /* I - Profiles array */
|
|
|
|
+ const char *printer_name, /* I - Printer name */
|
|
|
|
+ const char *qualifier, /* I - Profile qualifier */
|
2011-05-19 08:27:39 +00:00
|
|
|
+ const char *colorspace, /* I - Profile colorspace */
|
2011-03-07 13:40:36 +00:00
|
|
|
+ const char **format, /* I - Profile qualifier format */
|
|
|
|
+ const char *iccfile, /* I - ICC filename */
|
|
|
|
+ const char *scope) /* I - The scope of the profile, e.g.
|
|
|
|
+ 'normal', 'temp' or 'disk' */
|
2011-01-06 16:21:12 +00:00
|
|
|
+{
|
2011-03-07 13:40:36 +00:00
|
|
|
+ DBusMessage *message = NULL; /* D-Bus request */
|
|
|
|
+ DBusMessage *reply = NULL; /* D-Bus reply */
|
|
|
|
+ DBusMessageIter args; /* D-Bus method arguments */
|
|
|
|
+ DBusMessageIter dict; /* D-Bus method arguments */
|
|
|
|
+ DBusError error; /* D-Bus error */
|
|
|
|
+ char *idstr; /* Profile ID string */
|
|
|
|
+ size_t idstrlen; /* Profile ID allocated length */
|
|
|
|
+ const char *profile_path; /* Device object path */
|
|
|
|
+ char format_str[1024]; /* Qualifier format as a string */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Create the profile...
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ message = dbus_message_new_method_call("org.freedesktop.ColorManager",
|
2011-03-07 13:40:36 +00:00
|
|
|
+ "/org/freedesktop/ColorManager",
|
|
|
|
+ "org.freedesktop.ColorManager",
|
|
|
|
+ "CreateProfile");
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /* create a profile id */
|
2011-01-06 16:21:12 +00:00
|
|
|
+ idstrlen = strlen (printer_name) + 1 + strlen (qualifier) + 1;
|
|
|
|
+ idstr = malloc (idstrlen);
|
|
|
|
+ if (!idstr)
|
|
|
|
+ goto out;
|
|
|
|
+ snprintf (idstr, idstrlen, "%s-%s", printer_name, qualifier);
|
2011-03-07 13:40:36 +00:00
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Using profile id of %s",
|
|
|
|
+ idstr);
|
|
|
|
+
|
|
|
|
+ dbus_message_iter_init_append(message, &args);
|
|
|
|
+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &idstr);
|
|
|
|
+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &scope);
|
|
|
|
+
|
|
|
|
+ /* mush the qualifier format into a simple string */
|
|
|
|
+ snprintf(format_str, sizeof(format_str), "%s.%s.%s",
|
|
|
|
+ format[0],
|
|
|
|
+ format[1],
|
|
|
|
+ format[2]);
|
|
|
|
+
|
|
|
|
+ /* set initial properties */
|
|
|
|
+ dbus_message_iter_open_container(&args,
|
|
|
|
+ DBUS_TYPE_ARRAY,
|
|
|
|
+ "{ss}",
|
|
|
|
+ &dict);
|
|
|
|
+ message_dict_add_strings(&dict, "Qualifier", qualifier);
|
|
|
|
+ message_dict_add_strings(&dict, "Format", format_str);
|
2011-05-19 08:27:39 +00:00
|
|
|
+ message_dict_add_strings(&dict, "Colorspace", colorspace);
|
2011-03-07 13:40:36 +00:00
|
|
|
+ if (iccfile != NULL)
|
|
|
|
+ message_dict_add_strings(&dict, "Filename", iccfile);
|
|
|
|
+ dbus_message_iter_close_container(&args, &dict);
|
|
|
|
+
|
|
|
|
+ /* send syncronous */
|
|
|
|
+ dbus_error_init(&error);
|
2011-05-17 08:43:15 +00:00
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling CreateProfile(%s,%s)",
|
|
|
|
+ idstr, scope);
|
2011-03-07 13:40:36 +00:00
|
|
|
+ reply = dbus_connection_send_with_reply_and_block(con,
|
|
|
|
+ message,
|
2011-05-17 08:43:15 +00:00
|
|
|
+ COLORD_DBUS_TIMEOUT,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ &error);
|
|
|
|
+ if (reply == NULL)
|
|
|
|
+ {
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_WARN,
|
|
|
|
+ "failed to CreateProfile: %s:%s",
|
|
|
|
+ error.name, error.message);
|
|
|
|
+ dbus_error_free(&error);
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /* get reply data */
|
|
|
|
+ dbus_message_iter_init(reply, &args);
|
|
|
|
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
|
|
|
|
+ {
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_WARN,
|
|
|
|
+ "incorrect reply type");
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+ dbus_message_iter_get_basic(&args, &profile_path);
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
|
|
|
|
+ "created profile %s",
|
|
|
|
+ profile_path);
|
|
|
|
+ cupsArrayAdd(profiles, strdup(profile_path));
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+out:
|
2011-03-07 13:40:36 +00:00
|
|
|
+ if (message != NULL)
|
|
|
|
+ dbus_message_unref(message);
|
|
|
|
+ if (reply != NULL)
|
|
|
|
+ dbus_message_unref(reply);
|
2011-01-06 16:21:12 +00:00
|
|
|
+ free (idstr);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * 'colordDeviceAddProfile()' - Assign a profile to a device.
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+static void
|
2011-03-07 13:40:36 +00:00
|
|
|
+colordDeviceAddProfile (const char *device_path, /* I - Device object path */
|
|
|
|
+ const char *profile_path, /* I - Profile object path */
|
|
|
|
+ const char *relation) /* I - Device relation, either 'soft' or 'hard' */
|
2011-01-06 16:21:12 +00:00
|
|
|
+{
|
2011-03-07 13:40:36 +00:00
|
|
|
+ DBusMessage *message = NULL; /* D-Bus request */
|
|
|
|
+ DBusMessage *reply = NULL; /* D-Bus reply */
|
|
|
|
+ DBusMessageIter args; /* D-Bus method arguments */
|
|
|
|
+ DBusError error; /* D-Bus error */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+ message = dbus_message_new_method_call("org.freedesktop.ColorManager",
|
2011-03-07 13:40:36 +00:00
|
|
|
+ device_path,
|
|
|
|
+ "org.freedesktop.ColorManager.Device",
|
|
|
|
+ "AddProfile");
|
|
|
|
+
|
|
|
|
+ /* send profile path as the argument */
|
|
|
|
+ dbus_message_iter_init_append(message, &args);
|
|
|
|
+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &relation);
|
|
|
|
+ dbus_message_iter_append_basic(&args, DBUS_TYPE_OBJECT_PATH, &profile_path);
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
|
|
|
|
+ "Calling %s:AddProfile(%s) [%s]",
|
|
|
|
+ device_path, profile_path, relation);
|
|
|
|
+
|
|
|
|
+ /* send syncronous */
|
|
|
|
+ dbus_error_init(&error);
|
|
|
|
+ reply = dbus_connection_send_with_reply_and_block(con,
|
|
|
|
+ message,
|
2011-05-17 08:43:15 +00:00
|
|
|
+ COLORD_DBUS_TIMEOUT,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ &error);
|
|
|
|
+ if (reply == NULL)
|
2011-01-06 16:21:12 +00:00
|
|
|
+ {
|
2011-03-07 13:40:36 +00:00
|
|
|
+ cupsdLogMessage(CUPSD_LOG_WARN,
|
|
|
|
+ "failed to AddProfile: %s:%s",
|
|
|
|
+ error.name, error.message);
|
|
|
|
+ dbus_error_free(&error);
|
|
|
|
+ goto out;
|
2011-01-06 16:21:12 +00:00
|
|
|
+ }
|
2011-03-07 13:40:36 +00:00
|
|
|
+out:
|
|
|
|
+ if (message != NULL)
|
|
|
|
+ dbus_message_unref(message);
|
|
|
|
+ if (reply != NULL)
|
|
|
|
+ dbus_message_unref(reply);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * 'colordCreateDevice()' - Create a device and register profiles.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+static void
|
|
|
|
+colordCreateDevice (cupsd_printer_t *p, /* I - Printer */
|
2011-05-17 08:43:15 +00:00
|
|
|
+ ppd_file_t *ppd, /* I - PPD file */
|
2011-03-07 13:40:36 +00:00
|
|
|
+ cups_array_t *profiles, /* I - Profiles array */
|
|
|
|
+ const char *colorspace, /* I - Device colorspace, e.g. 'rgb' */
|
2011-10-03 11:30:59 +00:00
|
|
|
+ char **format, /* I - Device qualifier format */
|
2011-03-07 13:40:36 +00:00
|
|
|
+ const char *relation, /* I - Profile relation, either 'soft' or 'hard' */
|
|
|
|
+ const char *scope) /* I - The scope of the device, e.g.
|
|
|
|
+ 'normal', 'temp' or 'disk' */
|
|
|
|
+{
|
|
|
|
+ DBusMessage *message = NULL; /* D-Bus request */
|
|
|
|
+ DBusMessage *reply = NULL; /* D-Bus reply */
|
|
|
|
+ DBusMessageIter args; /* D-Bus method arguments */
|
|
|
|
+ DBusMessageIter dict; /* D-Bus method arguments */
|
|
|
|
+ DBusError error; /* D-Bus error */
|
|
|
|
+ const char *device_path; /* Device object path */
|
|
|
|
+ const char *profile_path; /* Profile path */
|
|
|
|
+ char *default_profile_path = NULL;
|
|
|
|
+ /* Default profile path */
|
|
|
|
+ char device_id[1024]; /* Device ID as understood by colord */
|
2011-10-03 11:30:59 +00:00
|
|
|
+ char format_str[1024]; /* Qualifier format as a string */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+ /*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * Create the device...
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ snprintf(device_id, sizeof(device_id), "cups-%s", p->name);
|
|
|
|
+ device_path = device_id;
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ message = dbus_message_new_method_call("org.freedesktop.ColorManager",
|
|
|
|
+ "/org/freedesktop/ColorManager",
|
|
|
|
+ "org.freedesktop.ColorManager",
|
|
|
|
+ "CreateDevice");
|
|
|
|
+
|
|
|
|
+ dbus_message_iter_init_append(message, &args);
|
|
|
|
+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &device_path);
|
|
|
|
+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &scope);
|
|
|
|
+
|
2011-10-03 11:30:59 +00:00
|
|
|
+ /* mush the qualifier format into a simple string */
|
|
|
|
+ snprintf(format_str, sizeof(format_str), "%s.%s.%s",
|
|
|
|
+ format[0],
|
|
|
|
+ format[1],
|
|
|
|
+ format[2]);
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /* set initial properties */
|
|
|
|
+ dbus_message_iter_open_container(&args,
|
|
|
|
+ DBUS_TYPE_ARRAY,
|
|
|
|
+ "{ss}",
|
|
|
|
+ &dict);
|
|
|
|
+ message_dict_add_strings(&dict, "Colorspace", colorspace);
|
|
|
|
+ message_dict_add_strings(&dict, "Mode", COLORD_MODE_PHYSICAL);
|
2011-05-17 08:43:15 +00:00
|
|
|
+ if (ppd->manufacturer != NULL)
|
|
|
|
+ message_dict_add_strings(&dict, "Vendor", ppd->manufacturer);
|
|
|
|
+ if (ppd->modelname != NULL)
|
|
|
|
+ message_dict_add_strings(&dict, "Model", ppd->modelname);
|
2011-03-07 13:40:36 +00:00
|
|
|
+ if (p->sanitized_device_uri != NULL)
|
|
|
|
+ message_dict_add_strings(&dict, "Serial", p->sanitized_device_uri);
|
2011-10-03 11:30:59 +00:00
|
|
|
+ message_dict_add_strings(&dict, "Format", format_str);
|
2011-03-07 13:40:36 +00:00
|
|
|
+ message_dict_add_strings(&dict, "Kind", COLORD_KIND_PRINTER);
|
|
|
|
+ dbus_message_iter_close_container(&args, &dict);
|
|
|
|
+
|
|
|
|
+ /* send syncronous */
|
|
|
|
+ dbus_error_init(&error);
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling CreateDevice(%s,%s)",
|
|
|
|
+ device_id, scope);
|
|
|
|
+ reply = dbus_connection_send_with_reply_and_block(con,
|
|
|
|
+ message,
|
2011-05-17 08:43:15 +00:00
|
|
|
+ COLORD_DBUS_TIMEOUT,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ &error);
|
|
|
|
+ if (reply == NULL)
|
|
|
|
+ {
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_WARN,
|
|
|
|
+ "failed to CreateDevice: %s:%s",
|
|
|
|
+ error.name, error.message);
|
|
|
|
+ dbus_error_free(&error);
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /* get reply data */
|
|
|
|
+ dbus_message_iter_init(reply, &args);
|
|
|
|
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
|
|
|
|
+ {
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_WARN,
|
|
|
|
+ "incorrect reply type");
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+ dbus_message_iter_get_basic(&args, &device_path);
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
|
|
|
|
+ "created device %s",
|
|
|
|
+ device_path);
|
2011-01-12 16:14:35 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /* add profiles */
|
|
|
|
+ for (profile_path = cupsArrayFirst(profiles);
|
|
|
|
+ profile_path;
|
|
|
|
+ profile_path = cupsArrayNext(profiles))
|
|
|
|
+ {
|
|
|
|
+ colordDeviceAddProfile (device_path, profile_path, relation);
|
|
|
|
+ }
|
2011-01-12 16:14:35 +00:00
|
|
|
+
|
2011-01-06 16:21:12 +00:00
|
|
|
+out:
|
|
|
|
+ free(default_profile_path);
|
2011-03-07 13:40:36 +00:00
|
|
|
+ if (message != NULL)
|
|
|
|
+ dbus_message_unref(message);
|
|
|
|
+ if (reply != NULL)
|
|
|
|
+ dbus_message_unref(reply);
|
2011-01-06 16:21:12 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
2011-10-03 11:30:59 +00:00
|
|
|
+ * 'colordFindDeviceById()' - Finds a device
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+static char *
|
|
|
|
+colordFindDeviceById (const char *device_id) /* I - Device ID string */
|
|
|
|
+{
|
|
|
|
+ DBusMessage *message = NULL; /* D-Bus request */
|
|
|
|
+ DBusMessage *reply = NULL; /* D-Bus reply */
|
|
|
|
+ DBusMessageIter args; /* D-Bus method arguments */
|
|
|
|
+ DBusError error; /* D-Bus error */
|
|
|
|
+ const char *device_path_tmp; /* Device object path */
|
|
|
|
+ char *device_path = NULL; /* Device object path */
|
|
|
|
+
|
|
|
|
+ message = dbus_message_new_method_call("org.freedesktop.ColorManager",
|
|
|
|
+ "/org/freedesktop/ColorManager",
|
|
|
|
+ "org.freedesktop.ColorManager",
|
|
|
|
+ "FindDeviceById");
|
|
|
|
+
|
|
|
|
+ dbus_message_iter_init_append(message, &args);
|
|
|
|
+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &device_id);
|
|
|
|
+
|
|
|
|
+ /* send syncronous */
|
|
|
|
+ dbus_error_init(&error);
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling FindDeviceById(%s)", device_id);
|
|
|
|
+ reply = dbus_connection_send_with_reply_and_block(con,
|
|
|
|
+ message,
|
|
|
|
+ COLORD_DBUS_TIMEOUT,
|
|
|
|
+ &error);
|
|
|
|
+ if (reply == NULL)
|
|
|
|
+ {
|
|
|
|
+ /* this can happen normally on start-up */
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
|
|
|
|
+ "failed to DeleteDevice: %s:%s",
|
|
|
|
+ error.name, error.message);
|
|
|
|
+ dbus_error_free(&error);
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* get reply data */
|
|
|
|
+ dbus_message_iter_init(reply, &args);
|
|
|
|
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
|
|
|
|
+ {
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_WARN,
|
|
|
|
+ "incorrect reply type");
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+ dbus_message_iter_get_basic(&args, &device_path_tmp);
|
|
|
|
+ if (device_path_tmp != NULL)
|
|
|
|
+ device_path = strdup (device_path_tmp);
|
|
|
|
+out:
|
|
|
|
+ if (message != NULL)
|
|
|
|
+ dbus_message_unref(message);
|
|
|
|
+ if (reply != NULL)
|
|
|
|
+ dbus_message_unref(reply);
|
|
|
|
+ return device_path;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * 'colordDeleteDevice()' - Delete a device
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+static void
|
2011-03-07 13:40:36 +00:00
|
|
|
+colordDeleteDevice (const char *device_id) /* I - Device ID string */
|
2011-01-06 16:21:12 +00:00
|
|
|
+{
|
2011-03-07 13:40:36 +00:00
|
|
|
+ DBusMessage *message = NULL; /* D-Bus request */
|
|
|
|
+ DBusMessage *reply = NULL; /* D-Bus reply */
|
|
|
|
+ DBusMessageIter args; /* D-Bus method arguments */
|
|
|
|
+ DBusError error; /* D-Bus error */
|
2011-10-03 11:30:59 +00:00
|
|
|
+ char *device_path; /* Device object path */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+ /*
|
2011-10-03 11:30:59 +00:00
|
|
|
+ * Find the device...
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ device_path = colordFindDeviceById (device_id);
|
|
|
|
+ if (device_path == NULL)
|
|
|
|
+ {
|
|
|
|
+ /* this can happen normally on start-up */
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_WARN,
|
|
|
|
+ "failed to find device: %s",
|
|
|
|
+ device_id);
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Delete the device...
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ message = dbus_message_new_method_call("org.freedesktop.ColorManager",
|
2011-03-07 13:40:36 +00:00
|
|
|
+ "/org/freedesktop/ColorManager",
|
|
|
|
+ "org.freedesktop.ColorManager",
|
|
|
|
+ "DeleteDevice");
|
|
|
|
+
|
|
|
|
+ dbus_message_iter_init_append(message, &args);
|
|
|
|
+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &device_id);
|
|
|
|
+
|
|
|
|
+ /* send syncronous */
|
|
|
|
+ dbus_error_init(&error);
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling DeleteDevice(%s)", device_id);
|
|
|
|
+ reply = dbus_connection_send_with_reply_and_block(con,
|
|
|
|
+ message,
|
2011-05-17 08:43:15 +00:00
|
|
|
+ COLORD_DBUS_TIMEOUT,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ &error);
|
|
|
|
+ if (reply == NULL)
|
2011-01-06 16:21:12 +00:00
|
|
|
+ {
|
2011-05-17 08:43:15 +00:00
|
|
|
+ /* this can happen normally on start-up */
|
2011-03-10 13:40:08 +00:00
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
|
|
|
|
+ "failed to DeleteDevice: %s:%s",
|
2011-03-07 13:40:36 +00:00
|
|
|
+ error.name, error.message);
|
|
|
|
+ dbus_error_free(&error);
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+out:
|
2011-10-03 11:30:59 +00:00
|
|
|
+ free (device_path);
|
2011-03-07 13:40:36 +00:00
|
|
|
+ if (message != NULL)
|
|
|
|
+ dbus_message_unref(message);
|
|
|
|
+ if (reply != NULL)
|
|
|
|
+ dbus_message_unref(reply);
|
|
|
|
+}
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+/*
|
|
|
|
+ * 'colordGetQualifierFormat()' - Get the qualifier format.
|
|
|
|
+ *
|
|
|
|
+ * Notes: Returns a value of "ColorSpace.MediaType.Resolution" by default
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+char **
|
|
|
|
+colordGetQualifierFormat(ppd_file_t *ppd)
|
|
|
|
+{
|
|
|
|
+ char **format; /* Qualifier format tuple */
|
|
|
|
+ const char *tmp; /* Temporary string */
|
|
|
|
+ ppd_attr_t *attr; /* Profile attributes */
|
|
|
|
+
|
|
|
|
+ /* create 3-tuple */
|
|
|
|
+ format = calloc(3, sizeof(char*));
|
|
|
|
+
|
|
|
|
+ /* get 1st section */
|
|
|
|
+ tmp = "cupsICCQualifier1";
|
|
|
|
+ attr = ppdFindAttr(ppd, tmp, NULL);
|
|
|
|
+ if (attr != NULL)
|
|
|
|
+ tmp = attr->value;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ tmp = "DefaultColorSpace";
|
|
|
|
+ attr = ppdFindAttr(ppd, tmp, NULL);
|
|
|
|
+ }
|
|
|
|
+ if (attr == NULL)
|
|
|
|
+ {
|
|
|
|
+ tmp = "DefaultColorModel";
|
|
|
|
+ attr = ppdFindAttr(ppd, tmp, NULL);
|
|
|
|
+ }
|
|
|
|
+ if (attr == NULL)
|
|
|
|
+ {
|
|
|
|
+ tmp = "";
|
|
|
|
+ }
|
|
|
|
+ if (strncmp(tmp, "Default", 7) == 0)
|
|
|
|
+ tmp += 7;
|
|
|
|
+ format[0] = strdup(tmp);
|
|
|
|
+
|
2011-06-04 15:13:25 +00:00
|
|
|
+ /* get 2nd section */
|
2011-03-07 13:40:36 +00:00
|
|
|
+ tmp = "cupsICCQualifier2";
|
|
|
|
+ attr = ppdFindAttr(ppd, tmp, NULL);
|
|
|
|
+ if (attr != NULL)
|
|
|
|
+ tmp = attr->value;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ tmp = "DefaultMediaType";
|
|
|
|
+ attr = ppdFindAttr(ppd, tmp, NULL);
|
|
|
|
+ }
|
|
|
|
+ if (attr == NULL)
|
|
|
|
+ {
|
|
|
|
+ tmp = "";
|
|
|
|
+ }
|
|
|
|
+ if (strncmp(tmp, "Default", 7) == 0)
|
|
|
|
+ tmp += 7;
|
|
|
|
+ format[1] = strdup(tmp);
|
|
|
|
+
|
2011-06-04 15:13:25 +00:00
|
|
|
+ /* get 3rd section */
|
2011-03-07 13:40:36 +00:00
|
|
|
+ tmp = "cupsICCQualifier3";
|
|
|
|
+ attr = ppdFindAttr(ppd, tmp, NULL);
|
|
|
|
+ if (attr != NULL)
|
|
|
|
+ tmp = attr->value;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ tmp = "DefaultResolution";
|
|
|
|
+ attr = ppdFindAttr(ppd, tmp, NULL);
|
|
|
|
+ }
|
|
|
|
+ if (attr == NULL)
|
|
|
|
+ {
|
|
|
|
+ tmp = "";
|
|
|
|
+ }
|
|
|
|
+ if (strncmp(tmp, "Default", 7) == 0)
|
|
|
|
+ tmp += 7;
|
|
|
|
+ format[2] = strdup(tmp);
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ return format;
|
2011-01-06 16:21:12 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * 'colordRegisterPrinter()' - Register profiles for a printer.
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+void
|
2011-03-07 13:40:36 +00:00
|
|
|
+colordRegisterPrinter(cupsd_printer_t *p) /* I - printer */
|
2011-01-06 16:21:12 +00:00
|
|
|
+{
|
2011-03-07 13:40:36 +00:00
|
|
|
+ char ppdfile[1024], /* PPD filename */
|
|
|
|
+ iccfile[1024]; /* ICC filename */
|
|
|
|
+ ppd_file_t *ppd; /* PPD file */
|
|
|
|
+ cups_array_t *profiles; /* Profile paths array */
|
|
|
|
+ const char *profile_key; /* Profile keyword */
|
|
|
|
+ ppd_attr_t *attr; /* Profile attributes */
|
|
|
|
+ const char *device_colorspace; /* Device colorspace */
|
|
|
|
+ char **format; /* Qualifier format tuple */
|
|
|
|
+ int i; /* Loop counter */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+ /*
|
2011-05-24 11:49:43 +00:00
|
|
|
+ * Do nothing for discovered printers as they will have local color
|
|
|
|
+ * correction
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ if (p->type & CUPS_PRINTER_DISCOVERED)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ /*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * Ensure we have a DBus connection
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ colordStart();
|
2011-06-04 15:13:25 +00:00
|
|
|
+ if (con == NULL)
|
|
|
|
+ return;
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Try opening the PPD file for this printer...
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ snprintf(ppdfile, sizeof(ppdfile), "%s/ppd/%s.ppd", ServerRoot, p->name);
|
|
|
|
+ if ((ppd = ppdOpenFile(ppdfile)) == NULL)
|
2011-03-07 13:40:36 +00:00
|
|
|
+ {
|
2011-05-24 11:49:43 +00:00
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ "cannot open %s",
|
|
|
|
+ ppdfile);
|
2011-01-06 16:21:12 +00:00
|
|
|
+ return;
|
2011-03-07 13:40:36 +00:00
|
|
|
+ }
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+ /*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * Find out the qualifier format
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ format = colordGetQualifierFormat(ppd);
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * See if we have any embedded profiles...
|
|
|
|
+ */
|
|
|
|
+
|
2011-05-31 16:25:38 +00:00
|
|
|
+ profiles = cupsArrayNew3 (NULL, NULL, NULL, 0, NULL,
|
|
|
|
+ (cups_afree_func_t) free);
|
2011-05-17 08:43:15 +00:00
|
|
|
+ profile_key = "cupsICCProfile";
|
2011-03-07 13:40:36 +00:00
|
|
|
+ attr = ppdFindAttr(ppd, profile_key, NULL);
|
|
|
|
+ for (; attr; attr = ppdFindNextAttr(ppd, profile_key, NULL))
|
2011-01-06 16:21:12 +00:00
|
|
|
+ if (attr->spec[0] && attr->value && attr->value[0])
|
|
|
|
+ {
|
|
|
|
+ if (attr->value[0] != '/')
|
2011-03-07 13:40:36 +00:00
|
|
|
+ snprintf(iccfile, sizeof(iccfile), "%s/profiles/%s", DataDir,
|
|
|
|
+ attr->value);
|
2011-01-06 16:21:12 +00:00
|
|
|
+ else
|
2011-03-07 13:40:36 +00:00
|
|
|
+ strlcpy(iccfile, attr->value, sizeof(iccfile));
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+ if (access(iccfile, 0))
|
|
|
|
+ {
|
2011-03-07 13:40:36 +00:00
|
|
|
+ cupsdLogMessage(CUPSD_LOG_WARN,
|
|
|
|
+ "no access to %s",
|
|
|
|
+ iccfile);
|
|
|
|
+ continue;
|
2011-01-06 16:21:12 +00:00
|
|
|
+ }
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ colordCreateProfile(profiles,
|
|
|
|
+ p->name,
|
|
|
|
+ attr->spec,
|
2011-05-19 08:27:39 +00:00
|
|
|
+ COLORD_SPACE_UNKNOWN,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ (const char **)format,
|
|
|
|
+ iccfile,
|
|
|
|
+ COLORD_SCOPE_TEMP);
|
2011-01-06 16:21:12 +00:00
|
|
|
+ }
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /*
|
|
|
|
+ * Add the grayscale profile first. We always have a grayscale profile.
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ colordCreateProfile(profiles,
|
|
|
|
+ p->name,
|
|
|
|
+ "Gray..",
|
2011-05-19 08:27:39 +00:00
|
|
|
+ COLORD_SPACE_GRAY,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ (const char **)format,
|
|
|
|
+ NULL,
|
|
|
|
+ COLORD_SCOPE_TEMP);
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /*
|
|
|
|
+ * Then add the RGB/CMYK/DeviceN color profile...
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ device_colorspace = "unknown";
|
|
|
|
+ switch (ppd->colorspace)
|
2011-01-06 16:21:12 +00:00
|
|
|
+ {
|
2011-03-07 13:40:36 +00:00
|
|
|
+ case PPD_CS_RGB :
|
|
|
|
+ case PPD_CS_CMY :
|
|
|
|
+ device_colorspace = COLORD_SPACE_RGB;
|
|
|
|
+ colordCreateProfile(profiles,
|
|
|
|
+ p->name,
|
|
|
|
+ "RGB..",
|
2011-05-19 08:27:39 +00:00
|
|
|
+ COLORD_SPACE_RGB,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ (const char **)format,
|
|
|
|
+ NULL,
|
|
|
|
+ COLORD_SCOPE_TEMP);
|
|
|
|
+ break;
|
|
|
|
+ case PPD_CS_RGBK :
|
|
|
|
+ case PPD_CS_CMYK :
|
|
|
|
+ device_colorspace = COLORD_SPACE_CMYK;
|
|
|
|
+ colordCreateProfile(profiles,
|
|
|
|
+ p->name,
|
|
|
|
+ "CMYK..",
|
2011-05-19 08:27:39 +00:00
|
|
|
+ COLORD_SPACE_CMYK,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ (const char **)format,
|
|
|
|
+ NULL,
|
|
|
|
+ COLORD_SCOPE_TEMP);
|
|
|
|
+ break;
|
|
|
|
+ case PPD_CS_GRAY :
|
2011-05-17 08:43:15 +00:00
|
|
|
+ device_colorspace = COLORD_SPACE_GRAY;
|
|
|
|
+ break;
|
2011-03-07 13:40:36 +00:00
|
|
|
+ case PPD_CS_N :
|
|
|
|
+ colordCreateProfile(profiles,
|
|
|
|
+ p->name,
|
|
|
|
+ "DeviceN..",
|
2011-05-19 08:27:39 +00:00
|
|
|
+ COLORD_SPACE_UNKNOWN,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ (const char **)format,
|
|
|
|
+ NULL,
|
|
|
|
+ COLORD_SCOPE_TEMP);
|
|
|
|
+ break;
|
|
|
|
+ }
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /*
|
|
|
|
+ * Register the device with colord.
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ cupsdLogMessage(CUPSD_LOG_INFO, "Registering ICC color profiles for \"%s\"",
|
|
|
|
+ p->name);
|
|
|
|
+ colordCreateDevice (p,
|
2011-05-17 08:43:15 +00:00
|
|
|
+ ppd,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ profiles,
|
|
|
|
+ device_colorspace,
|
2011-10-03 11:30:59 +00:00
|
|
|
+ format,
|
2011-03-07 13:40:36 +00:00
|
|
|
+ COLORD_RELATION_SOFT,
|
|
|
|
+ COLORD_SCOPE_TEMP);
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /*
|
|
|
|
+ * Free any memory we used...
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ cupsArrayDelete(profiles);
|
|
|
|
+ for (i=0; i<3; i++)
|
|
|
|
+ free(format[i]);
|
|
|
|
+ free(format);
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ ppdClose(ppd);
|
|
|
|
+}
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+/*
|
|
|
|
+ * 'colordUnregisterPrinter()' - Unregister profiles for a printer.
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+void
|
|
|
|
+colordUnregisterPrinter(cupsd_printer_t *p) /* I - printer */
|
|
|
|
+{
|
|
|
|
+ char device_id[1024]; /* Device ID as understood by colord */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /*
|
|
|
|
+ * Ensure we have a DBus connection
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ colordStart();
|
2011-06-04 15:13:25 +00:00
|
|
|
+ if (con == NULL)
|
|
|
|
+ return;
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /*
|
|
|
|
+ * Just delete the device itself, and leave the profiles registered
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ snprintf(device_id, sizeof(device_id), "cups-%s", p->name);
|
|
|
|
+ colordDeleteDevice(device_id);
|
|
|
|
+}
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+#endif /* HAVE_DBUS */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+/*
|
|
|
|
+ * End of "$Id$".
|
|
|
|
+ */
|
2011-05-31 16:25:38 +00:00
|
|
|
diff --git a/scheduler/colord.h b/scheduler/colord.h
|
|
|
|
new file mode 100644
|
2011-10-03 11:30:59 +00:00
|
|
|
index 0000000..75bdd3b
|
2011-03-07 13:40:36 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/scheduler/colord.h
|
2011-10-03 11:30:59 +00:00
|
|
|
@@ -0,0 +1,41 @@
|
2011-03-07 13:40:36 +00:00
|
|
|
+/*
|
|
|
|
+ * "$Id$"
|
|
|
|
+ *
|
|
|
|
+ * colord integration for the CUPS scheduler.
|
|
|
|
+ *
|
2011-10-03 11:30:59 +00:00
|
|
|
+ * Copyright 2011 Red Hat, Inc.
|
|
|
|
+ *
|
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
|
+ * modification, are permitted provided that the following conditions
|
|
|
|
+ * are met:
|
|
|
|
+ *
|
|
|
|
+ * Redistributions of source code must retain the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer.
|
|
|
|
+ *
|
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
|
+ *
|
|
|
|
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
|
|
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
|
|
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
|
2011-03-07 13:40:36 +00:00
|
|
|
+ *
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+void colordRegisterPrinter(cupsd_printer_t *p);
|
|
|
|
+void colordUnregisterPrinter(cupsd_printer_t *p);
|
|
|
|
+void colordStart(void);
|
|
|
|
+void colordStop(void);
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+/*
|
|
|
|
+ * End of "$Id$".
|
|
|
|
+ */
|
2011-05-31 16:25:38 +00:00
|
|
|
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
|
2011-10-03 11:30:59 +00:00
|
|
|
index b9903d1..b5af36f 100644
|
2011-03-07 13:40:36 +00:00
|
|
|
--- a/scheduler/ipp.c
|
|
|
|
+++ b/scheduler/ipp.c
|
2011-10-03 11:30:59 +00:00
|
|
|
@@ -2921,17 +2921,23 @@ add_printer(cupsd_client_t *con, /* I - Client connection */
|
2011-03-07 13:40:36 +00:00
|
|
|
|
|
|
|
cupsdSetPrinterReasons(printer, "none");
|
|
|
|
|
|
|
|
-#ifdef __APPLE__
|
|
|
|
/*
|
|
|
|
* (Re)register color profiles...
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!RunUser)
|
|
|
|
{
|
|
|
|
+ cupsdCmsRegisterPrinter(printer);
|
2011-01-06 16:21:12 +00:00
|
|
|
+#ifdef __APPLE__
|
|
|
|
+ /*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * FIXME: ideally the ColorSync stuff would be moved to colorsync.c
|
|
|
|
+ * and the colorsyncRegisterProfiles() would be called from
|
|
|
|
+ * cupsdCmsRegisterPrinter() in printers.c
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
2011-03-07 13:40:36 +00:00
|
|
|
apple_unregister_profiles(printer);
|
|
|
|
apple_register_profiles(printer);
|
|
|
|
- }
|
|
|
|
#endif /* __APPLE__ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+ }
|
2011-03-07 13:40:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-10-03 11:30:59 +00:00
|
|
|
@@ -7028,11 +7034,17 @@ delete_printer(cupsd_client_t *con, /* I - Client connection */
|
2011-05-31 16:25:38 +00:00
|
|
|
snprintf(filename, sizeof(filename), "%s/%s.data", CacheDir, printer->name);
|
2011-03-07 13:40:36 +00:00
|
|
|
unlink(filename);
|
|
|
|
|
|
|
|
-#ifdef __APPLE__
|
|
|
|
/*
|
|
|
|
* Unregister color profiles...
|
|
|
|
*/
|
|
|
|
|
|
|
|
+ cupsdCmsUnregisterPrinter(printer);
|
|
|
|
+#ifdef __APPLE__
|
|
|
|
+ /*
|
|
|
|
+ * FIXME: ideally the ColorSync stuff would be moved to colorsync.c
|
|
|
|
+ * and the colorsyncUnregisterPrinter() would be called from
|
|
|
|
+ * cupsdCmsUnregisterPrinter() in printers.c
|
|
|
|
+ */
|
|
|
|
apple_unregister_profiles(printer);
|
|
|
|
#endif /* __APPLE__ */
|
|
|
|
|
2011-05-31 16:25:38 +00:00
|
|
|
diff --git a/scheduler/printers.c b/scheduler/printers.c
|
2011-10-03 11:30:59 +00:00
|
|
|
index 6920801..e830499 100644
|
2011-03-07 13:40:36 +00:00
|
|
|
--- a/scheduler/printers.c
|
|
|
|
+++ b/scheduler/printers.c
|
2011-06-15 10:11:10 +00:00
|
|
|
@@ -80,6 +80,9 @@
|
|
|
|
# include <asl.h>
|
|
|
|
#endif /* __APPLE__ */
|
2011-03-07 13:40:36 +00:00
|
|
|
|
|
|
|
+#ifdef HAVE_DBUS
|
|
|
|
+# include "colord.h"
|
|
|
|
+#endif /* HAVE_DBUS */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local functions...
|
2011-10-03 11:30:59 +00:00
|
|
|
@@ -712,6 +715,53 @@ cupsdDeleteAllPrinters(void)
|
2011-03-07 13:40:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * 'cupsdCmsRegisterPrinter()' - Registers a printer and profiles with the CMS
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+void
|
|
|
|
+cupsdCmsRegisterPrinter(cupsd_printer_t *p)
|
|
|
|
+{
|
|
|
|
+#if defined(HAVE_DBUS)
|
|
|
|
+ colordRegisterPrinter(p);
|
|
|
|
+#endif /* defined(HAVE_DBUS) */
|
|
|
|
+}
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+/*
|
|
|
|
+ * 'cupsdCmsUnregisterPrinter()' - Unregisters a printer and profiles with the CMS
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+void
|
|
|
|
+cupsdCmsUnregisterPrinter(cupsd_printer_t *p)
|
|
|
|
+{
|
|
|
|
+#if defined(HAVE_DBUS)
|
|
|
|
+ colordUnregisterPrinter(p);
|
|
|
|
+#endif /* defined(HAVE_DBUS) */
|
2011-01-06 16:21:12 +00:00
|
|
|
+}
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+/*
|
|
|
|
+ * 'cupsdCmsStart()' - Starts the CMS
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+cupsdCmsStart(void)
|
|
|
|
+{
|
|
|
|
+#if defined(HAVE_DBUS)
|
|
|
|
+ colordStart();
|
|
|
|
+#endif /* defined(HAVE_DBUS) */
|
|
|
|
+}
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
|
|
|
+/*
|
2011-03-07 13:40:36 +00:00
|
|
|
+ * 'cupsdCmsStop()' - Stops the CMS
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+void
|
2011-03-07 13:40:36 +00:00
|
|
|
+cupsdCmsStop(void)
|
2011-01-06 16:21:12 +00:00
|
|
|
+{
|
2011-03-07 13:40:36 +00:00
|
|
|
+#if defined(HAVE_DBUS)
|
|
|
|
+ colordStop();
|
|
|
|
+#endif /* defined(HAVE_DBUS) */
|
|
|
|
+}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 'cupsdDeletePrinter()' - Delete a printer from the system.
|
2011-10-03 11:30:59 +00:00
|
|
|
@@ -752,6 +802,12 @@ cupsdDeletePrinter(
|
2011-03-07 13:40:36 +00:00
|
|
|
"Job stopped.");
|
|
|
|
|
|
|
|
/*
|
|
|
|
+ * Unregister profiles...
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ cupsdCmsUnregisterPrinter(p);
|
|
|
|
+
|
2011-01-06 16:21:12 +00:00
|
|
|
+ /*
|
2011-03-07 13:40:36 +00:00
|
|
|
* If this printer is the next for browsing, point to the next one...
|
|
|
|
*/
|
|
|
|
|
2011-10-03 11:30:59 +00:00
|
|
|
@@ -1418,6 +1474,12 @@ cupsdRenamePrinter(
|
2011-05-31 16:25:38 +00:00
|
|
|
}
|
2011-03-07 13:40:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
+ * Unregister profiles...
|
2011-01-06 16:21:12 +00:00
|
|
|
+ */
|
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ cupsdCmsUnregisterPrinter(p);
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ /*
|
|
|
|
* Rename the printer...
|
|
|
|
*/
|
|
|
|
|
2011-10-03 11:30:59 +00:00
|
|
|
@@ -2644,6 +2706,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
|
2011-03-07 13:40:36 +00:00
|
|
|
#endif /* __sgi */
|
|
|
|
|
|
|
|
/*
|
|
|
|
+ * Re-register profiles...
|
|
|
|
+ */
|
2011-01-06 16:21:12 +00:00
|
|
|
+
|
2011-03-07 13:40:36 +00:00
|
|
|
+ cupsdCmsUnregisterPrinter(p);
|
|
|
|
+ cupsdCmsRegisterPrinter(p);
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
* Let the browse protocols reflect the change
|
|
|
|
*/
|
|
|
|
|
2011-05-31 16:25:38 +00:00
|
|
|
diff --git a/scheduler/printers.h b/scheduler/printers.h
|
|
|
|
index 1751578..3820428 100644
|
2011-03-07 13:40:36 +00:00
|
|
|
--- a/scheduler/printers.h
|
|
|
|
+++ b/scheduler/printers.h
|
2011-05-31 16:25:38 +00:00
|
|
|
@@ -170,6 +170,10 @@ extern const char *cupsdValidateDest(const char *uri,
|
2011-01-06 16:21:12 +00:00
|
|
|
cups_ptype_t *dtype,
|
|
|
|
cupsd_printer_t **printer);
|
|
|
|
extern void cupsdWritePrintcap(void);
|
2011-03-07 13:40:36 +00:00
|
|
|
+extern void cupsdCmsRegisterPrinter(cupsd_printer_t *p);
|
|
|
|
+extern void cupsdCmsUnregisterPrinter(cupsd_printer_t *p);
|
|
|
|
+extern void cupsdCmsStart(void);
|
|
|
|
+extern void cupsdCmsStop(void);
|
2011-01-06 16:21:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2011-05-31 16:25:38 +00:00
|
|
|
--
|
2011-10-03 11:30:59 +00:00
|
|
|
1.7.6.2
|
2011-05-31 16:25:38 +00:00
|
|
|
|