Andreas Krennmair:
[apps/madmutt.git] / imap / imap.c
index d444b41..9bc7e86 100644 (file)
@@ -606,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);
@@ -1473,3 +1484,20 @@ int imap_complete(char* dest, size_t dlen, char* path) {
   FREE (&mx.mbox);
   return -1;
 }
+
+/* reconnect if connection was lost */
+int imap_reconnect(CONTEXT* ctx) {
+  IMAP_DATA* imap_data = (IMAP_DATA *)ctx->data;
+
+  if (imap_data) {
+    if (imap_data->status == IMAP_CONNECTED)
+      return -1;
+  }
+
+  if (query_quadoption(OPT_IMAPRECONNECT,_("Connection lost. Reconnect to IMAP server?")) != M_YES)
+    return -1;
+
+  mx_open_mailbox(ctx->path,0,ctx);
+  return 0;
+}
+