NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c
Go to the documentation of this file.
1
23
29
30#include "config.h"
31#include <stdbool.h>
32#include <stdio.h>
33#include <string.h>
34#include <sys/stat.h>
35#include "mutt/lib.h"
36#include "config/lib.h"
37#include "email/lib.h"
38#include "core/lib.h"
39#include "gui/lib.h"
40#include "functions.h"
41#include "lib.h"
42#include "attach/lib.h"
43#include "editor/lib.h"
44#include "history/lib.h"
45#include "imap/lib.h"
46#include "key/lib.h"
47#include "menu/lib.h"
48#include "nntp/lib.h"
49#include "pattern/lib.h"
50#include "question/lib.h"
51#include "send/lib.h"
52#include "globals.h"
53#include "mutt_mailbox.h"
54#include "muttlib.h"
55#include "mx.h"
56#include "nntp/adata.h" // IWYU pragma: keep
57#include "nntp/mdata.h" // IWYU pragma: keep
58#include "private_data.h"
59#include "sort.h"
60
61static int op_subscribe_pattern(struct BrowserPrivateData *priv, const struct KeyEvent *event);
62
65
66// clang-format off
70static const struct MenuFuncOp OpBrowser[] = { /* map: browser */
71 { "catchup", OP_CATCHUP },
72 { "change-dir", OP_CHANGE_DIRECTORY },
73 { "check-new", OP_CHECK_NEW },
74 { "create-mailbox", OP_CREATE_MAILBOX },
75 { "delete-mailbox", OP_DELETE_MAILBOX },
76 { "descend-directory", OP_DESCEND_DIRECTORY },
77 { "display-filename", OP_BROWSER_TELL },
78 { "enter-mask", OP_ENTER_MASK },
79 { "exit", OP_EXIT },
80 { "goto-folder", OP_BROWSER_GOTO_FOLDER },
81 { "goto-parent", OP_GOTO_PARENT },
82 { "mailbox-list", OP_MAILBOX_LIST },
83 { "reload-active", OP_LOAD_ACTIVE },
84 { "rename-mailbox", OP_RENAME_MAILBOX },
85 { "select-new", OP_BROWSER_NEW_FILE },
86 { "sort", OP_SORT },
87 { "sort-reverse", OP_SORT_REVERSE },
88 { "subscribe", OP_BROWSER_SUBSCRIBE },
89 { "subscribe-pattern", OP_SUBSCRIBE_PATTERN },
90 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES },
91 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB },
92 { "uncatchup", OP_UNCATCHUP },
93 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE },
94 { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN },
95 { "view-file", OP_BROWSER_VIEW_FILE },
96 // Deprecated
97 { "buffy-list", OP_MAILBOX_LIST, MFF_DEPRECATED },
98 { NULL, 0 },
99};
100
104static const struct MenuOpSeq BrowserDefaultBindings[] = { /* map: browser */
105 { OP_BROWSER_GOTO_FOLDER, "=" },
106 { OP_BROWSER_NEW_FILE, "N" },
107 { OP_BROWSER_SUBSCRIBE, "s" },
108 { OP_BROWSER_TELL, "@" },
109 { OP_BROWSER_TOGGLE_LSUB, "T" },
110 { OP_BROWSER_UNSUBSCRIBE, "u" },
111 { OP_BROWSER_VIEW_FILE, " " }, // <Space>
112 { OP_CHANGE_DIRECTORY, "c" },
113 { OP_CREATE_MAILBOX, "C" },
114 { OP_DELETE_MAILBOX, "d" },
115 { OP_ENTER_MASK, "m" },
116 { OP_EXIT, "q" },
117 { OP_GOTO_PARENT, "p" },
118 { OP_MAILBOX_LIST, "." },
119 { OP_RENAME_MAILBOX, "r" },
120 { OP_SORT, "o" },
121 { OP_SORT_REVERSE, "O" },
122 { OP_TOGGLE_MAILBOXES, "\t" }, // <Tab>
123 { 0, NULL },
124};
125// clang-format on
126
130void browser_init_keys(struct SubMenu *sm_generic)
131{
132 struct MenuDefinition *md = NULL;
133 struct SubMenu *sm = NULL;
134
136 md = km_register_menu(MENU_BROWSER, "browser");
137 km_menu_add_submenu(md, sm);
138 km_menu_add_submenu(md, sm_generic);
140
141 MdBrowser = md;
142}
143
150void destroy_state(struct BrowserState *state)
151{
152 struct FolderFile *ff = NULL;
153 ARRAY_FOREACH(ff, &state->entry)
154 {
155 FREE(&ff->name);
156 FREE(&ff->desc);
157 }
158 ARRAY_FREE(&state->entry);
159 FREE(&state->folder);
160}
161
162// -----------------------------------------------------------------------------
163
167static int op_browser_new_file(struct BrowserPrivateData *priv, const struct KeyEvent *event)
168{
169 struct Buffer *buf = buf_pool_get();
170 buf_printf(buf, "%s/", buf_string(&LastDir));
171
172 struct FileCompletionData cdata = { false, priv->mailbox, NULL, NULL, NULL };
173 const int rc = mw_get_field(_("New file name: "), buf, MUTT_COMP_NO_FLAGS,
174 HC_FILE, &CompleteMailboxOps, &cdata);
175 if (rc != 0)
176 {
177 buf_pool_release(&buf);
178 return FR_NO_ACTION;
179 }
180
181 buf_copy(priv->file, buf);
182 buf_pool_release(&buf);
183 priv->done = true;
184 return FR_DONE;
185}
186
194static int op_browser_subscribe(struct BrowserPrivateData *priv, const struct KeyEvent *event)
195{
196 const int op = event->op;
197
198 if (OptNews)
199 {
201 int index = menu_get_index(priv->menu);
202
203 if (ARRAY_EMPTY(&priv->state.entry))
204 {
205 mutt_error(_("No newsgroups match the mask"));
206 return FR_ERROR;
207 }
208
209 int rc = nntp_newsrc_parse(adata);
210 if (rc < 0)
211 return FR_ERROR;
212
213 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
214 if (op == OP_BROWSER_SUBSCRIBE)
215 mutt_newsgroup_subscribe(adata, ff->name);
216 else
218
219 menu_set_index(priv->menu, index + 1);
220
221 if (rc > 0)
223 nntp_newsrc_update(adata);
224 nntp_clear_cache(adata);
225 nntp_newsrc_close(adata);
226 }
227 else
228 {
229 if (ARRAY_EMPTY(&priv->state.entry))
230 {
231 mutt_error(_("There are no mailboxes"));
232 return FR_ERROR;
233 }
234
235 struct Buffer *buf = buf_pool_get();
236 int index = menu_get_index(priv->menu);
237 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
238 buf_strcpy(buf, ff->name);
239 expand_path(buf, false);
240 imap_subscribe(buf_string(buf), (op == OP_BROWSER_SUBSCRIBE));
241 buf_pool_release(&buf);
242 }
243 return FR_SUCCESS;
244}
245
249static int op_browser_tell(struct BrowserPrivateData *priv, const struct KeyEvent *event)
250{
251 int index = menu_get_index(priv->menu);
252 if (ARRAY_EMPTY(&priv->state.entry))
253 return FR_ERROR;
254
255 mutt_message("%s", ARRAY_GET(&priv->state.entry, index)->name);
256 return FR_SUCCESS;
257}
258
262static int op_browser_toggle_lsub(struct BrowserPrivateData *priv, const struct KeyEvent *event)
263{
264 bool_str_toggle(NeoMutt->sub, "imap_list_subscribed", NULL);
265
266 mutt_unget_op(OP_CHECK_NEW);
267 return FR_SUCCESS;
268}
269
273static int op_browser_view_file(struct BrowserPrivateData *priv, const struct KeyEvent *event)
274{
275 if (ARRAY_EMPTY(&priv->state.entry))
276 {
277 mutt_error(_("No files match the file mask"));
278 return FR_ERROR;
279 }
280
281 int index = menu_get_index(priv->menu);
282 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
283 if (ff->selectable)
284 {
285 buf_strcpy(priv->file, ff->name);
286 priv->done = true;
287 return FR_DONE;
288 }
289 else if (S_ISDIR(ff->mode) ||
290 (S_ISLNK(ff->mode) && link_is_dir(buf_string(&LastDir), ff->name)))
291 {
292 mutt_error(_("Can't view a directory"));
293 return FR_ERROR;
294 }
295 else
296 {
297 struct Buffer *path = buf_pool_get();
299 struct Body *b = mutt_make_file_attach(buf_string(path), NeoMutt->sub);
300 if (b)
301 {
302 mutt_view_attachment(NULL, b, MUTT_VA_REGULAR, NULL, NULL, priv->menu->win);
303 mutt_body_free(&b);
305 }
306 else
307 {
308 mutt_error(_("Error trying to view file"));
309 }
310 buf_pool_release(&path);
311 }
312 return FR_ERROR;
313}
314
318static int op_catchup(struct BrowserPrivateData *priv, const struct KeyEvent *event)
319{
320 if (!OptNews)
321 return FR_NOT_IMPL;
322
323 struct NntpMboxData *mdata = NULL;
324
326 if (rc < 0)
327 return FR_ERROR;
328
329 if (ARRAY_EMPTY(&priv->state.entry))
330 return FR_ERROR;
331
332 int index = menu_get_index(priv->menu);
333 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
334 if (event->op == OP_CATCHUP)
336 else
338
339 if (mdata)
340 {
342 index = menu_get_index(priv->menu) + 1;
343 if (index < priv->menu->max)
344 menu_set_index(priv->menu, index);
345 }
346
347 if (rc != 0)
349
351 return FR_ERROR;
352}
353
361static int op_change_directory(struct BrowserPrivateData *priv, const struct KeyEvent *event)
362{
363 if (OptNews)
364 return FR_NOT_IMPL;
365
366 struct Buffer *buf = buf_pool_get();
367 buf_copy(buf, &LastDir);
368 if (!priv->state.imap_browse)
369 {
370 /* add '/' at the end of the directory name if not already there */
371 size_t len = buf_len(buf);
372 if ((len > 0) && (buf_string(&LastDir)[len - 1] != '/'))
373 buf_addch(buf, '/');
374 }
375
376 const int op = event->op;
377 if (op == OP_CHANGE_DIRECTORY)
378 {
379 struct FileCompletionData cdata = { false, priv->mailbox, NULL, NULL, NULL };
380 int rc = mw_get_field(_("Chdir to: "), buf, MUTT_COMP_NO_FLAGS, HC_FILE,
381 &CompleteMailboxOps, &cdata);
382 if ((rc != 0) && buf_is_empty(buf))
383 {
384 buf_pool_release(&buf);
385 return FR_NO_ACTION;
386 }
387 }
388 else if (op == OP_GOTO_PARENT)
389 {
390 mutt_get_parent_path(buf_string(buf), buf->data, buf->dsize);
391 }
392
393 if (!buf_is_empty(buf))
394 {
395 priv->state.is_mailbox_list = false;
396 expand_path(buf, false);
397 if (imap_path_probe(buf_string(buf), NULL) == MUTT_IMAP)
398 {
399 buf_copy(&LastDir, buf);
400 destroy_state(&priv->state);
401 init_state(&priv->state);
402 priv->state.imap_browse = true;
404 browser_sort(&priv->state);
405 browser_highlight_default(&priv->state, priv->menu);
406 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
407 }
408 else
409 {
410 if (buf_string(buf)[0] != '/')
411 {
412 /* in case dir is relative, make it relative to LastDir,
413 * not current working dir */
414 struct Buffer *tmp = buf_pool_get();
416 buf_copy(buf, tmp);
417 buf_pool_release(&tmp);
418 }
419 /* Resolve path from <chdir>
420 * Avoids buildup such as /a/b/../../c
421 * Symlinks are always unraveled to keep code simple */
422 if (mutt_path_realpath(buf) == 0)
423 {
424 buf_pool_release(&buf);
425 return FR_ERROR;
426 }
427
428 struct stat st = { 0 };
429 if (stat(buf_string(buf), &st) == 0)
430 {
431 if (S_ISDIR(st.st_mode))
432 {
433 destroy_state(&priv->state);
434 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
435 buf_string(buf), buf_string(priv->prefix)) == 0)
436 {
437 buf_copy(&LastDir, buf);
438 }
439 else
440 {
441 mutt_error(_("Error scanning directory"));
442 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
443 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
444 {
445 priv->done = true;
446 return FR_ERROR;
447 }
448 }
449 browser_highlight_default(&priv->state, priv->menu);
450 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
451 }
452 else
453 {
454 mutt_error(_("%s is not a directory"), buf_string(buf));
455 }
456 }
457 else
458 {
459 mutt_perror("%s", buf_string(buf));
460 }
461 }
462 }
463 buf_pool_release(&buf);
464 return FR_ERROR;
465}
466
470static int op_create_mailbox(struct BrowserPrivateData *priv, const struct KeyEvent *event)
471{
472 if (!priv->state.imap_browse)
473 {
474 mutt_error(_("Create is only supported for IMAP mailboxes"));
475 return FR_ERROR;
476 }
477
479 return FR_ERROR;
480
481 /* TODO: find a way to detect if the new folder would appear in
482 * this window, and insert it without starting over. */
483 destroy_state(&priv->state);
484 init_state(&priv->state);
485 priv->state.imap_browse = true;
487 browser_sort(&priv->state);
488 browser_highlight_default(&priv->state, priv->menu);
489 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
490
491 return FR_SUCCESS;
492}
493
497static int op_delete_mailbox(struct BrowserPrivateData *priv, const struct KeyEvent *event)
498{
499 if (ARRAY_EMPTY(&priv->state.entry))
500 return FR_ERROR;
501
502 int index = menu_get_index(priv->menu);
503 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
504 if (!ff->imap)
505 {
506 mutt_error(_("Delete is only supported for IMAP mailboxes"));
507 return FR_ERROR;
508 }
509
510 char msg[128] = { 0 };
511
512 // TODO(sileht): It could be better to select INBOX instead. But I
513 // don't want to manipulate Mailboxes/mailbox->account here for now.
514 // Let's just protect neomutt against crash for now. #1417
515 if (mutt_str_equal(mailbox_path(priv->mailbox), ff->name))
516 {
517 mutt_error(_("Can't delete currently selected mailbox"));
518 return FR_ERROR;
519 }
520
521 snprintf(msg, sizeof(msg), _("Really delete mailbox \"%s\"?"), ff->name);
522 if (query_yesorno(msg, MUTT_NO) != MUTT_YES)
523 {
524 mutt_message(_("Mailbox not deleted"));
525 return FR_NO_ACTION;
526 }
527
528 if (imap_delete_mailbox(priv->mailbox, ff->name) != 0)
529 {
530 mutt_error(_("Mailbox deletion failed"));
531 return FR_ERROR;
532 }
533
534 /* free the mailbox from the browser */
535 FREE(&ff->name);
536 FREE(&ff->desc);
537 /* and move all other entries up */
538 ARRAY_REMOVE(&priv->state.entry, ff);
539 mutt_message(_("Mailbox deleted"));
540 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
541
542 return FR_SUCCESS;
543}
544
548static int op_enter_mask(struct BrowserPrivateData *priv, const struct KeyEvent *event)
549{
550 const struct Regex *c_mask = cs_subset_regex(NeoMutt->sub, "mask");
551 struct Buffer *buf = buf_pool_get();
552 buf_strcpy(buf, c_mask ? c_mask->pattern : NULL);
553 if (mw_get_field(_("File Mask: "), buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0)
554 {
555 buf_pool_release(&buf);
556 return FR_NO_ACTION;
557 }
558
559 buf_fix_dptr(buf);
560
561 priv->state.is_mailbox_list = false;
562 /* assume that the user wants to see everything */
563 if (buf_is_empty(buf))
564 buf_strcpy(buf, ".");
565
566 struct Buffer *errmsg = buf_pool_get();
567 int rc = cs_subset_str_string_set(NeoMutt->sub, "mask", buf_string(buf), errmsg);
568 buf_pool_release(&buf);
569 if (CSR_RESULT(rc) != CSR_SUCCESS)
570 {
571 if (!buf_is_empty(errmsg))
572 {
573 mutt_error("%s", buf_string(errmsg));
574 buf_pool_release(&errmsg);
575 }
576 return FR_ERROR;
577 }
578 buf_pool_release(&errmsg);
579
580 destroy_state(&priv->state);
581 if (priv->state.imap_browse)
582 {
583 init_state(&priv->state);
584 priv->state.imap_browse = true;
586 browser_sort(&priv->state);
587 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
588 }
589 else if (examine_directory(priv->mailbox, priv->menu, &priv->state,
590 buf_string(&LastDir), NULL) == 0)
591 {
592 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
593 }
594 else
595 {
596 mutt_error(_("Error scanning directory"));
597 priv->done = true;
598 return FR_ERROR;
599 }
600 priv->kill_prefix = false;
601 if (ARRAY_EMPTY(&priv->state.entry))
602 {
603 mutt_error(_("No files match the file mask"));
604 return FR_ERROR;
605 }
606 return FR_SUCCESS;
607}
608
612static int op_exit(struct BrowserPrivateData *priv, const struct KeyEvent *event)
613{
614 if (priv->multiple)
615 {
616 char **tfiles = NULL;
617
618 if (priv->menu->tag_prefix && (priv->menu->num_tagged != 0))
619 {
620 *priv->numfiles = priv->menu->num_tagged;
621 tfiles = MUTT_MEM_CALLOC(*priv->numfiles, char *);
622 size_t j = 0;
623 struct FolderFile *ff = NULL;
624 ARRAY_FOREACH(ff, &priv->state.entry)
625 {
626 if (ff->tagged)
627 {
628 struct Buffer *buf = buf_pool_get();
630 expand_path(buf, false);
631 tfiles[j++] = buf_strdup(buf);
632 buf_pool_release(&buf);
633 }
634 }
635 *priv->files = tfiles;
636 }
637 else if (!buf_is_empty(priv->file)) /* no tagged entries. return selected entry */
638 {
639 *priv->numfiles = 1;
640 tfiles = MUTT_MEM_CALLOC(*priv->numfiles, char *);
641 expand_path(priv->file, false);
642 tfiles[0] = buf_strdup(priv->file);
643 *priv->files = tfiles;
644 }
645 }
646
647 priv->done = true;
648 return FR_DONE;
649}
650
658static int op_generic_select_entry(struct BrowserPrivateData *priv, const struct KeyEvent *event)
659{
660 if (ARRAY_EMPTY(&priv->state.entry))
661 {
662 mutt_warning(_("No files match the file mask"));
663 return FR_ERROR;
664 }
665
666 const int op = event->op;
667 int index = menu_get_index(priv->menu);
668 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
669 if ((priv->menu->tag_prefix) && (op == OP_GENERIC_SELECT_ENTRY))
670 {
671 // Do nothing
672 }
673 else if (S_ISDIR(ff->mode) ||
674 (S_ISLNK(ff->mode) && link_is_dir(buf_string(&LastDir), ff->name)) || ff->inferiors)
675 {
676 /* make sure this isn't a MH or maildir mailbox */
677 struct Buffer *buf = buf_pool_get();
678 if (priv->state.is_mailbox_list)
679 {
680 buf_strcpy(buf, ff->name);
681 expand_path(buf, false);
682 }
683 else if (priv->state.imap_browse)
684 {
685 buf_strcpy(buf, ff->name);
686 }
687 else
688 {
690 }
691
692 enum MailboxType type = mx_path_probe(buf_string(buf));
693 buf_pool_release(&buf);
694
695 if ((op == OP_DESCEND_DIRECTORY) || (type == MUTT_MAILBOX_ERROR) ||
696 (type == MUTT_UNKNOWN) || ff->inferiors)
697 {
698 /* save the old directory */
700
701 if (mutt_str_equal(ff->name, ".."))
702 {
703 size_t lastdirlen = buf_len(&LastDir);
704 if ((lastdirlen > 1) && mutt_str_equal("..", buf_string(&LastDir) + lastdirlen - 2))
705 {
706 buf_addstr(&LastDir, "/..");
707 }
708 else
709 {
710 char *p = NULL;
711 if (lastdirlen > 1)
712 p = strrchr(LastDir.data + 1, '/');
713
714 if (p)
715 {
716 *p = '\0';
718 }
719 else
720 {
721 if (buf_string(&LastDir)[0] == '/')
722 buf_strcpy(&LastDir, "/");
723 else
724 buf_addstr(&LastDir, "/..");
725 }
726 }
727 }
728 else if (priv->state.is_mailbox_list)
729 {
730 buf_strcpy(&LastDir, ff->name);
731 expand_path(&LastDir, false);
732 }
733 else if (priv->state.imap_browse)
734 {
735 buf_strcpy(&LastDir, ff->name);
736 /* tack on delimiter here */
737
738 /* special case "" needs no delimiter */
739 struct Url *url = url_parse(ff->name);
740 if (url && url->path && (ff->delim != '\0'))
741 {
742 buf_addch(&LastDir, ff->delim);
743 }
744 url_free(&url);
745 }
746 else
747 {
748 struct Buffer *tmp = buf_pool_get();
750 buf_copy(&LastDir, tmp);
751 buf_pool_release(&tmp);
752 }
753
754 destroy_state(&priv->state);
755 if (priv->kill_prefix)
756 {
757 buf_reset(priv->prefix);
758 priv->kill_prefix = false;
759 }
760 priv->state.is_mailbox_list = false;
761 if (priv->state.imap_browse)
762 {
763 init_state(&priv->state);
764 priv->state.imap_browse = true;
766 browser_sort(&priv->state);
767 }
768 else
769 {
770 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
771 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
772 {
773 /* try to restore the old values */
775 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
776 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
777 {
779 priv->done = true;
780 return FR_DONE;
781 }
782 }
783 /* resolve paths navigated from GUI */
784 if (mutt_path_realpath(&LastDir) == 0)
785 return FR_ERROR;
786 }
787
788 browser_highlight_default(&priv->state, priv->menu);
789 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
790 priv->goto_swapper[0] = '\0';
791 return FR_SUCCESS;
792 }
793 }
794 else if (op == OP_DESCEND_DIRECTORY)
795 {
796 mutt_error(_("%s is not a directory"), ARRAY_GET(&priv->state.entry, index)->name);
797 return FR_ERROR;
798 }
799
800 if (priv->state.is_mailbox_list || OptNews)
801 {
802 buf_strcpy(priv->file, ff->name);
803 expand_path(priv->file, false);
804 }
805 else if (priv->state.imap_browse)
806 {
807 buf_strcpy(priv->file, ff->name);
808 }
809 else
810 {
812 }
813
814 return op_exit(priv, event);
815}
816
820static int op_load_active(struct BrowserPrivateData *priv, const struct KeyEvent *event)
821{
822 if (!OptNews)
823 return FR_NOT_IMPL;
824
826
827 if (nntp_newsrc_parse(adata) < 0)
828 return FR_ERROR;
829
830 for (size_t i = 0; i < adata->groups_num; i++)
831 {
832 struct NntpMboxData *mdata = adata->groups_list[i];
833 if (mdata)
834 mdata->deleted = true;
835 }
839
840 destroy_state(&priv->state);
841 if (priv->state.is_mailbox_list)
842 {
843 examine_mailboxes(priv->mailbox, priv->menu, &priv->state);
844 }
845 else
846 {
847 if (examine_directory(priv->mailbox, priv->menu, &priv->state, NULL, NULL) == -1)
848 return FR_ERROR;
849 }
850 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
851 return FR_SUCCESS;
852}
853
857static int op_mailbox_list(struct BrowserPrivateData *priv, const struct KeyEvent *event)
858{
860 return FR_SUCCESS;
861}
862
866static int op_rename_mailbox(struct BrowserPrivateData *priv, const struct KeyEvent *event)
867{
868 if (ARRAY_EMPTY(&priv->state.entry))
869 return FR_ERROR;
870
871 int index = menu_get_index(priv->menu);
872 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
873 if (!ff->imap)
874 {
875 mutt_error(_("Rename is only supported for IMAP mailboxes"));
876 return FR_ERROR;
877 }
878
879 if (imap_mailbox_rename(ff->name) < 0)
880 return FR_ERROR;
881
882 destroy_state(&priv->state);
883 init_state(&priv->state);
884 priv->state.imap_browse = true;
886 browser_sort(&priv->state);
887 browser_highlight_default(&priv->state, priv->menu);
888 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
889
890 return FR_SUCCESS;
891}
892
900static int op_sort(struct BrowserPrivateData *priv, const struct KeyEvent *event)
901{
902 bool resort = true;
903 int sort = -1;
904 const int op = event->op;
905 int reverse = (op == OP_SORT_REVERSE);
906
907 switch (mw_multi_choice((reverse) ?
908 /* L10N: The highlighted letters must match the "Sort" options */
909 _("Reverse sort by (d)ate, (a)lpha, si(z)e, d(e)scription, (c)ount, ne(w) count, or do(n)'t sort?") :
910 /* L10N: The highlighted letters must match the "Reverse Sort" options */
911 _("Sort by (d)ate, (a)lpha, si(z)e, d(e)scription, (c)ount, ne(w) count, or do(n)'t sort?"),
912 /* L10N: These must match the highlighted letters from "Sort" and "Reverse Sort" */
913 _("dazecwn")))
914 {
915 case -1: /* abort */
916 resort = false;
917 break;
918
919 case 1: /* (d)ate */
920 sort = BROWSER_SORT_DATE;
921 break;
922
923 case 2: /* (a)lpha */
924 sort = BROWSER_SORT_ALPHA;
925 break;
926
927 case 3: /* si(z)e */
928 sort = BROWSER_SORT_SIZE;
929 break;
930
931 case 4: /* d(e)scription */
932 sort = BROWSER_SORT_DESC;
933 break;
934
935 case 5: /* (c)ount */
936 sort = BROWSER_SORT_COUNT;
937 break;
938
939 case 6: /* ne(w) count */
940 sort = BROWSER_SORT_NEW;
941 break;
942
943 case 7: /* do(n)'t sort */
945 break;
946 }
947
948 if (!resort)
949 return FR_NO_ACTION;
950
951 sort |= reverse ? SORT_REVERSE : 0;
952 cs_subset_str_native_set(NeoMutt->sub, "browser_sort", sort, NULL);
953 browser_sort(&priv->state);
954 browser_highlight_default(&priv->state, priv->menu);
956 return FR_SUCCESS;
957}
958
966static int op_subscribe_pattern(struct BrowserPrivateData *priv, const struct KeyEvent *event)
967{
968 if (!OptNews)
969 return FR_NOT_IMPL;
970
972 regex_t rx = { 0 };
973 int index = menu_get_index(priv->menu);
974
975 char tmp2[256] = { 0 };
976
977 const int op = event->op;
978 struct Buffer *buf = buf_pool_get();
979 if (op == OP_SUBSCRIBE_PATTERN)
980 snprintf(tmp2, sizeof(tmp2), _("Subscribe pattern: "));
981 else
982 snprintf(tmp2, sizeof(tmp2), _("Unsubscribe pattern: "));
983 /* buf comes from the buffer pool, so defaults to size 1024 */
984 if ((mw_get_field(tmp2, buf, MUTT_COMP_NO_FLAGS, HC_PATTERN, &CompletePatternOps, NULL) != 0) ||
985 buf_is_empty(buf))
986 {
987 buf_pool_release(&buf);
988 return FR_NO_ACTION;
989 }
990
991 int err = REG_COMP(&rx, buf->data, REG_NOSUB);
992 if (err != 0)
993 {
994 regerror(err, &rx, buf->data, buf->dsize);
995 regfree(&rx);
996 mutt_error("%s", buf_string(buf));
997 buf_pool_release(&buf);
998 return FR_ERROR;
999 }
1001 index = 0;
1002 buf_pool_release(&buf);
1003
1004 int rc = nntp_newsrc_parse(adata);
1005 if (rc < 0)
1006 return FR_ERROR;
1007
1008 struct FolderFile *ff = NULL;
1009 ARRAY_FOREACH_FROM(ff, &priv->state.entry, index)
1010 {
1011 if (regexec(&rx, ff->name, 0, NULL, 0) == 0)
1012 {
1013 if (op == OP_SUBSCRIBE_PATTERN)
1014 mutt_newsgroup_subscribe(adata, ff->name);
1015 else
1016 mutt_newsgroup_unsubscribe(adata, ff->name);
1017 }
1018 }
1019
1020 if (op == OP_SUBSCRIBE_PATTERN)
1021 {
1022 for (size_t j = 0; j < adata->groups_num; j++)
1023 {
1024 struct NntpMboxData *mdata = adata->groups_list[j];
1025 if (mdata && mdata->group && !mdata->subscribed)
1026 {
1027 if (regexec(&rx, mdata->group, 0, NULL, 0) == 0)
1028 {
1030 browser_add_folder(priv->menu, &priv->state, mdata->group, NULL, NULL, NULL, mdata);
1031 }
1032 }
1033 }
1034 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
1035 }
1036 if (rc > 0)
1041 regfree(&rx);
1042 return FR_SUCCESS;
1043}
1044
1052static int op_toggle_mailboxes(struct BrowserPrivateData *priv, const struct KeyEvent *event)
1053{
1054 if (priv->state.is_mailbox_list)
1055 {
1057 }
1058
1059 const int op = event->op;
1060 if (op == OP_TOGGLE_MAILBOXES)
1061 {
1063 }
1064
1065 if (op == OP_BROWSER_GOTO_FOLDER)
1066 {
1067 /* When in mailboxes mode, disables this feature */
1068 const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
1069 if (c_folder)
1070 {
1071 mutt_debug(LL_DEBUG3, "= hit! Folder: %s, LastDir: %s\n", c_folder,
1073 if (priv->goto_swapper[0] == '\0')
1074 {
1075 if (!mutt_str_equal(buf_string(&LastDir), c_folder))
1076 {
1077 /* Stores into goto_swapper LastDir, and swaps to `$folder` */
1078 mutt_str_copy(priv->goto_swapper, buf_string(&LastDir), sizeof(priv->goto_swapper));
1080 buf_strcpy(&LastDir, c_folder);
1081 }
1082 }
1083 else
1084 {
1087 priv->goto_swapper[0] = '\0';
1088 }
1089 }
1090 }
1091 destroy_state(&priv->state);
1092 buf_reset(priv->prefix);
1093 priv->kill_prefix = false;
1094
1095 if (priv->state.is_mailbox_list)
1096 {
1097 examine_mailboxes(priv->mailbox, priv->menu, &priv->state);
1098 }
1099 else if (imap_path_probe(buf_string(&LastDir), NULL) == MUTT_IMAP)
1100 {
1101 init_state(&priv->state);
1102 priv->state.imap_browse = true;
1104 browser_sort(&priv->state);
1105 }
1106 else if (examine_directory(priv->mailbox, priv->menu, &priv->state,
1107 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
1108 {
1109 priv->done = true;
1110 return FR_ERROR;
1111 }
1112 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
1113 if (priv->state.is_mailbox_list)
1115 return FR_ERROR;
1116}
1117
1118// -----------------------------------------------------------------------------
1119
1123static const struct BrowserFunction BrowserFunctions[] = {
1124 // clang-format off
1125 { OP_BROWSER_GOTO_FOLDER, op_toggle_mailboxes },
1126 { OP_BROWSER_NEW_FILE, op_browser_new_file },
1127 { OP_BROWSER_SUBSCRIBE, op_browser_subscribe },
1128 { OP_BROWSER_TELL, op_browser_tell },
1129 { OP_BROWSER_TOGGLE_LSUB, op_browser_toggle_lsub },
1130 { OP_BROWSER_UNSUBSCRIBE, op_browser_subscribe },
1131 { OP_BROWSER_VIEW_FILE, op_browser_view_file },
1132 { OP_CATCHUP, op_catchup },
1133 { OP_CHANGE_DIRECTORY, op_change_directory },
1134 { OP_CHECK_NEW, op_toggle_mailboxes },
1135 { OP_CREATE_MAILBOX, op_create_mailbox },
1136 { OP_DELETE_MAILBOX, op_delete_mailbox },
1137 { OP_DESCEND_DIRECTORY, op_generic_select_entry },
1138 { OP_ENTER_MASK, op_enter_mask },
1139 { OP_EXIT, op_exit },
1140 { OP_GENERIC_SELECT_ENTRY, op_generic_select_entry },
1141 { OP_GOTO_PARENT, op_change_directory },
1142 { OP_LOAD_ACTIVE, op_load_active },
1143 { OP_MAILBOX_LIST, op_mailbox_list },
1144 { OP_RENAME_MAILBOX, op_rename_mailbox },
1145 { OP_SORT, op_sort },
1146 { OP_SORT_REVERSE, op_sort },
1147 { OP_SUBSCRIBE_PATTERN, op_subscribe_pattern },
1148 { OP_TOGGLE_MAILBOXES, op_toggle_mailboxes },
1149 { OP_UNCATCHUP, op_catchup },
1150 { OP_UNSUBSCRIBE_PATTERN, op_subscribe_pattern },
1151 { 0, NULL },
1152 // clang-format on
1153};
1154
1161int browser_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
1162{
1163 // The Dispatcher may be called on any Window in the Dialog
1164 struct MuttWindow *dlg = dialog_find(win);
1165 if (!dlg || !dlg->wdata)
1166 return FR_ERROR;
1167
1168 struct Menu *menu = dlg->wdata;
1169 struct BrowserPrivateData *priv = menu->mdata;
1170 if (!priv)
1171 return FR_ERROR;
1172
1173 int rc = FR_UNKNOWN;
1174 for (size_t i = 0; BrowserFunctions[i].op != OP_NULL; i++)
1175 {
1176 const struct BrowserFunction *fn = &BrowserFunctions[i];
1177 if (fn->op == event->op)
1178 {
1179 rc = fn->function(priv, event);
1180 break;
1181 }
1182 }
1183
1184 return rc;
1185}
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition array.h:355
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
#define ARRAY_FOREACH_FROM(elem, head, from)
Iterate from an index to the end.
Definition array.h:235
#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:231
int imap_browse(const char *path, struct BrowserState *state)
IMAP hook into the folder browser.
Definition browse.c:196
int imap_mailbox_create(const char *path)
Create a new IMAP mailbox.
Definition browse.c:393
int imap_mailbox_rename(const char *path)
Rename a mailbox.
Definition browse.c:448
const struct CompleteOps CompleteMailboxOps
Auto-Completion of Files / Mailboxes.
Definition complete.c:159
struct MenuDefinition * MdBrowser
Browser Menu Definition.
Definition functions.c:64
static const struct MenuOpSeq BrowserDefaultBindings[]
Key bindings for the file Browser Menu.
Definition functions.c:104
void browser_init_keys(struct SubMenu *sm_generic)
Initialise the Browser Keybindings - Implements ::init_keys_api.
Definition functions.c:130
static const struct MenuFuncOp OpBrowser[]
Functions for the file Browser Menu.
Definition functions.c:70
void destroy_state(struct BrowserState *state)
Free the BrowserState.
Definition functions.c:150
int browser_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
Perform a Browser function.
Definition functions.c:1161
static const struct BrowserFunction BrowserFunctions[]
All the NeoMutt functions that the Browser supports.
Definition functions.c:1123
Browser functions.
Select a Mailbox from a list.
void browser_sort(struct BrowserState *state)
Sort the entries in the browser.
Definition sort.c:186
Private state data for the Browser.
Browser sorting functions.
@ BROWSER_SORT_ALPHA
Sort by name.
Definition sort.h:31
@ BROWSER_SORT_UNSORTED
Sort into the raw order.
Definition sort.h:37
@ BROWSER_SORT_COUNT
Sort by total message count.
Definition sort.h:32
@ BROWSER_SORT_DATE
Sort by date.
Definition sort.h:33
@ BROWSER_SORT_NEW
Sort by count of new messages.
Definition sort.h:35
@ BROWSER_SORT_SIZE
Sort by size.
Definition sort.h:36
@ BROWSER_SORT_DESC
Sort by description.
Definition sort.h:34
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.
#define CSR_RESULT(x)
Extract the result code from CSR_* flags.
Definition set.h:53
#define CSR_SUCCESS
Action completed successfully.
Definition set.h:33
#define SORT_REVERSE
Reverse the order of the sort.
Definition sort.h:40
Convenience wrapper for the core headers.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:213
MailboxType
Supported mailbox formats.
Definition mailbox.h:40
@ MUTT_MAILBOX_ERROR
Error occurred examining Mailbox.
Definition mailbox.h:42
@ MUTT_IMAP
'IMAP' Mailbox type
Definition mailbox.h:49
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition mailbox.h:43
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:40
@ FR_DONE
Exit the Dialog.
Definition dispatcher.h:36
@ FR_UNKNOWN
Unknown function.
Definition dispatcher.h:34
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
@ FR_NOT_IMPL
Invalid function - feature not enabled.
Definition dispatcher.h:37
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
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.
void init_menu(struct BrowserState *state, struct Menu *menu, struct Mailbox *m, struct MuttWindow *sbar)
Set up a new menu.
struct Buffer LastDir
Browser: previous selected directory.
void init_state(struct BrowserState *state)
Initialise a browser state.
struct Buffer LastDirBackup
Browser: backup copy of the current directory.
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.
void browser_highlight_default(struct BrowserState *state, struct Menu *menu)
Decide which browser item should be highlighted.
int examine_mailboxes(struct Mailbox *m, struct Menu *menu, struct BrowserState *state)
Get list of mailboxes/subscribed newsgroups.
bool link_is_dir(const char *folder, const char *path)
Does this symlink point to a directory?
Edit a string.
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition wdata.h:42
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition body.c:58
Structs that make up an email.
void mutt_unget_op(int op)
Return an operation to the input buffer.
Definition get.c:133
#define MFF_DEPRECATED
Redraw the pager.
Definition get.h:44
bool OptNews
(pseudo) used to change reader mode
Definition globals.c:53
Global variables.
static int op_generic_select_entry(struct AliasMenuData *mdata, const struct KeyEvent *event)
select the current entry - Implements alias_function_t -
Definition functions.c:248
static int op_sort(struct AliasMenuData *mdata, const struct KeyEvent *event)
sort aliases - Implements alias_function_t -
Definition functions.c:423
static int op_exit(struct AliasMenuData *mdata, const struct KeyEvent *event)
exit this menu - Implements alias_function_t -
Definition functions.c:234
static int op_browser_new_file(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Select a new file in this directory - Implements browser_function_t -.
Definition functions.c:167
static int op_rename_mailbox(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Rename the current mailbox (IMAP only) - Implements browser_function_t -.
Definition functions.c:866
static int op_create_mailbox(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Create a new mailbox (IMAP only) - Implements browser_function_t -.
Definition functions.c:470
static int op_browser_view_file(struct BrowserPrivateData *priv, const struct KeyEvent *event)
View file - Implements browser_function_t -.
Definition functions.c:273
static int op_mailbox_list(struct BrowserPrivateData *priv, const struct KeyEvent *event)
List mailboxes with new mail - Implements browser_function_t -.
Definition functions.c:857
static int op_catchup(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Mark all articles in newsgroup as read - Implements browser_function_t -.
Definition functions.c:318
static int op_browser_subscribe(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Subscribe to current mbox (IMAP/NNTP only) - Implements browser_function_t -.
Definition functions.c:194
static int op_delete_mailbox(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Delete the current mailbox (IMAP only) - Implements browser_function_t -.
Definition functions.c:497
static int op_load_active(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Load list of all newsgroups from NNTP server - Implements browser_function_t -.
Definition functions.c:820
static int op_enter_mask(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Enter a file mask - Implements browser_function_t -.
Definition functions.c:548
static int op_subscribe_pattern(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Subscribe to newsgroups matching a pattern - Implements browser_function_t -.
Definition functions.c:966
static int op_browser_tell(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Display the currently selected file's name - Implements browser_function_t -.
Definition functions.c:249
static int op_browser_toggle_lsub(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Toggle view all/subscribed mailboxes (IMAP only) - Implements browser_function_t -.
Definition functions.c:262
static int op_toggle_mailboxes(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Toggle whether to browse mailboxes or all files - Implements browser_function_t -.
Definition functions.c:1052
static int op_change_directory(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Change directories - Implements browser_function_t -.
Definition functions.c:361
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:463
int mw_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question -.
Definition question.c:62
#define mutt_warning(...)
Definition logging2.h:92
#define mutt_error(...)
Definition logging2.h:94
#define mutt_message(...)
Definition logging2.h:93
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
#define mutt_perror(...)
Definition logging2.h:95
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox?
Definition imap.c:2546
Convenience wrapper for the gui headers.
Read/write command history from/to a file.
@ HC_FILE
Files.
Definition lib.h:58
@ HC_PATTERN
Patterns.
Definition lib.h:59
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:60
IMAP network mailbox.
int imap_subscribe(const char *path, bool subscribe)
Subscribe to a mailbox.
Definition imap.c:1405
int imap_delete_mailbox(struct Mailbox *m, char *path)
Delete a mailbox.
Definition imap.c:611
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:123
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:91
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:107
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:136
Manage keymappings.
@ LL_DEBUG3
Log at debug level 3.
Definition logging2.h:47
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
GUI present the user with a selectable list.
#define MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:60
#define MENU_REDRAW_INDEX
Redraw the index.
Definition lib.h:57
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:188
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:164
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:178
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:665
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:586
int mutt_view_attachment(FILE *fp, struct Body *b, enum ViewAttachMode mode, struct Email *e, struct AttachCtx *actx, struct MuttWindow *win)
View an attachment.
@ 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.
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:867
void expand_path(struct Buffer *buf, bool regex)
Create the canonical path.
Definition muttlib.c:122
Some miscellaneous functions.
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition mx.c:1323
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:846
int nntp_active_fetch(struct NntpAccountData *adata, bool mark_new)
Fetch list of all newsgroups from server.
Definition nntp.c:2038
int nntp_newsrc_parse(struct NntpAccountData *adata)
Parse .newsrc file.
Definition newsrc.c:163
void nntp_newsrc_close(struct NntpAccountData *adata)
Unlock and close .newsrc file.
Definition newsrc.c:119
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition newsrc.c:1232
int nntp_newsrc_update(struct NntpAccountData *adata)
Update .newsrc file.
Definition newsrc.c:442
struct NntpMboxData * mutt_newsgroup_subscribe(struct NntpAccountData *adata, char *group)
Subscribe newsgroup.
Definition newsrc.c:1181
struct NntpMboxData * mutt_newsgroup_uncatchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Uncatchup newsgroup.
Definition newsrc.c:1271
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
Definition nntp.c:74
struct NntpMboxData * mutt_newsgroup_unsubscribe(struct NntpAccountData *adata, char *group)
Unsubscribe newsgroup.
Definition newsrc.c:1205
Nntp-specific Mailbox data.
const struct CompleteOps CompletePatternOps
Auto-Completion of Patterns.
Definition complete.c:98
Match patterns to emails.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
@ 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:329
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition regex3.h:49
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:613
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:51
int op
Op code, e.g. OP_MAIN_LIMIT.
Definition functions.h:52
browser_function_t function
Function to call.
Definition functions.h:53
Private state data for the Browser.
char *** files
Array of selected files.
struct Menu * menu
Menu.
struct Buffer * prefix
Folder prefix string.
struct Buffer * old_last_dir
Previous to last dir.
bool kill_prefix
Prefix is in use.
bool done
Should we close the Dialog?
int last_selected_mailbox
Index of last selected Mailbox.
int * numfiles
Number of selected files.
struct Mailbox * mailbox
Mailbox.
struct BrowserState state
State containing list of files/dir/mailboxes.
struct Buffer * file
Buffer for the result.
bool multiple
Allow multiple selections.
struct MuttWindow * sbar
Status Bar.
char goto_swapper[PATH_MAX]
Saved path after <goto-folder>
State of the file/mailbox browser.
Definition lib.h:145
char * folder
Folder name.
Definition lib.h:148
bool is_mailbox_list
Viewing mailboxes.
Definition lib.h:149
struct BrowserEntryArray entry
Array of files / dirs / mailboxes.
Definition lib.h:146
bool imap_browse
IMAP folder.
Definition lib.h:147
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:39
Browser entry representing a folder/dir.
Definition lib.h:79
bool selectable
Folder can be selected.
Definition lib.h:97
char delim
Path delimiter.
Definition lib.h:94
bool imap
This is an IMAP folder.
Definition lib.h:96
char * name
Name of file/dir/mailbox.
Definition lib.h:87
bool tagged
Folder is tagged.
Definition lib.h:103
char * desc
Description of mailbox.
Definition lib.h:88
mode_t mode
File permissions.
Definition lib.h:80
bool inferiors
Folder has children.
Definition lib.h:98
An event such as a keypress.
Definition get.h:50
int op
Function opcode, e.g. OP_HELP.
Definition get.h:52
void * mdata
Driver specific data.
Definition mailbox.h:131
Functions for a Dialog or Window.
Definition menu.h:80
Mapping between a function and an operation.
Definition menu.h:38
Mapping between an operation and a key sequence.
Definition menu.h:48
Definition lib.h:80
struct MuttWindow * win
Window holding the Menu.
Definition lib.h:88
int num_tagged
Number of tagged entries.
Definition lib.h:95
void * mdata
Private data.
Definition lib.h:149
bool tag_prefix
User has pressed <tag-prefix>
Definition lib.h:86
void * wdata
Private data.
Container for Accounts, Notifications.
Definition neomutt.h:41
char * home_dir
User's home directory.
Definition neomutt.h:56
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
NNTP-specific Account data -.
Definition adata.h:36
struct NntpMboxData ** groups_list
List of newsgroups.
Definition adata.h:60
unsigned int groups_num
Number of newsgroups.
Definition adata.h:58
NNTP-specific Mailbox data -.
Definition mdata.h:34
bool deleted
Newsgroup is deleted.
Definition mdata.h:45
struct NntpAccountData * adata
Account data.
Definition mdata.h:48
Cached regular expression.
Definition regex3.h:85
char * pattern
printable version
Definition regex3.h:86
Collection of related functions.
Definition menu.h:68
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:303
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:392
@ MENU_BROWSER
General file/mailbox browser.
Definition type.h:39
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