split off open_box() from select_box()
aka prepare_paths() reloaded. we'll need it in a moment.
This commit is contained in:
parent
97a42cd825
commit
fb19d644f7
|
@ -161,9 +161,12 @@ struct driver {
|
||||||
void (*list_store)( store_t *ctx, int flags,
|
void (*list_store)( store_t *ctx, int flags,
|
||||||
void (*cb)( int sts, void *aux ), void *aux );
|
void (*cb)( int sts, void *aux ), void *aux );
|
||||||
|
|
||||||
/* Open the mailbox name. Optionally create missing boxes.
|
/* Invoked before open_box(), this informs the driver which box is to be opened.
|
||||||
* As a side effect, this should resolve ctx->path if applicable. */
|
* As a side effect, this should resolve ctx->path if applicable. */
|
||||||
void (*select_box)( store_t *ctx, const char *name, int create,
|
int (*select_box)( store_t *ctx, const char *name );
|
||||||
|
|
||||||
|
/* Open the selected mailbox. Optionally create missing boxes. */
|
||||||
|
void (*open_box)( store_t *ctx, int create,
|
||||||
void (*cb)( int sts, void *aux ), void *aux );
|
void (*cb)( int sts, void *aux ), void *aux );
|
||||||
|
|
||||||
/* Invoked before load_box(), this informs the driver which operations (OP_*)
|
/* Invoked before load_box(), this informs the driver which operations (OP_*)
|
||||||
|
|
|
@ -2108,21 +2108,29 @@ imap_open_store_bail( imap_store_t *ctx )
|
||||||
cb( 0, aux );
|
cb( 0, aux );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************* imap_select_box *******************/
|
/******************* imap_open_box *******************/
|
||||||
|
|
||||||
static void
|
static int
|
||||||
imap_select_box( store_t *gctx, const char *name, int create,
|
imap_select_box( store_t *gctx, const char *name )
|
||||||
void (*cb)( int sts, void *aux ), void *aux )
|
|
||||||
{
|
{
|
||||||
imap_store_t *ctx = (imap_store_t *)gctx;
|
imap_store_t *ctx = (imap_store_t *)gctx;
|
||||||
struct imap_cmd_simple *cmd;
|
|
||||||
char *buf;
|
|
||||||
|
|
||||||
free_generic_messages( gctx->msgs );
|
free_generic_messages( gctx->msgs );
|
||||||
gctx->msgs = 0;
|
gctx->msgs = 0;
|
||||||
ctx->msgapp = &gctx->msgs;
|
ctx->msgapp = &gctx->msgs;
|
||||||
|
|
||||||
ctx->name = name;
|
ctx->name = name;
|
||||||
|
return DRV_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
imap_open_box( store_t *gctx, int create,
|
||||||
|
void (*cb)( int sts, void *aux ), void *aux )
|
||||||
|
{
|
||||||
|
imap_store_t *ctx = (imap_store_t *)gctx;
|
||||||
|
struct imap_cmd_simple *cmd;
|
||||||
|
char *buf;
|
||||||
|
|
||||||
if (prepare_box( &buf, ctx ) < 0) {
|
if (prepare_box( &buf, ctx ) < 0) {
|
||||||
cb( DRV_BOX_BAD, aux );
|
cb( DRV_BOX_BAD, aux );
|
||||||
return;
|
return;
|
||||||
|
@ -2780,6 +2788,7 @@ struct driver imap_driver = {
|
||||||
imap_cancel_store,
|
imap_cancel_store,
|
||||||
imap_list_store,
|
imap_list_store,
|
||||||
imap_select_box,
|
imap_select_box,
|
||||||
|
imap_open_box,
|
||||||
imap_prepare_load_box,
|
imap_prepare_load_box,
|
||||||
imap_load_box,
|
imap_load_box,
|
||||||
imap_fetch_msg,
|
imap_fetch_msg,
|
||||||
|
|
|
@ -926,16 +926,10 @@ maildir_app_msg( maildir_store_t *ctx, message_t ***msgapp, msg_t *entry )
|
||||||
maildir_init_msg( ctx, msg, entry );
|
maildir_init_msg( ctx, msg, entry );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
maildir_select_box( store_t *gctx, const char *name, int create,
|
maildir_select_box( store_t *gctx, const char *name )
|
||||||
void (*cb)( int sts, void *aux ), void *aux )
|
|
||||||
{
|
{
|
||||||
maildir_store_t *ctx = (maildir_store_t *)gctx;
|
maildir_store_t *ctx = (maildir_store_t *)gctx;
|
||||||
int ret;
|
|
||||||
#ifdef USE_DB
|
|
||||||
struct stat st;
|
|
||||||
#endif /* USE_DB */
|
|
||||||
char uvpath[_POSIX_PATH_MAX];
|
|
||||||
|
|
||||||
maildir_cleanup( gctx );
|
maildir_cleanup( gctx );
|
||||||
gctx->msgs = 0;
|
gctx->msgs = 0;
|
||||||
|
@ -948,12 +942,24 @@ maildir_select_box( store_t *gctx, const char *name, int create,
|
||||||
gctx->path = maildir_join_path( ((maildir_store_conf_t *)gctx->conf)->inbox, name + 5 );
|
gctx->path = maildir_join_path( ((maildir_store_conf_t *)gctx->conf)->inbox, name + 5 );
|
||||||
} else {
|
} else {
|
||||||
if (maildir_validate_path( gctx->conf ) < 0) {
|
if (maildir_validate_path( gctx->conf ) < 0) {
|
||||||
maildir_invoke_bad_callback( gctx );
|
gctx->path = 0;
|
||||||
cb( DRV_CANCELED, aux );
|
return DRV_CANCELED;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
gctx->path = maildir_join_path( gctx->conf->path, name );
|
gctx->path = maildir_join_path( gctx->conf->path, name );
|
||||||
}
|
}
|
||||||
|
return DRV_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
maildir_open_box( store_t *gctx, int create,
|
||||||
|
void (*cb)( int sts, void *aux ), void *aux )
|
||||||
|
{
|
||||||
|
maildir_store_t *ctx = (maildir_store_t *)gctx;
|
||||||
|
int ret;
|
||||||
|
#ifdef USE_DB
|
||||||
|
struct stat st;
|
||||||
|
#endif /* USE_DB */
|
||||||
|
char uvpath[_POSIX_PATH_MAX];
|
||||||
|
|
||||||
if ((ret = maildir_validate( gctx->path, create, ctx )) != DRV_OK) {
|
if ((ret = maildir_validate( gctx->path, create, ctx )) != DRV_OK) {
|
||||||
cb( ret, aux );
|
cb( ret, aux );
|
||||||
|
@ -1532,6 +1538,7 @@ struct driver maildir_driver = {
|
||||||
maildir_disown_store, /* _cancel_, but it's the same */
|
maildir_disown_store, /* _cancel_, but it's the same */
|
||||||
maildir_list_store,
|
maildir_list_store,
|
||||||
maildir_select_box,
|
maildir_select_box,
|
||||||
|
maildir_open_box,
|
||||||
maildir_prepare_load_box,
|
maildir_prepare_load_box,
|
||||||
maildir_load_box,
|
maildir_load_box,
|
||||||
maildir_fetch_msg,
|
maildir_fetch_msg,
|
||||||
|
|
|
@ -599,7 +599,7 @@ sync_chans( main_vars_t *mvars, int ent )
|
||||||
else
|
else
|
||||||
labels[M] = labels[S] = "";
|
labels[M] = labels[S] = "";
|
||||||
for (t = 0; ; t++) {
|
for (t = 0; ; t++) {
|
||||||
info( "Opening %s %s...\n", str_ms[t], mvars->chan->stores[t]->name );
|
info( "Opening %s store %s...\n", str_ms[t], mvars->chan->stores[t]->name );
|
||||||
mvars->drv[t] = mvars->chan->stores[t]->driver;
|
mvars->drv[t] = mvars->chan->stores[t]->driver;
|
||||||
mvars->drv[t]->open_store( mvars->chan->stores[t], labels[t], store_opened, AUX );
|
mvars->drv[t]->open_store( mvars->chan->stores[t], labels[t], store_opened, AUX );
|
||||||
if (t)
|
if (t)
|
||||||
|
|
14
src/sync.c
14
src/sync.c
|
@ -919,7 +919,7 @@ load_state( sync_vars_t *svars )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void box_selected( int sts, void *aux );
|
static void box_opened( int sts, void *aux );
|
||||||
|
|
||||||
void
|
void
|
||||||
sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan,
|
sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan,
|
||||||
|
@ -957,10 +957,16 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan,
|
||||||
}
|
}
|
||||||
/* Both boxes must be fully set up at this point, so that error exit paths
|
/* Both boxes must be fully set up at this point, so that error exit paths
|
||||||
* don't run into uninitialized variables. */
|
* don't run into uninitialized variables. */
|
||||||
|
for (t = 0; t < 2; t++) {
|
||||||
|
if (svars->drv[t]->select_box( ctx[t], svars->box_name[t] ) == DRV_CANCELED) {
|
||||||
|
store_bad( AUX );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
sync_ref( svars );
|
sync_ref( svars );
|
||||||
for (t = 0; t < 2; t++) {
|
for (t = 0; t < 2; t++) {
|
||||||
info( "Selecting %s %s...\n", str_ms[t], svars->orig_name[t] );
|
info( "Opening %s box %s...\n", str_ms[t], svars->orig_name[t] );
|
||||||
svars->drv[t]->select_box( ctx[t], svars->box_name[t], (chan->ops[t] & OP_CREATE) != 0, box_selected, AUX );
|
svars->drv[t]->open_box( ctx[t], (chan->ops[t] & OP_CREATE) != 0, box_opened, AUX );
|
||||||
if (check_cancel( svars ))
|
if (check_cancel( svars ))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -970,7 +976,7 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan,
|
||||||
static void load_box( sync_vars_t *svars, int t, int minwuid, int *mexcs, int nmexcs );
|
static void load_box( sync_vars_t *svars, int t, int minwuid, int *mexcs, int nmexcs );
|
||||||
|
|
||||||
static void
|
static void
|
||||||
box_selected( int sts, void *aux )
|
box_opened( int sts, void *aux )
|
||||||
{
|
{
|
||||||
DECL_SVARS;
|
DECL_SVARS;
|
||||||
sync_rec_t *srec;
|
sync_rec_t *srec;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user