Browse Source

Merge branch 'isync_1_1_branch' into HEAD

Conflicts:
	src/socket.c
wip/server-refactor
Oswald Buddenhagen 10 years ago
parent
commit
b730f66f7d
  1. 2
      src/driver.h
  2. 21
      src/drv_imap.c
  3. 2
      src/drv_maildir.c
  4. 8
      src/main.c
  5. 8
      src/socket.c
  6. 3
      src/socket.h
  7. 8
      src/sync.c

2
src/driver.h

@ -191,7 +191,7 @@ struct driver {
/* Index the messages which have newly appeared in the mailbox, including their /* 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 * 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. */ * 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 ); void (*cb)( int sts, void *aux ), void *aux );
/* Add/remove the named flags to/from the given message. The message may be either /* Add/remove the named flags to/from the given message. The message may be either

21
src/drv_imap.c

@ -166,6 +166,11 @@ struct imap_cmd_out_uid {
int out_uid; int out_uid;
}; };
struct imap_cmd_find_new {
struct imap_cmd_simple gen;
int uid;
};
struct imap_cmd_refcounted_state { struct imap_cmd_refcounted_state {
void (*callback)( int sts, void *aux ); void (*callback)( int sts, void *aux );
void *callback_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_p2( imap_store_t *, struct imap_cmd *, int );
static void 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 ) void (*cb)( int sts, void *aux ), void *aux )
{ {
imap_store_t *ctx = (imap_store_t *)gctx; 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) INIT_IMAP_CMD_X(imap_cmd_find_new, cmd, cb, aux)
imap_exec( (imap_store_t *)ctx, &cmd->gen, imap_find_new_msgs_p2, "CHECK" ); cmd->uid = newuid;
imap_exec( (imap_store_t *)ctx, &cmd->gen.gen, imap_find_new_msgs_p2, "CHECK" );
} }
static void static void
imap_find_new_msgs_p2( imap_store_t *ctx, struct imap_cmd *gcmd, int response ) 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) { if (response != RESP_OK) {
imap_done_simple_box( ctx, gcmd, response ); imap_done_simple_box( ctx, gcmd, response );
return; 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, 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 *******************/ /******************* imap_list *******************/

2
src/drv_maildir.c

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

8
src/main.c

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

8
src/socket.c

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

3
src/socket.h

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

8
src/sync.c

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

Loading…
Cancel
Save