/* Support for IMAP4rev1, with the occasional nod to IMAP 4. */
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "mutt.h"
#include "mutt_curses.h"
#include "mx.h"
return 0;
}
+int imap_rename_mailbox (IMAP_DATA* idata, IMAP_MBOX* mx, const char* newname)
+{
+ char oldmbox[LONG_STRING];
+ char newmbox[LONG_STRING];
+ char buf[LONG_STRING];
+
+ imap_munge_mbox_name (oldmbox, sizeof (oldmbox), mx->mbox);
+ imap_munge_mbox_name (newmbox, sizeof (newmbox), newname);
+
+ snprintf (buf, sizeof (buf), "RENAME %s %s", oldmbox, newmbox);
+
+ if (imap_exec (idata, buf, 0) != 0)
+ return -1;
+
+ return 0;
+}
+
int imap_delete_mailbox (CONTEXT* ctx, IMAP_MBOX mx)
{
char buf[LONG_STRING], mbox[LONG_STRING];
IMAP_DATA *idata;
if (!ctx || !ctx->data) {
- if (!(idata = imap_conn_find (&mx.account,
- option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW : 0)))
- {
- FREE (&mx.mbox);
- return -1;
- }
+ if (!(idata = imap_conn_find (&mx.account,
+ option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW : 0)))
+ {
+ FREE (&mx.mbox);
+ return -1;
+ }
} else {
- idata = ctx->data;
+ idata = ctx->data;
}
imap_munge_mbox_name (mbox, sizeof (mbox), mx.mbox);
{
mutt_error (_("Could not negotiate TLS connection"));
mutt_sleep (1);
- goto bail;
+ goto err_close_conn;
}
else
{
err_close_conn:
mutt_socket_close (idata->conn);
+ idata->state = IMAP_DISCONNECTED;
bail:
FREE (&idata->capstr);
return -1;
imap_cmd_start (idata, "LOGOUT");
while (imap_cmd_step (idata) == IMAP_CMD_CONTINUE)
;
+ FREE(& idata->cmd.buf);
+ FREE(& idata);
}
+/*
int imap_close_connection (CONTEXT *ctx)
{
dprint (1, (debugfile, "imap_close_connection(): closing connection\n"));
- /* if the server didn't shut down on us, close the connection gracefully */
if (CTX_DATA->status != IMAP_BYE)
{
mutt_message _("Closing connection to IMAP server...");
CTX_DATA->conn->data = NULL;
return 0;
}
+*/
/* imap_set_flag: append str to flags if we currently have permission
* according to aclbit */
{
if (mutt_bit_isset (idata->rights, aclbit))
if (flag)
- strncat (flags, str, flsize);
+ safe_strcat (flags, flsize, str);
}
/* imap_make_msg_set: make an IMAP4rev1 UID message set out of a set of
return -1;
}
-/* reconnect and verify indexes if connection was lost */
+/* reconnect 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 (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;
- return imap_open_mailbox(ctx);
+ mx_open_mailbox(ctx->path,0,ctx);
+ return 0;
}