don't mess with the driver's mailbox list from outside
the api specifies that the list remains owned by the driver, so poking around in it is ugly and risky.
This commit is contained in:
parent
c886f71054
commit
96b5ae8360
32
src/main.c
32
src/main.c
|
@ -381,6 +381,7 @@ typedef struct {
|
||||||
store_t *ctx[2];
|
store_t *ctx[2];
|
||||||
chan_ent_t *chanptr;
|
chan_ent_t *chanptr;
|
||||||
box_ent_t *boxptr;
|
box_ent_t *boxptr;
|
||||||
|
string_list_t *boxes[2];
|
||||||
char *names[2];
|
char *names[2];
|
||||||
int ret, all, list, state[2];
|
int ret, all, list, state[2];
|
||||||
char done, skip, cben;
|
char done, skip, cben;
|
||||||
|
@ -835,8 +836,8 @@ sync_chans( main_vars_t *mvars, int ent )
|
||||||
|
|
||||||
if (!mvars->chanptr->boxlist && mvars->chan->patterns) {
|
if (!mvars->chanptr->boxlist && mvars->chan->patterns) {
|
||||||
mvars->chanptr->boxlist = 2;
|
mvars->chanptr->boxlist = 2;
|
||||||
boxes[M] = filter_boxes( mvars->ctx[M]->boxes, mvars->chan->boxes[M], mvars->chan->patterns );
|
boxes[M] = filter_boxes( mvars->boxes[M], mvars->chan->boxes[M], mvars->chan->patterns );
|
||||||
boxes[S] = filter_boxes( mvars->ctx[S]->boxes, mvars->chan->boxes[S], mvars->chan->patterns );
|
boxes[S] = filter_boxes( mvars->boxes[S], mvars->chan->boxes[S], mvars->chan->patterns );
|
||||||
mboxapp = &mvars->chanptr->boxes;
|
mboxapp = &mvars->chanptr->boxes;
|
||||||
for (mb = sb = 0; ; ) {
|
for (mb = sb = 0; ; ) {
|
||||||
char *mname = boxes[M] ? boxes[M][mb] : 0;
|
char *mname = boxes[M] ? boxes[M][mb] : 0;
|
||||||
|
@ -901,7 +902,9 @@ sync_chans( main_vars_t *mvars, int ent )
|
||||||
|
|
||||||
next:
|
next:
|
||||||
mvars->cben = 0;
|
mvars->cben = 0;
|
||||||
for (t = 0; t < 2; t++)
|
for (t = 0; t < 2; t++) {
|
||||||
|
free_string_list( mvars->boxes[t] );
|
||||||
|
mvars->boxes[t] = 0;
|
||||||
if (mvars->state[t] == ST_FRESH) {
|
if (mvars->state[t] == ST_FRESH) {
|
||||||
/* An unconnected store may be only cancelled. */
|
/* An unconnected store may be only cancelled. */
|
||||||
mvars->state[t] = ST_CLOSED;
|
mvars->state[t] = ST_CLOSED;
|
||||||
|
@ -910,6 +913,7 @@ sync_chans( main_vars_t *mvars, int ent )
|
||||||
mvars->state[t] = ST_CANCELING;
|
mvars->state[t] = ST_CANCELING;
|
||||||
mvars->drv[t]->cancel_cmds( mvars->ctx[t], cancel_prep_done, AUX );
|
mvars->drv[t]->cancel_cmds( mvars->ctx[t], cancel_prep_done, AUX );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mvars->cben = 1;
|
mvars->cben = 1;
|
||||||
if (mvars->state[M] != ST_CLOSED || mvars->state[S] != ST_CLOSED) {
|
if (mvars->state[M] != ST_CLOSED || mvars->state[S] != ST_CLOSED) {
|
||||||
mvars->skip = 1;
|
mvars->skip = 1;
|
||||||
|
@ -998,7 +1002,8 @@ static void
|
||||||
store_listed( int sts, void *aux )
|
store_listed( int sts, void *aux )
|
||||||
{
|
{
|
||||||
MVARS(aux)
|
MVARS(aux)
|
||||||
string_list_t **box, *bx;
|
string_list_t *boxes = mvars->ctx[t]->boxes;
|
||||||
|
string_list_t *box;
|
||||||
|
|
||||||
switch (sts) {
|
switch (sts) {
|
||||||
case DRV_CANCELED:
|
case DRV_CANCELED:
|
||||||
|
@ -1006,25 +1011,26 @@ store_listed( int sts, void *aux )
|
||||||
case DRV_OK:
|
case DRV_OK:
|
||||||
if (DFlags & DEBUG_MAIN) {
|
if (DFlags & DEBUG_MAIN) {
|
||||||
debug( "got mailbox list from %s:\n", str_ms[t] );
|
debug( "got mailbox list from %s:\n", str_ms[t] );
|
||||||
for (bx = mvars->ctx[t]->boxes; bx; bx = bx->next)
|
for (box = boxes; box; box = box->next)
|
||||||
debug( " %s\n", bx->string );
|
debug( " %s\n", box->string );
|
||||||
}
|
}
|
||||||
|
for (box = boxes; box; box = box->next) {
|
||||||
if (mvars->ctx[t]->conf->flat_delim) {
|
if (mvars->ctx[t]->conf->flat_delim) {
|
||||||
for (box = &mvars->ctx[t]->boxes; *box; box = &(*box)->next) {
|
|
||||||
string_list_t *nbox;
|
string_list_t *nbox;
|
||||||
if (map_name( (*box)->string, (char **)&nbox, offsetof(string_list_t, string), mvars->ctx[t]->conf->flat_delim, "/" ) < 0) {
|
if (map_name( box->string, (char **)&nbox, offsetof(string_list_t, string), mvars->ctx[t]->conf->flat_delim, "/" ) < 0) {
|
||||||
error( "Error: flattened mailbox name '%s' contains canonical hierarchy delimiter\n", (*box)->string );
|
error( "Error: flattened mailbox name '%s' contains canonical hierarchy delimiter\n", box->string );
|
||||||
mvars->ret = mvars->skip = 1;
|
mvars->ret = mvars->skip = 1;
|
||||||
} else {
|
} else {
|
||||||
nbox->next = (*box)->next;
|
nbox->next = mvars->boxes[t];
|
||||||
free( *box );
|
mvars->boxes[t] = nbox;
|
||||||
*box = nbox;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
add_string_list( &mvars->boxes[t], box->string );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mvars->ctx[t]->conf->map_inbox) {
|
if (mvars->ctx[t]->conf->map_inbox) {
|
||||||
debug( "adding mapped inbox to %s: %s\n", str_ms[t], mvars->ctx[t]->conf->map_inbox );
|
debug( "adding mapped inbox to %s: %s\n", str_ms[t], mvars->ctx[t]->conf->map_inbox );
|
||||||
add_string_list( &mvars->ctx[t]->boxes, mvars->ctx[t]->conf->map_inbox );
|
add_string_list( &mvars->boxes[t], mvars->ctx[t]->conf->map_inbox );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user