source: owl.h @ fe6f1d3

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