2008-10-07 [colin] 3.6.0cvs14
[claws.git] / src / imap.c
index 256cef837ad3bb194d4a3ff7ac21674da61b3b31..b2bf4884a528498fab8ba4f1463735c44d34f813 100644 (file)
@@ -1163,7 +1163,7 @@ static gint imap_session_authenticate(IMAPSession *session,
        acc_pass = account->passwd;
 try_again:
        pass = acc_pass;
-       if (!pass && account->imap_auth_type != IMAP_AUTH_ANON) {
+       if (!pass && account->imap_auth_type != IMAP_AUTH_ANON && account->imap_auth_type != IMAP_AUTH_GSSAPI) {
                gchar *tmp_pass;
                tmp_pass = input_dialog_query_password_keep(account->recv_server, 
                                                            account->userid,
@@ -1172,7 +1172,7 @@ try_again:
                        return MAILIMAP_NO_ERROR;
                Xstrdup_a(pass, tmp_pass, {g_free(tmp_pass); return MAILIMAP_NO_ERROR;});
                g_free(tmp_pass);
-       } else if (account->imap_auth_type == IMAP_AUTH_ANON) {
+       } else if (account->imap_auth_type == IMAP_AUTH_ANON || account->imap_auth_type == IMAP_AUTH_GSSAPI) {
                pass = "";
        }
        statuswindow_print_all(_("Connecting to IMAP4 server %s...\n"),
@@ -2487,31 +2487,70 @@ static gchar *imap_folder_get_path(Folder *folder)
        return folder_path;
 }
 
+#ifdef G_OS_WIN32
+static gchar *imap_encode_unsafe_chars(const gchar *str)
+{
+       gchar *ret = NULL, *o_ret;
+       gchar *i;
+       if (!str) 
+               return NULL;
+       ret = g_malloc(3*strlen(str)+1);
+       o_ret = ret;
+       for (i = str; *i; i++) {
+               switch(*i) {
+                       case ':':
+                       case '|':
+                       case '<':
+                       case '>':
+                       case '*':
+                       case '?':
+                       case '#':
+                               *ret++ = '%';
+                               *ret++ = '0'+(*i/10);
+                               *ret++ = '0'+(*i%10);
+                               break;
+                       default:
+                               *ret++ = *i;
+               }
+       }
+       *ret++ = '\0';
+       return o_ret;
+}
+#endif
 static gchar *imap_item_get_path(Folder *folder, FolderItem *item)
 {
        gchar *folder_path, *path;
-
+       gchar *item_path = NULL;
+       
        g_return_val_if_fail(folder != NULL, NULL);
        g_return_val_if_fail(item != NULL, NULL);
        folder_path = imap_folder_get_path(folder);
 
        g_return_val_if_fail(folder_path != NULL, NULL);
+
+#ifdef G_OS_UNIX
+       item_path = g_strdup(item->path);
+#else
+       item_path = imap_encode_unsafe_chars(item->path);
+#endif 
+
         if (g_path_is_absolute(folder_path)) {
-                if (item->path)
+                if (item_path)
                         path = g_strconcat(folder_path, G_DIR_SEPARATOR_S,
-                                           item->path, NULL);
+                                           item_path, NULL);
                 else
                         path = g_strdup(folder_path);
         } else {
-                if (item->path)
+                if (item_path)
                         path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
                                            folder_path, G_DIR_SEPARATOR_S,
-                                           item->path, NULL);
+                                           item_path, NULL);
                 else
                         path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
                                            folder_path, NULL);
         }
         g_free(folder_path);
+        g_free(item_path);
 #ifdef G_OS_WIN32
        while (strchr(path, '/'))
                *strchr(path, '/') = '\\';