NeoMutt  2024-12-12-19-ge4b57e
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" // IWYU pragma: keep
61#include "nntp/mdata.h" // IWYU pragma: keep
62#include "private_data.h"
63#include "sort.h"
64#endif
65
66static int op_subscribe_pattern(struct BrowserPrivateData *priv, int op);
67
68// clang-format off
72const struct MenuFuncOp OpBrowser[] = { /* map: browser */
73 { "catchup", OP_CATCHUP },
74 { "change-dir", OP_CHANGE_DIRECTORY },
75 { "check-new", OP_CHECK_NEW },
76 { "create-mailbox", OP_CREATE_MAILBOX },
77 { "delete-mailbox", OP_DELETE_MAILBOX },
78 { "descend-directory", OP_DESCEND_DIRECTORY },
79 { "display-filename", OP_BROWSER_TELL },
80 { "enter-mask", OP_ENTER_MASK },
81 { "exit", OP_EXIT },
82 { "goto-folder", OP_BROWSER_GOTO_FOLDER },
83 { "goto-parent", OP_GOTO_PARENT },
84 { "mailbox-list", OP_MAILBOX_LIST },
85 { "reload-active", OP_LOAD_ACTIVE },
86 { "rename-mailbox", OP_RENAME_MAILBOX },
87 { "select-new", OP_BROWSER_NEW_FILE },
88 { "sort", OP_SORT },
89 { "sort-reverse", OP_SORT_REVERSE },
90 { "subscribe", OP_BROWSER_SUBSCRIBE },
91 { "subscribe-pattern", OP_SUBSCRIBE_PATTERN },
92 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES },
93 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB },
94 { "uncatchup", OP_UNCATCHUP },
95 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE },
96 { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN },
97 { "view-file", OP_BROWSER_VIEW_FILE },
98 // Deprecated
99 { "buffy-list", OP_MAILBOX_LIST },
100 { NULL, 0 },
101};
102
106const struct MenuOpSeq BrowserDefaultBindings[] = { /* map: browser */
107 { OP_BROWSER_GOTO_FOLDER, "=" },
108 { OP_BROWSER_NEW_FILE, "N" },
109 { OP_BROWSER_SUBSCRIBE, "s" },
110 { OP_BROWSER_TELL, "@" },
111 { OP_BROWSER_TOGGLE_LSUB, "T" },
112 { OP_BROWSER_UNSUBSCRIBE, "u" },
113 { OP_BROWSER_VIEW_FILE, " " }, // <Space>
114 { OP_CHANGE_DIRECTORY, "c" },
115 { OP_CREATE_MAILBOX, "C" },
116 { OP_DELETE_MAILBOX, "d" },
117 { OP_ENTER_MASK, "m" },
118 { OP_EXIT, "q" },
119 { OP_GOTO_PARENT, "p" },
120 { OP_MAILBOX_LIST, "." },
121 { OP_RENAME_MAILBOX, "r" },
122 { OP_SORT, "o" },
123 { OP_SORT_REVERSE, "O" },
124 { OP_TOGGLE_MAILBOXES, "\t" }, // <Tab>
125 { 0, NULL },
126};
127// clang-format on
128
135void destroy_state(struct BrowserState *state)
136{
137 struct FolderFile *ff = NULL;
138 ARRAY_FOREACH(ff, &state->entry)
139 {
140 FREE(&ff->name);
141 FREE(&ff->desc);
142 }
143 ARRAY_FREE(&state->entry);
144 FREE(&state->folder);
145}
146
147// -----------------------------------------------------------------------------
148
152static int op_browser_new_file(struct BrowserPrivateData *priv, int op)
153{
154 struct Buffer *buf = buf_pool_get();
155 buf_printf(buf, "%s/", buf_string(&LastDir));
156
157 struct FileCompletionData cdata = { false, priv->mailbox, NULL, NULL };
158 const int rc = mw_get_field(_("New file name: "), buf, MUTT_COMP_NO_FLAGS,
159 HC_FILE, &CompleteMailboxOps, &cdata);
160 if (rc != 0)
161 {
162 buf_pool_release(&buf);
163 return FR_NO_ACTION;
164 }
165
166 buf_copy(priv->file, buf);
167 buf_pool_release(&buf);
168 priv->done = true;
169 return FR_DONE;
170}
171
179static int op_browser_subscribe(struct BrowserPrivateData *priv, int op)
180{
181 if (OptNews)
182 {
184 int index = menu_get_index(priv->menu);
185
186 if (ARRAY_EMPTY(&priv->state.entry))
187 {
188 mutt_error(_("No newsgroups match the mask"));
189 return FR_ERROR;
190 }
191
192 int rc = nntp_newsrc_parse(adata);
193 if (rc < 0)
194 return FR_ERROR;
195
196 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
197 if (op == OP_BROWSER_SUBSCRIBE)
198 mutt_newsgroup_subscribe(adata, ff->name);
199 else
201
202 menu_set_index(priv->menu, index + 1);
203
204 if (rc > 0)
206 nntp_newsrc_update(adata);
207 nntp_clear_cache(adata);
208 nntp_newsrc_close(adata);
209 }
210 else
211 {
212 if (ARRAY_EMPTY(&priv->state.entry))
213 {
214 mutt_error(_("There are no mailboxes"));
215 return FR_ERROR;
216 }
217
218 struct Buffer *buf = buf_pool_get();
219 int index = menu_get_index(priv->menu);
220 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
221 buf_strcpy(buf, ff->name);
222 buf_expand_path(buf);
223 imap_subscribe(buf_string(buf), (op == OP_BROWSER_SUBSCRIBE));
224 buf_pool_release(&buf);
225 }
226 return FR_SUCCESS;
227}
228
232static int op_browser_tell(struct BrowserPrivateData *priv, int op)
233{
234 int index = menu_get_index(priv->menu);
235 if (ARRAY_EMPTY(&priv->state.entry))
236 return FR_ERROR;
237
238 mutt_message("%s", ARRAY_GET(&priv->state.entry, index)->name);
239 return FR_SUCCESS;
240}
241
245static int op_browser_toggle_lsub(struct BrowserPrivateData *priv, int op)
246{
247 bool_str_toggle(NeoMutt->sub, "imap_list_subscribed", NULL);
248
249 mutt_unget_op(OP_CHECK_NEW);
250 return FR_SUCCESS;
251}
252
256static int op_browser_view_file(struct BrowserPrivateData *priv, int op)
257{
258 if (ARRAY_EMPTY(&priv->state.entry))
259 {
260 mutt_error(_("No files match the file mask"));
261 return FR_ERROR;
262 }
263
264 int index = menu_get_index(priv->menu);
265 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
266 if (ff->selectable)
267 {
268 buf_strcpy(priv->file, ff->name);
269 priv->done = true;
270 return FR_DONE;
271 }
272 else if (S_ISDIR(ff->mode) ||
273 (S_ISLNK(ff->mode) && link_is_dir(buf_string(&LastDir), ff->name)))
274 {
275 mutt_error(_("Can't view a directory"));
276 return FR_ERROR;
277 }
278 else
279 {
280 struct Buffer *path = buf_pool_get();
282 struct Body *b = mutt_make_file_attach(buf_string(path), NeoMutt->sub);
283 if (b)
284 {
285 mutt_view_attachment(NULL, b, MUTT_VA_REGULAR, NULL, NULL, priv->menu->win);
286 mutt_body_free(&b);
288 }
289 else
290 {
291 mutt_error(_("Error trying to view file"));
292 }
293 buf_pool_release(&path);
294 }
295 return FR_ERROR;
296}
297
301static int op_catchup(struct BrowserPrivateData *priv, int op)
302{
303 if (!OptNews)
304 return FR_NOT_IMPL;
305
306 struct NntpMboxData *mdata = NULL;
307
309 if (rc < 0)
310 return FR_ERROR;
311
312 int index = menu_get_index(priv->menu);
313 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
314 if (op == OP_CATCHUP)
316 else
318
319 if (mdata)
320 {
322 index = menu_get_index(priv->menu) + 1;
323 if (index < priv->menu->max)
324 menu_set_index(priv->menu, index);
325 }
326
327 if (rc != 0)
329
331 return FR_ERROR;
332}
333
341static int op_change_directory(struct BrowserPrivateData *priv, int op)
342{
343 if (OptNews)
344 return FR_NOT_IMPL;
345
346 struct Buffer *buf = buf_pool_get();
347 buf_copy(buf, &LastDir);
348 if (!priv->state.imap_browse)
349 {
350 /* add '/' at the end of the directory name if not already there */
351 size_t len = buf_len(buf);
352 if ((len > 0) && (buf_string(&LastDir)[len - 1] != '/'))
353 buf_addch(buf, '/');
354 }
355
356 if (op == OP_CHANGE_DIRECTORY)
357 {
358 struct FileCompletionData cdata = { false, priv->mailbox, NULL, NULL };
359 int rc = mw_get_field(_("Chdir to: "), buf, MUTT_COMP_NO_FLAGS, HC_FILE,
360 &CompleteMailboxOps, &cdata);
361 if ((rc != 0) && buf_is_empty(buf))
362 {
363 buf_pool_release(&buf);
364 return FR_NO_ACTION;
365 }
366 }
367 else if (op == OP_GOTO_PARENT)
368 {
369 mutt_get_parent_path(buf_string(buf), buf->data, buf->dsize);
370 }
371
372 if (!buf_is_empty(buf))
373 {
374 priv->state.is_mailbox_list = false;
375 buf_expand_path(buf);
376 if (imap_path_probe(buf_string(buf), NULL) == MUTT_IMAP)
377 {
378 buf_copy(&LastDir, buf);
379 destroy_state(&priv->state);
380 init_state(&priv->state);
381 priv->state.imap_browse = true;
383 browser_sort(&priv->state);
384 browser_highlight_default(&priv->state, priv->menu);
385 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
386 }
387 else
388 {
389 if (buf_string(buf)[0] != '/')
390 {
391 /* in case dir is relative, make it relative to LastDir,
392 * not current working dir */
393 struct Buffer *tmp = buf_pool_get();
395 buf_copy(buf, tmp);
396 buf_pool_release(&tmp);
397 }
398 /* Resolve path from <chdir>
399 * Avoids buildup such as /a/b/../../c
400 * Symlinks are always unraveled to keep code simple */
401 if (mutt_path_realpath(buf) == 0)
402 {
403 buf_pool_release(&buf);
404 return FR_ERROR;
405 }
406
407 struct stat st = { 0 };
408 if (stat(buf_string(buf), &st) == 0)
409 {
410 if (S_ISDIR(st.st_mode))
411 {
412 destroy_state(&priv->state);
413 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
414 buf_string(buf), buf_string(priv->prefix)) == 0)
415 {
416 buf_copy(&LastDir, buf);
417 }
418 else
419 {
420 mutt_error(_("Error scanning directory"));
421 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
422 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
423 {
424 priv->done = true;
425 return FR_ERROR;
426 }
427 }
428 browser_highlight_default(&priv->state, priv->menu);
429 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
430 }
431 else
432 {
433 mutt_error(_("%s is not a directory"), buf_string(buf));
434 }
435 }
436 else
437 {
438 mutt_perror("%s", buf_string(buf));
439 }
440 }
441 }
442 buf_pool_release(&buf);
443 return FR_ERROR;
444}
445
449static int op_create_mailbox(struct BrowserPrivateData *priv, int op)
450{
451 if (!priv->state.imap_browse)
452 {
453 mutt_error(_("Create is only supported for IMAP mailboxes"));
454 return FR_ERROR;
455 }
456
458 return FR_ERROR;
459
460 /* TODO: find a way to detect if the new folder would appear in
461 * this window, and insert it without starting over. */
462 destroy_state(&priv->state);
463 init_state(&priv->state);
464 priv->state.imap_browse = true;
466 browser_sort(&priv->state);
467 browser_highlight_default(&priv->state, priv->menu);
468 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
469
470 return FR_SUCCESS;
471}
472
476static int op_delete_mailbox(struct BrowserPrivateData *priv, int op)
477{
478 int index = menu_get_index(priv->menu);
479 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
480 if (!ff->imap)
481 {
482 mutt_error(_("Delete is only supported for IMAP mailboxes"));
483 return FR_ERROR;
484 }
485
486 char msg[128] = { 0 };
487
488 // TODO(sileht): It could be better to select INBOX instead. But I
489 // don't want to manipulate Mailboxes/mailbox->account here for now.
490 // Let's just protect neomutt against crash for now. #1417
491 if (mutt_str_equal(mailbox_path(priv->mailbox), ff->name))
492 {
493 mutt_error(_("Can't delete currently selected mailbox"));
494 return FR_ERROR;
495 }
496
497 snprintf(msg, sizeof(msg), _("Really delete mailbox \"%s\"?"), ff->name);
498 if (query_yesorno(msg, MUTT_NO) != MUTT_YES)
499 {
500 mutt_message(_("Mailbox not deleted"));
501 return FR_NO_ACTION;
502 }
503
504 if (imap_delete_mailbox(priv->mailbox, ff->name) != 0)
505 {
506 mutt_error(_("Mailbox deletion failed"));
507 return FR_ERROR;
508 }
509
510 /* free the mailbox from the browser */
511 FREE(&ff->name);
512 FREE(&ff->desc);
513 /* and move all other entries up */
514 ARRAY_REMOVE(&priv->state.entry, ff);
515 mutt_message(_("Mailbox deleted"));
516 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
517
518 return FR_SUCCESS;
519}
520
524static int op_enter_mask(struct BrowserPrivateData *priv, int op)
525{
526 const struct Regex *c_mask = cs_subset_regex(NeoMutt->sub, "mask");
527 struct Buffer *buf = buf_pool_get();
528 buf_strcpy(buf, c_mask ? c_mask->pattern : NULL);
529 if (mw_get_field(_("File Mask: "), buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0)
530 {
531 buf_pool_release(&buf);
532 return FR_NO_ACTION;
533 }
534
535 buf_fix_dptr(buf);
536
537 priv->state.is_mailbox_list = false;
538 /* assume that the user wants to see everything */
539 if (buf_is_empty(buf))
540 buf_strcpy(buf, ".");
541
542 struct Buffer *errmsg = buf_pool_get();
543 int rc = cs_subset_str_string_set(NeoMutt->sub, "mask", buf_string(buf), errmsg);
544 buf_pool_release(&buf);
545 if (CSR_RESULT(rc) != CSR_SUCCESS)
546 {
547 if (!buf_is_empty(errmsg))
548 {
549 mutt_error("%s", buf_string(errmsg));
550 buf_pool_release(&errmsg);
551 }
552 return FR_ERROR;
553 }
554 buf_pool_release(&errmsg);
555
556 destroy_state(&priv->state);
557 if (priv->state.imap_browse)
558 {
559 init_state(&priv->state);
560 priv->state.imap_browse = true;
562 browser_sort(&priv->state);
563 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
564 }
565 else if (examine_directory(priv->mailbox, priv->menu, &priv->state,
566 buf_string(&LastDir), NULL) == 0)
567 {
568 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
569 }
570 else
571 {
572 mutt_error(_("Error scanning directory"));
573 priv->done = true;
574 return FR_ERROR;
575 }
576 priv->kill_prefix = false;
577 if (ARRAY_EMPTY(&priv->state.entry))
578 {
579 mutt_error(_("No files match the file mask"));
580 return FR_ERROR;
581 }
582 return FR_SUCCESS;
583}
584
588static int op_exit(struct BrowserPrivateData *priv, int op)
589{
590 if (priv->multiple)
591 {
592 char **tfiles = NULL;
593
594 if (priv->menu->num_tagged)
595 {
596 *priv->numfiles = priv->menu->num_tagged;
597 tfiles = MUTT_MEM_CALLOC(*priv->numfiles, char *);
598 size_t j = 0;
599 struct FolderFile *ff = NULL;
600 ARRAY_FOREACH(ff, &priv->state.entry)
601 {
602 if (ff->tagged)
603 {
604 struct Buffer *buf = buf_pool_get();
606 buf_expand_path(buf);
607 tfiles[j++] = buf_strdup(buf);
608 buf_pool_release(&buf);
609 }
610 }
611 *priv->files = tfiles;
612 }
613 else if (!buf_is_empty(priv->file)) /* no tagged entries. return selected entry */
614 {
615 *priv->numfiles = 1;
616 tfiles = MUTT_MEM_CALLOC(*priv->numfiles, char *);
617 buf_expand_path(priv->file);
618 tfiles[0] = buf_strdup(priv->file);
619 *priv->files = tfiles;
620 }
621 }
622
623 priv->done = true;
624 return FR_DONE;
625}
626
634static int op_generic_select_entry(struct BrowserPrivateData *priv, int op)
635{
636 if (ARRAY_EMPTY(&priv->state.entry))
637 {
638 mutt_error(_("No files match the file mask"));
639 return FR_ERROR;
640 }
641
642 int index = menu_get_index(priv->menu);
643 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
644 if (S_ISDIR(ff->mode) ||
645 (S_ISLNK(ff->mode) && link_is_dir(buf_string(&LastDir), ff->name)) || ff->inferiors)
646 {
647 /* make sure this isn't a MH or maildir mailbox */
648 struct Buffer *buf = buf_pool_get();
649 if (priv->state.is_mailbox_list)
650 {
651 buf_strcpy(buf, ff->name);
652 buf_expand_path(buf);
653 }
654 else if (priv->state.imap_browse)
655 {
656 buf_strcpy(buf, ff->name);
657 }
658 else
659 {
661 }
662
663 enum MailboxType type = mx_path_probe(buf_string(buf));
664 buf_pool_release(&buf);
665
666 if ((op == OP_DESCEND_DIRECTORY) || (type == MUTT_MAILBOX_ERROR) ||
667 (type == MUTT_UNKNOWN) || ff->inferiors)
668 {
669 /* save the old directory */
671
672 if (mutt_str_equal(ff->name, ".."))
673 {
674 size_t lastdirlen = buf_len(&LastDir);
675 if ((lastdirlen > 1) && mutt_str_equal("..", buf_string(&LastDir) + lastdirlen - 2))
676 {
677 buf_addstr(&LastDir, "/..");
678 }
679 else
680 {
681 char *p = NULL;
682 if (lastdirlen > 1)
683 p = strrchr(LastDir.data + 1, '/');
684
685 if (p)
686 {
687 *p = '\0';
689 }
690 else
691 {
692 if (buf_string(&LastDir)[0] == '/')
693 buf_strcpy(&LastDir, "/");
694 else
695 buf_addstr(&LastDir, "/..");
696 }
697 }
698 }
699 else if (priv->state.is_mailbox_list)
700 {
701 buf_strcpy(&LastDir, ff->name);
703 }
704 else if (priv->state.imap_browse)
705 {
706 buf_strcpy(&LastDir, ff->name);
707 /* tack on delimiter here */
708
709 /* special case "" needs no delimiter */
710 struct Url *url = url_parse(ff->name);
711 if (url && url->path && (ff->delim != '\0'))
712 {
713 buf_addch(&LastDir, ff->delim);
714 }
715 url_free(&url);
716 }
717 else
718 {
719 struct Buffer *tmp = buf_pool_get();
721 buf_copy(&LastDir, tmp);
722 buf_pool_release(&tmp);
723 }
724
725 destroy_state(&priv->state);
726 if (priv->kill_prefix)
727 {
728 buf_reset(priv->prefix);
729 priv->kill_prefix = false;
730 }
731 priv->state.is_mailbox_list = false;
732 if (priv->state.imap_browse)
733 {
734 init_state(&priv->state);
735 priv->state.imap_browse = true;
737 browser_sort(&priv->state);
738 }
739 else
740 {
741 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
742 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
743 {
744 /* try to restore the old values */
746 if (examine_directory(priv->mailbox, priv->menu, &priv->state,
747 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
748 {
750 priv->done = true;
751 return FR_DONE;
752 }
753 }
754 /* resolve paths navigated from GUI */
755 if (mutt_path_realpath(&LastDir) == 0)
756 return FR_ERROR;
757 }
758
759 browser_highlight_default(&priv->state, priv->menu);
760 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
761 priv->goto_swapper[0] = '\0';
762 return FR_SUCCESS;
763 }
764 }
765 else if (op == OP_DESCEND_DIRECTORY)
766 {
767 mutt_error(_("%s is not a directory"), ARRAY_GET(&priv->state.entry, index)->name);
768 return FR_ERROR;
769 }
770
771 if (priv->state.is_mailbox_list || OptNews)
772 {
773 buf_strcpy(priv->file, ff->name);
774 buf_expand_path(priv->file);
775 }
776 else if (priv->state.imap_browse)
777 {
778 buf_strcpy(priv->file, ff->name);
779 }
780 else
781 {
783 }
784
785 return op_exit(priv, op);
786}
787
791static int op_load_active(struct BrowserPrivateData *priv, int op)
792{
793 if (!OptNews)
794 return FR_NOT_IMPL;
795
797
798 if (nntp_newsrc_parse(adata) < 0)
799 return FR_ERROR;
800
801 for (size_t i = 0; i < adata->groups_num; i++)
802 {
803 struct NntpMboxData *mdata = adata->groups_list[i];
804 if (mdata)
805 mdata->deleted = true;
806 }
810
811 destroy_state(&priv->state);
812 if (priv->state.is_mailbox_list)
813 {
814 examine_mailboxes(priv->mailbox, priv->menu, &priv->state);
815 }
816 else
817 {
818 if (examine_directory(priv->mailbox, priv->menu, &priv->state, NULL, NULL) == -1)
819 return FR_ERROR;
820 }
821 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
822 return FR_SUCCESS;
823}
824
828static int op_mailbox_list(struct BrowserPrivateData *priv, int op)
829{
831 return FR_SUCCESS;
832}
833
837static int op_rename_mailbox(struct BrowserPrivateData *priv, int op)
838{
839 int index = menu_get_index(priv->menu);
840 struct FolderFile *ff = ARRAY_GET(&priv->state.entry, index);
841 if (!ff->imap)
842 {
843 mutt_error(_("Rename is only supported for IMAP mailboxes"));
844 return FR_ERROR;
845 }
846
847 if (imap_mailbox_rename(ff->name) < 0)
848 return FR_ERROR;
849
850 destroy_state(&priv->state);
851 init_state(&priv->state);
852 priv->state.imap_browse = true;
854 browser_sort(&priv->state);
855 browser_highlight_default(&priv->state, priv->menu);
856 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
857
858 return FR_SUCCESS;
859}
860
868static int op_sort(struct BrowserPrivateData *priv, int op)
869{
870 bool resort = true;
871 int sort = -1;
872 int reverse = (op == OP_SORT_REVERSE);
873
874 switch (mw_multi_choice((reverse) ?
875 /* L10N: The highlighted letters must match the "Sort" options */
876 _("Reverse sort by (d)ate, (a)lpha, si(z)e, d(e)scription, (c)ount, ne(w) count, or do(n)'t sort?") :
877 /* L10N: The highlighted letters must match the "Reverse Sort" options */
878 _("Sort by (d)ate, (a)lpha, si(z)e, d(e)scription, (c)ount, ne(w) count, or do(n)'t sort?"),
879 /* L10N: These must match the highlighted letters from "Sort" and "Reverse Sort" */
880 _("dazecwn")))
881 {
882 case -1: /* abort */
883 resort = false;
884 break;
885
886 case 1: /* (d)ate */
887 sort = BROWSER_SORT_DATE;
888 break;
889
890 case 2: /* (a)lpha */
891 sort = BROWSER_SORT_ALPHA;
892 break;
893
894 case 3: /* si(z)e */
895 sort = BROWSER_SORT_SIZE;
896 break;
897
898 case 4: /* d(e)scription */
899 sort = BROWSER_SORT_DESC;
900 break;
901
902 case 5: /* (c)ount */
903 sort = BROWSER_SORT_COUNT;
904 break;
905
906 case 6: /* ne(w) count */
907 sort = BROWSER_SORT_NEW;
908 break;
909
910 case 7: /* do(n)'t sort */
912 break;
913 }
914
915 if (!resort)
916 return FR_NO_ACTION;
917
918 sort |= reverse ? SORT_REVERSE : 0;
919 cs_subset_str_native_set(NeoMutt->sub, "browser_sort", sort, NULL);
920 browser_sort(&priv->state);
921 browser_highlight_default(&priv->state, priv->menu);
923 return FR_SUCCESS;
924}
925
933static int op_subscribe_pattern(struct BrowserPrivateData *priv, int op)
934{
935 if (!OptNews)
936 return FR_NOT_IMPL;
937
939 regex_t rx = { 0 };
940 int index = menu_get_index(priv->menu);
941
942 char tmp2[256] = { 0 };
943
944 struct Buffer *buf = buf_pool_get();
945 if (op == OP_SUBSCRIBE_PATTERN)
946 snprintf(tmp2, sizeof(tmp2), _("Subscribe pattern: "));
947 else
948 snprintf(tmp2, sizeof(tmp2), _("Unsubscribe pattern: "));
949 /* buf comes from the buffer pool, so defaults to size 1024 */
950 if ((mw_get_field(tmp2, buf, MUTT_COMP_NO_FLAGS, HC_PATTERN, &CompletePatternOps, NULL) != 0) ||
951 buf_is_empty(buf))
952 {
953 buf_pool_release(&buf);
954 return FR_NO_ACTION;
955 }
956
957 int err = REG_COMP(&rx, buf->data, REG_NOSUB);
958 if (err != 0)
959 {
960 regerror(err, &rx, buf->data, buf->dsize);
961 regfree(&rx);
962 mutt_error("%s", buf_string(buf));
963 buf_pool_release(&buf);
964 return FR_ERROR;
965 }
967 index = 0;
968 buf_pool_release(&buf);
969
970 int rc = nntp_newsrc_parse(adata);
971 if (rc < 0)
972 return FR_ERROR;
973
974 struct FolderFile *ff = NULL;
975 ARRAY_FOREACH_FROM(ff, &priv->state.entry, index)
976 {
977 if (regexec(&rx, ff->name, 0, NULL, 0) == 0)
978 {
979 if (op == OP_SUBSCRIBE_PATTERN)
980 mutt_newsgroup_subscribe(adata, ff->name);
981 else
983 }
984 }
985
986 if (op == OP_SUBSCRIBE_PATTERN)
987 {
988 for (size_t j = 0; j < adata->groups_num; j++)
989 {
990 struct NntpMboxData *mdata = adata->groups_list[j];
991 if (mdata && mdata->group && !mdata->subscribed)
992 {
993 if (regexec(&rx, mdata->group, 0, NULL, 0) == 0)
994 {
996 browser_add_folder(priv->menu, &priv->state, mdata->group, NULL, NULL, NULL, mdata);
997 }
998 }
999 }
1000 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
1001 }
1002 if (rc > 0)
1007 regfree(&rx);
1008 return FR_SUCCESS;
1009}
1010
1018static int op_toggle_mailboxes(struct BrowserPrivateData *priv, int op)
1019{
1020 if (priv->state.is_mailbox_list)
1021 {
1023 }
1024
1025 if (op == OP_TOGGLE_MAILBOXES)
1026 {
1028 }
1029
1030 if (op == OP_BROWSER_GOTO_FOLDER)
1031 {
1032 /* When in mailboxes mode, disables this feature */
1033 const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
1034 if (c_folder)
1035 {
1036 mutt_debug(LL_DEBUG3, "= hit! Folder: %s, LastDir: %s\n", c_folder,
1038 if (priv->goto_swapper[0] == '\0')
1039 {
1040 if (!mutt_str_equal(buf_string(&LastDir), c_folder))
1041 {
1042 /* Stores into goto_swapper LastDir, and swaps to `$folder` */
1043 mutt_str_copy(priv->goto_swapper, buf_string(&LastDir), sizeof(priv->goto_swapper));
1045 buf_strcpy(&LastDir, c_folder);
1046 }
1047 }
1048 else
1049 {
1052 priv->goto_swapper[0] = '\0';
1053 }
1054 }
1055 }
1056 destroy_state(&priv->state);
1057 buf_reset(priv->prefix);
1058 priv->kill_prefix = false;
1059
1060 if (priv->state.is_mailbox_list)
1061 {
1062 examine_mailboxes(priv->mailbox, priv->menu, &priv->state);
1063 }
1064 else if (imap_path_probe(buf_string(&LastDir), NULL) == MUTT_IMAP)
1065 {
1066 init_state(&priv->state);
1067 priv->state.imap_browse = true;
1069 browser_sort(&priv->state);
1070 }
1071 else if (examine_directory(priv->mailbox, priv->menu, &priv->state,
1072 buf_string(&LastDir), buf_string(priv->prefix)) == -1)
1073 {
1074 priv->done = true;
1075 return FR_ERROR;
1076 }
1077 init_menu(&priv->state, priv->menu, priv->mailbox, priv->sbar);
1078 if (priv->state.is_mailbox_list)
1080 return FR_ERROR;
1081}
1082
1083// -----------------------------------------------------------------------------
1084
1088static const struct BrowserFunction BrowserFunctions[] = {
1089 // clang-format off
1090 { OP_BROWSER_GOTO_FOLDER, op_toggle_mailboxes },
1091 { OP_BROWSER_NEW_FILE, op_browser_new_file },
1092 { OP_BROWSER_SUBSCRIBE, op_browser_subscribe },
1093 { OP_BROWSER_TELL, op_browser_tell },
1094 { OP_BROWSER_TOGGLE_LSUB, op_browser_toggle_lsub },
1095 { OP_BROWSER_UNSUBSCRIBE, op_browser_subscribe },
1096 { OP_BROWSER_VIEW_FILE, op_browser_view_file },
1097 { OP_CATCHUP, op_catchup },
1098 { OP_CHANGE_DIRECTORY, op_change_directory },
1099 { OP_CHECK_NEW, op_toggle_mailboxes },
1100 { OP_CREATE_MAILBOX, op_create_mailbox },
1101 { OP_DELETE_MAILBOX, op_delete_mailbox },
1102 { OP_DESCEND_DIRECTORY, op_generic_select_entry },
1103 { OP_ENTER_MASK, op_enter_mask },
1104 { OP_EXIT, op_exit },
1105 { OP_GENERIC_SELECT_ENTRY, op_generic_select_entry },
1106 { OP_GOTO_PARENT, op_change_directory },
1107 { OP_LOAD_ACTIVE, op_load_active },
1108 { OP_MAILBOX_LIST, op_mailbox_list },
1109 { OP_RENAME_MAILBOX, op_rename_mailbox },
1110 { OP_SORT, op_sort },
1111 { OP_SORT_REVERSE, op_sort },
1112 { OP_SUBSCRIBE_PATTERN, op_subscribe_pattern },
1113 { OP_TOGGLE_MAILBOXES, op_toggle_mailboxes },
1114 { OP_UNCATCHUP, op_catchup },
1115 { OP_UNSUBSCRIBE_PATTERN, op_subscribe_pattern },
1116 { 0, NULL },
1117 // clang-format on
1118};
1119
1127{
1128 // The Dispatcher may be called on any Window in the Dialog
1129 struct MuttWindow *dlg = dialog_find(win);
1130 if (!dlg || !dlg->wdata)
1131 return FR_ERROR;
1132
1133 struct Menu *menu = dlg->wdata;
1134 struct BrowserPrivateData *priv = menu->mdata;
1135 if (!priv)
1136 return FR_ERROR;
1137
1138 int rc = FR_UNKNOWN;
1139 for (size_t i = 0; BrowserFunctions[i].op != OP_NULL; i++)
1140 {
1141 const struct BrowserFunction *fn = &BrowserFunctions[i];
1142 if (fn->op == op)
1143 {
1144 rc = fn->function(priv, op);
1145 break;
1146 }
1147 }
1148
1149 return rc;
1150}
#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
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
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:1126
const struct MenuOpSeq BrowserDefaultBindings[]
Key bindings for the file Browser Menu.
Definition: functions.c:106
const struct MenuFuncOp OpBrowser[]
Functions for the file Browser Menu.
Definition: functions.c:72
void destroy_state(struct BrowserState *state)
Free the BrowserState.
Definition: functions.c:135
static const struct BrowserFunction BrowserFunctions[]
All the NeoMutt functions that the Browser supports.
Definition: functions.c:1088
void browser_sort(struct BrowserState *state)
Sort the entries in the browser.
Definition: sort.c:186
@ BROWSER_SORT_ALPHA
Sort alphabetically 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.
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
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort.h:39
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:265
void init_menu(struct BrowserState *state, struct Menu *menu, struct Mailbox *m, struct MuttWindow *sbar)
Set up a new menu.
Definition: dlg_browser.c:585
struct Buffer LastDir
Browser: previous selected directory.
Definition: dlg_browser.c:136
void init_state(struct BrowserState *state)
Initialise a browser state.
Definition: dlg_browser.c:248
struct Buffer LastDirBackup
Browser: backup copy of the current directory.
Definition: dlg_browser.c:138
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:198
void browser_highlight_default(struct BrowserState *state, struct Menu *menu)
Decide which browser item should be highlighted.
Definition: dlg_browser.c:559
int examine_mailboxes(struct Mailbox *m, struct Menu *menu, struct BrowserState *state)
Get list of mailboxes/subscribed newsgroups.
Definition: dlg_browser.c:392
bool link_is_dir(const char *folder, const char *path)
Does this symlink point to a directory?
Definition: dlg_browser.c:172
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:215
static int op_exit(struct AliasMenuData *mdata, int op)
exit this menu - Implements alias_function_t -
Definition: functions.c:201
static int op_sort(struct AliasMenuData *mdata, int op)
sort aliases - Implements alias_function_t -
Definition: functions.c:390
static int op_browser_view_file(struct BrowserPrivateData *priv, int op)
View file - Implements browser_function_t -.
Definition: functions.c:256
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:152
static int op_enter_mask(struct BrowserPrivateData *priv, int op)
Enter a file mask - Implements browser_function_t -.
Definition: functions.c:524
static int op_subscribe_pattern(struct BrowserPrivateData *priv, int op)
Subscribe to newsgroups matching a pattern - Implements browser_function_t -.
Definition: functions.c:933
static int op_catchup(struct BrowserPrivateData *priv, int op)
Mark all articles in newsgroup as read - Implements browser_function_t -.
Definition: functions.c:301
static int op_rename_mailbox(struct BrowserPrivateData *priv, int op)
Rename the current mailbox (IMAP only) - Implements browser_function_t -.
Definition: functions.c:837
static int op_browser_subscribe(struct BrowserPrivateData *priv, int op)
Subscribe to current mbox (IMAP/NNTP only) - Implements browser_function_t -.
Definition: functions.c:179
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:245
static int op_create_mailbox(struct BrowserPrivateData *priv, int op)
Create a new mailbox (IMAP only) - Implements browser_function_t -.
Definition: functions.c:449
static int op_delete_mailbox(struct BrowserPrivateData *priv, int op)
Delete the current mailbox (IMAP only) - Implements browser_function_t -.
Definition: functions.c:476
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:791
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:1018
static int op_browser_tell(struct BrowserPrivateData *priv, int op)
Display the currently selected file's name - Implements browser_function_t -.
Definition: functions.c:232
static int op_mailbox_list(struct BrowserPrivateData *priv, int op)
List mailboxes with new mail - Implements browser_function_t -.
Definition: functions.c:828
static int op_change_directory(struct BrowserPrivateData *priv, int op)
Change directories - Implements browser_function_t -.
Definition: functions.c:341
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:2344
Convenience wrapper for the gui headers.
Read/write command history from/to a file.
@ HC_FILE
Files.
Definition: lib.h:56
@ HC_PATTERN
Patterns.
Definition: lib.h:57
@ HC_OTHER
Miscellaneous strings.
Definition: lib.h:58
IMAP network mailbox.
int imap_subscribe(const char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1222
int imap_delete_mailbox(struct Mailbox *m, char *path)
Delete a mailbox.
Definition: imap.c:504
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:841
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:164
void nntp_newsrc_close(struct NntpAccountData *adata)
Unlock and close .newsrc file.
Definition: newsrc.c:120
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition: newsrc.c:1226
int nntp_newsrc_update(struct NntpAccountData *adata)
Update .newsrc file.
Definition: newsrc.c:443
struct NntpMboxData * mutt_newsgroup_subscribe(struct NntpAccountData *adata, char *group)
Subscribe newsgroup.
Definition: newsrc.c:1175
struct NntpMboxData * mutt_newsgroup_uncatchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Uncatchup newsgroup.
Definition: newsrc.c:1265
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:1199
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:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:96
@ 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.
Sidebar sorting functions.
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:144
char * folder
Folder name.
Definition: lib.h:147
bool is_mailbox_list
Viewing mailboxes.
Definition: lib.h:148
struct BrowserEntryArray entry
Array of files / dirs / mailboxes.
Definition: lib.h:145
bool imap_browse
IMAP folder.
Definition: lib.h:146
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:78
bool selectable
Folder can be selected.
Definition: lib.h:96
char delim
Path delimiter.
Definition: lib.h:93
bool imap
This is an IMAP folder.
Definition: lib.h:95
char * name
Name of file/dir/mailbox.
Definition: lib.h:86
bool tagged
Folder is tagged.
Definition: lib.h:102
char * desc
Description of mailbox.
Definition: lib.h:87
mode_t mode
File permissions.
Definition: lib.h:79
bool inferiors
Folder has children.
Definition: lib.h:97
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:145
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