remove own_store() function from driver model

the drivers which support it can abstract it inside open_store() just
fine.
This commit is contained in:
Oswald Buddenhagen 2013-12-08 15:49:03 +01:00
parent 2cb483fb2e
commit 0b32734693
4 changed files with 11 additions and 33 deletions

View File

@ -1351,7 +1351,7 @@ imap_invoke_bad_callback( imap_store_t *ctx )
ctx->gen.bad_callback( ctx->gen.bad_callback_aux ); ctx->gen.bad_callback( ctx->gen.bad_callback_aux );
} }
/******************* imap_disown_store & imap_own_store *******************/ /******************* imap_disown_store *******************/
static store_t *unowned; static store_t *unowned;
@ -1378,19 +1378,6 @@ imap_disown_store( store_t *gctx )
unowned = 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 *******************/ /******************* imap_cleanup *******************/
static void imap_cleanup_p2( imap_store_t *, struct imap_cmd *, int ); static void imap_cleanup_p2( imap_store_t *, struct imap_cmd *, int );
@ -1470,6 +1457,12 @@ imap_open_store( store_conf_t *conf,
imap_store_t *ctx; imap_store_t *ctx;
store_t **ctxp; 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) for (ctxp = &unowned; (ctx = (imap_store_t *)*ctxp); ctxp = &ctx->gen.next)
if (((imap_store_conf_t *)ctx->gen.conf)->server == srvc) { if (((imap_store_conf_t *)ctx->gen.conf)->server == srvc) {
*ctxp = ctx->gen.next; *ctxp = ctx->gen.next;
@ -2359,7 +2352,6 @@ struct driver imap_driver = {
imap_cleanup, imap_cleanup,
imap_open_store, imap_open_store,
imap_disown_store, imap_disown_store,
imap_own_store,
imap_cancel_store, imap_cancel_store,
imap_list, imap_list,
imap_prepare_opts, imap_prepare_opts,

View File

@ -178,12 +178,6 @@ maildir_disown_store( store_t *gctx )
free( gctx ); free( gctx );
} }
static store_t *
maildir_own_store( store_conf_t *conf ATTR_UNUSED )
{
return 0;
}
static void static void
maildir_cleanup_drv( void ) maildir_cleanup_drv( void )
{ {
@ -1478,7 +1472,6 @@ struct driver maildir_driver = {
maildir_cleanup_drv, maildir_cleanup_drv,
maildir_open_store, maildir_open_store,
maildir_disown_store, maildir_disown_store,
maildir_own_store,
maildir_disown_store, /* _cancel_, but it's the same */ maildir_disown_store, /* _cancel_, but it's the same */
maildir_list, maildir_list,
maildir_prepare_opts, maildir_prepare_opts,

View File

@ -289,9 +289,6 @@ struct driver {
/* Mark the store as available for recycling. Server connection may be kept alive. */ /* Mark the store as available for recycling. Server connection may be kept alive. */
void (*disown_store)( store_t *ctx ); 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. /* Discard the store after a bad_callback. The server connections will be closed.
* Pending commands will have their callbacks synchronously invoked with DRV_CANCELED. */ * Pending commands will have their callbacks synchronously invoked with DRV_CANCELED. */
void (*cancel_store)( store_t *ctx ); void (*cancel_store)( store_t *ctx );

View File

@ -517,7 +517,6 @@ sync_chans( main_vars_t *mvars, int ent )
{ {
group_conf_t *group; group_conf_t *group;
channel_conf_t *chan; channel_conf_t *chan;
store_t *store;
string_list_t *mbox, *sbox, **mboxp, **sboxp; string_list_t *mbox, *sbox, **mboxp, **sboxp;
char *channame, *boxp, *nboxp; char *channame, *boxp, *nboxp;
int t; int t;
@ -587,14 +586,11 @@ sync_chans( main_vars_t *mvars, int ent )
info( "Channel %s\n", mvars->chan->name ); info( "Channel %s\n", mvars->chan->name );
mvars->skip = mvars->cben = 0; mvars->skip = mvars->cben = 0;
for (t = 0; t < 2; t++) { for (t = 0; t < 2; t++) {
mvars->drv[t] = mvars->chan->stores[t]->driver;
if ((store = mvars->drv[t]->own_store( mvars->chan->stores[t] )))
store_opened( store, AUX );
}
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 ); info( "Opening %s %s...\n", str_ms[t], mvars->chan->stores[t]->name );
mvars->drv[t] = mvars->chan->stores[t]->driver;
mvars->drv[t]->open_store( mvars->chan->stores[t], store_opened, AUX ); mvars->drv[t]->open_store( mvars->chan->stores[t], store_opened, AUX );
if (mvars->skip)
break;
} }
mvars->cben = 1; mvars->cben = 1;
opened: opened: