summaryrefslogtreecommitdiffstats
path: root/browser.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-02-09 20:50:36 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-02-09 20:50:36 +0000
commit5ba906d2a77b9b45e46ed23a6959f7a97a6ad68e (patch)
treedeaead3c88005ef70d4d954cca3552083294e145 /browser.c
parente4f9683bb99a38bd46b9e7f2d18d2a35dfcd94bf (diff)
Brandon's IMAP clean-up; new czech translation.
Diffstat (limited to 'browser.c')
-rw-r--r--browser.c153
1 files changed, 131 insertions, 22 deletions
diff --git a/browser.c b/browser.c
index ae4a29d9..e6264561 100644
--- a/browser.c
+++ b/browser.c
@@ -23,6 +23,10 @@
#include "mapping.h"
#include "sort.h"
#include "mailbox.h"
+#include "browser.h"
+#ifdef USE_IMAP
+#include "imap.h"
+#endif
#include <stdlib.h>
#include <dirent.h>
@@ -33,23 +37,6 @@
#include <pwd.h>
#include <grp.h>
-struct folder_file
-{
- mode_t mode;
- time_t mtime;
- off_t size;
- char *name;
- char *desc;
- short tagged;
-};
-
-struct browser_state
-{
- struct folder_file *entry;
- short entrylen; /* number of real entries */
- short entrymax; /* max entry */
-};
-
static struct mapping_t FolderHelp[] = {
{ N_("Exit"), OP_EXIT },
{ N_("Chdir"), OP_CHANGE_DIRECTORY },
@@ -456,6 +443,12 @@ static void init_menu (struct browser_state *state, MUTTMENU *menu, char *title,
{
strfcpy (path, LastDir, sizeof (path));
mutt_pretty_mailbox (path);
+#ifdef USE_IMAP
+ if (state->imap_browse && option (OPTIMAPLSUB))
+ snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
+ path, Mask.pattern);
+ else
+#endif
snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
path, Mask.pattern);
}
@@ -491,6 +484,17 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
if (*f)
{
mutt_expand_path (f, flen);
+#ifdef USE_IMAP
+ if (mx_is_imap (f))
+ {
+ init_state (&state, NULL);
+ state.imap_browse = 1;
+ imap_init_browse (f, &state);
+ strfcpy (LastDir, f, sizeof (LastDir));
+ }
+ else
+ {
+#endif
for (i = mutt_strlen (f) - 1; i > 0 && f[i] != '/' ; i--);
if (i > 0)
{
@@ -520,9 +524,23 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
else
strfcpy (prefix, f + i + 1, sizeof (prefix));
killPrefix = 1;
+#ifdef USE_IMAP
+ }
+#endif
+ }
+ else
+ {
+ if (!LastDir[0])
+ strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir));
+#ifdef USE_IMAP
+ if (!buffy && mx_is_imap (LastDir))
+ {
+ init_state (&state, NULL);
+ state.imap_browse = 1;
+ imap_init_browse (LastDir, &state);
+ }
+#endif
}
- else if (!LastDir[0])
- strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir));
*f = 0;
@@ -531,7 +549,11 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
if (examine_mailboxes (NULL, &state) == -1)
return;
}
- else if (examine_directory (NULL, &state, LastDir, prefix) == -1)
+ else
+#ifdef USE_IMAP
+ if (!state.imap_browse)
+#endif
+ if (examine_directory (NULL, &state, LastDir, prefix) == -1)
return;
menu = mutt_new_menu ();
@@ -561,7 +583,11 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
if (S_ISDIR (state.entry[menu->current].mode) ||
(S_ISLNK (state.entry[menu->current].mode) &&
- link_is_dir (state.entry[menu->current].name)))
+ link_is_dir (state.entry[menu->current].name))
+#ifdef USE_IMAP
+ || state.entry[menu->current].notfolder
+#endif
+ )
{
/* make sure this isn't a MH or maildir mailbox */
if (buffy)
@@ -569,11 +595,21 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
mutt_expand_path (buf, sizeof (buf));
}
+#ifdef USE_IMAP
+ else if (state.imap_browse)
+ {
+ strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
+ }
+#endif
else
snprintf (buf, sizeof (buf), "%s/%s", LastDir,
state.entry[menu->current].name);
- if (mx_get_magic (buf) <= 0)
+ if ((mx_get_magic (buf) <= 0)
+#ifdef USE_IMAP
+ || state.entry[menu->current].notfolder
+#endif
+ )
{
char OldLastDir[_POSIX_PATH_MAX];
@@ -604,6 +640,13 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
sprintf (LastDir, "%s", state.entry[menu->current].name);
mutt_expand_path (LastDir, sizeof (LastDir));
}
+#ifdef USE_IMAP
+ else if (state.imap_browse)
+ {
+ strfcpy (LastDir, state.entry[menu->current].name,
+ sizeof (LastDir));
+ }
+#endif
else
sprintf (LastDir + mutt_strlen (LastDir), "/%s",
state.entry[menu->current].name);
@@ -615,6 +658,16 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
killPrefix = 0;
}
buffy = 0;
+#ifdef USE_IMAP
+ if (state.imap_browse)
+ {
+ init_state (&state, NULL);
+ state.imap_browse = 1;
+ imap_init_browse (LastDir, &state);
+ menu->data = state.entry;
+ }
+ else
+#endif
if (examine_directory (menu, &state, LastDir, prefix) == -1)
{
/* try to restore the old values */
@@ -637,6 +690,12 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
strfcpy (f, state.entry[menu->current].name, flen);
mutt_expand_path (f, flen);
}
+#ifdef USE_IMAP
+ else if (state.imap_browse)
+ {
+ strfcpy (f, state.entry[menu->current].name, flen);
+ }
+#endif
else
snprintf (f, flen, "%s/%s", LastDir, state.entry[menu->current].name);
@@ -684,10 +743,35 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
if(state.entrylen)
mutt_message(state.entry[menu->current].name);
break;
+
+#ifdef USE_IMAP
+ case OP_BROWSER_SUBSCRIBE:
+ imap_subscribe (state.entry[menu->current].name, 1);
+ break;
+
+ case OP_BROWSER_UNSUBSCRIBE:
+ imap_subscribe (state.entry[menu->current].name, 0);
+ break;
+
+ case OP_BROWSER_TOGGLE_LSUB:
+ if (option (OPTIMAPLSUB))
+ {
+ unset_option (OPTIMAPLSUB);
+ }
+ else
+ {
+ set_option (OPTIMAPLSUB);
+ }
+ mutt_ungetch (0, OP_CHECK_NEW);
+ break;
+#endif
case OP_CHANGE_DIRECTORY:
strfcpy (buf, LastDir, sizeof (buf));
+#ifdef USE_IMAP
+ if (!state.imap_browse)
+#endif
{/* add '/' at the end of the directory name */
int len=mutt_strlen(LastDir);
if (sizeof (buf) > len)
@@ -699,6 +783,21 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
{
buffy = 0;
mutt_expand_path (buf, sizeof (buf));
+#ifdef USE_IMAP
+ if (mx_is_imap (buf))
+ {
+ strfcpy (LastDir, buf, sizeof (LastDir));
+ destroy_state (&state);
+ init_state (&state, NULL);
+ state.imap_browse = 1;
+ imap_init_browse (LastDir, &state);
+ menu->data = state.entry;
+ menu->current = 0;
+ menu->top = 0;
+ init_menu (&state, menu, title, sizeof (title), buffy);
+ }
+ else
+#endif
if (stat (buf, &st) == 0)
{
if (S_ISDIR (st.st_mode))
@@ -834,11 +933,21 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
destroy_state (&state);
prefix[0] = 0;
killPrefix = 0;
+
if (buffy)
{
if (examine_mailboxes (menu, &state) == -1)
return;
}
+#ifdef USE_IMAP
+ else if (mx_is_imap (LastDir))
+ {
+ init_state (&state, NULL);
+ state.imap_browse = 1;
+ imap_init_browse (LastDir, &state);
+ menu->data = state.entry;
+ }
+#endif
else if (examine_directory (menu, &state, LastDir, prefix) == -1)
return;
init_menu (&state, menu, title, sizeof (title), buffy);