CVS commit by ossi: keep the result of driver->list() and a flag whether it is valid in the store.
M +9 -8 drv_imap.c 1.21 M +4 -3 drv_maildir.c 1.14 M +3 -1 isync.h 1.57 M +7 -20 main.c 1.55 --- isync/src/drv_imap.c #1.20:1.21 @@ -114,5 +114,4 @@ typedef struct imap_store { int uidnext; /* from SELECT responses */ list_t *ns_personal, *ns_other, *ns_shared; /* NAMESPACE info */ - string_list_t *boxes; /* LIST results */ message_t **msgapp; /* FETCH results */ unsigned caps, rcaps; /* CAPABILITY results */ @@ -899,5 +898,5 @@ parse_list_rsp( imap_store_t *ctx, char if (!memcmp( arg + strlen( arg ) - 5, ".lock", 5 )) /* workaround broken servers */ return; - add_string_list( &ctx->boxes, arg ); + add_string_list( &ctx->gen.boxes, arg ); } @@ -1043,4 +1042,5 @@ imap_close_store( store_t *gctx ) free_generic_messages( gctx->msgs ); + free_string_list( ctx->gen.boxes ); if (ctx->buf.sock.fd != -1) { imap_exec( ctx, 0, "LOGOUT" ); @@ -1181,4 +1181,7 @@ imap_open_store( store_conf_t *conf, sto if (ctx) { if (((imap_store_conf_t *)(ctx->gen.conf))->server == cfg->server) { + free_string_list( ctx->gen.boxes ); + ctx->gen.boxes = 0; + ctx->gen.listed = 0; ctx->gen.conf = conf; goto final; @@ -1587,14 +1590,12 @@ imap_find_msg( store_t *gctx, const char static int -imap_list( store_t *gctx, string_list_t **retb ) +imap_list( store_t *gctx ) { imap_store_t *ctx = (imap_store_t *)gctx; int ret; - ctx->boxes = 0; - if ((ret = imap_exec_b( ctx, 0, "LIST \"\" \"%s%%\"", ctx->prefix )) != DRV_OK) + if ((ret = imap_exec_b( ctx, 0, "LIST \"\" \"%s%%\"", ctx->prefix )) == DRV_OK) + gctx->listed = 1; return ret; - *retb = ctx->boxes; - return DRV_OK; } --- isync/src/drv_maildir.c #1.13:1.14 @@ -148,9 +148,10 @@ maildir_close_store( store_t *gctx ) { maildir_cleanup( gctx ); + free_string_list( gctx->boxes ); free( gctx ); } static int -maildir_list( store_t *gctx, string_list_t **retb ) +maildir_list( store_t *gctx ) { DIR *dir; @@ -161,5 +162,4 @@ maildir_list( store_t *gctx, string_list return DRV_STORE_BAD; } - *retb = 0; while ((de = readdir( dir ))) { struct stat st; @@ -171,7 +171,8 @@ maildir_list( store_t *gctx, string_list if (stat( buf, &st ) || !S_ISDIR(st.st_mode)) continue; - add_string_list( retb, de->d_name ); + add_string_list( &gctx->boxes, de->d_name ); } closedir (dir); + gctx->listed = 1; return DRV_OK; --- isync/src/isync.h #1.56:1.57 @@ -145,4 +145,6 @@ typedef struct message { typedef struct store { store_conf_t *conf; /* foreign */ + string_list_t *boxes; /* _list results - own */ + unsigned listed:1; /* was _list already run? */ /* currently open mailbox */ @@ -177,5 +179,5 @@ struct driver { store_t *(*open_store)( store_conf_t *conf, store_t *oldctx ); void (*close_store)( store_t *ctx ); - int (*list)( store_t *ctx, string_list_t **boxes ); + int (*list)( store_t *ctx ); void (*prepare_paths)( store_t *ctx ); void (*prepare_opts)( store_t *ctx, int opts ); --- isync/src/main.c #1.54:1.55 @@ -195,8 +195,8 @@ main( int argc, char **argv ) driver_t *driver[2]; store_t *ctx[2]; - string_list_t *uboxes[2], *boxes[2], *mbox, *sbox, **mboxp, **sboxp, *cboxes, *chanptr; + string_list_t *boxes[2], *mbox, *sbox, **mboxp, **sboxp, *cboxes, *chanptr; char *config = 0, *channame, *boxlist, *opt, *ochar; const char *names[2]; - int all = 0, list = 0, cops = 0, ops[2] = { 0, 0 }, guboxes[2]; + int all = 0, list = 0, cops = 0, ops[2] = { 0, 0 }; int oind, ret, op, multiple, pseudo = 0, t; @@ -445,6 +445,4 @@ main( int argc, char **argv ) conf[M] = conf[S] = 0; /* make-gcc-happy */ driver[M] = driver[S] = 0; /* make-gcc-happy */ - guboxes[M] = guboxes[S] = 0; - uboxes[M] = uboxes[S] = 0; if (all) multiple = channels->next != 0; @@ -494,7 +492,4 @@ main( int argc, char **argv ) if (conf[t] == chan->stores[t]) continue; - free_string_list( uboxes[t] ); - uboxes[t] = 0; - guboxes[t] = 0; if (conf[t]->driver != chan->stores[t]->driver) { driver[t]->close_store( ctx[t] ); @@ -526,21 +521,15 @@ main( int argc, char **argv ) } else if (chan->patterns) { for (t = 0; t < 2; t++) { - if (!guboxes[t]) { - if (driver[t]->list( ctx[t], &uboxes[t] ) != DRV_OK) { + if (!ctx[t]->listed) { + if (driver[t]->list( ctx[t] ) != DRV_OK) { screwt: driver[t]->close_store( ctx[t] ); - free_string_list( uboxes[t] ); - uboxes[t] = 0; - guboxes[t] = 0; ctx[t] = 0; ret = 1; goto next; - } else { - guboxes[t] = 1; - if (ctx[t]->conf->map_inbox) - add_string_list( &uboxes[t], ctx[t]->conf->map_inbox ); - } + } else if (ctx[t]->conf->map_inbox) + add_string_list( &ctx[t]->boxes, ctx[t]->conf->map_inbox ); } - boxes[t] = filter_boxes( uboxes[t], chan->patterns ); + boxes[t] = filter_boxes( ctx[t]->boxes, chan->patterns ); } for (mboxp = &boxes[M]; (mbox = *mboxp); ) { @@ -607,8 +596,6 @@ main( int argc, char **argv ) } } - free_string_list( uboxes[S] ); if (ctx[S]) driver[S]->close_store( ctx[S] ); - free_string_list( uboxes[M] ); if (ctx[M]) driver[M]->close_store( ctx[M] ); ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel