source: owl.h @ 4b660cc

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 4b660cc was 4b660cc, checked in by James M. Kretchmar <kretch@mit.edu>, 20 years ago
Now have a set of 'aaway' commands and variables just like the 'zaway' ones (except that changing the 'aaway' variable talks to the server) The new 'away' command does everything for both AIM *and* zephyr. There is a known funkiness here, where if you turn one away on, and then use 'away' (or 'A') to toggle, you will turn on off and the other on. Just leaving it for now. Should do better in the next patch. The 'A' key is bound to 'away' Status bar can now read AWAY, Z-AWAY or A-AWAY.
  • Property mode set to 100644
File size: 13.8 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 <signal.h>
11#include <libfaim/aim.h>
12#include "config.h"
13#ifdef HAVE_LIBZEPHYR
14#include <zephyr/zephyr.h>
15#endif
16#ifdef HAVE_COM_ERR_H
17#include <com_err.h>
18#endif
19
20static const char owl_h_fileIdent[] = "$Id$";
21
22#define OWL_VERSION         2.1.1-pre-2
23#define OWL_VERSION_STRING "2.1.1-pre-2"
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
28
29#define OWL_DEBUG 0
30#define OWL_DEBUG_FILE "/var/tmp/owldebug"
31
32#define OWL_CONFIG_DIR "/.owl"             /* this is relative to the user's home directory */
33#define OWL_STARTUP_FILE "/.owl/startup"   /* this is relative to the user's home directory */
34
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
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
60#define OWL_MESSAGE_TYPE_ADMIN      0
61#define OWL_MESSAGE_TYPE_GENERIC    1
62#define OWL_MESSAGE_TYPE_ZEPHYR     2
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
68#define OWL_MESSAGE_TYPE_LOOPBACK   8
69
70#define OWL_MESSAGE_DIRECTION_NONE  0
71#define OWL_MESSAGE_DIRECTION_IN    1
72#define OWL_MESSAGE_DIRECTION_OUT   2
73
74#define OWL_DIRECTION_NONE      0
75#define OWL_DIRECTION_DOWNWARDS 1
76#define OWL_DIRECTION_UPWARDS   2
77
78#define OWL_LOGGING_DIRECTION_BOTH 0
79#define OWL_LOGGING_DIRECTION_IN   1
80#define OWL_LOGGING_DIRECTION_OUT  2
81
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
87#define OWL_SCROLLMODE_PAGEDCENTER 5
88
89#define OWL_STYLE_TYPE_INTERNAL  0
90#define OWL_STYLE_TYPE_PERL      1
91
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
112#define OWL_CTX_EDIT         0x7000
113#define OWL_CTX_EDITLINE     0x1000
114#define OWL_CTX_EDITMULTI    0x2000
115#define OWL_CTX_EDITRESPONSE 0x4000
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
125#define OWL_WEBBROWSER_OPERA    3
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
134#define OWL_KEYMAP_MAXSTACK     20
135
136#define OWL_KEYBINDING_COMMAND  1   /* command string */
137#define OWL_KEYBINDING_FUNCTION 2   /* function taking no args */
138
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"
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"
141
142#define OWL_INCLUDE_REG_TESTS   1  /* whether to build in regression tests */
143
144#define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: "
145
146#define OWL_WEBZEPHYR_PRINCIPAL "daemon.webzephyr"
147#define OWL_WEBZEPHYR_CLASS     "webzephyr"
148#define OWL_WEBZEPHYR_OPCODE    "webzephyr"
149
150#define OWL_REGEX_QUOTECHARS    "+*.?[]^\\"
151#define OWL_REGEX_QUOTEWITH     "\\"
152
153#if defined(HAVE_DES_STRING_TO_KEY) && defined(HAVE_DES_KEY_SCHED) && defined(HAVE_DES_ECB_ENCRYPT)
154#define OWL_ENABLE_ZCRYPT 1
155#endif
156
157#define OWL_META(key) ((key)|0200)
158/* OWL_CTRL is definied in kepress.c */
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 */
168  char *summary;                /* summary of usage */
169  char *description;            /* detailed description */
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 {
261  char *class;
262  char *inst;
263  char *realm;
264  char *opcode;
265  char *zsig;
266  char *message;
267  owl_list recips;
268  int cc;
269  int noping;
270} owl_zwrite;
271
272typedef struct _owl_pair {
273  void *key;
274  void *value;
275} owl_pair;
276
277typedef struct _owl_message {
278  int id;
279  int type;
280  int direction;
281#ifdef HAVE_LIBZEPHYR
282  ZNotice_t notice;
283#endif
284  owl_fmtext fmtext;              /* this is now only a CACHED copy */
285  int invalid_format;             /* indicates whether fmtext needs to be regenerated */
286  int delete;
287  char hostname[MAXHOSTNAMELEN+1];
288  owl_list attributes;            /* this is a list of pairs */
289  char *timestr;
290  time_t time;
291  char *zwriteline;
292} owl_message;
293
294typedef struct _owl_style {
295  char *name;
296  char *description;
297  int type;
298  char *perlfuncname;
299  void (*formatfunc) (owl_fmtext *fm, owl_message *m);
300} owl_style;
301
302typedef struct _owl_mainwin {
303  int curtruncated;
304  int lasttruncated;
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;
341} owl_filterelement;
342
343typedef struct _owl_filter {
344  char *name;
345  int polarity;
346  owl_list fes; /* filterelements */
347  int color;
348  int cachedmsgid;  /* cached msgid: should move into view eventually */
349} owl_filter;
350
351typedef struct _owl_view {
352  char *name;
353  owl_filter *filter;
354  owl_messagelist ml;
355  owl_style *style;
356} owl_view;
357
358typedef struct _owl_history {
359  owl_list hist;
360  int cur;
361  int touched;
362  int partial;
363  int repeats;
364} owl_history;
365
366typedef struct _owl_editwin {
367  char *buff;
368  owl_history *hist;
369  int bufflen;
370  int allocated;
371  int buffx, buffy;
372  int topline;
373  int winlines, wincols, fillcol, wrapcol;
374  WINDOW *curswin;
375  int style;
376  int lock;
377  int dotsend;
378  int echochar;
379} owl_editwin;
380
381typedef struct _owl_keybinding {
382  int  *j;                      /* keypress stack (0-terminated) */ 
383  int   type;                   /* command or function? */
384  char *desc;                   /* description (or "*user*") */
385  char *command;                /* command, if of type command */
386  void (*function_fn)(void);    /* function ptr, if of type function */
387} owl_keybinding;
388
389typedef struct _owl_keymap {
390  char     *name;               /* name of keymap */
391  char     *desc;               /* description */
392  owl_list  bindings;           /* key bindings */
393  struct _owl_keymap *submap;   /* submap */
394  void (*default_fn)(int j);    /* default action (takes a keypress) */
395  void (*prealways_fn)(int j);  /* always called before a keypress is received */
396  void (*postalways_fn)(int j); /* always called after keypress is processed */
397} owl_keymap;
398
399typedef struct _owl_keyhandler {
400  owl_dict  keymaps;            /* dictionary of keymaps */
401  owl_keymap *active;           /* currently active keymap */
402  int       in_esc;             /* escape pressed? */
403  int       kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */
404  int       kpstackpos;         /* location in stack (-1 = none) */
405} owl_keyhandler;
406
407typedef struct _owl_buddy {
408  int proto;
409  char *name;
410  int isidle;
411  int idlesince;
412} owl_buddy;
413
414typedef struct _owl_buddylist {
415  owl_list buddies;
416} owl_buddylist;
417
418typedef struct _owl_zbuddylist {
419  owl_list zusers;
420} owl_zbuddylist;
421
422typedef struct _owl_timer {
423  int direction;
424  time_t starttime;
425  int start;
426} owl_timer;
427
428typedef struct _owl_errqueue {
429  owl_list errlist;
430} owl_errqueue;
431
432typedef struct _owl_global {
433  owl_mainwin mw;
434  owl_popwin pw;
435  owl_history cmdhist;          /* command history */
436  owl_history msghist;          /* outgoing message history */
437  owl_keyhandler kh;
438  owl_list filterlist;
439  owl_list puntlist;
440  owl_vardict vars;
441  owl_cmddict cmds;
442  owl_context ctx;
443  owl_errqueue errqueue;
444  int lines, cols;
445  int curmsg, topmsg;
446  int curmsg_vert_offset;
447  owl_view current_view;
448  owl_messagelist msglist;
449  WINDOW *recwin, *sepwin, *msgwin, *typwin;
450  int needrefresh;
451  int rightshift;
452  int resizepending;
453  int recwinlines;
454  int typwinactive;
455  char *thishost;
456  char *homedir;
457  int direction;
458  int zaway;
459  char *cur_zaway_msg;
460  int haveconfig;
461  int config_format;
462  char *buffercommand;
463  owl_editwin tw;
464  owl_viewwin vw;
465  void *perl;
466  int debug;
467  int starttime;
468  char *startupargs;
469  int userclue;
470  int nextmsgid;
471  int hascolors;
472  int colorpairs;
473  int searchactive;
474  int newmsgproc_pid;
475  int malloced, freed;
476  char *searchstring;
477  owl_filterelement fe_true;
478  owl_filterelement fe_false;
479  owl_filterelement fe_null;
480  aim_session_t aimsess;
481  aim_conn_t bosconn;
482  owl_timer aim_noop_timer;
483  owl_timer aim_ignorelogin_timer;
484  owl_timer aim_buddyinfo_timer;
485  int aim_loggedin;         /* true if currently logged into AIM */
486  int aim_doprocessing;     /* true if we should process AIM events (like pending login) */
487  char *aim_screenname;     /* currently logged in AIM screen name */
488  owl_buddylist buddylist;  /* list of logged in AIM buddies */
489  owl_list messagequeue;    /* for queueing up aim and other messages */
490  owl_dict styledict;       /* global dictionary of available styles */
491  char *response;           /* response to the last question asked */
492  int havezephyr;
493  int haveaim;
494  int got_err_signal;       /* 1 if we got an unexpected signal */
495  siginfo_t err_signal_info;
496  owl_zbuddylist zbuddies;
497  owl_timer zephyr_buddycheck_timer;
498} owl_global;
499
500/* globals */
501extern owl_global g;
502
503#include "owl_prototypes.h"
504
505/* these are missing from the zephyr includes for some reason */
506#ifdef HAVE_LIBZEPHYR
507int ZGetSubscriptions(ZSubscription_t *, int *);
508int ZGetLocations(ZLocations_t *,int *);
509#endif
510
511#endif /* INC_OWL_H */
Note: See TracBrowser for help on using the repository browser.