X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=browser.c;h=ff4dc3df2e581caa9db7d895791899bf91204b41;hp=d4a7157d86fae30c358772cb75de76f817f357c2;hb=8e037c67a88cb4680c4391134c578e3b55a80f8a;hpb=ba5e3af4ea19e1d20c80941c077039871ec84258 diff --git a/browser.c b/browser.c index d4a7157..ff4dc3d 100644 --- a/browser.c +++ b/browser.c @@ -11,7 +11,10 @@ # include "config.h" #endif +#include + #include "mutt.h" +#include "enter.h" #include "mx.h" #include "mutt_curses.h" #include "mutt_menu.h" @@ -19,6 +22,8 @@ #include "mapping.h" #include "sort.h" #include "browser.h" +#include "attach.h" + #ifdef USE_IMAP #include "imap.h" #include "imap/mx_imap.h" @@ -46,7 +51,7 @@ static struct mapping_t FolderHelp[] = { {N_("Chdir"), OP_CHANGE_DIRECTORY}, {N_("Mask"), OP_ENTER_MASK}, {N_("Help"), OP_HELP}, - {NULL} + {NULL, OP_NULL} }; #ifdef USE_NNTP @@ -58,7 +63,7 @@ static struct mapping_t FolderNewsHelp[] = { {N_("Catchup"), OP_CATCHUP}, {N_("Mask"), OP_ENTER_MASK}, {N_("Help"), OP_HELP}, - {NULL} + {NULL, OP_NULL} }; #endif @@ -76,14 +81,14 @@ static void destroy_state (struct browser_state *state) int c; for (c = 0; c < state->entrylen; c++) { - mem_free (&((state->entry)[c].name)); - mem_free (&((state->entry)[c].desc)); - mem_free (&((state->entry)[c].st)); + p_delete(&((state->entry)[c].name)); + p_delete(&((state->entry)[c].desc)); + p_delete(&((state->entry)[c].st)); } #ifdef USE_IMAP - mem_free (&state->folder); + p_delete(&state->folder); #endif - mem_free (&state->entry); + p_delete(&state->entry); } static int browser_compare_subject (const void *a, const void *b) @@ -164,8 +169,8 @@ static const char *folder_format_str (char *dest, size_t destlen, char op, const char *elsestring, unsigned long data, format_flag flags) { - char fn[SHORT_STRING], tmp[SHORT_STRING], permission[11]; - char date[16], *t_fmt; + char fn[SHORT_STRING], tmp[SHORT_STRING], permission[11], date[16]; + const char *t_fmt; time_t tnow; FOLDER *folder = (FOLDER *) data; struct passwd *pw; @@ -194,7 +199,7 @@ static const char *folder_format_str (char *dest, size_t destlen, char op, case 'f': { - char *s; + const char *s; #ifdef USE_IMAP if (folder->ff->imap) @@ -437,7 +442,7 @@ static void add_folder (MUTTMENU * m, struct browser_state *state, (state->entry)[state->entrylen].mtime = s->st_mtime; (state->entry)[state->entrylen].size = s->st_size; - (state->entry)[state->entrylen].st = mem_malloc (sizeof (struct stat)); + (state->entry)[state->entrylen].st = p_new(struct stat, 1); memcpy ((state->entry)[state->entrylen].st, s, sizeof (struct stat)); } @@ -484,6 +489,7 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, for (tmp = news->list; tmp; tmp = tmp->next) { if (!(data = (NNTP_DATA *) tmp->data)) continue; + nntp_sync_sidebar (data); if (prefix && *prefix && strncmp (prefix, data->group, str_len (prefix)) != 0) continue; @@ -491,6 +497,7 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, continue; add_folder (menu, state, data->group, NULL, data, data->new); } + sidebar_draw (CurrentMenu); } else #endif /* USE_NNTP */ @@ -573,14 +580,14 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state) init_state (state, menu); for (tmp = news->list; tmp; tmp = tmp->next) { - if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new || - (data->subscribed - && - (!option - (OPTSHOWONLYUNREAD) - || data->unread)))) + if ((data = (NNTP_DATA*) tmp->data) == NULL) + continue; + nntp_sync_sidebar (data); + if ((data->new || (data->subscribed && + (!option (OPTSHOWONLYUNREAD)|| data->unread)))) add_folder (menu, state, data->group, NULL, data, data->new); } + sidebar_draw (CurrentMenu); } else #endif @@ -816,6 +823,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); } #endif } @@ -951,6 +959,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; } else @@ -1049,6 +1058,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; menu->current = 0; menu->top = 0; @@ -1068,6 +1078,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; menu->current = 0; menu->top = 0; @@ -1091,8 +1102,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (mutt_yesorno (msg, M_NO) == M_YES) { if (!imap_delete_mailbox (Context, mx)) { /* free the mailbox from the browser */ - mem_free (&((state.entry)[nentry].name)); - mem_free (&((state.entry)[nentry].desc)); + p_delete(&((state.entry)[nentry].name)); + p_delete(&((state.entry)[nentry].desc)); /* and move all other entries up */ if (nentry + 1 < state.entrylen) memmove (state.entry + nentry, state.entry + nentry + 1, @@ -1107,7 +1118,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, } else mutt_message _("Mailbox not deleted."); - mem_free (&mx.mbox); + p_delete(&mx.mbox); } break; #endif @@ -1142,6 +1153,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; menu->current = 0; menu->top = 0; @@ -1179,7 +1191,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, strfcpy (buf, NONULL (Mask.pattern), sizeof (buf)); if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) { - regex_t *rx = (regex_t *) mem_malloc (sizeof (regex_t)); + regex_t *rx = p_new(regex_t, 1); char *s = buf; int not = 0, err; @@ -1197,13 +1209,13 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) { regerror (err, rx, buf, sizeof (buf)); regfree (rx); - mem_free (&rx); + p_delete(&rx); mutt_error ("%s", buf); } else { str_replace (&Mask.pattern, buf); regfree (Mask.rx); - mem_free (&Mask.rx); + p_delete(&Mask.rx); Mask.rx = rx; Mask.not = not; @@ -1213,6 +1225,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; init_menu (&state, menu, title, sizeof (title), buffy); } @@ -1297,6 +1310,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; } #endif @@ -1306,6 +1320,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, break; case OP_BUFFY_LIST: + if (option (OPTFORCEBUFFYCHECK)) + buffy_check (1); buffy_list (); break; @@ -1384,7 +1400,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, folder.ff->st = NULL; folder.ff->is_new = nd->new; folder.ff->nd = nd; - mem_free (&f->desc); + p_delete(&f->desc); mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat), newsgroup_format_str, (unsigned long) &folder, M_FORMAT_ARROWCURSOR); @@ -1428,7 +1444,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, case OP_SUBSCRIBE_PATTERN: case OP_UNSUBSCRIBE_PATTERN: if (option (OPTNEWS)) { - regex_t *rx = (regex_t *) mem_malloc (sizeof (regex_t)); + regex_t *rx = p_new(regex_t, 1); char *s = buf; int j = menu->current; NNTP_DATA *nd; @@ -1444,14 +1460,14 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, else snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: ")); if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) { - mem_free (&rx); + p_delete(&rx); break; } if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) { regerror (err, rx, buf, sizeof (buf)); regfree (rx); - mem_free (&rx); + p_delete(&rx); mutt_error ("%s", buf); break; } @@ -1482,7 +1498,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, folder.f = NULL; folder.new = nd->new; folder.nd = nd; - mem_free (&f->desc); + p_delete(&f->desc); mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat), newsgroup_format_str, (unsigned long) &folder, M_FORMAT_ARROWCURSOR); @@ -1516,7 +1532,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, nntp_clear_cacheindex (news); if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE) regfree (rx); - mem_free (&rx); + p_delete(&rx); } #ifdef USE_IMAP else