allow spaces in imap foldernames
authorPaul Mangan <paul@claws-mail.org>
Sun, 9 Dec 2001 10:48:52 +0000 (10:48 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sun, 9 Dec 2001 10:48:52 +0000 (10:48 +0000)
AUTHORS
ChangeLog.claws
configure.in
src/imap.c
src/utils.h

diff --git a/AUTHORS b/AUTHORS
index 081aa352817db97710c65b472107839f6d859e76..d7e2c375fa293018bd4d34269e4b9e50cbeb2c26 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -97,3 +97,4 @@ contributors (beside the above; based on Changelog)
        Manrat Chobchuen
        Shimamoto "Neko" Tatsuya
         Jesse Skinner
+        Willem van Engen
index fa8aea52139a0c0cc9d7bb9deae438fc5a72dfd4..a3003a2bb36e548224c928226547abe196d8cd5a 100644 (file)
@@ -1,3 +1,10 @@
+2001-12-09 [paul]      0.6.5claws67
+
+       * src/imap.c
+        * src/utils.h
+               allow spaces in imap folder names
+                submitted by Willem van Engen <wvengen@stack.nl>
+
 2001-12-09 [paul]      0.6.5claws66
 
        * sync with sylpheed 0.6.5cvs24
index 8057ef6a87b794af31151d3893622303dc7bf9ee..ed4a24c9a21223074dff680d3563cfd23afd75e6 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws66
+EXTRA_VERSION=claws67
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index aefabf823317ec90a7a1c7e7bf2e5efb633fe08a..43e4b944dff8db24ade471153a221316833eb0cc 100644 (file)
@@ -708,6 +708,18 @@ gint imap_remove_msg(Folder *folder, FolderItem *item, gint uid)
        return IMAP_SUCCESS;
 }
 
+#define QUOTE_IF_REQUIRED(out, str) \
+{ \
+       if (*str != '"' && strchr(str, ' ')) { \
+               gint len; \
+               len = strlen(str) + 3; \
+               Xalloca(out, len, return IMAP_ERROR); \
+               g_snprintf(out, len, "\"%s\"", str); \
+       } else { \
+               Xstrdup_a(out, str, return IMAP_ERROR); \
+       } \
+}
+
 gint imap_remove_all_msg(Folder *folder, FolderItem *item)
 {
        gint exists, recent, unseen;
@@ -828,7 +840,7 @@ static void imap_scan_tree_recursive(IMAPSession *session,
        IMAPFolder *imapfolder;
        FolderItem *new_item;
        GSList *item_list, *cur;
-       gchar *real_path;
+       gchar *real_path, *wildcard_path, *wildcard_path_;
 
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
@@ -842,15 +854,21 @@ static void imap_scan_tree_recursive(IMAPSession *session,
 
        if (item->path) {
                real_path = imap_get_real_path(imapfolder, item->path);
-               imap_cmd_gen_send(SESSION(session)->sock, "LIST \"\" %s%c%%",
-                                 real_path,
+               Xstrconcat_a(wildcard_path, real_path,"/%", return IMAP_ERROR);
+               QUOTE_IF_REQUIRED(wildcard_path_, wildcard_path);
+               imap_cmd_gen_send(SESSION(session)->sock, "LIST \"\" %s",
+                                 wildcard_path_,
                                  namespace && namespace->separator
                                  ? namespace->separator : '/');
+               g_free(wildcard_path);
        } else {
                real_path = g_strdup(namespace && namespace->name
                                     ? namespace->name : "");
-               imap_cmd_gen_send(SESSION(session)->sock, "LIST \"\" %s%%",
-                                 real_path);
+               Xstrconcat_a(wildcard_path, real_path, "%", return IMAP_ERROR);
+               QUOTE_IF_REQUIRED(wildcard_path_, wildcard_path);
+               imap_cmd_gen_send(SESSION(session)->sock, "LIST \"\" %s",
+                                 wildcard_path_);
+               g_free(wildcard_path);
        }
 
        strtailchomp(real_path, namespace && namespace->separator
@@ -1819,18 +1837,6 @@ catch:
        return ok;
 }
 
-#define QUOTE_IF_REQUIRED(out, str) \
-{ \
-       if (*str != '"' && strchr(str, ' ')) { \
-               gint len; \
-               len = strlen(str) + 3; \
-               Xalloca(out, len, return IMAP_ERROR); \
-               g_snprintf(out, len, "\"%s\"", str); \
-       } else { \
-               Xstrdup_a(out, str, return IMAP_ERROR); \
-       } \
-}
-
 static gint imap_status(IMAPSession *session, IMAPFolder *folder,
                        const gchar *path,
                        gint *messages, gint *recent, gint *unseen,
@@ -2115,14 +2121,16 @@ static gint imap_cmd_append(SockInfo *sock, const gchar *destfolder,
 {
        gint ok;
        gint size;
+        gchar *destfolder_;
 
        g_return_val_if_fail(file != NULL, IMAP_ERROR);
 
        size = get_file_size(file);
-       imap_cmd_gen_send(sock, "APPEND %s {%d}", destfolder, size);
+       QUOTE_IF_REQUIRED(destfolder_, destfolder);
+       imap_cmd_gen_send(sock, "APPEND %s {%d}", destfolder_, size);
        ok = imap_cmd_ok(sock, NULL);
        if (ok != IMAP_SUCCESS) {
-               log_warning(_("can't append %s to %s\n"), file, destfolder);
+               log_warning(_("can't append %s to %s\n"), file, destfolder_);
                return -1;
        }
 
index 61bbccd0553de15a7841bb92c83bb40095a89d14..1d3729fec3628a15e6ba346cdabf5f1ecdc8907b 100644 (file)
        ptr = __tmp; \
 }
 
+#define Xstrconcat_a(ptr, str1, str2, iffail) \
+{ \
+       gchar *__tmp; \
+ \
+       if ((__tmp = alloca(strlen(str1) + strlen(str2) + 1)) == NULL) { \
+               g_warning("can't allocate memory\n"); \
+               iffail; \
+       } else { \
+               strcpy(__tmp, str1); \
+               strcat(__tmp, str2); \
+       } \
+ \
+       ptr = __tmp; \
+}
+
 #define FILE_OP_ERROR(file, func) \
 { \
        fprintf(stderr, "%s: ", file); \