source: owl.h @ 8d0796c0

owl
Last change on this file since 8d0796c0 was d1948ce, checked in by James M. Kretchmar <kretch@mit.edu>, 15 years ago
2.1.12 included a patch that breaks opaque resizing for some versions of ncurses on solaris. Reverting that part of the change to fix.
  • Property mode set to 100644
File size: 15.5 KB
Line 
1/* Copyright (c) 2002,2003,2004,2009 James M. Kretchmar
2 *
3 * This file is part of Owl.
4 *
5 * Owl is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * Owl is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with Owl.  If not, see <http://www.gnu.org/licenses/>.
17 *
18 * ---------------------------------------------------------------
19 *
20 * As of Owl version 2.1.12 there are patches contributed by
21 * developers of the branched BarnOwl project, Copyright (c)
22 * 2006-2009 The BarnOwl Developers. All rights reserved.
23 */
24
25#ifndef INC_OWL_H
26#define INC_OWL_H
27
28#include <curses.h>
29#include <sys/param.h>
30#include <EXTERN.h>
31#include <netdb.h>
32#include <regex.h>
33#include <time.h>
34#include <signal.h>
35#include <termios.h>
36#include <glib.h>
37#include <libfaim/aim.h>
38#include "config.h"
39#ifdef HAVE_LIBZEPHYR
40#include <zephyr/zephyr.h>
41#endif
42#ifdef HAVE_COM_ERR_H
43#include <com_err.h>
44#endif
45
46static const char owl_h_fileIdent[] = "$Id$";
47
48#define OWL_VERSION         2.2.2
49#define OWL_VERSION_STRING "2.2.2"
50
51/* Feature that is being tested to redirect stderr through a pipe.
52 * There may still be some portability problems with this. */
53#define OWL_STDERR_REDIR 1
54
55#define OWL_DEBUG 0
56#define OWL_DEBUG_FILE "/var/tmp/owldebug"
57
58#define OWL_CONFIG_DIR "/.owl"             /* this is relative to the user's home directory */
59#define OWL_STARTUP_FILE "/.owl/startup"   /* this is relative to the user's home directory */
60
61#define OWL_FMTEXT_ATTR_NONE      0
62#define OWL_FMTEXT_ATTR_BOLD      1
63#define OWL_FMTEXT_ATTR_REVERSE   2
64#define OWL_FMTEXT_ATTR_UNDERLINE 4
65
66#define OWL_COLOR_BLACK     0
67#define OWL_COLOR_RED       1
68#define OWL_COLOR_GREEN     2
69#define OWL_COLOR_YELLOW    3
70#define OWL_COLOR_BLUE      4
71#define OWL_COLOR_MAGENTA   5
72#define OWL_COLOR_CYAN      6
73#define OWL_COLOR_WHITE     7
74#define OWL_COLOR_DEFAULT   8
75
76#define OWL_EDITWIN_STYLE_MULTILINE 0
77#define OWL_EDITWIN_STYLE_ONELINE   1
78
79#define OWL_PROTOCOL_ZEPHYR         0
80#define OWL_PROTOCOL_AIM            1
81#define OWL_PROTOCOL_JABBER         2
82#define OWL_PROTOCOL_ICQ            3
83#define OWL_PROTOCOL_YAHOO          4
84#define OWL_PROTOCOL_MSN            5
85
86#define OWL_MESSAGE_TYPE_ADMIN      0
87#define OWL_MESSAGE_TYPE_GENERIC    1
88#define OWL_MESSAGE_TYPE_ZEPHYR     2
89#define OWL_MESSAGE_TYPE_AIM        3
90#define OWL_MESSAGE_TYPE_JABBER     4
91#define OWL_MESSAGE_TYPE_ICQ        5
92#define OWL_MESSAGE_TYPE_YAHOO      6
93#define OWL_MESSAGE_TYPE_MSN        7
94#define OWL_MESSAGE_TYPE_LOOPBACK   8
95
96#define OWL_MESSAGE_DIRECTION_NONE  0
97#define OWL_MESSAGE_DIRECTION_IN    1
98#define OWL_MESSAGE_DIRECTION_OUT   2
99
100#define OWL_MUX_READ   1
101#define OWL_MUX_WRITE  2
102#define OWL_MUX_EXCEPT 4
103
104#define OWL_DIRECTION_NONE      0
105#define OWL_DIRECTION_DOWNWARDS 1
106#define OWL_DIRECTION_UPWARDS   2
107
108#define OWL_LOGGING_DIRECTION_BOTH 0
109#define OWL_LOGGING_DIRECTION_IN   1
110#define OWL_LOGGING_DIRECTION_OUT  2
111
112#define OWL_SCROLLMODE_NORMAL      0
113#define OWL_SCROLLMODE_TOP         1
114#define OWL_SCROLLMODE_NEARTOP     2
115#define OWL_SCROLLMODE_CENTER      3
116#define OWL_SCROLLMODE_PAGED       4
117#define OWL_SCROLLMODE_PAGEDCENTER 5
118
119#define OWL_STYLE_TYPE_INTERNAL  0
120#define OWL_STYLE_TYPE_PERL      1
121
122#define OWL_TAB               3  /* This *HAS* to be the size of TABSTR below */
123#define OWL_TABSTR        "   "
124#define OWL_MSGTAB            7
125#define OWL_TYPWIN_SIZE       8
126#define OWL_HISTORYSIZE       50
127
128/* Indicate current state, as well as what is allowed */
129#define OWL_CTX_ANY          0xffff
130/* Only one of these may be active at a time... */
131#define OWL_CTX_MODE_BITS    0x000f
132#define OWL_CTX_STARTUP      0x0001
133#define OWL_CTX_READCONFIG   0x0002
134#define OWL_CTX_INTERACTIVE  0x0004
135/* Only one of these may be active at a time... */
136#define OWL_CTX_ACTIVE_BITS  0xfff0
137#define OWL_CTX_POPWIN       0x00f0
138#define OWL_CTX_POPLESS      0x0010
139#define OWL_CTX_RECWIN       0x0f00
140#define OWL_CTX_RECV         0x0100
141#define OWL_CTX_TYPWIN       0xf000
142#define OWL_CTX_EDIT         0x7000
143#define OWL_CTX_EDITLINE     0x1000
144#define OWL_CTX_EDITMULTI    0x2000
145#define OWL_CTX_EDITRESPONSE 0x4000
146
147#define OWL_USERCLUE_NONE       0
148#define OWL_USERCLUE_CLASSES    1
149#define OWL_USERCLUE_FOOBAR     2
150#define OWL_USERCLUE_BAZ        4
151
152#define OWL_WEBBROWSER_NONE     0
153#define OWL_WEBBROWSER_NETSCAPE 1
154#define OWL_WEBBROWSER_GALEON   2
155#define OWL_WEBBROWSER_OPERA    3
156
157#define OWL_VARIABLE_OTHER      0
158#define OWL_VARIABLE_INT        1
159#define OWL_VARIABLE_BOOL       2
160#define OWL_VARIABLE_STRING     3
161
162#define OWL_FILTER_MAX_DEPTH    300
163
164#define OWL_KEYMAP_MAXSTACK     20
165
166#define OWL_KEYBINDING_COMMAND  1   /* command string */
167#define OWL_KEYBINDING_FUNCTION 2   /* function taking no args */
168
169#define OWL_DEFAULT_ZAWAYMSG    "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
170#define OWL_DEFAULT_AAWAYMSG    "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
171
172#define OWL_INCLUDE_REG_TESTS   1  /* whether to build in regression tests */
173
174#define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: "
175
176#define OWL_WEBZEPHYR_PRINCIPAL "daemon.webzephyr"
177#define OWL_WEBZEPHYR_CLASS     "webzephyr"
178#define OWL_WEBZEPHYR_OPCODE    "webzephyr"
179
180#define OWL_REGEX_QUOTECHARS    "+*.?[]^\\${}()"
181#define OWL_REGEX_QUOTEWITH     "\\"
182
183#if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT)
184#define OWL_ENABLE_ZCRYPT 1
185#endif
186
187#define OWL_META(key) ((key)|0200)
188/* OWL_CTRL is definied in kepress.c */
189
190#define LINE 2048
191
192typedef struct _owl_variable {
193  char *name;
194  int   type;  /* OWL_VARIABLE_* */
195  void *pval_default;  /* for types other and string */
196  int   ival_default;  /* for types int and bool     */
197  char *validsettings;          /* documentation of valid settings */
198  char *summary;                /* summary of usage */
199  char *description;            /* detailed description */
200  void *val;                    /* current value */
201  int  (*validate_fn)(struct _owl_variable *v, void *newval);
202                                /* returns 1 if newval is valid */
203  int  (*set_fn)(struct _owl_variable *v, void *newval); 
204                                /* sets the variable to a value
205                                 * of the appropriate type.
206                                 * unless documented, this
207                                 * should make a copy.
208                                 * returns 0 on success. */
209  int  (*set_fromstring_fn)(struct _owl_variable *v, char *newval);
210                                /* sets the variable to a value
211                                 * of the appropriate type.
212                                 * unless documented, this
213                                 * should make a copy.
214                                 * returns 0 on success. */
215  void *(*get_fn)(struct _owl_variable *v);
216                                /* returns a reference to the current value.
217                                 * WARNING:  this approach is hard to make
218                                 * thread-safe... */
219  int  (*get_tostring_fn)(struct _owl_variable *v, 
220                          char *buf, int bufsize, void *val); 
221                                /* converts val to a string
222                                 * and puts into buf */
223  void  (*free_fn)(struct _owl_variable *v);
224                                /* frees val as needed */
225} owl_variable;
226
227typedef struct _owl_fmtext {
228  int textlen;
229  char *textbuff;
230  char *fmbuff;
231  char *colorbuff;
232} owl_fmtext;
233
234typedef struct _owl_list {
235  int size;
236  int avail;
237  void **list;
238} owl_list;
239
240typedef struct _owl_dict_el {
241  char *k;                      /* key   */
242  void *v;                      /* value */
243} owl_dict_el;
244
245typedef struct _owl_dict {
246  int size;
247  int avail;
248  owl_dict_el *els;             /* invariant: sorted by k */
249} owl_dict;
250typedef owl_dict owl_vardict;   /* dict of variables */
251typedef owl_dict owl_cmddict;   /* dict of commands */
252
253typedef struct _owl_context {
254  int   mode;
255  void *data;           /* determined by mode */
256} owl_context;
257
258typedef struct _owl_cmd {       /* command */
259  char *name;
260
261  char *summary;                /* one line summary of command */
262  char *usage;                  /* usage synopsis */
263  char *description;            /* long description of command */
264
265  int validctx;                 /* bitmask of valid contexts */
266
267  /* we should probably have a type here that says which of
268   * the following is valid, and maybe make the below into a union... */
269
270  /* Only one of these may be non-NULL ... */
271
272  char *cmd_aliased_to;         /* what this command is aliased to... */
273 
274  /* These don't take any context */
275  char *(*cmd_args_fn)(int argc, char **argv, char *buff); 
276                                /* takes argv and the full command as buff.
277                                 * caller must free return value if !NULL */
278  void (*cmd_v_fn)(void);       /* takes no args */
279  void (*cmd_i_fn)(int i);      /* takes an int as an arg */
280
281  /* The following also take the active context if it's valid */
282  char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); 
283                                /* takes argv and the full command as buff.
284                                 * caller must free return value if !NULL */
285  void (*cmd_ctxv_fn)(void *ctx);               /* takes no args */
286  void (*cmd_ctxi_fn)(void *ctx, int i);        /* takes an int as an arg */
287} owl_cmd;
288
289
290typedef struct _owl_zwrite {
291  char *class;
292  char *inst;
293  char *realm;
294  char *opcode;
295  char *zsig;
296  char *message;
297  owl_list recips;
298  int cc;
299  int noping;
300} owl_zwrite;
301
302typedef struct _owl_pair {
303  void *key;
304  void *value;
305} owl_pair;
306
307typedef struct _owl_message {
308  int id;
309  int type;
310  int direction;
311#ifdef HAVE_LIBZEPHYR
312  ZNotice_t notice;
313#endif
314  owl_fmtext fmtext;              /* this is now only a CACHED copy */
315  int invalid_format;             /* indicates whether fmtext needs to be regenerated */
316  int delete;
317  char *hostname;
318  owl_list attributes;            /* this is a list of pairs */
319  char *timestr;
320  time_t time;
321  char *zwriteline;
322} owl_message;
323
324typedef struct _owl_style {
325  char *name;
326  char *description;
327  int type;
328  char *perlfuncname;
329  void (*formatfunc) (owl_fmtext *fm, owl_message *m);
330} owl_style;
331
332typedef struct _owl_mainwin {
333  int curtruncated;
334  int lasttruncated;
335  int lastdisplayed;
336} owl_mainwin;
337
338typedef struct _owl_viewwin {
339  owl_fmtext fmtext;
340  int textlines;
341  int topline;
342  int rightshift;
343  int winlines, wincols;
344  WINDOW *curswin;
345  void (*onclose_hook) (struct _owl_viewwin *vwin, void *data);
346  void *onclose_hook_data;
347} owl_viewwin;
348 
349typedef struct _owl_popwin {
350  WINDOW *borderwin;
351  WINDOW *popwin;
352  int lines;
353  int cols;
354  int active;
355  int needsfirstrefresh;
356  void (*handler) (int ch);
357} owl_popwin;
358
359typedef struct _owl_dispatch {
360  int fd;                                 /* FD to watch for dispatch. */
361  int needs_gc;
362  void (*cfunc)(struct _owl_dispatch*);   /* C function to dispatch to. */
363  void (*destroy)(struct _owl_dispatch*); /* Destructor */
364  void *data;
365} owl_dispatch;
366
367typedef struct _owl_popexec {
368  int refcount;
369  owl_viewwin *vwin;
370  int winactive;
371  int pid;                      /* or 0 if it has terminated */
372  owl_dispatch dispatch;
373} owl_popexec;
374
375typedef struct _owl_messagelist {
376  owl_list list;
377} owl_messagelist;
378
379typedef struct _owl_regex {
380  int negate;
381  char *string;
382  regex_t re;
383} owl_regex;
384
385typedef struct _owl_filterelement {
386  int type;
387  char *field;
388  owl_regex re;
389  char *filtername;  /* for maching on another filter */
390} owl_filterelement;
391
392typedef struct _owl_filter {
393  char *name;
394  int polarity;
395  owl_list fes; /* filterelements */
396  int color;
397  int cachedmsgid;  /* cached msgid: should move into view eventually */
398} owl_filter;
399
400typedef struct _owl_view {
401  char *name;
402  owl_filter *filter;
403  owl_messagelist ml;
404  owl_style *style;
405} owl_view;
406
407typedef struct _owl_history {
408  owl_list hist;
409  int cur;
410  int touched;
411  int partial;
412  int repeats;
413} owl_history;
414
415typedef struct _owl_editwin {
416  char *buff;
417  owl_history *hist;
418  int bufflen;
419  int allocated;
420  int buffx, buffy;
421  int topline;
422  int winlines, wincols, fillcol, wrapcol;
423  WINDOW *curswin;
424  int style;
425  int lock;
426  int dotsend;
427  int echochar;
428} owl_editwin;
429
430typedef struct _owl_keybinding {
431  int  *j;                      /* keypress stack (0-terminated) */ 
432  int   type;                   /* command or function? */
433  char *desc;                   /* description (or "*user*") */
434  char *command;                /* command, if of type command */
435  void (*function_fn)(void);    /* function ptr, if of type function */
436} owl_keybinding;
437
438typedef struct _owl_keymap {
439  char     *name;               /* name of keymap */
440  char     *desc;               /* description */
441  owl_list  bindings;           /* key bindings */
442  struct _owl_keymap *submap;   /* submap */
443  void (*default_fn)(int j);    /* default action (takes a keypress) */
444  void (*prealways_fn)(int j);  /* always called before a keypress is received */
445  void (*postalways_fn)(int j); /* always called after keypress is processed */
446} owl_keymap;
447
448typedef struct _owl_keyhandler {
449  owl_dict  keymaps;            /* dictionary of keymaps */
450  owl_keymap *active;           /* currently active keymap */
451  int       in_esc;             /* escape pressed? */
452  int       kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */
453  int       kpstackpos;         /* location in stack (-1 = none) */
454} owl_keyhandler;
455
456typedef struct _owl_buddy {
457  int proto;
458  char *name;
459  int isidle;
460  int idlesince;
461} owl_buddy;
462
463typedef struct _owl_buddylist {
464  owl_list buddies;
465} owl_buddylist;
466
467typedef struct _owl_zbuddylist {
468  owl_list zusers;
469} owl_zbuddylist;
470
471typedef struct _owl_timer {
472  int direction;
473  time_t starttime;
474  int start;
475} owl_timer;
476
477typedef struct _owl_errqueue {
478  owl_list errlist;
479} owl_errqueue;
480
481typedef struct _owl_global {
482  owl_mainwin mw;
483  owl_popwin pw;
484  owl_history cmdhist;          /* command history */
485  owl_history msghist;          /* outgoing message history */
486  owl_keyhandler kh;
487  owl_list filterlist;
488  owl_list puntlist;
489  owl_vardict vars;
490  owl_cmddict cmds;
491  owl_context ctx;
492  owl_errqueue errqueue;
493  int lines, cols;
494  int curmsg, topmsg;
495  int curmsg_vert_offset;
496  owl_view current_view;
497  owl_messagelist msglist;
498  WINDOW *recwin, *sepwin, *msgwin, *typwin;
499  int needrefresh;
500  int rightshift;
501  int resizepending;
502  int recwinlines;
503  int typwinactive;
504  char *thishost;
505  char *homedir;
506  int direction;
507  int zaway;
508  char *cur_zaway_msg;
509  int haveconfig;
510  int config_format;
511  char *buffercommand;
512  owl_editwin tw;
513  owl_viewwin vw;
514  void *perl;
515  int debug;
516  int starttime;
517  char *startupargs;
518  int userclue;
519  int nextmsgid;
520  int hascolors;
521  int colorpairs;
522  int searchactive;
523  int newmsgproc_pid;
524  int malloced, freed;
525  char *searchstring;
526  owl_filterelement fe_true;
527  owl_filterelement fe_false;
528  owl_filterelement fe_null;
529  aim_session_t aimsess;
530  aim_conn_t bosconn;
531  owl_timer aim_noop_timer;
532  owl_timer aim_ignorelogin_timer;
533  owl_timer aim_buddyinfo_timer;
534  int aim_loggedin;         /* true if currently logged into AIM */
535  int aim_doprocessing;     /* true if we should process AIM events (like pending login) */
536  char *aim_screenname;     /* currently logged in AIM screen name */
537  owl_buddylist buddylist;  /* list of logged in AIM buddies */
538  owl_list messagequeue;    /* for queueing up aim and other messages */
539  owl_dict styledict;       /* global dictionary of available styles */
540  char *response;           /* response to the last question asked */
541  int havezephyr;
542  int haveaim;
543  int got_err_signal;       /* 1 if we got an unexpected signal */
544  siginfo_t err_signal_info;
545  owl_zbuddylist zbuddies;
546  owl_timer zephyr_buddycheck_timer;
547  struct termios startup_tio;
548  owl_list dispatchlist;
549} owl_global;
550
551/* globals */
552extern owl_global g;
553
554#include "owl_prototypes.h"
555
556/* these are missing from the zephyr includes for some reason */
557#ifdef HAVE_LIBZEPHYR
558int ZGetSubscriptions(ZSubscription_t *, int *);
559int ZGetLocations(ZLocations_t *,int *);
560#endif
561
562#endif /* INC_OWL_H */
Note: See TracBrowser for help on using the repository browser.