NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
DOXYGEN
dlg_mixmaster.c File Reference

Mixmaster Remailer Dialog. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "menu/lib.h"
#include "functions.h"
#include "keymap.h"
#include "mutt_logging.h"
#include "opcodes.h"
#include "private_data.h"
#include "remailer.h"
#include "win_chain.h"
#include "win_hosts.h"
+ Include dependency graph for dlg_mixmaster.c:

Go to the source code of this file.

Functions

static int remailer_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -. More...
 
static int remailer_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -. More...
 
static struct MuttWindowmix_dlg_new (struct MixmasterPrivateData *priv, struct RemailerArray *ra)
 Create a new Mixmaster Remailer Dialog. More...
 
void dlg_mixmaster (struct ListHead *chainhead)
 Create a Mixmaster chain. More...
 

Variables

static const struct Mapping RemailerHelp []
 Help Bar for the Mixmaster dialog. More...
 

Detailed Description

Mixmaster Remailer Dialog.

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

Function Documentation

◆ mix_dlg_new()

static struct MuttWindow * mix_dlg_new ( struct MixmasterPrivateData priv,
struct RemailerArray *  ra 
)
static

Create a new Mixmaster Remailer Dialog.

Parameters
privMixmaster private data
raArray of all Remailer hosts
Return values
ptrNew Mixmaster Remailer Dialog

Definition at line 141 of file dlg_mixmaster.c.

143{
147 dlg->help_menu = MENU_MIX;
148 dlg->help_data = RemailerHelp;
149 dlg->wdata = priv;
150
151 priv->win_hosts = win_hosts_new(ra);
152 struct MuttWindow *win_cbar = sbar_new();
153 priv->win_chain = win_chain_new(win_cbar);
154
155 struct MuttWindow *win_rbar = sbar_new();
156 sbar_set_title(win_rbar, _("Select a remailer chain"));
157
158 const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
159 if (c_status_on_top)
160 {
161 mutt_window_add_child(dlg, win_rbar);
163 mutt_window_add_child(dlg, win_cbar);
165 }
166 else
167 {
169 mutt_window_add_child(dlg, win_cbar);
171 mutt_window_add_child(dlg, win_rbar);
172 }
173
176
177 return dlg;
178}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
static const struct Mapping RemailerHelp[]
Help Bar for the Mixmaster dialog.
Definition: dlg_mixmaster.c:80
static int remailer_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_mixmaster.c:94
static int remailer_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
#define _(a)
Definition: message.h:28
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:189
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:439
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_REMAILER
Remailer Dialog, dlg_mixmaster()
Definition: mutt_window.h:91
@ 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
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
struct MuttWindow * sbar_new(void)
Add the Simple Bar (status)
Definition: sbar.c:200
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:224
struct MuttWindow * win_chain
Chain Window.
Definition: private_data.h:32
struct MuttWindow * win_hosts
Hosts Window.
Definition: private_data.h:31
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:142
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:141
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
@ MENU_MIX
Create/edit a Mixmaster chain.
Definition: type.h:52
struct MuttWindow * win_chain_new(struct MuttWindow *win_cbar)
Create a new Chain list Window.
Definition: win_chain.c:184
struct MuttWindow * win_hosts_new(struct RemailerArray *ra)
Create a new Hosts Window.
Definition: win_hosts.c:207
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_mixmaster()

void dlg_mixmaster ( struct ListHead *  chainhead)

Create a Mixmaster chain.

Parameters
chainheadList of chain links

Ask the user to select Mixmaster hosts to create a chain.

Definition at line 186 of file dlg_mixmaster.c.

187{
188 struct MixmasterPrivateData priv = { 0 };
189
190 struct RemailerArray ra = remailer_get_hosts();
191 if (ARRAY_EMPTY(&ra))
192 {
193 mutt_error(_("Can't get mixmaster's type2.list"));
194 return;
195 }
196
197 struct MuttWindow *dlg = mix_dlg_new(&priv, &ra);
198
199 win_chain_init(priv.win_chain, chainhead, &ra);
200 mutt_list_free(chainhead);
201
202 dialog_push(dlg);
203
204 // ---------------------------------------------------------------------------
205 // Event Loop
206 int op = OP_NULL;
207 int rc = FR_UNKNOWN;
208 do
209 {
211 window_redraw(NULL);
212
213 op = km_dokey(MENU_MIX);
214 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
215 if (op < 0)
216 continue;
217 if (op == OP_NULL)
218 {
220 continue;
221 }
223
224 rc = mix_function_dispatcher(dlg, op);
225
226 if (rc == FR_UNKNOWN)
227 rc = menu_function_dispatcher(priv.win_hosts, op);
228 if (rc == FR_UNKNOWN)
229 rc = global_function_dispatcher(NULL, op);
230 } while ((rc != FR_DONE) && (rc != FR_NO_ACTION));
231 // ---------------------------------------------------------------------------
232
233 /* construct the remailer list */
234 if (rc == FR_DONE)
235 win_chain_extract(priv.win_chain, chainhead);
236
237 dialog_pop();
238 mutt_window_free(&dlg);
239
241}
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:73
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
Definition: dialog.c:103
void dialog_pop(void)
Hide a Window from the user.
Definition: dialog.c:137
@ FR_DONE
Exit the Dialog.
Definition: dispatcher.h:35
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
@ FR_NO_ACTION
Valid function - no action performed.
Definition: dispatcher.h:37
static struct MuttWindow * mix_dlg_new(struct MixmasterPrivateData *priv, struct RemailerArray *ra)
Create a new Mixmaster Remailer Dialog.
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:320
int mix_function_dispatcher(struct MuttWindow *win, int op)
Perform a Mixmaster function - Implements function_dispatcher_t -.
Definition: functions.c:140
#define mutt_error(...)
Definition: logging.h:87
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:795
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1061
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:604
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:201
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:46
struct RemailerArray remailer_get_hosts(void)
Parse the type2.list as given by mixmaster -T.
Definition: remailer.c:114
void remailer_clear_hosts(struct RemailerArray *ra)
Clear a Remailer List.
Definition: remailer.c:205
Private state data for the Mixmaster.
Definition: private_data.h:30
int win_chain_extract(struct MuttWindow *win, struct ListHead *chain)
Extract the Chain list data.
Definition: win_chain.c:233
void win_chain_init(struct MuttWindow *win, struct ListHead *chain, struct RemailerArray *ra)
Initialise the Chain list Window.
Definition: win_chain.c:207
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ RemailerHelp

const struct Mapping RemailerHelp[]
static
Initial value:
= {
{ N_("Append"), OP_MIX_APPEND },
{ N_("Insert"), OP_MIX_INSERT },
{ N_("Delete"), OP_MIX_DELETE },
{ N_("Abort"), OP_EXIT },
{ N_("OK"), OP_MIX_USE },
{ NULL, 0 },
}
#define N_(a)
Definition: message.h:32

Help Bar for the Mixmaster dialog.

Definition at line 80 of file dlg_mixmaster.c.