source: owl.h @ a352335c

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