Andreas Krennmair:
authorak1 <ak1@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Mon, 21 Feb 2005 20:09:57 +0000 (20:09 +0000)
committerak1 <ak1@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Mon, 21 Feb 2005 20:09:57 +0000 (20:09 +0000)
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

19 files changed:
ChangeLog
ChangeLog.mutt-ng
OPS
PATCHES
browser.c
doc/manual.sgml.head
functions.h
hcache.c
imap/browse.c
imap/imap.c
imap/imap.h
imap/imap_private.h
imap/message.c
init.h
muttlib.c
pager.c
protos.h
sendlib.c
status.c

index 9a0dd4d..1e1c9f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2005-02-19 16:00:24  Thomas Roessler  <roessler@does-not-exist.org>  (roessler)
+
+       * sendlib.c: Fix Debian 295528.
+
+2005-02-17 03:33:00  Brendan Cully  <brendan@kublai.com>  (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  <roland@spinnaker.de>  (roessler)
 
        * po/de.po: update
 2005-02-13 17:37:31  Roland Rosenfeld  <roland@spinnaker.de>  (roessler)
 
        * po/de.po: update
index 7efaf5f..edfea8c 100644 (file)
@@ -1,5 +1,9 @@
 Changes specific to mutt-ng:
 
 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
 2004-02-16:
   * fixed segfault in curs_lib.c
   * fixed names
diff --git a/OPS b/OPS
index 2a2380a..9d3c079 100644 (file)
--- 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_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"
 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 (file)
--- a/PATCHES
+++ b/PATCHES
@@ -1,4 +1,5 @@
 patch-1.5.6.tg.hcache.12
 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
 rr.compressed
 patch-1.5.4.fw.maildir_inode_sort
 patch-1.4.admcd.gnutls.59d
index f0dc183..7782671 100644 (file)
--- 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;
 
        }
        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
        if (!state.entry[menu->current].imap)
          mutt_error (_("Delete is only supported for IMAP mailboxes"));
        else
index 0dc9691..f34b850 100644 (file)
@@ -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 <tt>view-file</tt> instead
   (bound to <tt>space</tt> by default).
   will choose to descend into the subfolder view. If you wish to view
   the messages in that folder, you must use <tt>view-file</tt> instead
   (bound to <tt>space</tt> by default).
-<item>You can delete mailboxes with the <tt>delete-mailbox</tt>
-  command (bound to <tt>d</tt> by default. You may also
+<item>You can create, delete and rename mailboxes with the
+  <tt>create-mailbox</tt>, <tt>delete-mailbox</tt>, and
+  <tt>rename-mailbox</tt> commands (default bindings: <tt>C</tt>,
+  <tt>d</tt> and <tt>r</tt>, respectively). You may also
   <tt>subscribe</tt> and <tt>unsubscribe</tt> to mailboxes (normally
   these are bound to <tt>s</tt> and <tt>u</tt>, respectively).
 </itemize>
   <tt>subscribe</tt> and <tt>unsubscribe</tt> to mailboxes (normally
   these are bound to <tt>s</tt> and <tt>u</tt>, respectively).
 </itemize>
index 18b0b04..9047248 100644 (file)
@@ -413,6 +413,7 @@ struct binding_t OpBrowser[] = {
 #ifdef USE_IMAP
   { "create-mailbox",   OP_CREATE_MAILBOX,      "C" },
   { "delete-mailbox",   OP_DELETE_MAILBOX,      "d" },
 #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" },
 #endif
 #if defined USE_IMAP || defined USE_NNTP
   { "subscribe",       OP_BROWSER_SUBSCRIBE,   "s" },
index 9b053c3..dea409e 100644 (file)
--- a/hcache.c
+++ b/hcache.c
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  */
 
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  */
 
-#include <stdint.h>
+# if HAVE_INTTYPES_H
+#  include <inttypes.h>
+# else
+#  if HAVE_STDINT_H
+#   include <stdint.h>
+#  endif
+# endif
 
 #if HAVE_CONFIG_H
 #include "config.h"
 
 #if HAVE_CONFIG_H
 #include "config.h"
index 760870e..f2b01f4 100644 (file)
@@ -302,6 +302,55 @@ int imap_mailbox_create (const char* folder)
   return -1;
 }
 
   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)
 {
 static int browse_add_list_result (IMAP_DATA* idata, const char* cmd,
   struct browser_state* state, short isparent)
 {
index 63eae5a..a9552ce 100644 (file)
@@ -108,20 +108,37 @@ int imap_create_mailbox (IMAP_DATA* idata, char* mailbox)
   return 0;
 }
 
   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) {
 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 {
   } else {
-         idata = ctx->data;
+    idata = ctx->data;
   }
 
   imap_munge_mbox_name (mbox, sizeof (mbox), mx.mbox);
   }
 
   imap_munge_mbox_name (mbox, sizeof (mbox), mx.mbox);
index ae42ff2..9ac7a95 100644 (file)
@@ -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);
 /* 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);
 
 /* message.c */
 int imap_append_message (CONTEXT* ctx, MESSAGE* msg);
index 36d877d..bbaf1ef 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef _IMAP_PRIVATE_H
 #define _IMAP_PRIVATE_H 1
 
 #ifndef _IMAP_PRIVATE_H
 #define _IMAP_PRIVATE_H 1
 
-#include <stdint.h>
+#include <inttypes.h>
 
 #include "imap.h"
 #include "mutt_socket.h"
 
 #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);
 /* -- 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);
 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);
index 2b7a8e0..96d7e22 100644 (file)
 #include "pgp.h"
 #endif
 
 #include "pgp.h"
 #endif
 
+#if HAVE_STDINT_H
 #include <stdint.h>
 #include <stdint.h>
+#elif HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
 
 static void flush_buffer(char* buf, size_t* len, CONNECTION* conn);
 static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf,
 
 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 (file)
--- 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 *
   ** .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 *
   ** .dt %d  .dd number of deleted messages *
   ** .dt %f  .dd the full pathname of the current mailbox
   ** .dt %F  .dd number of flagged messages *
index 22d4c76..4beb99c 100644 (file)
--- 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
        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 */
        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;
          }
            wptr += count;
            col += count;
          }
-         if (len + wlen > destlen)
+         if (wid + wlen > destlen)
            len = destlen - wlen;
            len = destlen - wlen;
+    else
+      len = wid;
          memcpy (wptr, buf, len);
          wptr += len;
          wlen += len;
          memcpy (wptr, buf, len);
          wptr += len;
          wlen += len;
diff --git a/pager.c b/pager.c
index 0e975e4..b735abf 100644 (file)
--- 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;
 
   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;
   
   if (wrap_cols <= 0)
     wrap_cols = COLS;
   
index a128aed..a79c25f 100644 (file)
--- a/protos.h
+++ b/protos.h
 # include "config.h"
 #endif
 
 # include "config.h"
 #endif
 
+#if HAVE_STDINT_H
 #include <stdint.h>
 #include <stdint.h>
+#elif HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
 #include "mbyte.h"
 
 #ifdef DEBUG
 #include "mbyte.h"
 
 #ifdef DEBUG
index 5cdfcf4..c0d204c 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1177,6 +1177,9 @@ static void transform_to_7bit (BODY *a, FILE *fpin)
     }
     else 
     {
     }
     else 
     {
+      a->noconv = 1;
+      a->force_charset = 1;
+      
       mutt_mktemp (buff);
       if ((s.fpout = safe_fopen (buff, "w")) == NULL) 
       {
       mutt_mktemp (buff);
       if ((s.fpout = safe_fopen (buff, "w")) == NULL) 
       {
index 0dc5d0e..8f58fec 100644 (file)
--- 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 = 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]
  * %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)
 {
                   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;
 
   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;
 
        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)
       {
     case 'd':
       if (!optional)
       {