Updating branch refs/heads/master
         to 76c5b41bbab7ddd32e16aeeedb03deeac4a51c4c (commit)
       from 8be394950c30ff84da0723f963b07880e67f6e46 (commit)

commit 76c5b41bbab7ddd32e16aeeedb03deeac4a51c4c
Author: Christian Dywan <[email protected]>
Date:   Thu Nov 4 22:41:37 2010 +0100

    Encode subfolders with a ~ as separator

 isync/drv_imap.c    |    4 +++
 isync/drv_maildir.c |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/isync/drv_imap.c b/isync/drv_imap.c
index c52bb09..9966bfb 100644
--- a/isync/drv_imap.c
+++ b/isync/drv_imap.c
@@ -1749,7 +1749,11 @@ imap_list( store_t *gctx,
        imap_store_t *ctx = (imap_store_t *)gctx;
        int ret;
 
+#ifdef POSTLER_CHANGES
+       if ((ret = imap_exec_b( ctx, 0, "LIST \"\" \"%s*\"", ctx->prefix )) != 
DRV_OK)
+#else
        if ((ret = imap_exec_b( ctx, 0, "LIST \"\" \"%s%%\"", ctx->prefix )) == 
DRV_OK)
+#endif
                gctx->listed = 1;
        cb( ret, aux );
 }
diff --git a/isync/drv_maildir.c b/isync/drv_maildir.c
index 80a7cac..94d701e 100644
--- a/isync/drv_maildir.c
+++ b/isync/drv_maildir.c
@@ -24,6 +24,9 @@
 
 #include "isync.h"
 
+#ifdef POSTLER_CHANGES
+#include <assert.h>
+#endif
 #include <limits.h>
 #include <stdlib.h>
 #include <string.h>
@@ -46,6 +49,58 @@
 #include <db.h>
 #endif /* USE_DB */
 
+#ifdef POSTLER_CHANGES
+static void encode_maildir_box(const char* in, char* out, size_t size)
+{
+       const char* p;
+       char c;
+       size_t out_chars;
+
+       for (p = in, out_chars = 0; (c = *p); ++p, ++out, ++out_chars) {
+               assert(out_chars < size);
+               if (c == '/') {
+                       assert(out_chars < size - 1);
+                       *(out++) = '~';
+                       *out = '-';
+                       ++out_chars;
+               }
+               else if (c == '~') {
+                       assert(out_chars < size - 1);
+                       *(out++) = '~';
+                       *out = '~';
+                       ++out_chars;
+               }
+               else {
+                       *out = c;
+               }
+       }
+       assert(out_chars < size);
+       *out = 0;
+}
+
+static void decode_maildir_box(const char* in, char* out, size_t size)
+{
+       const char* p;
+       char c;
+       size_t out_chars;
+
+       for (p = in, out_chars = 0; (c = *p); ++p, ++out, ++out_chars) {
+               assert(out_chars < size);
+               if (c == '~') {
+                       assert(out_chars < size - 1);
+                       c = *(++p);
+                       *out = (c == '-' ? '/' : '~');
+                       ++out_chars;
+               }
+               else {
+                       *out = c;
+               }
+       }
+       assert(out_chars < size);
+       *out = 0;
+}
+#endif
+
 typedef struct maildir_store_conf {
        store_conf_t gen;
        char *inbox;
@@ -178,14 +233,23 @@ maildir_list( store_t *gctx,
                int bl;
                struct stat st;
                char buf[PATH_MAX];
+#ifdef POSTLER_CHANGES
+               char box[PATH_MAX];
+#endif
 
                if (*de->d_name == '.')
                        continue;
                bl = nfsnprintf( buf, sizeof(buf), "%s%s/cur", 
gctx->conf->path, de->d_name );
                if (stat( buf, &st ) || !S_ISDIR(st.st_mode))
                        continue;
+#ifdef POSTLER_CHANGES
+               decode_maildir_box(de->d_name, box, PATH_MAX);
+               add_string_list( &gctx->boxes,
+                                !memcmp( buf, inbox, bl - 4 ) && !inbox[bl - 
4] ? "INBOX" : box );
+#else
                add_string_list( &gctx->boxes,
                                 !memcmp( buf, inbox, bl - 4 ) && !inbox[bl - 
4] ? "INBOX" : de->d_name );
+#endif
        }
        closedir (dir);
        gctx->listed = 1;
@@ -753,8 +817,16 @@ maildir_prepare_paths( store_t *gctx )
 #endif /* USE_DB */
        if (!strcmp( gctx->name, "INBOX" ))
                gctx->path = nfstrdup( ((maildir_store_conf_t 
*)gctx->conf)->inbox );
+#ifdef POSTLER_CHANGES
+        else {
+            char box[_POSIX_PATH_MAX];
+            encode_maildir_box(gctx->name, box, _POSIX_PATH_MAX);
+            nfasprintf( &gctx->path, "%s%s", gctx->conf->path, box );
+        }
+#else
        else
                nfasprintf( &gctx->path, "%s%s", gctx->conf->path, gctx->name );
+#endif
 }
 
 static void
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to