diff options
author | Milan Crha <mcrha@redhat.com> | 2009-07-17 21:50:23 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-07-17 21:50:23 +0800 |
commit | 303ced5b758696c33477494c74e97d37d13aa12e (patch) | |
tree | cb715cf97404d96efaa2d06b6d47c2fa6259948c | |
parent | 143695d07f3f23a82b5cb8f7f60ae777e91a3b6c (diff) | |
download | gsoc2013-evolution-303ced5b758696c33477494c74e97d37d13aa12e.tar gsoc2013-evolution-303ced5b758696c33477494c74e97d37d13aa12e.tar.gz gsoc2013-evolution-303ced5b758696c33477494c74e97d37d13aa12e.tar.bz2 gsoc2013-evolution-303ced5b758696c33477494c74e97d37d13aa12e.tar.lz gsoc2013-evolution-303ced5b758696c33477494c74e97d37d13aa12e.tar.xz gsoc2013-evolution-303ced5b758696c33477494c74e97d37d13aa12e.tar.zst gsoc2013-evolution-303ced5b758696c33477494c74e97d37d13aa12e.zip |
Bug #588856 - Migration code for Google by CalDAV calendar
-rw-r--r-- | plugins/google-account-setup/Makefile.am | 6 | ||||
-rw-r--r-- | plugins/google-account-setup/google-source.c | 66 | ||||
-rw-r--r-- | plugins/google-account-setup/org-gnome-evolution-google.eplug.xml | 4 |
3 files changed, 62 insertions, 14 deletions
diff --git a/plugins/google-account-setup/Makefile.am b/plugins/google-account-setup/Makefile.am index ed452c0bc7..67a7c2c152 100644 --- a/plugins/google-account-setup/Makefile.am +++ b/plugins/google-account-setup/Makefile.am @@ -1,6 +1,7 @@ AM_CPPFLAGS = \ -I . \ -I$(top_srcdir) \ + -I$(top_builddir)/shell \ -DCALDAV_GLADEDIR=\""$(gladedir)"\" \ $(EVOLUTION_CALENDAR_CFLAGS) \ $(EVOLUTION_ADDRESSBOOK_CFLAGS) @@ -15,8 +16,9 @@ liborg_gnome_evolution_google_la_SOURCES = \ google-contacts-source.h \ google-contacts-source.c -liborg_gnome_evolution_google_la_LIBADD = \ - $(EVOLUTION_CALENDAR_LIBS) \ +liborg_gnome_evolution_google_la_LIBADD = \ + $(top_builddir)/calendar/gui/libevolution-calendar.la \ + $(EVOLUTION_CALENDAR_LIBS) \ $(EPLUGIN_LIBS) liborg_gnome_evolution_google_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) diff --git a/plugins/google-account-setup/google-source.c b/plugins/google-account-setup/google-source.c index c3cfde8ff2..2a8b6c46e5 100644 --- a/plugins/google-account-setup/google-source.c +++ b/plugins/google-account-setup/google-source.c @@ -36,6 +36,8 @@ #include <e-util/e-plugin.h> #include <calendar/gui/e-cal-config.h> +#include <calendar/gui/e-cal-event.h> +#include <calendar/gui/calendar-component.h> #include <libedataserver/e-url.h> #include <libedataserver/e-account-list.h> @@ -49,6 +51,7 @@ #include "google-contacts-source.h" +#define GOOGLE_BASE_URI "google://" #define CALENDAR_LOCATION "://www.google.com/calendar/feeds/" #define CALENDAR_DEFAULT_PATH "/private/full" #define URL_GET_SUBSCRIBED_CALENDARS "://www.google.com/calendar/feeds/default/allcalendars/full" @@ -58,11 +61,9 @@ /*****************************************************************************/ /* prototypes */ -gint e_plugin_lib_enable (EPluginLib *ep, - gint enable); - -GtkWidget * plugin_google (EPlugin *epl, - EConfigHookItemFactoryData *data); +gint e_plugin_lib_enable (EPluginLib *ep, gint enable); +GtkWidget *plugin_google (EPlugin *epl, EConfigHookItemFactoryData *data); +void e_calendar_google_migrate (EPlugin *epl, ECalEventTargetComponent *data); /*****************************************************************************/ /* plugin intialization */ @@ -77,7 +78,7 @@ ensure_google_source_group (void) return; } - e_source_list_ensure_group (slist, _("Google"), "google://", FALSE); + e_source_list_ensure_group (slist, _("Google"), GOOGLE_BASE_URI, FALSE); g_object_unref (slist); } @@ -247,18 +248,19 @@ update_source_uris (ESource *source, const gchar *uri) static void init_combo_values (GtkComboBox *combo, const gchar *deftitle, const gchar *defuri); static void -user_changed (GtkEntry *editable, ESource *source) +update_user_in_source (ESource *source, const gchar *new_user) { - gchar *uri, *eml; - const gchar *user, *ssl; + gchar *uri, *eml, *user; + const gchar *ssl; + + /* to ensure it will not be freed before the work with it is done */ + user = g_strdup (new_user); /* two reasons why set readonly to FALSE: a) the e_source_set_relative_uri does nothing for readonly sources b) we are going to set default uri, which should be always writeable */ e_source_set_readonly (source, FALSE); - user = gtk_entry_get_text (GTK_ENTRY (editable)); - if (user && *user) { /* store the non-encoded email in the "username" property */ if (strstr (user, "@") == NULL && strstr (user, "%40") == NULL) @@ -288,6 +290,13 @@ user_changed (GtkEntry *editable, ESource *source) e_source_set_property (source, "auth-domain", NULL); g_free (eml); + g_free (user); +} + +static void +user_changed (GtkEntry *editable, ESource *source) +{ + update_user_in_source (source, gtk_entry_get_text (GTK_ENTRY (editable))); /* we changed user, thus reset the chosen calendar combo too, because other user means other calendars subscribed */ @@ -644,7 +653,7 @@ plugin_google (EPlugin *epl, group = e_source_peek_group (source); widget = NULL; - if (g_ascii_strncasecmp ("google://", e_source_group_peek_base_uri (group), 9) != 0) { + if (g_ascii_strncasecmp (GOOGLE_BASE_URI, e_source_group_peek_base_uri (group), strlen (GOOGLE_BASE_URI)) != 0) { return NULL; } @@ -774,3 +783,36 @@ plugin_google (EPlugin *epl, return widget; } + +void +e_calendar_google_migrate (EPlugin *epl, ECalEventTargetComponent *data) +{ + CalendarComponent *component; + ESourceList *source_list; + ESourceGroup *google = NULL; + gboolean changed = FALSE; + + component = data->component; + source_list = calendar_component_peek_source_list (component); + + google = e_source_list_peek_group_by_base_uri (source_list, GOOGLE_BASE_URI); + if (google) { + GSList *s; + + for (s = e_source_group_peek_sources (google); s; s = s->next) { + ESource *source = E_SOURCE (s->data); + + if (!source) + continue; + + /* new source through CalDAV uses absolute uri, thus it should be migrated if not set */ + if (!e_source_peek_absolute_uri (source)) { + update_user_in_source (source, e_source_get_property (source, "username")); + changed = TRUE; + } + } + } + + if (changed) + e_source_list_sync (source_list, NULL); +} diff --git a/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml b/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml index 42b84d58fa..afccbd3fb7 100644 --- a/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml +++ b/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml @@ -11,6 +11,10 @@ <item type="item_table" path="00.general/00.source/15.google" factory="plugin_google"/> </group> </hook> + <hook class="org.gnome.evolution.calendar.events:1.0"> + <event target="component" id="component.migration" handle="e_calendar_google_migrate"/> + </hook> + <hook class="org.gnome.evolution.addressbook.config:1.0"> <group target="source" id="com.novell.evolution.addressbook.config.accountEditor"> <item type="item" path="00.general/10.display/00.google" factory="plugin_google_contacts"/> |