source: owl.h @ 6a415e9

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