* When forwarding a message, replacing an attachment might make Alpine
[alpine.git] / mapi / pmapi.h
blob2a8d28f89ad6c6e97bad9190fb56c8ee87d64fd8
1 /*
2 * ========================================================================
3 * Copyright 2006 University of Washington
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * ========================================================================
14 #include "windows.h"
16 #include "mapi.h"
17 #include "io.h"
18 #include "fcntl.h"
19 #include "sys/stat.h"
20 #include "string.h"
21 #include "stdio.h"
22 #include "errno.h"
23 #include "process.h"
24 #include "resource.h"
25 #include "time.h"
26 #undef ERROR
27 #include "../c-client-dll/mail.h"
28 #include "../c-client-dll/rfc822.h"
29 #include "../c-client-dll/osdep.h"
30 #include "../c-client-dll/smtp.h"
31 #include "../c-client-dll/misc.h"
32 #include "ctype.h"
34 #define USER_ID 0
35 #define PERSONAL_NAME 1
36 #define USER_DOMAIN 2
37 #define SMTP_SERVER 3
38 #define INBOX_PATH 4
39 #define FEATURE_LIST 5
40 #define CHARACTER_SET 6
41 #define FOLDER_COLLECTIONS 7
42 #define PMAPI_SEND_BEHAVIOR 8
43 #define DEFAULT_FCC 9
44 #define PMAPI_SUPPRESS_DIALOGS 10
45 #define PMAPI_STRICT_NO_DIALOG 11
46 #define NUMPRCVARS 12
47 #define ENABLE8BIT 0
48 #define NUMPRCFEATS 1
49 #define PMSB_ALWAYS_PROMPT 0
50 #define PMSB_ALWAYS_SEND 1
51 #define PMSB_NEVER_SEND 2
52 #define PMSD_NO 0
53 #define PMSD_YES 1
54 #define PMSD_PROMPT 2
55 #define errBufSize 300 /* for buffers to sprintf %.200s error messages into */
56 #define BUFLEN 1024
57 #define EDITLEN 128
58 #define MSDEBUG ms_global && ms_global->debug
59 #define NOT_PINERC 0
60 #define IS_PINERC 1
61 #define PINERC_FILE "tmpmapiuwpinerc"
62 #define ErrorBox(msg,parm){ \
63 char buf[errBufSize]; \
64 sprintf(buf, msg, parm); \
65 ErrorBoxFunc(buf); \
66 } /* a macro so parm can be a pointer or a value as per % format */
67 #define DEBUG_WRITE(msg, parm) { if(MSDEBUG) fprintf(ms_global->dfd,msg,parm);}
69 #ifdef ANSI
70 #define PROTO(args) args
71 #else
72 #define PROTO(args) ()
73 #endif
75 /* used for pine pwd file */
76 #define FIRSTCH 0x20
77 #define LASTCH 0x7e
78 #define TABSZ (LASTCH - FIRSTCH + 1)
81 typedef struct rc_entry{
82 char *var;
83 union {
84 char *p;
85 char **l;
86 } val;
87 int islist;
88 int ispmapivar;
89 } rc_entry_s;
91 typedef struct rc_feat {
92 char *var;
93 int is_set;
94 } rc_feat_s;
96 typedef struct STRLIST{
97 char *str;
98 struct STRLIST *next;
99 } STRLIST_S;
101 typedef struct file_struct{
102 char *filename;
103 struct file_struct *next;
104 } file_s;
106 typedef enum {RecipDesc, Message} BufType;
108 typedef struct mbuffer_list{
109 void *buf;
110 int arraysize; /* should always be 1 unless it's one of those silly arrays */
111 BufType type;
112 struct mbuffer_list *next;
113 } MBUFFER_LIST_S;
115 typedef struct strbuffer{
116 char *buf;
117 unsigned long cur_bytes;
118 unsigned long increment;
119 unsigned long bufsize;
120 } STRBUFFER_S;
122 typedef struct dlg_edits{
123 char edit1[EDITLEN];
124 char edit2[EDITLEN];
125 } dlg_edits_s;
127 typedef struct pw_cache {
128 char user[EDITLEN];
129 char pwd[EDITLEN];
130 char host[EDITLEN];
131 int validpw;
132 struct pw_cache *next;
133 } pw_cache_s;
135 typedef struct sessionl{
136 NETMBX *mb;
137 dlg_edits_s dlge;
138 pw_cache_s *pwc;
139 MAILSTREAM *open_stream;
140 char *currently_open;
141 struct {
142 unsigned dlg_cancel:1;
143 unsigned int mapi_logon_ui:1;
144 unsigned int check_stream:1;
145 /* int passfile_checked; */
146 } flags;
147 file_s *fs;
148 lpMapiMessage FAR lpm;
149 HWND mhwnd;
150 unsigned long session_number;
151 struct sessionl *next;
152 } sessionlist_s;
154 typedef struct mapi_global{
155 char *debugFile;
156 int debug;
157 FILE *dfd;
158 char *pineExe;
159 char *pineExeAlt;
160 char *pinerc;
161 char *pineconf;
162 char *pinercex;
163 char *fccfolder;
164 int inited;
165 char *tmpmbxptr;
166 rc_entry_s *prcvars[NUMPRCVARS];
167 rc_feat_s *prcfeats[NUMPRCFEATS];
168 int pmapi_send_behavior;
169 int pmapi_suppress_dialogs;
170 int pmapi_strict_no_dialog;
171 sessionlist_s *sessionlist;
172 sessionlist_s *cs; /* the current session, used for logins */
173 unsigned long next_session;
174 unsigned long attach_no;
175 unsigned long attached;
176 MBUFFER_LIST_S *mapi_bufs;
177 char *attachDir;
178 HINSTANCE mhinst;
179 } mapi_global_s;
181 extern struct mapi_global *ms_global;
183 void ErrorBoxFunc(char *msg);
184 char *quote(char *old);
185 char *mstrdup(char *old);
186 int msprint(char *str);
187 int msprint1(char *str, void *arg1);
188 int msprint_message_structure(lpMapiMessage lpm);
189 int msprint_recipient_structure(lpMapiRecipDesc lmrd, int mapi_orig_is_unexpected);
190 int msprint_file_structure(lpMapiFileDesc lmfd);
192 int est_size(ADDRESS *a);
193 int send_documents(char *files, char sep);
194 unsigned long send_msg_nodlg(LHANDLE lhSession, ULONG ulUIParam,
195 lpMapiMessage lpMessage, FLAGS flFlags, ULONG ulReserved);
196 ADDRESS *mapirecip2address(lpMapiRecipDesc lpmrd);
197 long pmapi_soutr(STRBUFFER_S *s, char *str);
198 char *TmpCopy(char *srcFile, int is_pinerc);
199 sessionlist_s *new_sessionlist();
200 sessionlist_s *free_sessionlist_node(sessionlist_s *cs);
201 sessionlist_s *get_session(unsigned long num);
202 lpMapiRecipDesc new_MapiRecipDesc(int arraysize);
203 void free_MapiRecipDesc(lpMapiRecipDesc buf, int arraysize);
204 lpMapiMessage new_MapiMessage(int arraysize);
205 void free_MapiMessage(lpMapiMessage buf, int arraysize);
206 int new_mbuffer(void *buf, int arraysize, BufType type);
207 int free_mbuffer(void *buf);
208 int InitPineSpecific(sessionlist_s *cs);
209 MAILSTREAM *mapi_mail_open(sessionlist_s *cs, MAILSTREAM *stream, char *name, long options);
210 MAILSTREAM *check_mailstream(sessionlist_s *cs);
211 unsigned long convert_to_msgno(char *msgid);
212 int fetch_structure_and_attachments(long msgno, long flags,
213 FLAGS MAPIflags, sessionlist_s *cs);
214 char *message_structure_to_mailto_url(lpMapiMessage lpm);
215 ULONG FAR PASCAL MAPISendMail(LHANDLE lhSession, ULONG ulUIParam, lpMapiMessage lpMessage,
216 FLAGS flFlags, ULONG ulReserved);
217 ULONG FAR PASCAL MAPILogon(ULONG ulUIParam, LPTSTR lpszProfileName, LPTSTR lpszPassword,
218 FLAGS flFlags, ULONG ulReserved, LPLHANDLE lplhSession);
219 ULONG FAR PASCAL MAPILogoff (LHANDLE lhSession, ULONG ulUIParam, FLAGS flFlags, ULONG ulReserved);
220 ULONG FAR PASCAL MAPIFindNext (LHANDLE lhSession, ULONG ulUIParam, LPSTR lpszMessageType,
221 LPSTR lpszSeedMessageID, FLAGS flFlags, ULONG ulReserved,
222 LPSTR lpszMessageID);
223 ULONG FAR PASCAL MAPIReadMail(LHANDLE lhSession, ULONG ulUIParam, LPSTR lpszMessageID,
224 FLAGS flFlags, ULONG ulReserved, lpMapiMessage FAR *lppMessage);
225 ULONG FAR PASCAL MAPIAddress(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszCaption,
226 ULONG nEditFields, LPTSTR lpszLabels, ULONG nRecips,
227 lpMapiRecipDesc lpRecips, FLAGS flFlags, ULONG ulReserved,
228 LPULONG lpnNewRecips, lpMapiRecipDesc FAR * lppNewRecips);
229 ULONG FAR PASCAL MAPIDeleteMail(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszMessageID,
230 FLAGS flFlags, ULONG ulReserved);
231 ULONG FAR PASCAL MAPIDetails(LHANDLE lhSession, ULONG ulUIParam, lpMapiRecipDesc lpRecip,
232 FLAGS flFlags, ULONG ulReserved);
233 ULONG FAR PASCAL MAPIFreeBuffer(LPVOID pv);
234 ULONG FAR PASCAL MAPIResolveName(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszName,
235 FLAGS flFlags, ULONG ulReserved, lpMapiRecipDesc FAR * lppRecip);
236 ULONG FAR PASCAL MAPISaveMail(LHANDLE lhSession, ULONG ulUIParam, lpMapiMessage lpMessage,
237 FLAGS flFlags, ULONG ulReserved, LPTSTR lpszMessageID);
238 ULONG FAR PASCAL MAPISendDocuments(ULONG ulUIParam, LPTSTR lpszDelimChar, LPTSTR lpszFullPaths,
239 LPTSTR lpszFileNames, ULONG ulReserved);
241 /* rfc1522.c */
242 char *rfc1522_encode PROTO((char *, size_t, unsigned char *, char *));
243 void get_pair PROTO((char *, char **, char **, int, int));
244 void removing_leading_and_trailing_white_space PROTO((char *));