sync with sylpheed 0.4.99cvs11
authorPaul Mangan <paul@claws-mail.org>
Fri, 15 Jun 2001 10:29:27 +0000 (10:29 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 15 Jun 2001 10:29:27 +0000 (10:29 +0000)
12 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/account.c
src/folder.c
src/folderview.c
src/imap.c
src/imap.h
src/send.c
src/utils.c
src/utils.h

index 7c22510..f7d2478 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2001-06-15
+
+       * src/folderview.c:
+         folderview_new_folder_cb()
+         folderview_new_imap_folder_cb(): show error dialog when creation
+         of folder failed.
+         Made it allow users to create a folder which contains subfolders.
+       * AUTHORS: incorporated from claws branch. It now contains all
+         contributors.
+       * src/send.c: enabled cancellation.
+         EXIT_IF_CANCELLED(): new macro.
+         Added cancelled flag to SendProgressDialog.
+       * src/utils.[ch]: strtailchomp(): new. It removes the trailing
+         specified character.
+       * src/imap.c: imap_cmd_fetch(): a fix for MS Exchange 2000 server.
+
+2001-06-15
+
+       * src/imap.c: imap_create_tree(): new. It creates required
+         folders such as INBOX and Trash.
+         imap_do_copy(), imap_do_copy_msgs_with_dest(): don't expunge
+         if COPY failed.
+         imap_remove_all_msg(): return immediately if exists == 0.
+       * src/account.c: account_add(), account_set_missing_folder():
+         made them use folder->create_tree().
+
+2001-06-14
+
+       * src/imap.c: more namespace implementation.
+         imap_find_namespace(), imap_path_separator_subst(): new.
+
 2001-06-13
 
        * src/imap.c: imap_parse_namespace(), imap_cmd_namespace(): new.
index 491606c..d3f4dc0 100644 (file)
@@ -1,3 +1,9 @@
+2001-06-15 [paul]
+
+        0.4.99claws10
+
+        * sync with sylpheed 0.4.99cvs11
+
 2001-06-13 [paul]
 
         0.4.99claws9
index c800bba..38cf52b 100644 (file)
@@ -1,3 +1,33 @@
+2001-06-15
+
+       * src/folderview.c:
+         folderview_new_folder_cb()
+         folderview_new_imap_folder_cb(): ¥Õ¥©¥ë¥À¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤¿¤é
+         ¥¨¥é¡¼¥À¥¤¥¢¥í¥°¤òɽ¼¨¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+         ¥µ¥Ö¥Õ¥©¥ë¥À¤ò´Þ¤à¥Õ¥©¥ë¥À¤òºîÀ®¤Ç¤­¤ë¤è¤¦¤Ë¤·¤¿¡£
+       * AUTHORS: claws ¥Ö¥é¥ó¥Á¤«¤é¼è¹þ¡£Á´¤Æ¤Î contributor ¤ò´Þ¤ó¤Ç¤¤¤ë¡£
+       * src/send.c: ¥­¥ã¥ó¥»¥ë¤òÍ­¸ú¤Ë¤·¤¿¡£
+         EXIT_IF_CANCELLED(): ¿·µ¬¥Þ¥¯¥í¡£
+         SendProgressDialog ¤Ë cancelled ¥Õ¥é¥°¤òÄɲá£
+       * src/utils.[ch]: strtailchomp(): ¿·µ¬¡£ËöÈø¤Î»ØÄꤷ¤¿Ê¸»ú¤ò¼è¤ê½ü¤¯¡£
+       * src/imap.c: imap_cmd_fetch(): MS Exchange 2000 ¥µ¡¼¥Ð¤Î¤¿¤á¤Î½¤Àµ¡£
+
+2001-06-15
+
+       * src/imap.c: imap_create_tree(): ¿·µ¬¡£ INBOX ¤ä Trash ¤Î¤è¤¦¤Ê
+         É¬Íפʥե©¥ë¥À¤òºîÀ®¤¹¤ë¡£
+         imap_do_copy(), imap_do_copy_msgs_with_dest(): COPY ¤¬¼ºÇÔ¤·¤¿¤é
+         expunge ¤·¤Ê¤¤¤è¤¦¤Ë¤·¤¿¡£
+         imap_remove_all_msg(): exists == 0 ¤Ê¤é¤¹¤°¤Ë return ¤¹¤ë¤è¤¦¤Ë
+         ¤·¤¿¡£
+       * src/account.c: account_add(), account_set_missing_folder():
+         folder->create_tree() ¤ò»ÈÍѤ¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+
+2001-06-14
+
+       * src/imap.c: ¤µ¤é¤Ë namespace ¤ò¼ÂÁõ¡£
+       * imap_find_namespace(), imap_path_separator_subst(): ¿·µ¬¡£
+
 2001-06-13
 
        * src/imap.c: imap_parse_namespace(), imap_cmd_namespace(): ¿·µ¬¡£
index d8b09ef..1b8d1bf 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=4
 MICRO_VERSION=99
 INTERFACE_AGE=99
 BINARY_AGE=99
-EXTRA_VERSION=claws9
+EXTRA_VERSION=claws10
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index 3301c5c..bca28dd 100644 (file)
@@ -280,6 +280,8 @@ void account_add(void)
                folder->account = ac_prefs;
                ac_prefs->folder = REMOTE_FOLDER(folder);
                folder_add(folder);
+               if (ac_prefs->protocol == A_IMAP4)
+                       folder->create_tree(folder);
                folderview_update_all();
        }
 }
@@ -333,9 +335,12 @@ void account_set_missing_folder(void)
                                folder = folder_new(F_NEWS, ap->account_name,
                                                    ap->nntp_server);
                        }
+
                        folder->account = ap;
                        ap->folder = REMOTE_FOLDER(folder);
                        folder_add(folder);
+                       if (ap->protocol == A_IMAP4)
+                               folder->create_tree(folder);
                }
        }
 }
index a3d656c..a8c609a 100644 (file)
@@ -932,6 +932,7 @@ static void folder_init(Folder *folder, FolderType type, const gchar *name)
                folder->remove_msg          = imap_remove_msg;
                folder->remove_all_msg      = imap_remove_all_msg;
                folder->scan                = imap_scan_folder;
+               folder->create_tree         = imap_create_tree;
                folder->create_folder       = imap_create_folder;
                folder->remove_folder       = imap_remove_folder;
                break;
index 5770db7..23d24fe 100644 (file)
@@ -1678,6 +1678,7 @@ static void folderview_new_imap_folder_cb(FolderView *folderview, guint action,
        FolderItem *item;
        FolderItem *new_item;
        gchar *new_folder;
+       gchar *p;
 
        if (!folderview->selected) return;
 
@@ -1687,12 +1688,16 @@ static void folderview_new_imap_folder_cb(FolderView *folderview, guint action,
        g_return_if_fail(item->folder->type == F_IMAP);
        g_return_if_fail(item->folder->account != NULL);
 
-       new_folder = input_dialog(_("New folder"),
-                                 _("Input the name of new folder:"),
-                                 _("NewFolder"));
+       new_folder = input_dialog
+               (_("New folder"),
+                _("Input the name of new folder:\n"
+                  "(if you want to create a folder to store subfolders,\n"
+                  " append `/' at the end of the name)"),
+                _("NewFolder"));
        if (!new_folder) return;
 
-       if (strchr(new_folder, G_DIR_SEPARATOR) != NULL) {
+       if ((p = strchr(new_folder, G_DIR_SEPARATOR)) != NULL &&
+           *(p + 1) != '\0') {
                alertpanel_error(_("`%c' can't be included in folder name."),
                                 G_DIR_SEPARATOR);
                g_free(new_folder);
index 7be5806..f3a981a 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <dirent.h>
 #include <unistd.h>
+#include <ctype.h>
 
 #include "intl.h"
 #include "imap.h"
@@ -53,7 +54,7 @@ static gint imap_do_copy              (Folder         *folder,
                                         MsgInfo        *msginfo,
                                         gboolean        remove_source);
 static gint imap_do_copy_msgs_with_dest        (Folder         *folder,
-                                        FolderItem     *dest,
+                                        FolderItem     *dest, 
                                         GSList         *msglist,
                                         gboolean        remove_source);
 
@@ -76,8 +77,10 @@ static gint imap_set_article_flags   (IMAPSession    *session,
                                         IMAPFlags       flag,
                                         gboolean        is_set);
 
-static void imap_parse_namespace       (IMAPSession    *session,
-                                        Folder         *folder);
+static void imap_parse_namespace               (IMAPSession    *session,
+                                                IMAPFolder     *folder);
+static IMAPNameSpace *imap_find_namespace      (IMAPFolder     *folder,
+                                                const gchar    *path);
 
 static gchar *imap_parse_atom          (SockInfo *sock,
                                         gchar    *src,
@@ -149,14 +152,14 @@ static gint imap_cmd_gen_recv     (SockInfo       *sock,
                                 gint            size);
 
 /* misc utility functions */
-static gchar *strchr_cpy               (const gchar    *src,
-                                        gchar           ch,
-                                        gchar          *dest,
-                                        gint            len);
-static gchar *search_array_contain_str (GPtrArray      *array,
-                                        gchar          *str);
-static void imap_path_subst_slash_to_dot(gchar *str);
-
+static gchar *strchr_cpy                       (const gchar    *src,
+                                                gchar           ch,
+                                                gchar          *dest,
+                                                gint            len);
+static gchar *search_array_contain_str         (GPtrArray      *array,
+                                                gchar          *str);
+static void imap_path_separator_subst          (gchar          *str,
+                                                gchar           separator);
 
 static IMAPSession *imap_session_connect_if_not(Folder *folder)
 {
@@ -172,6 +175,8 @@ static IMAPSession *imap_session_connect_if_not(Folder *folder)
                                         IMAP4_PORT,
                                         folder->account->userid,
                                         folder->account->passwd);
+               imap_parse_namespace(IMAP_SESSION(rfolder->session),
+                                    IMAP_FOLDER(folder));
                statusbar_pop_all();
                return IMAP_SESSION(rfolder->session);
        }
@@ -185,6 +190,8 @@ static IMAPSession *imap_session_connect_if_not(Folder *folder)
                        imap_session_new(folder->account->recv_server,
                                         IMAP4_PORT, folder->account->userid,
                                         folder->account->passwd);
+               imap_parse_namespace(IMAP_SESSION(rfolder->session),
+                                    IMAP_FOLDER(folder));
        }
 
        statusbar_pop_all();
@@ -249,6 +256,8 @@ GSList *imap_get_msg_list(Folder *folder, FolderItem *item, gboolean use_cache)
 {
        GSList *mlist = NULL;
        IMAPSession *session;
+       IMAPNameSpace *namespace;
+       gchar *path;
        gint ok, exists = 0, recent = 0, unseen = 0, begin = 1;
        gulong uid = 0, last_uid;
 
@@ -269,7 +278,12 @@ GSList *imap_get_msg_list(Folder *folder, FolderItem *item, gboolean use_cache)
 
        last_uid = item->mtime;
 
-       ok = imap_cmd_select(SESSION(session)->sock, item->path,
+       Xstrdup_a(path, item->path, return mlist);
+       namespace = imap_find_namespace(IMAP_FOLDER(folder), path);
+       if (namespace && namespace->separator)
+               imap_path_separator_subst(path, namespace->separator);
+
+       ok = imap_cmd_select(SESSION(session)->sock, path,
                             &exists, &recent, &unseen, &uid);
        if (ok != IMAP_SUCCESS) {
                log_warning(_("can't select folder: %s\n"), item->path);
@@ -407,8 +421,11 @@ static gint imap_do_copy(Folder *folder, FolderItem *dest, MsgInfo *msginfo,
 {
        gchar *destdir;
        IMAPSession *session;
+       IMAPNameSpace *namespace;
+       gint ok;
 
        g_return_val_if_fail(folder != NULL, -1);
+       g_return_val_if_fail(folder->type == F_IMAP, -1);
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msginfo != NULL, -1);
 
@@ -421,25 +438,32 @@ static gint imap_do_copy(Folder *folder, FolderItem *dest, MsgInfo *msginfo,
        }
 
        Xstrdup_a(destdir, dest->path, return -1);
-       /* imap_path_subst_slash_to_dot(destdir); */
+       namespace = imap_find_namespace(IMAP_FOLDER(folder), destdir);
+       if (namespace && namespace->separator)
+               imap_path_separator_subst(destdir, namespace->separator);
 
-       debug_print(_("%s message %s%c%d to %s ...\n"),
-                   remove_source ? "Moving" : "Copying",
-                   msginfo->folder->path, G_DIR_SEPARATOR,
-                   msginfo->msgnum, destdir);
+       if (remove_source)
+               debug_print(_("Moving message %s%c%d to %s ...\n"),
+                           msginfo->folder->path, G_DIR_SEPARATOR,
+                           msginfo->msgnum, destdir);
+       else
+               debug_print(_("Copying message %s%c%d to %s ...\n"),
+                           msginfo->folder->path, G_DIR_SEPARATOR,
+                           msginfo->msgnum, destdir);
 
-       imap_cmd_copy(SESSION(session)->sock, msginfo->msgnum, destdir);
+       ok = imap_cmd_copy(SESSION(session)->sock, msginfo->msgnum, destdir);
 
-       if (remove_source) {
+       if (ok == IMAP_SUCCESS && remove_source) {
                imap_set_article_flags(session, msginfo->msgnum, msginfo->msgnum,
                                       IMAP_FLAG_DELETED, TRUE);
                imap_cmd_expunge(SESSION(session)->sock);
        }
 
-       return IMAP_SUCCESS;
+       statusbar_pop_all();
+       return ok;
 }
 
-static gint imap_do_copy_msgs_with_dest(Folder *folder, FolderItem *dest,
+static gint imap_do_copy_msgs_with_dest(Folder *folder, FolderItem *dest, 
                                        GSList *msglist,
                                        gboolean remove_source)
 {
@@ -447,6 +471,8 @@ static gint imap_do_copy_msgs_with_dest(Folder *folder, FolderItem *dest,
        GSList *cur;
        MsgInfo *msginfo;
        IMAPSession *session;
+       IMAPNameSpace *namespace;
+       gint ok;
 
        g_return_val_if_fail(folder != NULL, -1);
        g_return_val_if_fail(dest != NULL, -1);
@@ -456,7 +482,9 @@ static gint imap_do_copy_msgs_with_dest(Folder *folder, FolderItem *dest,
        if (!session) return -1;
 
        Xstrdup_a(destdir, dest->path, return -1);
-       /* imap_path_subst_slash_to_dot(destdir); */
+       namespace = imap_find_namespace(IMAP_FOLDER(folder), destdir);
+       if (namespace && namespace->separator)
+               imap_path_separator_subst(destdir, namespace->separator);
 
        for (cur = msglist; cur != NULL; cur = cur->next) {
                msginfo = (MsgInfo *)cur->data;
@@ -466,15 +494,19 @@ static gint imap_do_copy_msgs_with_dest(Folder *folder, FolderItem *dest,
                        continue;
                }
 
-               debug_print(_("%s message %s%c%d to %s ...\n"),
-                           remove_source ? "Moving" : "Copying",
-                           msginfo->folder->path, G_DIR_SEPARATOR,
-                           msginfo->msgnum, destdir);
+               if (remove_source)
+                       debug_print(_("Moving message %s%c%d to %s ...\n"),
+                                   msginfo->folder->path, G_DIR_SEPARATOR,
+                                   msginfo->msgnum, destdir);
+               else
+                       debug_print(_("Copying message %s%c%d to %s ...\n"),
+                                   msginfo->folder->path, G_DIR_SEPARATOR,
+                                   msginfo->msgnum, destdir);
 
-               imap_cmd_copy(SESSION(session)->sock, msginfo->msgnum,
-                             destdir);
+               ok = imap_cmd_copy(SESSION(session)->sock, msginfo->msgnum,
+                                  destdir);
 
-               if (remove_source) {
+               if (ok == IMAP_SUCCESS && remove_source) {
                        imap_set_article_flags
                                (session, msginfo->msgnum, msginfo->msgnum,
                                 IMAP_FLAG_DELETED, TRUE);
@@ -484,8 +516,8 @@ static gint imap_do_copy_msgs_with_dest(Folder *folder, FolderItem *dest,
        if (remove_source)
                imap_cmd_expunge(SESSION(session)->sock);
 
+       statusbar_pop_all();
        return IMAP_SUCCESS;
-
 }
 
 gint imap_move_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
@@ -493,7 +525,7 @@ gint imap_move_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
        return imap_do_copy(folder, dest, msginfo, TRUE);
 }
 
-gint imap_move_msgs_with_dest(Folder *folder, FolderItem *dest,
+gint imap_move_msgs_with_dest(Folder *folder, FolderItem *dest, 
                              GSList *msglist)
 {
        return imap_do_copy_msgs_with_dest(folder, dest, msglist, TRUE);
@@ -504,7 +536,7 @@ gint imap_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
        return imap_do_copy(folder, dest, msginfo, FALSE);
 }
 
-gint imap_copy_msgs_with_dest(Folder *folder, FolderItem *dest,
+gint imap_copy_msgs_with_dest(Folder *folder, FolderItem *dest, 
                              GSList *msglist)
 {
        return imap_do_copy_msgs_with_dest(folder, dest, msglist, FALSE);
@@ -516,16 +548,25 @@ gint imap_remove_msg(Folder *folder, FolderItem *item, gint num)
        gulong uid;
        gint ok;
        IMAPSession *session;
+       IMAPNameSpace *namespace;
+       gchar *path;
 
        g_return_val_if_fail(folder != NULL, -1);
+       g_return_val_if_fail(folder->type == F_IMAP, -1);
        g_return_val_if_fail(item != NULL, -1);
        g_return_val_if_fail(num > 0 && num <= item->last_num, -1);
 
        session = imap_session_connect_if_not(folder);
        if (!session) return -1;
 
-       ok = imap_cmd_select(SESSION(session)->sock, item->path,
+       Xstrdup_a(path, item->path, return -1);
+       namespace = imap_find_namespace(IMAP_FOLDER(folder), path);
+       if (namespace && namespace->separator)
+               imap_path_separator_subst(path, namespace->separator);
+
+       ok = imap_cmd_select(SESSION(session)->sock, path,
                             &exists, &recent, &unseen, &uid);
+       statusbar_pop_all();
        if (ok != IMAP_SUCCESS) {
                log_warning(_("can't select folder: %s\n"), item->path);
                return ok;
@@ -533,12 +574,14 @@ gint imap_remove_msg(Folder *folder, FolderItem *item, gint num)
 
        ok = imap_set_article_flags(IMAP_SESSION(REMOTE_FOLDER(folder)->session),
                                    num, num, IMAP_FLAG_DELETED, TRUE);
+       statusbar_pop_all();
        if (ok != IMAP_SUCCESS) {
                log_warning(_("can't set deleted flags: %d\n"), num);
                return ok;
        }
 
        ok = imap_cmd_expunge(SESSION(session)->sock);
+       statusbar_pop_all();
        if (ok != IMAP_SUCCESS) {
                log_warning(_("can't expunge\n"));
                return ok;
@@ -553,6 +596,8 @@ gint imap_remove_all_msg(Folder *folder, FolderItem *item)
        gulong uid;
        gint ok;
        IMAPSession *session;
+       IMAPNameSpace *namespace;
+       gchar *path;
 
        g_return_val_if_fail(folder != NULL, -1);
        g_return_val_if_fail(item != NULL, -1);
@@ -560,21 +605,31 @@ gint imap_remove_all_msg(Folder *folder, FolderItem *item)
        session = imap_session_connect_if_not(folder);
        if (!session) return -1;
 
-       ok = imap_cmd_select(SESSION(session)->sock, item->path,
+       Xstrdup_a(path, item->path, return -1);
+       namespace = imap_find_namespace(IMAP_FOLDER(folder), path);
+       if (namespace && namespace->separator)
+               imap_path_separator_subst(path, namespace->separator);
+
+       ok = imap_cmd_select(SESSION(session)->sock, path,
                             &exists, &recent, &unseen, &uid);
+       statusbar_pop_all();
        if (ok != IMAP_SUCCESS) {
                log_warning(_("can't select folder: %s\n"), item->path);
                return ok;
        }
+       if (exists == 0)
+               return IMAP_SUCCESS;
 
        ok = imap_set_article_flags(session, 1, exists,
                                    IMAP_FLAG_DELETED, TRUE);
+       statusbar_pop_all();
        if (ok != IMAP_SUCCESS) {
                log_warning(_("can't set deleted flags: 1:%d\n"), exists);
                return ok;
        }
 
        ok = imap_cmd_expunge(SESSION(session)->sock);
+       statusbar_pop_all();
        if (ok != IMAP_SUCCESS) {
                log_warning(_("can't expunge\n"));
                return ok;
@@ -587,12 +642,44 @@ void imap_scan_folder(Folder *folder, FolderItem *item)
 {
 }
 
+gint imap_create_tree(Folder *folder)
+{
+       FolderItem *item;
+       FolderItem *new_item;
+
+       g_return_val_if_fail(folder != NULL, -1);
+       g_return_val_if_fail(folder->node != NULL, -1);
+       g_return_val_if_fail(folder->node->data != NULL, -1);
+
+       item = FOLDER_ITEM(folder->node->data);
+
+       new_item = folder_item_new("INBOX", "INBOX");
+       new_item->stype = F_INBOX;
+       folder_item_append(item, new_item);
+       folder->inbox = new_item;
+
+       new_item = imap_create_folder(folder, item, "trash");
+       if (!new_item) {
+               new_item = folder_item_new("Trash", "trash");
+               folder_item_append(item, new_item);
+       } else {
+               g_free(new_item->name);
+               new_item->name = g_strdup("Trash");
+       }
+       new_item->stype = F_TRASH;
+       folder->trash = new_item;
+
+       return 0;
+}
+
 FolderItem *imap_create_folder(Folder *folder, FolderItem *parent,
                               const gchar *name)
 {
        gchar *dirpath, *imappath;
        IMAPSession *session;
+       IMAPNameSpace *namespace;
        FolderItem *new_item;
+       gchar *new_name;
        gint ok;
 
        g_return_val_if_fail(folder != NULL, NULL);
@@ -608,8 +695,15 @@ FolderItem *imap_create_folder(Folder *folder, FolderItem *parent,
        else
                dirpath = g_strdup(name);
 
-       imappath = g_strdup(dirpath);
-       /* imap_path_subst_slash_to_dot(imappath); */
+       Xstrdup_a(imappath, dirpath, {g_free(dirpath); return NULL;});
+       Xstrdup_a(new_name, name, {g_free(dirpath); return NULL;});
+       namespace = imap_find_namespace(IMAP_FOLDER(folder), imappath);
+       if (namespace && namespace->separator) {
+               imap_path_separator_subst(imappath, namespace->separator);
+               imap_path_separator_subst(new_name, namespace->separator);
+               strtailchomp(dirpath, namespace->separator);
+               strtailchomp(new_name, namespace->separator);
+       }
 
        if (strcmp(name, "INBOX") != 0) {
                ok = imap_cmd_status(SESSION(session)->sock, imappath,
@@ -619,7 +713,6 @@ FolderItem *imap_create_folder(Folder *folder, FolderItem *parent,
                        statusbar_pop_all();
                        if (ok != IMAP_SUCCESS) {
                                log_warning(_("can't create mailbox\n"));
-                               g_free(imappath);
                                g_free(dirpath);
                                return NULL;
                        }
@@ -627,9 +720,8 @@ FolderItem *imap_create_folder(Folder *folder, FolderItem *parent,
                statusbar_pop_all();
        }
 
-       new_item = folder_item_new(name, dirpath);
+       new_item = folder_item_new(new_name, dirpath);
        folder_item_append(parent, new_item);
-       g_free(imappath);
        g_free(dirpath);
 
        return new_item;
@@ -776,7 +868,7 @@ static SockInfo *imap_open(const gchar *server, gushort port, gchar *buf)
 
 #define THROW goto catch
 
-static void imap_parse_namespace(IMAPSession *session, Folder *folder)
+static void imap_parse_namespace(IMAPSession *session, IMAPFolder *folder)
 {
        gchar *ns_str;
        gchar *name;
@@ -787,7 +879,8 @@ static void imap_parse_namespace(IMAPSession *session, Folder *folder)
 
        g_return_if_fail(session != NULL);
        g_return_if_fail(folder != NULL);
-       g_return_if_fail(folder->type == F_IMAP);
+
+       if (folder->namespace != NULL) return;
 
        if (imap_cmd_namespace(SESSION(session)->sock, &ns_str)
            != IMAP_SUCCESS) {
@@ -801,6 +894,8 @@ static void imap_parse_namespace(IMAPSession *session, Folder *folder)
        p = ns_str;
 
        while (*p != '\0') {
+               /* parse ("#foo" "/") */
+
                while (*p && *p != '(') p++;
                if (*p == '\0') THROW;
                p++;
@@ -815,15 +910,18 @@ static void imap_parse_namespace(IMAPSession *session, Folder *folder)
                *p = '\0';
                p++;
 
-               while (*p && *p != '"') p++;
+               while (*p && isspace(*p)) p++;
                if (*p == '\0') THROW;
-               p++;
-               separator = p;
-
-               while (*p && *p != '"') p++;
-               if (*p == '\0') THROW;
-               *p = '\0';
-               p++;
+               if (strncmp(p, "NIL", 3) == 0)
+                       separator = NULL;
+               else if (*p == '"') {
+                       p++;
+                       separator = p;
+                       while (*p && *p != '"') p++;
+                       if (*p == '\0') THROW;
+                       *p = '\0';
+                       p++;
+               } else THROW;
 
                while (*p && *p != ')') p++;
                if (*p == '\0') THROW;
@@ -831,7 +929,7 @@ static void imap_parse_namespace(IMAPSession *session, Folder *folder)
 
                namespace = g_new(IMAPNameSpace, 1);
                namespace->name = g_strdup(name);
-               namespace->separator = separator[0];
+               namespace->separator = separator ? separator[0] : '\0';
                ns_list = g_list_append(ns_list, namespace);
                IMAP_FOLDER(folder)->namespace = ns_list;
        }
@@ -843,6 +941,26 @@ catch:
 
 #undef THROW
 
+static IMAPNameSpace *imap_find_namespace(IMAPFolder *folder,
+                                         const gchar *path)
+{
+       IMAPNameSpace *namespace = NULL;
+       GList *ns_list;
+
+       g_return_val_if_fail(folder != NULL, NULL);
+       g_return_val_if_fail(path != NULL, NULL);
+
+       ns_list = folder->namespace;
+
+       for (; ns_list != NULL; ns_list = ns_list->next) {
+               IMAPNameSpace *tmp_ns = ns_list->data;
+               if (strncmp(path, tmp_ns->name, strlen(tmp_ns->name)) == 0)
+                       namespace = tmp_ns;
+       }
+
+       return namespace;
+}
+
 static gchar *imap_parse_atom(SockInfo *sock, gchar *src, gchar *dest,
                              gchar *orig_buf)
 {
@@ -1214,15 +1332,11 @@ static gint imap_cmd_select(SockInfo *sock, const gchar *folder,
        gint ok;
        gchar *resp_str;
        GPtrArray *argbuf;
-       gchar *imappath;
 
        *exists = *recent = *unseen = *uid = 0;
        argbuf = g_ptr_array_new();
 
-       Xstrdup_a(imappath, folder, return -1);
-       /* imap_path_subst_slash_to_dot(imappath); */
-
-       imap_cmd_gen_send(sock, "SELECT \"%s\"", imappath);
+       imap_cmd_gen_send(sock, "SELECT \"%s\"", folder);
        if ((ok = imap_cmd_ok(sock, argbuf)) != IMAP_SUCCESS)
                goto bail;
 
@@ -1317,7 +1431,7 @@ static gint imap_cmd_fetch(SockInfo *sock, gint num, const gchar *filename)
        if (imap_cmd_gen_recv(sock, buf, sizeof(buf)) != IMAP_SUCCESS)
                return IMAP_ERROR;
 
-       if (buf[0] != ')')
+       if (buf[0] == '\0' || buf[strlen(buf) - 1] != ')')
                return IMAP_ERROR;
 
        ok = imap_cmd_ok(sock, NULL);
@@ -1375,7 +1489,7 @@ static gint imap_cmd_store(SockInfo *sock, gint first, gint last,
        gint ok;
 
        imap_cmd_gen_send(sock, "STORE %d:%d %s", first, last, sub_cmd);
-
+       
        if ((ok = imap_cmd_ok(sock, NULL)) != IMAP_SUCCESS) {
                log_warning(_("error while imap command: STORE %d:%d %s\n"),
                            first, last, sub_cmd);
@@ -1495,7 +1609,8 @@ static gchar *search_array_contain_str(GPtrArray *array, gchar *str)
        return NULL;
 }
 
-static void imap_path_subst_slash_to_dot(gchar *str)
+static void imap_path_separator_subst(gchar *str, gchar separator)
 {
-       subst_char(str, '/', '.');
+       if (separator != '/')
+               subst_char(str, '/', separator);
 }
index 6b15979..af67261 100644 (file)
@@ -110,6 +110,8 @@ gint imap_remove_all_msg            (Folder         *folder,
 void imap_scan_folder                  (Folder         *folder,
                                         FolderItem     *item);
 
+gint imap_create_tree                  (Folder         *folder);
+
 FolderItem *imap_create_folder         (Folder         *folder,
                                         FolderItem     *parent,
                                         const gchar    *name);
index 6fd12db..51e818f 100644 (file)
@@ -55,6 +55,7 @@ struct _SendProgressDialog
 {
        ProgressDialog *dialog;
        GList *queue_list;
+       gboolean cancelled;
 };
 
 static gint send_message_smtp  (GSList *to_list, const gchar *from,
@@ -97,9 +98,8 @@ gint send_message(const gchar *file, PrefsAccount *ac_prefs, GSList *to_list)
                domain = ac_prefs->set_domain ? ac_prefs->domain : NULL;
 
                val = send_message_smtp(to_list, ac_prefs->address,
-                                       ac_prefs->smtp_server, port,
-                                       domain, ac_prefs->userid,
-                                       ac_prefs->passwd,
+                                       ac_prefs->smtp_server, port, domain,
+                                        ac_prefs->userid, ac_prefs->passwd,
                                        ac_prefs->use_smtp_auth, fp);
        }
 
@@ -233,12 +233,21 @@ gint send_message_queue(const gchar *file)
        return val;
 }
 
+#define EXIT_IF_CANCELLED() \
+{ \
+       if (dialog->cancelled) { \
+               sock_close(smtp_sock); \
+               send_progress_dialog_destroy(dialog); \
+               return -1; \
+       } \
+}
+
 #define SEND_EXIT_IF_ERROR(f, s) \
 { \
+       EXIT_IF_CANCELLED(); \
        if (!(f)) { \
                log_warning("Error occurred while %s\n", s); \
                sock_close(smtp_sock); \
-               smtp_sock = NULL; \
                send_progress_dialog_destroy(dialog); \
                return -1; \
        } \
@@ -246,12 +255,12 @@ gint send_message_queue(const gchar *file)
 
 #define SEND_EXIT_IF_NOTOK(f, s) \
 { \
+       EXIT_IF_CANCELLED(); \
        if ((f) != SM_OK) { \
                log_warning("Error occurred while %s\n", s); \
                if (smtp_quit(smtp_sock) != SM_OK) \
                        log_warning("Error occurred while sending QUIT\n"); \
                sock_close(smtp_sock); \
-               smtp_sock = NULL; \
                send_progress_dialog_destroy(dialog); \
                return -1; \
        } \
@@ -263,7 +272,7 @@ static gint send_message_smtp(GSList *to_list, const gchar *from,
                              const gchar *passwd, gboolean use_smtp_auth,
                              FILE *fp)
 {
-       SockInfo *smtp_sock;
+       SockInfo *smtp_sock = NULL;
        SendProgressDialog *dialog;
        GtkCList *clist;
        const gchar *text[3];
@@ -410,6 +419,7 @@ static SendProgressDialog *send_progress_dialog_create(void)
 
        dialog->dialog = progress;
        dialog->queue_list = NULL;
+       dialog->cancelled = FALSE;
 
        return dialog;
 }
@@ -426,5 +436,5 @@ static void send_cancel(GtkWidget *widget, gpointer data)
 {
        SendProgressDialog *dialog = data;
 
-       g_print("cancelled\n");
+       dialog->cancelled = TRUE;
 }
index e30a5b0..7fe6c65 100644 (file)
@@ -190,6 +190,21 @@ gchar *strretchomp(gchar *str)
        return str;
 }
 
+/* remove trailing character */
+gchar *strtailchomp(gchar *str, gchar tail_char)
+{
+       register gchar *s;
+
+       if (!*str) return str;
+       if (tail_char == '\0') return str;
+
+       for (s = str + strlen(str) - 1; s >= str && *s == tail_char; s--)
+               *s = '\0';
+
+       return str;
+}
+
+
 /* Similar to `strstr' but this function ignores the case of both strings.  */
 gchar *strcasestr(const gchar *haystack, const gchar *needle)
 {
index a7de67f..de6de58 100644 (file)
@@ -141,6 +141,8 @@ gint strcmp2                (const gchar    *s1,
 gint path_cmp          (const gchar    *s1,
                         const gchar    *s2);
 gchar *strretchomp     (gchar          *str);
+gchar *strtailchomp    (gchar          *str,
+                        gchar           tail_char);
 gchar *strcasestr      (const gchar    *haystack,
                         const gchar    *needle);
 gchar *strncpy2                (gchar          *dest,