From 8bcf586b78fea574a791fcf1f3522a800a4d5c79 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 24 Mar 2011 15:05:56 +0000 Subject: trivial: add another FAQ entry for applications --- doc/website/faq.html | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'doc') diff --git a/doc/website/faq.html b/doc/website/faq.html index 712cd97..5fe416a 100644 --- a/doc/website/faq.html +++ b/doc/website/faq.html @@ -22,6 +22,7 @@ +
  • How would an application like Simple Scan use colord?
  • What is a qualifier used for?
  • How do system daemons add devices and profiles?
  • How would a system daemon like CUPS use colord?
  • @@ -159,6 +160,62 @@ already being used by CUPS in the cupsICCProfile PPD Extensions format.

    +
    +

    How would an application like Simple Scan use colord?

    +

    +It's actually really easy. +Simple Scan already knows the SANE_Device object of the +scanner that it wants to use. +From the SANE_Device object we can easily get the +device_id for the color managed device in colord. +To do this, refer to the +device and profile specification for scanner devices. +This specifies the device_id for a sane device is made up from +"sane_" + sane_device->model. +

    +

    +We can now query colord using +libcolord for the device that matches this ID: +

    +
    +    CdClient *client = NULL;
    +    CdDevice *device = NULL;
    +    CdProfile *profile = NULL;
    +    GError *error = NULL;
    +
    +    /* create a connection to colord */
    +    client = cd_client_new ();
    +
    +    /* find the device for a specific ID */
    +    device = cd_client_find_device_sync (client, device_id, NULL, &error);
    +    if (device == NULL) {
    +        g_warning ("failed to find a device in colord: %s,
    +                   error->message);
    +        g_error_free (error);
    +        goto out;
    +    }
    +
    +    /* get the default profile for this device */
    +    profile = cd_device_get_default_profile (device);
    +    if (profile == NULL)
    +        goto out;
    +
    +    /* TODO: use lcms to convert the scanned image */
    +    g_message ("need to use: %s", cd_profile_get_filename (profile));
    +out:
    +    if (profile != NULL)
    +        g_object_unref (profile);
    +    if (device != NULL)
    +        g_object_unref (device);
    +    g_object_unref (client);
    +
    +

    +If you're not happy gaining an additional dependency of libcolord, then +it's also pretty easy to use raw DBus calls to do the same thing. +See the +examples folder for some code samples. +

    +

    How do system daemons add devices and profiles?

    -- cgit v1.2.1