commit 990cc112f1d6807adfe07a550bedd179177d5949 Author: Oswald Buddenhagen <o...@users.sf.net> Date: Tue Nov 26 15:49:19 2019 +0100
Add option to use IMAP LSUB instead of LIST Based on patch by Cedric Ware <cedric.ware__...@normalesup.org> NEWS | 2 ++ src/drv_imap.c | 10 +++++++--- src/mbsync.1 | 8 ++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 18e4f13..d1a27aa 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ The IMAP '$Forwarded' / Maildir 'P' (passed) flag is supported now. Support for configuring a TLS cipher string was added. +IMAP mailbox subscriptions are supported now. + [1.3.0] Network timeout handling has been added. diff --git a/src/drv_imap.c b/src/drv_imap.c index 5563ff4..7d271bd 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -66,6 +66,7 @@ typedef struct { imap_server_conf_t *server; char delimiter; char use_namespace; + char use_lsub; } imap_store_conf_t; typedef struct { @@ -1453,7 +1454,7 @@ imap_socket_read( void *aux ) error( "Error from IMAP server: %s\n", cmd ); } else if (!strcmp( "CAPABILITY", arg )) { parse_capability( ctx, cmd ); - } else if (!strcmp( "LIST", arg )) { + } else if (!strcmp( "LIST", arg ) || !strcmp( "LSUB", arg )) { resp = parse_list( ctx, cmd, parse_list_rsp ); goto listret; } else if (!strcmp( "NAMESPACE", arg )) { @@ -3083,6 +3084,7 @@ imap_list_store( store_t *gctx, int flags, void (*cb)( int sts, string_list_t *boxes, void *aux ), void *aux ) { imap_store_t *ctx = (imap_store_t *)gctx; + imap_store_conf_t *cfg = (imap_store_conf_t *)ctx->gen.conf; INIT_REFCOUNTED_STATE(imap_list_store_state_t, sts, cb, aux) // ctx->prefix may be empty, "INBOX.", or something else. @@ -3106,14 +3108,14 @@ imap_list_store( store_t *gctx, int flags, if (pfx_is_empty) ctx->listed |= LIST_INBOX; imap_exec( ctx, imap_refcounted_new_cmd( &sts->gen ), imap_list_store_p2, - "LIST \"\" \"%\\s*\"", ctx->prefix ); + "%s \"\" \"%\\s*\"", cfg->use_lsub ? "LSUB" : "LIST", ctx->prefix ); } if (((flags & LIST_INBOX) || pfx_is_inbox) && !pfx_is_empty && !(ctx->listed & LIST_INBOX)) { ctx->listed |= LIST_INBOX; if (pfx_is_inbox) ctx->listed |= LIST_PATH; imap_exec( ctx, imap_refcounted_new_cmd( &sts->gen ), imap_list_store_p2, - "LIST \"\" INBOX*" ); + "%s \"\" INBOX*", cfg->use_lsub ? "LSUB" : "LIST" ); } imap_list_store_p3( ctx, sts ); } @@ -3373,6 +3375,8 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep ) store->server = srv; } else if (!strcasecmp( "UseNamespace", cfg->cmd )) store->use_namespace = parse_bool( cfg ); + else if (!strcasecmp( "SubscribedOnly", cfg->cmd )) + store->use_lsub = parse_bool( cfg ); else if (!strcasecmp( "Path", cfg->cmd )) store->gen.path = nfstrdup( cfg->val ); else if (!strcasecmp( "PathDelimiter", cfg->cmd )) { diff --git a/src/mbsync.1 b/src/mbsync.1 index 325385f..423d796 100644 --- a/src/mbsync.1 +++ b/src/mbsync.1 @@ -466,6 +466,14 @@ Specify the server's hierarchy delimiter. Do \fInot\fR abuse this to re-interpret the hierarchy. Use \fBFlatten\fR instead. . +.TP +\fBSubscribedOnly\fR \fByes\fR|\fBno\fR +Selects whether to synchronize only mailboxes that are subscribed to on the +IMAP server. In technical terms, if this option is set, \fBmbsync\fR will use +the IMAP command LSUB instead of LIST to look for mailboxes in this Store. +This option make sense only in conjunction with \fBPatterns\fR. +(Default: \fBno\fR) +. .SS Channels .TP \fBChannel\fR \fIname\fR _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel