NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_compose.c File Reference

Compose Email Dialog. More...

#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "attach/lib.h"
#include "envelope/lib.h"
#include "index/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "attach_data.h"
#include "cbar.h"
#include "functions.h"
#include "globals.h"
#include "hook.h"
#include "mutt_logging.h"
#include "shared_data.h"
+ Include dependency graph for dlg_compose.c:

Go to the source code of this file.

Functions

static int compose_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
static int compose_email_observer (struct NotifyCallback *nc)
 Notification that an Email has changed - Implements observer_t -.
 
static int compose_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
static void gen_attach_list (struct AttachCtx *actx, struct Body *b, int parent_type, int level)
 Generate the attachment list for the compose screen.
 
void update_menu (struct AttachCtx *actx, struct Menu *menu, bool init)
 Redraw the compose window.
 
static struct MuttWindowcompose_dlg_init (struct ConfigSubset *sub, struct Email *e, struct Buffer *fcc)
 Allocate the Windows for Compose.
 
int dlg_compose (struct Email *e, struct Buffer *fcc, uint8_t flags, struct ConfigSubset *sub)
 Allow the user to edit the message envelope -.
 

Variables

static const struct Mapping ComposeHelp []
 Help Bar for the Compose dialog.
 
static const struct Mapping ComposeNewsHelp []
 Help Bar for the News Compose dialog.
 

Detailed Description

Compose Email Dialog.

Authors
  • Richard Russon
  • Pietro Cerutti

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 dlg_compose.c.

Function Documentation

◆ gen_attach_list()

static void gen_attach_list ( struct AttachCtx actx,
struct Body b,
int  parent_type,
int  level 
)
static

Generate the attachment list for the compose screen.

Parameters
actxAttachment context
bAttachment
parent_typeAttachment type, e.g TYPE_MULTIPART
levelNesting depth of attachment

Definition at line 196 of file dlg_compose.c.

197{
198 for (; b; b = b->next)
199 {
200 struct AttachPtr *ap = mutt_aptr_new();
201 mutt_actx_add_attach(actx, ap);
202 ap->body = b;
203 b->aptr = ap;
205 ap->level = level;
206 if ((b->type == TYPE_MULTIPART) && b->parts &&
208 {
209 gen_attach_list(actx, b->parts, b->type, level + 1);
210 }
211 }
212}
void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach)
Add an Attachment to an Attachment Context.
Definition: attach.c:65
struct AttachPtr * mutt_aptr_new(void)
Create a new Attachment Pointer.
Definition: attach.c:40
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:443
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:196
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:90
#define WithCrypto
Definition: lib.h:116
An email to which things will be attached.
Definition: attach.h:37
struct Body * body
Attachment.
Definition: attach.h:38
int level
Nesting depth of attachment.
Definition: attach.h:42
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition: attach.h:40
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:73
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition: body.h:75
struct Body * next
next attachment in the list
Definition: body.h:72
unsigned int type
content-type primary type, ContentType
Definition: body.h:40
+ 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 220 of file dlg_compose.c.

221{
222 if (init)
223 {
224 gen_attach_list(actx, actx->email->body, -1, 0);
225 mutt_attach_init(actx);
226
227 struct ComposeAttachData *adata = menu->mdata;
228 adata->actx = actx;
229 }
230
232
233 menu->max = actx->vcount;
234 if (menu->max)
235 {
236 int index = menu_get_index(menu);
237 if (index >= menu->max)
239 }
240 else
241 {
243 }
244
246}
#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
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 AttachCtx * actx
Set of attachments.
Definition: attach_data.h:34
struct Body * body
List of MIME parts.
Definition: email.h:69
void * mdata
Private data.
Definition: lib.h:147
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:

◆ compose_dlg_init()

static struct MuttWindow * compose_dlg_init ( struct ConfigSubset sub,
struct Email e,
struct Buffer fcc 
)
static

Allocate the Windows for Compose.

Parameters
subConfigSubset
eEmail
fccBuffer to save FCC
Return values
ptrDialog containing nested Windows

Definition at line 255 of file dlg_compose.c.

257{
259 shared->sub = sub;
260 shared->email = e;
261
265 dlg->wdata = shared;
267
268 struct MuttWindow *win_env = env_window_new(e, fcc, sub);
269 struct MuttWindow *win_attach = attach_new(dlg, shared);
270 struct MuttWindow *win_cbar = cbar_new(shared);
271 struct MuttWindow *win_abar = sbar_new();
272 sbar_set_title(win_abar, _("-- Attachments"));
273
274 const bool c_status_on_top = cs_subset_bool(sub, "status_on_top");
275 if (c_status_on_top)
276 {
277 mutt_window_add_child(dlg, win_cbar);
278 mutt_window_add_child(dlg, win_env);
279 mutt_window_add_child(dlg, win_abar);
280 mutt_window_add_child(dlg, win_attach);
281 }
282 else
283 {
284 mutt_window_add_child(dlg, win_env);
285 mutt_window_add_child(dlg, win_abar);
286 mutt_window_add_child(dlg, win_attach);
287 mutt_window_add_child(dlg, win_cbar);
288 }
289
290 dlg->help_data = ComposeHelp;
291 dlg->help_menu = MENU_COMPOSE;
292
293 return dlg;
294}
struct MuttWindow * cbar_new(struct ComposeSharedData *shared)
Create the Compose Bar (status)
Definition: cbar.c:298
struct MuttWindow * attach_new(struct MuttWindow *parent, struct ComposeSharedData *shared)
Create the Attachments Menu.
Definition: attach.c:242
struct ComposeSharedData * compose_shared_data_new(void)
Free the compose shared data.
Definition: shared_data.c:48
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
static const struct Mapping ComposeHelp[]
Help Bar for the Compose dialog.
Definition: dlg_compose.c:91
struct MuttWindow * env_window_new(struct Email *e, struct Buffer *fcc, struct ConfigSubset *sub)
Create the Envelope Window.
Definition: window.c:944
void compose_shared_data_free(struct MuttWindow *win, void **ptr)
Free the compose shared data - Implements MuttWindow::wdata_free() -.
Definition: shared_data.c:36
#define _(a)
Definition: message.h:28
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:445
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
Definition: mutt_window.c:181
@ WT_DLG_COMPOSE
Compose Dialog, dlg_compose()
Definition: mutt_window.h:82
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:38
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:52
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:48
struct MuttWindow * sbar_new(void)
Add the Simple Bar (status)
Definition: sbar.c:203
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:227
Shared Compose Data.
Definition: shared_data.h:35
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:36
struct Email * email
Email being composed.
Definition: shared_data.h:38
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:141
void * wdata
Private data.
Definition: mutt_window.h:144
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:158
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:140
@ 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:

Variable Documentation

◆ ComposeHelp

const struct Mapping ComposeHelp[]
static
Initial value:
= {
{ N_("Send"), OP_COMPOSE_SEND_MESSAGE },
{ N_("Abort"), OP_EXIT },
{ N_("To"), OP_ENVELOPE_EDIT_TO },
{ N_("CC"), OP_ENVELOPE_EDIT_CC },
{ N_("Subj"), OP_ENVELOPE_EDIT_SUBJECT },
{ N_("Attach file"), OP_ATTACHMENT_ATTACH_FILE },
{ N_("Descrip"), OP_ATTACHMENT_EDIT_DESCRIPTION },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}
#define N_(a)
Definition: message.h:32

Help Bar for the Compose dialog.

Definition at line 91 of file dlg_compose.c.

◆ ComposeNewsHelp

const struct Mapping ComposeNewsHelp[]
static
Initial value:
= {
{ N_("Send"), OP_COMPOSE_SEND_MESSAGE },
{ N_("Abort"), OP_EXIT },
{ N_("Newsgroups"), OP_ENVELOPE_EDIT_NEWSGROUPS },
{ N_("Subj"), OP_ENVELOPE_EDIT_SUBJECT },
{ N_("Attach file"), OP_ATTACHMENT_ATTACH_FILE },
{ N_("Descrip"), OP_ATTACHMENT_EDIT_DESCRIPTION },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}

Help Bar for the News Compose dialog.

Definition at line 109 of file dlg_compose.c.