]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/colorman.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / scheduler / colorman.c
index c662a2c155921cf329daca8d20d483e3dcd633d4..8af4e5cd1fd3d55374158795ebd096673e5933ca 100644 (file)
@@ -1,22 +1,16 @@
 /*
- * "$Id$"
+ * Color management routines for the CUPS scheduler.
  *
- *   Color management routines for the CUPS scheduler.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- *   Copyright 2007-2012 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. 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
- *   file is missing or damaged, see the license at "http://www.cups.org/".
+ * Original DBUS/colord code is Copyright 2011 Red Hat, Inc.
  *
- *   Original DBUS/colord code is 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:
+ * 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.
  *   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.
- *
- * Contents:
- *
+ * 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.
  */
 
 /*
@@ -84,11 +75,10 @@ extern CFUUIDRef ColorSyncCreateUUIDFromUInt32(unsigned id);
 #  define COLORD_KIND_PRINTER  "printer"
                                        /* printing output device */
 
-#  define COLORD_DBUS_MSG(p,m) dbus_message_new_method_call(\
-                                       "org.freedesktop.ColorManager", (p),\
-                                        "org.freedesktop.ColorManager", (m))
-                                        /* Macro to make new colord messages */
-#  define COLORD_DBUS_PATH     "/org/freedesktop/ColorManager"
+#  define COLORD_DBUS_SERVICE          "org.freedesktop.ColorManager"
+#  define COLORD_DBUS_INTERFACE        "org.freedesktop.ColorManager"
+#  define COLORD_DBUS_INTERFACE_DEVICE "org.freedesktop.ColorManager.Device"
+#  define COLORD_DBUS_PATH             "/org/freedesktop/ColorManager"
                                        /* Path for color management system */
 #  define COLORD_DBUS_TIMEOUT  5000    /* Timeout for connecting to colord in ms */
 #endif /* __APPLE__ */
@@ -148,12 +138,18 @@ void
 cupsdRegisterColor(cupsd_printer_t *p) /* I - Printer */
 {
 #ifdef __APPLE__
-  apple_unregister_profiles(p);
-  apple_register_profiles(p);
+  if (!RunUser)
+  {
+    apple_unregister_profiles(p);
+    apple_register_profiles(p);
+  }
 
 #elif defined(HAVE_DBUS)
-  colord_unregister_printer(p);
-  colord_register_printer(p);
+  if (!RunUser)
+  {
+    colord_unregister_printer(p);
+    colord_register_printer(p);
+  }
 #endif /* __APPLE__ */
 }
 
@@ -187,7 +183,8 @@ void
 cupsdStopColor(void)
 {
 #if !defined(__APPLE__) && defined(HAVE_DBUS)
-  dbus_connection_unref(colord_con);
+  if (colord_con)
+    dbus_connection_unref(colord_con);
   colord_con = NULL;
 #endif /* !__APPLE__ && HAVE_DBUS */
 }
@@ -201,10 +198,12 @@ void
 cupsdUnregisterColor(cupsd_printer_t *p)/* I - Printer */
 {
 #ifdef __APPLE__
-  apple_unregister_profiles(p);
+  if (!RunUser)
+    apple_unregister_profiles(p);
 
 #elif defined(HAVE_DBUS)
-  colord_unregister_printer(p);
+  if (!RunUser)
+    colord_unregister_printer(p);
 #endif /* __APPLE__ */
 }
 
@@ -303,11 +302,9 @@ apple_init_profile(
   * Fill in the profile data...
   */
 
- if (iccfile)
+ if (iccfile && *iccfile)
  {
-    url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
-                                                 (const UInt8 *)iccfile,
-                                                  strlen(iccfile), false);
+    url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)iccfile, (CFIndex)strlen(iccfile), false);
 
     if (url)
     {
@@ -365,7 +362,7 @@ apple_register_profiles(
   * Make sure ColorSync is available...
   */
 
-  if (ColorSyncRegisterDevice == NULL)
+  if (&ColorSyncRegisterDevice == NULL)
     return;
 
  /*
@@ -493,7 +490,7 @@ apple_register_profiles(
 
         if (_cupsFileCheck(iccfile, _CUPS_FILE_CHECK_FILE, !RunUser,
                           cupsdLogFCMessage, p))
-         continue;
+         iccfile[0] = '\0';
 
        cupsArraySave(ppd->sorted_attrs);
 
@@ -865,7 +862,7 @@ apple_unregister_profiles(
   * Make sure ColorSync is available...
   */
 
-  if (ColorSyncUnregisterDevice != NULL)
+  if (&ColorSyncUnregisterDevice != NULL)
   {
     CFUUIDRef deviceUUID;              /* Device UUID */
 
@@ -916,7 +913,10 @@ colord_create_device(
   snprintf(device_id, sizeof(device_id), "cups-%s", p->name);
   device_path = device_id;
 
-  message = COLORD_DBUS_MSG(COLORD_DBUS_PATH, "CreateDevice");
+  message = dbus_message_new_method_call(COLORD_DBUS_SERVICE,
+                                         COLORD_DBUS_PATH,
+                                         COLORD_DBUS_INTERFACE,
+                                         "CreateDevice");
 
   dbus_message_iter_init_append(message, &args);
   dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &device_path);
@@ -1025,7 +1025,10 @@ colord_create_profile(
   * Create the profile...
   */
 
-  message = COLORD_DBUS_MSG(COLORD_DBUS_PATH, "CreateProfile");
+  message = dbus_message_new_method_call(COLORD_DBUS_SERVICE,
+                                         COLORD_DBUS_PATH,
+                                         COLORD_DBUS_INTERFACE,
+                                         "CreateProfile");
 
   idstrlen = strlen(printer_name) + 1 + strlen(qualifier) + 1;
   if ((idstr = malloc(idstrlen)) == NULL)
@@ -1121,17 +1124,20 @@ colord_delete_device(
   * Delete the device...
   */
 
-  message = COLORD_DBUS_MSG(COLORD_DBUS_PATH, "DeleteDevice");
+  message = dbus_message_new_method_call(COLORD_DBUS_SERVICE,
+                                         COLORD_DBUS_PATH,
+                                         COLORD_DBUS_INTERFACE,
+                                         "DeleteDevice");
 
   dbus_message_iter_init_append(message, &args);
-  dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &device_id);
+  dbus_message_iter_append_basic(&args, DBUS_TYPE_OBJECT_PATH, &device_path);
 
  /*
   * Send the DeleteDevice request synchronously...
   */
 
   dbus_error_init(&error);
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling DeleteDevice(%s)", device_id);
+  cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling DeleteDevice(%s)", device_path);
   reply = dbus_connection_send_with_reply_and_block(colord_con, message,
                                                     COLORD_DBUS_TIMEOUT,
                                                     &error);
@@ -1173,7 +1179,10 @@ colord_device_add_profile(
   DBusError    error;                  /* D-Bus error */
 
 
-  message = COLORD_DBUS_MSG(device_path, "AddProfile");
+  message = dbus_message_new_method_call(COLORD_DBUS_SERVICE,
+                                         device_path,
+                                         COLORD_DBUS_INTERFACE_DEVICE,
+                                         "AddProfile");
 
   dbus_message_iter_init_append(message, &args);
   dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &relation);
@@ -1243,7 +1252,10 @@ colord_find_device(
   char         *device_path = NULL;    /* Device object path */
 
 
-  message = COLORD_DBUS_MSG(COLORD_DBUS_PATH, "FindDeviceById");
+  message = dbus_message_new_method_call(COLORD_DBUS_SERVICE,
+                                         COLORD_DBUS_PATH,
+                                         COLORD_DBUS_INTERFACE,
+                                         "FindDeviceById");
 
   dbus_message_iter_init_append(message, &args);
   dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &device_id);
@@ -1498,8 +1510,3 @@ colord_unregister_printer(
   colord_delete_device(device_id);
 }
 #endif /* __APPLE__ */
-
-
-/*
- * End of "$Id$".
- */