source: owl.h @ 32eed98

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 32eed98 was 32eed98, checked in by Erik Nygren <nygren@mit.edu>, 20 years ago
2.1.3-pre-2 Added perl filter elements. Similar to having "filter <subfilter>" in a filter, you may also have "perl <functionname>" where <functionname> is passed an owl::Message object and returns 0 or 1 depending on whether the message matches that element of the filter. [Note: currently this overloads the filtername element of the filterelement structure to store the function name. Perhaps we should change the name of this element to something more general to avoid confusion?]
  • Property mode set to 100644
File size: 13.9 KB
Line 
1#ifndef INC_OWL_H
2#define INC_OWL_H
3
4#include <curses.h>
5#include <sys/param.h>
6#include <EXTERN.h>
7#include <netdb.h>
8#include <regex.h>
9#include <time.h>
10#include <signal.h>
11#include <libfaim/aim.h>
12#include "config.h"
13#ifdef HAVE_LIBZEPHYR
14#include <zephyr/zephyr.h>
15#endif
16#ifdef HAVE_COM_ERR_H
17#include <com_err.h>
18#endif
19
20static const char owl_h_fileIdent[] = "$Id$";
21
22#define OWL_VERSION         2.1.3-pre-2
23#define OWL_VERSION_STRING "2.1.3-pre-2"
24
25/* Feature that is being tested to redirect stderr through a pipe.
26 * There may still be some portability problems with this. */
27#define OWL_STDERR_REDIR 1
28
29#define OWL_DEBUG 0
30#define OWL_DEBUG_FILE "/var/tmp/owldebug"
31
32#define OWL_CONFIG_DIR "/.owl"             /* this is relative to the user's home directory */
33#define OWL_STARTUP_FILE "/.owl/startup"   /* this is relative to the user's home directory */
34
35#define OWL_FMTEXT_ATTR_NONE      0
36#define OWL_FMTEXT_ATTR_BOLD      1
37#define OWL_FMTEXT_ATTR_REVERSE   2
38#define OWL_FMTEXT_ATTR_UNDERLINE 4
39
40#define OWL_COLOR_BLACK     0
41#define OWL_COLOR_RED       1
42#define OWL_COLOR_GREEN     2
43#define OWL_COLOR_YELLOW    3
44#define OWL_COLOR_BLUE      4
45#define OWL_COLOR_MAGENTA   5
46#define OWL_COLOR_CYAN      6
47#define OWL_COLOR_WHITE     7
48#define OWL_COLOR_DEFAULT   8
49
50#define OWL_EDITWIN_STYLE_MULTILINE 0
51#define OWL_EDITWIN_STYLE_ONELINE   1
52
53#define OWL_PROTOCOL_ZEPHYR         0
54#define OWL_PROTOCOL_AIM            1
55#define OWL_PROTOCOL_JABBER         2
56#define OWL_PROTOCOL_ICQ            3
57#define OWL_PROTOCOL_YAHOO          4
58#define OWL_PROTOCOL_MSN            5
59
60#define OWL_MESSAGE_TYPE_ADMIN      0
61#define OWL_MESSAGE_TYPE_GENERIC    1
62#define OWL_MESSAGE_TYPE_ZEPHYR     2
63#define OWL_MESSAGE_TYPE_AIM        3
64#define OWL_MESSAGE_TYPE_JABBER     4
65#define OWL_MESSAGE_TYPE_ICQ        5
66#define OWL_MESSAGE_TYPE_YAHOO      6
67#define OWL_MESSAGE_TYPE_MSN        7
68#define OWL_MESSAGE_TYPE_LOOPBACK   8
69
70#define OWL_MESSAGE_DIRECTION_NONE  0
71#define OWL_MESSAGE_DIRECTION_IN    1
72#define OWL_MESSAGE_DIRECTION_OUT   2
73
74#define OWL_DIRECTION_NONE      0
75#define OWL_DIRECTION_DOWNWARDS 1
76#define OWL_DIRECTION_UPWARDS   2
77
78#define OWL_LOGGING_DIRECTION_BOTH 0
79#define OWL_LOGGING_DIRECTION_IN   1
80#define OWL_LOGGING_DIRECTION_OUT  2
81
82#define OWL_SCROLLMODE_NORMAL      0
83#define OWL_SCROLLMODE_TOP         1
84#define OWL_SCROLLMODE_NEARTOP     2
85#define OWL_SCROLLMODE_CENTER      3
86#define OWL_SCROLLMODE_PAGED       4
87#define OWL_SCROLLMODE_PAGEDCENTER 5
88
89#define OWL_STYLE_TYPE_INTERNAL  0
90#define OWL_STYLE_TYPE_PERL      1
91
92#define OWL_TAB               3  /* This *HAS* to be the size of TABSTR below */
93#define OWL_TABSTR        "   "
94#define OWL_MSGTAB            7
95#define OWL_TYPWIN_SIZE       8
96#define OWL_HISTORYSIZE       50
97
98/* Indicate current state, as well as what is allowed */
99#define OWL_CTX_ANY          0xffff
100/* Only one of these may be active at a time... */
101#define OWL_CTX_MODE_BITS    0x000f
102#define OWL_CTX_STARTUP      0x0001
103#define OWL_CTX_READCONFIG   0x0002
104#define OWL_CTX_INTERACTIVE  0x0004
105/* Only one of these may be active at a time... */
106#define OWL_CTX_ACTIVE_BITS  0xfff0
107#define OWL_CTX_POPWIN       0x00f0
108#define OWL_CTX_POPLESS      0x0010
109#define OWL_CTX_RECWIN       0x0f00
110#define OWL_CTX_RECV         0x0100
111#define OWL_CTX_TYPWIN       0xf000
112#define OWL_CTX_EDIT         0x7000
113#define OWL_CTX_EDITLINE     0x1000
114#define OWL_CTX_EDITMULTI    0x2000
115#define OWL_CTX_EDITRESPONSE 0x4000
116
117#define OWL_USERCLUE_NONE       0
118#define OWL_USERCLUE_CLASSES    1
119#define OWL_USERCLUE_FOOBAR     2
120#define OWL_USERCLUE_BAZ        4
121
122#define OWL_WEBBROWSER_NONE     0
123#define OWL_WEBBROWSER_NETSCAPE 1
124#define OWL_WEBBROWSER_GALEON   2
125#define OWL_WEBBROWSER_OPERA    3
126
127#define OWL_VARIABLE_OTHER      0
128#define OWL_VARIABLE_INT        1
129#define OWL_VARIABLE_BOOL       2
130#define OWL_VARIABLE_STRING     3
131
132#define OWL_FILTER_MAX_DEPTH    300
133
134#define OWL_KEYMAP_MAXSTACK     20
135
136#define OWL_KEYBINDING_COMMAND  1   /* command string */
137#define OWL_KEYBINDING_FUNCTION 2   /* function taking no args */
138
139#define OWL_DEFAULT_ZAWAYMSG    "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
140#define OWL_DEFAULT_AAWAYMSG    "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
141
142#define OWL_INCLUDE_REG_TESTS   1  /* whether to build in regression tests */
143
144#define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: "
145
146#define OWL_WEBZEPHYR_PRINCIPAL "daemon.webzephyr"
147#define OWL_WEBZEPHYR_CLASS     "webzephyr"
148#define OWL_WEBZEPHYR_OPCODE    "webzephyr"
149
150#define OWL_REGEX_QUOTECHARS    "+*.?[]^\\"
151#define OWL_REGEX_QUOTEWITH     "\\"
152
153#if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT)
154#define OWL_ENABLE_ZCRYPT 1
155#endif
156
157#define OWL_META(key) ((key)|0200)
158/* OWL_CTRL is definied in kepress.c */
159
160#define LINE 2048
161
162typedef struct _owl_variable {
163  char *name;
164  int   type;  /* OWL_VARIABLE_* */
165  void *pval_default;  /* for types other and string */
166  int   ival_default;  /* for types int and bool     */
167  char *validsettings;          /* documentation of valid settings */
168  char *summary;                /* summary of usage */
169  char *description;            /* detailed description */
170  void *val;                    /* current value */
171  int  (*validate_fn)(struct _owl_variable *v, void *newval);
172                                /* returns 1 if newval is valid */
173  int  (*set_fn)(struct _owl_variable *v, void *newval); 
174                                /* sets the variable to a value
175                                 * of the appropriate type.
176                                 * unless documented, this
177                                 * should make a copy.
178                                 * returns 0 on success. */
179  int  (*set_fromstring_fn)(struct _owl_variable *v, char *newval);
180                                /* sets the variable to a value
181                                 * of the appropriate type.
182                                 * unless documented, this
183                                 * should make a copy.
184                                 * returns 0 on success. */
185  void *(*get_fn)(struct _owl_variable *v);
186                                /* returns a reference to the current value.
187                                 * WARNING:  this approach is hard to make
188                                 * thread-safe... */
189  int  (*get_tostring_fn)(struct _owl_variable *v, 
190                          char *buf, int bufsize, void *val); 
191                                /* converts val to a string
192                                 * and puts into buf */
193  void  (*free_fn)(struct _owl_variable *v);
194                                /* frees val as needed */
195} owl_variable;
196
197typedef struct _owl_fmtext {
198  int textlen;
199  char *textbuff;
200  char *fmbuff;
201  char *colorbuff;
202} owl_fmtext;
203
204typedef struct _owl_list {
205  int size;
206  int avail;
207  void **list;
208} owl_list;
209
210typedef struct _owl_dict_el {
211  char *k;                      /* key   */
212  void *v;                      /* value */
213} owl_dict_el;
214
215typedef struct _owl_dict {
216  int size;
217  int avail;
218  owl_dict_el *els;             /* invariant: sorted by k */
219} owl_dict;
220typedef owl_dict owl_vardict;   /* dict of variables */
221typedef owl_dict owl_cmddict;   /* dict of commands */
222
223typedef struct _owl_context {
224  int   mode;
225  void *data;           /* determined by mode */
226} owl_context;
227
228typedef struct _owl_cmd {       /* command */
229  char *name;
230
231  char *summary;                /* one line summary of command */
232  char *usage;                  /* usage synopsis */
233  char *description;            /* long description of command */
234
235  int validctx;                 /* bitmask of valid contexts */
236
237  /* we should probably have a type here that says which of
238   * the following is valid, and maybe make the below into a union... */
239
240  /* Only one of these may be non-NULL ... */
241
242  char *cmd_aliased_to;         /* what this command is aliased to... */
243 
244  /* These don't take any context */
245  char *(*cmd_args_fn)(int argc, char **argv, char *buff); 
246                                /* takes argv and the full command as buff.
247                                 * caller must free return value if !NULL */
248  void (*cmd_v_fn)(void);       /* takes no args */
249  void (*cmd_i_fn)(int i);      /* takes an int as an arg */
250
251  /* The following also take the active context if it's valid */
252  char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); 
253                                /* takes argv and the full command as buff.
254                                 * caller must free return value if !NULL */
255  void (*cmd_ctxv_fn)(void *ctx);               /* takes no args */
256  void (*cmd_ctxi_fn)(void *ctx, int i);        /* takes an int as an arg */
257} owl_cmd;
258
259
260typedef struct _owl_zwrite {
261  char *class;
262  char *inst;
263  char *realm;
264  char *opcode;
265  char *zsig;
266  char *message;
267  owl_list recips;
268  int cc;
269  int noping;
270} owl_zwrite;
271
272typedef struct _owl_pair {
273  void *key;
274  void *value;
275} owl_pair;
276
277typedef struct _owl_message {
278  int id;
279  int type;
280  int direction;
281#ifdef HAVE_LIBZEPHYR
282  ZNotice_t notice;
283#endif
284  owl_fmtext fmtext;              /* this is now only a CACHED copy */
285  int invalid_format;             /* indicates whether fmtext needs to be regenerated */
286  int delete;
287  char hostname[MAXHOSTNAMELEN+1];
288  owl_list attributes;            /* this is a list of pairs */
289  char *timestr;
290  time_t time;
291  char *zwriteline;
292} owl_message;
293
294typedef struct _owl_style {
295  char *name;
296  char *description;
297  int type;
298  char *perlfuncname;
299  void (*formatfunc) (owl_fmtext *fm, owl_message *m);
300} owl_style;
301
302typedef struct _owl_mainwin {
303  int curtruncated;
304  int lasttruncated;
305  int lastdisplayed;
306} owl_mainwin;
307
308typedef struct _owl_viewwin {
309  owl_fmtext fmtext;
310  int textlines;
311  int topline;
312  int rightshift;
313  int winlines, wincols;
314  WINDOW *curswin;
315} owl_viewwin;
316 
317typedef struct _owl_popwin {
318  WINDOW *borderwin;
319  WINDOW *popwin;
320  int lines;
321  int cols;
322  int active;
323  int needsfirstrefresh;
324  void (*handler) (int ch);
325} owl_popwin;
326
327typedef struct _owl_messagelist {
328  owl_list list;
329} owl_messagelist;
330
331typedef struct _owl_regex {
332  int negate;
333  char *string;
334  regex_t re;
335} owl_regex;
336
337typedef struct _owl_filterelement {
338  int type;
339  char *field;
340  owl_regex re;
341  char *filtername;  /* for maching on another filter */
342} owl_filterelement;
343
344typedef struct _owl_filter {
345  char *name;
346  int polarity;
347  owl_list fes; /* filterelements */
348  int color;
349  int cachedmsgid;  /* cached msgid: should move into view eventually */
350} owl_filter;
351
352typedef struct _owl_view {
353  char *name;
354  owl_filter *filter;
355  owl_messagelist ml;
356  owl_style *style;
357} owl_view;
358
359typedef struct _owl_history {
360  owl_list hist;
361  int cur;
362  int touched;
363  int partial;
364  int repeats;
365} owl_history;
366
367typedef struct _owl_editwin {
368  char *buff;
369  owl_history *hist;
370  int bufflen;
371  int allocated;
372  int buffx, buffy;
373  int topline;
374  int winlines, wincols, fillcol, wrapcol;
375  WINDOW *curswin;
376  int style;
377  int lock;
378  int dotsend;
379  int echochar;
380} owl_editwin;
381
382typedef struct _owl_keybinding {
383  int  *j;                      /* keypress stack (0-terminated) */ 
384  int   type;                   /* command or function? */
385  char *desc;                   /* description (or "*user*") */
386  char *command;                /* command, if of type command */
387  void (*function_fn)(void);    /* function ptr, if of type function */
388} owl_keybinding;
389
390typedef struct _owl_keymap {
391  char     *name;               /* name of keymap */
392  char     *desc;               /* description */
393  owl_list  bindings;           /* key bindings */
394  struct _owl_keymap *submap;   /* submap */
395  void (*default_fn)(int j);    /* default action (takes a keypress) */
396  void (*prealways_fn)(int j);  /* always called before a keypress is received */
397  void (*postalways_fn)(int j); /* always called after keypress is processed */
398} owl_keymap;
399
400typedef struct _owl_keyhandler {
401  owl_dict  keymaps;            /* dictionary of keymaps */
402  owl_keymap *active;           /* currently active keymap */
403  int       in_esc;             /* escape pressed? */
404  int       kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */
405  int       kpstackpos;         /* location in stack (-1 = none) */
406} owl_keyhandler;
407
408typedef struct _owl_buddy {
409  int proto;
410  char *name;
411  int isidle;
412  int idlesince;
413} owl_buddy;
414
415typedef struct _owl_buddylist {
416  owl_list buddies;
417} owl_buddylist;
418
419typedef struct _owl_zbuddylist {
420  owl_list zusers;
421} owl_zbuddylist;
422
423typedef struct _owl_timer {
424  int direction;
425  time_t starttime;
426  int start;
427} owl_timer;
428
429typedef struct _owl_errqueue {
430  owl_list errlist;
431} owl_errqueue;
432
433typedef struct _owl_global {
434  owl_mainwin mw;
435  owl_popwin pw;
436  owl_history cmdhist;          /* command history */
437  owl_history msghist;          /* outgoing message history */
438  owl_keyhandler kh;
439  owl_list filterlist;
440  owl_list puntlist;
441  owl_vardict vars;
442  owl_cmddict cmds;
443  owl_context ctx;
444  owl_errqueue errqueue;
445  int lines, cols;
446  int curmsg, topmsg;
447  int curmsg_vert_offset;
448  owl_view current_view;
449  owl_messagelist msglist;
450  WINDOW *recwin, *sepwin, *msgwin, *typwin;
451  int needrefresh;
452  int rightshift;
453  int resizepending;
454  int recwinlines;
455  int typwinactive;
456  char *thishost;
457  char *homedir;
458  int direction;
459  int zaway;
460  char *cur_zaway_msg;
461  int haveconfig;
462  int config_format;
463  char *buffercommand;
464  owl_editwin tw;
465  owl_viewwin vw;
466  void *perl;
467  int debug;
468  int starttime;
469  char *startupargs;
470  int userclue;
471  int nextmsgid;
472  int hascolors;
473  int colorpairs;
474  int searchactive;
475  int newmsgproc_pid;
476  int malloced, freed;
477  char *searchstring;
478  owl_filterelement fe_true;
479  owl_filterelement fe_false;
480  owl_filterelement fe_null;
481  aim_session_t aimsess;
482  aim_conn_t bosconn;
483  owl_timer aim_noop_timer;
484  owl_timer aim_ignorelogin_timer;
485  owl_timer aim_buddyinfo_timer;
486  int aim_loggedin;         /* true if currently logged into AIM */
487  int aim_doprocessing;     /* true if we should process AIM events (like pending login) */
488  char *aim_screenname;     /* currently logged in AIM screen name */
489  owl_buddylist buddylist;  /* list of logged in AIM buddies */
490  owl_list messagequeue;    /* for queueing up aim and other messages */
491  owl_dict styledict;       /* global dictionary of available styles */
492  char *response;           /* response to the last question asked */
493  int havezephyr;
494  int haveaim;
495  int got_err_signal;       /* 1 if we got an unexpected signal */
496  siginfo_t err_signal_info;
497  owl_zbuddylist zbuddies;
498  owl_timer zephyr_buddycheck_timer;
499} owl_global;
500
501/* globals */
502extern owl_global g;
503
504#include "owl_prototypes.h"
505
506/* these are missing from the zephyr includes for some reason */
507#ifdef HAVE_LIBZEPHYR
508int ZGetSubscriptions(ZSubscription_t *, int *);
509int ZGetLocations(ZLocations_t *,int *);
510#endif
511
512#endif /* INC_OWL_H */
Note: See TracBrowser for help on using the repository browser.