NeoMutt  2021-10-29-43-g6b8931
Teaching an old dog new tricks
DOXYGEN
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 "context.h"
+ Include dependency graph for notify.c:

Go to the source code of this file.

Functions

static const char * get_event_type (enum NotifyType type)
 
const char * get_mailbox_type (enum MailboxType type)
 
static const char * get_global_event (int id)
 
static const char * get_config_type (int id)
 
static const char * get_mailbox_event (int id)
 
static const char * get_context (int id)
 
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_context (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 []
 
const struct Mapping ComposeColorFields []
 

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

◆ get_event_type()

static const char* get_event_type ( enum NotifyType  type)
static

Definition at line 43 of file notify.c.

44 {
45  switch (type)
46  {
47  case NT_ACCOUNT:
48  return "account";
49  case NT_COLOR:
50  return "color";
51  case NT_COMMAND:
52  return "command";
53  case NT_CONFIG:
54  return "config";
55  case NT_CONTEXT:
56  return "context";
57  case NT_EMAIL:
58  return "email";
59  case NT_GLOBAL:
60  return "global";
61  case NT_MAILBOX:
62  return "mailbox";
63  case NT_WINDOW:
64  return "window";
65  default:
66  return "UNKNOWN";
67  }
68 }
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:42
@ NT_COLOR
Colour has changed, NotifyColor, EventColor.
Definition: notify_type.h:39
@ NT_EMAIL
Email has changed, NotifyEmail, EventEmail.
Definition: notify_type.h:44
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition: notify_type.h:48
@ NT_COMMAND
A Command has been executed, Command.
Definition: notify_type.h:40
@ NT_ACCOUNT
Account has changed, NotifyAccount, EventAccount.
Definition: notify_type.h:34
@ NT_GLOBAL
Not object-related, NotifyGlobal.
Definition: notify_type.h:45
@ NT_CONTEXT
Context has changed, NotifyContext, EventContext.
Definition: notify_type.h:43
+ Here is the caller graph for this function:

◆ get_mailbox_type()

const char* get_mailbox_type ( enum MailboxType  type)

Definition at line 70 of file notify.c.

71 {
72  switch (type)
73  {
74  case MUTT_COMPRESSED:
75  return "compressed";
76  case MUTT_IMAP:
77  return "imap";
78  case MUTT_MAILDIR:
79  return "maildir";
80  case MUTT_MBOX:
81  return "mbox";
82  case MUTT_MH:
83  return "mh";
84  case MUTT_MMDF:
85  return "mmdf";
86  case MUTT_NNTP:
87  return "nntp";
88  case MUTT_NOTMUCH:
89  return "notmuch";
90  case MUTT_POP:
91  return "pop";
92  default:
93  return "UNKNOWN";
94  }
95 }
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition: mailbox.h:54
@ MUTT_MMDF
'mmdf' Mailbox type
Definition: mailbox.h:49
@ MUTT_POP
'POP3' Mailbox type
Definition: mailbox.h:55
@ MUTT_MH
'MH' Mailbox type
Definition: mailbox.h:50
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition: mailbox.h:52
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:53
@ MUTT_MBOX
'mbox' Mailbox type
Definition: mailbox.h:48
@ MUTT_COMPRESSED
Compressed file Mailbox type.
Definition: mailbox.h:56
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition: mailbox.h:51
+ Here is the caller graph for this function:

◆ get_global_event()

static const char* get_global_event ( int  id)
static

Definition at line 97 of file notify.c.

98 {
99  switch (id)
100  {
101  case NT_GLOBAL_SHUTDOWN:
102  return "shutdown";
103  case NT_GLOBAL_STARTUP:
104  return "startup";
105  case NT_GLOBAL_TIMEOUT:
106  return "timeout";
107  default:
108  return "UNKNOWN";
109  }
110 }
@ NT_GLOBAL_STARTUP
NeoMutt is initialised.
Definition: neomutt.h:50
@ NT_GLOBAL_TIMEOUT
A timer has elapsed.
Definition: neomutt.h:52
@ NT_GLOBAL_SHUTDOWN
NeoMutt is about to close.
Definition: neomutt.h:51
+ Here is the caller graph for this function:

◆ get_config_type()

static const char* get_config_type ( int  id)
static

Definition at line 112 of file notify.c.

113 {
114  switch (id)
115  {
116  case NT_CONFIG_SET:
117  return "set";
118  case NT_CONFIG_RESET:
119  return "reset";
120  default:
121  return "UNKNOWN";
122  }
123 }
@ NT_CONFIG_RESET
Config item has been reset to initial, or parent, value.
Definition: subset.h:63
@ NT_CONFIG_SET
Config item has been set.
Definition: subset.h:62
+ Here is the caller graph for this function:

◆ get_mailbox_event()

static const char* get_mailbox_event ( int  id)
static

Definition at line 125 of file notify.c.

126 {
127  switch (id)
128  {
129  case NT_MAILBOX_ADD:
130  return "add";
131  case NT_MAILBOX_DELETE:
132  return "delete";
133  case NT_MAILBOX_INVALID:
134  return "invalid";
135  case NT_MAILBOX_RESORT:
136  return "resort";
137  case NT_MAILBOX_UPDATE:
138  return "update";
139  case NT_MAILBOX_UNTAG:
140  return "untag";
141  default:
142  return "UNKNOWN";
143  }
144 }
@ NT_MAILBOX_UNTAG
Clear the 'last-tagged' pointer.
Definition: mailbox.h:184
@ NT_MAILBOX_RESORT
Email list needs resorting.
Definition: mailbox.h:181
@ NT_MAILBOX_DELETE
Mailbox is about to be deleted.
Definition: mailbox.h:174
@ NT_MAILBOX_INVALID
Email list was changed.
Definition: mailbox.h:180
@ NT_MAILBOX_UPDATE
Update internal tables.
Definition: mailbox.h:183
@ NT_MAILBOX_ADD
Mailbox has been added.
Definition: mailbox.h:173
+ Here is the caller graph for this function:

◆ get_context()

static const char* get_context ( int  id)
static

Definition at line 146 of file notify.c.

147 {
148  switch (id)
149  {
150  case NT_CONTEXT_DELETE:
151  return "delete";
152  case NT_CONTEXT_ADD:
153  return "add";
154  default:
155  return "UNKNOWN";
156  }
157 }
@ NT_CONTEXT_DELETE
The Context is about to be destroyed.
Definition: context.h:61
@ NT_CONTEXT_ADD
The Context has been opened.
Definition: context.h:60
+ Here is the caller graph for this function:

◆ notify_dump_account()

static void notify_dump_account ( struct NotifyCallback nc)
static

Definition at line 159 of file notify.c.

160 {
161  struct EventAccount *ev_a = nc->event_data;
162  struct Account *a = ev_a->account;
163 
164  mutt_debug(LL_DEBUG1, " Account: %p (%s) %s\n", a,
165  get_mailbox_type(a->type), NONULL(a->name));
166 }
const char * get_mailbox_type(enum MailboxType type)
Definition: notify.c:70
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
#define NONULL(x)
Definition: string2.h:37
A group of associated Mailboxes.
Definition: account.h:37
enum MailboxType type
Type of Mailboxes this Account contains.
Definition: account.h:38
char * name
Name of Account.
Definition: account.h:39
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 168 of file notify.c.

169 {
170  struct EventColor *ev_c = nc->event_data;
171 
172  const char *color = NULL;
173  const char *scope = "";
174 
175  if (ev_c->color == MT_COLOR_MAX)
176  color = "ALL";
177 
178  if (!color)
180 
181  if (!color)
182  {
184  scope = "compose ";
185  }
186 
187  if (!color)
188  color = "UNKNOWN";
189 
190  mutt_debug(LL_DEBUG1, " Color: %s %s%s (%d)\n",
191  (nc->event_subtype == NT_COLOR_SET) ? "set" : "reset", scope,
192  color, ev_c->color);
193 }
@ MT_COLOR_MAX
Definition: color.h:88
const struct Mapping ComposeColorFields[]
Definition: command.c:91
const struct Mapping ColorFields[]
Definition: command.c:41
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 color
Colour 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 195 of file notify.c.

196 {
197  struct Command *cmd = nc->event_data;
198 
199  if (cmd->data < 4096)
200  mutt_debug(LL_DEBUG1, " Command: %s, data: %ld\n", cmd->name, cmd->data);
201  else
202  mutt_debug(LL_DEBUG1, " Command: %s, data: %p\n", cmd->name, (void *) cmd->data);
203 }
intptr_t data
Data or flags to pass to the command.
Definition: command.h:63
const char * name
Name of the command.
Definition: command.h:48
+ Here is the caller graph for this function:

◆ notify_dump_config()

static void notify_dump_config ( struct NotifyCallback nc)
static

Definition at line 205 of file notify.c.

206 {
207  struct EventConfig *ev_c = nc->event_data;
208 
209  struct Buffer value = mutt_buffer_make(128);
210  cs_he_string_get(ev_c->sub->cs, ev_c->he, &value);
211  mutt_debug(LL_DEBUG1, " Config: %s %s = %s\n", get_config_type(nc->event_subtype),
212  ev_c->name, mutt_buffer_string(&value));
213  mutt_buffer_dealloc(&value);
214 }
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
static const char * get_config_type(int id)
Definition: notify.c:112
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:618
String manipulation buffer.
Definition: buffer.h:34
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:51
A config-change event.
Definition: subset.h:70
const struct ConfigSubset * sub
Config Subset.
Definition: subset.h:71
const char * name
Name of config item that changed.
Definition: subset.h:72
struct HashElem * he
Config item that changed.
Definition: subset.h:73
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notify_dump_context()

static void notify_dump_context ( struct NotifyCallback nc)
static

Definition at line 216 of file notify.c.

217 {
218  struct EventContext *ev_c = nc->event_data;
219 
220  const char *path = "NONE";
221  if (ev_c->ctx && ev_c->ctx->mailbox)
222  path = mailbox_path(ev_c->ctx->mailbox);
223 
224  mutt_debug(LL_DEBUG1, " Context: %s %s\n", get_context(nc->event_subtype), path);
225 }
static const char * get_context(int id)
Definition: notify.c:146
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:215
struct Mailbox * mailbox
Current Mailbox.
Definition: context.h:49
An Event that happened to an Context.
Definition: context.h:69
struct Context * ctx
The Context this Event relates to.
Definition: context.h:70
+ 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 227 of file notify.c.

228 {
229  struct EventEmail *ev_e = nc->event_data;
230 
231  mutt_debug(LL_DEBUG1, " Email: %d\n", ev_e->num_emails);
232  for (size_t i = 0; i < ev_e->num_emails; i++)
233  {
234  mutt_debug(LL_DEBUG1, " : %p\n", ev_e->emails[i]);
235  }
236 }
An Event that happened to an Email.
Definition: email.h:157
int num_emails
Number of Emails the event applies to.
Definition: email.h:158
struct Email ** emails
Emails affected by the event.
Definition: email.h:159
+ Here is the caller graph for this function:

◆ notify_dump_global()

static void notify_dump_global ( struct NotifyCallback nc)
static

Definition at line 238 of file notify.c.

239 {
240  mutt_debug(LL_DEBUG1, " Global: %s\n", get_global_event(nc->event_subtype));
241 }
static const char * get_global_event(int id)
Definition: notify.c:97
+ 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 243 of file notify.c.

244 {
245  struct EventMailbox *ev_m = nc->event_data;
246 
247  struct Mailbox *m = ev_m->mailbox;
248  const char *path = m ? mailbox_path(m) : "";
249  mutt_debug(LL_DEBUG1, " Mailbox: %s %s\n", get_mailbox_event(nc->event_subtype), path);
250 }
static const char * get_mailbox_event(int id)
Definition: notify.c:125
An Event that happened to a Mailbox.
Definition: mailbox.h:191
struct Mailbox * mailbox
The Mailbox this Event relates to.
Definition: mailbox.h:192
A mailbox.
Definition: mailbox.h:82
+ 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 252 of file notify.c.

253 {
254  struct EventWindow *ev_w = nc->event_data;
255  const struct MuttWindow *win = ev_w->win;
256  WindowNotifyFlags flags = ev_w->flags;
257 
258  struct Buffer buf = mutt_buffer_make(128);
259 
260  mutt_buffer_add_printf(&buf, "[%s] ", mutt_window_win_name(win));
261 
262  if (flags & WN_VISIBLE)
263  mutt_buffer_addstr(&buf, "visible ");
264  if (flags & WN_HIDDEN)
265  mutt_buffer_addstr(&buf, "hidden ");
266 
267  if (flags & WN_MOVED)
268  {
269  mutt_buffer_add_printf(&buf, "moved (C%d,R%d)->(C%d,R%d) ",
270  win->old.col_offset, win->old.row_offset,
271  win->state.col_offset, win->state.row_offset);
272  }
273 
274  if (flags & WN_TALLER)
275  mutt_buffer_add_printf(&buf, "taller [%d->%d] ", win->old.rows, win->state.rows);
276  if (flags & WN_SHORTER)
277  mutt_buffer_add_printf(&buf, "shorter [%d->%d] ", win->old.rows, win->state.rows);
278  if (flags & WN_WIDER)
279  mutt_buffer_add_printf(&buf, "wider [%d->%d] ", win->old.cols, win->state.cols);
280  if (flags & WN_NARROWER)
281  mutt_buffer_add_printf(&buf, "narrower [%d->%d] ", win->old.cols, win->state.cols);
282 
283  mutt_debug(LL_DEBUG1, " Window: %s\n", mutt_buffer_string(&buf));
284 
285  mutt_buffer_dealloc(&buf);
286 }
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
int mutt_buffer_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition: buffer.c:203
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
Definition: mutt_window.c:701
#define WN_MOVED
Window moved.
Definition: mutt_window.h:191
uint8_t WindowNotifyFlags
Flags for Changes to a MuttWindow, e.g. WN_TALLER.
Definition: mutt_window.h:185
#define WN_WIDER
Window became wider.
Definition: mutt_window.h:189
#define WN_VISIBLE
Window became visible.
Definition: mutt_window.h:192
#define WN_HIDDEN
Window became hidden.
Definition: mutt_window.h:193
#define WN_TALLER
Window became taller.
Definition: mutt_window.h:187
#define WN_NARROWER
Window became narrower.
Definition: mutt_window.h:190
#define WN_SHORTER
Window became shorter.
Definition: mutt_window.h:188
An Event that happened to a Window.
Definition: mutt_window.h:216
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:218
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 288 of file notify.c.

289 {
290  struct EventWindow *ev_w = nc->event_data;
291  struct MuttWindow *win = ev_w->win;
292 
293  struct Buffer buf = mutt_buffer_make(128);
294 
295  mutt_buffer_addstr(&buf, "Focus: ");
296 
297  if (win)
298  {
299  struct MuttWindow *dlg = dialog_find(win);
300  if (dlg && (dlg != win))
301  mutt_buffer_add_printf(&buf, "%s:", mutt_window_win_name(dlg));
302 
303  mutt_buffer_add_printf(&buf, "%s ", mutt_window_win_name(win));
304 
305  mutt_buffer_add_printf(&buf, "(C%d,R%d) [%dx%d]", win->state.col_offset,
306  win->state.row_offset, win->state.cols, win->state.rows);
307  }
308  else
309  {
310  mutt_buffer_addstr(&buf, "NONE");
311  }
312 
313  mutt_debug(LL_DEBUG1, " Window: %s\n", mutt_buffer_string(&buf));
314 
315  mutt_buffer_dealloc(&buf);
316 }
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:83
+ 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 318 of file notify.c.

319 {
320  mutt_debug(LL_DEBUG1, "\033[1;31mNotification:\033[0m %s\n", get_event_type(nc->event_type));
321 
322  switch (nc->event_type)
323  {
324  case NT_ACCOUNT:
326  break;
327  case NT_COLOR:
328  notify_dump_color(nc);
329  break;
330  case NT_COMMAND:
332  break;
333  case NT_CONFIG:
334  notify_dump_config(nc);
335  break;
336  case NT_CONTEXT:
338  break;
339  case NT_EMAIL:
340  notify_dump_email(nc);
341  break;
342  case NT_GLOBAL:
343  notify_dump_global(nc);
344  break;
345  case NT_MAILBOX:
347  break;
348  case NT_WINDOW:
349  if (nc->event_subtype == NT_WINDOW_STATE)
351  else if (nc->event_subtype == NT_WINDOW_FOCUS)
353  break;
354  default:
355  mutt_debug(LL_DEBUG1, " Event Type: %d\n", nc->event_type);
356  mutt_debug(LL_DEBUG1, " Event Sub-type: %d\n", nc->event_subtype);
357  mutt_debug(LL_DEBUG1, " Event Data: %p\n", nc->event_data);
358  break;
359  }
360 
361  mutt_debug(LL_DEBUG1, " Global Data: %p\n", nc->global_data);
362 
363  mutt_debug(LL_DEBUG5, "debug done\n");
364  return 0;
365 }
static const char * get_event_type(enum NotifyType type)
Definition: notify.c:43
static void notify_dump_global(struct NotifyCallback *nc)
Definition: notify.c:238
static void notify_dump_config(struct NotifyCallback *nc)
Definition: notify.c:205
static void notify_dump_command(struct NotifyCallback *nc)
Definition: notify.c:195
static void notify_dump_context(struct NotifyCallback *nc)
Definition: notify.c:216
static void notify_dump_color(struct NotifyCallback *nc)
Definition: notify.c:168
static void notify_dump_mailbox(struct NotifyCallback *nc)
Definition: notify.c:243
static void notify_dump_window_focus(struct NotifyCallback *nc)
Definition: notify.c:288
static void notify_dump_account(struct NotifyCallback *nc)
Definition: notify.c:159
static void notify_dump_email(struct NotifyCallback *nc)
Definition: notify.c:227
static void notify_dump_window_state(struct NotifyCallback *nc)
Definition: notify.c:252
@ LL_DEBUG5
Log at debug level 5.
Definition: logging.h:44
@ NT_WINDOW_STATE
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:207
@ NT_WINDOW_FOCUS
Window focus has changed.
Definition: mutt_window.h:209
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

Definition at line 1 of file command.c.

◆ ComposeColorFields

const struct Mapping ComposeColorFields[]
extern

Definition at line 1 of file command.c.