X-Git-Url: http://git.madism.org/?a=blobdiff_plain;ds=inline;f=imap%2Fimap.c;h=0ad54d1ead48eda4e8bcd86d35f69dc3ef3227ad;hb=f07b807db70d3ac5d0a8086819cfbb4f7ff25f07;hp=6432e83aecd8eb9b0872874219b07ab4bfda2058;hpb=420f3633557ed75a0de989eb065af6e09eed29ba;p=apps%2Fmadmutt.git diff --git a/imap/imap.c b/imap/imap.c index 6432e83..0ad54d1 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -29,7 +29,7 @@ #include "browser.h" #include "message.h" #include "imap_private.h" -#ifdef USE_SSL +#if defined(USE_SSL) || defined(USE_GNUTLS) # include "mutt_ssl.h" #endif @@ -408,7 +408,7 @@ int imap_open_connection (IMAP_DATA* idata) /* TODO: Parse new tagged CAPABILITY data (* OK [CAPABILITY...]) */ if (imap_check_capabilities (idata)) goto bail; -#if defined(USE_SSL) && !defined(USE_NSS) +#if defined(USE_SSL) || defined(USE_GNUTLS) /* Attempt STARTTLS if available and desired. */ if (mutt_bit_isset (idata->capabilities, STARTTLS) && !idata->conn->ssf) { @@ -422,7 +422,11 @@ int imap_open_connection (IMAP_DATA* idata) goto bail; if (rc != -2) { +#ifdef USE_SSL if (mutt_ssl_starttls (idata->conn)) +#elif USE_GNUTLS + if (mutt_gnutls_starttls (idata->conn)) +#endif { mutt_error (_("Could not negotiate TLS connection")); mutt_sleep (1); @@ -602,6 +606,17 @@ int imap_open_mailbox (CONTEXT* ctx) if ((pc = imap_get_flags (&(idata->flags), pc)) == NULL) goto fail; } +#ifdef USE_HCACHE + /* save UIDVALIDITY for the header cache */ + else if (ascii_strncasecmp("OK [UIDVALIDITY", pc, 14) == 0) + { + dprint(2, (debugfile, "Getting mailbox UIDVALIDITY\n")); + pc += 3; + pc = imap_next_word(pc); + + sscanf(pc, "%u", &(idata->uid_validity)); + } +#endif else { pc = imap_next_word (pc); @@ -1469,3 +1484,21 @@ int imap_complete(char* dest, size_t dlen, char* path) { FREE (&mx.mbox); return -1; } + +/* reconnect and verify indexes if connection was lost */ +int imap_reconnect(CONTEXT* ctx) { + IMAP_DATA* imap_data = (IMAP_DATA *)ctx->data; + + if (imap_data->status == IMAP_CONNECTED) + return -1; + if (imap_data->status == IMAP_BYE) + return 0; + + mutt_socket_close(imap_data->conn); + + if (query_quadoption(OPT_IMAPRECONNECT,_("Connection lost. Reconnect to IMAP server?")) != M_YES) + return -1; + + return imap_open_mailbox(ctx); +} +