[evolution/gnome-3-8] Newly configured Google calendar cannot be opened
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-8] Newly configured Google calendar cannot be opened
- Date: Tue, 7 May 2013 11:33:03 +0000 (UTC)
commit 9d0632eb54ae1d5f4ae9c85d5131f57f6f20f4bc
Author: Milan Crha <mcrha redhat com>
Date: Tue May 7 13:32:41 2013 +0200
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.)
modules/cal-config-google/e-google-chooser.c | 70 +++++++++++++------
modules/cal-config-google/e-google-chooser.h | 4 +
.../evolution-cal-config-google.c | 8 ++
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 b51976f..1a4ebbc 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 8c97314..b43f358 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 97b4c7e..9f6310b 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");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]