NeoMutt  2023-05-17-16-g61469c
Teaching an old dog new tricks
DOXYGEN
win_hosts.c File Reference

Mixmaster Hosts Window. More...

#include "config.h"
#include <stddef.h>
#include <stdbool.h>
#include <stdint.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 "format_flags.h"
#include "muttlib.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 (struct Remailer *r)
 Turn flags into a MixMaster capability string. More...
 
static const char * mix_format_str (char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
 Format a string for the remailer menu - Implements format_t -. More...
 
static void mix_make_entry (struct Menu *menu, char *buf, size_t buflen, int num)
 Format a menu item for the mixmaster chain list - Implements Menu::make_entry() -. More...
 
struct MuttWindowwin_hosts_new (struct RemailerArray *ra)
 Create a new Hosts Window. More...
 
struct Remailerwin_hosts_get_selection (struct MuttWindow *win)
 Get the current selection. More...
 

Detailed Description

Mixmaster Hosts Window.

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

Function Documentation

◆ mix_format_caps()

static const char * mix_format_caps ( 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 static char capbuf[10];
70 char *t = capbuf;
71
72 if (r->caps & MIX_CAP_COMPRESS)
73 *t++ = 'C';
74 else
75 *t++ = ' ';
76
77 if (r->caps & MIX_CAP_MIDDLEMAN)
78 *t++ = 'M';
79 else
80 *t++ = ' ';
81
82 if (r->caps & MIX_CAP_NEWSPOST)
83 {
84 *t++ = 'N';
85 *t++ = 'p';
86 }
87 else
88 {
89 *t++ = ' ';
90 *t++ = ' ';
91 }
92
93 if (r->caps & MIX_CAP_NEWSMAIL)
94 {
95 *t++ = 'N';
96 *t++ = 'm';
97 }
98 else
99 {
100 *t++ = ' ';
101 *t++ = ' ';
102 }
103
104 *t = '\0';
105
106 return capbuf;
107}
#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 211 of file win_hosts.c.

212{
213 struct MuttWindow *win_hosts = menu_window_new(MENU_MIX, NeoMutt->sub);
214 win_hosts->focus = win_hosts;
215
216 struct Menu *menu = win_hosts->wdata;
217
218 menu->max = ARRAY_SIZE(ra);
220 menu->tag = NULL;
221 menu->mdata = ra;
222 menu->mdata_free = NULL; // Menu doesn't own the data
223
224 return win_hosts;
225}
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:86
static void mix_make_entry(struct Menu *menu, char *buf, size_t buflen, int num)
Format a menu item for the mixmaster chain list - Implements Menu::make_entry() -.
Definition: win_hosts.c:194
struct MuttWindow * menu_window_new(enum MenuType type, struct ConfigSubset *sub)
Create a new Menu Window.
Definition: window.c:138
Definition: lib.h:70
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:97
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:122
void * mdata
Private data.
Definition: lib.h:138
int max
Number of entries in the menu.
Definition: lib.h:72
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:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
@ MENU_MIX
Create/edit a Mixmaster chain.
Definition: type.h:52
+ 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 232 of file win_hosts.c.

233{
234 if (!win || !win->wdata)
235 return NULL;
236
237 struct Menu *menu = win->wdata;
238 if (!menu->mdata)
239 return NULL;
240
241 struct RemailerArray *ra = menu->mdata;
242
243 const int sel = menu_get_index(menu);
244 if (sel < 0)
245 return NULL;
246
247 struct Remailer **r = ARRAY_GET(ra, sel);
248 if (!r)
249 return NULL;
250
251 return *r;
252}
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:108
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:155
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:77
A Mixmaster remailer.
Definition: remailer.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function: