isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 17f3348ff1765a4238a2202a224510e942453260
parent 72c2d695ac5f9c9d81a662dcefd4b80426d8ec14
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Sat, 23 May 2015 11:06:17 +0200

make it possible to specifiy Pattern INBOX* with no Path defined

that pattern may very well expand to INBOXNOT, which would naturally
live under Path, so we need to look into the Path. of course, this
actually makes sense only if there *is* a Path, and complaining about
it being absent is backwards.

Diffstat:
Msrc/driver.h | 5+++--
Msrc/drv_imap.c | 4++--
Msrc/drv_maildir.c | 5+++--
Msrc/main.c | 9++++-----
4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/driver.h b/src/driver.h @@ -139,8 +139,9 @@ typedef struct { */ #define DRV_VERBOSE 2 -#define LIST_PATH 1 -#define LIST_INBOX 2 +#define LIST_INBOX 1 +#define LIST_PATH 2 +#define LIST_PATH_MAYBE 4 struct driver { int flags; diff --git a/src/drv_imap.c b/src/drv_imap.c @@ -2620,10 +2620,10 @@ imap_list_store( store_t *gctx, int flags, imap_store_t *ctx = (imap_store_t *)gctx; struct imap_cmd_refcounted_state *sts = imap_refcounted_new_state( cb, aux ); - if ((flags & LIST_PATH) && (!(flags & LIST_INBOX) || !is_inbox( ctx, ctx->prefix, -1 ))) + if ((flags & (LIST_PATH | LIST_PATH_MAYBE)) && (!(flags & LIST_INBOX) || !is_inbox( ctx, ctx->prefix, -1 ))) imap_exec( ctx, imap_refcounted_new_cmd( sts ), imap_refcounted_done_box, "LIST \"\" \"%\\s*\"", ctx->prefix ); - if ((flags & LIST_INBOX) && (!(flags & LIST_PATH) || *ctx->prefix)) + if ((flags & LIST_INBOX) && (!(flags & (LIST_PATH | LIST_PATH_MAYBE)) || *ctx->prefix)) imap_exec( ctx, imap_refcounted_new_cmd( sts ), imap_refcounted_done_box, "LIST \"\" INBOX*" ); imap_refcounted_done( sts ); diff --git a/src/drv_maildir.c b/src/drv_maildir.c @@ -325,7 +325,7 @@ maildir_list_recurse( store_t *gctx, int isBox, int flags, } } else if (basePath && equals( path, pl, basePath, basePathLen )) { /* Path nested into Inbox. List now if it won't be listed separately anyway. */ - if (!(flags & LIST_PATH) && maildir_list_path( gctx, flags, 0 ) < 0) { + if (!(flags & (LIST_PATH | LIST_PATH_MAYBE)) && maildir_list_path( gctx, flags, 0 ) < 0) { closedir( dir ); return -1; } @@ -401,7 +401,8 @@ static void maildir_list_store( store_t *gctx, int flags, void (*cb)( int sts, void *aux ), void *aux ) { - if (((flags & LIST_PATH) && maildir_list_path( gctx, flags, ((maildir_store_conf_t *)gctx->conf)->inbox ) < 0) || + if ((((flags & LIST_PATH) || ((flags & LIST_PATH_MAYBE) && gctx->conf->path)) + && maildir_list_path( gctx, flags, ((maildir_store_conf_t *)gctx->conf)->inbox ) < 0) || ((flags & LIST_INBOX) && maildir_list_inbox( gctx, flags, gctx->conf->path ) < 0)) { maildir_invoke_bad_callback( gctx ); cb( DRV_CANCELED, aux ); diff --git a/src/main.c b/src/main.c @@ -945,13 +945,12 @@ store_connected( int sts, void *aux ) flags |= LIST_PATH; else flags |= LIST_INBOX; + } else if (c == '*' || c == '%') { + /* It can be both INBOX and Path, but don't require Path to be configured. */ + flags |= LIST_INBOX | LIST_PATH_MAYBE; } else { - /* User may not want the INBOX after all ... */ + /* It's definitely not the INBOX. */ flags |= LIST_PATH; - /* ... but maybe he does. - * The flattened sub-folder case is implicitly covered by the previous line. */ - if (c == '*' || c == '%') - flags |= LIST_INBOX; } } else { flags |= LIST_PATH;