Andreas Krennmair:
[apps/madmutt.git] / imap / imap.c
index d4b622c..eefdd31 100644 (file)
@@ -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);
@@ -981,9 +996,11 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
       mutt_buffer_addstr (&cmd, "UID STORE ");
       mutt_buffer_addstr (&cmd, uid);
 
-      /* if attachments have been deleted we delete the message and reupload
-       * it. This works better if we're expunging, of course. */
-      if (ctx->hdrs[n]->attach_del)
+      /* if the message has been rethreaded or attachments have been deleted
+       * we delete the message and reupload it.
+       * This works better if we're expunging, of course. */
+      if (ctx->hdrs[n]->refs_changed || ctx->hdrs[n]->irt_changed ||
+         ctx->hdrs[n]->attach_del)
       {
        dprint (3, (debugfile, "imap_sync_mailbox: Attachments to be deleted, falling back to _mutt_save_message\n"));
        if (!appendctx)