Skip to content

Commit

Permalink
create libattach
Browse files Browse the repository at this point in the history
  • Loading branch information
flatcap committed Aug 3, 2021
1 parent a3c77fd commit 967709f
Show file tree
Hide file tree
Showing 32 changed files with 116 additions and 107 deletions.
24 changes: 19 additions & 5 deletions Makefile.autosetup
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ default: all
###############################################################################
# neomutt
NEOMUTT= neomutt$(EXEEXT)
NEOMUTTOBJS= alternates.o attachments.o browser.o commands.o command_parse.o \
complete.o conststrings.o context.o copy.o dlg_attach.o dlg_postpone.o \
NEOMUTTOBJS= alternates.o browser.o commands.o command_parse.o \
complete.o conststrings.o context.o copy.o dlg_postpone.o \
editmsg.o enriched.o enter.o flags.o functions.o git_ver.o \
handler.o hdrline.o help.o hook.o icommands.o init.o \
keymap.o mailcap.o maillist.o main.o muttlib.o mutt_account.o \
mutt_attach.o mutt_body.o mutt_commands.o mutt_config.o \
mutt_body.o mutt_commands.o mutt_config.o \
mutt_header.o mutt_history.o mutt_logging.o mutt_mailbox.o \
mutt_signal.o mutt_socket.o mutt_thread.o mx.o \
myvar.o opcodes.o postpone.o \
recvattach.o recvcmd.o resize.o rfc3676.o score.o \
recvcmd.o resize.o rfc3676.o score.o \
sort.o status.o subjectrx.o system.o version.o

@if !HAVE_WCSCASECMP
Expand Down Expand Up @@ -118,6 +118,20 @@ $(LIBALIAS): $(PWD)/alias $(LIBALIASOBJS)
$(PWD)/alias:
$(MKDIR_P) $(PWD)/alias

###############################################################################
# libattach
LIBATTACH= libattach.a
LIBATTACHOBJS= attach/attachments.o attach/dlg_attach.o attach/mutt_attach.o \
attach/recvattach.o
CLEANFILES+= $(LIBATTACH) $(LIBATTACHOBJS)
ALLOBJS+= $(LIBATTACHOBJS)

$(LIBATTACH): $(PWD)/attach $(LIBATTACHOBJS)
$(AR) cr $@ $(LIBATTACHOBJS)
$(RANLIB) $@
$(PWD)/attach:
$(MKDIR_P) $(PWD)/attach

###############################################################################
# libautocrypt
@if USE_AUTOCRYPT
Expand Down Expand Up @@ -684,7 +698,7 @@ $(ALLOBJS):
MUTTLIBS+= $(LIBINDEX) $(LIBPAGER) $(LIBAUTOCRYPT) $(LIBPOP) $(LIBNNTP) \
$(LIBCOMPMBOX) $(LIBSTORE) $(LIBPATTERN) $(LIBPROGRESS) $(LIBQUESTION)\
$(LIBGUI) $(LIBHELPBAR) $(LIBMENU) $(LIBMBOX) $(LIBNOTMUCH) \
$(LIBMAILDIR) $(LIBNCRYPT) $(LIBIMAP) $(LIBCONN) $(LIBHCACHE) \
$(LIBATTACH) $(LIBMAILDIR) $(LIBNCRYPT) $(LIBIMAP) $(LIBCONN) $(LIBHCACHE) \
$(LIBCOMPRESS) $(LIBSIDEBAR) $(LIBBCACHE) $(LIBHISTORY) \
$(LIBALIAS) $(LIBSEND) $(LIBCOMPOSE) $(LIBCORE) $(LIBCONFIG) \
$(LIBEMAIL) $(LIBADDRESS) $(LIBDEBUG) $(LIBMUTT)
Expand Down
2 changes: 1 addition & 1 deletion attachments.c → attach/attachments.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

/**
* @page neo_attachments Handle the attachments commmand
* @page attach_attachments Handle the attachments commmand
*
* Handle the attachments commmand
*/
Expand Down
6 changes: 3 additions & 3 deletions attachments.h → attach/attachments.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef MUTT_ATTACHMENTS_H
#define MUTT_ATTACHMENTS_H
#ifndef MUTT_ATTACH_ATTACHMENTS_H
#define MUTT_ATTACH_ATTACHMENTS_H

#include <stdio.h>

Expand All @@ -47,4 +47,4 @@ void mutt_attachments_reset (struct Mailbox *m);
int mutt_count_body_parts (struct Mailbox *m, struct Email *e, FILE *fp);
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e, FILE *fp);

#endif /* MUTT_ATTACHMENTS_H */
#endif /* MUTT_ATTACH_ATTACHMENTS_H */
2 changes: 1 addition & 1 deletion dlg_attach.c → attach/dlg_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

/**
* @page neo_dlg_attach Attachment Selection Dialog
* @page attach_dialog Attachment Selection Dialog
*
* ## Overview
*
Expand Down
45 changes: 45 additions & 0 deletions attach/lib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @file
* GUI display the mailboxes in a side panel
*
* @authors
* Copyright (C) 2021 Richard Russon <[email protected]>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* 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/>.
*/

/**
* @page lib_attach Attach
*
* Attachment handling
*
* | File | Description |
* | :------------------- | :-------------------------- |
* | attach/attachments.c | @subpage attach_attachments |
* | attach/dlg_attach.c | @subpage attach_dialog |
* | attach/mutt_attach.c | @subpage attach_mutt_attach |
* | attach/recvattach.c | @subpage attach_recvattach |
*/

#ifndef MUTT_ATTACH_LIB_H
#define MUTT_ATTACH_LIB_H

// IWYU pragma: begin_exports
#include "attachments.h"
#include "mutt_attach.h"
#include "recvattach.h"
// IWYU pragma: end_exports

#endif /* MUTT_ATTACH_LIB_H */
2 changes: 1 addition & 1 deletion mutt_attach.c → attach/mutt_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

/**
* @page neo_mutt_attach Handling of email attachments
* @page attach_mutt_attach Handling of email attachments
*
* Handling of email attachments
*/
Expand Down
6 changes: 3 additions & 3 deletions mutt_attach.h → attach/mutt_attach.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

/* common protos for compose / attach menus */

#ifndef MUTT_MUTT_ATTACH_H
#define MUTT_MUTT_ATTACH_H
#ifndef MUTT_ATTACH_MUTT_ATTACH_H
#define MUTT_ATTACH_MUTT_ATTACH_H

#include <stdbool.h>
#include <stdio.h>
Expand Down Expand Up @@ -84,4 +84,4 @@ int mutt_save_attachment(FILE *fp, struct Body *m, const char *path, enum SaveAt
void mutt_add_temp_attachment(const char *filename);
void mutt_unlink_temp_attachments(void);

#endif /* MUTT_MUTT_ATTACH_H */
#endif /* MUTT_ATTACH_MUTT_ATTACH_H */
52 changes: 5 additions & 47 deletions recvattach.c → attach/recvattach.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file
* Attachment Selection Dialog
* Attachment code
*
* @authors
* Copyright (C) 1996-2000,2002,2007,2010 Michael R. Elkins <[email protected]>
Expand All @@ -22,50 +22,9 @@
*/

/**
* @page neo_recvattach Attachment Selection Dialog
* @page attach_recvattach Attachment code
*
* ## Overview
*
* The Attachment Selection Dialog lets the user select an email attachment.
*
* This is a @ref gui_simple
*
* ## Windows
*
* | Name | Type | See Also |
* | :-------------------------- | :------------ | :---------------------- |
* | Attachment Selection Dialog | WT_DLG_ATTACH | dlg_select_attachment() |
*
* **Parent**
* - @ref gui_dialog
*
* **Children**
* - See: @ref gui_simple
*
* ## Data
* - #Menu
* - #Menu::mdata
* - #AttachCtx
*
* The @ref gui_simple holds a Menu. The Attachment Selection Dialog stores
* its data (#AttachCtx) in Menu::mdata.
*
* ## Events
*
* Once constructed, it is controlled by the following events:
*
* | Event Type | Handler |
* | :---------- | :----------------------- |
* | #NT_CONFIG | attach_config_observer() |
* | #NT_WINDOW | attach_window_observer() |
*
* The Attachment Selection Dialog doesn't have any specific colours, so it
* doesn't need to support #NT_COLOR.
*
* The Attachment Selection Dialog does not implement MuttWindow::recalc() or
* MuttWindow::repaint().
*
* Some other events are handled by the @ref gui_simple.
* Attachment code
*/

#include "config.h"
Expand Down Expand Up @@ -953,7 +912,7 @@ void mutt_print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, stru
* @param e Email
*/
void recvattach_edit_content_type(struct ConfigSubset *sub, struct AttachCtx *actx,
struct Menu *menu, struct Email *e)
struct Menu *menu, struct Email *e)
{
struct AttachPtr *cur_att = current_attachment(actx, menu);
if (!mutt_edit_content_type(e, cur_att->body, cur_att->fp))
Expand Down Expand Up @@ -1210,7 +1169,7 @@ void mutt_attach_init(struct AttachCtx *actx)
* @param init If true, create a new Attachments context
*/
void mutt_update_recvattach_menu(struct ConfigSubset *sub, struct AttachCtx *actx,
struct Menu *menu, bool init)
struct Menu *menu, bool init)
{
if (init)
{
Expand All @@ -1229,4 +1188,3 @@ void mutt_update_recvattach_menu(struct ConfigSubset *sub, struct AttachCtx *act
menu_set_index(menu, menu->max - 1);
menu_queue_redraw(menu, MENU_REDRAW_INDEX);
}

6 changes: 3 additions & 3 deletions recvattach.h → attach/recvattach.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef MUTT_RECVATTACH_H
#define MUTT_RECVATTACH_H
#ifndef MUTT_ATTACH_RECVATTACH_H
#define MUTT_ATTACH_RECVATTACH_H

#include <stddef.h>
#include <stdbool.h>
Expand All @@ -48,4 +48,4 @@ struct AttachPtr *current_attachment(struct AttachCtx *actx, struct Menu *menu);
void mutt_update_recvattach_menu(struct ConfigSubset *sub, struct AttachCtx *actx, struct Menu *menu, bool init);
void recvattach_edit_content_type(struct ConfigSubset *sub, struct AttachCtx *actx, struct Menu *menu, struct Email *e);

#endif /* MUTT_RECVATTACH_H */
#endif /* MUTT_ATTACH_RECVATTACH_H */
2 changes: 1 addition & 1 deletion browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@
#include "gui/lib.h"
#include "mutt.h"
#include "browser.h"
#include "attach/lib.h"
#include "menu/lib.h"
#include "question/lib.h"
#include "send/lib.h"
#include "format_flags.h"
#include "mutt_attach.h"
#include "mutt_globals.h"
#include "mutt_mailbox.h"
#include "muttlib.h"
Expand Down
2 changes: 1 addition & 1 deletion commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
#include "gui/lib.h"
#include "mutt.h"
#include "commands.h"
#include "attach/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "pager/lib.h"
#include "progress/lib.h"
#include "question/lib.h"
#include "send/lib.h"
#include "attachments.h"
#include "browser.h"
#include "context.h"
#include "copy.h"
Expand Down
2 changes: 1 addition & 1 deletion compose/attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "attach/lib.h"
#include "menu/lib.h"
#include "send/lib.h"
#include "attach_data.h"
#include "format_flags.h"
#include "muttlib.h"
#include "recvattach.h"
#include "shared_data.h"

/**
Expand Down
3 changes: 1 addition & 2 deletions compose/compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#include "gui/lib.h"
#include "mutt.h"
#include "lib.h"
#include "attach/lib.h"
#include "index/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
Expand All @@ -98,7 +99,6 @@
#include "context.h"
#include "env_data.h"
#include "hook.h"
#include "mutt_attach.h"
#include "mutt_globals.h"
#include "mutt_header.h"
#include "mutt_logging.h"
Expand All @@ -107,7 +107,6 @@
#include "opcodes.h"
#include "options.h"
#include "protos.h"
#include "recvattach.h"
#include "rfc3676.h"
#include "shared_data.h"
#ifdef ENABLE_NLS
Expand Down
2 changes: 1 addition & 1 deletion handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
#include "core/lib.h"
#include "mutt.h"
#include "handler.h"
#include "attach/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "pager/lib.h"
#include "copy.h"
#include "enriched.h"
#include "keymap.h"
#include "mailcap.h"
#include "mutt_attach.h"
#include "mutt_globals.h"
#include "mutt_logging.h"
#include "muttlib.h"
Expand Down
2 changes: 1 addition & 1 deletion hdrline.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#include "alias/lib.h"
#include "gui/lib.h"
#include "hdrline.h"
#include "attach/lib.h"
#include "ncrypt/lib.h"
#include "attachments.h"
#include "format_flags.h"
#include "hook.h"
#include "maillist.h"
Expand Down
2 changes: 1 addition & 1 deletion hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
#include "alias/lib.h"
#include "mutt.h"
#include "hook.h"
#include "attach/lib.h"
#include "ncrypt/lib.h"
#include "pattern/lib.h"
#include "context.h"
#include "format_flags.h"
#include "hdrline.h"
#include "init.h"
#include "mutt_attach.h"
#include "mutt_commands.h"
#include "mutt_globals.h"
#include "muttlib.h"
Expand Down
2 changes: 1 addition & 1 deletion index/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "mutt.h"
#include "functions.h"
#include "lib.h"
#include "attach/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "pager/lib.h"
Expand All @@ -62,7 +63,6 @@
#include "options.h"
#include "private_data.h"
#include "protos.h"
#include "recvattach.h"
#include "score.h"
#include "shared_data.h"
#include "sort.h"
Expand Down
2 changes: 1 addition & 1 deletion index/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "attach/lib.h"
#include "menu/lib.h"
#include "alternates.h"
#include "attachments.h"
#include "mutt_thread.h"
#include "muttlib.h"
#include "options.h"
Expand Down
Loading

0 comments on commit 967709f

Please sign in to comment.