source: owl.h @ 373b7e7

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