source: owl.h @ bd3f232

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