isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 0b32734693d87596c2733ba24d4a782074108ae7
parent 2cb483fb2e4424b47ab1ddfb58a492a9aaff0469
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Sun,  8 Dec 2013 15:49:03 +0100

remove own_store() function from driver model

the drivers which support it can abstract it inside open_store() just
fine.

Diffstat:
Msrc/drv_imap.c | 22+++++++---------------
Msrc/drv_maildir.c | 7-------
Msrc/isync.h | 3---
Msrc/main.c | 12++++--------
4 files changed, 11 insertions(+), 33 deletions(-)

diff --git a/src/drv_imap.c b/src/drv_imap.c @@ -1351,7 +1351,7 @@ imap_invoke_bad_callback( imap_store_t *ctx ) ctx->gen.bad_callback( ctx->gen.bad_callback_aux ); } -/******************* imap_disown_store & imap_own_store *******************/ +/******************* imap_disown_store *******************/ static store_t *unowned; @@ -1378,19 +1378,6 @@ imap_disown_store( store_t *gctx ) unowned = gctx; } -static store_t * -imap_own_store( store_conf_t *conf ) -{ - store_t *store, **storep; - - for (storep = &unowned; (store = *storep); storep = &store->next) - if (store->conf == conf) { - *storep = store->next; - return store; - } - return 0; -} - /******************* imap_cleanup *******************/ static void imap_cleanup_p2( imap_store_t *, struct imap_cmd *, int ); @@ -1471,6 +1458,12 @@ imap_open_store( store_conf_t *conf, store_t **ctxp; for (ctxp = &unowned; (ctx = (imap_store_t *)*ctxp); ctxp = &ctx->gen.next) + if (ctx->gen.conf == conf) { + *ctxp = ctx->gen.next; + cb( &ctx->gen, aux ); + return; + } + for (ctxp = &unowned; (ctx = (imap_store_t *)*ctxp); ctxp = &ctx->gen.next) if (((imap_store_conf_t *)ctx->gen.conf)->server == srvc) { *ctxp = ctx->gen.next; /* One could ping the server here, but given that the idle timeout @@ -2359,7 +2352,6 @@ struct driver imap_driver = { imap_cleanup, imap_open_store, imap_disown_store, - imap_own_store, imap_cancel_store, imap_list, imap_prepare_opts, diff --git a/src/drv_maildir.c b/src/drv_maildir.c @@ -178,12 +178,6 @@ maildir_disown_store( store_t *gctx ) free( gctx ); } -static store_t * -maildir_own_store( store_conf_t *conf ATTR_UNUSED ) -{ - return 0; -} - static void maildir_cleanup_drv( void ) { @@ -1478,7 +1472,6 @@ struct driver maildir_driver = { maildir_cleanup_drv, maildir_open_store, maildir_disown_store, - maildir_own_store, maildir_disown_store, /* _cancel_, but it's the same */ maildir_list, maildir_prepare_opts, diff --git a/src/isync.h b/src/isync.h @@ -289,9 +289,6 @@ struct driver { /* Mark the store as available for recycling. Server connection may be kept alive. */ void (*disown_store)( store_t *ctx ); - /* Try to recycle a store with the given configuration. */ - store_t *(*own_store)( store_conf_t *conf ); - /* Discard the store after a bad_callback. The server connections will be closed. * Pending commands will have their callbacks synchronously invoked with DRV_CANCELED. */ void (*cancel_store)( store_t *ctx ); diff --git a/src/main.c b/src/main.c @@ -517,7 +517,6 @@ sync_chans( main_vars_t *mvars, int ent ) { group_conf_t *group; channel_conf_t *chan; - store_t *store; string_list_t *mbox, *sbox, **mboxp, **sboxp; char *channame, *boxp, *nboxp; int t; @@ -587,15 +586,12 @@ sync_chans( main_vars_t *mvars, int ent ) info( "Channel %s\n", mvars->chan->name ); mvars->skip = mvars->cben = 0; for (t = 0; t < 2; t++) { + info( "Opening %s %s...\n", str_ms[t], mvars->chan->stores[t]->name ); mvars->drv[t] = mvars->chan->stores[t]->driver; - if ((store = mvars->drv[t]->own_store( mvars->chan->stores[t] ))) - store_opened( store, AUX ); + mvars->drv[t]->open_store( mvars->chan->stores[t], store_opened, AUX ); + if (mvars->skip) + break; } - for (t = 0; t < 2 && !mvars->skip; t++) - if (mvars->state[t] == ST_FRESH) { - info( "Opening %s %s...\n", str_ms[t], mvars->chan->stores[t]->name ); - mvars->drv[t]->open_store( mvars->chan->stores[t], store_opened, AUX ); - } mvars->cben = 1; opened: if (mvars->skip)