Browse Source

tag verbose output when channel links two verbose stores

otherwise it's pure guesswork to assign the output to particular stores.
wip/maildir-uid-dupes-test
Oswald Buddenhagen 11 years ago
parent
commit
92b892d247
  1. 22
      src/drv_imap.c
  2. 2
      src/drv_maildir.c
  3. 6
      src/isync.h
  4. 7
      src/main.c

22
src/drv_imap.c

@ -83,6 +83,7 @@ struct imap_cmd;
typedef struct imap_store { typedef struct imap_store {
store_t gen; store_t gen;
const char *label; /* foreign */
const char *prefix; const char *prefix;
int ref_count; int ref_count;
/* trash folder's existence is not confirmed yet */ /* trash folder's existence is not confirmed yet */
@ -254,9 +255,9 @@ send_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd )
if (ctx->num_in_progress) if (ctx->num_in_progress)
printf( "(%d in progress) ", ctx->num_in_progress ); printf( "(%d in progress) ", ctx->num_in_progress );
if (memcmp( cmd->cmd, "LOGIN", 5 )) if (memcmp( cmd->cmd, "LOGIN", 5 ))
printf( ">>> %s", buf ); printf( "%s>>> %s", ctx->label, buf );
else else
printf( ">>> %d LOGIN <user> <pass>\n", cmd->tag ); printf( "%s>>> %d LOGIN <user> <pass>\n", ctx->label, cmd->tag );
fflush( stdout ); fflush( stdout );
} }
if (socket_write( &ctx->conn, buf, bufl, KeepOwn ) < 0) if (socket_write( &ctx->conn, buf, bufl, KeepOwn ) < 0)
@ -692,9 +693,9 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts )
goto postpone; goto postpone;
if (DFlags & XVERBOSE) { if (DFlags & XVERBOSE) {
puts( "=========" ); printf( "%s=========\n", ctx->label );
fwrite( cur->val, cur->len, 1, stdout ); fwrite( cur->val, cur->len, 1, stdout );
puts( "=========" ); printf( "%s=========\n", ctx->label );
fflush( stdout ); fflush( stdout );
} }
@ -702,7 +703,7 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts )
if (!(s = socket_read_line( &ctx->conn ))) if (!(s = socket_read_line( &ctx->conn )))
goto postpone; goto postpone;
if (DFlags & VERBOSE) { if (DFlags & VERBOSE) {
puts( s ); printf( "%s%s\n", ctx->label, s );
fflush( stdout ); fflush( stdout );
} }
} else if (*s == '"') { } else if (*s == '"') {
@ -1167,7 +1168,7 @@ imap_socket_read( void *aux )
if (!(cmd = socket_read_line( &ctx->conn ))) if (!(cmd = socket_read_line( &ctx->conn )))
return; return;
if (DFlags & VERBOSE) { if (DFlags & VERBOSE) {
puts( cmd ); printf( "%s%s\n", ctx->label, cmd );
fflush( stdout ); fflush( stdout );
} }
@ -1425,7 +1426,7 @@ do_cram_auth( imap_store_t *ctx, struct imap_cmd *cmdp, const char *prompt )
cram( prompt, srvc->user, srvc->pass, &resp, &l ); cram( prompt, srvc->user, srvc->pass, &resp, &l );
if (DFlags & VERBOSE) { if (DFlags & VERBOSE) {
printf( ">+> %s\n", resp ); printf( "%s>+> %s\n", ctx->label, resp );
fflush( stdout ); fflush( stdout );
} }
if (socket_write( &ctx->conn, resp, l, GiveOwn ) < 0) if (socket_write( &ctx->conn, resp, l, GiveOwn ) < 0)
@ -1457,7 +1458,7 @@ static void imap_open_store_ssl_bail( imap_store_t * );
static void imap_open_store_bail( imap_store_t * ); static void imap_open_store_bail( imap_store_t * );
static void static void
imap_open_store( store_conf_t *conf, imap_open_store( store_conf_t *conf, const char *label,
void (*cb)( store_t *srv, void *aux ), void *aux ) void (*cb)( store_t *srv, void *aux ), void *aux )
{ {
imap_store_conf_t *cfg = (imap_store_conf_t *)conf; imap_store_conf_t *cfg = (imap_store_conf_t *)conf;
@ -1468,12 +1469,14 @@ imap_open_store( store_conf_t *conf,
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 (ctx->gen.conf == conf) { if (ctx->gen.conf == conf) {
*ctxp = ctx->gen.next; *ctxp = ctx->gen.next;
ctx->label = label;
cb( &ctx->gen, aux ); cb( &ctx->gen, aux );
return; 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;
ctx->label = label;
/* One could ping the server here, but given that the idle timeout /* One could ping the server here, but given that the idle timeout
* is at least 30 minutes, this sounds pretty pointless. */ * is at least 30 minutes, this sounds pretty pointless. */
free_string_list( ctx->gen.boxes ); free_string_list( ctx->gen.boxes );
@ -1491,6 +1494,7 @@ imap_open_store( store_conf_t *conf,
ctx = nfcalloc( sizeof(*ctx) ); ctx = nfcalloc( sizeof(*ctx) );
ctx->gen.conf = conf; ctx->gen.conf = conf;
ctx->label = label;
ctx->ref_count = 1; ctx->ref_count = 1;
ctx->callbacks.imap_open = cb; ctx->callbacks.imap_open = cb;
ctx->callback_aux = aux; ctx->callback_aux = aux;
@ -2355,7 +2359,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep )
} }
struct driver imap_driver = { struct driver imap_driver = {
DRV_CRLF, DRV_CRLF | DRV_VERBOSE,
imap_parse_store, imap_parse_store,
imap_cleanup, imap_cleanup,
imap_open_store, imap_open_store,

2
src/drv_maildir.c

@ -122,7 +122,7 @@ maildir_join_path( const char *prefix, const char *box )
} }
static void static void
maildir_open_store( store_conf_t *conf, maildir_open_store( store_conf_t *conf, const char *label ATTR_UNUSED,
void (*cb)( store_t *ctx, void *aux ), void *aux ) void (*cb)( store_t *ctx, void *aux ), void *aux )
{ {
maildir_store_t *ctx; maildir_store_t *ctx;

6
src/isync.h

@ -268,6 +268,10 @@ typedef struct {
and as CRLF is the canonical format, we convert. and as CRLF is the canonical format, we convert.
*/ */
#define DRV_CRLF 1 #define DRV_CRLF 1
/*
This flag says that the driver will act upon (DFlags & VERBOSE).
*/
#define DRV_VERBOSE 2
#define LIST_PATH 1 #define LIST_PATH 1
#define LIST_INBOX 2 #define LIST_INBOX 2
@ -283,7 +287,7 @@ struct driver {
/* Open a store with the given configuration. This may recycle existing /* Open a store with the given configuration. This may recycle existing
* server connections. Upon failure, a null store is passed to the callback. */ * server connections. Upon failure, a null store is passed to the callback. */
void (*open_store)( store_conf_t *conf, void (*open_store)( store_conf_t *conf, const char *label,
void (*cb)( store_t *ctx, void *aux ), void *aux ); void (*cb)( store_t *ctx, void *aux ), void *aux );
/* 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. */

7
src/main.c

@ -519,6 +519,7 @@ sync_chans( main_vars_t *mvars, int ent )
channel_conf_t *chan; channel_conf_t *chan;
string_list_t *mbox, *sbox, **mboxp, **sboxp; string_list_t *mbox, *sbox, **mboxp, **sboxp;
char *channame, *boxp, *nboxp; char *channame, *boxp, *nboxp;
const char *labels[2];
int t; int t;
if (!mvars->cben) if (!mvars->cben)
@ -585,10 +586,14 @@ sync_chans( main_vars_t *mvars, int ent )
mvars->state[M] = mvars->state[S] = ST_FRESH; mvars->state[M] = mvars->state[S] = ST_FRESH;
info( "Channel %s\n", mvars->chan->name ); info( "Channel %s\n", mvars->chan->name );
mvars->skip = mvars->cben = 0; mvars->skip = mvars->cben = 0;
if (mvars->chan->stores[M]->driver->flags & mvars->chan->stores[S]->driver->flags & DRV_VERBOSE)
labels[M] = "M: ", labels[S] = "S: ";
else
labels[M] = labels[S] = "";
for (t = 0; t < 2; t++) { for (t = 0; t < 2; t++) {
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] = 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], labels[t], store_opened, AUX );
if (mvars->skip) if (mvars->skip)
break; break;
} }

Loading…
Cancel
Save