source: owl.h @ 8ba37ec

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