wmauda: Fix installation dir
[dockapps.git] / wmbiff-0.4.27 / wmbiff / Client.h
blob607ba76328d3519cfbd2ce48f968417fde8c0d17
1 /* $Id: Client.h,v 1.42 2005/05/08 21:31:22 bluehal Exp $ */
2 /* Author : Scott Holden ( scotth@thezone.net )
3 Modified : Yong-iL Joh ( tolkien@mizi.com )
4 Modified : Jorge GarcĂ­a ( Jorge.Garcia@uv.es )
6 * Email Checker Pop3/Imap4/Gicu/mbox/maildir/finger
8 * Last Updated : $Date: 2005/05/08 21:31:22 $
12 #ifndef CLIENT
13 #define CLIENT
14 #ifdef HAVE_CONFIG_H
15 #include <config.h>
16 #endif
18 #include <string.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <sys/time.h>
23 #ifdef HAVE_GCRYPT_H
24 #include <gcrypt.h>
25 #endif
27 #ifdef __LCLINT__
28 typedef unsigned int off_t;
29 #endif
31 #define BUF_BIG 256
32 #define BUF_SMALL 32
33 #define BUF_SIZE 1024
35 struct msglst;
36 typedef struct _mbox_t *Pop3;
37 typedef struct _mbox_t {
38 char label[BUF_SMALL]; /* Printed at left; max 5 chars */
39 char path[BUF_BIG]; /* Path to mailbox */
40 char notify[BUF_BIG]; /* Program to notify mail arrivation */
41 char action[BUF_BIG]; /* Action to execute on mouse click, reduces to
42 * what happens on button1. this is executed after
43 * either actionnew or actionnonew (if they are
44 * defined in the config file) */
45 char actionnew[BUF_BIG]; /* Action to execute on mouse click when new mail */
46 char actionnonew[BUF_BIG]; /* Action to execute on mouse click when no new mail */
47 char actiondc[BUF_BIG]; /* Action to execute when icq is disconnected */
48 char button2[BUF_BIG]; /* What to run on button2. (middle) */
49 char fetchcmd[BUF_BIG]; /* Action for mail fetching for pop3/imap, reduces to what happens on button3 */
50 int fetchinterval;
51 int TotalMsgs; /* Total messages in mailbox */
52 int UnreadMsgs; /* New (unread) messages in mailbox */
53 int OldMsgs;
54 int OldUnreadMsgs;
55 char TextStatus[10]; /* if set to a string, toupper() and blit
56 * that string. instead of a message count */
57 int blink_stat; /* blink digits flag-counter */
58 int debug; /* debugging status */
60 struct msglst *headerCache;
62 union {
63 struct {
64 time_t mtime;
65 off_t size;
66 } mbox;
67 struct {
68 char *detail;
69 } shell;
70 struct {
71 time_t mtime_new;
72 off_t size_new;
73 time_t mtime_cur;
74 off_t size_cur;
75 unsigned int dircache_flush:1; /* hack to flush directory caches */
76 } maildir;
77 struct {
78 char password[BUF_SMALL];
79 char userName[BUF_SMALL];
80 char serverName[BUF_BIG];
81 int serverPort;
82 int localPort;
83 char authList[100];
84 unsigned int dossl:1; /* use tls. */
85 /* prompt the user if we can't login / password is empty */
86 unsigned int interactive_password:1;
87 /* using the msglst feature, fetch the headers
88 to have them on hand */
89 unsigned int wantCacheHeaders:1;
90 unsigned char password_len; /* memfrob may shorten passwords */
91 } pop_imap;
92 } u;
94 int (*checkMail) ( /*@notnull@ */ Pop3);
96 /* collect the headers to show in a pop up */
97 struct msglst *(*getHeaders) ( /*@notnull@ */ Pop3);
98 /* allow the client to free the headers, or keep them cached */
99 void (*releaseHeaders) ( /*@notnull@ */ Pop3, struct msglst * ml);
101 time_t prevtime;
102 time_t prevfetch_time;
103 int loopinterval; /* loop interval for this mailbox */
105 /* command to execute to get a password, if needed */
106 const char *askpass;
107 } mbox_t;
109 /* creation calls must have this prototype */
110 int pop3Create( /*@notnull@ */ Pop3 pc, const char *str);
111 int imap4Create( /*@notnull@ */ Pop3 pc, const char *str);
112 int shellCreate( /*@notnull@ */ Pop3 pc, const char *str);
113 int mboxCreate( /*@notnull@ */ Pop3 pc, const char *str);
114 int maildirCreate( /*@notnull@ */ Pop3 pc, const char *str);
116 int sock_connect(const char *hostname, int port);
117 FILE *openMailbox(Pop3 pc, const char *mbox_filename);
119 /* backtickExpand returns null on failure */
120 /*@null@ */
121 char *backtickExpand(Pop3 pc, const char *path);
122 int fileHasChanged(const char *mbox_filename, time_t * atime,
123 time_t * mtime, off_t * size);
124 int grabCommandOutput(Pop3 pc, const char *command,
125 /*@out@ */ char **output,
126 /*@out@ *//*@null@ */ char **details);
127 int exists(const char *filename); /* test -f */
129 /* _NONE is for silent operation. _ERROR is for things that should
130 be printed assuming that the user might possibly see them. _INFO is
131 for reasonably useless but possibly interesting messages. _ALL is
132 for everything. Restated, _ERROR will always be printed, _INFO only
133 if debugging messages were requested. */
134 #define DEBUG_NONE 0
135 #define DEBUG_ERROR 1
136 #define DEBUG_INFO 2
137 #define DEBUG_ALL 2
138 /* inspired by ksymoops-2.3.4/ksymoops.h */
139 #define DM(mbox, msglevel, X...) \
140 do { \
141 if (mbox == NULL || (mbox)->debug >= msglevel) { \
142 printf("wmbiff/%s ", (mbox != NULL) ? (mbox)->label : "NULL"); \
143 printf(X); \
144 (void)fflush(NULL); \
146 } while(0)
148 extern int debug_default;
149 #define DMA(msglevel, X...) \
150 do { \
151 if (debug_default >= msglevel) { \
152 printf("wmbiff: " X); \
153 (void)fflush(NULL); \
155 } while(0)
157 /* technique used in apache to allow GCC's attribute tags,
158 without requiring gcc as the compiler */
159 #if !defined(__GNUC__) || __GNUC__ < 2 || \
160 (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
161 #ifndef __attribute__
162 #define __attribute__(__x)
163 #endif
164 #endif /* gnuc */
165 #endif /* client.h */
167 #ifndef FALSE
168 #define FALSE (0)
169 #define TRUE (!FALSE)
170 #endif
172 #ifdef __LCLINT__
173 /* lclint doesn't do typeof */
174 #define min(x,y) ((x > y) ? x : y)
175 #define max(x,y) ((x > y) ? x : y)
176 #else
177 /* from linux/kernel.h */
178 #define min(x,y) ({ \
179 const typeof(x) _xi = (x); \
180 const typeof(y) _yi = (y); \
181 (void) (&_xi == &_yi); \
182 _xi < _yi ? _xi : _yi; })
183 #define max(x,y) ({ \
184 const typeof(x) _xa = (x); \
185 const typeof(y) _ya = (y); \
186 (void) (&_xa == &_ya); \
187 _xa > _ya ? _xa : _ya; })
188 #endif
191 /* vim:set ts=4: */
193 * Local Variables:
194 * tab-width: 4
195 * c-indent-level: 4
196 * c-basic-offset: 4
197 * End: