1 /**
2  * @file
3  * GUI component for displaying/selecting items from a list
4  *
5  * @authors
6  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
7  *
8  * @copyright
9  * This program is free software: you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License as published by the Free Software
11  * Foundation, either version 2 of the License, or (at your option) any later
12  * version.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License along with
20  * this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef MUTT_BROWSER_H
24 #define MUTT_BROWSER_H
25 
26 #include "config.h"
27 #include <stdbool.h>
28 #include <stdint.h>
29 #include <sys/types.h>
30 #include <time.h>
31 #include "mutt/lib.h"
32 
33 struct Mailbox;
34 
35 typedef uint8_t SelectFileFlags;  ///< Flags for mutt_select_file(), e.g. #MUTT_SEL_MAILBOX
36 #define MUTT_SEL_NO_FLAGS      0  ///< No flags are set
37 #define MUTT_SEL_MAILBOX (1 << 0) ///< Select a mailbox
38 #define MUTT_SEL_MULTI   (1 << 1) ///< Multi-selection is enabled
39 #define MUTT_SEL_FOLDER  (1 << 2) ///< Select a local directory
40 
41 /**
42  * struct Folder - A folder/dir in the browser
43  */
44 struct Folder
45 {
46   struct FolderFile *ff; ///< File / Dir / Mailbox
47   int num;               ///< Number in the index
48 };
49 
50 /**
51  * struct FolderFile - Browser entry representing a folder/dir
52  */
53 struct FolderFile
54 {
55   mode_t mode;             ///< File permissions
56   off_t size;              ///< File size
57   time_t mtime;            ///< Modification time
58   uid_t uid;               ///< File's User ID
59   gid_t gid;               ///< File's Group ID
60   nlink_t nlink;           ///< Number of hard links
61 
62   char *name;              ///< Name of file/dir/mailbox
63   char *desc;              ///< Description of mailbox
64 
65   bool has_new_mail;       ///< true if mailbox has "new mail"
66   int msg_count;           ///< total number of messages
67   int msg_unread;          ///< number of unread messages
68 
69 #ifdef USE_IMAP
70   char delim;              ///< Path delimiter
71 
72   bool imap        : 1;    ///< This is an IMAP folder
73   bool selectable  : 1;    ///< Folder can be selected
74   bool inferiors   : 1;    ///< Folder has children
75 #endif
76   bool has_mailbox : 1;    ///< This is a mailbox
77   bool local       : 1;    ///< Folder is on local filesystem
78   bool tagged      : 1;    ///< Folder is tagged
79 #ifdef USE_NNTP
80   struct NntpMboxData *nd; ///< Extra NNTP data
81 #endif
82 
83   int gen;                 ///< Unique id, used for (un)sorting
84 };
85 
86 ARRAY_HEAD(BrowserStateEntry, struct FolderFile);
87 
88 /**
89  * struct BrowserState - State of the file/mailbox browser
90  */
91 struct BrowserState
92 {
93   struct BrowserStateEntry entry; ///< Array of files / dirs / mailboxes
94 #ifdef USE_IMAP
95   bool imap_browse; ///< IMAP folder
96   char *folder;     ///< Folder name
97 #endif
98   bool is_mailbox_list; ///< Viewing mailboxes
99 };
100 
101 void mutt_select_file(char *file, size_t filelen, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles);
102 void mutt_buffer_select_file(struct Buffer *file, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles);
103 void mutt_browser_select_dir(const char *f);
104 void mutt_browser_cleanup(void);
105 
106 #endif /* MUTT_BROWSER_H */
107