[evolution/gnome-3-32] I#474 - [ESource Editors] Invalid URL: field value reset on User: field change



commit 0f959eccb69ba497650c0637d1bffce0243a8793
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jun 7 17:29:20 2019 +0200

    I#474 - [ESource Editors] Invalid URL: field value reset on User: field change
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/474

 .../evolution-book-config-carddav.c                | 20 ++++++++++--
 .../evolution-cal-config-caldav.c                  | 28 ++++++++++++-----
 .../evolution-cal-config-webcal.c                  | 36 ++++++++++++++++------
 3 files changed, 64 insertions(+), 20 deletions(-)
---
diff --git a/src/modules/book-config-carddav/evolution-book-config-carddav.c 
b/src/modules/book-config-carddav/evolution-book-config-carddav.c
index d97e50e963..85ef417bc0 100644
--- a/src/modules/book-config-carddav/evolution-book-config-carddav.c
+++ b/src/modules/book-config-carddav/evolution-book-config-carddav.c
@@ -168,7 +168,21 @@ book_config_carddav_uri_to_text (GBinding *binding,
        soup_uri = g_value_get_boxed (source_value);
        soup_uri_set_user (soup_uri, NULL);
 
-       text = soup_uri_to_string (soup_uri, FALSE);
+       if (soup_uri_get_host (soup_uri)) {
+               text = soup_uri_to_string (soup_uri, FALSE);
+       } else {
+               GObject *target;
+
+               text = NULL;
+               target = g_binding_get_target (binding);
+               g_object_get (target, g_binding_get_target_property (binding), &text, NULL);
+
+               if (!text || !*text) {
+                       g_free (text);
+                       text = soup_uri_to_string (soup_uri, FALSE);
+               }
+       }
+
        g_value_take_string (target_value, text);
 
        return TRUE;
@@ -191,8 +205,8 @@ book_config_carddav_text_to_uri (GBinding *binding,
        text = g_value_get_string (source_value);
        soup_uri = soup_uri_new (text);
 
-       if (soup_uri == NULL)
-               return FALSE;
+       if (!soup_uri)
+               soup_uri = soup_uri_new ("http://";);
 
        source_binding = g_binding_get_source (binding);
        source = e_source_extension_ref_source (
diff --git a/src/modules/cal-config-caldav/evolution-cal-config-caldav.c 
b/src/modules/cal-config-caldav/evolution-cal-config-caldav.c
index 6b5ed89fc5..8260a8456c 100644
--- a/src/modules/cal-config-caldav/evolution-cal-config-caldav.c
+++ b/src/modules/cal-config-caldav/evolution-cal-config-caldav.c
@@ -221,7 +221,21 @@ cal_config_caldav_uri_to_text (GBinding *binding,
        soup_uri = g_value_get_boxed (source_value);
        soup_uri_set_user (soup_uri, NULL);
 
-       text = soup_uri_to_string (soup_uri, FALSE);
+       if (soup_uri_get_host (soup_uri)) {
+               text = soup_uri_to_string (soup_uri, FALSE);
+       } else {
+               GObject *target;
+
+               text = NULL;
+               target = g_binding_get_target (binding);
+               g_object_get (target, g_binding_get_target_property (binding), &text, NULL);
+
+               if (!text || !*text) {
+                       g_free (text);
+                       text = soup_uri_to_string (soup_uri, FALSE);
+               }
+       }
+
        g_value_take_string (target_value, text);
 
        return TRUE;
@@ -243,8 +257,8 @@ cal_config_caldav_text_to_uri (GBinding *binding,
        text = g_value_get_string (source_value);
        soup_uri = soup_uri_new (text);
 
-       if (soup_uri == NULL)
-               return FALSE;
+       if (!soup_uri)
+               soup_uri = soup_uri_new ("http://";);
 
        source = E_SOURCE (user_data);
        extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
@@ -409,13 +423,13 @@ cal_config_caldav_check_complete (ESourceConfigBackend *backend,
        uri_string = gtk_entry_get_text (GTK_ENTRY (context->url_entry));
        soup_uri = soup_uri_new (uri_string);
 
-       if (!soup_uri) {
-               complete = FALSE;
-       } else {
+       if (soup_uri) {
                if (g_strcmp0 (soup_uri_get_scheme (soup_uri), "caldav") == 0)
                        soup_uri_set_scheme (soup_uri, SOUP_URI_SCHEME_HTTP);
 
-               complete = SOUP_URI_VALID_FOR_HTTP (soup_uri);
+               complete = soup_uri_get_host (soup_uri) && SOUP_URI_VALID_FOR_HTTP (soup_uri);
+       } else {
+               complete = FALSE;
        }
 
        if (soup_uri != NULL)
diff --git a/src/modules/cal-config-webcal/evolution-cal-config-webcal.c 
b/src/modules/cal-config-webcal/evolution-cal-config-webcal.c
index f24f94f463..78235ad1b0 100644
--- a/src/modules/cal-config-webcal/evolution-cal-config-webcal.c
+++ b/src/modules/cal-config-webcal/evolution-cal-config-webcal.c
@@ -64,7 +64,21 @@ cal_config_webcal_uri_to_text (GBinding *binding,
        soup_uri = g_value_get_boxed (source_value);
        soup_uri_set_user (soup_uri, NULL);
 
-       text = soup_uri_to_string (soup_uri, FALSE);
+       if (soup_uri_get_host (soup_uri)) {
+               text = soup_uri_to_string (soup_uri, FALSE);
+       } else {
+               GObject *target;
+
+               text = NULL;
+               target = g_binding_get_target (binding);
+               g_object_get (target, g_binding_get_target_property (binding), &text, NULL);
+
+               if (!text || !*text) {
+                       g_free (text);
+                       text = soup_uri_to_string (soup_uri, FALSE);
+               }
+       }
+
        g_value_take_string (target_value, text);
 
        return TRUE;
@@ -86,8 +100,8 @@ cal_config_webcal_text_to_uri (GBinding *binding,
        text = g_value_get_string (source_value);
        soup_uri = soup_uri_new (text);
 
-       if (soup_uri == NULL)
-               return FALSE;
+       if (!soup_uri)
+               soup_uri = soup_uri_new ("http://";);
 
        source = E_SOURCE (user_data);
        extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
@@ -158,7 +172,6 @@ cal_config_webcal_check_complete (ESourceConfigBackend *backend,
        GtkEntry *entry;
        Context *context;
        const gchar *uri_string;
-       const gchar *scheme;
        const gchar *uid;
        gboolean complete;
 
@@ -171,13 +184,16 @@ cal_config_webcal_check_complete (ESourceConfigBackend *backend,
 
        soup_uri = soup_uri_new (uri_string);
 
-       /* XXX webcal:// is a non-standard scheme, but we accept it.
-        *     Just convert it to http:// for the URI validity test. */
-       scheme = soup_uri_get_scheme (soup_uri);
-       if (g_strcmp0 (scheme, "webcal") == 0)
-               soup_uri_set_scheme (soup_uri, SOUP_URI_SCHEME_HTTP);
+       if (soup_uri) {
+               /* XXX webcal:// is a non-standard scheme, but we accept it.
+                *     Just convert it to http:// for the URI validity test. */
+               if (g_strcmp0 (soup_uri_get_scheme (soup_uri), "webcal") == 0)
+                       soup_uri_set_scheme (soup_uri, SOUP_URI_SCHEME_HTTP);
 
-       complete = SOUP_URI_VALID_FOR_HTTP (soup_uri);
+               complete = soup_uri_get_host (soup_uri) && SOUP_URI_VALID_FOR_HTTP (soup_uri);
+       } else {
+               complete = FALSE;
+       }
 
        if (soup_uri != NULL)
                soup_uri_free (soup_uri);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]