[gnome-online-accounts/exchange] Replace the server in the {As, Oab}Url with the one provided by the user



commit b5c7195d579ad970e09dae546f551c9b8f6ff10b
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Apr 4 14:40:51 2012 +0200

    Replace the server in the {As,Oab}Url with the one provided by the user
    
    In some Exchange server setups, the hostname part of the AsUrl and
    OabUrl may be wrong. Right now we just replace the hostname with the
    server provided by the user or guessed from the email. We might need
    to do something more intelligent if this is not enough.
    
    Fixes: https://bugzilla.gnome.org/667889

 src/goabackend/goaewsclient.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/goabackend/goaewsclient.c b/src/goabackend/goaewsclient.c
index 34a9944..0fb999d 100644
--- a/src/goabackend/goaewsclient.c
+++ b/src/goabackend/goaewsclient.c
@@ -78,6 +78,7 @@ typedef struct
   GSimpleAsyncResult *res;
   SoupMessage *msgs[2];
   SoupSession *session;
+  gchar *server;
   gulong cancellable_id;
   xmlOutputBuffer *buf;
 } AutodiscoverData;
@@ -99,6 +100,7 @@ ews_client_autodiscover_data_free (AutodiscoverData *data)
 
   /* soup_session_queue_message stole the references to data->msgs */
   xmlOutputBufferClose (data->buf);
+  g_free (data->server);
   g_object_unref (data->res);
   g_object_unref (data->session);
   g_slice_free (AutodiscoverData, data);
@@ -177,6 +179,19 @@ ews_client_autodiscover_parse_protocol (xmlNode *node)
 }
 
 static void
+ews_client_autodiscover_replace_server (gchar **url, const gchar *server)
+{
+  SoupURI *uri;
+
+  uri = soup_uri_new (*url);
+  g_free (*url);
+
+  soup_uri_set_host (uri, server);
+  *url = soup_uri_to_string (uri, FALSE);
+  soup_uri_free (uri);
+}
+
+static void
 ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpointer user_data)
 {
   GError *error;
@@ -286,6 +301,9 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo
       goto out;
     }
 
+  ews_client_autodiscover_replace_server (&urls->as_url, data->server);
+  ews_client_autodiscover_replace_server (&urls->oab_url, data->server);
+
   for (idx = 0; idx < size; idx++)
     {
       if (data->msgs[idx] != NULL)
@@ -432,6 +450,7 @@ goa_ews_client_autodiscover (GoaEwsClient        *client,
    */
   data = g_slice_new0 (AutodiscoverData);
   data->buf = buf;
+  data->server = g_strdup (server);
   data->res = g_simple_async_result_new (G_OBJECT (client), callback, user_data, goa_ews_client_autodiscover);
   data->msgs[0] = ews_client_create_msg_for_url (url1, buf);
   data->msgs[1] = ews_client_create_msg_for_url (url2, buf);



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