NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
notify.c File Reference

Dump all notifications. More...

#include "config.h"
#include <stddef.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 "color/lib.h"
#include "mview.h"
+ Include dependency graph for notify.c:

Go to the source code of this file.

Functions

static void notify_dump_account (struct NotifyCallback *nc)
 
static void notify_dump_color (struct NotifyCallback *nc)
 
static void notify_dump_command (struct NotifyCallback *nc)
 
static void notify_dump_config (struct NotifyCallback *nc)
 
static void notify_dump_mview (struct NotifyCallback *nc)
 
static void notify_dump_email (struct NotifyCallback *nc)
 
static void notify_dump_global (struct NotifyCallback *nc)
 
static void notify_dump_mailbox (struct NotifyCallback *nc)
 
static void notify_dump_window_state (struct NotifyCallback *nc)
 
static void notify_dump_window_focus (struct NotifyCallback *nc)
 
int debug_all_observer (struct NotifyCallback *nc)
 

Variables

const struct Mapping ColorFields []
 Mapping of colour names to their IDs.
 
const struct Mapping ComposeColorFields []
 Mapping of compose colour names to their IDs.
 

Detailed Description

Dump all notifications.

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

Function Documentation

◆ notify_dump_account()

static void notify_dump_account ( struct NotifyCallback nc)
static

Definition at line 43 of file notify.c.

44{
45 struct EventAccount *ev_a = nc->event_data;
46 struct Account *a = ev_a->account;
47 if (!a)
48 return;
49
50 mutt_debug(LL_DEBUG1, " Account: %p (%s) %s\n", (void *) a,
51 name_mailbox_type(a->type), NONULL(a->name));
52}
const char * name_mailbox_type(enum MailboxType type)
Definition: names.c:123
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
#define NONULL(x)
Definition: string2.h:37
A group of associated Mailboxes.
Definition: account.h:36
An Event that happened to an Account.
Definition: account.h:79
struct Account * account
The Account this Event relates to.
Definition: account.h:80
void * event_data
Data from notify_send()
Definition: observer.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notify_dump_color()

static void notify_dump_color ( struct NotifyCallback nc)
static

Definition at line 54 of file notify.c.

55{
56 struct EventColor *ev_c = nc->event_data;
57
58 const char *color = NULL;
59 const char *scope = "";
60
61 if (ev_c->cid == MT_COLOR_MAX)
62 color = "ALL";
63
64 if (!color)
65 color = mutt_map_get_name(ev_c->cid, ColorFields);
66
67 if (!color)
68 {
70 scope = "compose ";
71 }
72
73 if (!color)
74 color = "UNKNOWN";
75
76 mutt_debug(LL_DEBUG1, " Color: %s %s%s (%d)\n",
77 (nc->event_subtype == NT_COLOR_SET) ? "set" : "reset", scope,
78 color, ev_c->cid);
79}
@ MT_COLOR_MAX
Definition: color.h:94
const struct Mapping ComposeColorFields[]
Mapping of compose colour names to their IDs.
Definition: command.c:111
const struct Mapping ColorFields[]
Mapping of colour names to their IDs.
Definition: command.c:56
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
Definition: mapping.c:42
@ NT_COLOR_SET
Color has been set.
Definition: notify2.h:41
An Event that happened to a Colour.
Definition: notify2.h:53
enum ColorId cid
Colour ID that has changed.
Definition: notify2.h:54
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notify_dump_command()

static void notify_dump_command ( struct NotifyCallback nc)
static

Definition at line 81 of file notify.c.

82{
83 struct Command *cmd = nc->event_data;
84
85 if (cmd->data < 4096)
86 mutt_debug(LL_DEBUG1, " Command: %s, data: %ld\n", cmd->name, cmd->data);
87 else
88 mutt_debug(LL_DEBUG1, " Command: %s, data: %p\n", cmd->name, (void *) cmd->data);
89}
intptr_t data
Data or flags to pass to the command.
Definition: command.h:67
const char * name
Name of the command.
Definition: command.h:52
+ Here is the caller graph for this function:

◆ notify_dump_config()

static void notify_dump_config ( struct NotifyCallback nc)
static

Definition at line 91 of file notify.c.

92{
93 struct EventConfig *ev_c = nc->event_data;
94
95 struct Buffer *value = buf_pool_get();
96 cs_he_string_get(ev_c->sub->cs, ev_c->he, value);
97 mutt_debug(LL_DEBUG1, " Config: %s %s = %s\n",
99 buf_pool_release(&value);
100}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
int cs_he_string_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
Definition: set.c:663
const char * name_notify_config(int id)
Definition: names.c:185
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
String manipulation buffer.
Definition: buffer.h:36
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:51
A config-change event.
Definition: subset.h:71
const struct ConfigSubset * sub
Config Subset.
Definition: subset.h:72
const char * name
Name of config item that changed.
Definition: subset.h:73
struct HashElem * he
Config item that changed.
Definition: subset.h:74
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notify_dump_mview()

static void notify_dump_mview ( struct NotifyCallback nc)
static

Definition at line 102 of file notify.c.

103{
104 struct EventMview *ev_m = nc->event_data;
105
106 const char *path = "NONE";
107 if (ev_m->mv && ev_m->mv->mailbox)
108 path = mailbox_path(ev_m->mv->mailbox);
109
110 mutt_debug(LL_DEBUG1, " MailboxView: %s %s\n",
112}
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:223
const char * name_notify_mview(int id)
Definition: names.c:212
An Event that happened to an MailboxView.
Definition: mview.h:71
struct MailboxView * mv
The MailboxView this Event relates to.
Definition: mview.h:72
struct Mailbox * mailbox
Current Mailbox.
Definition: mview.h:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notify_dump_email()

static void notify_dump_email ( struct NotifyCallback nc)
static

Definition at line 114 of file notify.c.

115{
116 struct EventEmail *ev_e = nc->event_data;
117
118 mutt_debug(LL_DEBUG1, " Email: %d\n", ev_e->num_emails);
119 for (size_t i = 0; i < ev_e->num_emails; i++)
120 {
121 mutt_debug(LL_DEBUG1, " : %p\n", (void *) ev_e->emails[i]);
122 }
123}
An Event that happened to an Email.
Definition: email.h:199
int num_emails
Number of Emails the event applies to.
Definition: email.h:200
struct Email ** emails
Emails affected by the event.
Definition: email.h:201
+ Here is the caller graph for this function:

◆ notify_dump_global()

static void notify_dump_global ( struct NotifyCallback nc)
static

Definition at line 125 of file notify.c.

126{
128}
const char * name_notify_global(int id)
Definition: names.c:174
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notify_dump_mailbox()

static void notify_dump_mailbox ( struct NotifyCallback nc)
static

Definition at line 130 of file notify.c.

131{
132 struct EventMailbox *ev_m = nc->event_data;
133
134 struct Mailbox *m = ev_m->mailbox;
135 const char *path = m ? mailbox_path(m) : "";
136 mutt_debug(LL_DEBUG1, " Mailbox: %s %s\n",
138}
const char * name_notify_mailbox(int id)
Definition: names.c:196
An Event that happened to a Mailbox.
Definition: mailbox.h:199
struct Mailbox * mailbox
The Mailbox this Event relates to.
Definition: mailbox.h:200
A mailbox.
Definition: mailbox.h:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notify_dump_window_state()

static void notify_dump_window_state ( struct NotifyCallback nc)
static

Definition at line 140 of file notify.c.

141{
142 struct EventWindow *ev_w = nc->event_data;
143 const struct MuttWindow *win = ev_w->win;
144 WindowNotifyFlags flags = ev_w->flags;
145
146 struct Buffer *buf = buf_pool_get();
147
148 buf_add_printf(buf, "[%s] ", mutt_window_win_name(win));
149
150 if (flags & WN_VISIBLE)
151 buf_addstr(buf, "visible ");
152 if (flags & WN_HIDDEN)
153 buf_addstr(buf, "hidden ");
154
155 if (flags & WN_MOVED)
156 {
157 buf_add_printf(buf, "moved (C%d,R%d)->(C%d,R%d) ", win->old.col_offset,
158 win->old.row_offset, win->state.col_offset, win->state.row_offset);
159 }
160
161 if (flags & WN_TALLER)
162 buf_add_printf(buf, "taller [%d->%d] ", win->old.rows, win->state.rows);
163 if (flags & WN_SHORTER)
164 buf_add_printf(buf, "shorter [%d->%d] ", win->old.rows, win->state.rows);
165 if (flags & WN_WIDER)
166 buf_add_printf(buf, "wider [%d->%d] ", win->old.cols, win->state.cols);
167 if (flags & WN_NARROWER)
168 buf_add_printf(buf, "narrower [%d->%d] ", win->old.cols, win->state.cols);
169
170 mutt_debug(LL_DEBUG1, " Window: %s\n", buf_string(buf));
171
172 buf_pool_release(&buf);
173}
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition: buffer.c:203
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
Definition: mutt_window.c:735
#define WN_MOVED
Window moved.
Definition: mutt_window.h:214
uint8_t WindowNotifyFlags
Flags for Changes to a MuttWindow, e.g. WN_TALLER.
Definition: mutt_window.h:208
#define WN_WIDER
Window became wider.
Definition: mutt_window.h:212
#define WN_VISIBLE
Window became visible.
Definition: mutt_window.h:215
#define WN_HIDDEN
Window became hidden.
Definition: mutt_window.h:216
#define WN_TALLER
Window became taller.
Definition: mutt_window.h:210
#define WN_NARROWER
Window became narrower.
Definition: mutt_window.h:213
#define WN_SHORTER
Window became shorter.
Definition: mutt_window.h:211
An Event that happened to a Window.
Definition: mutt_window.h:239
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:240
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:241
struct WindowState old
Previous state of the Window.
Definition: mutt_window.h:128
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:63
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:62
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notify_dump_window_focus()

static void notify_dump_window_focus ( struct NotifyCallback nc)
static

Definition at line 175 of file notify.c.

176{
177 struct EventWindow *ev_w = nc->event_data;
178 struct MuttWindow *win = ev_w->win;
179
180 struct Buffer *buf = buf_pool_get();
181
182 buf_addstr(buf, "Focus: ");
183
184 if (win)
185 {
186 struct MuttWindow *dlg = dialog_find(win);
187 if (dlg && (dlg != win))
188 buf_add_printf(buf, "%s:", mutt_window_win_name(dlg));
189
190 buf_add_printf(buf, "%s ", mutt_window_win_name(win));
191
192 buf_add_printf(buf, "(C%d,R%d) [%dx%d]", win->state.col_offset,
193 win->state.row_offset, win->state.cols, win->state.rows);
194 }
195 else
196 {
197 buf_addstr(buf, "NONE");
198 }
199
200 mutt_debug(LL_DEBUG1, " Window: %s\n", buf_string(buf));
201
202 buf_pool_release(&buf);
203}
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ debug_all_observer()

int debug_all_observer ( struct NotifyCallback nc)

Definition at line 205 of file notify.c.

206{
207 mutt_debug(LL_DEBUG1, "\033[1;31mNotification:\033[0m %s\n",
209
210 switch (nc->event_type)
211 {
212 case NT_ACCOUNT:
214 break;
215 case NT_COLOR:
217 break;
218 case NT_COMMAND:
220 break;
221 case NT_CONFIG:
223 break;
224 case NT_MVIEW:
226 break;
227 case NT_EMAIL:
229 break;
230 case NT_GLOBAL:
232 break;
233 case NT_MAILBOX:
235 break;
236 case NT_RESIZE:
237 case NT_TIMEOUT:
238 break; // no other data
239 case NT_WINDOW:
242 else if (nc->event_subtype == NT_WINDOW_FOCUS)
244 break;
245 default:
246 mutt_debug(LL_DEBUG1, " Event Type: %d\n", nc->event_type);
247 mutt_debug(LL_DEBUG1, " Event Sub-type: %d\n", nc->event_subtype);
248 mutt_debug(LL_DEBUG1, " Event Data: %p\n", nc->event_data);
249 break;
250 }
251
252 mutt_debug(LL_DEBUG1, " Global Data: %p\n", nc->global_data);
253
254 mutt_debug(LL_DEBUG5, "debug done\n");
255 return 0;
256}
const char * name_notify_type(enum NotifyType type)
Definition: names.c:92
static void notify_dump_global(struct NotifyCallback *nc)
Definition: notify.c:125
static void notify_dump_config(struct NotifyCallback *nc)
Definition: notify.c:91
static void notify_dump_mview(struct NotifyCallback *nc)
Definition: notify.c:102
static void notify_dump_command(struct NotifyCallback *nc)
Definition: notify.c:81
static void notify_dump_color(struct NotifyCallback *nc)
Definition: notify.c:54
static void notify_dump_mailbox(struct NotifyCallback *nc)
Definition: notify.c:130
static void notify_dump_window_focus(struct NotifyCallback *nc)
Definition: notify.c:175
static void notify_dump_account(struct NotifyCallback *nc)
Definition: notify.c:43
static void notify_dump_email(struct NotifyCallback *nc)
Definition: notify.c:114
static void notify_dump_window_state(struct NotifyCallback *nc)
Definition: notify.c:140
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
@ NT_WINDOW_STATE
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:230
@ NT_WINDOW_FOCUS
Window focus has changed.
Definition: mutt_window.h:232
@ NT_TIMEOUT
Timeout has occurred.
Definition: notify_type.h:56
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
@ NT_COLOR
Colour has changed, NotifyColor, EventColor.
Definition: notify_type.h:41
@ NT_EMAIL
Email has changed, NotifyEmail, EventEmail.
Definition: notify_type.h:44
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition: notify_type.h:49
@ NT_COMMAND
A Command has been executed, Command.
Definition: notify_type.h:42
@ NT_ACCOUNT
Account has changed, NotifyAccount, EventAccount.
Definition: notify_type.h:36
@ NT_MVIEW
MailboxView has changed, NotifyMview, EventMview.
Definition: notify_type.h:50
@ NT_GLOBAL
Not object-related, NotifyGlobal.
Definition: notify_type.h:46
@ NT_RESIZE
Window has been resized.
Definition: notify_type.h:52
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:36
void * global_data
Data from notify_observer_add()
Definition: observer.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ ColorFields

const struct Mapping ColorFields[]
extern

Mapping of colour names to their IDs.

Definition at line 56 of file command.c.

◆ ComposeColorFields

const struct Mapping ComposeColorFields[]
extern

Mapping of compose colour names to their IDs.

Definition at line 111 of file command.c.