Merge branch 'isync_1_1_branch' into HEAD

Conflicts:
	src/socket.c
This commit is contained in:
Oswald Buddenhagen 2015-01-11 14:32:15 +01:00
commit b730f66f7d
7 changed files with 33 additions and 19 deletions

View File

@ -191,7 +191,7 @@ struct driver {
/* Index the messages which have newly appeared in the mailbox, including their
* temporary UID headers. This is needed if store_msg() does not guarantee returning
* a UID; otherwise the driver needs to implement only the OPEN_FIND flag. */
void (*find_new_msgs)( store_t *ctx,
void (*find_new_msgs)( store_t *ctx, int newuid,
void (*cb)( int sts, void *aux ), void *aux );
/* Add/remove the named flags to/from the given message. The message may be either

View File

@ -166,6 +166,11 @@ struct imap_cmd_out_uid {
int out_uid;
};
struct imap_cmd_find_new {
struct imap_cmd_simple gen;
int uid;
};
struct imap_cmd_refcounted_state {
void (*callback)( int sts, void *aux );
void *callback_aux;
@ -2392,28 +2397,30 @@ imap_store_msg_p2( imap_store_t *ctx ATTR_UNUSED, struct imap_cmd *cmd, int resp
static void imap_find_new_msgs_p2( imap_store_t *, struct imap_cmd *, int );
static void
imap_find_new_msgs( store_t *gctx,
imap_find_new_msgs( store_t *gctx, int newuid,
void (*cb)( int sts, void *aux ), void *aux )
{
imap_store_t *ctx = (imap_store_t *)gctx;
struct imap_cmd_simple *cmd;
struct imap_cmd_find_new *cmd;
INIT_IMAP_CMD(imap_cmd_simple, cmd, cb, aux)
imap_exec( (imap_store_t *)ctx, &cmd->gen, imap_find_new_msgs_p2, "CHECK" );
INIT_IMAP_CMD_X(imap_cmd_find_new, cmd, cb, aux)
cmd->uid = newuid;
imap_exec( (imap_store_t *)ctx, &cmd->gen.gen, imap_find_new_msgs_p2, "CHECK" );
}
static void
imap_find_new_msgs_p2( imap_store_t *ctx, struct imap_cmd *gcmd, int response )
{
struct imap_cmd_simple *cmdp = (struct imap_cmd_simple *)gcmd, *cmd;
struct imap_cmd_find_new *cmdp = (struct imap_cmd_find_new *)gcmd;
struct imap_cmd_simple *cmd;
if (response != RESP_OK) {
imap_done_simple_box( ctx, gcmd, response );
return;
}
INIT_IMAP_CMD(imap_cmd_simple, cmd, cmdp->callback, cmdp->callback_aux)
INIT_IMAP_CMD(imap_cmd_simple, cmd, cmdp->gen.callback, cmdp->gen.callback_aux)
imap_exec( (imap_store_t *)ctx, &cmd->gen, imap_done_simple_box,
"UID FETCH %d:1000000000 (UID BODY.PEEK[HEADER.FIELDS (X-TUID)])", ctx->gen.uidnext );
"UID FETCH %d:1000000000 (UID BODY.PEEK[HEADER.FIELDS (X-TUID)])", cmdp->uid );
}
/******************* imap_list *******************/

View File

@ -1295,7 +1295,7 @@ maildir_store_msg( store_t *gctx, msg_data_t *data, int to_trash,
}
static void
maildir_find_new_msgs( store_t *gctx ATTR_UNUSED,
maildir_find_new_msgs( store_t *gctx ATTR_UNUSED, int newuid ATTR_UNUSED,
void (*cb)( int sts, void *aux ) ATTR_UNUSED, void *aux ATTR_UNUSED )
{
assert( !"maildir_find_new_msgs is not supposed to be called" );

View File

@ -598,12 +598,16 @@ sync_chans( main_vars_t *mvars, int ent )
labels[M] = "M: ", labels[S] = "S: ";
else
labels[M] = labels[S] = "";
for (t = 0; t < 2; t++) {
for (t = 0; ; t++) {
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], labels[t], store_opened, AUX );
if (mvars->skip)
if (t)
break;
if (mvars->skip) {
mvars->state[1] = ST_CLOSED;
break;
}
}
mvars->cben = 1;
opened:

View File

@ -154,7 +154,7 @@ verify_hostname( X509 *cert, const char *hostname )
static int
verify_cert_host( const server_conf_t *conf, conn_t *sock )
{
unsigned i;
int i;
long err;
X509 *cert;
STACK_OF(X509_OBJECT) *trusted;
@ -165,8 +165,8 @@ verify_cert_host( const server_conf_t *conf, conn_t *sock )
return -1;
}
trusted = SSL_CTX_get_cert_store( conf->SSLContext )->objs;
for (i = 0; i < conf->num_trusted; i++) {
trusted = (STACK_OF(X509_OBJECT) *)sock->conf->trusted_certs;
for (i = 0; i < sk_X509_OBJECT_num( trusted ); i++) {
if (!X509_cmp( cert, sk_X509_OBJECT_value( trusted, i )->data.x509 ))
return 0;
}
@ -218,7 +218,7 @@ init_ssl_ctx( const server_conf_t *conf )
conf->cert_file, ERR_error_string( ERR_get_error(), 0 ) );
return 0;
}
mconf->num_trusted = sk_X509_OBJECT_num( SSL_CTX_get_cert_store( mconf->SSLContext )->objs );
mconf->trusted_certs = (_STACK *)sk_X509_OBJECT_dup( SSL_CTX_get_cert_store( mconf->SSLContext )->objs );
if (mconf->system_certs && !SSL_CTX_set_default_verify_paths( mconf->SSLContext ))
warn( "Warning: Unable to load default certificate files: %s\n",
ERR_error_string( ERR_get_error(), 0 ) );

View File

@ -28,6 +28,7 @@
#ifdef HAVE_LIBSSL
typedef struct ssl_st SSL;
typedef struct ssl_ctx_st SSL_CTX;
typedef struct stack_st _STACK;
enum {
SSLv2 = 1,
@ -49,7 +50,7 @@ typedef struct server_conf {
/* these are actually variables and are leaked at the end */
char ssl_ctx_valid;
unsigned num_trusted;
_STACK *trusted_certs;
SSL_CTX *SSLContext;
#endif
} server_conf_t;

View File

@ -498,11 +498,12 @@ cancel_done( void *aux )
svars->state[t] |= ST_CANCELED;
if (svars->state[1-t] & ST_CANCELED) {
if (svars->lfd) {
if (svars->lfd >= 0) {
Fclose( svars->nfp, 0 );
Fclose( svars->jfp, 0 );
sync_bail( svars );
} else {
/* Early failure during box selection. */
sync_bail2( svars );
}
}
@ -1507,7 +1508,8 @@ box_loaded( int sts, void *aux )
if (UseFSync)
fdatasync( fileno( svars->jfp ) );
for (t = 0; t < 2; t++) {
Fprintf( svars->jfp, "%c %d\n", "{}"[t], svars->ctx[t]->uidnext );
svars->newuid[t] = svars->ctx[t]->uidnext;
Fprintf( svars->jfp, "%c %d\n", "{}"[t], svars->newuid[t] );
for (tmsg = svars->ctx[1-t]->msgs; tmsg; tmsg = tmsg->next) {
if ((srec = tmsg->srec) && srec->tuid[0]) {
svars->new_total[t]++;
@ -1605,7 +1607,7 @@ msgs_copied( sync_vars_t *svars, int t )
if (svars->state[t] & ST_FIND_NEW) {
debug( "finding just copied messages on %s\n", str_ms[t] );
svars->drv[t]->find_new_msgs( svars->ctx[t], msgs_found_new, AUX );
svars->drv[t]->find_new_msgs( svars->ctx[t], svars->newuid[t], msgs_found_new, AUX );
} else {
msgs_new_done( svars, t );
}