Changeset 1383:48430ce6f7b2

Show
Ignore:
Timestamp:
1999-11-22 08:01:39 (9 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

IMAP folder creation and deletion. From Brendan Cully.

Files:
12 modified

Legend:

Unmodified
Added
Removed
  • OPS

    r1306 r1383  
    77OP_BROWSER_VIEW_FILE "view file" 
    88OP_BROWSER_TELL "display the currently selected file's name" 
    9 OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP Only)" 
    10 OP_BROWSER_UNSUBSCRIBE "unsubscribe to current mailbox (IMAP Only)" 
    11 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP Only)" 
     9OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)" 
     10OP_BROWSER_UNSUBSCRIBE "unsubscribe to current mailbox (IMAP only)" 
     11OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)" 
    1212OP_CHANGE_DIRECTORY "change directories" 
    1313OP_CHECK_NEW "check mailboxes for new mail" 
     
    4848OP_DECODE_SAVE "make decoded copy (text/plain) and delete" 
    4949OP_DELETE "delete the current entry" 
     50OP_DELETE_MAILBOX "delete the current mailbox (IMAP only)" 
    5051OP_DELETE_SUBTHREAD "delete all messages in subthread" 
    5152OP_DELETE_THREAD "delete all messages in thread" 
     
    113114OP_MAIN_UNTAG_PATTERN "untag messages matching a pattern" 
    114115OP_MIDDLE_PAGE "move to the middle of the page" 
     116OP_NEW_MAILBOX "create a new mailbox (IMAP only)" 
    115117OP_NEXT_ENTRY "move to the next entry" 
    116118OP_NEXT_LINE "scroll down one line" 
  • browser.c

    r1349 r1383  
    338338  state->entry = (struct folder_file *) safe_malloc (sizeof (struct folder_file) * state->entrymax); 
    339339  memset (state->entry, 0, sizeof (struct folder_file) * state->entrymax); 
     340#ifdef USE_IMAP 
     341  state->imap_browse = 0; 
     342#endif 
    340343  if (menu) 
    341344    menu->data = state->entry; 
     
    597600    menu->tag = file_tag; 
    598601 
    599   menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER, FolderHelp); 
     602  menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER, 
     603    FolderHelp); 
    600604 
    601605  init_menu (&state, menu, title, sizeof (title), buffy); 
     
    794798        mutt_ungetch (0, OP_CHECK_NEW); 
    795799        break; 
     800 
     801      case OP_NEW_MAILBOX: 
     802        mutt_error (_("Creating mailboxes is not yet supported.")); 
     803        break; 
     804 
     805      case OP_DELETE_MAILBOX: 
     806        if (!mx_is_imap (state.entry[menu->current].name)) 
     807          mutt_error (_("Delete is only supported for IMAP mailboxes")); 
     808        else 
     809        { 
     810          char msg[LONG_STRING]; 
     811          char* mbox; 
     812          int nentry = menu->current; 
     813           
     814          imap_parse_path (state.entry[nentry].name, NULL, 0, NULL, 
     815            NULL, &mbox); 
     816          snprintf (msg, sizeof (msg), _("Really delete mailbox \"%s\"?"), 
     817            mbox); 
     818          if (mutt_yesorno (msg, M_NO) == M_YES) 
     819          { 
     820            if (!imap_delete_mailbox (Context, mbox)) 
     821            { 
     822              /* free the mailbox from the browser */ 
     823              safe_free ((void **) &((state.entry)[nentry].name)); 
     824              safe_free ((void **) &((state.entry)[nentry].desc)); 
     825              /* and move all other entries up */ 
     826              if (nentry+1 < state.entrylen) 
     827                memmove (state.entry + nentry, state.entry + nentry + 1, 
     828                  sizeof (struct folder_file) * (state.entrylen - (nentry+1))); 
     829              state.entrylen--; 
     830              mutt_message _("Mailbox deleted."); 
     831              init_menu (&state, menu, title, sizeof (title), buffy); 
     832              MAYBE_REDRAW (menu->redraw); 
     833            } 
     834          } 
     835          else 
     836            mutt_message _("Mailbox not deleted."); 
     837        } 
     838        break; 
    796839#endif 
    797840       
  • functions.h

    r1349 r1383  
    328328  { "view-file",        OP_BROWSER_VIEW_FILE,   " " }, 
    329329#ifdef USE_IMAP 
     330  { "new-mailbox",      OP_NEW_MAILBOX,         "n" }, 
     331  { "delete-mailbox",   OP_DELETE_MAILBOX,      "d" }, 
    330332  { "subscribe",        OP_BROWSER_SUBSCRIBE,   "s" }, 
    331333  { "unsubscribe",      OP_BROWSER_UNSUBSCRIBE, "u" }, 
  • imap/BUGS

    r1343 r1383  
    11In no particular order: 
     2 
     3* Mutt doesn't detect when a mailbox has only been opened read-only 
     4  (because, say, another process has it open), so it lets you store 
     5  changes that it can't commit. 
     6  --> just pick up the [READ-ONLY] in the tagged response, set mutt's flag 
     7 
     8* ~h searches download the entire folder, setting everything to \Seen in 
     9  the process. 
     10  --> Use SEARCH? or at least try to use .PEEK when doing scans. I've been 
     11      thinking of going to always PEEK anyway, but then you'd have to store 
     12      updates for every message you touched. Maybe a config option? 
    213 
    314* No checks are performed on long commands to make sure that they are 
     
    4152 
    4253Brendan Cully <brendan@kublai.com> 
    43 Updated 19991102 
     54Updated 19991110 
  • imap/README

    r1310 r1383  
    2626* Preserve message keywords 
    2727* Preserve deleted messages if you don't choose to expunge them 
     28* Delete mailboxes (from the browser) 
  • imap/TODO

    r1282 r1383  
    2828  PRIORITY: [** ] 
    2929 
     30* See if we can't add more info to the IMAP browser than just name (without 
     31  incurring too much overhead). eg which folders contain new mail, size, 
     32  number of messages. 
     33 
     34  PRIORITY: [** ] 
     35 
    3036[ -- speed -- ] 
    3137* Persistent caching of data. I think the nicest way to do this is to store 
     
    4248    the server changes its file format, bad things might happen. Could be 
    4349    worked around with a specific Mutt header in all messages, probably. 
     50 
     51  PRIORITY: [*  ] 
     52 
     53* Instead of testing for the existence of a mailbox for APPEND, just append 
     54  and create/retry on failure. This is only a small bandwidth savings, but 
     55  it should be easy. 
    4456 
    4557  PRIORITY: [*  ] 
     
    6173 
    6274Brendan Cully <brendan@kublai.com> 
    63 Updated: 19990911 
     75Updated: 19991119 
  • imap/imap.c

    r1373 r1383  
    4343static int imap_check_capabilities (IMAP_DATA *idata); 
    4444 
     45int imap_create_mailbox (CONTEXT* ctx, char* mailbox) 
     46{ 
     47  char buf[LONG_STRING], mbox[LONG_STRING]; 
     48 
     49  imap_quote_string (mbox, sizeof (mbox), mailbox); 
     50  snprintf (buf, sizeof (buf), "CREATE %s", mbox); 
     51       
     52  if (imap_exec (buf, sizeof (buf), CTX_DATA, buf, 0) != 0) 
     53  { 
     54    imap_error ("imap_create_mailbox()", buf); 
     55    return -1; 
     56  } 
     57  return 0; 
     58} 
     59 
     60int imap_delete_mailbox (CONTEXT* ctx, char* mailbox) 
     61{ 
     62  char buf[LONG_STRING], mbox[LONG_STRING]; 
     63   
     64  imap_quote_string (mbox, sizeof (mbox), mailbox); 
     65  snprintf (buf, sizeof (buf), "DELETE %s", mbox); 
     66 
     67  if (imap_exec (buf, sizeof (buf), CTX_DATA, buf, 0) != 0) 
     68  { 
     69    imap_error ("imap_delete_mailbox", buf); 
     70    return -1; 
     71  } 
     72 
     73  return 0; 
     74} 
     75 
    4576void imap_set_logout (CONTEXT *ctx) 
    4677{ 
     
    713744} 
    714745 
    715 int imap_create_mailbox (IMAP_DATA* idata, char* mailbox) 
    716 { 
    717   char buf[LONG_STRING], mbox[LONG_STRING]; 
    718  
    719   imap_quote_string (mbox, sizeof (mbox), mailbox); 
    720   snprintf (buf, sizeof (buf), "CREATE %s", mbox); 
    721        
    722   if (imap_exec (buf, sizeof (buf), idata, buf, 0) != 0) 
    723   { 
    724     imap_error ("imap_create_mailbox()", buf); 
    725     return (-1); 
    726   } 
    727   return 0; 
    728 } 
    729  
    730746int imap_open_mailbox_append (CONTEXT *ctx) 
    731747{ 
     
    799815        return (-1); 
    800816      } 
    801       if (imap_create_mailbox (idata, mailbox) < 0) 
     817      if (imap_create_mailbox (ctx, mailbox) < 0) 
    802818      { 
    803819        return (-1); 
  • imap/imap.h

    r1373 r1383  
    2323#include "mailbox.h" 
    2424 
     25/* imap.c */ 
    2526int imap_check_mailbox (CONTEXT *ctx, int *index_hint); 
     27int imap_create_mailbox (CONTEXT* idata, char* mailbox); 
    2628int imap_close_connection (CONTEXT *ctx); 
     29int imap_delete_mailbox (CONTEXT* idata, char* mailbox); 
    2730int imap_open_mailbox (CONTEXT *ctx); 
    2831int imap_open_mailbox_append (CONTEXT *ctx); 
  • imap/imap_private.h

    r1373 r1383  
    150150/* -- private IMAP functions -- */ 
    151151/* imap.c */ 
    152 int imap_create_mailbox (IMAP_DATA* idata, char* mailbox); 
    153152int imap_make_msg_set (char* buf, size_t buflen, CONTEXT* ctx, int flag, 
    154153  int changed); 
  • imap/message.c

    r1373 r1383  
    581581        return -1; 
    582582      } 
    583       if (imap_create_mailbox (CTX_DATA, mbox) < 0) 
     583      if (imap_create_mailbox (ctx, mbox) < 0) 
    584584        return -1; 
    585585    } 
  • imap/util.c

    r1373 r1383  
    129129 
    130130  /* set default port */ 
    131   *port = 0; 
     131  if (port) 
     132    *port = 0; 
    132133  if (socktype) 
    133134    *socktype = M_NEW_SOCKET; 
     
    136137    return -1; 
    137138  pc++; 
    138   n = 0; 
    139   while (*pc && *pc != '}' && *pc != ':' && *pc != '/' && (n < hlen-1)) 
    140     host[n++] = *pc++; 
    141   host[n] = 0; 
    142   /* catch NULL hosts */ 
    143   if (!*host) 
     139  /* skip over the entire host, but copy in only what we have room for */ 
     140  for (n = 0; *pc && *pc != '}' && *pc != ':' && *pc != '/'; pc++) 
     141    if (n+1 < hlen) 
     142      host[n++] = *pc; 
     143  if (hlen) 
     144    host[n] = 0; 
     145 
     146  /* catch NULL hosts, unless we're deliberately not parsing them */ 
     147  if (hlen && !*host) 
    144148  { 
    145149    dprint (1, (debugfile, "imap_parse_path: NULL host in %s\n", path)); 
     
    158162    c = *pc; 
    159163    *pc = '\0'; 
    160     *port = atoi (pt); 
    161     if (!port) 
     164    if (port) 
     165      *port = atoi (pt); 
     166    if (port && !*port) 
    162167    { 
    163168      dprint (1, (debugfile, "imap_parse_path: bad port in %s\n", path)); 
     
    179184      if (socktype) 
    180185        *socktype = M_NEW_SSL_SOCKET; 
    181       if (!*port) 
     186      if (port && !*port) 
    182187        *port = IMAP_SSL_PORT; 
    183188    } else 
     
    188193  pc++; 
    189194   
    190   if (!*port) 
     195  if (port && !*port) 
    191196    *port = IMAP_PORT; 
    192197   
  • pgppubring.c

    r1348 r1383  
    134134  } 
    135135   
    136   pgpring_find_candidates (kring, argv + optind, argc - optind); 
     136  pgpring_find_candidates (kring, (const char**) argv + optind, argc - optind); 
    137137     
    138138  return 0;