NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
private.h File Reference

Compose Private Data. More...

#include "config.h"
#include <stdbool.h>
+ Include dependency graph for private.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct MuttWindowattach_new (struct MuttWindow *parent, struct ComposeSharedData *shared)
 Create the Attachments Menu.
 
unsigned long cum_attachs_size (struct ConfigSubset *sub, struct ComposeAttachData *adata)
 Cumulative Attachments Size.
 
void update_menu (struct AttachCtx *actx, struct Menu *menu, bool init)
 Redraw the compose window.
 

Detailed Description

Compose Private Data.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file private.h.

Function Documentation

◆ attach_new()

struct MuttWindow * attach_new ( struct MuttWindow parent,
struct ComposeSharedData shared 
)

Create the Attachments Menu.

Parameters
parentParent Window
sharedShared compose data

Definition at line 241 of file attach.c.

242{
243 struct MuttWindow *win_attach = menu_window_new(MENU_COMPOSE, NeoMutt->sub);
244
245 struct ComposeAttachData *adata = attach_data_new(shared->email);
246
247 shared->adata = adata;
248
249 // NT_COLOR is handled by the Menu Window
253
254 struct Menu *menu = win_attach->wdata;
255 menu->page_len = win_attach->state.rows;
256 menu->win = win_attach;
257
259 menu->tag = compose_attach_tag;
260 menu->mdata = adata;
262 adata->menu = menu;
263
264 return win_attach;
265}
struct ComposeAttachData * attach_data_new(struct Email *e)
Create new Compose Attach Data.
Definition: attach_data.c:54
static int attach_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: attach.c:167
static int compose_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format an Attachment for the Menu - Implements Menu::make_entry() -.
Definition: attach.c:217
void attach_data_free(struct Menu *menu, void **ptr)
Free the Compose Attach Data - Implements Menu::mdata_free() -.
Definition: attach_data.c:37
static int compose_attach_tag(struct Menu *menu, int sel, int act)
Tag an attachment - Implements Menu::tag() -.
Definition: attach.c:201
static int attach_email_observer(struct NotifyCallback *nc)
Notification that the Email has changed - Implements observer_t -.
Definition: attach.c:126
static int attach_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_attach.c:114
struct MuttWindow * menu_window_new(enum MenuType type, struct ConfigSubset *sub)
Create a new Menu Window.
Definition: window.c:140
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:191
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
@ NT_EMAIL
Email has changed, NotifyEmail, EventEmail.
Definition: notify_type.h:44
Data to fill the Compose Attach Window.
Definition: attach_data.h:33
struct Menu * menu
Menu displaying the attachments.
Definition: attach_data.h:35
struct ComposeAttachData * adata
Attachments.
Definition: shared_data.h:39
struct Email * email
Email being composed.
Definition: shared_data.h:38
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition: subset.h:52
struct Notify * notify
Notifications: NotifyEmail, EventEmail.
Definition: email.h:73
Definition: lib.h:79
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:86
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:161
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:131
int(* make_entry)(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Definition: lib.h:106
void * mdata
Private data.
Definition: lib.h:147
int page_len
Number of entries per screen.
Definition: lib.h:84
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
@ MENU_COMPOSE
Compose an email.
Definition: type.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cum_attachs_size()

unsigned long cum_attachs_size ( struct ConfigSubset sub,
struct ComposeAttachData adata 
)

Cumulative Attachments Size.

Parameters
subConfig Subset
adataAttachment data
Return values
numBytes in attachments

Returns the total number of bytes used by the attachments in the attachment list after content-transfer-encodings have been applied.

Definition at line 84 of file attach.c.

85{
86 if (!adata || !adata->actx)
87 return 0;
88
89 size_t s = 0;
90 struct Content *info = NULL;
91 struct Body *b = NULL;
92 struct AttachCtx *actx = adata->actx;
93 struct AttachPtr **idx = actx->idx;
94
95 for (unsigned short i = 0; i < actx->idxlen; i++)
96 {
97 b = idx[i]->body;
98
99 if (!b->content)
100 b->content = mutt_get_content_info(b->filename, b, sub);
101
102 info = b->content;
103 if (info)
104 {
105 switch (b->encoding)
106 {
108 s += 3 * (info->lobin + info->hibin) + info->ascii + info->crlf;
109 break;
110 case ENC_BASE64:
111 s += (4 * (info->lobin + info->hibin + info->ascii + info->crlf)) / 3;
112 break;
113 default:
114 s += info->lobin + info->hibin + info->ascii + info->crlf;
115 break;
116 }
117 }
118 }
119
120 return s;
121}
struct Content * mutt_get_content_info(const char *fname, struct Body *b, struct ConfigSubset *sub)
Analyze file to determine MIME encoding to use.
Definition: content_info.c:188
@ ENC_BASE64
Base-64 encoded text.
Definition: mime.h:52
@ ENC_QUOTED_PRINTABLE
Quoted-printable text.
Definition: mime.h:51
A set of attachments.
Definition: attach.h:65
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:69
short idxlen
Number of attachmentes.
Definition: attach.h:70
An email to which things will be attached.
Definition: attach.h:37
struct Body * body
Attachment.
Definition: attach.h:38
The body of an email.
Definition: body.h:36
struct Content * content
Detailed info about the content of the attachment.
Definition: body.h:69
unsigned int encoding
content-transfer-encoding, ContentEncoding
Definition: body.h:41
char * filename
When sending a message, this is the file to which this structure refers.
Definition: body.h:58
struct AttachCtx * actx
Set of attachments.
Definition: attach_data.h:34
Info about an attachment.
Definition: content.h:36
long crlf
\r and \n characters
Definition: content.h:40
long hibin
8-bit characters
Definition: content.h:37
long ascii
Number of ascii chars.
Definition: content.h:41
long lobin
Unprintable 7-bit chars (eg., control chars)
Definition: content.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_menu()

void update_menu ( struct AttachCtx actx,
struct Menu menu,
bool  init 
)

Redraw the compose window.

Parameters
actxAttachment context
menuCurrent menu
initIf true, initialise the attachment list

Definition at line 217 of file dlg_compose.c.

218{
219 if (init)
220 {
221 gen_attach_list(actx, actx->email->body, -1, 0);
222 mutt_attach_init(actx);
223
224 struct ComposeAttachData *adata = menu->mdata;
225 adata->actx = actx;
226 }
227
229
230 menu->max = actx->vcount;
231 if (menu->max)
232 {
233 int index = menu_get_index(menu);
234 if (index >= menu->max)
236 }
237 else
238 {
240 }
241
243}
static void gen_attach_list(struct AttachCtx *actx, struct Body *b, int parent_type, int level)
Generate the attachment list for the compose screen.
Definition: dlg_compose.c:193
#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
void mutt_attach_init(struct AttachCtx *actx)
Create a new Attachment context.
Definition: recvattach.c:1189
void mutt_update_tree(struct AttachCtx *actx)
Refresh the list of attachments.
Definition: recvattach.c:122
short vcount
The number of virtual attachments.
Definition: attach.h:74
struct Email * email
Used by recvattach for updating.
Definition: attach.h:66
struct Body * body
List of MIME parts.
Definition: email.h:69
int max
Number of entries in the menu.
Definition: lib.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function: