NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c
Go to the documentation of this file.
1
30#include "config.h"
31#ifdef _MAKEDOC
32#include "docs/makedoc_defs.h"
33#else
34#include <stdbool.h>
35#include <stdio.h>
36#include <string.h>
37#include <sys/stat.h>
38#include "mutt/lib.h"
39#include "config/lib.h"
40#include "email/lib.h"
41#include "core/lib.h"
42#include "gui/lib.h"
43#include "mutt.h"
44#include "lib.h"
45#include "attach/lib.h"
46#include "editor/lib.h"
47#include "history/lib.h"
48#include "imap/lib.h"
49#include "key/lib.h"
50#include "menu/lib.h"
51#include "nntp/lib.h"
52#include "pattern/lib.h"
53#include "question/lib.h"
54#include "send/lib.h"
55#include "functions.h"
56#include "globals.h"
57#include "mutt_mailbox.h"
58#include "muttlib.h"
59#include "mx.h"
60#include "nntp/adata.h"
61#include "nntp/mdata.h"
62#include "private_data.h"
63#endif
64
65static int op_subscribe_pattern(struct BrowserPrivateData *priv, int op);
66
67// clang-format off
71const struct MenuFuncOp OpBrowser[] = { /* map: browser */
72 { "catchup", OP_CATCHUP },
73 { "change-dir", OP_CHANGE_DIRECTORY },
74 { "check-new", OP_CHECK_NEW },
75 { "create-mailbox", OP_CREATE_MAILBOX },
76 { "delete-mailbox", OP_DELETE_MAILBOX },
77 { "descend-directory", OP_DESCEND_DIRECTORY },
78 { "display-filename", OP_BROWSER_TELL },
79 { "enter-mask", OP_ENTER_MASK },
80 { "exit", OP_EXIT },
81 { "goto-folder", OP_BROWSER_GOTO_FOLDER },
82 { "goto-parent", OP_GOTO_PARENT },
83 { "mailbox-list", OP_MAILBOX_LIST },
84 { "reload-active", OP_LOAD_ACTIVE },
85 { "rename-mailbox", OP_RENAME_MAILBOX },
86 { "select-new", OP_BROWSER_NEW_FILE },
87 { "sort", OP_SORT },
88 { "sort-reverse", OP_SORT_REVERSE },
89 { "subscribe", OP_BROWSER_SUBSCRIBE },
90 { "subscribe-pattern", OP_SUBSCRIBE_PATTERN },
91 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES },
92 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB },
93 { "uncatchup", OP_UNCATCHUP },
94 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE },
95 { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN },
96 { "view-file", OP_BROWSER_VIEW_FILE },
97 // Deprecated
98 { "buffy-list", OP_MAILBOX_LIST },
99 { NULL, 0 },
100};
101
105const struct MenuOpSeq BrowserDefaultBindings[] = { /* map: browser */
106 { OP_BROWSER_GOTO_FOLDER, "=" },
107 { OP_BROWSER_NEW_FILE, "N" },
108 { OP_BROWSER_SUBSCRIBE, "s" },
109 { OP_BROWSER_TELL, "@" },
110 { OP_BROWSER_TOGGLE_LSUB, "T" },
111 { OP_BROWSER_UNSUBSCRIBE, "u" },
112 { OP_BROWSER_VIEW_FILE, " " }, // <Space>
113 { OP_CHANGE_DIRECTORY, "c" },
114 { OP_CREATE_MAILBOX, "C" },
115 { OP_DELETE_MAILBOX, "d" },
116 { OP_ENTER_MASK, "m" },
117 { OP_EXIT, "q" },
118 { OP_GOTO_PARENT, "p" },
119 { OP_MAILBOX_LIST, "." },
120 { OP_RENAME_MAILBOX, "r" },
121 { OP_SORT, "o" },
122 { OP_SORT_REVERSE, "O" },
123 { OP_TOGGLE_MAILBOXES, "\t" }, // <Tab>
124 { 0, NULL },
125};
126// clang-format on
127
134void destroy_state(struct BrowserState *state)
135{
136 struct FolderFile *ff = NULL;
137 ARRAY_FOREACH(ff, &state->entry)
138 {
139 FREE(&ff->name);
140 FREE(&ff->desc);
141 }
142 ARRAY_FREE(&state->entry);
143 FREE(&state->folder);
144}
145
146// -----------------------------------------------------------------------------
147
151static int op_browser_new_file(struct BrowserPrivateData *priv, int op)
152{
153 struct Buffer *buf = buf_pool_get();
154 buf_printf(buf, "%s/", buf_string(&LastDir));
155
156 struct FileCompletionData cdata = { false, priv->mailbox, NULL, NULL };
157 const int rc = mw_get_field(_("New file name: "), buf, MUTT_COMP_NO_FLAGS,
158 HC_FILE, &CompleteMailboxOps, &cdata);
159 if (rc != 0)
160 {
161 buf_pool_release(&buf);
162 return FR_NO_ACTION;
163 }
164
165 buf_copy(priv->file, buf);
166 buf_pool_release(&buf);
167 priv->done = true;
168 return FR_DONE;
169}
170
178static int op_browser_subscribe(struct BrowserPrivateData *priv, int op)
179{
180 if (OptNews)
181 {
183 int index = menu_get_index(priv->menu);
184
185 if (ARRAY_EMPTY(&priv->state.entry))
186 {
187 mutt_error(_("No newsgroups match the mask"));
188 return FR_ERROR;
189 }
190
191 int rc = nntp_newsrc_parse(adata);
192 if (rc < 0)
193 return FR_ERROR;
194
195 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
196 if (op == OP_BROWSER_SUBSCRIBE)
197 mutt_newsgroup_subscribe(adata, ff->name);
198 else
200
201 menu_set_index(priv->menu, index + 1);
202
203 if (rc > 0)
205 nntp_newsrc_update(adata);
206 nntp_clear_cache(adata);
207 nntp_newsrc_close(adata);
208 }
209 else
210 {
211 if (ARRAY_EMPTY(&priv->state.entry))
212 {
213 mutt_error(_("There are no mailboxes"));
214 return FR_ERROR;
215 }
216
217 struct Buffer *buf = buf_pool_get();
218 int index = menu_get_index(priv->menu);
219 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
220 buf_strcpy(buf, ff->name);
221 buf_expand_path(buf);
222 imap_subscribe(buf_string(buf), (op == OP_BROWSER_SUBSCRIBE));
223 buf_pool_release(&buf);
224 }
225 return FR_SUCCESS;
226}
227
231static int op_browser_tell(struct BrowserPrivateData *priv, int op)
232{
233 int index = menu_get_index(priv->menu);
234 if (ARRAY_EMPTY(&priv->state.entry))
235 return FR_ERROR;
236
237 mutt_message("%s", ARRAY_GET(&priv->state.entry, index)->name);
238 return FR_SUCCESS;
239}
240
244static int op_browser_toggle_lsub(struct BrowserPrivateData *priv, int op)
245{
246 bool_str_toggle(NeoMutt->sub, "imap_list_subscribed", NULL);
247
248 mutt_unget_op(OP_CHECK_NEW);
249 return FR_SUCCESS;
250}
251
255static int op_browser_view_file(struct BrowserPrivateData *priv, int op)
256{
257 if (ARRAY_EMPTY(&priv->state.entry))
258 {
259 mutt_error(_("No files match the file mask"));
260 return FR_ERROR;
261 }
262
263 int index = menu_get_index(priv->menu);
264 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
265 if (ff->selectable)
266 {
267 buf_strcpy(priv->file, ff->name);
268 priv->done = true;
269 return FR_DONE;
270 }
271 else if (S_ISDIR(ff->mode) ||
272 (S_ISLNK(ff->mode) && link_is_dir(buf_string(&LastDir), ff->name)))
273 {
274 mutt_error(_("Can't view a directory"));
275 return FR_ERROR;
276 }
277 else
278 {
279 struct Buffer *path = buf_pool_get();
281 struct Body *b = mutt_make_file_attach(buf_string(path), NeoMutt->sub);
282 if (b)
283 {
284 mutt_view_attachment(NULL, b, MUTT_VA_REGULAR, NULL, NULL, priv->menu->win);
285 mutt_body_free(&b);
287 }
288 else
289 {
290 mutt_error(_("Error trying to view file"));
291 }
292 buf_pool_release(&path);
293 }
294 return FR_ERROR;
295}
296
300static int op_catchup(struct BrowserPrivateData *priv, int op)
301{
302 if (!OptNews)
303 return FR_NOT_IMPL;
304
305 struct NntpMboxData *mdata = NULL;
306
308 if (rc < 0)
309 return FR_ERROR;
310
311 int index = menu_get_index(priv->menu);
312 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
313 if (op == OP_CATCHUP)
315 else
317
318 if (mdata)
319 {
321 index = menu_get_index(priv->menu) + 1;
322 if (index < priv->menu->max)
323 menu_set_index(priv->menu, index);
324 }
325
326 if (rc != 0)
328
330 return FR_ERROR;
331}
332
340static int op_change_directory(struct BrowserPrivateData *priv, int op)
341{
342 if (OptNews)
343 return FR_NOT_IMPL;
344
345 struct Buffer *buf = buf_pool_get();
346 buf_copy(buf, &LastDir);
347 if (!priv->state.imap_browse)
348 {
349 /* add '/' at the end of the directory name if not already there */
350 size_t len = buf_len(buf);
351 if ((len > 0) && (buf_string(&LastDir)[len - 1] != '/'))
352 buf_addch(buf, '/');
353 }
354
355 if (op == OP_CHANGE_DIRECTORY)
356 {
357 struct FileCompletionData cdata = { false, priv->mailbox, NULL, NULL };
358 int rc = mw_get_field(_("Chdir to: "), buf, MUTT_COMP_NO_FLAGS, HC_FILE,
359 &CompleteMailboxOps, &cdata);
360 if ((rc != 0) && buf_is_empty(buf))
361 {
362 buf_pool_release(&buf);
363 return FR_NO_ACTION;
364 }
365 }
366 else if (op == OP_GOTO_PARENT)
367 {
368 mutt_get_parent_path(buf_string(buf), buf->data, buf->dsize);
369 }
370
371 if (!buf_is_empty(buf))
372 {
373 priv->state.is_mailbox_list = false;
374 buf_expand_path(buf);
375 if (imap_path_probe(buf_string(buf), NULL) == MUTT_IMAP)
376 {
377 buf_copy(&LastDir, buf);
378 destroy_state(&priv->state);
379 init_state(&priv->state);
380 priv->state.imap_browse = true;
382 browser_sort(&priv->state);
383 browser_highlight_default(&priv->state, priv->menu);
384 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
385 }
386 else
387 {
388 if (buf_string(buf)[0] != '/')
389 {
390 /* in case dir is relative, make it relative to LastDir,
391 * not current working dir */
392 struct Buffer *tmp = buf_pool_get();
394 buf_copy(buf, tmp);
395 buf_pool_release(&tmp);
396 }
397 /* Resolve path from <chdir>
398 * Avoids buildup such as /a/b/../../c
399 * Symlinks are always unraveled to keep code simple */
400 if (mutt_path_realpath(buf) == 0)
401 {
402 buf_pool_release(&buf);
403 return FR_ERROR;
404 }
405
406 struct stat st = { 0 };
407 if (stat(buf_string(buf), &st) == 0)
408 {
409 if (S_ISDIR(st.st_mode))
410 {
411 destroy_state(&priv->state);
412 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
413 buf_string(buf), buf_string(priv->prefix)) == 0)
414 {
415 buf_copy(&LastDir, buf);
416 }
417 else
418 {
419 mutt_error(_("Error scanning directory"));
420 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
421 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
422 {
423 priv->done = true;
424 return FR_ERROR;
425 }
426 }
427 browser_highlight_default(&priv->state, priv->menu);
428 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
429 }
430 else
431 {
432 mutt_error(_("%s is not a directory"), buf_string(buf));
433 }
434 }
435 else
436 {
437 mutt_perror("%s", buf_string(buf));
438 }
439 }
440 }
441 buf_pool_release(&buf);
442 return FR_ERROR;
443}
444
448static int op_create_mailbox(struct BrowserPrivateData *priv, int op)
449{
450 if (!priv->state.imap_browse)
451 {
452 mutt_error(_("Create is only supported for IMAP mailboxes"));
453 return FR_ERROR;
454 }
455
457 return FR_ERROR;
458
459 /* TODO: find a way to detect if the new folder would appear in
460 * this window, and insert it without starting over. */
461 destroy_state(&priv->state);
462 init_state(&priv->state);
463 priv->state.imap_browse = true;
465 browser_sort(&priv->state);
466 browser_highlight_default(&priv->state, priv->menu);
467 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
468
469 return FR_SUCCESS;
470}
471
475static int op_delete_mailbox(struct BrowserPrivateData *priv, int op)
476{
477 int index = menu_get_index(priv->menu);
478 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
479 if (!ff->imap)
480 {
481 mutt_error(_("Delete is only supported for IMAP mailboxes"));
482 return FR_ERROR;
483 }
484
485 char msg[128] = { 0 };
486
487 // TODO(sileht): It could be better to select INBOX instead. But I
488 // don't want to manipulate Mailboxes/mailbox->account here for now.
489 // Let's just protect neomutt against crash for now. #1417
490 if (mutt_str_equal(mailbox_path(priv->mailbox), ff->name))
491 {
492 mutt_error(_("Can't delete currently selected mailbox"));
493 return FR_ERROR;
494 }
495
496 snprintf(msg, sizeof(msg), _("Really delete mailbox \"%s\"?"), ff->name);
497 if (query_yesorno(msg, MUTT_NO) != MUTT_YES)
498 {
499 mutt_message(_("Mailbox not deleted"));
500 return FR_NO_ACTION;
501 }
502
503 if (imap_delete_mailbox(priv->mailbox, ff->name) != 0)
504 {
505 mutt_error(_("Mailbox deletion failed"));
506 return FR_ERROR;
507 }
508
509 /* free the mailbox from the browser */
510 FREE(&ff->name);
511 FREE(&ff->desc);
512 /* and move all other entries up */
513 ARRAY_REMOVE(&priv->state.entry, ff);
514 mutt_message(_("Mailbox deleted"));
515 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
516
517 return FR_SUCCESS;
518}
519
523static int op_enter_mask(struct BrowserPrivateData *priv, int op)
524{
525 const struct Regex *c_mask = cs_subset_regex(NeoMutt->sub, "mask");
526 struct Buffer *buf = buf_pool_get();
527 buf_strcpy(buf, c_mask ? c_mask->pattern : NULL);
528 if (mw_get_field(_("File Mask: "), buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0)
529 {
530 buf_pool_release(&buf);
531 return FR_NO_ACTION;
532 }
533
534 buf_fix_dptr(buf);
535
536 priv->state.is_mailbox_list = false;
537 /* assume that the user wants to see everything */
538 if (buf_is_empty(buf))
539 buf_strcpy(buf, ".");
540
541 struct Buffer *errmsg = buf_pool_get();
542 int rc = cs_subset_str_string_set(NeoMutt->sub, "mask", buf_string(buf), errmsg);
543 buf_pool_release(&buf);
544 if (CSR_RESULT(rc) != CSR_SUCCESS)
545 {
546 if (!buf_is_empty(errmsg))
547 {
548 mutt_error("%s", buf_string(errmsg));
549 buf_pool_release(&errmsg);
550 }
551 return FR_ERROR;
552 }
553 buf_pool_release(&errmsg);
554
555 destroy_state(&priv->state);
556 if (priv->state.imap_browse)
557 {
558 init_state(&priv->state);
559 priv->state.imap_browse = true;
561 browser_sort(&priv->state);
562 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
563 }
564 else if (examine_directory(priv->mailbox, priv->menu, &priv->state,
565 buf_string(&LastDir), NULL) == 0)
566 {
567 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
568 }
569 else
570 {
571 mutt_error(_("Error scanning directory"));
572 priv->done = true;
573 return FR_ERROR;
574 }
575 priv->kill_prefix = false;
576 if (ARRAY_EMPTY(&priv->state.entry))
577 {
578 mutt_error(_("No files match the file mask"));
579 return FR_ERROR;
580 }
581 return FR_SUCCESS;
582}
583
587static int op_exit(struct BrowserPrivateData *priv, int op)
588{
589 if (priv->multiple)
590 {
591 char **tfiles = NULL;
592
593 if (priv->menu->num_tagged)
594 {
595 *priv->numfiles = priv->menu->num_tagged;
596 tfiles = MUTT_MEM_CALLOC(*priv->numfiles, char *);
597 size_t j = 0;
598 struct FolderFile *ff = NULL;
599 ARRAY_FOREACH(ff, &priv->state.entry)
600 {
601 if (ff->tagged)
602 {
603 struct Buffer *buf = buf_pool_get();
605 buf_expand_path(buf);
606 tfiles[j++] = buf_strdup(buf);
607 buf_pool_release(&buf);
608 }
609 }
610 *priv->files = tfiles;
611 }
612 else if (!buf_is_empty(priv->file)) /* no tagged entries. return selected entry */
613 {
614 *priv->numfiles = 1;
615 tfiles = MUTT_MEM_CALLOC(*priv->numfiles, char *);
616 buf_expand_path(priv->file);
617 tfiles[0] = buf_strdup(priv->file);
618 *priv->files = tfiles;
619 }
620 }
621
622 priv->done = true;
623 return FR_DONE;
624}
625
633static int op_generic_select_entry(struct BrowserPrivateData *priv, int op)
634{
635 if (ARRAY_EMPTY(&priv->state.entry))
636 {
637 mutt_error(_("No files match the file mask"));
638 return FR_ERROR;
639 }
640
641 int index = menu_get_index(priv->menu);
642 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
643 if (S_ISDIR(ff->mode) ||
644 (S_ISLNK(ff->mode) && link_is_dir(buf_string(&LastDir), ff->name)) || ff->inferiors)
645 {
646 /* make sure this isn't a MH or maildir mailbox */
647 struct Buffer *buf = buf_pool_get();
648 if (priv->state.is_mailbox_list)
649 {
650 buf_strcpy(buf, ff->name);
651 buf_expand_path(buf);
652 }
653 else if (priv->state.imap_browse)
654 {
655 buf_strcpy(buf, ff->name);
656 }
657 else
658 {
660 }
661
662 enum MailboxType type = mx_path_probe(buf_string(buf));
663 buf_pool_release(&buf);
664
665 if ((op == OP_DESCEND_DIRECTORY) || (type == MUTT_MAILBOX_ERROR) ||
666 (type == MUTT_UNKNOWN) || ff->inferiors)
667 {
668 /* save the old directory */
670
671 if (mutt_str_equal(ff->name, ".."))
672 {
673 size_t lastdirlen = buf_len(&LastDir);
674 if ((lastdirlen > 1) && mutt_str_equal("..", buf_string(&LastDir) + lastdirlen - 2))
675 {
676 buf_addstr(&LastDir, "/..");
677 }
678 else
679 {
680 char *p = NULL;
681 if (lastdirlen > 1)
682 p = strrchr(LastDir.data + 1, '/');
683
684 if (p)
685 {
686 *p = '\0';
688 }
689 else
690 {
691 if (buf_string(&LastDir)[0] == '/')
692 buf_strcpy(&LastDir, "/");
693 else
694 buf_addstr(&LastDir, "/..");
695 }
696 }
697 }
698 else if (priv->state.is_mailbox_list)
699 {
700 buf_strcpy(&LastDir, ff->name);
702 }
703 else if (priv->state.imap_browse)
704 {
705 buf_strcpy(&LastDir, ff->name);
706 /* tack on delimiter here */
707
708 /* special case "" needs no delimiter */
709 struct Url *url = url_parse(ff->name);
710 if (url && url->path && (ff->delim != '\0'))
711 {
712 buf_addch(&LastDir, ff->delim);
713 }
714 url_free(&url);
715 }
716 else
717 {
718 struct Buffer *tmp = buf_pool_get();
720 buf_copy(&LastDir, tmp);
721 buf_pool_release(&tmp);
722 }
723
724 destroy_state(&priv->state);
725 if (priv->kill_prefix)
726 {
727 buf_reset(priv->prefix);
728 priv->kill_prefix = false;
729 }
730 priv->state.is_mailbox_list = false;
731 if (priv->state.imap_browse)
732 {
733 init_state(&priv->state);
734 priv->state.imap_browse = true;
736 browser_sort(&priv->state);
737 }
738 else
739 {
740 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
741 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
742 {
743 /* try to restore the old values */
745 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
746 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
747 {
749 priv->done = true;
750 return FR_DONE;
751 }
752 }
753 /* resolve paths navigated from GUI */
754 if (mutt_path_realpath(&LastDir) == 0)
755 return FR_ERROR;
756 }
757
758 browser_highlight_default(&priv->state, priv->menu);
759 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
760 priv->goto_swapper[0] = '\0';
761 return FR_SUCCESS;
762 }
763 }
764 else if (op == OP_DESCEND_DIRECTORY)
765 {
766 mutt_error(_("%s is not a directory"), ARRAY_GET(&priv->state.entry, index)->name);
767 return FR_ERROR;
768 }
769
770 if (priv->state.is_mailbox_list || OptNews)
771 {
772 buf_strcpy(priv->file, ff->name);
773 buf_expand_path(priv->file);
774 }
775 else if (priv->state.imap_browse)
776 {
777 buf_strcpy(priv->file, ff->name);
778 }
779 else
780 {
782 }
783
784 return op_exit(priv, op);
785}
786
790static int op_load_active(struct BrowserPrivateData *priv, int op)
791{
792 if (!OptNews)
793 return FR_NOT_IMPL;
794
796
797 if (nntp_newsrc_parse(adata) < 0)
798 return FR_ERROR;
799
800 for (size_t i = 0; i < adata->groups_num; i++)
801 {
802 struct NntpMboxData *mdata = adata->groups_list[i];
803 if (mdata)
804 mdata->deleted = true;
805 }
809
810 destroy_state(&priv->state);
811 if (priv->state.is_mailbox_list)
812 {
813 examine_mailboxes(priv->mailbox, priv->menu, &priv->state);
814 }
815 else
816 {
817 if (examine_directory(priv->mailbox, priv->menu, &priv->state, NULL, NULL) == -1)
818 return FR_ERROR;
819 }
820 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
821 return FR_SUCCESS;
822}
823
827static int op_mailbox_list(struct BrowserPrivateData *priv, int op)
828{
830 return FR_SUCCESS;
831}
832
836static int op_rename_mailbox(struct BrowserPrivateData *priv, int op)
837{
838 int index = menu_get_index(priv->menu);
839 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
840 if (!ff->imap)
841 {
842 mutt_error(_("Rename is only supported for IMAP mailboxes"));
843 return FR_ERROR;
844 }
845
846 if (imap_mailbox_rename(ff->name) < 0)
847 return FR_ERROR;
848
849 destroy_state(&priv->state);
850 init_state(&priv->state);
851 priv->state.imap_browse = true;
853 browser_sort(&priv->state);
854 browser_highlight_default(&priv->state, priv->menu);
855 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
856
857 return FR_SUCCESS;
858}
859
867static int op_sort(struct BrowserPrivateData *priv, int op)
868{
869 bool resort = true;
870 int sort = -1;
871 int reverse = (op == OP_SORT_REVERSE);
872
873 switch (mw_multi_choice((reverse) ?
874 /* L10N: The highlighted letters must match the "Sort" options */
875 _("Reverse sort by (d)ate, (a)lpha, si(z)e, d(e)scription, (c)ount, ne(w) count, or do(n)'t sort?") :
876 /* L10N: The highlighted letters must match the "Reverse Sort" options */
877 _("Sort by (d)ate, (a)lpha, si(z)e, d(e)scription, (c)ount, ne(w) count, or do(n)'t sort?"),
878 /* L10N: These must match the highlighted letters from "Sort" and "Reverse Sort" */
879 _("dazecwn")))
880 {
881 case -1: /* abort */
882 resort = false;
883 break;
884
885 case 1: /* (d)ate */
886 sort = SORT_DATE;
887 break;
888
889 case 2: /* (a)lpha */
890 sort = SORT_SUBJECT;
891 break;
892
893 case 3: /* si(z)e */
894 sort = SORT_SIZE;
895 break;
896
897 case 4: /* d(e)scription */
898 sort = SORT_DESC;
899 break;
900
901 case 5: /* (c)ount */
902 sort = SORT_COUNT;
903 break;
904
905 case 6: /* ne(w) count */
906 sort = SORT_UNREAD;
907 break;
908
909 case 7: /* do(n)'t sort */
910 sort = SORT_ORDER;
911 break;
912 }
913
914 if (!resort)
915 return FR_NO_ACTION;
916
917 sort |= reverse ? SORT_REVERSE : 0;
918 cs_subset_str_native_set(NeoMutt->sub, "sort_browser", sort, NULL);
919 browser_sort(&priv->state);
920 browser_highlight_default(&priv->state, priv->menu);
922 return FR_SUCCESS;
923}
924
932static int op_subscribe_pattern(struct BrowserPrivateData *priv, int op)
933{
934 if (!OptNews)
935 return FR_NOT_IMPL;
936
938 regex_t rx = { 0 };
939 int index = menu_get_index(priv->menu);
940
941 char tmp2[256] = { 0 };
942
943 struct Buffer *buf = buf_pool_get();
944 if (op == OP_SUBSCRIBE_PATTERN)
945 snprintf(tmp2, sizeof(tmp2), _("Subscribe pattern: "));
946 else
947 snprintf(tmp2, sizeof(tmp2), _("Unsubscribe pattern: "));
948 /* buf comes from the buffer pool, so defaults to size 1024 */
949 if ((mw_get_field(tmp2, buf, MUTT_COMP_NO_FLAGS, HC_PATTERN, &CompletePatternOps, NULL) != 0) ||
950 buf_is_empty(buf))
951 {
952 buf_pool_release(&buf);
953 return FR_NO_ACTION;
954 }
955
956 int err = REG_COMP(&rx, buf->data, REG_NOSUB);
957 if (err != 0)
958 {
959 regerror(err, &rx, buf->data, buf->dsize);
960 regfree(&rx);
961 mutt_error("%s", buf_string(buf));
962 buf_pool_release(&buf);
963 return FR_ERROR;
964 }
966 index = 0;
967 buf_pool_release(&buf);
968
969 int rc = nntp_newsrc_parse(adata);
970 if (rc < 0)
971 return FR_ERROR;
972
973 struct FolderFile *ff = NULL;
974 ARRAY_FOREACH_FROM(ff, &priv->state.entry, index)
975 {
976 if (regexec(&rx, ff->name, 0, NULL, 0) == 0)
977 {
978 if (op == OP_SUBSCRIBE_PATTERN)
979 mutt_newsgroup_subscribe(adata, ff->name);
980 else
982 }
983 }
984
985 if (op == OP_SUBSCRIBE_PATTERN)
986 {
987 for (size_t j = 0; j < adata->groups_num; j++)
988 {
989 struct NntpMboxData *mdata = adata->groups_list[j];
990 if (mdata && mdata->group && !mdata->subscribed)
991 {
992 if (regexec(&rx, mdata->group, 0, NULL, 0) == 0)
993 {
995 browser_add_folder(priv->menu, &priv->state, mdata->group, NULL, NULL, NULL, mdata);
996 }
997 }
998 }
999 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
1000 }
1001 if (rc > 0)
1006 regfree(&rx);
1007 return FR_SUCCESS;
1008}
1009
1017static int op_toggle_mailboxes(struct BrowserPrivateData *priv, int op)
1018{
1019 if (priv->state.is_mailbox_list)
1020 {
1022 }
1023
1024 if (op == OP_TOGGLE_MAILBOXES)
1025 {
1027 }
1028
1029 if (op == OP_BROWSER_GOTO_FOLDER)
1030 {
1031 /* When in mailboxes mode, disables this feature */
1032 const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
1033 if (c_folder)
1034 {
1035 mutt_debug(LL_DEBUG3, "= hit! Folder: %s, LastDir: %s\n", c_folder,
1037 if (priv->goto_swapper[0] == '\0')
1038 {
1039 if (!mutt_str_equal(buf_string(&LastDir), c_folder))
1040 {
1041 /* Stores into goto_swapper LastDir, and swaps to `$folder` */
1042 mutt_str_copy(priv->goto_swapper, buf_string(&LastDir), sizeof(priv->goto_swapper));
1044 buf_strcpy(&LastDir, c_folder);
1045 }
1046 }
1047 else
1048 {
1051 priv->goto_swapper[0] = '\0';
1052 }
1053 }
1054 }
1055 destroy_state(&priv->state);
1056 buf_reset(priv->prefix);
1057 priv->kill_prefix = false;
1058
1059 if (priv->state.is_mailbox_list)
1060 {
1061 examine_mailboxes(priv->mailbox, priv->menu, &priv->state);
1062 }
1063 else if (imap_path_probe(buf_string(&LastDir), NULL) == MUTT_IMAP)
1064 {
1065 init_state(&priv->state);
1066 priv->state.imap_browse = true;
1068 browser_sort(&priv->state);
1069 }
1070 else if (examine_directory(priv->mailbox, priv->menu, &priv->state,
1071 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
1072 {
1073 priv->done = true;
1074 return FR_ERROR;
1075 }
1076 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
1077 if (priv->state.is_mailbox_list)
1079 return FR_ERROR;
1080}
1081
1082// -----------------------------------------------------------------------------
1083
1087static const struct BrowserFunction BrowserFunctions[] = {
1088 // clang-format off
1089 { OP_BROWSER_GOTO_FOLDER, op_toggle_mailboxes },
1090 { OP_BROWSER_NEW_FILE, op_browser_new_file },
1091 { OP_BROWSER_SUBSCRIBE, op_browser_subscribe },
1092 { OP_BROWSER_TELL, op_browser_tell },
1093 { OP_BROWSER_TOGGLE_LSUB, op_browser_toggle_lsub },
1094 { OP_BROWSER_UNSUBSCRIBE, op_browser_subscribe },
1095 { OP_BROWSER_VIEW_FILE, op_browser_view_file },
1096 { OP_CATCHUP, op_catchup },
1097 { OP_CHANGE_DIRECTORY, op_change_directory },
1098 { OP_CHECK_NEW, op_toggle_mailboxes },
1099 { OP_CREATE_MAILBOX, op_create_mailbox },
1100 { OP_DELETE_MAILBOX, op_delete_mailbox },
1101 { OP_DESCEND_DIRECTORY, op_generic_select_entry },
1102 { OP_ENTER_MASK, op_enter_mask },
1103 { OP_EXIT, op_exit },
1104 { OP_GENERIC_SELECT_ENTRY, op_generic_select_entry },
1105 { OP_GOTO_PARENT, op_change_directory },
1106 { OP_LOAD_ACTIVE, op_load_active },
1107 { OP_MAILBOX_LIST, op_mailbox_list },
1108 { OP_RENAME_MAILBOX, op_rename_mailbox },
1109 { OP_SORT, op_sort },
1110 { OP_SORT_REVERSE, op_sort },
1111 { OP_SUBSCRIBE_PATTERN, op_subscribe_pattern },
1112 { OP_TOGGLE_MAILBOXES, op_toggle_mailboxes },
1113 { OP_UNCATCHUP, op_catchup },
1114 { OP_UNSUBSCRIBE_PATTERN, op_subscribe_pattern },
1115 { 0, NULL },
1116 // clang-format on
1117};
1118
1126{
1127 // The Dispatcher may be called on any Window in the Dialog
1128 struct MuttWindow *dlg = dialog_find(win);
1129 if (!dlg || !dlg->wdata)
1130 return FR_ERROR;
1131
1132 struct Menu *menu = dlg->wdata;
1133 struct BrowserPrivateData *priv = menu->mdata;
1134 if (!priv)
1135 return FR_ERROR;
1136
1137 int rc = FR_UNKNOWN;
1138 for (size_t i = 0; BrowserFunctions[i].op != OP_NULL; i++)
1139 {
1140 const struct BrowserFunction *fn = &BrowserFunctions[i];
1141 if (fn->op == op)
1142 {
1143 rc = fn->function(priv, op);
1144 break;
1145 }
1146 }
1147
1148 return rc;
1149}
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition: array.h:267
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:74
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
#define ARRAY_FOREACH_FROM(elem, head, from)
Iterate from an index to the end.
Definition: array.h:223
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:109
GUI display the mailboxes in a side panel.
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:224
const struct CompleteOps CompleteMailboxOps
Auto-Completion of Files / Mailboxes.
Definition: complete.c:160
int browser_function_dispatcher(struct MuttWindow *win, int op)
Perform a Browser function.
Definition: functions.c:1125
const struct MenuOpSeq BrowserDefaultBindings[]
Key bindings for the file Browser Menu.
Definition: functions.c:105
const struct MenuFuncOp OpBrowser[]
Functions for the file Browser Menu.
Definition: functions.c:71
void destroy_state(struct BrowserState *state)
Free the BrowserState.
Definition: functions.c:134
static const struct BrowserFunction BrowserFunctions[]
All the NeoMutt functions that the Browser supports.
Definition: functions.c:1087
void browser_sort(struct BrowserState *state)
Sort the entries in the browser.
Definition: sort.c:185
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:491
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:76
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:291
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
Definition: buffer.c:182
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:241
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:226
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition: buffer.c:601
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition: buffer.c:571
size_t buf_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
Definition: buffer.c:509
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
const struct Regex * cs_subset_regex(const struct ConfigSubset *sub, const char *name)
Get a regex config item by name.
Definition: helpers.c:217
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
Convenience wrapper for the config headers.
char * HomeDir
User's home directory.
Definition: globals.c:37
#define CSR_RESULT(x)
Definition: set.h:52
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
Convenience wrapper for the core headers.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:223
MailboxType
Supported mailbox formats.
Definition: mailbox.h:41
@ MUTT_MAILBOX_ERROR
Error occurred examining Mailbox.
Definition: mailbox.h:43
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:50
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition: mailbox.h:44
void mutt_unget_op(int op)
Return an operation to the input buffer.
Definition: get.c:126
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:89
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
@ FR_DONE
Exit the Dialog.
Definition: dispatcher.h:35
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
@ FR_ERROR
Valid function - error occurred.
Definition: dispatcher.h:38
@ FR_NOT_IMPL
Invalid function - feature not enabled.
Definition: dispatcher.h:36
@ FR_NO_ACTION
Valid function - no action performed.
Definition: dispatcher.h:37
int examine_directory(struct Mailbox *m, struct Menu *menu, struct BrowserState *state, const char *dirname, const char *prefix)
Get list of all files/newsgroups with mask.
Definition: dlg_browser.c:699
void init_menu(struct BrowserState *state, struct Menu *menu, struct Mailbox *m, struct MuttWindow *sbar)
Set up a new menu.
Definition: dlg_browser.c:1019
struct Buffer LastDir
Browser: previous selected directory.
Definition: dlg_browser.c:139
void init_state(struct BrowserState *state)
Initialise a browser state.
Definition: dlg_browser.c:682
struct Buffer LastDirBackup
Browser: backup copy of the current directory.
Definition: dlg_browser.c:141
void browser_add_folder(const struct Menu *menu, struct BrowserState *state, const char *name, const char *desc, const struct stat *st, struct Mailbox *m, void *data)
Add a folder to the browser list.
Definition: dlg_browser.c:632
void browser_highlight_default(struct BrowserState *state, struct Menu *menu)
Decide which browser item should be highlighted.
Definition: dlg_browser.c:993
int examine_mailboxes(struct Mailbox *m, struct Menu *menu, struct BrowserState *state)
Get list of mailboxes/subscribed newsgroups.
Definition: dlg_browser.c:826
bool link_is_dir(const char *folder, const char *path)
Does this symlink point to a directory?
Definition: dlg_browser.c:175
Edit a string.
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:58
Structs that make up an email.
bool OptNews
(pseudo) used to change reader mode
Definition: globals.c:67
static int op_generic_select_entry(struct AliasMenuData *mdata, int op)
select the current entry - Implements alias_function_t -
Definition: functions.c:214
static int op_exit(struct AliasMenuData *mdata, int op)
exit this menu - Implements alias_function_t -
Definition: functions.c:200
static int op_sort(struct AliasMenuData *mdata, int op)
sort aliases - Implements alias_function_t -
Definition: functions.c:389
static int op_browser_view_file(struct BrowserPrivateData *priv, int op)
View file - Implements browser_function_t -.
Definition: functions.c:255
static int op_browser_new_file(struct BrowserPrivateData *priv, int op)
Select a new file in this directory - Implements browser_function_t -.
Definition: functions.c:151
static int op_enter_mask(struct BrowserPrivateData *priv, int op)
Enter a file mask - Implements browser_function_t -.
Definition: functions.c:523
static int op_subscribe_pattern(struct BrowserPrivateData *priv, int op)
Subscribe to newsgroups matching a pattern - Implements browser_function_t -.
Definition: functions.c:932
static int op_catchup(struct BrowserPrivateData *priv, int op)
Mark all articles in newsgroup as read - Implements browser_function_t -.
Definition: functions.c:300
static int op_rename_mailbox(struct BrowserPrivateData *priv, int op)
Rename the current mailbox (IMAP only) - Implements browser_function_t -.
Definition: functions.c:836
static int op_browser_subscribe(struct BrowserPrivateData *priv, int op)
Subscribe to current mbox (IMAP/NNTP only) - Implements browser_function_t -.
Definition: functions.c:178
static int op_browser_toggle_lsub(struct BrowserPrivateData *priv, int op)
Toggle view all/subscribed mailboxes (IMAP only) - Implements browser_function_t -.
Definition: functions.c:244
static int op_create_mailbox(struct BrowserPrivateData *priv, int op)
Create a new mailbox (IMAP only) - Implements browser_function_t -.
Definition: functions.c:448
static int op_delete_mailbox(struct BrowserPrivateData *priv, int op)
Delete the current mailbox (IMAP only) - Implements browser_function_t -.
Definition: functions.c:475
static int op_load_active(struct BrowserPrivateData *priv, int op)
Load list of all newsgroups from NNTP server - Implements browser_function_t -.
Definition: functions.c:790
static int op_toggle_mailboxes(struct BrowserPrivateData *priv, int op)
Toggle whether to browse mailboxes or all files - Implements browser_function_t -.
Definition: functions.c:1017
static int op_browser_tell(struct BrowserPrivateData *priv, int op)
Display the currently selected file's name - Implements browser_function_t -.
Definition: functions.c:231
static int op_mailbox_list(struct BrowserPrivateData *priv, int op)
List mailboxes with new mail - Implements browser_function_t -.
Definition: functions.c:827
static int op_change_directory(struct BrowserPrivateData *priv, int op)
Change directories - Implements browser_function_t -.
Definition: functions.c:340
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition: window.c:274
int mw_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question -.
Definition: question.c:63
#define mutt_error(...)
Definition: logging2.h:92
#define mutt_message(...)
Definition: logging2.h:91
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
#define mutt_perror(...)
Definition: logging2.h:93
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe() -.
Definition: imap.c:2345
Convenience wrapper for the gui headers.
Read/write command history from/to a file.
@ HC_FILE
Files.
Definition: lib.h:57
@ HC_PATTERN
Patterns.
Definition: lib.h:58
@ HC_OTHER
Miscellaneous strings.
Definition: lib.h:59
int imap_browse(const char *path, struct BrowserState *state)
IMAP hook into the folder browser.
Definition: browse.c:197
int imap_mailbox_create(const char *path)
Create a new IMAP mailbox.
Definition: browse.c:394
int imap_mailbox_rename(const char *path)
Rename a mailbox.
Definition: browse.c:449
IMAP network mailbox.
int imap_subscribe(const char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1223
int imap_delete_mailbox(struct Mailbox *m, char *path)
Delete a mailbox.
Definition: imap.c:505
Manage keymappings.
@ LL_DEBUG3
Log at debug level 3.
Definition: logging2.h:45
#define FREE(x)
Definition: memory.h:55
#define MUTT_MEM_CALLOC(n, type)
Definition: memory.h:40
GUI present the user with a selectable list.
#define MENU_REDRAW_FULL
Redraw everything.
Definition: lib.h:59
#define MENU_REDRAW_INDEX
Redraw the index.
Definition: lib.h:56
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:184
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:160
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:174
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
size_t mutt_path_realpath(struct Buffer *path)
Resolve path, unraveling symlinks.
Definition: path.c:377
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:581
Many unsorted constants and some structs.
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:56
int mutt_view_attachment(FILE *fp, struct Body *b, enum ViewAttachMode mode, struct Email *e, struct AttachCtx *actx, struct MuttWindow *win)
View an attachment.
Definition: mutt_attach.c:419
@ MUTT_VA_REGULAR
View using default method.
Definition: mutt_attach.h:44
bool mutt_mailbox_list(void)
Show a message with the list of mailboxes with new mail.
Definition: mutt_mailbox.c:248
Mailbox helper functions.
void mutt_get_parent_path(const char *path, char *buf, size_t buflen)
Find the parent of a path (or mailbox)
Definition: muttlib.c:936
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:315
Some miscellaneous functions.
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition: mx.c:1321
API for mailboxes.
Nntp-specific Account data.
Usenet network mailbox type; talk to an NNTP server.
void nntp_clear_cache(struct NntpAccountData *adata)
Clear the NNTP cache.
Definition: newsrc.c:843
int nntp_active_fetch(struct NntpAccountData *adata, bool mark_new)
Fetch list of all newsgroups from server.
Definition: nntp.c:2037
int nntp_newsrc_parse(struct NntpAccountData *adata)
Parse .newsrc file.
Definition: newsrc.c:166
void nntp_newsrc_close(struct NntpAccountData *adata)
Unlock and close .newsrc file.
Definition: newsrc.c:122
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition: newsrc.c:1343
int nntp_newsrc_update(struct NntpAccountData *adata)
Update .newsrc file.
Definition: newsrc.c:445
struct NntpMboxData * mutt_newsgroup_subscribe(struct NntpAccountData *adata, char *group)
Subscribe newsgroup.
Definition: newsrc.c:1292
struct NntpMboxData * mutt_newsgroup_uncatchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Uncatchup newsgroup.
Definition: newsrc.c:1382
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
Definition: nntp.c:77
struct NntpMboxData * mutt_newsgroup_unsubscribe(struct NntpAccountData *adata, char *group)
Unsubscribe newsgroup.
Definition: newsrc.c:1316
Nntp-specific Mailbox data.
Private state data for the Pager.
const struct CompleteOps CompletePatternOps
Auto-Completion of Patterns.
Definition: complete.c:82
Match patterns to emails.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition: quad.h:38
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:39
Ask the user a question.
enum QuadOption query_yesorno(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question.
Definition: question.c:327
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition: regex3.h:50
Convenience wrapper for the send headers.
struct Body * mutt_make_file_attach(const char *path, struct ConfigSubset *sub)
Create a file attachment.
Definition: sendlib.c:607
Sidebar functions.
@ SORT_SUBJECT
Sort by the email's subject.
Definition: sort2.h:38
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:40
@ SORT_SIZE
Sort by the size of the email.
Definition: sort2.h:36
@ SORT_DESC
Sort by the folder's description.
Definition: sort2.h:55
@ SORT_DATE
Sort by the date the email was sent.
Definition: sort2.h:35
@ SORT_COUNT
Sort by number of emails in a folder.
Definition: sort2.h:50
@ SORT_UNREAD
Sort by the number of unread emails.
Definition: sort2.h:51
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort2.h:71
Key value store.
void * adata
Private data (for Mailbox backends)
Definition: account.h:42
The body of an email.
Definition: body.h:36
A NeoMutt function.
Definition: functions.h:44
int op
Op code, e.g. OP_MAIN_LIMIT.
Definition: functions.h:45
browser_function_t function
Function to call.
Definition: functions.h:46
Private state data for the Browser.
Definition: private_data.h:34
char *** files
Array of selected files.
Definition: private_data.h:38
struct Menu * menu
Menu.
Definition: private_data.h:43
struct Buffer * prefix
Folder prefix string.
Definition: private_data.h:49
struct Buffer * old_last_dir
Previous to last dir.
Definition: private_data.h:48
bool kill_prefix
Prefix is in use.
Definition: private_data.h:44
bool done
Should we close the Dialog?
Definition: private_data.h:52
int last_selected_mailbox
Index of last selected Mailbox.
Definition: private_data.h:50
int * numfiles
Number of selected files.
Definition: private_data.h:39
struct Mailbox * mailbox
Mailbox.
Definition: private_data.h:37
struct BrowserState state
State containing list of files/dir/mailboxes.
Definition: private_data.h:42
struct Buffer * file
Buffer for the result.
Definition: private_data.h:36
bool multiple
Allow multiple selections.
Definition: private_data.h:45
struct MuttWindow * sbar
Status Bar.
Definition: private_data.h:51
char goto_swapper[PATH_MAX]
Saved path after <goto-folder>
Definition: private_data.h:47
State of the file/mailbox browser.
Definition: lib.h:143
char * folder
Folder name.
Definition: lib.h:146
bool is_mailbox_list
Viewing mailboxes.
Definition: lib.h:147
struct BrowserEntryArray entry
Array of files / dirs / mailboxes.
Definition: lib.h:144
bool imap_browse
IMAP folder.
Definition: lib.h:145
String manipulation buffer.
Definition: buffer.h:36
size_t dsize
Length of data.
Definition: buffer.h:39
char * data
Pointer to data.
Definition: buffer.h:37
Input for the file completion function.
Definition: curs_lib.h:40
Browser entry representing a folder/dir.
Definition: lib.h:77
bool selectable
Folder can be selected.
Definition: lib.h:95
char delim
Path delimiter.
Definition: lib.h:92
bool imap
This is an IMAP folder.
Definition: lib.h:94
char * name
Name of file/dir/mailbox.
Definition: lib.h:85
bool tagged
Folder is tagged.
Definition: lib.h:101
char * desc
Description of mailbox.
Definition: lib.h:86
mode_t mode
File permissions.
Definition: lib.h:78
bool inferiors
Folder has children.
Definition: lib.h:96
void * mdata
Driver specific data.
Definition: mailbox.h:132
Mapping between a function and an operation.
Definition: lib.h:101
Mapping between an operation and a key sequence.
Definition: lib.h:110
Definition: lib.h:79
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:86
int num_tagged
Number of tagged entries.
Definition: lib.h:93
void * mdata
Private data.
Definition: lib.h:147
void * wdata
Private data.
Definition: mutt_window.h:144
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
NNTP-specific Account data -.
Definition: adata.h:36
struct NntpMboxData ** groups_list
Definition: adata.h:60
unsigned int groups_num
Definition: adata.h:58
NNTP-specific Mailbox data -.
Definition: mdata.h:34
struct NntpAccountData * adata
Definition: mdata.h:48
Cached regular expression.
Definition: regex3.h:86
char * pattern
printable version
Definition: regex3.h:87
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:69
char * path
Path.
Definition: url.h:75
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition: subset.c:297
int cs_subset_str_string_set(const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
Definition: subset.c:386
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:239
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:124