X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=imap%2Fimap.c;h=a9552ceaca683bda6508eb8045c4bcee1547ff2f;hp=20c396083d252655dc3c4fae15a93640634a81ac;hb=643be053e447a35cccc37550ac0087bb5bb5c5ad;hpb=3d937534e7b1ee723f86594b5e4c64c95158a933 diff --git a/imap/imap.c b/imap/imap.c index 20c3960..a9552ce 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -20,6 +20,10 @@ /* 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" @@ -104,20 +108,37 @@ int imap_create_mailbox (IMAP_DATA* idata, char* mailbox) 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);