diff options
author | David Zeuthen <davidz@redhat.com> | 2011-05-27 14:08:54 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2011-05-27 14:08:54 -0400 |
commit | 695f81ff8ca23b0532c97902923ba203634406b7 (patch) | |
tree | 42b7cb854121c8993a96c79d111360895f8a59bd | |
parent | 8aae0af0a6b77327f9015b52b609dd2c680996bd (diff) |
Only read conf from ~/.config/goa-1.0/accounts.conf, not any dirs
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r-- | data/dbus-interfaces.xml | 6 | ||||
-rw-r--r-- | doc/goa-sections.txt | 4 | ||||
-rw-r--r-- | src/daemon/goadaemon.c | 57 | ||||
-rw-r--r-- | src/goabackend/goaprovider.c | 134 |
4 files changed, 94 insertions, 107 deletions
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml index b091efd..74e74b4 100644 --- a/data/dbus-interfaces.xml +++ b/data/dbus-interfaces.xml @@ -50,12 +50,6 @@ --> <property name="Id" type="s" access="read"/> - <!-- KeyfilePath: The path to the keyfile where the account is defined. --> - <property name="KeyfilePath" type="ay" access="read"/> - - <!-- KeyfileGroup: The group name in #org.gnome.OnlineAccounts.Account:KeyfilePath for the account. --> - <property name="KeyfileGroup" type="s" access="read"/> - <!-- AttentionNeeded: Set to %TRUE if the account is in need of attention. This is used when a human operator is needed to service the diff --git a/doc/goa-sections.txt b/doc/goa-sections.txt index eaa5e22..9089b9d 100644 --- a/doc/goa-sections.txt +++ b/doc/goa-sections.txt @@ -114,10 +114,6 @@ goa_account_get_identity goa_account_set_identity goa_account_get_presentation_identity goa_account_set_presentation_identity -goa_account_get_keyfile_group -goa_account_set_keyfile_group -goa_account_get_keyfile_path -goa_account_set_keyfile_path goa_account_call_ensure_credentials goa_account_call_ensure_credentials_finish goa_account_call_ensure_credentials_sync diff --git a/src/daemon/goadaemon.c b/src/daemon/goadaemon.c index 45d232b..6fc9102 100644 --- a/src/daemon/goadaemon.c +++ b/src/daemon/goadaemon.c @@ -23,8 +23,6 @@ /* TODO: * * - Document files, directories and file formats somewhere. - * - /etc/goa-1.0/accounts.conf.d/ - * - $HOME/.config/goa-1.0/accounts.conf.d/ * - $HOME/.config/goa-1.0/accounts.conf */ @@ -222,8 +220,8 @@ goa_daemon_init (GoaDaemon *daemon) g_dbus_object_manager_server_export (daemon->object_manager, G_DBUS_OBJECT_SKELETON (object)); g_object_unref (object); - /* create ~/.config/goa-1.0 and ~/.config/goa-1.0/accounts.conf.d directories */ - path = g_strdup_printf ("%s/goa-1.0/accounts.d", g_get_user_config_dir ()); + /* create ~/.config/goa-1.0 directory */ + path = g_strdup_printf ("%s/goa-1.0", g_get_user_config_dir ()); if (g_mkdir_with_parents (path, 0755) != 0) { /* TODO: syslog */ @@ -232,14 +230,6 @@ goa_daemon_init (GoaDaemon *daemon) g_free (path); /* set up file monitoring */ - daemon->system_conf_dir_monitor = create_monitor (PACKAGE_SYSCONF_DIR "/goa-1.0/accounts.conf.d", TRUE); - if (daemon->system_conf_dir_monitor != NULL) - g_signal_connect (daemon->system_conf_dir_monitor, "changed", G_CALLBACK (on_file_monitor_changed), daemon); - path = g_strdup_printf ("%s/goa-1.0/accounts.d", g_get_user_config_dir ()); - daemon->home_conf_dir_monitor = create_monitor (path, TRUE); - if (daemon->home_conf_dir_monitor != NULL) - g_signal_connect (daemon->home_conf_dir_monitor, "changed", G_CALLBACK (on_file_monitor_changed), daemon); - g_free (path); path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); daemon->home_conf_file_monitor = create_monitor (path, FALSE); if (daemon->home_conf_file_monitor != NULL) @@ -444,8 +434,6 @@ update_account_object (GoaDaemon *daemon, } goa_account_set_id (account, g_strrstr (g_dbus_object_get_object_path (G_DBUS_OBJECT (object)), "/") + 1); - goa_account_set_keyfile_path (account, path); - goa_account_set_keyfile_group (account, group); goa_account_set_provider_type (account, type); goa_account_set_identity (account, identity); goa_account_set_presentation_identity (account, presentation_identity); @@ -656,9 +644,7 @@ goa_daemon_reload_configuration (GoaDaemon *daemon) { GList *key_files_to_free; GHashTable *group_name_to_key_file_data; - GDir *dir; gchar *path; - gchar *dir_path; key_files_to_free = NULL; group_name_to_key_file_data = g_hash_table_new_full (g_str_hash, @@ -666,44 +652,7 @@ goa_daemon_reload_configuration (GoaDaemon *daemon) g_free, (GDestroyNotify) key_file_data_free); - /* First read system config files at /etc/goa-1.0/accounts.conf.d/ */ - dir_path = PACKAGE_SYSCONF_DIR "/goa-1.0/accounts.conf.d"; - dir = g_dir_open (dir_path, 0 /* flags */, NULL); - if (dir != NULL) - { - const gchar *name; - while ((name = g_dir_read_name (dir)) != NULL) - { - if (g_str_has_suffix (name, ".conf")) - { - path = g_strdup_printf ("%s/%s", dir_path, name); - add_config_file (path, group_name_to_key_file_data, &key_files_to_free); - g_free (path); - } - } - g_dir_close (dir); - } - - /* Then read user config files at $HOME/.config/goa-1.0/accounts.conf.d/ */ - dir_path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); - dir = g_dir_open (dir_path, 0 /* flags */, NULL); - if (dir != NULL) - { - const gchar *name; - while ((name = g_dir_read_name (dir)) != NULL) - { - if (g_str_has_suffix (name, ".conf")) - { - path = g_strdup_printf ("%s/%s", dir_path, name); - add_config_file (path, group_name_to_key_file_data, &key_files_to_free); - g_free (path); - } - } - g_dir_close (dir); - } - g_free (dir_path); - - /* Finally the main user config file at $HOME/.config/goa-1.0/accounts.conf */ + /* Read the main user config file at $HOME/.config/goa-1.0/accounts.conf */ path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); add_config_file (path, group_name_to_key_file_data, &key_files_to_free); g_free (path); diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c index e6fbe4c..66e62a8 100644 --- a/src/goabackend/goaprovider.c +++ b/src/goabackend/goaprovider.c @@ -878,27 +878,31 @@ goa_util_lookup_keyfile_string (GoaObject *object, GoaAccount *account; GError *error; GKeyFile *key_file; + gchar *path; + gchar *group; gchar *ret; ret = NULL; account = goa_object_peek_account (object); + path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); + group = g_strdup_printf ("Account %s", goa_account_get_id (account)); key_file = g_key_file_new (); error = NULL; if (!g_key_file_load_from_file (key_file, - goa_account_get_keyfile_path (account), + path, G_KEY_FILE_NONE, &error)) { goa_warning ("Error loading keyfile %s: %s (%s, %d)", - goa_account_get_keyfile_path (account), + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } ret = g_key_file_get_string (key_file, - goa_account_get_keyfile_group (account), + group, key, &error); if (ret == NULL) @@ -906,14 +910,16 @@ goa_util_lookup_keyfile_string (GoaObject *object, /* this is not fatal (think upgrade-path) */ goa_debug ("Error getting value for key %s in group `%s' from keyfile %s: %s (%s, %d)", key, - goa_account_get_keyfile_group (account), - goa_account_get_keyfile_path (account), + group, + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } out: + g_free (group); + g_free (path); return ret; } @@ -924,27 +930,31 @@ goa_util_lookup_keyfile_boolean (GoaObject *object, GoaAccount *account; GError *error; GKeyFile *key_file; + gchar *path; + gchar *group; gboolean ret; ret = FALSE; account = goa_object_peek_account (object); + path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); + group = g_strdup_printf ("Account %s", goa_account_get_id (account)); key_file = g_key_file_new (); error = NULL; if (!g_key_file_load_from_file (key_file, - goa_account_get_keyfile_path (account), + path, G_KEY_FILE_NONE, &error)) { goa_warning ("Error loading keyfile %s: %s (%s, %d)", - goa_account_get_keyfile_path (account), + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } ret = g_key_file_get_boolean (key_file, - goa_account_get_keyfile_group (account), + group, key, &error); if (error != NULL) @@ -952,14 +962,16 @@ goa_util_lookup_keyfile_boolean (GoaObject *object, /* this is not fatal (think upgrade-path) */ goa_debug ("Error getting boolean value for key %s in group `%s' from keyfile %s: %s (%s, %d)", key, - goa_account_get_keyfile_group (account), - goa_account_get_keyfile_path (account), + group, + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } out: + g_free (group); + g_free (path); return ret; } @@ -997,27 +1009,31 @@ keyfile_editable_on_editing_done (GtkEditable *editable, GoaAccount *account; GError *error; GKeyFile *key_file; + gchar *path; + gchar *group; gchar *contents; gsize length; account = goa_object_peek_account (data->object); + path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); + group = g_strdup_printf ("Account %s", goa_account_get_id (account)); key_file = g_key_file_new (); error = NULL; if (!g_key_file_load_from_file (key_file, - goa_account_get_keyfile_path (account), + path, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) { goa_warning ("Error loading keyfile %s: %s (%s, %d)", - goa_account_get_keyfile_path (account), + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } g_key_file_set_string (key_file, - goa_account_get_keyfile_group (account), + group, data->key, goa_editable_label_get_text (GOA_EDITABLE_LABEL (editable))); @@ -1029,7 +1045,7 @@ keyfile_editable_on_editing_done (GtkEditable *editable, { g_prefix_error (&error, "Error generating key-value-file %s: ", - goa_account_get_keyfile_path (account)); + path); goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); @@ -1037,14 +1053,14 @@ keyfile_editable_on_editing_done (GtkEditable *editable, } error = NULL; - if (!g_file_set_contents (goa_account_get_keyfile_path (account), + if (!g_file_set_contents (path, contents, length, &error)) { g_prefix_error (&error, "Error writing key-value-file %s: ", - goa_account_get_keyfile_path (account)); + path); goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); @@ -1053,6 +1069,8 @@ keyfile_editable_on_editing_done (GtkEditable *editable, out: g_key_file_free (key_file); + g_free (group); + g_free (path); } /** @@ -1079,6 +1097,8 @@ goa_util_add_row_editable_label_from_keyfile (GtkTable *table, GoaAccount *account; GtkWidget *elabel; GKeyFile *key_file; + gchar *path; + gchar *group; GError *error; gchar *value; @@ -1087,22 +1107,24 @@ goa_util_add_row_editable_label_from_keyfile (GtkTable *table, account = goa_object_peek_account (object); elabel = goa_editable_label_new (); + path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); + group = g_strdup_printf ("Account %s", goa_account_get_id (account)); key_file = g_key_file_new (); error = NULL; if (!g_key_file_load_from_file (key_file, - goa_account_get_keyfile_path (account), + path, G_KEY_FILE_NONE, &error)) { goa_warning ("Error loading keyfile %s: %s (%s, %d)", - goa_account_get_keyfile_path (account), + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } value = g_key_file_get_string (key_file, - goa_account_get_keyfile_group (account), + group, key, &error); if (value == NULL) @@ -1110,8 +1132,8 @@ goa_util_add_row_editable_label_from_keyfile (GtkTable *table, /* this is not fatal (think upgrade-path) */ goa_debug ("Error getting value for key %s in group `%s' from keyfile %s: %s (%s, %d)", key, - goa_account_get_keyfile_group (account), - goa_account_get_keyfile_path (account), + group, + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; @@ -1133,6 +1155,8 @@ goa_util_add_row_editable_label_from_keyfile (GtkTable *table, } g_free (value); + g_free (group); + g_free (path); if (key_file != NULL) g_key_file_free (key_file); return goa_util_add_row_widget (table, label_text, elabel); @@ -1149,27 +1173,31 @@ keyfile_switch_on_notify_active (GObject *object, GoaAccount *account; GError *error; GKeyFile *key_file; + gchar *path; + gchar *group; gchar *contents; gsize length; account = goa_object_peek_account (data->object); + path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); + group = g_strdup_printf ("Account %s", goa_account_get_id (account)); key_file = g_key_file_new (); error = NULL; if (!g_key_file_load_from_file (key_file, - goa_account_get_keyfile_path (account), + path, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) { goa_warning ("Error loading keyfile %s: %s (%s, %d)", - goa_account_get_keyfile_path (account), + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } g_key_file_set_boolean (key_file, - goa_account_get_keyfile_group (account), + group, data->key, gtk_switch_get_active (GTK_SWITCH (object))); @@ -1181,7 +1209,7 @@ keyfile_switch_on_notify_active (GObject *object, { g_prefix_error (&error, "Error generating key-value-file %s: ", - goa_account_get_keyfile_path (account)); + path); goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); @@ -1189,14 +1217,14 @@ keyfile_switch_on_notify_active (GObject *object, } error = NULL; - if (!g_file_set_contents (goa_account_get_keyfile_path (account), + if (!g_file_set_contents (path, contents, length, &error)) { g_prefix_error (&error, "Error writing key-value-file %s: ", - goa_account_get_keyfile_path (account)); + path); goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); @@ -1205,6 +1233,8 @@ keyfile_switch_on_notify_active (GObject *object, out: g_key_file_free (key_file); + g_free (group); + g_free (path); } /** @@ -1230,6 +1260,8 @@ goa_util_add_row_switch_from_keyfile (GtkTable *table, GtkWidget *hbox; GtkWidget *switch_; GKeyFile *key_file; + gchar *path; + gchar *group; GError *error; gboolean value; @@ -1237,22 +1269,24 @@ goa_util_add_row_switch_from_keyfile (GtkTable *table, account = goa_object_peek_account (object); switch_ = gtk_switch_new (); + path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); + group = g_strdup_printf ("Account %s", goa_account_get_id (account)); key_file = g_key_file_new (); error = NULL; if (!g_key_file_load_from_file (key_file, - goa_account_get_keyfile_path (account), + path, G_KEY_FILE_NONE, &error)) { goa_warning ("Error loading keyfile %s: %s (%s, %d)", - goa_account_get_keyfile_path (account), + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } value = g_key_file_get_boolean (key_file, - goa_account_get_keyfile_group (account), + group, key, &error); if (error != NULL) @@ -1260,8 +1294,8 @@ goa_util_add_row_switch_from_keyfile (GtkTable *table, /* this is not fatal (think upgrade-path) */ goa_debug ("Error getting boolean value for key %s in group `%s' from keyfile %s: %s (%s, %d)", key, - goa_account_get_keyfile_group (account), - goa_account_get_keyfile_path (account), + group, + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; @@ -1278,6 +1312,8 @@ goa_util_add_row_switch_from_keyfile (GtkTable *table, 0); /* GConnectFlags */ if (key_file != NULL) g_key_file_free (key_file); + g_free (group); + g_free (path); hbox = gtk_hbox_new (0, FALSE); gtk_box_pack_start (GTK_BOX (hbox), switch_, FALSE, TRUE, 0); @@ -1296,27 +1332,31 @@ keyfile_check_button_on_notify_active (GObject *object, GoaAccount *account; GError *error; GKeyFile *key_file; + gchar *path; + gchar *group; gchar *contents; gsize length; account = goa_object_peek_account (data->object); + path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); + group = g_strdup_printf ("Account %s", goa_account_get_id (account)); key_file = g_key_file_new (); error = NULL; if (!g_key_file_load_from_file (key_file, - goa_account_get_keyfile_path (account), + path, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) { goa_warning ("Error loading keyfile %s: %s (%s, %d)", - goa_account_get_keyfile_path (account), + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } g_key_file_set_boolean (key_file, - goa_account_get_keyfile_group (account), + group, data->key, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object))); @@ -1328,7 +1368,7 @@ keyfile_check_button_on_notify_active (GObject *object, { g_prefix_error (&error, "Error generating key-value-file %s: ", - goa_account_get_keyfile_path (account)); + path); goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); @@ -1336,14 +1376,14 @@ keyfile_check_button_on_notify_active (GObject *object, } error = NULL; - if (!g_file_set_contents (goa_account_get_keyfile_path (account), + if (!g_file_set_contents (path, contents, length, &error)) { g_prefix_error (&error, "Error writing key-value-file %s: ", - goa_account_get_keyfile_path (account)); + path); goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); @@ -1352,6 +1392,8 @@ keyfile_check_button_on_notify_active (GObject *object, out: g_key_file_free (key_file); + g_free (group); + g_free (path); } /** @@ -1378,6 +1420,8 @@ goa_util_add_row_check_button_from_keyfile (GtkTable *table, GoaAccount *account; GtkWidget *check_button; GKeyFile *key_file; + gchar *path; + gchar *group; GError *error; gboolean value; @@ -1385,22 +1429,24 @@ goa_util_add_row_check_button_from_keyfile (GtkTable *table, account = goa_object_peek_account (object); check_button = gtk_check_button_new_with_mnemonic (value_mnemonic); + path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ()); + group = g_strdup_printf ("Account %s", goa_account_get_id (account)); key_file = g_key_file_new (); error = NULL; if (!g_key_file_load_from_file (key_file, - goa_account_get_keyfile_path (account), + path, G_KEY_FILE_NONE, &error)) { goa_warning ("Error loading keyfile %s: %s (%s, %d)", - goa_account_get_keyfile_path (account), + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } value = g_key_file_get_boolean (key_file, - goa_account_get_keyfile_group (account), + group, key, &error); if (error != NULL) @@ -1408,8 +1454,8 @@ goa_util_add_row_check_button_from_keyfile (GtkTable *table, /* this is not fatal (think upgrade-path) */ goa_debug ("Error getting boolean value for key %s in group `%s' from keyfile %s: %s (%s, %d)", key, - goa_account_get_keyfile_group (account), - goa_account_get_keyfile_path (account), + group, + path, error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; @@ -1426,6 +1472,8 @@ goa_util_add_row_check_button_from_keyfile (GtkTable *table, 0); /* GConnectFlags */ if (key_file != NULL) g_key_file_free (key_file); + g_free (group); + g_free (path); return goa_util_add_row_widget (table, label_text, check_button); } |