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