Fix the password key to be consistent with the camel key. Strips the ';'
authorSarfraaz Ahmed <asarfraaz@novell.com>
Wed, 28 Sep 2005 13:35:18 +0000 (13:35 +0000)
committerAhmed Sarfraaz <sarfraaz@src.gnome.org>
Wed, 28 Sep 2005 13:35:18 +0000 (13:35 +0000)
2005-08-26  Sarfraaz Ahmed <asarfraaz@novell.com>

        * lib/e2k-autoconfig.c (e2k_validate_user) : Fix the password key to
        be consistent with the camel key.
        * storage/e-folder-exchange.c (sanitize_path) : Strips the ';' in the
        path.
        * storage/exchange-account.c (get_hierarchy_for)
        (setup_account_hierarchies) : Fix the physical uri to delimit the
        folder path from the uri with a ';'
        (exchange_account_new) : Fix the uri authority to be same as the camel
        uri which would be later used in all components for creating the
        password key.

servers/exchange/ChangeLog
servers/exchange/lib/e2k-autoconfig.c
servers/exchange/storage/e-folder-exchange.c
servers/exchange/storage/exchange-account.c

index 44e9dd5..abcc295 100644 (file)
@@ -1,3 +1,16 @@
+2005-08-26  Sarfraaz Ahmed <asarfraaz@novell.com>
+
+       * lib/e2k-autoconfig.c (e2k_validate_user) : Fix the password key to
+       be consistent with the camel key.
+       * storage/e-folder-exchange.c (sanitize_path) : Strips the ';' in the
+       path.
+       * storage/exchange-account.c (get_hierarchy_for)
+       (setup_account_hierarchies) : Fix the physical uri to delimit the
+       folder path from the uri with a ';'
+       (exchange_account_new) : Fix the uri authority to be same as the camel
+       uri which would be later used in all components for creating the
+       password key.
+
 2005-09-05  Praveen Kumar  <kpraveen@novell.com>
 
        ** Fixes bug 314588.
index 1dd8e3d..20f04db 100644 (file)
@@ -1568,6 +1568,7 @@ e2k_validate_user (const char *owa_url, char *user,
        char *key, *password, *prompt;
 
        key = g_strdup_printf ("%s//%s@%s", "exchange:", user, owa_url); /* FIXME */
+               
        password = e_passwords_get_password ("Exchange", key);
        if (!password) {
                prompt = g_strdup_printf (_("Enter password for %s"), user);
@@ -1587,8 +1588,11 @@ e2k_validate_user (const char *owa_url, char *user,
 
                                *remember_password = remember;
                                g_free (key);
-                               key = g_strdup_printf ("%s//%s@%s", 
-                                                      "exchange:", user, exchange_params->host);
+                               if (exchange_params->is_ntlm)
+                                       key = g_strdup_printf ("exchange://%s;auth=NTLM@%s/", 
+                                                                      user, exchange_params->host);
+                               else
+                                       key = g_strdup_printf ("exchange://%s@%s/", user, exchange_params->host);
                                e_passwords_add_password (key, password);
                                e_passwords_remember_password ("Exchange", key);
                        }
index 66f588a..9a7d850 100644 (file)
@@ -45,7 +45,7 @@ struct _EFolderExchangePrivate {
        ExchangeHierarchy *hier;
        char *internal_uri, *permanent_uri;
        char *outlook_class, *storage_dir;
-       const char *path;
+       char *path;
        long long int folder_size;
        gboolean has_subfolders;
 };
@@ -98,6 +98,7 @@ finalize (GObject *object)
        g_free (folder->priv->permanent_uri);
        g_free (folder->priv->outlook_class);
        g_free (folder->priv->storage_dir);
+       g_free (folder->priv->path);
        g_free (folder->priv);
 
        G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -147,6 +148,26 @@ e_mkdir_hier(const char *path, mode_t mode)
        return 0;
 }
 
+static char *
+sanitize_path (const char *path)
+{
+       gchar **comps;
+       char *new_path = NULL;
+
+       if (!path)
+               return;
+
+       comps = g_strsplit (path, ";", 2);
+       if (comps[1])
+               new_path = g_strdup_printf ("%s%s", comps[0], comps[1]);
+       else if (comps[0])
+               new_path = g_strdup (comps[0]);
+
+       g_strfreev (comps);
+       return new_path;        
+}
+
+
 /**
  * e_folder_exchange_new:
  * @hier: the #ExchangeHierarchy containing the new folder
@@ -181,7 +202,7 @@ e_folder_exchange_new (ExchangeHierarchy *hier, const char *name,
        efe->priv->hier = hier;
        g_object_ref (hier);
        efe->priv->internal_uri = g_strdup (internal_uri);
-       efe->priv->path = e2k_uri_path (e_folder_get_physical_uri (ef));
+       efe->priv->path = sanitize_path (e2k_uri_path (e_folder_get_physical_uri (ef)));
        efe->priv->outlook_class = g_strdup (outlook_class);
 
        /* Add ESources */
index eea4fd4..d750826 100644 (file)
@@ -370,6 +370,7 @@ hierarchy_new_folder (ExchangeHierarchy *hier, EFolder *folder,
                g_hash_table_insert (account->priv->folders,
                                     key,
                                     folder);
+               d(printf ("added path : %s\n", key));
                table_updated = 1;
        }
 
@@ -388,6 +389,7 @@ hierarchy_new_folder (ExchangeHierarchy *hier, EFolder *folder,
                g_hash_table_insert (account->priv->folders,
                                     key,
                                     folder);
+               d(printf ("added phy path : %s\n", key));
                table_updated = 1;
        }
 
@@ -400,6 +402,7 @@ hierarchy_new_folder (ExchangeHierarchy *hier, EFolder *folder,
                g_hash_table_insert (account->priv->folders,
                                     key,
                                     folder);
+               d(printf ("added int path : %s\n", key));
                table_updated = 1;
        }
 
@@ -624,7 +627,7 @@ get_hierarchy_for (ExchangeAccount *account, E2kGlobalCatalogEntry *entry)
                                          entry->display_name);
        source = g_strdup_printf ("exchange://%s@%s/", entry->mailbox,
                                  account->exchange_server);
-       physical_uri_prefix = g_strdup_printf ("exchange://%s/%s",
+       physical_uri_prefix = g_strdup_printf ("exchange://%s/;%s",
                                               account->priv->uri_authority,
                                               entry->email);
        internal_uri_prefix = exchange_account_get_foreign_uri (account, entry,
@@ -1261,7 +1264,7 @@ setup_account_hierarchies (ExchangeAccount *account)
                return FALSE;
 
        /* Set up Personal Folders hierarchy */
-       phys_uri_prefix = g_strdup_printf ("exchange://%s/personal",
+       phys_uri_prefix = g_strdup_printf ("exchange://%s/;personal",
                                           account->priv->uri_authority);
        hier = exchange_hierarchy_webdav_new (account,
                                              EXCHANGE_HIERARCHY_PERSONAL,
@@ -1277,7 +1280,7 @@ setup_account_hierarchies (ExchangeAccount *account)
        personal_hier = hier;
 
        /* Favorite Public Folders */
-       phys_uri_prefix = g_strdup_printf ("exchange://%s/favorites",
+       phys_uri_prefix = g_strdup_printf ("exchange://%s/;favorites",
                                           account->priv->uri_authority);
        hier = exchange_hierarchy_favorites_new (account,
                                                 _("Favorite Public Folders"),
@@ -1292,7 +1295,7 @@ setup_account_hierarchies (ExchangeAccount *account)
        account->priv->favorites_hierarchy = hier;
 
        /* Public Folders */
-       phys_uri_prefix = g_strdup_printf ("exchange://%s/public",
+       phys_uri_prefix = g_strdup_printf ("exchange://%s/;public",
                                           account->priv->uri_authority);
        hier = exchange_hierarchy_webdav_new (account,
                                              EXCHANGE_HIERARCHY_PUBLIC,
@@ -2024,7 +2027,7 @@ ExchangeAccount *
 exchange_account_new (EAccountList *account_list, EAccount *adata)
 {
        ExchangeAccount *account;
-       char *enc_user, *mailbox;
+       char *enc_user, *mailbox, *old_uri_authority;
        const char *param, *proto="http", *owa_path, *pf_server, *owa_url; 
        const char *passwd_exp_warn_period, *offline_sync;
        E2kUri *uri;
@@ -2047,8 +2050,8 @@ exchange_account_new (EAccountList *account_list, EAccount *adata)
        account->storage_dir = g_strdup_printf ("%s/.evolution/exchange/%s@%s",
                                                g_get_home_dir (),
                                                uri->user, uri->host);
-       account->account_filename = strrchr (account->storage_dir, '/') + 1;
-       e_filename_make_safe (account->account_filename);
+       /*account->account_filename = strrchr (account->storage_dir, '/') + 1;
+       e_filename_make_safe (account->account_filename); */
 
        /* Identity info */
        account->priv->identity_name = g_strdup (adata->id->name);
@@ -2056,16 +2059,25 @@ exchange_account_new (EAccountList *account_list, EAccount *adata)
 
        /* URI, etc, info */
        enc_user = e2k_uri_encode (uri->user, FALSE, "@/;:");
-       account->priv->uri_authority = g_strdup_printf ("%s@%s", enc_user,
+       old_uri_authority = g_strdup_printf ("%s@%s", enc_user,
                                                        uri->host);
+       if (uri->authmech)
+               account->priv->uri_authority = g_strdup_printf ("%s;auth=%s@%s", enc_user,
+                                                               uri->authmech, uri->host);
+       else
+               account->priv->uri_authority = g_strdup_printf ("%s@%s", enc_user,
+                                                               uri->host);
        g_free (enc_user);
 
+       account->account_filename = account->priv->uri_authority;
+
        account->priv->source_uri = g_strdup_printf ("exchange://%s/", account->priv->uri_authority);
 
        /* Backword compatibility; FIXME, we should just migrate the
         * password from this to source_uri.
         */
-       account->priv->password_key = g_strdup_printf ("exchange://%s", account->priv->uri_authority);
+       account->priv->password_key = g_strdup_printf ("exchange://%s", old_uri_authority);
+       g_free (old_uri_authority);
 
        account->priv->username = g_strdup (uri->user);
        if (uri->domain)