1 *** mutt-1.5.24-orig/buffy.c 2015-08-30 12:06:38.000000000 -0500
2 --- mutt-1.5.24/buffy.c 2015-09-16 23:18:13.000000000 -0500
9 + static int buffy_compare_name(const void *a, const void *b) {
10 + const BUFFY *b1 = * (BUFFY * const *) a;
11 + const BUFFY *b2 = * (BUFFY * const *) b;
13 + return mutt_strcoll(b1->path, b2->path);
16 + static BUFFY *buffy_sort(BUFFY *b)
23 + if (!option(OPTSIDEBARSORT))
26 + for (; tmp != NULL; tmp = tmp->next)
29 + ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
32 + for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
36 + qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
38 + for (i = 0; i < buffycount - 1; i++) {
39 + ary[i]->next = ary[i+1];
41 + ary[buffycount - 1]->next = NULL;
42 + for (i = 1; i < buffycount; i++) {
43 + ary[i]->prev = ary[i-1];
45 + ary[0]->prev = NULL;
52 BUFFY *mutt_find_mailbox (const char *path)
58 static BUFFY *buffy_new (const char *path)
64 buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
65 strfcpy (buffy->path, path, sizeof (buffy->path));
66 + r = realpath(path, rp);
67 + strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath));
73 p = realpath (buf, f1);
74 for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
76 ! q = realpath ((*tmp)->path, f2);
77 ! if (mutt_strcmp (p ? p : buf, q ? q : (*tmp)->path) == 0)
79 dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
82 p = realpath (buf, f1);
83 for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
85 ! q = (*tmp)->realpath;
86 ! if (mutt_strcmp (p ? p : buf, q) == 0)
88 dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
96 + Incoming = buffy_sort(Incoming);
106 + if (option(OPTSIDEBAR) && mailbox->msg_unread > 0) {
111 if ((dirp = opendir (path)) == NULL)
121 + /* update message counts for the sidebar */
122 + void buffy_maildir_update (BUFFY* mailbox)
124 + char path[_POSIX_PATH_MAX];
129 + if(!option(OPTSIDEBAR))
132 + mailbox->msgcount = 0;
133 + mailbox->msg_unread = 0;
134 + mailbox->msg_flagged = 0;
136 + snprintf (path, sizeof (path), "%s/new", mailbox->path);
138 + if ((dirp = opendir (path)) == NULL)
140 + mailbox->magic = 0;
144 + while ((de = readdir (dirp)) != NULL)
146 + if (*de->d_name == '.')
149 + if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
151 + mailbox->msgcount++;
152 + mailbox->msg_unread++;
157 + snprintf (path, sizeof (path), "%s/cur", mailbox->path);
159 + if ((dirp = opendir (path)) == NULL)
161 + mailbox->magic = 0;
165 + while ((de = readdir (dirp)) != NULL)
167 + if (*de->d_name == '.')
170 + if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
171 + mailbox->msgcount++;
172 + if ((p = strstr (de->d_name, ":2,"))) {
173 + if (!strchr (p + 3, 'T')) {
174 + if (!strchr (p + 3, 'S'))
175 + mailbox->msg_unread++;
176 + if (strchr(p + 3, 'F'))
177 + mailbox->msg_flagged++;
183 + mailbox->sb_last_checked = time(NULL);
187 /* returns 1 if mailbox has new mail */
188 static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
193 statcheck = sb->st_mtime > sb->st_atime
194 || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime);
197 if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited)
201 statcheck = sb->st_mtime > sb->st_atime
202 || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime);
203 ! if ((!option(OPTSIDEBAR) && statcheck) || (option(OPTSIDEBAR) && mailbox->msg_unread > 0))
205 if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited)
213 + /* update message counts for the sidebar */
214 + void buffy_mbox_update (BUFFY* mailbox, struct stat *sb)
216 + CONTEXT *ctx = NULL;
218 + if(!option(OPTSIDEBAR))
220 + if(mailbox->sb_last_checked > sb->st_mtime && mailbox->msgcount != 0)
221 + return; /* no check necessary */
223 + ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
226 + mailbox->msgcount = ctx->msgcount;
227 + mailbox->msg_unread = ctx->unread;
228 + mailbox->msg_flagged = ctx->flagged;
229 + mailbox->sb_last_checked = time(NULL);
230 + mx_close_mailbox(ctx, 0);
234 int mutt_buffy_check (int force)
242 if (buffy_mbox_hasnew (tmp, &sb) > 0)
247 if (buffy_maildir_hasnew (tmp) > 0)
260 + buffy_mbox_update (tmp, &sb);
261 if (buffy_mbox_hasnew (tmp, &sb) > 0)
266 + buffy_maildir_update (tmp);
267 if (buffy_maildir_hasnew (tmp) > 0)
272 ! mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged, &tmp->sb_last_checked);
277 *** mutt-1.5.24-orig/buffy.h 2015-08-30 12:06:38.000000000 -0500
278 --- mutt-1.5.24/buffy.h 2015-09-16 23:18:13.000000000 -0500
282 typedef struct buffy_t
284 char path[_POSIX_PATH_MAX];
285 + char realpath[_POSIX_PATH_MAX];
287 struct buffy_t *next;
288 + struct buffy_t *prev;
289 short new; /* mailbox has new mail */
290 + int msgcount; /* total number of messages */
291 + int msg_unread; /* number of unread messages */
292 + int msg_flagged; /* number of flagged messages */
293 short notified; /* user has been notified */
294 short magic; /* mailbox type */
295 short newly_created; /* mbox or mmdf just popped into existence */
296 time_t last_visited; /* time of last exit from this mailbox */
297 + time_t sb_last_checked; /* time of last buffy check from sidebar */
301 *** mutt-1.5.24-orig/color.c 2015-08-30 12:06:38.000000000 -0500
302 --- mutt-1.5.24/color.c 2015-09-16 23:18:13.000000000 -0500
306 { "underline", MT_COLOR_UNDERLINE },
307 { "index", MT_COLOR_INDEX },
308 { "prompt", MT_COLOR_PROMPT },
309 + { "sidebar_new", MT_COLOR_NEW },
310 + { "sidebar_flagged", MT_COLOR_FLAGGED },
314 *** mutt-1.5.24-orig/compose.c 2015-08-30 12:06:38.000000000 -0500
315 --- mutt-1.5.24/compose.c 2015-09-16 23:18:13.000000000 -0500
319 #define HDR_XOFFSET 10
320 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
321 ! #define W (COLS - HDR_XOFFSET)
323 static const char * const Prompts[] =
327 #define HDR_XOFFSET 10
328 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
329 ! #define W (COLS - HDR_XOFFSET - SidebarWidth)
331 static const char * const Prompts[] =
336 static void redraw_crypt_lines (HEADER *msg)
338 ! mvaddstr (HDR_CRYPT, 0, "Security: ");
340 if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
344 static void redraw_crypt_lines (HEADER *msg)
346 ! mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
348 if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
352 addstr (_(" (OppEnc mode)"));
355 ! move (HDR_CRYPTINFO, 0);
358 if ((WithCrypto & APPLICATION_PGP)
360 addstr (_(" (OppEnc mode)"));
363 ! move (HDR_CRYPTINFO, SidebarWidth);
366 if ((WithCrypto & APPLICATION_PGP)
369 && (msg->security & ENCRYPT)
372 ! mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
373 NONULL(SmimeCryptAlg));
377 && (msg->security & ENCRYPT)
380 ! mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
381 NONULL(SmimeCryptAlg));
389 ! mvaddstr (HDR_MIX, 0, " Mix: ");
397 ! mvaddstr (HDR_MIX, SidebarWidth, " Mix: ");
403 if (t && t[0] == '0' && t[1] == '\0')
406 ! if (c + mutt_strlen (t) + 2 >= COLS)
411 if (t && t[0] == '0' && t[1] == '\0')
414 ! if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
422 rfc822_write_address (buf, sizeof (buf), addr, 1);
423 ! mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
424 mutt_paddstr (W, buf);
430 rfc822_write_address (buf, sizeof (buf), addr, 1);
431 ! mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
432 mutt_paddstr (W, buf);
437 draw_envelope_addr (HDR_TO, msg->env->to);
438 draw_envelope_addr (HDR_CC, msg->env->cc);
439 draw_envelope_addr (HDR_BCC, msg->env->bcc);
440 ! mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
441 mutt_paddstr (W, NONULL (msg->env->subject));
442 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
443 ! mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
444 mutt_paddstr (W, fcc);
448 draw_envelope_addr (HDR_TO, msg->env->to);
449 draw_envelope_addr (HDR_CC, msg->env->cc);
450 draw_envelope_addr (HDR_BCC, msg->env->bcc);
451 ! mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
452 mutt_paddstr (W, NONULL (msg->env->subject));
453 draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
454 ! mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
455 mutt_paddstr (W, fcc);
462 SETCOLOR (MT_COLOR_STATUS);
463 ! mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
470 SETCOLOR (MT_COLOR_STATUS);
471 ! mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
477 /* redraw the expanded list so the user can see the result */
479 rfc822_write_address (buf, sizeof (buf), *addr, 1);
480 ! move (line, HDR_XOFFSET);
481 mutt_paddstr (W, buf);
485 /* redraw the expanded list so the user can see the result */
487 rfc822_write_address (buf, sizeof (buf), *addr, 1);
488 ! move (line, HDR_XOFFSET+SidebarWidth);
489 mutt_paddstr (W, buf);
494 if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
496 mutt_str_replace (&msg->env->subject, buf);
497 ! move (HDR_SUBJECT, HDR_XOFFSET);
498 if (msg->env->subject)
499 mutt_paddstr (W, msg->env->subject);
502 if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
504 mutt_str_replace (&msg->env->subject, buf);
505 ! move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
506 if (msg->env->subject)
507 mutt_paddstr (W, msg->env->subject);
512 strfcpy (fcc, buf, fcclen);
513 mutt_pretty_mailbox (fcc, fcclen);
514 ! move (HDR_FCC, HDR_XOFFSET);
515 mutt_paddstr (W, fcc);
520 strfcpy (fcc, buf, fcclen);
521 mutt_pretty_mailbox (fcc, fcclen);
522 ! move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
523 mutt_paddstr (W, fcc);
526 *** mutt-1.5.24-orig/configure.ac 2015-08-30 12:24:20.000000000 -0500
527 --- mutt-1.5.24/configure.ac 2015-09-16 23:18:13.000000000 -0500
531 AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,[ Define if you have <langinfo.h> and nl_langinfo(YESEXPR). ])
534 + AC_CHECK_FUNCS(fmemopen open_memstream)
536 dnl Documentation tools
538 AC_PATH_PROG([OSPCAT], [ospcat], [none])
539 *** mutt-1.5.24-orig/curs_main.c 2015-08-30 12:06:38.000000000 -0500
540 --- mutt-1.5.24/curs_main.c 2015-09-16 23:18:13.000000000 -0500
549 + #include "sidebar.h"
555 menu->redraw |= REDRAW_STATUS;
558 ! if (mutt_buffy_notify () && option (OPTBEEPNEW))
568 if (menu->redraw & REDRAW_FULL)
570 menu_redraw_full (menu);
574 if (menu->menu == MENU_MAIN)
576 menu->redraw |= REDRAW_STATUS;
579 ! if (mutt_buffy_notify ())
581 ! menu->redraw |= REDRAW_STATUS;
582 ! if (option (OPTBEEPNEW))
590 + if(option(OPTSIDEBAR))
591 + menu->redraw |= REDRAW_SIDEBAR;
596 if (menu->redraw & REDRAW_FULL)
598 menu_redraw_full (menu);
599 + draw_sidebar(menu->menu);
601 + } else if(menu->redraw & REDRAW_SIDEBAR) {
602 + draw_sidebar(menu->menu);
603 + menu->redraw &= ~REDRAW_SIDEBAR;
606 if (menu->menu == MENU_MAIN)
611 if (menu->redraw & REDRAW_STATUS)
614 menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
616 move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
617 SETCOLOR (MT_COLOR_STATUS);
618 + set_buffystats(Context);
619 mutt_paddstr (COLS, buf);
621 menu->redraw &= ~REDRAW_STATUS;
624 menu->oldcurrent = -1;
626 if (option (OPTARROWCURSOR))
627 ! move (menu->current - menu->top + menu->offset, 2);
628 else if (option (OPTBRAILLEFRIENDLY))
629 move (menu->current - menu->top + menu->offset, 0);
632 menu->oldcurrent = -1;
634 if (option (OPTARROWCURSOR))
635 ! move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
636 else if (option (OPTBRAILLEFRIENDLY))
637 move (menu->current - menu->top + menu->offset, 0);
648 int oldvcount = Context->vcount;
652 menu->redraw = REDRAW_FULL;
655 + case OP_SIDEBAR_OPEN:
656 case OP_MAIN_CHANGE_FOLDER:
657 case OP_MAIN_NEXT_UNREAD_MAILBOX:
662 mutt_buffy (buf, sizeof (buf));
664 ! if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
666 if (menu->menu == MENU_PAGER)
670 mutt_buffy (buf, sizeof (buf));
672 ! if ( op == OP_SIDEBAR_OPEN ) {
675 ! strncpy( buf, CurBuffy->path, sizeof(buf) );
676 ! } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
678 if (menu->menu == MENU_PAGER)
685 mutt_expand_path (buf, sizeof (buf));
687 if (mx_get_magic (buf) <= 0)
689 mutt_error (_("%s is not a mailbox."), buf);
696 + case OP_SIDEBAR_SCROLL_UP:
697 + case OP_SIDEBAR_SCROLL_DOWN:
698 + case OP_SIDEBAR_NEXT:
699 + case OP_SIDEBAR_PREV:
700 + scroll_sidebar(op, menu->menu);
703 if (menu->menu == MENU_MAIN)
704 km_error_key (MENU_MAIN);
705 *** mutt-1.5.24-orig/flags.c 2015-08-30 12:06:38.000000000 -0500
706 --- mutt-1.5.24/flags.c 2015-09-16 23:18:13.000000000 -0500
712 #include "mutt_curses.h"
713 + #include "mutt_menu.h"
716 + #include "sidebar.h"
718 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
724 if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
729 void mutt_tag_set_flag (int flag, int bf)
730 *** mutt-1.5.24-orig/functions.h 2015-08-30 12:06:38.000000000 -0500
731 --- mutt-1.5.24/functions.h 2015-09-16 23:18:13.000000000 -0500
735 { "decrypt-save", OP_DECRYPT_SAVE, NULL },
738 + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
739 + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
740 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
741 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
742 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
750 { "what-key", OP_WHAT_KEY, NULL },
752 + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL },
753 + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
754 + { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
755 + { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
756 + { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
760 *** mutt-1.5.24-orig/globals.h 2015-08-30 12:06:38.000000000 -0500
761 --- mutt-1.5.24/globals.h 2015-09-16 23:18:13.000000000 -0500
765 WHERE char *SendCharset;
766 WHERE char *Sendmail;
768 + WHERE char *SidebarDelim;
769 + WHERE char *SidebarFormat;
770 + WHERE char *SidebarIndentStr;
771 WHERE char *Signature;
772 WHERE char *SimpleSearch;
777 WHERE short ScoreThresholdRead;
778 WHERE short ScoreThresholdFlag;
780 + WHERE struct buffy_t *CurBuffy INITVAL(0);
781 + WHERE short DrawFullLine INITVAL(0);
782 + WHERE short SidebarWidth;
784 WHERE short ImapKeepalive;
785 WHERE short ImapPipelineDepth;
786 *** mutt-1.5.24-orig/handler.c 2015-08-30 12:06:38.000000000 -0500
787 --- mutt-1.5.24/handler.c 2015-09-16 23:18:13.000000000 -0500
792 fseeko (s->fpin, b->offset, 0);
794 + #ifdef HAVE_FMEMOPEN
799 /* see if we need to decode this part before processing it */
800 if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE ||
801 b->encoding == ENCUUENCODED || plaintext ||
806 /* decode to a tempfile, saving the original destination */
808 + #ifdef HAVE_FMEMOPEN
809 + if ((s->fpout = open_memstream(&temp, &tempsize)) == NULL)
811 + mutt_error _("Unable to open memory stream!");
812 + dprint (1, (debugfile, "Can't open memory stream.\n"));
816 mutt_mktemp (tempfile, sizeof (tempfile));
817 if ((s->fpout = safe_fopen (tempfile, "w")) == NULL)
822 dprint (1, (debugfile, "Can't open %s.\n", tempfile));
826 /* decoding the attachment changes the size and offset, so save a copy
827 * of the "real" values now, and restore them after processing
831 /* restore final destination and substitute the tempfile for input */
834 s->fpin = fopen (tempfile, "r");
837 /* restore the prefix */
838 s->prefix = savePrefix;
841 /* restore final destination and substitute the tempfile for input */
844 + #ifdef HAVE_FMEMOPEN
846 + s->fpin = fmemopen(temp, tempsize, "r");
847 + else /* fmemopen cannot handle zero-length buffers */
848 + s->fpin = safe_fopen ("/dev/null", "r");
849 + if(s->fpin == NULL) {
850 + mutt_perror("failed to re-open memstream!");
854 s->fpin = fopen (tempfile, "r");
857 /* restore the prefix */
858 s->prefix = savePrefix;
864 /* restore the original source stream */
865 safe_fclose (&s->fpin);
866 + #ifdef HAVE_FMEMOPEN
873 *** mutt-1.5.24-orig/init.h 2015-08-30 12:06:38.000000000 -0500
874 --- mutt-1.5.24/init.h 2015-09-16 23:18:13.000000000 -0500
881 + {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, UL "|"},
884 + ** This specifies the delimiter between the sidebar (if visible) and
887 + {"sidebar_indentstr", DT_STR, R_BOTH, UL &SidebarIndentStr, UL " "},
890 + ** This specifies the string that is used to indent items
891 + ** with sidebar_folderindent= yes
893 + { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
896 + ** This specifies whether or not to show sidebar (left-side list of folders).
898 + { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
901 + ** This specifies whether or not to sort the sidebar alphabetically.
903 + { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
906 + ** The width of the sidebar.
908 + { "sidebar_shortpath", DT_BOOL, R_BOTH, OPTSIDEBARSHORTPATH, 0 },
911 + ** Should the sidebar shorten the path showed.
913 + {"sidebar_format", DT_STR, R_NONE, UL &SidebarFormat, UL "%B%?F? [%F]?%* %?N?%N/?%4S"},
916 + ** Format string for the sidebar. The sequences `%N', `%F' and `%S'
917 + ** will be replaced by the number of new or flagged messages or the total
918 + ** size of them mailbox. `%B' will be replaced with the name of the mailbox.
919 + ** The `%!' sequence will be expanded to `!' if there is one flagged message;
920 + ** to `!!' if there are two flagged messages; and to `n!' for n flagged
923 + { "sidebar_folderindent", DT_BOOL, R_BOTH, OPTSIDEBARFOLDERINDENT, 0 },
926 + ** Should folders be indented in the sidebar.
929 { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
932 *** mutt-1.5.24-orig/mailbox.h 2015-08-30 12:06:38.000000000 -0500
933 --- mutt-1.5.24/mailbox.h 2015-09-16 23:18:13.000000000 -0500
937 #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses
938 * safe_fopen() for mbox-style folders.
940 + #define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */
942 /* mx_open_new_message() */
943 #define M_ADD_FROM (1<<0) /* add a From_ line */
944 *** mutt-1.5.24-orig/main.c 2015-08-30 12:06:38.000000000 -0500
945 --- mutt-1.5.24/main.c 2015-09-16 23:18:13.000000000 -0500
951 #include <sys/stat.h>
952 + #include <limits.h>
953 #include <sys/utsname.h>
959 int main (int argc, char **argv)
961 ! char folder[_POSIX_PATH_MAX] = "";
962 char *subject = NULL;
963 char *includeFile = NULL;
964 char *draftFile = NULL;
967 int main (int argc, char **argv)
969 ! char folder[PATH_MAX] = "";
970 char *subject = NULL;
971 char *includeFile = NULL;
972 char *draftFile = NULL;
976 strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
977 mutt_expand_path (folder, sizeof (folder));
980 + char tmpfolder[PATH_MAX];
981 + strfcpy (tmpfolder, folder, sizeof (tmpfolder));
982 + if(!realpath(tmpfolder, folder))
983 + strfcpy (folder, tmpfolder, sizeof (tmpfolder));
986 mutt_str_replace (&CurrentFolder, folder);
987 mutt_str_replace (&LastFolder, folder);
992 if((Context = mx_open_mailbox (folder, ((flags & M_RO) || option (OPTREADONLY)) ? M_READONLY : 0, NULL))
995 + set_curbuffy(folder);
999 *** mutt-1.5.24-orig/Makefile.am 2015-08-30 12:06:38.000000000 -0500
1000 --- mutt-1.5.24/Makefile.am 2015-09-16 23:18:13.000000000 -0500
1004 rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \
1005 score.c send.c sendlib.c signal.c signature.c sort.c \
1006 status.c system.c thread.c charset.c history.c lib.c \
1008 muttlib.c editmsg.c mbyte.c \
1009 url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
1011 *** mutt-1.5.24-orig/mbox.c 2015-08-30 12:06:38.000000000 -0500
1012 --- mutt-1.5.24/mbox.c 2015-09-16 23:18:13.000000000 -0500
1016 mutt_perror (ctx->path);
1019 + ctx->atime = sb.st_atime;
1020 ctx->mtime = sb.st_mtime;
1021 ctx->size = sb.st_size;
1027 ctx->size = sb.st_size;
1028 ctx->mtime = sb.st_mtime;
1029 + ctx->atime = sb.st_atime;
1031 #ifdef NFS_ATTRIBUTE_HACK
1032 if (sb.st_mtime > sb.st_atime)
1033 *** mutt-1.5.24-orig/menu.c 2015-08-30 12:06:38.000000000 -0500
1034 --- mutt-1.5.24/menu.c 2015-09-16 23:18:13.000000000 -0500
1038 #include "mutt_curses.h"
1039 #include "mutt_menu.h"
1041 + #include "sidebar.h"
1043 extern size_t UngetCount;
1048 char *scratch = safe_strdup (s);
1049 int shift = option (OPTARROWCURSOR) ? 3 : 0;
1050 ! int cols = COLS - shift;
1052 mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
1056 char *scratch = safe_strdup (s);
1057 int shift = option (OPTARROWCURSOR) ? 3 : 0;
1058 ! int cols = COLS - shift - SidebarWidth;
1060 mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
1069 for (i = menu->top; i < menu->top + menu->pagelen; i++)
1074 menu_pad_string (buf, sizeof (buf));
1077 ! move(i - menu->top + menu->offset, 0);
1080 if (i == menu->current)
1082 menu_pad_string (buf, sizeof (buf));
1085 ! move(i - menu->top + menu->offset, SidebarWidth);
1088 if (i == menu->current)
1094 ! CLEARLINE(i - menu->top + menu->offset);
1102 ! CLEARLINE_WIN (i - menu->top + menu->offset);
1111 ! move (menu->oldcurrent + menu->offset - menu->top, 0);
1112 ATTRSET(menu->color (menu->oldcurrent));
1114 if (option (OPTARROWCURSOR))
1119 ! move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
1120 ATTRSET(menu->color (menu->oldcurrent));
1122 if (option (OPTARROWCURSOR))
1126 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
1127 menu_pad_string (buf, sizeof (buf));
1128 ! move (menu->oldcurrent + menu->offset - menu->top, 3);
1129 print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
1132 /* now draw it in the new location */
1133 SETCOLOR(MT_COLOR_INDICATOR);
1134 ! mvaddstr(menu->current + menu->offset - menu->top, 0, "->");
1140 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
1141 menu_pad_string (buf, sizeof (buf));
1142 ! move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
1143 print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
1146 /* now draw it in the new location */
1147 SETCOLOR(MT_COLOR_INDICATOR);
1148 ! mvaddstr(menu->current + menu->offset - menu->top, SidebarWidth, "->");
1154 menu_make_entry (buf, sizeof (buf), menu, menu->current);
1155 menu_pad_string (buf, sizeof (buf));
1156 SETCOLOR(MT_COLOR_INDICATOR);
1157 ! move(menu->current - menu->top + menu->offset, 0);
1158 print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
1160 menu->redraw &= REDRAW_STATUS;
1162 menu_make_entry (buf, sizeof (buf), menu, menu->current);
1163 menu_pad_string (buf, sizeof (buf));
1164 SETCOLOR(MT_COLOR_INDICATOR);
1165 ! move(menu->current - menu->top + menu->offset, SidebarWidth);
1166 print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
1168 menu->redraw &= REDRAW_STATUS;
1171 char buf[LONG_STRING];
1172 int attr = menu->color (menu->current);
1174 ! move (menu->current + menu->offset - menu->top, 0);
1175 menu_make_entry (buf, sizeof (buf), menu, menu->current);
1176 menu_pad_string (buf, sizeof (buf));
1179 char buf[LONG_STRING];
1180 int attr = menu->color (menu->current);
1182 ! move (menu->current + menu->offset - menu->top, SidebarWidth);
1183 menu_make_entry (buf, sizeof (buf), menu, menu->current);
1184 menu_pad_string (buf, sizeof (buf));
1190 if (option (OPTARROWCURSOR))
1191 ! move (menu->current - menu->top + menu->offset, 2);
1192 else if (option (OPTBRAILLEFRIENDLY))
1193 move (menu->current - menu->top + menu->offset, 0);
1198 if (option (OPTARROWCURSOR))
1199 ! move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
1200 else if (option (OPTBRAILLEFRIENDLY))
1201 move (menu->current - menu->top + menu->offset, 0);
1203 *** mutt-1.5.24-orig/mh.c 2015-08-30 12:06:38.000000000 -0500
1204 --- mutt-1.5.24/mh.c 2015-09-16 23:18:13.000000000 -0500
1208 mhs_free_sequences (&mhs);
1211 + void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged, time_t *sb_last_checked)
1214 + struct mh_sequences mhs;
1215 + memset (&mhs, 0, sizeof (mhs));
1217 + if(!option(OPTSIDEBAR))
1220 + if (mh_read_sequences (&mhs, path) < 0)
1226 + for (i = 0; i <= mhs.max; i++)
1228 + if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) {
1231 + if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED)
1233 + mhs_free_sequences (&mhs);
1234 + *sb_last_checked = time(NULL);
1237 static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
1240 *** mutt-1.5.24-orig/mutt_curses.h 2015-08-30 12:06:38.000000000 -0500
1241 --- mutt-1.5.24/mutt_curses.h 2015-09-16 23:18:13.000000000 -0500
1248 + #define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
1249 #define CLEARLINE(x) move(x,0), clrtoeol()
1250 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
1251 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
1263 *** mutt-1.5.24-orig/mutt_menu.h 2015-08-30 12:06:38.000000000 -0500
1264 --- mutt-1.5.24/mutt_menu.h 2015-09-16 23:18:13.000000000 -0500
1268 #define REDRAW_FULL (1<<5)
1269 #define REDRAW_BODY (1<<6)
1270 #define REDRAW_SIGWINCH (1<<7)
1271 + #define REDRAW_SIDEBAR (1<<8)
1273 #define M_MODEFMT "-- Mutt: %s"
1275 *** mutt-1.5.24-orig/mutt.h 2015-08-30 12:06:38.000000000 -0500
1276 --- mutt-1.5.24/mutt.h 2015-09-16 23:18:13.000000000 -0500
1284 + OPTSIDEBARSHORTPATH,
1286 + OPTSIDEBARFOLDERINDENT,
1303 unsigned int quiet : 1; /* inhibit status messages? */
1304 unsigned int collapsed : 1; /* are all threads collapsed? */
1305 unsigned int closing : 1; /* mailbox is being closed */
1306 + unsigned int peekonly : 1; /* just taking a glance, revert atime */
1309 void *data; /* driver specific data */
1310 *** mutt-1.5.24-orig/muttlib.c 2015-08-30 12:06:38.000000000 -0500
1311 --- mutt-1.5.24/muttlib.c 2015-09-16 23:18:13.000000000 -0500
1317 /* see if there's room to add content, else ignore */
1318 + if ( DrawFullLine )
1320 if ((col < COLS && wlen < destlen) || soft)
1332 + if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
1336 + /* get contents after padding */
1337 + mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
1338 + len = mutt_strlen (buf);
1339 + wid = mutt_strwidth (buf);
1341 + /* try to consume as many columns as we can, if we don't have
1342 + * memory for that, use as much memory as possible */
1343 + pad = (COLS - SidebarWidth - col - wid) / pw;
1344 + if (pad > 0 && wlen + (pad * pl) + len > destlen)
1345 + pad = ((signed)(destlen - wlen - len)) / pl;
1350 + memcpy (wptr, src, pl);
1356 + else if (soft && pad < 0)
1358 + /* \0-terminate dest for length computation in mutt_wstr_trunc() */
1360 + /* make sure right part is at most as wide as display */
1361 + len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
1362 + /* truncate left so that right part fits completely in */
1363 + wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
1364 + wptr = dest + wlen;
1366 + if (len + wlen > destlen)
1367 + len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
1368 + memcpy (wptr, buf, len);
1375 break; /* skip rest of input */
1378 *** mutt-1.5.24-orig/mx.c 2015-08-30 12:06:38.000000000 -0500
1379 --- mutt-1.5.24/mx.c 2015-09-16 23:18:13.000000000 -0500
1383 * M_APPEND open mailbox for appending
1384 * M_READONLY open mailbox in read-only mode
1385 * M_QUIET only print error messages
1386 + * M_PEEK revert atime where applicable
1387 * ctx if non-null, context struct to use
1389 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
1394 if (flags & M_READONLY)
1396 + if (flags & M_PEEK)
1397 + ctx->peekonly = 1;
1399 if (flags & (M_APPEND|M_NEWFOLDER))
1403 void mx_fastclose_mailbox (CONTEXT *ctx)
1410 /* never announce that a mailbox we've just left has new mail. #3290
1411 * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
1412 ! mutt_buffy_setnotified(ctx->path);
1415 ctx->mx_close (ctx);
1417 void mx_fastclose_mailbox (CONTEXT *ctx)
1420 + #ifndef BUFFY_SIZE
1421 + struct utimbuf ut;
1426 + #ifndef BUFFY_SIZE
1427 + /* fix up the times so buffy won't get confused */
1428 + if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
1430 + ut.actime = ctx->atime;
1431 + ut.modtime = ctx->mtime;
1432 + utime (ctx->path, &ut);
1436 /* never announce that a mailbox we've just left has new mail. #3290
1437 * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
1438 ! if(!ctx->peekonly)
1439 ! mutt_buffy_setnotified(ctx->path);
1442 ctx->mx_close (ctx);
1446 mutt_clear_threads (ctx);
1447 for (i = 0; i < ctx->msgcount; i++)
1448 mutt_free_header (&ctx->hdrs[i]);
1449 + ctx->msgcount -= ctx->deleted;
1450 + set_buffystats(ctx);
1457 if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read
1458 && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
1460 + if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read)
1462 + if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->flagged)
1466 if (read_msgs && quadoption (OPT_MOVE) != M_NO)
1467 *** mutt-1.5.24-orig/mx.h 2015-08-30 12:06:38.000000000 -0500
1468 --- mutt-1.5.24/mx.h 2015-09-16 23:18:13.000000000 -0500
1472 int mh_read_dir (CONTEXT *, const char *);
1473 int mh_sync_mailbox (CONTEXT *, int *);
1474 int mh_check_mailbox (CONTEXT *, int *);
1475 + void mh_buffy_update (const char *, int *, int *, int *, time_t *);
1476 int mh_check_empty (const char *);
1478 int maildir_read_dir (CONTEXT *);
1479 *** mutt-1.5.24-orig/OPS 2015-08-30 12:06:38.000000000 -0500
1480 --- mutt-1.5.24/OPS 2015-09-16 23:18:13.000000000 -0500
1484 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
1485 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
1486 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
1487 + OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
1488 + OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
1489 + OP_SIDEBAR_NEXT "go down to next mailbox"
1490 + OP_SIDEBAR_PREV "go to previous mailbox"
1491 + OP_SIDEBAR_OPEN "open hilighted mailbox"
1492 *** mutt-1.5.24-orig/pager.c 2015-08-30 12:06:38.000000000 -0500
1493 --- mutt-1.5.24/pager.c 2015-09-16 23:18:13.000000000 -0500
1500 + #include "sidebar.h"
1502 #include "mutt_crypt.h"
1509 int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
1510 + wrap_cols -= SidebarWidth;
1512 if (check_attachment_marker ((char *)buf) == 0)
1518 int bodyoffset = 1; /* offset of first line of real text */
1519 int statusoffset = 0; /* offset for the status bar */
1521 int helpoffset = LINES - 2; /* offset for the help bar. */
1522 int bodylen = LINES - 2 - bodyoffset; /* length of displayable area */
1526 if ((redraw & REDRAW_BODY) || topline != oldtopline)
1529 ! move (bodyoffset, 0);
1530 curline = oldtopline = topline;
1534 if ((redraw & REDRAW_BODY) || topline != oldtopline)
1537 ! move (bodyoffset, SidebarWidth);
1538 curline = oldtopline = topline;
1544 &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
1547 + move(lines + bodyoffset, SidebarWidth);
1549 last_offset = lineInfo[curline].offset;
1550 } while (force_redraw);
1557 + move(lines + bodyoffset, SidebarWidth);
1564 hfi.pager_progress = pager_progress_str;
1566 if (last_pos < sb.st_size - 1)
1567 snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * last_offset / sb.st_size));
1569 strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str));
1571 /* print out the pager status bar */
1572 ! move (statusoffset, 0);
1573 SETCOLOR (MT_COLOR_STATUS);
1575 if (IsHeader (extra) || IsMsgAttach (extra))
1577 ! size_t l1 = COLS * MB_LEN_MAX;
1578 size_t l2 = sizeof (buffer);
1579 hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
1580 mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
1581 ! mutt_paddstr (COLS, buffer);
1586 snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
1587 ! mutt_paddstr (COLS, bn);
1590 if (option(OPTTSENABLED) && TSSupported)
1594 hfi.pager_progress = pager_progress_str;
1596 + statuswidth = COLS - (option(OPTSTATUSONTOP) && PagerIndexLines > 0 ? SidebarWidth : 0);
1598 if (last_pos < sb.st_size - 1)
1599 snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * last_offset / sb.st_size));
1601 strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str));
1603 /* print out the pager status bar */
1604 ! move (statusoffset, SidebarWidth);
1605 SETCOLOR (MT_COLOR_STATUS);
1606 + if(option(OPTSTATUSONTOP) && PagerIndexLines > 0) {
1607 + CLEARLINE_WIN (statusoffset);
1609 + CLEARLINE (statusoffset);
1610 + DrawFullLine = 1; /* for mutt_make_string_info */
1613 if (IsHeader (extra) || IsMsgAttach (extra))
1615 ! size_t l1 = statuswidth * MB_LEN_MAX;
1616 size_t l2 = sizeof (buffer);
1617 hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
1618 mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
1619 ! mutt_paddstr (statuswidth, buffer);
1624 snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
1625 ! mutt_paddstr (statuswidth, bn);
1627 + if(!option(OPTSTATUSONTOP) || PagerIndexLines == 0)
1628 + DrawFullLine = 0; /* reset */
1630 if (option(OPTTSENABLED) && TSSupported)
1634 /* redraw the pager_index indicator, because the
1635 * flags for this message might have changed. */
1636 menu_redraw_current (index);
1638 /* print out the index status bar */
1639 menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
1641 ! move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
1642 SETCOLOR (MT_COLOR_STATUS);
1643 ! mutt_paddstr (COLS, buffer);
1649 if (option(OPTBRAILLEFRIENDLY)) {
1651 /* redraw the pager_index indicator, because the
1652 * flags for this message might have changed. */
1653 menu_redraw_current (index);
1654 + draw_sidebar(MENU_PAGER);
1656 /* print out the index status bar */
1657 menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
1659 ! move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),
1660 ! (option(OPTSTATUSONTOP) ? 0: SidebarWidth));
1661 SETCOLOR (MT_COLOR_STATUS);
1662 ! mutt_paddstr (COLS - (option(OPTSTATUSONTOP) ? 0 : SidebarWidth), buffer);
1666 + /* if we're not using the index, update every time */
1668 + draw_sidebar(MENU_PAGER);
1672 if (option(OPTBRAILLEFRIENDLY)) {
1679 + case OP_SIDEBAR_SCROLL_UP:
1680 + case OP_SIDEBAR_SCROLL_DOWN:
1681 + case OP_SIDEBAR_NEXT:
1682 + case OP_SIDEBAR_PREV:
1683 + scroll_sidebar(ch, MENU_PAGER);
1689 *** mutt-1.5.24-orig/pattern.c 2015-08-30 12:06:38.000000000 -0500
1690 --- mutt-1.5.24/pattern.c 2015-09-16 23:18:13.000000000 -0500
1694 HEADER *h = ctx->hdrs[msgno];
1697 + #ifdef HAVE_FMEMOPEN
1702 if ((msg = mx_open_message (ctx, msgno)) != NULL)
1707 memset (&s, 0, sizeof (s));
1709 s.flags = M_CHARCONV;
1710 + #ifdef HAVE_FMEMOPEN
1711 + if((s.fpout = open_memstream(&temp, &tempsize)) == NULL)
1713 + mutt_perror ("Error opening memstream");
1717 mutt_mktemp (tempfile, sizeof (tempfile));
1718 if ((s.fpout = safe_fopen (tempfile, "w+")) == NULL)
1720 mutt_perror (tempfile);
1725 if (pat->op != M_BODY)
1726 mutt_copy_header (msg->fp, h, s.fpout, CH_FROM | CH_DECODE, NULL);
1732 safe_fclose (&s.fpout);
1733 + #ifdef HAVE_FMEMOPEN
1744 mutt_body_handler (h->content, &s);
1747 + #ifdef HAVE_FMEMOPEN
1752 + if ((fp = fmemopen(temp, tempsize, "r")) == NULL) {
1753 + mutt_perror ("Error re-opening memstream");
1756 + } else { /* fmemopen cannot handle empty buffers */
1757 + if ((fp = safe_fopen ("/dev/null", "r")) == NULL) {
1758 + mutt_perror ("Error opening /dev/null");
1766 fstat (fileno (fp), &st);
1767 lng = (long) st.st_size;
1775 if (option (OPTTHOROUGHSRC))
1778 + #ifdef HAVE_FMEMOPEN
1787 *** mutt-1.5.24-orig/PATCHES 2015-08-30 12:06:38.000000000 -0500
1788 --- mutt-1.5.24/PATCHES 2015-11-11 09:39:02.000000000 -0600
1792 + patch-1.5.24.sidebar.20151111.txt
1793 *** mutt-1.5.24-orig/protos.h 2015-08-30 12:06:38.000000000 -0500
1794 --- mutt-1.5.24/protos.h 2015-09-16 23:18:13.000000000 -0500
1798 const char *pager_progress;
1801 + struct sidebar_entry {
1802 + char box[SHORT_STRING];
1803 + unsigned int size;
1805 + unsigned int flagged;
1808 void mutt_make_string_info (char *, size_t, const char *, struct hdr_format_info *, format_flag);
1810 int mutt_extract_token (BUFFER *, BUFFER *, int);
1811 *** mutt-1.5.24-orig/sidebar.c 1969-12-31 18:00:00.000000000 -0600
1812 --- mutt-1.5.24/sidebar.c 2015-11-11 09:38:45.000000000 -0600
1817 + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1818 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1820 + * This program is free software; you can redistribute it and/or modify
1821 + * it under the terms of the GNU General Public License as published by
1822 + * the Free Software Foundation; either version 2 of the License, or
1823 + * (at your option) any later version.
1825 + * This program is distributed in the hope that it will be useful,
1826 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1827 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1828 + * GNU General Public License for more details.
1830 + * You should have received a copy of the GNU General Public License
1831 + * along with this program; if not, write to the Free Software
1832 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
1837 + # include "config.h"
1841 + #include "mutt_menu.h"
1842 + #include "mutt_curses.h"
1843 + #include "sidebar.h"
1844 + #include "buffy.h"
1845 + #include <libgen.h>
1846 + #include "keymap.h"
1847 + #include <stdbool.h>
1849 + /*BUFFY *CurBuffy = 0;*/
1850 + static BUFFY *TopBuffy = 0;
1851 + static BUFFY *BottomBuffy = 0;
1852 + static int known_lines = 0;
1854 + void calc_boundaries() {
1856 + BUFFY *tmp = Incoming;
1858 + int count = LINES - 2 - (option(OPTHELP) ? 1 : 0);
1860 + if ( known_lines != LINES ) {
1861 + TopBuffy = BottomBuffy = 0;
1862 + known_lines = LINES;
1864 + for ( ; tmp->next != 0; tmp = tmp->next )
1865 + tmp->next->prev = tmp;
1867 + if ( TopBuffy == 0 && BottomBuffy == 0 )
1868 + TopBuffy = Incoming;
1869 + if ( BottomBuffy == 0 ) {
1870 + BottomBuffy = TopBuffy;
1871 + while ( --count && BottomBuffy->next )
1872 + BottomBuffy = BottomBuffy->next;
1874 + else if ( TopBuffy == CurBuffy->next ) {
1875 + BottomBuffy = CurBuffy;
1876 + tmp = BottomBuffy;
1877 + while ( --count && tmp->prev)
1881 + else if ( BottomBuffy == CurBuffy->prev ) {
1882 + TopBuffy = CurBuffy;
1884 + while ( --count && tmp->next )
1886 + BottomBuffy = tmp;
1890 + static const char *
1891 + sidebar_format_str (char *dest,
1896 + const char *prefix,
1897 + const char *ifstring,
1898 + const char *elsestring,
1899 + unsigned long data,
1900 + format_flag flags)
1902 + /* casting from unsigned long - srsly?! */
1903 + struct sidebar_entry *sbe = (struct sidebar_entry *) data;
1904 + unsigned int optional;
1905 + char fmt[SHORT_STRING], buf[SHORT_STRING];
1907 + optional = flags & M_FORMAT_OPTIONAL;
1912 + snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
1913 + snprintf (dest, destlen, fmt, sbe->flagged);
1914 + } else if(sbe->flagged == 0) {
1920 + if(sbe->flagged == 0)
1921 + mutt_format_s(dest, destlen, prefix, "");
1922 + if(sbe->flagged == 1)
1923 + mutt_format_s(dest, destlen, prefix, "!");
1924 + if(sbe->flagged == 2)
1925 + mutt_format_s(dest, destlen, prefix, "!!");
1926 + if(sbe->flagged > 2) {
1927 + snprintf (buf, sizeof (buf), "%d!", sbe->flagged);
1928 + mutt_format_s(dest, destlen, prefix, buf);
1934 + snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
1935 + snprintf (dest, destlen, fmt, sbe->size);
1936 + } else if (sbe->size == 0) {
1943 + snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
1944 + snprintf (dest, destlen, fmt, sbe->new);
1945 + } else if(sbe->new == 0) {
1951 + mutt_format_s(dest, destlen, prefix, sbe->box);
1956 + mutt_FormatString (dest, destlen, col, ifstring, sidebar_format_str, (unsigned long) sbe, flags);
1957 + else if (flags & M_FORMAT_OPTIONAL)
1958 + mutt_FormatString (dest, destlen, col, elsestring, sidebar_format_str, (unsigned long) sbe, flags);
1963 + char *make_sidebar_entry(char *box, unsigned int size, unsigned int new, unsigned int flagged) {
1964 + static char *entry = 0;
1965 + struct sidebar_entry sbe;
1968 + SBvisual = SidebarWidth - strlen(SidebarDelim);
1973 + sbe.flagged = flagged;
1975 + strncpy(sbe.box, box, 31);
1977 + safe_realloc(&entry, SBvisual + 2);
1978 + entry[SBvisual + 1] = '\0';
1980 + mutt_FormatString (entry, SBvisual+1, 0, SidebarFormat, sidebar_format_str, (unsigned long) &sbe, 0);
1985 + void set_curbuffy(char buf[LONG_STRING])
1987 + BUFFY* tmp = CurBuffy = Incoming;
1993 + if(!strcmp(tmp->path, buf) || !strcmp(tmp->realpath, buf)) {
2005 + int draw_sidebar(int menu) {
2008 + #ifndef USE_SLANG_CURSES
2011 + short delim_len = strlen(SidebarDelim);
2014 + static bool initialized = false;
2015 + static int prev_show_value;
2016 + static short saveSidebarWidth;
2018 + int SidebarHeight;
2020 + if(option(OPTSTATUSONTOP) || option(OPTHELP))
2021 + lines++; /* either one will occupy the first line */
2023 + /* initialize first time */
2024 + if(!initialized) {
2025 + prev_show_value = option(OPTSIDEBAR);
2026 + saveSidebarWidth = SidebarWidth;
2027 + if(!option(OPTSIDEBAR)) SidebarWidth = 0;
2028 + initialized = true;
2031 + /* save or restore the value SidebarWidth */
2032 + if(prev_show_value != option(OPTSIDEBAR)) {
2033 + if(prev_show_value && !option(OPTSIDEBAR)) {
2034 + saveSidebarWidth = SidebarWidth;
2036 + } else if(!prev_show_value && option(OPTSIDEBAR)) {
2037 + mutt_buffy_check(1); /* we probably have bad or no numbers */
2038 + SidebarWidth = saveSidebarWidth;
2040 + prev_show_value = option(OPTSIDEBAR);
2044 + /* if ( SidebarWidth == 0 ) return 0; */
2045 + if (SidebarWidth > 0 && option (OPTSIDEBAR)
2046 + && delim_len >= SidebarWidth) {
2047 + unset_option (OPTSIDEBAR);
2048 + /* saveSidebarWidth = SidebarWidth; */
2049 + if (saveSidebarWidth > delim_len) {
2050 + SidebarWidth = saveSidebarWidth;
2051 + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
2055 + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
2056 + sleep (4); /* the advise to set a sane value should be seen long enough */
2058 + saveSidebarWidth = 0;
2062 + if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
2063 + if (SidebarWidth > 0) {
2064 + saveSidebarWidth = SidebarWidth;
2067 + unset_option(OPTSIDEBAR);
2071 + /* get attributes for divider */
2072 + SETCOLOR(MT_COLOR_STATUS);
2073 + #ifndef USE_SLANG_CURSES
2074 + attr_get(&attrs, &color_pair, 0);
2076 + color_pair = attr_get();
2078 + SETCOLOR(MT_COLOR_NORMAL);
2080 + /* draw the divider */
2082 + SidebarHeight = LINES - 1;
2083 + if(option(OPTHELP) || !option(OPTSTATUSONTOP))
2086 + for ( ; lines < SidebarHeight; lines++ ) {
2087 + move(lines, SidebarWidth - delim_len);
2088 + addstr(NONULL(SidebarDelim));
2089 + #ifndef USE_SLANG_CURSES
2090 + mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
2094 + if ( Incoming == 0 ) return 0;
2096 + if(option(OPTSTATUSONTOP) || option(OPTHELP))
2097 + lines++; /* either one will occupy the first line */
2099 + if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 )
2100 + calc_boundaries(menu);
2101 + if ( CurBuffy == 0 ) CurBuffy = Incoming;
2105 + SETCOLOR(MT_COLOR_NORMAL);
2107 + for ( ; tmp && lines < SidebarHeight; tmp = tmp->next ) {
2108 + if ( tmp == CurBuffy )
2109 + SETCOLOR(MT_COLOR_INDICATOR);
2110 + else if ( tmp->msg_unread > 0 )
2111 + SETCOLOR(MT_COLOR_NEW);
2112 + else if ( tmp->msg_flagged > 0 )
2113 + SETCOLOR(MT_COLOR_FLAGGED);
2115 + SETCOLOR(MT_COLOR_NORMAL);
2118 + if ( Context && Context->path &&
2119 + (!strcmp(tmp->path, Context->path)||
2120 + !strcmp(tmp->realpath, Context->path)) ) {
2121 + tmp->msg_unread = Context->unread;
2122 + tmp->msgcount = Context->msgcount;
2123 + tmp->msg_flagged = Context->flagged;
2125 + /* check whether Maildir is a prefix of the current folder's path */
2126 + short maildir_is_prefix = 0;
2127 + if ( (strlen(tmp->path) > strlen(Maildir)) &&
2128 + (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
2129 + maildir_is_prefix = 1;
2130 + /* calculate depth of current folder and generate its display name with indented spaces */
2131 + int sidebar_folder_depth = 0;
2132 + char *sidebar_folder_name;
2133 + sidebar_folder_name = option(OPTSIDEBARSHORTPATH) ? mutt_basename(tmp->path) : tmp->path + maildir_is_prefix*(strlen(Maildir) + ((Maildir[strlen(Maildir) - 1] == '/' || Maildir[strlen(Maildir) - 1] == '}') ? 0 : 1));
2134 + if ( maildir_is_prefix && option(OPTSIDEBARFOLDERINDENT) ) {
2135 + char *tmp_folder_name;
2137 + tmp_folder_name = tmp->path + strlen(Maildir) + 1;
2138 + for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
2139 + if (tmp_folder_name[i] == '/' || tmp_folder_name[i] == '.') sidebar_folder_depth++;
2141 + if (sidebar_folder_depth > 0) {
2142 + if (option(OPTSIDEBARSHORTPATH)) {
2143 + tmp_folder_name = strrchr(tmp->path, '.');
2144 + if (tmp_folder_name == NULL)
2145 + tmp_folder_name = mutt_basename(tmp->path);
2147 + tmp_folder_name++;
2150 + tmp_folder_name = tmp->path + strlen(Maildir) + 1;
2151 + sidebar_folder_name = malloc(strlen(tmp_folder_name) + sidebar_folder_depth*strlen(NONULL(SidebarIndentStr)) + 1);
2152 + sidebar_folder_name[0]=0;
2153 + for (i=0; i < sidebar_folder_depth; i++)
2154 + strncat(sidebar_folder_name, NONULL(SidebarIndentStr), strlen(NONULL(SidebarIndentStr)));
2155 + strncat(sidebar_folder_name, tmp_folder_name, strlen(tmp_folder_name));
2158 + printw( "%.*s", SidebarWidth - delim_len + 1,
2159 + make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
2160 + tmp->msg_unread, tmp->msg_flagged));
2161 + if (sidebar_folder_depth > 0)
2162 + free(sidebar_folder_name);
2165 + SETCOLOR(MT_COLOR_NORMAL);
2166 + for ( ; lines < SidebarHeight; lines++ ) {
2169 + for ( ; i < SidebarWidth - delim_len; i++ )
2176 + void set_buffystats(CONTEXT* Context)
2178 + BUFFY *tmp = Incoming;
2180 + if(Context && (!strcmp(tmp->path, Context->path) ||
2181 + !strcmp(tmp->realpath, Context->path))) {
2182 + tmp->msg_unread = Context->unread;
2183 + tmp->msgcount = Context->msgcount;
2184 + tmp->msg_flagged = Context->flagged;
2191 + void scroll_sidebar(int op, int menu)
2193 + if(!SidebarWidth) return;
2194 + if(!CurBuffy) return;
2197 + case OP_SIDEBAR_NEXT:
2198 + if ( CurBuffy->next == NULL ) return;
2199 + CurBuffy = CurBuffy->next;
2201 + case OP_SIDEBAR_PREV:
2202 + if ( CurBuffy->prev == NULL ) return;
2203 + CurBuffy = CurBuffy->prev;
2205 + case OP_SIDEBAR_SCROLL_UP:
2206 + CurBuffy = TopBuffy;
2207 + if ( CurBuffy != Incoming ) {
2208 + calc_boundaries(menu);
2209 + CurBuffy = CurBuffy->prev;
2212 + case OP_SIDEBAR_SCROLL_DOWN:
2213 + CurBuffy = BottomBuffy;
2214 + if ( CurBuffy->next ) {
2215 + calc_boundaries(menu);
2216 + CurBuffy = CurBuffy->next;
2222 + calc_boundaries(menu);
2223 + draw_sidebar(menu);
2226 *** mutt-1.5.24-orig/sidebar.h 1969-12-31 18:00:00.000000000 -0600
2227 --- mutt-1.5.24/sidebar.h 2015-09-16 23:18:13.000000000 -0500
2232 + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
2233 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
2235 + * This program is free software; you can redistribute it and/or modify
2236 + * it under the terms of the GNU General Public License as published by
2237 + * the Free Software Foundation; either version 2 of the License, or
2238 + * (at your option) any later version.
2240 + * This program is distributed in the hope that it will be useful,
2241 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2242 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2243 + * GNU General Public License for more details.
2245 + * You should have received a copy of the GNU General Public License
2246 + * along with this program; if not, write to the Free Software
2247 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
2253 + struct MBOX_LIST {
2259 + /* parameter is whether or not to go to the status line */
2260 + /* used for omitting the last | that covers up the status bar in the index */
2261 + int draw_sidebar(int);
2262 + void scroll_sidebar(int, int);
2263 + void set_curbuffy(char*);
2264 + void set_buffystats(CONTEXT*);
2266 + #endif /* SIDEBAR_H */
2267 *** mutt-1.5.24-orig/doc/Muttrc 2015-08-30 12:24:53.000000000 -0500
2268 --- mutt-1.5.24/doc/Muttrc 2015-09-16 23:18:13.000000000 -0500
2272 # $crypt_autosign, $crypt_replysign and $smime_is_default.
2275 + # set sidebar_visible=no
2277 + # Name: sidebar_visible
2282 + # This specifies whether or not to show sidebar (left-side list of folders).
2285 + # set sidebar_width=0
2287 + # Name: sidebar_width
2292 + # The width of the sidebar.
2295 # set crypt_autosign=no
2297 # Name: crypt_autosign
2298 *** mutt-1.5.24-orig/imap/imap.c 2015-08-30 12:06:38.000000000 -0500
2299 --- mutt-1.5.24/imap/imap.c 2015-09-16 23:18:13.000000000 -0500
2303 imap_munge_mbox_name (munged, sizeof (munged), name);
2304 snprintf (command, sizeof (command),
2305 ! "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
2307 if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
2311 imap_munge_mbox_name (munged, sizeof (munged), name);
2312 snprintf (command, sizeof (command),
2313 ! "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
2315 if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
2317 *** mutt-1.5.24-orig/imap/command.c 2015-08-30 12:06:38.000000000 -0500
2318 --- mutt-1.5.24/imap/command.c 2015-09-16 23:18:13.000000000 -0500
2323 status->uidnext = oldun;
2325 + /* Added to make the sidebar show the correct numbers */
2326 + if (status->messages)
2328 + inc->msgcount = status->messages;
2329 + inc->msg_unread = status->unseen;