Changeset 842:e20c4487dc39 for browser.c

Show
Ignore:
Timestamp:
1999-02-09 12:50:36 (10 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

Brandon's IMAP clean-up; new czech translation.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • browser.c

    r775 r842  
    2424#include "sort.h" 
    2525#include "mailbox.h" 
     26#include "browser.h" 
     27#ifdef USE_IMAP 
     28#include "imap.h" 
     29#endif 
    2630 
    2731#include <stdlib.h> 
     
    3337#include <pwd.h> 
    3438#include <grp.h> 
    35  
    36 struct folder_file 
    37 { 
    38   mode_t mode; 
    39   time_t mtime; 
    40   off_t size; 
    41   char *name; 
    42   char *desc; 
    43   short tagged; 
    44 }; 
    45  
    46 struct browser_state 
    47 { 
    48   struct folder_file *entry; 
    49   short entrylen; /* number of real entries */ 
    50   short entrymax;  /* max entry */ 
    51 }; 
    5239 
    5340static struct mapping_t FolderHelp[] = { 
     
    457444    strfcpy (path, LastDir, sizeof (path)); 
    458445    mutt_pretty_mailbox (path); 
     446#ifdef USE_IMAP 
     447  if (state->imap_browse && option (OPTIMAPLSUB)) 
     448    snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"), 
     449              path, Mask.pattern); 
     450  else 
     451#endif 
    459452    snprintf (title, titlelen, _("Directory [%s], File mask: %s"), 
    460453              path, Mask.pattern); 
     
    492485  { 
    493486    mutt_expand_path (f, flen); 
     487#ifdef USE_IMAP 
     488    if (mx_is_imap (f)) 
     489    { 
     490      init_state (&state, NULL); 
     491      state.imap_browse = 1; 
     492      imap_init_browse (f, &state); 
     493      strfcpy (LastDir, f, sizeof (LastDir)); 
     494    } 
     495    else 
     496    { 
     497#endif 
    494498    for (i = mutt_strlen (f) - 1; i > 0 && f[i] != '/' ; i--); 
    495499    if (i > 0) 
     
    521525      strfcpy (prefix, f + i + 1, sizeof (prefix)); 
    522526    killPrefix = 1; 
    523   } 
    524   else if (!LastDir[0]) 
    525     strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir)); 
     527#ifdef USE_IMAP 
     528    } 
     529#endif 
     530  } 
     531  else  
     532  { 
     533    if (!LastDir[0]) 
     534      strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir)); 
     535#ifdef USE_IMAP 
     536    if (!buffy && mx_is_imap (LastDir)) 
     537    { 
     538      init_state (&state, NULL); 
     539      state.imap_browse = 1; 
     540      imap_init_browse (LastDir, &state); 
     541    } 
     542#endif 
     543  } 
    526544 
    527545  *f = 0; 
     
    532550      return; 
    533551  } 
    534   else if (examine_directory (NULL, &state, LastDir, prefix) == -1) 
     552  else 
     553#ifdef USE_IMAP 
     554  if (!state.imap_browse) 
     555#endif 
     556  if (examine_directory (NULL, &state, LastDir, prefix) == -1) 
    535557    return; 
    536558 
     
    562584        if (S_ISDIR (state.entry[menu->current].mode) || 
    563585            (S_ISLNK (state.entry[menu->current].mode) && 
    564             link_is_dir (state.entry[menu->current].name))) 
     586            link_is_dir (state.entry[menu->current].name))  
     587#ifdef USE_IMAP 
     588            || state.entry[menu->current].notfolder 
     589#endif 
     590            ) 
    565591        { 
    566592          /* make sure this isn't a MH or maildir mailbox */ 
     
    570596            mutt_expand_path (buf, sizeof (buf)); 
    571597          } 
     598#ifdef USE_IMAP 
     599          else if (state.imap_browse) 
     600          { 
     601            strfcpy (buf, state.entry[menu->current].name, sizeof (buf)); 
     602          } 
     603#endif 
    572604          else 
    573605            snprintf (buf, sizeof (buf), "%s/%s", LastDir,  
    574606                      state.entry[menu->current].name); 
    575607 
    576           if (mx_get_magic (buf) <= 0) 
     608          if ((mx_get_magic (buf) <= 0) 
     609#ifdef USE_IMAP 
     610            || state.entry[menu->current].notfolder 
     611#endif 
     612            ) 
    577613          { 
    578614            char OldLastDir[_POSIX_PATH_MAX]; 
     
    605641              mutt_expand_path (LastDir, sizeof (LastDir)); 
    606642            } 
     643#ifdef USE_IMAP 
     644            else if (state.imap_browse) 
     645            { 
     646              strfcpy (LastDir, state.entry[menu->current].name,  
     647                  sizeof (LastDir)); 
     648            } 
     649#endif 
    607650            else 
    608651              sprintf (LastDir + mutt_strlen (LastDir), "/%s", 
     
    616659            } 
    617660            buffy = 0; 
     661#ifdef USE_IMAP 
     662            if (state.imap_browse) 
     663            { 
     664              init_state (&state, NULL); 
     665              state.imap_browse = 1; 
     666              imap_init_browse (LastDir, &state); 
     667              menu->data = state.entry; 
     668            } 
     669            else 
     670#endif 
    618671            if (examine_directory (menu, &state, LastDir, prefix) == -1) 
    619672            { 
     
    638691          mutt_expand_path (f, flen); 
    639692        } 
     693#ifdef USE_IMAP 
     694        else if (state.imap_browse) 
     695        { 
     696          strfcpy (f, state.entry[menu->current].name, flen); 
     697        } 
     698#endif 
    640699        else 
    641700          snprintf (f, flen, "%s/%s", LastDir, state.entry[menu->current].name); 
     
    685744          mutt_message(state.entry[menu->current].name); 
    686745        break; 
     746 
     747#ifdef USE_IMAP 
     748      case OP_BROWSER_SUBSCRIBE: 
     749        imap_subscribe (state.entry[menu->current].name, 1); 
     750        break; 
     751 
     752      case OP_BROWSER_UNSUBSCRIBE: 
     753        imap_subscribe (state.entry[menu->current].name, 0); 
     754        break; 
     755 
     756      case OP_BROWSER_TOGGLE_LSUB: 
     757        if (option (OPTIMAPLSUB)) 
     758        { 
     759          unset_option (OPTIMAPLSUB); 
     760        } 
     761        else 
     762        { 
     763          set_option (OPTIMAPLSUB); 
     764        } 
     765        mutt_ungetch (0, OP_CHECK_NEW); 
     766        break; 
     767#endif 
    687768       
    688769      case OP_CHANGE_DIRECTORY: 
    689770 
    690771        strfcpy (buf, LastDir, sizeof (buf)); 
     772#ifdef USE_IMAP 
     773        if (!state.imap_browse) 
     774#endif 
    691775        {/* add '/' at the end of the directory name */ 
    692776        int len=mutt_strlen(LastDir); 
     
    700784          buffy = 0;       
    701785          mutt_expand_path (buf, sizeof (buf)); 
     786#ifdef USE_IMAP 
     787          if (mx_is_imap (buf)) 
     788          { 
     789            strfcpy (LastDir, buf, sizeof (LastDir)); 
     790            destroy_state (&state); 
     791            init_state (&state, NULL); 
     792            state.imap_browse = 1; 
     793            imap_init_browse (LastDir, &state); 
     794            menu->data = state.entry; 
     795            menu->current = 0;  
     796            menu->top = 0;  
     797            init_menu (&state, menu, title, sizeof (title), buffy); 
     798          } 
     799          else 
     800#endif 
    702801          if (stat (buf, &st) == 0) 
    703802          { 
     
    835934        prefix[0] = 0; 
    836935        killPrefix = 0; 
     936 
    837937        if (buffy) 
    838938        { 
     
    840940            return; 
    841941        } 
     942#ifdef USE_IMAP 
     943        else if (mx_is_imap (LastDir)) 
     944        { 
     945          init_state (&state, NULL); 
     946          state.imap_browse = 1; 
     947          imap_init_browse (LastDir, &state); 
     948          menu->data = state.entry; 
     949        } 
     950#endif 
    842951        else if (examine_directory (menu, &state, LastDir, prefix) == -1) 
    843952          return;