[gnome-settings-daemon] color: Adapt to new async colord API



commit 78dba1a99c82ab1a572a1a3a891dae48dc5b667a
Author: Richard Hughes <richard hughsie com>
Date:   Mon May 30 22:04:05 2011 +0100

    color: Adapt to new async colord API
    
    The libcolord async API used to use a thread to get the properties for the
    device and profiles in the background.
    
    This was racy as hell, and was not good API design. Connect to each device and
    profiles explicitly before we access the properties.

 plugins/color/gsd-color-manager.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/plugins/color/gsd-color-manager.c b/plugins/color/gsd-color-manager.c
index c691dd6..b3256de 100644
--- a/plugins/color/gsd-color-manager.c
+++ b/plugins/color/gsd-color-manager.c
@@ -280,8 +280,21 @@ gcm_session_device_added_notify_cb (CdClient *client,
         const gchar *filename;
         gchar *basename = NULL;
         gboolean allow_notifications;
+        gboolean ret;
+        GError *error = NULL;
         GsdColorManagerPrivate *priv = manager->priv;
 
+        /* connect to the device */
+        ret = cd_device_connect_sync (device,
+                                      NULL,
+                                      &error);
+        if (!ret) {
+                g_warning ("failed to connect to device: %s",
+                           error->message);
+                g_error_free (error);
+                goto out;
+        }
+
         /* check we care */
         kind = cd_device_get_kind (device);
         if (kind != CD_DEVICE_KIND_DISPLAY &&
@@ -295,6 +308,17 @@ gcm_session_device_added_notify_cb (CdClient *client,
                 goto out;
         }
 
+        /* connect to the profile */
+        ret = cd_profile_connect_sync (profile,
+                                       NULL,
+                                       &error);
+        if (!ret) {
+                g_warning ("failed to connect to profile: %s",
+                           error->message);
+                g_error_free (error);
+                goto out;
+        }
+
         /* ensure it's a profile generated by us */
         filename = cd_profile_get_filename (profile);
         basename = g_path_get_basename (filename);
@@ -486,7 +510,7 @@ gcm_session_find_profile_by_filename_cb (GObject *object,
         /* remove it from colord */
         g_debug ("profile %s removed", cd_profile_get_id (profile));
         cd_client_delete_profile (manager->priv->client,
-                                  cd_profile_get_id (profile),
+                                  profile,
                                   NULL,
                                   gcm_session_delete_profile_cb,
                                   manager);



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