From 5c310cabcfafe551dcad7638c007daae1c7d3710 Mon Sep 17 00:00:00 2001 From: ak1 Date: Mon, 21 Feb 2005 20:09:57 +0000 Subject: [PATCH] Andreas Krennmair: merged in mutt changes fixed a bug in mutt_FormatString git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@68 e385b8ad-14ed-0310-8656-cc95a2468c6d --- ChangeLog | 14 +++++++++++++ ChangeLog.mutt-ng | 4 ++++ OPS | 1 + PATCHES | 1 + browser.c | 23 ++++++++++++++++++++- doc/manual.sgml.head | 6 ++++-- functions.h | 1 + hcache.c | 8 +++++++- imap/browse.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ imap/imap.c | 31 +++++++++++++++++++++------- imap/imap.h | 1 + imap/imap_private.h | 3 ++- imap/message.c | 4 ++++ init.h | 1 + muttlib.c | 6 ++++-- pager.c | 7 +++++-- protos.h | 4 ++++ sendlib.c | 3 +++ status.c | 27 +++++++++++++++++++++++- 19 files changed, 177 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a0dd4d..1e1c9f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-02-19 16:00:24 Thomas Roessler (roessler) + + * sendlib.c: Fix Debian 295528. + +2005-02-17 03:33:00 Brendan Cully (brendan) + + * OPS, browser.c, doc/manual.sgml.head, functions.h, + imap/browse.c, imap/imap.c, imap/imap.h, imap/imap_private.h: New + function: rename-mailbox (bound to 'r' by default). + + The lack of a rename-mailbox command for IMAP finally got too annoying. + It's a bit of a cut-and-paste job, but I've put my dreams of cleaning + up the IMAP codebase on hold. Gotta grow up some time. + 2005-02-13 17:37:31 Roland Rosenfeld (roessler) * po/de.po: update diff --git a/ChangeLog.mutt-ng b/ChangeLog.mutt-ng index 7efaf5f..edfea8c 100644 --- a/ChangeLog.mutt-ng +++ b/ChangeLog.mutt-ng @@ -1,5 +1,9 @@ Changes specific to mutt-ng: +2004-02-21: + * Merged past mutt changes + * Fixed a bug in mutt_FormatString regarding aligning the rest of a string to the right (%>) + 2004-02-16: * fixed segfault in curs_lib.c * fixed names diff --git a/OPS b/OPS index 2a2380a..9d3c079 100644 --- a/OPS +++ b/OPS @@ -162,6 +162,7 @@ OP_QUIT "save changes to mailbox and quit" OP_RECALL_MESSAGE "recall a postponed message" OP_REDRAW "clear and redraw the screen" OP_REFORMAT_WINCH "{internal}" +OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)" OP_REPLY "reply to a message" OP_RESEND "use the current message as a template for a new one" OP_SAVE "save message/attachment to a file" diff --git a/PATCHES b/PATCHES index 88643c8..1cf4aef 100644 --- a/PATCHES +++ b/PATCHES @@ -1,4 +1,5 @@ patch-1.5.6.tg.hcache.12 +patch-1.5.5.1.pdmef.short_mbox_name.1 rr.compressed patch-1.5.4.fw.maildir_inode_sort patch-1.4.admcd.gnutls.59d diff --git a/browser.c b/browser.c index f0dc183..7782671 100644 --- a/browser.c +++ b/browser.c @@ -1103,7 +1103,28 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num } break; - case OP_DELETE_MAILBOX: + case OP_RENAME_MAILBOX: + if (!state.entry[menu->current].imap) + mutt_error (_("Rename is only supported for IMAP mailboxes")); + else + { + int nentry = menu->current; + + if (imap_mailbox_rename (state.entry[nentry].name) >= 0) { + destroy_state (&state); + init_state (&state, NULL); + state.imap_browse = 1; + imap_browse (LastDir, &state); + menu->data = state.entry; + menu->current = 0; + menu->top = 0; + init_menu (&state, menu, title, sizeof (title), buffy); + MAYBE_REDRAW (menu->redraw); + } + } + break; + + case OP_DELETE_MAILBOX: if (!state.entry[menu->current].imap) mutt_error (_("Delete is only supported for IMAP mailboxes")); else diff --git a/doc/manual.sgml.head b/doc/manual.sgml.head index 0dc9691..f34b850 100644 --- a/doc/manual.sgml.head +++ b/doc/manual.sgml.head @@ -2507,8 +2507,10 @@ following differences: will choose to descend into the subfolder view. If you wish to view the messages in that folder, you must use view-file instead (bound to space by default). -You can delete mailboxes with the delete-mailbox - command (bound to d by default. You may also +You can create, delete and rename mailboxes with the + create-mailbox, delete-mailbox, and + rename-mailbox commands (default bindings: C, + d and r, respectively). You may also subscribe and unsubscribe to mailboxes (normally these are bound to s and u, respectively). diff --git a/functions.h b/functions.h index 18b0b04..9047248 100644 --- a/functions.h +++ b/functions.h @@ -413,6 +413,7 @@ struct binding_t OpBrowser[] = { #ifdef USE_IMAP { "create-mailbox", OP_CREATE_MAILBOX, "C" }, { "delete-mailbox", OP_DELETE_MAILBOX, "d" }, + { "rename-mailbox", OP_RENAME_MAILBOX, "r" }, #endif #if defined USE_IMAP || defined USE_NNTP { "subscribe", OP_BROWSER_SUBSCRIBE, "s" }, diff --git a/hcache.c b/hcache.c index 9b053c3..dea409e 100644 --- a/hcache.c +++ b/hcache.c @@ -18,7 +18,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ -#include +# if HAVE_INTTYPES_H +# include +# else +# if HAVE_STDINT_H +# include +# endif +# endif #if HAVE_CONFIG_H #include "config.h" diff --git a/imap/browse.c b/imap/browse.c index 760870e..f2b01f4 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -302,6 +302,55 @@ int imap_mailbox_create (const char* folder) return -1; } +int imap_mailbox_rename(const char* mailbox) +{ + IMAP_DATA* idata; + IMAP_MBOX mx; + char buf[LONG_STRING]; + char newname[SHORT_STRING]; + + if (imap_parse_path (mailbox, &mx) < 0) + { + dprint (1, (debugfile, "imap_mailbox_rename: Bad source mailbox %s\n", + mailbox)); + return -1; + } + + if (!(idata = imap_conn_find (&mx.account, M_IMAP_CONN_NONEW))) + { + dprint (1, (debugfile, "imap_mailbox_rename: Couldn't find open connection to %s", mx.account.host)); + goto fail; + } + + snprintf(buf, sizeof (buf), _("Rename mailbox %s to: "), mx.mbox); + + if (mutt_get_field (buf, newname, sizeof (newname), M_FILE) < 0) + goto fail; + + if (!mutt_strlen (newname)) + { + mutt_error (_("Mailbox must have a name.")); + mutt_sleep (1); + goto fail; + } + + if (imap_rename_mailbox (idata, &mx, newname) < 0) { + mutt_error (_("Rename failed: %s"), imap_get_qualifier (idata->cmd.buf)); + mutt_sleep (1); + goto fail; + } + + mutt_message (_("Mailbox renamed.")); + mutt_sleep (0); + + FREE (&mx.mbox); + return 0; + + fail: + FREE (&mx.mbox); + return -1; +} + static int browse_add_list_result (IMAP_DATA* idata, const char* cmd, struct browser_state* state, short isparent) { diff --git a/imap/imap.c b/imap/imap.c index 63eae5a..a9552ce 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -108,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); diff --git a/imap/imap.h b/imap/imap.h index ae42ff2..9ac7a95 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -50,6 +50,7 @@ void imap_disallow_reopen (CONTEXT *ctx); /* browse.c */ int imap_browse (char* path, struct browser_state* state); int imap_mailbox_create (const char* folder); +int imap_mailbox_rename (const char* mailbox); /* message.c */ int imap_append_message (CONTEXT* ctx, MESSAGE* msg); diff --git a/imap/imap_private.h b/imap/imap_private.h index 36d877d..bbaf1ef 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -20,7 +20,7 @@ #ifndef _IMAP_PRIVATE_H #define _IMAP_PRIVATE_H 1 -#include +#include #include "imap.h" #include "mutt_socket.h" @@ -196,6 +196,7 @@ typedef struct /* -- private IMAP functions -- */ /* imap.c */ int imap_create_mailbox (IMAP_DATA* idata, char* mailbox); +int imap_rename_mailbox (IMAP_DATA* idata, IMAP_MBOX* mx, const char* newname); int imap_make_msg_set (IMAP_DATA* idata, BUFFER* buf, int flag, int changed); int imap_open_connection (IMAP_DATA* idata); IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags); diff --git a/imap/message.c b/imap/message.c index 2b7a8e0..96d7e22 100644 --- a/imap/message.c +++ b/imap/message.c @@ -36,7 +36,11 @@ #include "pgp.h" #endif +#if HAVE_STDINT_H #include +#elif HAVE_INTTYPES_H +#include +#endif static void flush_buffer(char* buf, size_t* len, CONNECTION* conn); static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf, diff --git a/init.h b/init.h index 0505778..fd3713d 100644 --- a/init.h +++ b/init.h @@ -2873,6 +2873,7 @@ struct option_t MuttVars[] = { ** .pp ** .dl ** .dt %b .dd number of mailboxes with new mail * + ** .dt %B .dd the short pathname of the current mailbox ** .dt %d .dd number of deleted messages * ** .dt %f .dd the full pathname of the current mailbox ** .dt %F .dd number of flagged messages * diff --git a/muttlib.c b/muttlib.c index 22d4c76..4beb99c 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1029,7 +1029,7 @@ void mutt_FormatString (char *dest, /* output buffer */ if ( DrawFullLine ) count = (COLS < destlen ? COLS : destlen); else - count = ((COLS-SidebarWidth) < destlen ? COLS - SidebarWidth : destlen); + count = ((COLS-SidebarWidth) < destlen ? (COLS - SidebarWidth) : destlen); if (count > col) { count -= col; /* how many columns left on this line */ @@ -1042,8 +1042,10 @@ void mutt_FormatString (char *dest, /* output buffer */ wptr += count; col += count; } - if (len + wlen > destlen) + if (wid + wlen > destlen) len = destlen - wlen; + else + len = wid; memcpy (wptr, buf, len); wptr += len; wlen += len; diff --git a/pager.c b/pager.c index 0e975e4..b735abf 100644 --- a/pager.c +++ b/pager.c @@ -1042,8 +1042,11 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf, wchar_t wc; mbstate_t mbstate; - int wrap_cols = COLS - WrapMargin - SidebarWidth; - + int wrap_cols = COLS; + if (!(flags & (M_SHOWFLAT))) + wrap_cols -= WrapMargin; + wrap_cols -= SidebarWidth; + if (wrap_cols <= 0) wrap_cols = COLS; diff --git a/protos.h b/protos.h index a128aed..a79c25f 100644 --- a/protos.h +++ b/protos.h @@ -20,7 +20,11 @@ # include "config.h" #endif +#if HAVE_STDINT_H #include +#elif HAVE_INTTYPES_H +#include +#endif #include "mbyte.h" #ifdef DEBUG diff --git a/sendlib.c b/sendlib.c index 5cdfcf4..c0d204c 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1177,6 +1177,9 @@ static void transform_to_7bit (BODY *a, FILE *fpin) } else { + a->noconv = 1; + a->force_charset = 1; + mutt_mktemp (buff); if ((s.fpout = safe_fopen (buff, "w")) == NULL) { diff --git a/status.c b/status.c index 0dc5d0e..8f58fec 100644 --- a/status.c +++ b/status.c @@ -41,6 +41,7 @@ static char *get_sort_str (char *buf, size_t buflen, int method) } /* %b = number of incoming folders with unread messages [option] + * %B = short mailbox path * %d = number of deleted messages [option] * %f = full mailbox path * %F = number of flagged messages [option] @@ -63,7 +64,7 @@ status_format_str (char *buf, size_t buflen, char op, const char *src, const char *elsestring, unsigned long data, format_flag flags) { - char fmt[SHORT_STRING], tmp[SHORT_STRING], *cp; + char fmt[SHORT_STRING], tmp[SHORT_STRING], *cp, *p; int count, optional = (flags & M_FORMAT_OPTIONAL); MUTTMENU *menu = (MUTTMENU *) data; @@ -80,6 +81,30 @@ status_format_str (char *buf, size_t buflen, char op, const char *src, optional = 0; break; + case 'B': + snprintf (fmt, sizeof (fmt), "%%%ss", prefix); +#ifdef USE_COMPRESSED + if (Context && Context->compressinfo && Context->realpath) + { + if ((p = strrchr (Context->realpath, '/'))) + strfcpy (tmp, p + 1, sizeof (tmp)); + else + strfcpy (tmp, Context->realpath, sizeof (tmp)); + } + else +#endif + if (Context && Context->path) + { + if ((p = strrchr (Context->path, '/'))) + strfcpy (tmp, p + 1, sizeof (tmp)); + else + strfcpy (tmp, Context->path, sizeof (tmp)); + } + else + strfcpy (tmp, _("no mailbox"), sizeof (tmp)); + snprintf (buf, buflen, fmt, tmp); + break; + case 'd': if (!optional) { -- 2.20.1