aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2004-01-16 01:15:19 +0800
committerJP Rosevear <jpr@src.gnome.org>2004-01-16 01:15:19 +0800
commitc1f42ab2b0820cd1b52dc75ab1e7dfdaae6d604c (patch)
tree34fb84945b4a87679325241024f5a8723ca3c881
parent6dc6126ad803ecb3465a3f429078f36544182900 (diff)
downloadgsoc2013-evolution-c1f42ab2b0820cd1b52dc75ab1e7dfdaae6d604c.tar
gsoc2013-evolution-c1f42ab2b0820cd1b52dc75ab1e7dfdaae6d604c.tar.gz
gsoc2013-evolution-c1f42ab2b0820cd1b52dc75ab1e7dfdaae6d604c.tar.bz2
gsoc2013-evolution-c1f42ab2b0820cd1b52dc75ab1e7dfdaae6d604c.tar.lz
gsoc2013-evolution-c1f42ab2b0820cd1b52dc75ab1e7dfdaae6d604c.tar.xz
gsoc2013-evolution-c1f42ab2b0820cd1b52dc75ab1e7dfdaae6d604c.tar.zst
gsoc2013-evolution-c1f42ab2b0820cd1b52dc75ab1e7dfdaae6d604c.zip
update protos
2004-01-15 JP Rosevear <jpr@ximian.com> * gui/tasks-component.h: update protos * gui/tasks-component.c (impl_finalize): free base dir (impl_upgradeFromVersion): just call migrate_tasks (tasks_component_init): set base dir value (tasks_component_peek_base_directory): accessor (tasks_component_peek_source_list): ditto * gui/migration.c (process_old_dir): look for a source with the name and fallback to creating it (create_calendar_contact_source): create the contacts:// source (create_calendar_sources): use above and create all the necessary sources (create_task_sources): create all the necessary sources (migrate_calendars): do all the migration logic here, upgrade bonobo-conf to gconf (migrate_tasks): ditto * gui/calendar-component.h: update prototypes * gui/calendar-component.c (impl_finalize): free the base directory (impl_upgradeFromVersion): just call migrate_calendars (calendar_component_init): fill in base dir value (calendar_component_peek_base_directory): accessor (calendar_component_peek_source_list): ditto svn path=/trunk/; revision=24248
-rw-r--r--calendar/ChangeLog29
-rw-r--r--calendar/gui/calendar-component.c82
-rw-r--r--calendar/gui/calendar-component.h1
-rw-r--r--calendar/gui/migration.c361
-rw-r--r--calendar/gui/migration.h6
-rw-r--r--calendar/gui/tasks-component.c61
-rw-r--r--calendar/gui/tasks-component.h4
7 files changed, 402 insertions, 142 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 2ffd29ef11..cb5da772b1 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,32 @@
+2004-01-15 JP Rosevear <jpr@ximian.com>
+
+ * gui/tasks-component.h: update protos
+
+ * gui/tasks-component.c (impl_finalize): free base dir
+ (impl_upgradeFromVersion): just call migrate_tasks
+ (tasks_component_init): set base dir value
+ (tasks_component_peek_base_directory): accessor
+ (tasks_component_peek_source_list): ditto
+
+ * gui/migration.c (process_old_dir): look for a source with the
+ name and fallback to creating it
+ (create_calendar_contact_source): create the contacts:// source
+ (create_calendar_sources): use above and create all the necessary
+ sources
+ (create_task_sources): create all the necessary sources
+ (migrate_calendars): do all the migration logic here, upgrade
+ bonobo-conf to gconf
+ (migrate_tasks): ditto
+
+ * gui/calendar-component.h: update prototypes
+
+ * gui/calendar-component.c (impl_finalize): free the base
+ directory
+ (impl_upgradeFromVersion): just call migrate_calendars
+ (calendar_component_init): fill in base dir value
+ (calendar_component_peek_base_directory): accessor
+ (calendar_component_peek_source_list): ditto
+
2004-01-15 Radek Doulik <rodo@ximian.com>
* gui/calendar-component.c (create_new_event): test priv->calendar
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index 19fe36ff17..2158f2a32d 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -59,6 +59,7 @@
static BonoboObjectClass *parent_class = NULL;
struct _CalendarComponentPrivate {
+ char *base_directory;
char *config_directory;
GConfClient *gconf_client;
@@ -449,8 +450,8 @@ impl_finalize (GObject *object)
{
CalendarComponentPrivate *priv = CALENDAR_COMPONENT (object)->priv;
+ g_free (priv->base_directory);
g_free (priv->config_directory);
-
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
@@ -466,73 +467,9 @@ impl_upgradeFromVersion (PortableServer_Servant servant,
CORBA_short revision,
CORBA_Environment *ev)
{
- CalendarComponentPrivate *priv;
- GSList *groups;
- ESourceGroup *group;
- ESource *source;
- char *base_uri, *new_dir;
CalendarComponent *calendar_component = CALENDAR_COMPONENT (bonobo_object_from_servant (servant));
- priv = calendar_component->priv;
-
- base_uri = g_build_filename (g_get_home_dir (),
- "/.evolution/calendar/local/OnThisComputer/",
- NULL);
-
- /* create default calendars if there are no groups */
- groups = e_source_list_peek_groups (priv->source_list);
- if (!groups) {
- /* create the local source group */
- group = e_source_group_new (_("On This Computer"), base_uri);
- e_source_list_add_group (priv->source_list, group, -1);
-
- /* create the remote source group */
- group = e_source_group_new (_("On The Web"), "webcal://");
- e_source_list_add_group (priv->source_list, group, -1);
- e_source_list_sync (priv->source_list, NULL);
- }
-
- if (major == 1 && minor <= 4) {
- group = e_source_list_peek_group_by_name (priv->source_list, _("On This Computer"));
-
- /* migrate calendars from 1.4 setup */
- if (!migrate_old_calendars (group)) {
- /* create default calendars */
- new_dir = g_build_filename (base_uri, "Personal/", NULL);
- if (!e_mkdir_hier (new_dir, 0700)) {
- source = e_source_new (_("Personal"), "Personal");
- e_source_group_add_source (group, source, -1);
- }
- g_free (new_dir);
-
- new_dir = g_build_filename (base_uri, "Work/", NULL);
- if (!e_mkdir_hier (new_dir, 0700)) {
- source = e_source_new (_("Work"), "Work");
- e_source_group_add_source (group, source, -1);
- }
- g_free (new_dir);
- }
-
- /* create the remote source group */
- group = e_source_group_new (_("On The Web"), "webcal://");
- e_source_list_add_group (priv->source_list, group, -1);
-
- e_source_list_sync (priv->source_list, NULL);
- }
-
- /* create calendar for birthdays & anniversaries */
- if ((major < 0) ||
- ((major == 1) && (minor < 5)) ||
- ((major == 1) && (minor == 5) && (revision < 2))) {
- group = e_source_group_new (_("Contacts"), "contacts://");
- source = e_source_new (_("Birthdays & Anniversaries"), "/");
- e_source_group_add_source (group, source, -1);
- e_source_group_set_readonly (group, TRUE);
- e_source_list_add_group (priv->source_list, group, -1);
- e_source_list_sync (priv->source_list, NULL);
- }
-
- g_free (base_uri);
+ migrate_calendars (calendar_component, major, minor, revision);
return CORBA_TRUE;
}
@@ -848,6 +785,7 @@ calendar_component_init (CalendarComponent *component)
priv = g_new0 (CalendarComponentPrivate, 1);
+ priv->base_directory = g_build_filename (g_get_home_dir (), ".evolution", NULL);
priv->config_directory = g_build_filename (g_get_home_dir (),
".evolution", "calendar", "config",
NULL);
@@ -888,11 +826,23 @@ calendar_component_peek (void)
}
const char *
+calendar_component_peek_base_directory (CalendarComponent *component)
+{
+ return component->priv->base_directory;
+}
+
+const char *
calendar_component_peek_config_directory (CalendarComponent *component)
{
return component->priv->config_directory;
}
+ESourceList *
+calendar_component_peek_source_list (CalendarComponent *component)
+{
+ return component->priv->source_list;
+}
+
EActivityHandler *
calendar_component_peek_activity_handler (CalendarComponent *component)
{
diff --git a/calendar/gui/calendar-component.h b/calendar/gui/calendar-component.h
index 49ad267cec..1ddadf6857 100644
--- a/calendar/gui/calendar-component.h
+++ b/calendar/gui/calendar-component.h
@@ -59,6 +59,7 @@ GType calendar_component_get_type (void);
CalendarComponent *calendar_component_peek (void);
+const char *calendar_component_peek_base_directory (CalendarComponent *component);
const char *calendar_component_peek_config_directory (CalendarComponent *component);
ESourceList *calendar_component_peek_source_list (CalendarComponent *component);
EActivityHandler *calendar_component_peek_activity_handler (CalendarComponent *component);
diff --git a/calendar/gui/migration.c b/calendar/gui/migration.c
index 2809b59313..599fea59b6 100644
--- a/calendar/gui/migration.c
+++ b/calendar/gui/migration.c
@@ -24,8 +24,87 @@
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-xfer.h>
#include <gal/util/e-util.h>
+#include <e-util/e-bconf-map.h>
#include "migration.h"
+static e_gconf_map_t calendar_display_map[] = {
+ /* /Calendar/Display */
+ { "Timezone", "calendar/display/timezone", E_GCONF_MAP_STRING },
+ { "Use24HourFormat", "calendar/display/use_24hour_format", E_GCONF_MAP_BOOL },
+ { "WeekStartDay", "calendar/display/week_start_day", E_GCONF_MAP_INT },
+ { "DayStartHour", "calendar/display/day_start_hour", E_GCONF_MAP_INT },
+ { "DayStartMinute", "calendar/display/day_start_minute", E_GCONF_MAP_INT },
+ { "DayEndHour", "calendar/display/day_end_hour", E_GCONF_MAP_INT },
+ { "DayEndMinute", "calendar/display/day_end_minute", E_GCONF_MAP_INT },
+ { "TimeDivisions", "calendar/display/time_divisions", E_GCONF_MAP_INT },
+ { "View", "calendar/display/default_view", E_GCONF_MAP_INT },
+ { "HPanePosition", "calendar/display/hpane_position", E_GCONF_MAP_FLOAT },
+ { "VPanePosition", "calendar/display/vpane_position", E_GCONF_MAP_FLOAT },
+ { "MonthHPanePosition", "calendar/display/month_hpane_position", E_GCONF_MAP_FLOAT },
+ { "MonthVPanePosition", "calendar/display/month_vpane_position", E_GCONF_MAP_FLOAT },
+ { "CompressWeekend", "calendar/display/compress_weekend", E_GCONF_MAP_BOOL },
+ { "ShowEventEndTime", "calendar/display/show_event_end", E_GCONF_MAP_BOOL },
+ { "WorkingDays", "calendar/display/working_days", E_GCONF_MAP_INT },
+ { 0 },
+};
+
+static e_gconf_map_t calendar_tasks_map[] = {
+ /* /Calendar/Tasks */
+ { "HideCompletedTasks", "calendar/tasks/hide_completed", E_GCONF_MAP_BOOL },
+ { "HideCompletedTasksUnits", "calendar/tasks/hide_completed_units", E_GCONF_MAP_STRING },
+ { "HideCompletedTasksValue", "calendar/tasks/hide_completed_value", E_GCONF_MAP_INT },
+ { 0 },
+};
+
+static e_gconf_map_t calendar_tasks_colours_map[] = {
+ /* /Calendar/Tasks/Colors */
+ { "TasksDueToday", "calendar/tasks/colors/due_today", E_GCONF_MAP_STRING },
+ { "TasksOverDue", "calendar/tasks/colors/overdue", E_GCONF_MAP_STRING },
+ { "TasksDueToday", "calendar/tasks/colors/due_today", E_GCONF_MAP_STRING },
+ { 0 },
+};
+
+static e_gconf_map_t calendar_other_map[] = {
+ /* /Calendar/Other */
+ { "ConfirmDelete", "calendar/prompts/confirm_delete", E_GCONF_MAP_BOOL },
+ { "ConfirmExpunge", "calendar/prompts/confirm_expunge", E_GCONF_MAP_BOOL },
+ { "UseDefaultReminder", "calendar/other/use_default_reminder", E_GCONF_MAP_BOOL },
+ { "DefaultReminderInterval", "calendar/other/default_reminder_interval", E_GCONF_MAP_INT },
+ { "DefaultReminderUnits", "calendar/other/default_reminder_units", E_GCONF_MAP_STRING },
+ { 0 },
+};
+
+static e_gconf_map_t calendar_datenavigator_map[] = {
+ /* /Calendar/DateNavigator */
+ { "ShowWeekNumbers", "calendar/date_navigator/show_week_numbers", E_GCONF_MAP_BOOL },
+ { 0 },
+};
+
+static e_gconf_map_t calendar_alarmnotify_map[] = {
+ /* /Calendar/AlarmNotify */
+ { "LastNotificationTime", "calendar/notify/last_notification_time", E_GCONF_MAP_INT },
+ { "CalendarToLoad%i", "calendar/notify/calendars", E_GCONF_MAP_STRING|E_GCONF_MAP_LIST },
+ { "BlessedProgram%i", "calendar/notify/programs", E_GCONF_MAP_STRING|E_GCONF_MAP_LIST },
+ { 0 },
+};
+
+e_gconf_map_list_t calendar_remap_list[] = {
+
+ { "/Calendar/Display", calendar_display_map },
+ { "/Calendar/Other/Map", calendar_other_map },
+ { "/Calendar/DateNavigator", calendar_datenavigator_map },
+ { "/Calendar/AlarmNotify", calendar_alarmnotify_map },
+
+ { 0 },
+};
+
+e_gconf_map_list_t task_remap_list[] = {
+
+ { "/Calendar/Tasks", calendar_tasks_map },
+ { "/Calendar/Tasks/Colors", calendar_tasks_colours_map },
+
+ { 0 },
+};
static gboolean
process_old_dir (ESourceGroup *source_group, const char *path,
@@ -76,8 +155,10 @@ process_old_dir (ESourceGroup *source_group, const char *path,
if (vres != GNOME_VFS_OK)
return FALSE;
- /* create the new source */
- source = e_source_new (name, base_uri);
+ /* Find the default source we create or create a new source */
+ source = e_source_group_peek_source_by_name (source_group, name);
+ if (!source)
+ source = e_source_new (name, base_uri);
e_source_group_add_source (source_group, source, -1);
/* process subfolders */
@@ -104,48 +185,266 @@ process_old_dir (ESourceGroup *source_group, const char *path,
return retval;
}
-gboolean
-migrate_old_calendars (ESourceGroup *source_group)
+static ESourceGroup *
+create_calendar_contact_source (ESourceList *source_list)
+{
+ ESourceGroup *group;
+ ESource *source;
+
+ /* Create the contacts group */
+ group = e_source_group_new (_("Contacts"), "contacts://");
+ e_source_group_set_readonly (group, TRUE);
+ e_source_list_add_group (source_list, group, -1);
+
+ source = e_source_new (_("Birthdays & Anniversaries"), "/");
+ e_source_group_add_source (group, source, -1);
+ g_object_unref (source);
+
+ return group;
+}
+
+static gboolean
+create_calendar_sources (CalendarComponent *component,
+ ESourceList *source_list,
+ ESourceGroup **on_this_computer,
+ ESourceGroup **on_the_web,
+ ESourceGroup **contacts)
{
- char *path;
- gboolean retval;
+ GSList *groups;
+
+ groups = e_source_list_peek_groups (source_list);
+ if (groups) {
+ /* groups are already there, we need to search for things... */
+ g_warning ("can't migrate when existing groups are present");
+ return FALSE;
+ } else {
+ ESourceGroup *group;
+ ESource *source;
+ char *base_uri, *base_uri_proto, *new_dir;
+
+ /* Create the local source group */
+ base_uri = g_build_filename (calendar_component_peek_base_directory (component),
+ "/calendar/local/OnThisComputer/",
+ NULL);
+
+ base_uri_proto = g_strconcat ("file://", base_uri, NULL);
+
+ group = e_source_group_new (_("On This Computer"), base_uri_proto);
+ e_source_list_add_group (source_list, group, -1);
+
+ if (on_this_computer)
+ *on_this_computer = group;
+ else
+ g_object_unref (group);
+
+ g_free (base_uri_proto);
+
+ /* Create default calendar */
+ new_dir = g_build_filename (base_uri, "Personal/", NULL);
+ if (!e_mkdir_hier (new_dir, 0700)) {
+ source = e_source_new (_("Personal"), "Personal");
+ e_source_group_add_source (group, source, -1);
+ g_object_unref (source);
+ }
+ g_free (new_dir);
+
+ g_free (base_uri);
- g_return_val_if_fail (E_IS_SOURCE_GROUP (source_group), FALSE);
+ /* Create the web group */
+ group = e_source_group_new (_("On The Web"), "webcal://");
+ e_source_list_add_group (source_list, group, -1);
- path = g_build_filename (g_get_home_dir (), "evolution", NULL);
- if (!g_file_test (path, G_FILE_TEST_IS_DIR)) {
- g_free (path);
- return FALSE;
+ if (on_the_web)
+ *on_the_web = group;
+ else
+ g_object_unref (group);
+
+ /* Create the contact group */
+ group = create_calendar_contact_source (source_list);
+ if (contacts)
+ *contacts = group;
+ else
+ g_object_unref (group);
}
- g_free (path);
- /* look for the top-level calendar */
- path = g_build_filename (g_get_home_dir (), "evolution/local/Calendar", NULL);
- retval = process_old_dir (source_group, path, "calendar.ics", _("Personal"), "Personal");
- g_free (path);
-
- return retval;
+ return TRUE;
+}
+
+static gboolean
+create_task_sources (TasksComponent *component,
+ ESourceList *source_list,
+ ESourceGroup **on_this_computer)
+{
+ GSList *groups;
+
+ groups = e_source_list_peek_groups (source_list);
+ if (groups) {
+ /* groups are already there, we need to search for things... */
+ g_warning ("can't migrate when existing groups are present");
+ return FALSE;
+ } else {
+ ESourceGroup *group;
+ ESource *source;
+ char *base_uri, *base_uri_proto, *new_dir;
+
+ /* create the local source group */
+ base_uri = g_build_filename (tasks_component_peek_base_directory (component),
+ "/tasks/local/OnThisComputer/",
+ NULL);
+
+ base_uri_proto = g_strconcat ("file://", base_uri, NULL);
+
+ group = e_source_group_new (_("On This Computer"), base_uri_proto);
+ e_source_list_add_group (source_list, group, -1);
+
+ if (on_this_computer)
+ *on_this_computer = group;
+ else
+ g_object_unref (group);
+
+ g_free (base_uri_proto);
+
+ /* Create default task list */
+ new_dir = g_build_filename (base_uri, "Personal/", NULL);
+ if (!e_mkdir_hier (new_dir, 0700)) {
+ source = e_source_new (_("Personal"), "Personal");
+ e_source_group_add_source (group, source, -1);
+ g_object_unref (source);
+ }
+ g_free (new_dir);
+
+ g_free (base_uri);
+ }
+
+ return TRUE;
}
gboolean
-migrate_old_tasks (ESourceGroup *source_group)
+migrate_calendars (CalendarComponent *component, int major, int minor, int revision)
{
- char *path;
- gboolean retval;
+ gboolean retval = TRUE;
+
+ if (major == 0 && minor == 0 && revision == 0)
+ return create_calendar_sources (component, calendar_component_peek_source_list (component), NULL, NULL, NULL);
- g_return_val_if_fail (E_IS_SOURCE_GROUP (source_group), FALSE);
+ if (major == 1) {
+ xmlDocPtr config_doc = NULL;
+ char *conf_file;
+ struct stat st;
+
+ conf_file = g_build_filename (g_get_home_dir (), "evolution", "config.xmldb", NULL);
+ if (lstat (conf_file, &st) == 0 && S_ISREG (st.st_mode))
+ config_doc = xmlParseFile (conf_file);
+ g_free (conf_file);
+
+ if (config_doc && minor <= 2) {
+ GConfClient *gconf;
+ int res = 0;
+
+ /* move bonobo config to gconf */
+ gconf = gconf_client_get_default ();
+
+ res = e_bconf_import (gconf, config_doc, calendar_remap_list);
+
+ g_object_unref (gconf);
+
+ xmlFreeDoc(config_doc);
+
+ if (res != 0) {
+ g_warning("Could not move config from bonobo-conf to gconf");
+ return FALSE;
+ }
+ }
+
+ if (minor <= 4) {
+ ESourceGroup *on_this_computer;
+ char *path;
+
+ if (!create_calendar_sources (component, calendar_component_peek_source_list (component), &on_this_computer, NULL, NULL))
+ return FALSE;
+
+ /* FIXME Look for all top level calendars */
+ path = g_build_filename (g_get_home_dir (), "evolution/local/Calendar", NULL);
+ if (!g_file_test (path, G_FILE_TEST_IS_DIR)) {
+ g_free (path);
+ return FALSE;
+ }
+ retval = process_old_dir (on_this_computer, path, "calendar.ics", _("Personal"), "Personal");
+ g_free (path);
+
+ e_source_list_sync (calendar_component_peek_source_list (component), NULL);
+ }
+
+ if (minor == 5 && revision < 2) {
+ ESourceGroup *group;
+
+ group = create_calendar_contact_source (calendar_component_peek_source_list (component));
+ g_object_unref (group);
+
+ e_source_list_sync (calendar_component_peek_source_list (component), NULL);
+ }
- path = g_build_filename (g_get_home_dir (), "evolution", NULL);
- if (!g_file_test (path, G_FILE_TEST_IS_DIR)) {
- g_free (path);
- return FALSE;
}
- g_free (path);
- /* look for the top-level calendar */
- path = g_build_filename (g_get_home_dir (), "evolution/local/Tasks", NULL);
- retval = process_old_dir (source_group, path, "tasks.ics", _("Personal"), "Personal");
- g_free (path);
+ return retval;
+}
+
+gboolean
+migrate_tasks (TasksComponent *component, int major, int minor, int revision)
+{
+ gboolean retval = TRUE;
+
+ if (major == 0 && minor == 0 && revision == 0)
+ return create_task_sources (component, tasks_component_peek_source_list (component), NULL);
+
+ if (major == 1) {
+ xmlDocPtr config_doc = NULL;
+ char *conf_file;
+ struct stat st;
+
+ conf_file = g_build_filename (g_get_home_dir (), "evolution", "config.xmldb", NULL);
+ if (lstat (conf_file, &st) == 0 && S_ISREG (st.st_mode))
+ config_doc = xmlParseFile (conf_file);
+ g_free (conf_file);
+
+ if (config_doc && minor <= 2) {
+ GConfClient *gconf;
+ int res = 0;
+
+ /* move bonobo config to gconf */
+ gconf = gconf_client_get_default ();
+
+ res = e_bconf_import (gconf, config_doc, task_remap_list);
+
+ g_object_unref (gconf);
+
+ xmlFreeDoc(config_doc);
+
+ if (res != 0) {
+ g_warning("Could not move config from bonobo-conf to gconf");
+ return FALSE;
+ }
+ }
+
+ if (minor <= 4) {
+ ESourceGroup *on_this_computer;
+ char *path;
+
+ if (!create_task_sources (component, tasks_component_peek_source_list (component), &on_this_computer))
+ return FALSE;
+
+ /* FIXME Look for all top level tasks */
+ path = g_build_filename (g_get_home_dir (), "evolution/local/Tasks", NULL);
+ if (!g_file_test (path, G_FILE_TEST_IS_DIR)) {
+ g_free (path);
+ return FALSE;
+ }
+ retval = process_old_dir (on_this_computer, path, "tasks.ics", _("Personal"), "Personal");
+ g_free (path);
+
+ e_source_list_sync (tasks_component_peek_source_list (component), NULL);
+ }
+ }
return retval;
}
diff --git a/calendar/gui/migration.h b/calendar/gui/migration.h
index b217ae97c8..b7047d0898 100644
--- a/calendar/gui/migration.h
+++ b/calendar/gui/migration.h
@@ -24,8 +24,10 @@
#define MIGRATION_H
#include <libedataserver/e-source-group.h>
+#include "calendar-component.h"
+#include "tasks-component.h"
-gboolean migrate_old_calendars (ESourceGroup *source_group);
-gboolean migrate_old_tasks (ESourceGroup *source_group);
+gboolean migrate_calendars (CalendarComponent *component, int major, int minor, int revision);
+gboolean migrate_tasks (TasksComponent *component, int major, int minor, int revision);
#endif
diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c
index 7aac4dae0c..9f0470773a 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -59,7 +59,9 @@ static BonoboObjectClass *parent_class = NULL;
extern ECompEditorRegistry *comp_editor_registry;
struct _TasksComponentPrivate {
+ char *base_directory;
char *config_directory;
+
GConfClient *gconf_client;
ESourceList *source_list;
@@ -474,6 +476,7 @@ impl_finalize (GObject *object)
{
TasksComponentPrivate *priv = TASKS_COMPONENT (object)->priv;
+ g_free (priv->base_directory);
g_free (priv->config_directory);
g_free (priv);
@@ -489,49 +492,9 @@ impl_upgradeFromVersion (PortableServer_Servant servant,
CORBA_short revision,
CORBA_Environment *ev)
{
- TasksComponentPrivate *priv;
- GSList *groups;
- ESourceGroup *group;
- ESource *source;
- char *base_uri, *new_dir;
TasksComponent *component = TASKS_COMPONENT (bonobo_object_from_servant (servant));
- priv = component->priv;
-
- base_uri = g_build_filename (g_get_home_dir (),
- ".evolution/tasks/local/OnThisComputer/",
- NULL);
-
- /* create default tasks folders if there are no groups */
- groups = e_source_list_peek_groups (priv->source_list);
- if (!groups) {
- /* create the source group */
- group = e_source_group_new (_("On This Computer"), base_uri);
- e_source_list_add_group (priv->source_list, group, -1);
- e_source_list_sync (priv->source_list, NULL);
- }
-
- if (major == 1 && minor <= 4) {
- group = e_source_list_peek_group_by_name (priv->source_list, _("On This Computer"));
-
- /* migrate tasks from older setup */
- if (!migrate_old_tasks (group)) {
- /* create default tasks folders */
- new_dir = g_build_filename (base_uri, "Personal/", NULL);
- if (!e_mkdir_hier (new_dir, 0700)) {
- source = e_source_new (_("Personal"), "Personal");
- e_source_group_add_source (group, source, -1);
- }
-
- g_free (new_dir);
- }
-
- e_source_list_sync (priv->source_list, NULL);
- }
-
- g_free (base_uri);
-
- return CORBA_TRUE;
+ return migrate_tasks (component, major, minor, revision);
}
static void
@@ -803,6 +766,8 @@ tasks_component_init (TasksComponent *component, TasksComponentClass *klass)
TasksComponentPrivate *priv;
priv = g_new0 (TasksComponentPrivate, 1);
+
+ priv->base_directory = g_build_filename (g_get_home_dir (), ".evolution", NULL);
priv->config_directory = g_build_filename (g_get_home_dir (),
".evolution", "tasks", "config",
NULL);
@@ -837,9 +802,21 @@ tasks_component_peek (void)
}
const char *
+tasks_component_peek_base_directory (TasksComponent *component)
+{
+ return component->priv->base_directory;
+}
+
+const char *
tasks_component_peek_config_directory (TasksComponent *component)
{
- return (const char *) component->priv->config_directory;
+ return component->priv->config_directory;
+}
+
+ESourceList *
+tasks_component_peek_source_list (TasksComponent *component)
+{
+ return component->priv->source_list;
}
BONOBO_TYPE_FUNC_FULL (TasksComponent, GNOME_Evolution_Component, PARENT_TYPE, tasks_component)
diff --git a/calendar/gui/tasks-component.h b/calendar/gui/tasks-component.h
index 5a015da4a1..1cdb0bdff1 100644
--- a/calendar/gui/tasks-component.h
+++ b/calendar/gui/tasks-component.h
@@ -54,7 +54,9 @@ struct _TasksComponentClass {
GType tasks_component_get_type (void);
TasksComponent *tasks_component_peek (void);
-const char *tasks_component_peek_config_directory (TasksComponent *component);
+
+const char *tasks_component_peek_base_directory (TasksComponent *component);
+const char *tasks_component_peek_config_directory (TasksComponent *component);
ESourceList *tasks_component_peek_source_list (TasksComponent *component);
#endif /* _TASKS_COMPONENT_H_ */