aboutsummaryrefslogtreecommitdiffstats
path: root/modules/cal-config-google/e-google-chooser.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2013-05-07 19:27:24 +0800
committerMilan Crha <mcrha@redhat.com>2013-05-07 19:27:24 +0800
commit0ccccead12fae581ea9be349154928c1215896d5 (patch)
treea6e81d33d4c0d4f317e81c1049ad614fc8e44a3e /modules/cal-config-google/e-google-chooser.c
parentb254ea37eff47973b076fcf9345f80215ae5c978 (diff)
downloadgsoc2013-evolution-0ccccead12fae581ea9be349154928c1215896d5.tar
gsoc2013-evolution-0ccccead12fae581ea9be349154928c1215896d5.tar.gz
gsoc2013-evolution-0ccccead12fae581ea9be349154928c1215896d5.tar.bz2
gsoc2013-evolution-0ccccead12fae581ea9be349154928c1215896d5.tar.lz
gsoc2013-evolution-0ccccead12fae581ea9be349154928c1215896d5.tar.xz
gsoc2013-evolution-0ccccead12fae581ea9be349154928c1215896d5.tar.zst
gsoc2013-evolution-0ccccead12fae581ea9be349154928c1215896d5.zip
Newly configured Google calendar cannot be opened
Unless the button to choose a calendar was clicked, because the calendar path is not filled, thus the server claims "HTTP 405 error", which means an OPTIONS request cannot be done on the path, which was just root of www.google.com, instead of a calendar path. (This was reported as part of bug #659522.)
Diffstat (limited to 'modules/cal-config-google/e-google-chooser.c')
-rw-r--r--modules/cal-config-google/e-google-chooser.c70
1 files changed, 48 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);
+}