aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/cal-config-google/e-google-chooser.c70
-rw-r--r--modules/cal-config-google/e-google-chooser.h4
-rw-r--r--modules/cal-config-google/evolution-cal-config-google.c8
3 files changed, 60 insertions, 22 deletions
diff --git a/modules/cal-config-google/e-google-chooser.c b/modules/cal-config-google/e-google-chooser.c
index b51976f048..1a4ebbcfb8 100644
--- a/modules/cal-config-google/e-google-chooser.c
+++ b/modules/cal-config-google/e-google-chooser.c
@@ -122,6 +122,34 @@ google_chooser_extract_caldav_events_path (const gchar *uri)
return path;
}
+static gchar *
+google_chooser_decode_user (const gchar *user)
+{
+ gchar *decoded_user;
+
+ if (user == NULL || *user == '\0')
+ return NULL;
+
+ /* Decode any encoded 'at' symbols ('%40' -> '@'). */
+ if (strstr (user, "%40") != NULL) {
+ gchar **segments;
+
+ segments = g_strsplit (user, "%40", 0);
+ decoded_user = g_strjoinv ("@", segments);
+ g_strfreev (segments);
+
+ /* If no domain is given, append "@gmail.com". */
+ } else if (strstr (user, "@") == NULL) {
+ decoded_user = g_strconcat (user, "@gmail.com", NULL);
+
+ /* Otherwise the user name should be fine as is. */
+ } else {
+ decoded_user = g_strdup (user);
+ }
+
+ return decoded_user;
+}
+
static void
google_chooser_set_source (EGoogleChooser *chooser,
ESource *source)
@@ -287,7 +315,6 @@ e_google_chooser_get_decoded_user (EGoogleChooser *chooser)
ESource *source;
ESourceAuthentication *authentication_extension;
const gchar *user;
- gchar *decoded_user;
g_return_val_if_fail (E_IS_GOOGLE_CHOOSER (chooser), NULL);
@@ -297,27 +324,7 @@ e_google_chooser_get_decoded_user (EGoogleChooser *chooser)
source, E_SOURCE_EXTENSION_AUTHENTICATION);
user = e_source_authentication_get_user (authentication_extension);
- if (user == NULL || *user == '\0')
- return NULL;
-
- /* Decode any encoded 'at' symbols ('%40' -> '@'). */
- if (strstr (user, "%40") != NULL) {
- gchar **segments;
-
- segments = g_strsplit (user, "%40", 0);
- decoded_user = g_strjoinv ("@", segments);
- g_strfreev (segments);
-
- /* If no domain is given, append "@gmail.com". */
- } else if (strstr (user, "@") == NULL) {
- decoded_user = g_strconcat (user, "@gmail.com", NULL);
-
- /* Otherwise the user name should be fine as is. */
- } else {
- decoded_user = g_strdup (user);
- }
-
- return decoded_user;
+ return google_chooser_decode_user (user);
}
static void
@@ -617,3 +624,22 @@ e_google_chooser_apply_selected (EGoogleChooser *chooser)
return TRUE;
}
+
+void
+e_google_chooser_construct_default_uri (SoupURI *soup_uri,
+ const gchar *username)
+{
+ gchar *decoded_user, *path;
+
+ decoded_user = google_chooser_decode_user (username);
+ if (!decoded_user)
+ return;
+
+ path = g_strdup_printf (CALDAV_EVENTS_PATH_FORMAT, decoded_user);
+
+ soup_uri_set_user (soup_uri, decoded_user);
+ soup_uri_set_path (soup_uri, path);
+
+ g_free (decoded_user);
+ g_free (path);
+}
diff --git a/modules/cal-config-google/e-google-chooser.h b/modules/cal-config-google/e-google-chooser.h
index 8c973142e9..b43f358221 100644
--- a/modules/cal-config-google/e-google-chooser.h
+++ b/modules/cal-config-google/e-google-chooser.h
@@ -73,4 +73,8 @@ gboolean e_google_chooser_populate_finish
GError **error);
gboolean e_google_chooser_apply_selected (EGoogleChooser *chooser);
+void e_google_chooser_construct_default_uri
+ (SoupURI *soup_uri,
+ const gchar *username);
+
#endif /* E_GOOGLE_CHOOSER_H */
diff --git a/modules/cal-config-google/evolution-cal-config-google.c b/modules/cal-config-google/evolution-cal-config-google.c
index 97b4c7eeea..9f6310b036 100644
--- a/modules/cal-config-google/evolution-cal-config-google.c
+++ b/modules/cal-config-google/evolution-cal-config-google.c
@@ -123,6 +123,14 @@ cal_config_google_commit_changes (ESourceConfigBackend *backend,
soup_uri = e_source_webdav_dup_soup_uri (webdav_extension);
+ if (!soup_uri->path || !*soup_uri->path || g_strcmp0 (soup_uri->path, "/") == 0) {
+ ESourceAuthentication *authentication_extension
+ = e_source_get_extension (scratch_source, E_SOURCE_EXTENSION_AUTHENTICATION);
+
+ e_google_chooser_construct_default_uri (soup_uri,
+ e_source_authentication_get_user (authentication_extension));
+ }
+
/* The host name is fixed, obviously. */
soup_uri_set_host (soup_uri, "www.google.com");