[gnome-color-manager/colord: 24/72] Remove all support for device-profiles.conf
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager/colord: 24/72] Remove all support for device-profiles.conf
- Date: Tue, 8 Mar 2011 11:25:21 +0000 (UTC)
commit 59af2b52f2e06cb7fa6856ad39c5d61a270b944e
Author: Richard Hughes <richard hughsie com>
Date: Mon Jan 17 13:58:35 2011 +0000
Remove all support for device-profiles.conf
src/gcm-client.c | 62 --------
src/gcm-device-xrandr.c | 12 --
src/gcm-device.c | 361 -----------------------------------------------
src/gcm-device.h | 2 -
src/gcm-self-test.c | 31 +----
src/gcm-utils.c | 19 ---
src/gcm-utils.h | 1 -
7 files changed, 1 insertions(+), 487 deletions(-)
---
diff --git a/src/gcm-client.c b/src/gcm-client.c
index f5f6b3f..e61d6e6 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -624,68 +624,6 @@ gcm_client_remove_device (GcmClient *client, GcmDevice *device, GError **error)
}
/**
- * gcm_client_delete_device:
- **/
-gboolean
-gcm_client_delete_device (GcmClient *client, GcmDevice *device, GError **error)
-{
- gboolean ret = FALSE;
- const gchar *device_id;
- gchar *data = NULL;
- gchar *filename = NULL;
- GKeyFile *keyfile = NULL;
-
- g_return_val_if_fail (GCM_IS_CLIENT (client), FALSE);
- g_return_val_if_fail (GCM_IS_DEVICE (device), FALSE);
-
- /* check device is saved */
- device_id = gcm_device_get_id (device);
- if (!gcm_device_get_saved (device))
- goto out;
-
- /* get the config file */
- filename = gcm_utils_get_default_config_location ();
- g_debug ("removing %s from %s", device_id, 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)
- goto out;
-
- /* remove from the config file */
- ret = g_key_file_remove_group (keyfile, device_id, error);
- if (!ret)
- goto out;
-
- /* convert to string */
- data = g_key_file_to_data (keyfile, NULL, error);
- if (data == NULL) {
- ret = FALSE;
- goto out;
- }
-
- /* save contents */
- ret = g_file_set_contents (filename, data, -1, error);
- if (!ret)
- goto out;
-
- /* update status */
- gcm_device_set_saved (device, FALSE);
-
- /* remove device */
- ret = gcm_client_remove_device_internal (client, device, TRUE, error);
- if (!ret)
- goto out;
-out:
- g_free (data);
- g_free (filename);
- if (keyfile != NULL)
- g_key_file_free (keyfile);
- return ret;
-}
-
-/**
* gcm_client_get_property:
**/
static void
diff --git a/src/gcm-device-xrandr.c b/src/gcm-device-xrandr.c
index fd16edd..dbcb7a4 100644
--- a/src/gcm-device-xrandr.c
+++ b/src/gcm-device-xrandr.c
@@ -377,17 +377,6 @@ gcm_device_xrandr_set_remove_atom (GcmDeviceXrandr *device_xrandr, gboolean remo
}
/**
- * gcm_device_xrandr_get_config_data:
- **/
-static gchar *
-gcm_device_xrandr_get_config_data (GcmDevice *device)
-{
- GcmDeviceXrandr *device_xrandr = GCM_DEVICE_XRANDR (device);
- GcmDeviceXrandrPrivate *priv = device_xrandr->priv;
- return g_strdup_printf ("edid-hash=%s", priv->edid_md5);
-}
-
-/**
* gcm_device_xrandr_generate_profile:
**/
static GcmProfile *
@@ -757,7 +746,6 @@ gcm_device_xrandr_class_init (GcmDeviceXrandrClass *klass)
object_class->set_property = gcm_device_xrandr_set_property;
device_class->apply = gcm_device_xrandr_apply;
- device_class->get_config_data = gcm_device_xrandr_get_config_data;
device_class->generate_profile = gcm_device_xrandr_generate_profile;
/**
diff --git a/src/gcm-device.c b/src/gcm-device.c
index 122cc2d..48ccd0b 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -172,35 +172,6 @@ cd_device_kind_to_string (CdDeviceKind kind)
}
/**
- * gcm_device_load_from_default_profile:
- **/
-static gboolean
-gcm_device_load_from_default_profile (GcmDevice *device, GError **error)
-{
- gboolean ret = TRUE;
- GcmProfile *profile;
- GcmDevicePrivate *priv = device->priv;
-
- g_return_val_if_fail (GCM_IS_DEVICE (device), FALSE);
-
- /* no profile to load */
- if (priv->profiles->len == 0)
- goto out;
-
- /* if the profile was deleted */
- profile = g_ptr_array_index (priv->profiles, 0);
- ret = g_file_test (gcm_profile_get_filename (profile), G_FILE_TEST_EXISTS);
- if (!ret) {
- g_warning ("the file was deleted and can't be loaded: %s", gcm_profile_get_filename (profile));
- /* this is not fatal */
- ret = TRUE;
- goto out;
- }
-out:
- return ret;
-}
-
-/**
* gcm_device_get_kind:
**/
CdDeviceKind
@@ -735,338 +706,6 @@ gcm_device_get_modified_time (GcmDevice *device)
}
/**
- * gcm_device_load:
- **/
-gboolean
-gcm_device_load (GcmDevice *device, GError **error)
-{
- gboolean ret;
- GKeyFile *file = NULL;
- GError *error_local = NULL;
- gchar *filename = NULL;
- GTimeVal timeval;
- gchar *iso_date = NULL;
- gchar **profile_filenames = NULL;
- guint i;
- GcmProfile *profile;
- GFile *file_tmp;
- GcmDevicePrivate *priv = device->priv;
-
- g_return_val_if_fail (GCM_IS_DEVICE (device), FALSE);
- g_return_val_if_fail (priv->id != NULL, FALSE);
-
- /* get default config */
- filename = gcm_utils_get_default_config_location ();
-
- /* check we have a config, or is this first start */
- ret = g_file_test (filename, G_FILE_TEST_EXISTS);
- if (!ret) {
- /* we have no profile to load from */
- ret = TRUE;
- goto out;
- }
-
- /* load existing file */
- file = g_key_file_new ();
- ret = g_key_file_load_from_file (file, filename, G_KEY_FILE_NONE, &error_local);
- if (!ret) {
- /* not fatal */
- g_error_free (error_local);
- ret = TRUE;
- goto out;
- }
-
- /* has key */
- ret = g_key_file_has_group (file, priv->id);
- if (!ret) {
- /* not fatal */
- g_debug ("failed to find saved parameters for %s", priv->id);
- ret = TRUE;
- goto out;
- }
-
- /* we are backed by a keyfile */
- gcm_device_set_saved (device, TRUE);
-
- /* load data */
- g_ptr_array_set_size (priv->profiles, 0);
-
- /* parse filenames to object, skipping entries that fail to parse */
- profile_filenames = g_key_file_get_string_list (file, priv->id, "profile", NULL, NULL);
- if (profile_filenames != NULL) {
- for (i=0; profile_filenames[i] != NULL; i++) {
- file_tmp = g_file_new_for_path (profile_filenames[i]);
- profile = gcm_profile_new ();
- ret = gcm_profile_parse (profile, file_tmp, &error_local);
- if (ret) {
- g_ptr_array_add (priv->profiles, g_object_ref (profile));
- } else {
- g_warning ("failed to parse %s: %s", profile_filenames[i], error_local->message);
- g_clear_error (&error_local);
- }
- g_object_unref (profile);
- g_object_unref (file_tmp);
- }
- }
-
- if (priv->serial == NULL)
- priv->serial = g_key_file_get_string (file, priv->id, "serial", NULL);
- if (priv->model == NULL)
- priv->model = g_key_file_get_string (file, priv->id, "model", NULL);
- if (priv->manufacturer == NULL)
- priv->manufacturer = g_key_file_get_string (file, priv->id, "manufacturer", NULL);
- priv->gamma = g_key_file_get_double (file, priv->id, "gamma", &error_local);
- if (error_local != NULL) {
- priv->gamma = 1;
- g_clear_error (&error_local);
- }
- priv->brightness = g_key_file_get_double (file, priv->id, "brightness", &error_local);
- if (error_local != NULL) {
- priv->brightness = 0.0f;
- g_clear_error (&error_local);
- }
- priv->contrast = g_key_file_get_double (file, priv->id, "contrast", &error_local);
- if (error_local != NULL) {
- priv->contrast = 100.0f;
- g_clear_error (&error_local);
- }
-
- /* get modified time */
- iso_date = g_key_file_get_string (file, priv->id, "modified", NULL);
- if (iso_date != NULL) {
- ret = g_time_val_from_iso8601 (iso_date, &timeval);
- if (!ret) {
- g_warning ("failed to parse: %s", iso_date);
- g_get_current_time (&timeval);
- }
- } else {
- /* just use the current time */
- g_get_current_time (&timeval);
- }
- priv->modified_time = timeval.tv_sec;
-
- /* should we load the virtual profile */
- priv->use_edid_profile = g_key_file_get_boolean (file, priv->id, "use-edid-profile", &error_local);
- if (error_local != NULL) {
- /* if the key does not exist, and this is a display,
- * then enable it by default */
- if (gcm_device_get_kind (device) == CD_DEVICE_KIND_DISPLAY)
- priv->use_edid_profile = TRUE;
- g_clear_error (&error_local);
- }
-
- /* load this */
- ret = gcm_device_load_from_default_profile (device, &error_local);
- if (!ret) {
-
- /* just print a warning, this is not fatal */
- g_warning ("failed to load profile %s", error_local->message);
- g_error_free (error_local);
-
- /* recover as the file might have been corrupted */
- g_ptr_array_set_size (priv->profiles, 0);
- ret = TRUE;
- }
-out:
- g_strfreev (profile_filenames);
- g_free (iso_date);
- g_free (filename);
- if (file != NULL)
- g_key_file_free (file);
- return ret;
-}
-
-/**
- * gcm_device_save:
- **/
-gboolean
-gcm_device_save (GcmDevice *device, GError **error)
-{
- GKeyFile *keyfile = NULL;
- guint i;
- gboolean ret;
- gchar *data = NULL;
- gchar *dirname;
- GFile *file = NULL;
- gchar *filename = NULL;
- gchar *timespec = NULL;
- gchar **profile_filenames;
- gchar *config_data = NULL;
- gchar **config_items = NULL;
- GError *error_local = NULL;
- GTimeVal timeval;
- GcmProfile *profile;
- GcmDevicePrivate *priv = device->priv;
- GcmDeviceClass *klass = GCM_DEVICE_GET_CLASS (device);
-
- g_return_val_if_fail (GCM_IS_DEVICE (device), FALSE);
- g_return_val_if_fail (priv->id != NULL, FALSE);
-
- /* get default config */
- filename = gcm_utils_get_default_config_location ();
-
- /* directory exists? */
- dirname = g_path_get_dirname (filename);
- ret = g_file_test (dirname, G_FILE_TEST_IS_DIR);
- if (!ret) {
- file = g_file_new_for_path (dirname);
- ret = g_file_make_directory_with_parents (file, NULL, &error_local);
- if (!ret) {
- g_set_error (error, 1, 0, "failed to create config directory: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* if not ever created, then just create a dummy file */
- ret = g_file_test (filename, G_FILE_TEST_EXISTS);
- if (!ret) {
- ret = g_file_set_contents (filename, "#created today", -1, &error_local);
- if (!ret) {
- g_set_error (error, 1, 0, "failed to create dummy header: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* load existing file */
- keyfile = g_key_file_new ();
- ret = g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, &error_local);
- if (!ret) {
- /* empty or corrupt */
- if (error_local->code == G_KEY_FILE_ERROR_PARSE) {
- /* ignore */
- g_clear_error (&error_local);
- } else {
- g_set_error (error, 1, 0, "failed to load existing config: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
- }
-
- /* get current date and time */
- g_get_current_time (&timeval);
- timespec = g_time_val_to_iso8601 (&timeval);
-
- /* the device does not have a created date and time */
- ret = g_key_file_has_key (keyfile, priv->id, "created", NULL);
- if (!ret)
- g_key_file_set_string (keyfile, priv->id, "created", timespec);
-
- /* add modified date */
- g_key_file_set_string (keyfile, priv->id, "modified", timespec);
-
- /* save data */
- if (priv->profiles->len == 0)
- g_key_file_remove_key (keyfile, priv->id, "profile", NULL);
- else {
- profile_filenames = g_new0 (gchar *, priv->profiles->len + 1);
- for (i=0; i<priv->profiles->len; i++) {
- profile = g_ptr_array_index (priv->profiles, i);
- profile_filenames[i] = g_strdup (gcm_profile_get_filename (profile));
- }
- g_key_file_set_string_list (keyfile, priv->id, "profile",
- (const gchar * const*) profile_filenames,
- priv->profiles->len);
- g_strfreev (profile_filenames);
- }
-
- /* save device specific data */
- if (priv->serial == NULL)
- g_key_file_remove_key (keyfile, priv->id, "serial", NULL);
- else
- g_key_file_set_string (keyfile, priv->id, "serial", priv->serial);
- if (priv->model == NULL)
- g_key_file_remove_key (keyfile, priv->id, "model", NULL);
- else
- g_key_file_set_string (keyfile, priv->id, "model", priv->model);
- if (priv->manufacturer == NULL)
- g_key_file_remove_key (keyfile, priv->id, "manufacturer", NULL);
- else
- g_key_file_set_string (keyfile, priv->id, "manufacturer", priv->manufacturer);
-
- /* only save gamma if not the default */
- if (priv->gamma > 0.99 && priv->gamma < 1.01)
- g_key_file_remove_key (keyfile, priv->id, "gamma", NULL);
- else
- g_key_file_set_double (keyfile, priv->id, "gamma", priv->gamma);
-
- /* only save brightness if not the default */
- if (priv->brightness > -0.01 && priv->brightness < 0.01)
- g_key_file_remove_key (keyfile, priv->id, "brightness", NULL);
- else
- g_key_file_set_double (keyfile, priv->id, "brightness", priv->brightness);
-
- /* only save contrast if not the default */
- if (priv->contrast > 99.9 && priv->contrast < 100.1)
- g_key_file_remove_key (keyfile, priv->id, "contrast", NULL);
- else
- g_key_file_set_double (keyfile, priv->id, "contrast", priv->contrast);
-
- /* save other properties we'll need if we add this device offline */
- if (priv->title != NULL)
- g_key_file_set_string (keyfile, priv->id, "title", priv->title);
- g_key_file_set_string (keyfile, priv->id, "type", cd_device_kind_to_string (priv->kind));
-
- /* add colorspace */
- g_key_file_set_string (keyfile, priv->id, "colorspace", gcm_colorspace_to_string (priv->colorspace));
-
- /* add virtual */
- if (priv->virtual)
- g_key_file_set_boolean (keyfile, priv->id, "virtual", TRUE);
-
- /* add use_edid_profile */
- if (priv->kind == CD_DEVICE_KIND_DISPLAY)
- g_key_file_set_boolean (keyfile, priv->id, "use-edid-profile", priv->use_edid_profile);
-
- /* get extra, device specific config data */
- if (klass->get_config_data != NULL) {
- config_data = klass->get_config_data (device);
- config_items = g_strsplit (config_data, "=", 2);
- if (g_strv_length (config_items) != 2) {
- ret = FALSE;
- g_set_error (error, 1, 0, "failed to get device specific config data for: %s", priv->id);
- goto out;
- }
-
- /* save unstructured data to the keyfile */
- g_key_file_set_string (keyfile, priv->id, config_items[0], config_items[1]);
- }
-
- /* convert to string */
- data = g_key_file_to_data (keyfile, NULL, &error_local);
- if (data == NULL) {
- ret = FALSE;
- g_set_error (error, 1, 0, "failed to convert config: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* save contents */
- ret = g_file_set_contents (filename, data, -1, &error_local);
- if (!ret) {
- g_set_error (error, 1, 0, "failed to save config: %s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* update status */
- gcm_device_set_saved (device, TRUE);
-out:
- g_strfreev (config_items);
- g_free (config_data);
- g_free (timespec);
- g_free (data);
- g_free (filename);
- g_free (dirname);
- if (file != NULL)
- g_object_unref (file);
- if (keyfile != NULL)
- g_key_file_free (keyfile);
- return ret;
-}
-
-/**
* gcm_device_apply:
**/
gboolean
diff --git a/src/gcm-device.h b/src/gcm-device.h
index 8ede217..4b857be 100644
--- a/src/gcm-device.h
+++ b/src/gcm-device.h
@@ -58,8 +58,6 @@ struct _GcmDeviceClass
GError **error);
GcmProfile *(*generate_profile) (GcmDevice *device,
GError **error);
- gchar *(*get_config_data) (GcmDevice *device);
- /* padding for future expansion */
void (*_gcm_reserved1) (void);
void (*_gcm_reserved2) (void);
void (*_gcm_reserved3) (void);
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index 26fd671..5cf6971 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -960,7 +960,7 @@ gcm_test_calibrate_native_func (void)
GcmX11Screen *screen;
GcmDevice *device;
gchar *contents;
- gchar *filename;
+ gchar *filename = NULL;
calibrate = gcm_calibrate_native_new ();
g_assert (calibrate != NULL);
@@ -973,7 +973,6 @@ gcm_test_calibrate_native_func (void)
client = gcm_client_new ();
g_assert (client != NULL);
g_setenv ("GCM_TEST", "1", TRUE);
- filename = gcm_utils_get_default_config_location ();
contents = g_strdup_printf ("[xrandr_hewlett_packard_hp_lp2480zx_3cm82200kv]\n"
"serial=3CM82200KV\n"
"model=HP LP2480zx\n"
@@ -985,10 +984,6 @@ gcm_test_calibrate_native_func (void)
g_assert_no_error (error);
g_assert (ret);
- ret = gcm_client_coldplug (client, GCM_CLIENT_COLDPLUG_SAVED, &error);
- g_assert_no_error (error);
- g_assert (ret);
-
device = gcm_client_get_device_by_id (client, "xrandr_hewlett_packard_hp_lp2480zx_3cm82200kv");
g_assert (device != NULL);
@@ -1183,10 +1178,6 @@ gcm_test_device_func (void)
g_assert_cmpstr (gcm_device_get_id (device), ==, "sysfs_dummy_device");
- /* ensure the file is nuked */
- filename = gcm_utils_get_default_config_location ();
- g_unlink (filename);
-
/* missing file */
ret = gcm_device_load (device, &error);
g_assert_no_error (error);
@@ -1510,12 +1501,6 @@ gcm_test_utils_func (void)
g_assert_cmpstr (filename, ==, "Hel lo__Wo-(r)ld_");
g_free (filename);
- /* get default config location (when in make check) */
- g_setenv ("GCM_TEST", "1", TRUE);
- filename = gcm_utils_get_default_config_location ();
- g_assert_cmpstr (filename, ==, "/tmp/device-profiles.conf");
- g_free (filename);
-
g_assert (gcm_utils_device_kind_to_profile_kind (CD_DEVICE_KIND_SCANNER) == CD_PROFILE_KIND_INPUT_DEVICE);
g_assert (gcm_utils_device_kind_to_profile_kind (CD_DEVICE_KIND_UNKNOWN) == CD_PROFILE_KIND_UNKNOWN);
}
@@ -1535,16 +1520,6 @@ gcm_test_client_func (void)
client = gcm_client_new ();
g_assert (client != NULL);
- /* ensure file is gone */
- g_setenv ("GCM_TEST", "1", TRUE);
- filename = gcm_utils_get_default_config_location ();
- g_unlink (filename);
-
- /* ensure we don't fail with no config file */
- ret = gcm_client_coldplug (client, GCM_CLIENT_COLDPLUG_SAVED, &error);
- g_assert_no_error (error);
- g_assert (ret);
-
array = gcm_client_get_devices (client);
g_assert (array != NULL);
g_assert_cmpint (array->len, ==, 0);
@@ -1561,10 +1536,6 @@ gcm_test_client_func (void)
g_assert_no_error (error);
g_assert (ret);
- ret = gcm_client_coldplug (client, GCM_CLIENT_COLDPLUG_SAVED, &error);
- g_assert_no_error (error);
- g_assert (ret);
-
array = gcm_client_get_devices (client);
g_assert (array != NULL);
g_assert_cmpint (array->len, ==, 1);
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index a83d327..a2d3a7d 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -441,25 +441,6 @@ gcm_utils_ensure_sensible_filename (gchar *data)
}
/**
- * gcm_utils_get_default_config_location:
- **/
-gchar *
-gcm_utils_get_default_config_location (void)
-{
- gchar *filename;
-
- if (g_getenv ("GCM_TEST") != NULL) {
- filename = g_strdup ("/tmp/device-profiles.conf");
- goto out;
- }
-
- /* create default path */
- filename = g_build_filename (g_get_user_config_dir (), "color", "device-profiles.conf", NULL);
-out:
- return filename;
-}
-
-/**
* gcm_utils_device_kind_to_profile_kind:
**/
CdProfileKind
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index 378b87b..720ae5a 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -72,7 +72,6 @@ gboolean gcm_utils_output_is_lcd_internal (const gchar *output_name);
gboolean gcm_utils_output_is_lcd (const gchar *output_name);
void gcm_utils_alphanum_lcase (gchar *string);
void gcm_utils_ensure_sensible_filename (gchar *string);
-gchar *gcm_utils_get_default_config_location (void);
CdProfileKind gcm_utils_device_kind_to_profile_kind (CdDeviceKind kind);
gboolean gcm_utils_install_package (const gchar *package_name,
GtkWindow *window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]