[evolution-data-server] source_webdav_user_to_method: Don't stomp on custom method names.



commit d905302db275759346d10c9e9ea679b33fbbb45f
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jul 9 11:35:39 2013 -0400

    source_webdav_user_to_method: Don't stomp on custom method names.
    
    This binding might have just been a bad idea on my part, but this
    should salvage it without breaking API behavior.

 libedataserver/e-source-webdav.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/libedataserver/e-source-webdav.c b/libedataserver/e-source-webdav.c
index 26e9729..c7e7f4f 100644
--- a/libedataserver/e-source-webdav.c
+++ b/libedataserver/e-source-webdav.c
@@ -108,15 +108,39 @@ source_webdav_user_to_method (GBinding *binding,
                               GValue *target_value,
                               gpointer user_data)
 {
+       GObject *target_object;
+       ESourceAuthentication *extension;
        const gchar *user;
+       gchar *method;
+       gboolean success = TRUE;
+
+       target_object = g_binding_get_target (binding);
+       extension = E_SOURCE_AUTHENTICATION (target_object);
+       method = e_source_authentication_dup_method (extension);
+       g_return_val_if_fail (method != NULL, FALSE);
+
+       /* Be careful not to stomp on a custom method name.
+        * Only change it under the following conditions:
+        *
+        * 1) If "user" is empty, set "method" to "none".
+        * 2) If "user" is not empty and "method" is "none",
+        *    set "method" to "plain/password" (corresponds
+        *    to HTTP Basic authentication).
+        * 3) Otherwise preserve the current "method" value.
+        */
 
        user = g_value_get_string (source_value);
-       if (user == NULL || *user == '\0')
+       if (user == NULL || *user == '\0') {
                g_value_set_string (target_value, "none");
-       else
+       } else if (g_str_equal (method, "none")) {
                g_value_set_string (target_value, "plain/password");
+       } else {
+               success = FALSE;
+       }
 
-       return TRUE;
+       g_free (method);
+
+       return success;
 }
 
 static void


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