[gnome-color-manager/colord: 21/72] Remove support for saved devices in GcmClient



commit 9a069264b1d937c4ef3d33b00efc302abfda7328
Author: Richard Hughes <richard hughsie com>
Date:   Sun Jan 16 20:52:08 2011 +0000

    Remove support for saved devices in GcmClient

 src/cc-color-panel.c |    6 --
 src/gcm-client.c     |  136 --------------------------------------------------
 src/gcm-client.h     |    1 -
 3 files changed, 0 insertions(+), 143 deletions(-)
---
diff --git a/src/cc-color-panel.c b/src/cc-color-panel.c
index 8def2c0..41db391 100644
--- a/src/cc-color-panel.c
+++ b/src/cc-color-panel.c
@@ -1908,7 +1908,6 @@ cc_color_panel_changed_cb (GcmClient *client, GcmDevice *device, CcColorPanel *p
 static void
 cc_color_panel_removed_cb (GcmClient *client, GcmDevice *device, CcColorPanel *panel)
 {
-	gboolean connected;
 	GtkTreeIter iter;
 	GtkTreeSelection *selection;
 	GtkWidget *widget;
@@ -1917,11 +1916,6 @@ cc_color_panel_removed_cb (GcmClient *client, GcmDevice *device, CcColorPanel *p
 	/* remove from the UI */
 	cc_color_panel_remove_device (panel, device);
 
-	/* ensure this device is re-added if it's been saved */
-	connected = gcm_device_get_connected (device);
-	if (connected)
-		gcm_client_coldplug (panel->priv->gcm_client, GCM_CLIENT_COLDPLUG_SAVED, NULL);
-
 	/* select the first device */
 	ret = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (panel->priv->list_store_devices), &iter);
 	if (!ret)
diff --git a/src/gcm-client.c b/src/gcm-client.c
index 77cdc4f..daf33a6 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -649,134 +649,6 @@ out:
 #endif
 
 /**
- * gcm_client_add_unconnected_device:
- **/
-static void
-gcm_client_add_unconnected_device (GcmClient *client, GKeyFile *keyfile, const gchar *id)
-{
-	gchar *title;
-	gchar *kind_text = NULL;
-	gchar *colorspace_text = NULL;
-	GcmColorspace colorspace;
-	CdDeviceKind kind;
-	GcmDevice *device = NULL;
-	gboolean ret;
-	gboolean virtual;
-	GError *error = NULL;
-
-	/* add new device */
-	title = g_key_file_get_string (keyfile, id, "title", NULL);
-	if (title == NULL)
-		goto out;
-	virtual = g_key_file_get_boolean (keyfile, id, "virtual", NULL);
-	kind_text = g_key_file_get_string (keyfile, id, "type", NULL);
-	kind = cd_device_kind_from_string (kind_text);
-	if (kind == CD_DEVICE_KIND_UNKNOWN)
-		goto out;
-
-	/* get colorspace */
-	colorspace_text = g_key_file_get_string (keyfile, id, "colorspace", NULL);
-	if (colorspace_text == NULL) {
-		g_warning ("legacy device %s, falling back to RGB", id);
-		colorspace = GCM_COLORSPACE_RGB;
-	} else {
-		colorspace = gcm_colorspace_from_string (colorspace_text);
-	}
-
-	/* create device of specified type */
-#ifdef HAVE_SANE
-	if (kind == CD_DEVICE_KIND_SCANNER) {
-		device = gcm_device_sane_new ();
-#endif
-	} else {
-		g_warning ("device kind internal error");
-		goto out;
-	}
-
-	/* create device */
-	g_object_set (device,
-		      "kind", kind,
-		      "id", id,
-		      "connected", FALSE,
-		      "title", title,
-		      "saved", TRUE,
-		      "virtual", virtual,
-		      "colorspace", colorspace,
-		      NULL);
-
-	/* add device */
-	ret = gcm_client_add_device (client, device, &error);
-	if (!ret) {
-		g_debug ("failed to set for device: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-out:
-	if (device != NULL)
-		g_object_unref (device);
-	g_free (kind_text);
-	g_free (colorspace_text);
-	g_free (title);
-}
-
-/**
- * gcm_client_add_saved:
- **/
-static gboolean
-gcm_client_add_saved (GcmClient *client, GError **error)
-{
-	gboolean ret;
-	gchar *filename;
-	GKeyFile *keyfile;
-	gchar **groups = NULL;
-	guint i;
-	GcmDevice *device;
-
-	/* get the config file */
-	filename = gcm_utils_get_default_config_location ();
-	g_debug ("using %s", filename);
-
-	/* load the config file */
-	keyfile = g_key_file_new ();
-	ret = g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, error);
-	if (!ret) {
-		/* if the file is missing then ignore the error */
-		if ((*error)->domain == G_FILE_ERROR && (*error)->code == G_FILE_ERROR_NOENT) {
-			g_clear_error (error);
-			ret = TRUE;
-		}
-		goto out;
-	}
-
-	/* get groups */
-	groups = g_key_file_get_groups (keyfile, NULL);
-	if (groups == NULL) {
-		ret = FALSE;
-		g_set_error_literal (error, 1, 0, "failed to get groups");
-		goto out;
-	}
-
-	/* add each device if it's not already connected */
-	for (i=0; groups[i] != NULL; i++) {
-		device = gcm_client_get_device_by_id (client, groups[i]);
-		if (device == NULL) {
-			g_debug ("not found %s", groups[i]);
-			gcm_client_add_unconnected_device (client, keyfile, groups[i]);
-		} else {
-			g_debug ("found already added %s", groups[i]);
-			gcm_device_set_saved (device, TRUE);
-		}
-	}
-out:
-	/* inform the UI */
-	gcm_client_done_loading (client);
-	g_strfreev (groups);
-	g_free (filename);
-	g_key_file_free (keyfile);
-	return ret;
-}
-
-/**
  * gcm_client_coldplug:
  **/
 gboolean
@@ -790,14 +662,6 @@ gcm_client_coldplug (GcmClient *client, GcmClientColdplug coldplug, GError **err
 	/* reset */
 	client->priv->loading_refcount = 0;
 
-	/* saved devices */
-	if (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_SAVED) {
-		gcm_client_add_loading (client);
-		ret = gcm_client_add_saved (client, error);
-		if (!ret)
-			goto out;
-	}
-
 #ifdef HAVE_SANE
 	/* SANE */
 	enable = g_settings_get_boolean (client->priv->settings, GCM_SETTINGS_ENABLE_SANE);
diff --git a/src/gcm-client.h b/src/gcm-client.h
index e5f08fa..0f29a5d 100644
--- a/src/gcm-client.h
+++ b/src/gcm-client.h
@@ -63,7 +63,6 @@ struct _GcmClientClass
 typedef enum {
 	GCM_CLIENT_COLDPLUG_ALL		= 0x00,
 	GCM_CLIENT_COLDPLUG_SANE	= 0x04,
-	GCM_CLIENT_COLDPLUG_SAVED	= 0x10,
 	GCM_CLIENT_COLDPLUG_LAST,
 } GcmClientColdplug;
 



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