aboutsummaryrefslogtreecommitdiffstats
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
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.)
-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");