source: owl.h @ 09489b89

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