|
|
|
@ -38,7 +38,6 @@
|
|
|
|
|
#include <time.h> |
|
|
|
|
#include <utime.h> |
|
|
|
|
|
|
|
|
|
#define USE_DB 1 |
|
|
|
|
#ifdef __linux__ |
|
|
|
|
# define LEGACY_FLOCK 1 |
|
|
|
|
#endif |
|
|
|
@ -229,10 +228,12 @@ maildir_invoke_bad_callback( store_t *ctx )
|
|
|
|
|
ctx->bad_callback( ctx->bad_callback_aux ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int maildir_list_inbox( store_t *gctx, int *flags ); |
|
|
|
|
static int maildir_list_inbox( store_t *gctx, int flags, const char *basePath ); |
|
|
|
|
static int maildir_list_path( store_t *gctx, int flags, const char *inbox ); |
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox, int inboxLen, |
|
|
|
|
maildir_list_recurse( store_t *gctx, int isBox, int flags, |
|
|
|
|
const char *inbox, int inboxLen, const char *basePath, int basePathLen, |
|
|
|
|
char *path, int pathLen, char *name, int nameLen ) |
|
|
|
|
{ |
|
|
|
|
DIR *dir; |
|
|
|
@ -259,7 +260,14 @@ maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox, i
|
|
|
|
|
const char *ent = de->d_name; |
|
|
|
|
pl = pathLen + nfsnprintf( path + pathLen, _POSIX_PATH_MAX - pathLen, "%s", ent ); |
|
|
|
|
if (inbox && equals( path, pl, inbox, inboxLen )) { |
|
|
|
|
if (maildir_list_inbox( gctx, flags ) < 0) { |
|
|
|
|
/* Inbox nested into Path. List now if it won't be listed separately anyway. */ |
|
|
|
|
if (!(flags & LIST_INBOX) && maildir_list_inbox( gctx, flags, 0 ) < 0) { |
|
|
|
|
closedir( dir ); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
} 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) { |
|
|
|
|
closedir( dir ); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
@ -280,7 +288,7 @@ maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox, i
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
nl = nameLen + nfsnprintf( name + nameLen, _POSIX_PATH_MAX - nameLen, "%s", ent ); |
|
|
|
|
if (maildir_list_recurse( gctx, 1, flags, inbox, inboxLen, path, pl, name, nl ) < 0) { |
|
|
|
|
if (maildir_list_recurse( gctx, 1, flags, inbox, inboxLen, basePath, basePathLen, path, pl, name, nl ) < 0) { |
|
|
|
|
closedir( dir ); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
@ -291,27 +299,25 @@ maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox, i
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
maildir_list_inbox( store_t *gctx, int *flags ) |
|
|
|
|
maildir_list_inbox( store_t *gctx, int flags, const char *basePath ) |
|
|
|
|
{ |
|
|
|
|
char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; |
|
|
|
|
|
|
|
|
|
*flags &= ~LIST_INBOX; |
|
|
|
|
return maildir_list_recurse( |
|
|
|
|
gctx, 2, flags, 0, 0, |
|
|
|
|
gctx, 2, flags, 0, 0, basePath, basePath ? strlen( basePath ) - 1 : 0, |
|
|
|
|
path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ((maildir_store_conf_t *)gctx->conf)->inbox ), |
|
|
|
|
name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX" ) ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
maildir_list_path( store_t *gctx, int *flags ) |
|
|
|
|
maildir_list_path( store_t *gctx, int flags, const char *inbox ) |
|
|
|
|
{ |
|
|
|
|
const char *inbox = ((maildir_store_conf_t *)gctx->conf)->inbox; |
|
|
|
|
char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; |
|
|
|
|
|
|
|
|
|
if (maildir_validate_path( gctx->conf ) < 0) |
|
|
|
|
return -1; |
|
|
|
|
return maildir_list_recurse( |
|
|
|
|
gctx, 0, flags, inbox, strlen( inbox ), |
|
|
|
|
gctx, 0, flags, inbox, inbox ? strlen( inbox ) : 0, 0, 0, |
|
|
|
|
path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", gctx->conf->path ), |
|
|
|
|
name, 0 ); |
|
|
|
|
} |
|
|
|
@ -320,8 +326,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 ) < 0) || |
|
|
|
|
((flags & LIST_INBOX) && maildir_list_inbox( gctx, &flags ) < 0)) { |
|
|
|
|
if (((flags & LIST_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 ); |
|
|
|
|
} else { |
|
|
|
@ -1366,6 +1372,7 @@ maildir_store_msg( store_t *gctx, msg_data_t *data, int to_trash,
|
|
|
|
|
} |
|
|
|
|
box = gctx->path; |
|
|
|
|
} else { |
|
|
|
|
uid = 0; |
|
|
|
|
box = ctx->trash; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1464,7 +1471,7 @@ maildir_set_msg_flags( store_t *gctx, message_t *gmsg, int uid ATTR_UNUSED, int
|
|
|
|
|
for (i = 0; i < as(Flags); i++) { |
|
|
|
|
if ((p = strchr( s, Flags[i] ))) { |
|
|
|
|
if (del & (1 << i)) { |
|
|
|
|
memcpy( p, p + 1, fl - (p - s) ); |
|
|
|
|
memmove( p, p + 1, fl - (p - s) ); |
|
|
|
|
fl--; |
|
|
|
|
} |
|
|
|
|
} else if (add & (1 << i)) { |
|
|
|
|