diff --git a/src/driver.h b/src/driver.h index 358f52d..1abf671 100644 --- 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 index cf02760..f27e58e 100644 --- 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 index 3f000ff..a91b7cc 100644 --- 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 index fa0b936..c8c3bf2 100644 --- 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;