source: owl.h @ 5d9c664

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