|
|
@ -80,6 +80,13 @@ sanitize_flags( uchar tflags, sync_vars_t *svars, int t ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum { |
|
|
|
|
|
|
|
COPY_OK, |
|
|
|
|
|
|
|
COPY_NOGOOD, |
|
|
|
|
|
|
|
COPY_CANCELED, |
|
|
|
|
|
|
|
COPY_FAIL, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static void msg_fetched( int sts, void *aux ); |
|
|
|
static void msg_fetched( int sts, void *aux ); |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
@ -108,7 +115,7 @@ msg_fetched( int sts, void *aux ) |
|
|
|
INIT_SVARS(vars->aux); |
|
|
|
INIT_SVARS(vars->aux); |
|
|
|
if (check_cancel( svars )) { |
|
|
|
if (check_cancel( svars )) { |
|
|
|
free( vars->data.data ); |
|
|
|
free( vars->data.data ); |
|
|
|
vars->cb( SYNC_CANCELED, 0, vars ); |
|
|
|
vars->cb( COPY_CANCELED, 0, vars ); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -138,7 +145,7 @@ msg_fetched( int sts, void *aux ) |
|
|
|
const char *err; |
|
|
|
const char *err; |
|
|
|
if ((err = copy_msg_convert( scr, tcr, vars ))) { |
|
|
|
if ((err = copy_msg_convert( scr, tcr, vars ))) { |
|
|
|
warn( "Warning: message %u from %s %s; skipping.\n", vars->msg->uid, str_fn[t^1], err ); |
|
|
|
warn( "Warning: message %u from %s %s; skipping.\n", vars->msg->uid, str_fn[t^1], err ); |
|
|
|
vars->cb( SYNC_NOGOOD, 0, vars ); |
|
|
|
vars->cb( COPY_NOGOOD, 0, vars ); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -146,13 +153,13 @@ msg_fetched( int sts, void *aux ) |
|
|
|
svars->drv[t]->store_msg( svars->ctx[t], &vars->data, !srec, msg_stored, vars ); |
|
|
|
svars->drv[t]->store_msg( svars->ctx[t], &vars->data, !srec, msg_stored, vars ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case DRV_CANCELED: |
|
|
|
case DRV_CANCELED: |
|
|
|
vars->cb( SYNC_CANCELED, 0, vars ); |
|
|
|
vars->cb( COPY_CANCELED, 0, vars ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case DRV_MSG_BAD: |
|
|
|
case DRV_MSG_BAD: |
|
|
|
vars->cb( SYNC_NOGOOD, 0, vars ); |
|
|
|
vars->cb( COPY_NOGOOD, 0, vars ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: // DRV_BOX_BAD
|
|
|
|
default: // DRV_BOX_BAD
|
|
|
|
vars->cb( SYNC_FAIL, 0, vars ); |
|
|
|
vars->cb( COPY_FAIL, 0, vars ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -165,20 +172,20 @@ msg_stored( int sts, uint uid, void *aux ) |
|
|
|
|
|
|
|
|
|
|
|
switch (sts) { |
|
|
|
switch (sts) { |
|
|
|
case DRV_OK: |
|
|
|
case DRV_OK: |
|
|
|
vars->cb( SYNC_OK, uid, vars ); |
|
|
|
vars->cb( COPY_OK, uid, vars ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case DRV_CANCELED: |
|
|
|
case DRV_CANCELED: |
|
|
|
vars->cb( SYNC_CANCELED, 0, vars ); |
|
|
|
vars->cb( COPY_CANCELED, 0, vars ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case DRV_MSG_BAD: |
|
|
|
case DRV_MSG_BAD: |
|
|
|
INIT_SVARS(vars->aux); |
|
|
|
INIT_SVARS(vars->aux); |
|
|
|
(void)svars; |
|
|
|
(void)svars; |
|
|
|
warn( "Warning: %s refuses to store message %u from %s.\n", |
|
|
|
warn( "Warning: %s refuses to store message %u from %s.\n", |
|
|
|
str_fn[t], vars->msg->uid, str_fn[t^1] ); |
|
|
|
str_fn[t], vars->msg->uid, str_fn[t^1] ); |
|
|
|
vars->cb( SYNC_NOGOOD, 0, vars ); |
|
|
|
vars->cb( COPY_NOGOOD, 0, vars ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: // DRV_BOX_BAD
|
|
|
|
default: // DRV_BOX_BAD
|
|
|
|
vars->cb( SYNC_FAIL, 0, vars ); |
|
|
|
vars->cb( COPY_FAIL, 0, vars ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -265,7 +272,7 @@ check_ret( int sts, void *aux ) |
|
|
|
DECL_INIT_SVARS(vars->aux) |
|
|
|
DECL_INIT_SVARS(vars->aux) |
|
|
|
|
|
|
|
|
|
|
|
#define SVARS_CHECK_CANCEL_RET \ |
|
|
|
#define SVARS_CHECK_CANCEL_RET \ |
|
|
|
if (sts == SYNC_CANCELED) { \
|
|
|
|
if (sts == COPY_CANCELED) { \
|
|
|
|
free( vars ); \
|
|
|
|
free( vars ); \
|
|
|
|
return; \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
@ -1390,17 +1397,17 @@ msg_copied( int sts, uint uid, copy_vars_t *vars ) |
|
|
|
SVARS_CHECK_CANCEL_RET; |
|
|
|
SVARS_CHECK_CANCEL_RET; |
|
|
|
sync_rec_t *srec = vars->srec; |
|
|
|
sync_rec_t *srec = vars->srec; |
|
|
|
switch (sts) { |
|
|
|
switch (sts) { |
|
|
|
case SYNC_OK: |
|
|
|
case COPY_OK: |
|
|
|
if (!uid) // Stored to a non-UIDPLUS mailbox
|
|
|
|
if (!uid) // Stored to a non-UIDPLUS mailbox
|
|
|
|
svars->state[t] |= ST_FIND_NEW; |
|
|
|
svars->state[t] |= ST_FIND_NEW; |
|
|
|
else |
|
|
|
else |
|
|
|
ASSIGN_UID( srec, t, uid, "%sed message", str_hl[t] ); |
|
|
|
ASSIGN_UID( srec, t, uid, "%sed message", str_hl[t] ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case SYNC_NOGOOD: |
|
|
|
case COPY_NOGOOD: |
|
|
|
srec->status = S_DEAD; |
|
|
|
srec->status = S_DEAD; |
|
|
|
JLOG( "- %u %u", (srec->uid[F], srec->uid[N]), "%s failed", str_hl[t] ); |
|
|
|
JLOG( "- %u %u", (srec->uid[F], srec->uid[N]), "%s failed", str_hl[t] ); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: // COPY_FAIL
|
|
|
|
cancel_sync( svars ); |
|
|
|
cancel_sync( svars ); |
|
|
|
free( vars ); |
|
|
|
free( vars ); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1716,10 +1723,10 @@ msg_rtrashed( int sts, uint uid ATTR_UNUSED, copy_vars_t *vars ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SVARS_CHECK_CANCEL_RET; |
|
|
|
SVARS_CHECK_CANCEL_RET; |
|
|
|
switch (sts) { |
|
|
|
switch (sts) { |
|
|
|
case SYNC_OK: |
|
|
|
case COPY_OK: |
|
|
|
case SYNC_NOGOOD: /* the message is gone or heavily busted */ |
|
|
|
case COPY_NOGOOD: /* the message is gone or heavily busted */ |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: // COPY_FAIL
|
|
|
|
cancel_sync( svars ); |
|
|
|
cancel_sync( svars ); |
|
|
|
free( vars ); |
|
|
|
free( vars ); |
|
|
|
return; |
|
|
|
return; |
|
|
|