1 /*
2 * Copyright 2004 Jon Griffiths
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #ifndef MAPIUTIL_H_
20 #define MAPIUTIL_H_
21
22 #include <mapix.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #define TAD_ALL_ROWS 1 /* Delete all rows */
29
30 LPMALLOC WINAPI MAPIGetDefaultMalloc(void);
31
32 #define SOF_UNIQUEFILENAME 0x80000000U /* Create a unique (temporary) filename */
33
34 #if defined (UNICODE) || defined (__WINESRC__)
35 typedef HRESULT (WINAPI * LPOPENSTREAMONFILE)(LPALLOCATEBUFFER,LPFREEBUFFER,
36 ULONG,LPWSTR,LPWSTR,LPSTREAM*);
37 HRESULT WINAPI OpenStreamOnFile(LPALLOCATEBUFFER,LPFREEBUFFER,
38 ULONG,LPWSTR,LPWSTR,LPSTREAM*);
39 #else
40 typedef HRESULT (WINAPI * LPOPENSTREAMONFILE)(LPALLOCATEBUFFER,LPFREEBUFFER,
41 ULONG,LPSTR,LPSTR,LPSTREAM*);
42 HRESULT WINAPI OpenStreamOnFile(LPALLOCATEBUFFER,LPFREEBUFFER,
43 ULONG,LPSTR,LPSTR,LPSTREAM*);
44 #endif
45 #define OPENSTREAMONFILE "OpenStreamOnFile"
46
47 BOOL WINAPI FEqualNames(LPMAPINAMEID,LPMAPINAMEID);
48
49 typedef struct IPropData *LPPROPDATA;
50
51 #define IPROP_READONLY 0x00001U
52 #define IPROP_READWRITE 0x00002U
53 #define IPROP_CLEAN 0x10000U
54 #define IPROP_DIRTY 0x20000U
55
56 SCODE WINAPI CreateIProp(LPCIID,ALLOCATEBUFFER*,ALLOCATEMORE*,FREEBUFFER*,
57 LPVOID,LPPROPDATA*);
58 SCODE WINAPI PropCopyMore(LPSPropValue,LPSPropValue,ALLOCATEMORE*,LPVOID);
59 ULONG WINAPI UlPropSize(LPSPropValue);
60 VOID WINAPI GetInstance(LPSPropValue,LPSPropValue,ULONG);
61 BOOL WINAPI FPropContainsProp(LPSPropValue,LPSPropValue,ULONG);
62 BOOL WINAPI FPropCompareProp(LPSPropValue,ULONG,LPSPropValue);
63 LONG WINAPI LPropCompareProp(LPSPropValue,LPSPropValue);
64
65 HRESULT WINAPI HrAddColumns(LPMAPITABLE,LPSPropTagArray,LPALLOCATEBUFFER,LPFREEBUFFER);
66 HRESULT WINAPI HrAddColumnsEx(LPMAPITABLE,LPSPropTagArray,LPALLOCATEBUFFER,
67 LPFREEBUFFER,void (*)(LPSPropTagArray));
68 HRESULT WINAPI HrAllocAdviseSink(LPNOTIFCALLBACK,LPVOID,LPMAPIADVISESINK*);
69 HRESULT WINAPI HrThisThreadAdviseSink(LPMAPIADVISESINK,LPMAPIADVISESINK*);
70 HRESULT WINAPI HrDispatchNotifications (ULONG);
71
72 ULONG WINAPI UlAddRef(void*);
73 ULONG WINAPI UlRelease(void*);
74
75 HRESULT WINAPI HrGetOneProp(LPMAPIPROP,ULONG,LPSPropValue*);
76 HRESULT WINAPI HrSetOneProp(LPMAPIPROP,LPSPropValue);
77 BOOL WINAPI FPropExists(LPMAPIPROP,ULONG);
78 void WINAPI FreePadrlist(LPADRLIST);
79 void WINAPI FreeProws(LPSRowSet);
80 HRESULT WINAPI HrQueryAllRows(LPMAPITABLE,LPSPropTagArray,LPSRestriction,
81 LPSSortOrderSet,LONG,LPSRowSet*);
82 LPSPropValue WINAPI PpropFindProp(LPSPropValue,ULONG,ULONG);
83
84 #if defined (UNICODE) || defined (__WINESRC__)
85 BOOL WINAPI FBinFromHex(LPWSTR,LPBYTE);
86 SCODE WINAPI ScBinFromHexBounded(LPWSTR,LPBYTE,ULONG);
87 void WINAPI HexFromBin(LPBYTE,int,LPWSTR);
88 ULONG WINAPI UlFromSzHex(LPCWSTR);
89 LPWSTR WINAPI SzFindCh(LPCWSTR,USHORT);
90 LPWSTR WINAPI SzFindLastCh(LPCWSTR,USHORT);
91 LPWSTR WINAPI SzFindSz(LPCWSTR,LPCWSTR);
92 UINT WINAPI UFromSz(LPCSTR);
93 #else
94 BOOL WINAPI FBinFromHex(LPSTR,LPBYTE);
95 SCODE WINAPI ScBinFromHexBounded(LPSTR,LPBYTE,ULONG);
96 void WINAPI HexFromBin(LPBYTE,int,LPSTR);
97 ULONG WINAPI UlFromSzHex(LPCSTR);
98 LPSTR WINAPI SzFindCh(LPCSTR,USHORT);
99 LPSTR WINAPI SzFindLastCh(LPCSTR,USHORT);
100 LPSTR WINAPI SzFindSz(LPCSTR,LPCSTR);
101 UINT WINAPI UFromSz(LPCSTR);
102 #endif
103
104 SCODE WINAPI ScInitMapiUtil(ULONG);
105 void WINAPI DeinitMapiUtil(void);
106
107 #define szHrDispatchNotifications "_HrDispatchNotifications@4"
108 #define szScCreateConversationIndex "_ScCreateConversationIndex@16"
109
110 typedef HRESULT (WINAPI DISPATCHNOTIFICATIONS)(ULONG);
111 typedef DISPATCHNOTIFICATIONS *LPDISPATCHNOTIFICATIONS;
112 typedef SCODE (WINAPI CREATECONVERSATIONINDEX)(ULONG,LPBYTE,ULONG*,LPBYTE*);
113 typedef CREATECONVERSATIONINDEX *LPCREATECONVERSATIONINDEX;
114
115 typedef struct ITableData *LPTABLEDATA;
116
117 typedef void (WINAPI CALLERRELEASE)(ULONG,LPTABLEDATA,LPMAPITABLE);
118
119 /*****************************************************************************
120 * ITableData interface
121 *
122 * The underlying table data structure for IMAPITable.
123 */
124 #define INTERFACE ITableData
DECLARE_INTERFACE_(ITableData,IUnknown)125 DECLARE_INTERFACE_(ITableData,IUnknown)
126 {
127 /*** IUnknown methods ***/
128 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
129 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
130 STDMETHOD_(ULONG,Release)(THIS) PURE;
131 /*** ITableData methods ***/
132 STDMETHOD(HrGetView)(THIS_ LPSSortOrderSet lpSort, CALLERRELEASE *lpRel,
133 ULONG ulData, LPMAPITABLE *lppTable) PURE;
134 STDMETHOD(HrModifyRow)(THIS_ LPSRow lpRow) PURE;
135 STDMETHOD(HrDeleteRow)(THIS_ LPSPropValue lpKey) PURE;
136 STDMETHOD(HrQueryRow)(THIS_ LPSPropValue lpKey, LPSRow *lppRow, ULONG *lpRowNum) PURE;
137 STDMETHOD(HrEnumRow)(THIS_ ULONG ulRowNum, LPSRow *lppRow) PURE;
138 STDMETHOD(HrNotify)(THIS_ ULONG ulFlags, ULONG cValues, LPSPropValue lpValues) PURE;
139 STDMETHOD(HrInsertRow)(THIS_ ULONG ulRow, LPSRow lpRow) PURE;
140 STDMETHOD(HrModifyRows)(THIS_ ULONG ulFlags, LPSRowSet lpRows) PURE;
141 STDMETHOD(HrDeleteRows)(THIS_ ULONG ulFlags, LPSRowSet lpRows, ULONG *lpCount) PURE;
142 };
143 #undef INTERFACE
144
145 #if !defined(__cplusplus) || defined(CINTERFACE)
146 /*** IUnknown methods ***/
147 #define ITableData_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
148 #define ITableData_AddRef(p) (p)->lpVtbl->AddRef(p)
149 #define ITableData_Release(p) (p)->lpVtbl->Release(p)
150 /*** ITableData methods ***/
151 #define ITableData_HrGetView(p,a,b,c,d) (p)->lpVtbl->HrGetView(p,a,b,c,d)
152 #define ITableData_HrModifyRow(p,a) (p)->lpVtbl->HrModifyRow(p,a)
153 #define ITableData_HrDeleteRow(p,a) (p)->lpVtbl->HrDeleteRow(p,a)
154 #define ITableData_HrQueryRow(p,a,b,c) (p)->lpVtbl->HrQueryRow(p,a,b,c)
155 #define ITableData_HrEnumRow(p,a,b) (p)->lpVtbl->HrEnumRow(p,a,b)
156 #define ITableData_HrNotify(p,a,b,c) (p)->lpVtbl->HrNotify(p,a,b,c)
157 #define ITableData_HrInsertRow(p,a,b) (p)->lpVtbl->HrInsertRow(p,a,b)
158 #define ITableData_HrModifyRows(p,a,b) (p)->lpVtbl->HrModifyRows(p,a,b)
159 #define ITableData_HrDeleteRows(p,a,b,c) (p)->lpVtbl->HrDeleteRows(p,a,b,c)
160 #endif
161
162 SCODE WINAPI CreateTable(LPCIID,ALLOCATEBUFFER*,ALLOCATEMORE*,FREEBUFFER*,
163 LPVOID,ULONG,ULONG,LPSPropTagArray,LPTABLEDATA*);
164
165 SCODE WINAPI ScCountNotifications(int,LPNOTIFICATION,ULONG*);
166 SCODE WINAPI ScCountProps(int,LPSPropValue,ULONG*);
167 SCODE WINAPI ScCopyNotifications(int,LPNOTIFICATION,LPVOID,ULONG*);
168 SCODE WINAPI ScCopyProps(int,LPSPropValue,LPVOID,ULONG*);
169 SCODE WINAPI ScDupPropset(int,LPSPropValue,LPALLOCATEBUFFER,LPSPropValue*);
170 SCODE WINAPI ScRelocNotifications(int,LPNOTIFICATION,LPVOID,LPVOID,ULONG*);
171 SCODE WINAPI ScRelocProps(int,LPSPropValue,LPVOID,LPVOID,ULONG*);
172
173 LPSPropValue WINAPI LpValFindProp(ULONG,ULONG,LPSPropValue);
174
FtAddFt(FILETIME ftLeft,FILETIME ftRight)175 static inline FILETIME FtAddFt(FILETIME ftLeft, FILETIME ftRight)
176 {
177 LONG64 *pl = (LONG64*)&ftLeft, *pr = (LONG64*)&ftRight;
178 union { FILETIME ft; LONG64 ll; } ftmap;
179 ftmap.ll = *pl + *pr;
180 return ftmap.ft;
181 }
182
FtSubFt(FILETIME ftLeft,FILETIME ftRight)183 static inline FILETIME FtSubFt(FILETIME ftLeft, FILETIME ftRight)
184 {
185 LONG64 *pl = (LONG64*)&ftLeft, *pr = (LONG64*)&ftRight;
186 union { FILETIME ft; LONG64 ll; } ftmap;
187 ftmap.ll = *pl - *pr;
188 return ftmap.ft;
189 }
190
FtNegFt(FILETIME ftLeft)191 static inline FILETIME FtNegFt(FILETIME ftLeft)
192 {
193 LONG64 *p = (LONG64*)&ftLeft;
194 union { FILETIME ft; LONG64 ll; } ftmap;
195 ftmap.ll = -*p;
196 return ftmap.ft;
197 }
198
FtMulDw(DWORD dwLeft,FILETIME ftRight)199 static inline FILETIME FtMulDw(DWORD dwLeft, FILETIME ftRight)
200 {
201 LONG64 l = (LONG64)dwLeft, *pr = (LONG64*)&ftRight;
202 union { FILETIME ft; LONG64 ll; } ftmap;
203 ftmap.ll = l * (*pr);
204 return ftmap.ft;
205 }
206
FtMulDwDw(DWORD dwLeft,DWORD dwRight)207 static inline FILETIME FtMulDwDw(DWORD dwLeft, DWORD dwRight)
208 {
209 LONG64 l = (LONG64)dwLeft, r = (LONG64)dwRight;
210 union { FILETIME ft; LONG64 ll; } ftmap;
211 ftmap.ll = l * r;
212 return ftmap.ft;
213 }
214
215 /*****************************************************************************
216 * IPropData interface
217 *
218 */
219 #define INTERFACE IPropData
DECLARE_INTERFACE_(IPropData,IMAPIProp)220 DECLARE_INTERFACE_(IPropData,IMAPIProp)
221 {
222 /*** IUnknown methods ***/
223 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
224 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
225 STDMETHOD_(ULONG,Release)(THIS) PURE;
226 /*** IMAPIProp methods ***/
227 STDMETHOD(GetLastError)(THIS_ HRESULT hRes, ULONG ulFlags, LPMAPIERROR *lppErr) PURE;
228 STDMETHOD(SaveChanges)(THIS_ ULONG ulFlags) PURE;
229 STDMETHOD(GetProps)(THIS_ LPSPropTagArray lpPropTags, ULONG ulFlags, ULONG *lpValues, LPSPropValue *lppProps) PURE;
230 STDMETHOD(GetPropList)(THIS_ ULONG ulFlags, LPSPropTagArray *lppPropTagArray) PURE;
231 STDMETHOD(OpenProperty)(THIS_ ULONG ulPropTag, LPCIID lpIid, ULONG ulOpts, ULONG ulFlags, LPUNKNOWN *lppUnk) PURE;
232 STDMETHOD(SetProps)(THIS_ ULONG cValues, LPSPropValue lpProps, LPSPropProblemArray *lppProbs) PURE;
233 STDMETHOD(DeleteProps)(THIS_ LPSPropTagArray lpPropTags, LPSPropProblemArray *lppProbs) PURE;
234 STDMETHOD(CopyTo)(THIS_ ULONG ciidExclude, LPCIID lpIid, LPSPropTagArray lpProps, ULONG ulParam,
235 LPMAPIPROGRESS lpProgress, LPCIID lpIface,LPVOID lpDest, ULONG ulFlags,
236 LPSPropProblemArray *lppProbs) PURE;
237 STDMETHOD(CopyProps)(THIS_ LPSPropTagArray lpIncludeProps, ULONG ulParam, LPMAPIPROGRESS lpProgress,
238 LPCIID lpIid, LPVOID lpDestObj, ULONG ulFlags, LPSPropProblemArray *lppProblems) PURE;
239 STDMETHOD(GetNamesFromIDs)(THIS_ LPSPropTagArray *lppPropTags, LPGUID lpIid, ULONG ulFlags, ULONG *lpCount,
240 LPMAPINAMEID **lpppNames) PURE;
241 STDMETHOD(GetIDsFromNames)(THIS_ ULONG cPropNames, LPMAPINAMEID *lppNames, ULONG ulFlags, LPSPropTagArray *lppPropTags) PURE;
242 /*** IPropData methods ***/
243 STDMETHOD(HrSetObjAccess)(THIS_ ULONG ulAccess) PURE;
244 STDMETHOD(HrSetPropAccess)(THIS_ LPSPropTagArray lpPropTags, ULONG *lpAccess) PURE;
245 STDMETHOD(HrGetPropAccess)(THIS_ LPSPropTagArray *lppPropTags, ULONG **lppAccess) PURE;
246 STDMETHOD(HrAddObjProps)(THIS_ LPSPropTagArray lppPropTags, LPSPropProblemArray *lppProbs) PURE;
247 };
248 #undef INTERFACE
249
250 #if !defined(__cplusplus) || defined(CINTERFACE)
251 /*** IUnknown methods ***/
252 #define IPropData_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
253 #define IPropData_AddRef(p) (p)->lpVtbl->AddRef(p)
254 #define IPropData_Release(p) (p)->lpVtbl->Release(p)
255 /*** IMAPIProp methods ***/
256 #define IPropData_GetLastError(p,a,b,c) (p)->lpVtbl->GetLastError(p,a,b,c)
257 #define IPropData_SaveChanges(p,a) (p)->lpVtbl->SaveChanges(p,a)
258 #define IPropData_GetProps(p,a,b,c,d) (p)->lpVtbl->GetProps(p,a,b,c,d)
259 #define IPropData_GetPropList(p,a,b) (p)->lpVtbl->GetPropList(p,a,b)
260 #define IPropData_OpenProperty(p,a,b,c,d,e) (p)->lpVtbl->OpenProperty(p,a,b,c,d,e)
261 #define IPropData_SetProps(p,a,b,c) (p)->lpVtbl->SetProps(p,a,b,c)
262 #define IPropData_DeleteProps(p,a,b) (p)->lpVtbl->DeleteProps(p,a,b)
263 #define IPropData_CopyTo(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CopyTo(p,a,b,c,d,e,f,g,h,i)
264 #define IPropData_CopyProps(p,a,b,c,d,e,f,g) (p)->lpVtbl->CopyProps(p,a,b,c,d,e,f,g)
265 #define IPropData_GetNamesFromIDs(p,a,b,c,d,e) (p)->lpVtbl->GetNamesFromIDs(p,a,b,c,d,e)
266 #define IPropData_GetIDsFromNames(p,a,b,c,d) (p)->lpVtbl->GetIDsFromNames(p,a,b,c,d)
267 #define IPropData_HrSetObjAccess(p,a) (p)->lpVtbl->HrSetObjAccess(p,a)
268 #define IPropData_HrSetPropAccess(p,a,b) (p)->lpVtbl->HrSetPropAccess(p,a,b)
269 #define IPropData_HrGetPropAccess(p,a,b) (p)->lpVtbl->HrGetPropAccess(p,a,b)
270 #define IPropData_HrAddObjProps(p,a,b) (p)->lpVtbl->HrAddObjProps(p,a,b)
271 #endif
272
273 #ifdef __cplusplus
274 }
275 #endif
276
277 #endif /* MAPIUTIL_H_ */
278