diff options
author | Milan Crha <mcrha@redhat.com> | 2009-09-02 21:16:53 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-09-02 21:16:53 +0800 |
commit | 633b40bea15ee55df754cd0a23fc848b9ddd3372 (patch) | |
tree | bc29b0ccc8ba040384888ec8583c05fcfbb0b3af /modules | |
parent | 8962868ff902e58456c545478e62796029d1fe5c (diff) | |
download | gsoc2013-evolution-633b40bea15ee55df754cd0a23fc848b9ddd3372.tar gsoc2013-evolution-633b40bea15ee55df754cd0a23fc848b9ddd3372.tar.gz gsoc2013-evolution-633b40bea15ee55df754cd0a23fc848b9ddd3372.tar.bz2 gsoc2013-evolution-633b40bea15ee55df754cd0a23fc848b9ddd3372.tar.lz gsoc2013-evolution-633b40bea15ee55df754cd0a23fc848b9ddd3372.tar.xz gsoc2013-evolution-633b40bea15ee55df754cd0a23fc848b9ddd3372.tar.zst gsoc2013-evolution-633b40bea15ee55df754cd0a23fc848b9ddd3372.zip |
Bug #593761 - Wrong dir for calendar local sources
- using _get_data_dir, not _get_config_dir in calendar's and similar
ensure_sources functions
- current executable version is stored in gconf, thus not every start is
migrating done
- applied changes which were using e_source_list_ensure_group calls
- e_source_list_sync is called at the end of those ensure_sources, as it
didn't work to me to see the Personal source after start when I had
no "On this computer" group (the group was added, but the source wasn't)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/calendar/e-cal-shell-backend.c | 116 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-migrate.c | 4 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-backend.c | 68 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-migrate.c | 2 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-backend.c | 66 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-migrate.c | 4 |
6 files changed, 77 insertions, 183 deletions
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c index bb59356dae..4707ddb4b3 100644 --- a/modules/calendar/e-cal-shell-backend.c +++ b/modules/calendar/e-cal-shell-backend.c @@ -76,24 +76,17 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend) ECalShellBackendPrivate *priv; ESourceGroup *on_this_computer; - ESourceGroup *on_the_web; ESourceGroup *contacts; - ESourceGroup *weather; ESource *birthdays; ESource *personal; EShell *shell; EShellSettings *shell_settings; - GSList *groups, *iter; - const gchar *data_dir; - const gchar *name; - gchar *base_uri; + const gchar *data_dir, *name; + gchar *base_uri, base_uri_seventh; gchar *filename; gchar *property; + gboolean save_list = FALSE; - on_this_computer = NULL; - on_the_web = NULL; - contacts = NULL; - weather = NULL; birthdays = NULL; personal = NULL; @@ -112,41 +105,28 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend) base_uri = g_filename_to_uri (filename, NULL, NULL); g_free (filename); - groups = e_source_list_peek_groups (priv->source_list); - for (iter = groups; iter != NULL; iter = iter->next) { - ESourceGroup *source_group = iter->data; - const gchar *group_base_uri; - - group_base_uri = e_source_group_peek_base_uri (source_group); - - /* Compare only "file://" part. if the user's home - * changes, we do not want to create another group. */ - if (on_this_computer == NULL && - strncmp (base_uri, group_base_uri, 7) == 0) - on_this_computer = source_group; - - else if (on_the_web == NULL && - strcmp (WEB_BASE_URI, group_base_uri) == 0) - on_the_web = source_group; + if (strlen (base_uri) > 7) { + /* compare only file:// part. If user home dir name changes we do not want to create + one more group */ + base_uri_seventh = base_uri[7]; + base_uri[7] = 0; + } else { + base_uri_seventh = -1; + } - else if (contacts == NULL && - strcmp (CONTACTS_BASE_URI, group_base_uri) == 0) - contacts = source_group; + on_this_computer = e_source_list_ensure_group (priv->source_list, _("On This Computer"), base_uri, TRUE); + contacts = e_source_list_ensure_group (priv->source_list, _("Contacts"), CONTACTS_BASE_URI, TRUE); + e_source_list_ensure_group (priv->source_list, _("On The Web"), WEB_BASE_URI, FALSE); + e_source_list_ensure_group (priv->source_list, _("Weather"), WEATHER_BASE_URI, FALSE); - else if (weather == NULL && - strcmp (WEATHER_BASE_URI, group_base_uri) == 0) - weather = source_group; + if (base_uri_seventh != -1) { + base_uri[7] = base_uri_seventh; } - name = _("On This Computer"); - if (on_this_computer != NULL) { - GSList *sources; + GSList *sources, *iter; const gchar *group_base_uri; - /* Force the group name to the current locale. */ - e_source_group_set_name (on_this_computer, name); - sources = e_source_group_peek_sources (on_this_computer); group_base_uri = e_source_group_peek_base_uri (on_this_computer); @@ -177,15 +157,8 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend) * but that happens in an idle loop and too late * to prevent the user from seeing a "Cannot * Open ... because of invalid URI" error. */ - e_source_list_sync (priv->source_list, NULL); + save_list = TRUE; } - - } else { - ESourceGroup *source_group; - - source_group = e_source_group_new (name, base_uri); - e_source_list_add_group (priv->source_list, source_group, -1); - g_object_unref (source_group); } name = _("Personal"); @@ -196,8 +169,10 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend) gchar *primary; source = e_source_new (name, PERSONAL_RELATIVE_URI); + e_source_set_color_spec (source, "#BECEDD"); e_source_group_add_source (on_this_computer, source, -1); g_object_unref (source); + save_list = TRUE; primary = e_shell_settings_get_string ( shell_settings, "cal-primary-calendar"); @@ -223,27 +198,9 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend) e_source_set_name (personal, name); } - name = _("On The Web"); - - if (on_the_web == NULL) { - ESourceGroup *source_group; - - source_group = e_source_group_new (name, WEB_BASE_URI); - e_source_list_add_group (priv->source_list, source_group, -1); - g_object_unref (source_group); - } else { - /* Force the group name to the current locale. */ - e_source_group_set_name (on_the_web, name); - } - - name = _("Contacts"); - if (contacts != NULL) { GSList *sources; - /* Force the group name to the current locale. */ - e_source_group_set_name (contacts, name); - sources = e_source_group_peek_sources (contacts); if (sources != NULL) { @@ -261,18 +218,10 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend) ESource *source = trash->data; e_source_group_remove_source (contacts, source); trash = g_slist_delete_link (trash, trash); + save_list = TRUE; } } - } else { - ESourceGroup *source_group; - - source_group = e_source_group_new (name, CONTACTS_BASE_URI); - e_source_list_add_group (priv->source_list, source_group, -1); - g_object_unref (source_group); - - /* This is now a borrowed reference. */ - contacts = source_group; } /* XXX e_source_group_get_property() returns a newly-allocated @@ -287,12 +236,11 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend) if (birthdays == NULL) { ESource *source; - const gchar *name; - name = _("Birthdays & Anniversaries"); source = e_source_new (name, "/"); e_source_group_add_source (contacts, source, -1); g_object_unref (source); + save_list = TRUE; /* This is now a borrowed reference. */ birthdays = source; @@ -307,20 +255,12 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend) if (e_source_peek_color_spec (birthdays) == NULL) e_source_set_color_spec (birthdays, "#DDBECE"); - name = _("Weather"); - - if (weather == NULL) { - ESourceGroup *source_group; - - source_group = e_source_group_new (name, WEATHER_BASE_URI); - e_source_list_add_group (priv->source_list, source_group, -1); - g_object_unref (source_group); - } else { - /* Force the group name to the current locale. */ - e_source_group_set_name (weather, name); - } - + g_object_unref (on_this_computer); + g_object_unref (contacts); g_free (base_uri); + + if (save_list) + e_source_list_sync (priv->source_list, NULL); } static void diff --git a/modules/calendar/e-cal-shell-migrate.c b/modules/calendar/e-cal-shell-migrate.c index 5ec9c99bf3..ea0e6aa751 100644 --- a/modules/calendar/e-cal-shell-migrate.c +++ b/modules/calendar/e-cal-shell-migrate.c @@ -513,7 +513,7 @@ create_calendar_sources (EShellBackend *shell_backend, shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); - base_dir = e_shell_backend_get_config_dir (shell_backend); + base_dir = e_shell_backend_get_data_dir (shell_backend); base_uri = g_build_filename (base_dir, "local", NULL); base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL); @@ -733,7 +733,7 @@ e_cal_shell_backend_migrate (EShellBackend *shell_backend, gchar *old_path, *new_path; old_path = g_build_filename (g_get_home_dir (), "evolution", "local", "Calendar", NULL); - new_path = g_build_filename (e_shell_backend_get_config_dir (shell_backend), + new_path = g_build_filename (e_shell_backend_get_data_dir (shell_backend), "local", "system", NULL); migrate_pilot_data ("calendar", "calendar", old_path, new_path); g_free (new_path); diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c index 6c6a36491c..90ecc916b1 100644 --- a/modules/calendar/e-memo-shell-backend.c +++ b/modules/calendar/e-memo-shell-backend.c @@ -69,18 +69,15 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend) EMemoShellBackendPrivate *priv; ESourceGroup *on_this_computer; - ESourceGroup *on_the_web; ESource *personal; EShell *shell; EShellSettings *shell_settings; - GSList *groups, *iter; const gchar *data_dir; const gchar *name; - gchar *base_uri; + gchar *base_uri, base_uri_seventh; gchar *filename; + gboolean save_list = FALSE; - on_this_computer = NULL; - on_the_web = NULL; personal = NULL; priv = E_MEMO_SHELL_BACKEND_GET_PRIVATE (shell_backend); @@ -98,33 +95,26 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend) base_uri = g_filename_to_uri (filename, NULL, NULL); g_free (filename); - groups = e_source_list_peek_groups (priv->source_list); - for (iter = groups; iter != NULL; iter = iter->next) { - ESourceGroup *source_group = iter->data; - const gchar *group_base_uri; - - group_base_uri = e_source_group_peek_base_uri (source_group); + if (strlen (base_uri) > 7) { + /* compare only file:// part. If user home dir name changes we do not want to create + one more group */ + base_uri_seventh = base_uri[7]; + base_uri[7] = 0; + } else { + base_uri_seventh = -1; + } - /* Compare only "file://" part. If the user's home - * changes, we do not want to create another group. */ - if (on_this_computer == NULL && - strncmp (base_uri, group_base_uri, 7) == 0) - on_this_computer = source_group; + on_this_computer = e_source_list_ensure_group (priv->source_list, _("On This Computer"), base_uri, TRUE); + e_source_list_ensure_group (priv->source_list, _("On The Web"), WEB_BASE_URI, FALSE); - else if (on_the_web == NULL && - strcmp (WEB_BASE_URI, group_base_uri) == 0) - on_the_web = source_group; + if (base_uri_seventh != -1) { + base_uri[7] = base_uri_seventh; } - name = _("On This Computer"); - if (on_this_computer != NULL) { - GSList *sources; + GSList *sources, *iter; const gchar *group_base_uri; - /* Force the group name to the current locale. */ - e_source_group_set_name (on_this_computer, name); - sources = e_source_group_peek_sources (on_this_computer); group_base_uri = e_source_group_peek_base_uri (on_this_computer); @@ -155,15 +145,8 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend) * but that happens in an idle loop and too late * to prevent the user from seeing a "Cannot * Open ... because of invalid URI" error. */ - e_source_list_sync (priv->source_list, NULL); + save_list = TRUE; } - - } else { - ESourceGroup *source_group; - - source_group = e_source_group_new (name, base_uri); - e_source_list_add_group (priv->source_list, source_group, -1); - g_object_unref (source_group); } name = _("Personal"); @@ -174,8 +157,10 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend) gchar *primary; source = e_source_new (name, PERSONAL_RELATIVE_URI); + e_source_set_color_spec (source, "#BECEDD"); e_source_group_add_source (on_this_computer, source, -1); g_object_unref (source); + save_list = TRUE; primary = e_shell_settings_get_string ( shell_settings, "cal-primary-memo-list"); @@ -201,20 +186,11 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend) e_source_set_name (personal, name); } - name = _("On The Web"); - - if (on_the_web == NULL) { - ESourceGroup *source_group; - - source_group = e_source_group_new (name, WEB_BASE_URI); - e_source_list_add_group (priv->source_list, source_group, -1); - g_object_unref (source_group); - } else { - /* Force the group name to the current locale. */ - e_source_group_set_name (on_the_web, name); - } - + g_object_unref (on_this_computer); g_free (base_uri); + + if (save_list) + e_source_list_sync (priv->source_list, NULL); } static void diff --git a/modules/calendar/e-memo-shell-migrate.c b/modules/calendar/e-memo-shell-migrate.c index 3bcf3156a5..c2e4689576 100644 --- a/modules/calendar/e-memo-shell-migrate.c +++ b/modules/calendar/e-memo-shell-migrate.c @@ -59,7 +59,7 @@ create_memo_sources (EShellBackend *shell_backend, shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); - base_dir = e_shell_backend_get_config_dir (shell_backend); + base_dir = e_shell_backend_get_data_dir (shell_backend); base_uri = g_build_filename (base_dir, "local", NULL); base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL); diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c index 59a87e653c..756aca6a39 100644 --- a/modules/calendar/e-task-shell-backend.c +++ b/modules/calendar/e-task-shell-backend.c @@ -71,18 +71,16 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend) ETaskShellBackendPrivate *priv; ESourceGroup *on_this_computer; - ESourceGroup *on_the_web; ESource *personal; EShell *shell; EShellSettings *shell_settings; - GSList *groups, *iter; const gchar *data_dir; const gchar *name; - gchar *base_uri; + gchar *base_uri, base_uri_seventh; gchar *filename; + gboolean save_list = FALSE; on_this_computer = NULL; - on_the_web = NULL; personal = NULL; priv = E_TASK_SHELL_BACKEND_GET_PRIVATE (shell_backend); @@ -100,33 +98,26 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend) base_uri = g_filename_to_uri (filename, NULL, NULL); g_free (filename); - groups = e_source_list_peek_groups (priv->source_list); - for (iter = groups; iter != NULL; iter = iter->next) { - ESourceGroup *source_group = iter->data; - const gchar *group_base_uri; - - group_base_uri = e_source_group_peek_base_uri (source_group); + if (strlen (base_uri) > 7) { + /* compare only file:// part. If user home dir name changes we do not want to create + one more group */ + base_uri_seventh = base_uri[7]; + base_uri[7] = 0; + } else { + base_uri_seventh = -1; + } - /* Compare only "file://" part. If the user's home - * changes, we do not want to create another group. */ - if (on_this_computer == NULL && - strncmp (base_uri, group_base_uri, 7) == 0) - on_this_computer = source_group; + on_this_computer = e_source_list_ensure_group (priv->source_list, _("On This Computer"), base_uri, TRUE); + e_source_list_ensure_group (priv->source_list, _("On The Web"), WEB_BASE_URI, FALSE); - else if (on_the_web == NULL && - strcmp (WEB_BASE_URI, group_base_uri) == 0) - on_the_web = source_group; + if (base_uri_seventh != -1) { + base_uri[7] = base_uri_seventh; } - name = _("On This Computer"); - if (on_this_computer != NULL) { - GSList *sources; + GSList *sources, *iter; const gchar *group_base_uri; - /* Force the group name to the current locale. */ - e_source_group_set_name (on_this_computer, name); - sources = e_source_group_peek_sources (on_this_computer); group_base_uri = e_source_group_peek_base_uri (on_this_computer); @@ -157,15 +148,9 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend) * but that happens in an idle loop and too late * to prevent the user from seeing a "Cannot * Open ... because of invalid URI" error. */ - e_source_list_sync (priv->source_list, NULL); + save_list = TRUE; } - } else { - ESourceGroup *source_group; - - source_group = e_source_group_new (name, base_uri); - e_source_list_add_group (priv->source_list, source_group, -1); - g_object_unref (source_group); } name = _("Personal"); @@ -176,8 +161,10 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend) gchar *primary; source = e_source_new (name, PERSONAL_RELATIVE_URI); + e_source_set_color_spec (source, "#BECEDD"); e_source_group_add_source (on_this_computer, source, -1); g_object_unref (source); + save_list = TRUE; primary = e_shell_settings_get_string ( shell_settings, "cal-primary-task-list"); @@ -203,20 +190,11 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend) e_source_set_name (personal, name); } - name = _("On The Web"); - - if (on_the_web == NULL) { - ESourceGroup *source_group; - - source_group = e_source_group_new (name, WEB_BASE_URI); - e_source_list_add_group (priv->source_list, source_group, -1); - g_object_unref (source_group); - } else { - /* Force the group name to the current locale. */ - e_source_group_set_name (on_the_web, name); - } - + g_object_unref (on_this_computer); g_free (base_uri); + + if (save_list) + e_source_list_sync (priv->source_list, NULL); } static void diff --git a/modules/calendar/e-task-shell-migrate.c b/modules/calendar/e-task-shell-migrate.c index 799298f5a7..3ba36ce9b1 100644 --- a/modules/calendar/e-task-shell-migrate.c +++ b/modules/calendar/e-task-shell-migrate.c @@ -458,7 +458,7 @@ create_task_sources (EShellBackend *shell_backend, shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); - base_dir = e_shell_backend_get_config_dir (shell_backend); + base_dir = e_shell_backend_get_data_dir (shell_backend); base_uri = g_build_filename (base_dir, "local", NULL); base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL); @@ -634,7 +634,7 @@ e_task_shell_backend_migrate (EShellBackend *shell_backend, gchar *old_path, *new_path; old_path = g_build_filename (g_get_home_dir (), "evolution", "local", "Tasks", NULL); - new_path = g_build_filename (e_shell_backend_get_config_dir (shell_backend), + new_path = g_build_filename (e_shell_backend_get_data_dir (shell_backend), "local", "system", NULL); migrate_pilot_data ("tasks", "todo", old_path, new_path); g_free (new_path); |