NeoMutt  2024-04-25-89-g194907
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
win_hosts.c File Reference

Mixmaster Hosts Window. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "expando/lib.h"
#include "menu/lib.h"
#include "remailer.h"
+ Include dependency graph for win_hosts.c:

Go to the source code of this file.

Functions

static const char * mix_format_caps (const struct Remailer *r)
 Turn flags into a MixMaster capability string.
 
void mix_a (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Mixmaster: Email address - Implements ExpandoRenderData::get_string() -.
 
void mix_c (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Mixmaster: Capabilities - Implements ExpandoRenderData::get_string() -.
 
long mix_n_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Mixmaster: Index number - Implements ExpandoRenderData::get_number() -.
 
void mix_s (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Mixmaster: Short name - Implements ExpandoRenderData::get_string() -.
 
static int mix_make_entry (struct Menu *menu, int line, int max_cols, struct Buffer *buf)
 Format a Remailer for the Menu - Implements Menu::make_entry() -.
 
struct MuttWindowwin_hosts_new (struct RemailerArray *ra)
 Create a new Hosts Window.
 
struct Remailerwin_hosts_get_selection (struct MuttWindow *win)
 Get the current selection.
 

Variables

const struct ExpandoRenderData MixRenderData []
 Callbacks for Mixmaster Expandos.
 

Detailed Description

Mixmaster Hosts Window.

Authors
  • Richard Russon
  • Tóth János

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

Function Documentation

◆ mix_format_caps()

static const char * mix_format_caps ( const struct Remailer r)
static

Turn flags into a MixMaster capability string.

Parameters
rRemailer to use
Return values
ptrCapability string
Note
The string is a static buffer

Definition at line 67 of file win_hosts.c.

68{
69 // NOTE(g0mb4): use $to_chars?
70 static char capbuf[10];
71 char *t = capbuf;
72
73 if (r->caps & MIX_CAP_COMPRESS)
74 *t++ = 'C';
75 else
76 *t++ = ' ';
77
78 if (r->caps & MIX_CAP_MIDDLEMAN)
79 *t++ = 'M';
80 else
81 *t++ = ' ';
82
83 if (r->caps & MIX_CAP_NEWSPOST)
84 {
85 *t++ = 'N';
86 *t++ = 'p';
87 }
88 else
89 {
90 *t++ = ' ';
91 *t++ = ' ';
92 }
93
94 if (r->caps & MIX_CAP_NEWSMAIL)
95 {
96 *t++ = 'N';
97 *t++ = 'm';
98 }
99 else
100 {
101 *t++ = ' ';
102 *t++ = ' ';
103 }
104
105 *t = '\0';
106
107 return capbuf;
108}
#define MIX_CAP_MIDDLEMAN
Must be a middle-man (not at the end of a chain)
Definition: remailer.h:32
#define MIX_CAP_NEWSMAIL
Supports posting to Usenet through a mail-to-news gateway.
Definition: remailer.h:34
#define MIX_CAP_COMPRESS
Accepts compressed messages.
Definition: remailer.h:31
#define MIX_CAP_NEWSPOST
Supports direct posting to Usenet.
Definition: remailer.h:33
MixCapFlags caps
Capabilities of host.
Definition: remailer.h:45
+ Here is the caller graph for this function:

◆ win_hosts_new()

struct MuttWindow * win_hosts_new ( struct RemailerArray *  ra)

Create a new Hosts Window.

Parameters
raArray of Remailer hosts
Return values
ptrNew Hosts Window

Definition at line 185 of file win_hosts.c.

186{
187 struct MuttWindow *win_hosts = menu_window_new(MENU_MIXMASTER, NeoMutt->sub);
188 win_hosts->focus = win_hosts;
189
190 struct Menu *menu = win_hosts->wdata;
191
192 menu->max = ARRAY_SIZE(ra);
194 menu->tag = NULL;
195 menu->mdata = ra;
196 menu->mdata_free = NULL; // Menu doesn't own the data
197
198 return win_hosts;
199}
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
static int mix_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format a Remailer for the Menu - Implements Menu::make_entry() -.
Definition: win_hosts.c:161
struct MuttWindow * menu_window_new(enum MenuType type, struct ConfigSubset *sub)
Create a new Menu Window.
Definition: window.c:140
Definition: lib.h:79
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 max
Number of entries in the menu.
Definition: lib.h:81
struct MuttWindow * focus
Focused Window.
Definition: mutt_window.h:140
void * wdata
Private data.
Definition: mutt_window.h:145
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
@ MENU_MIXMASTER
Create/edit a Mixmaster chain.
Definition: type.h:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ win_hosts_get_selection()

struct Remailer * win_hosts_get_selection ( struct MuttWindow win)

Get the current selection.

Parameters
winHosts Window
Return values
ptrCurrently selected Remailer

Definition at line 206 of file win_hosts.c.

207{
208 if (!win || !win->wdata)
209 return NULL;
210
211 struct Menu *menu = win->wdata;
212 if (!menu->mdata)
213 return NULL;
214
215 struct RemailerArray *ra = menu->mdata;
216
217 const int sel = menu_get_index(menu);
218 if (sel < 0)
219 return NULL;
220
221 struct Remailer **r = ARRAY_GET(ra, sel);
222 if (!r)
223 return NULL;
224
225 return *r;
226}
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:109
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:160
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:86
A Mixmaster remailer.
Definition: remailer.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MixRenderData

const struct ExpandoRenderData MixRenderData
Initial value:
= {
{ -1, -1, NULL, NULL },
}
@ ED_MIXMASTER
Mixmaster ED_MIX_ ExpandoDataMixmaster.
Definition: domain.h:49
long mix_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Mixmaster: Index number - Implements ExpandoRenderData::get_number() -.
Definition: win_hosts.c:137
void mix_s(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Mixmaster: Short name - Implements ExpandoRenderData::get_string() -.
Definition: win_hosts.c:147
void mix_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Mixmaster: Capabilities - Implements ExpandoRenderData::get_string() -.
Definition: win_hosts.c:125
void mix_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Mixmaster: Email address - Implements ExpandoRenderData::get_string() -.
Definition: win_hosts.c:113
@ ED_MIX_ADDRESS
Remailer.addr.
Definition: remailer.h:56
@ ED_MIX_CAPABILITIES
Remailer, mix_format_caps()
Definition: remailer.h:57
@ ED_MIX_SHORT_NAME
Remailer.shortname.
Definition: remailer.h:59
@ ED_MIX_NUMBER
Remailer.num.
Definition: remailer.h:58

Callbacks for Mixmaster Expandos.

See also
MixFormatDef, ExpandoDataGlobal, ExpandoDataMixmaster

Definition at line 58 of file win_hosts.c.