source: owl.h @ 5639bf2

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