xref: /reactos/dll/win32/inetcomm/imaptransport.c (revision af764263)
1 /*
2  * IMAP Transport
3  *
4  * Copyright 2008 Hans Leidekker for CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #define COBJMACROS
22 
23 #include <stdarg.h>
24 #include <stdio.h>
25 
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winnt.h"
29 #include "winuser.h"
30 #include "objbase.h"
31 #include "mimeole.h"
32 #include "wine/debug.h"
33 
34 #include "inetcomm_private.h"
35 
36 WINE_DEFAULT_DEBUG_CHANNEL(inetcomm);
37 
38 typedef struct
39 {
40     InternetTransport InetTransport;
41     ULONG refs;
42 } IMAPTransport;
43 
IMAPTransport_QueryInterface(IIMAPTransport * iface,REFIID riid,void ** ppv)44 static HRESULT WINAPI IMAPTransport_QueryInterface(IIMAPTransport *iface, REFIID riid, void **ppv)
45 {
46     TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
47 
48     if (IsEqualIID(riid, &IID_IUnknown) ||
49         IsEqualIID(riid, &IID_IInternetTransport) ||
50         IsEqualIID(riid, &IID_IIMAPTransport))
51     {
52         *ppv = iface;
53         IIMAPTransport_AddRef(iface);
54         return S_OK;
55     }
56     *ppv = NULL;
57     FIXME("no interface for %s\n", debugstr_guid(riid));
58     return E_NOINTERFACE;
59 }
60 
IMAPTransport_AddRef(IIMAPTransport * iface)61 static ULONG WINAPI IMAPTransport_AddRef(IIMAPTransport *iface)
62 {
63     IMAPTransport *This = (IMAPTransport *)iface;
64     return InterlockedIncrement((LONG *)&This->refs);
65 }
66 
IMAPTransport_Release(IIMAPTransport * iface)67 static ULONG WINAPI IMAPTransport_Release(IIMAPTransport *iface)
68 {
69     IMAPTransport *This = (IMAPTransport *)iface;
70     ULONG refs = InterlockedDecrement((LONG *)&This->refs);
71     if (!refs)
72     {
73         TRACE("destroying %p\n", This);
74         if (This->InetTransport.Status != IXP_DISCONNECTED)
75             InternetTransport_DropConnection(&This->InetTransport);
76         if (This->InetTransport.pCallback) ITransportCallback_Release(This->InetTransport.pCallback);
77         HeapFree(GetProcessHeap(), 0, This);
78     }
79     return refs;
80 }
81 
IMAPTransport_GetServerInfo(IIMAPTransport * iface,LPINETSERVER pInetServer)82 static HRESULT WINAPI IMAPTransport_GetServerInfo(IIMAPTransport *iface,
83     LPINETSERVER pInetServer)
84 {
85     IMAPTransport *This = (IMAPTransport *)iface;
86 
87     TRACE("(%p)\n", pInetServer);
88     return InternetTransport_GetServerInfo(&This->InetTransport, pInetServer);
89 }
90 
IMAPTransport_GetIXPType(IIMAPTransport * iface)91 static IXPTYPE WINAPI IMAPTransport_GetIXPType(IIMAPTransport *iface)
92 {
93     TRACE("()\n");
94     return IXP_IMAP;
95 }
96 
IMAPTransport_IsState(IIMAPTransport * iface,IXPISSTATE isstate)97 static HRESULT WINAPI IMAPTransport_IsState(IIMAPTransport *iface,
98     IXPISSTATE isstate)
99 {
100     FIXME("(%d): stub\n", isstate);
101     return E_NOTIMPL;
102 }
103 
IMAPTransport_InetServerFromAccount(IIMAPTransport * iface,IImnAccount * pAccount,LPINETSERVER pInetServer)104 static HRESULT WINAPI IMAPTransport_InetServerFromAccount(
105     IIMAPTransport *iface, IImnAccount *pAccount, LPINETSERVER pInetServer)
106 {
107     IMAPTransport *This = (IMAPTransport *)iface;
108 
109     TRACE("(%p, %p)\n", pAccount, pInetServer);
110     return InternetTransport_InetServerFromAccount(&This->InetTransport, pAccount, pInetServer);
111 }
112 
IMAPTransport_Connect(IIMAPTransport * iface,LPINETSERVER pInetServer,boolean fAuthenticate,boolean fCommandLogging)113 static HRESULT WINAPI IMAPTransport_Connect(IIMAPTransport *iface,
114     LPINETSERVER pInetServer, boolean fAuthenticate, boolean fCommandLogging)
115 {
116     IMAPTransport *This = (IMAPTransport *)iface;
117     HRESULT hr;
118 
119     TRACE("(%p, %s, %s)\n", pInetServer, fAuthenticate ? "TRUE" : "FALSE", fCommandLogging ? "TRUE" : "FALSE");
120 
121     hr = InternetTransport_Connect(&This->InetTransport, pInetServer, fAuthenticate, fCommandLogging);
122     return hr;
123 }
124 
IMAPTransport_HandsOffCallback(IIMAPTransport * iface)125 static HRESULT WINAPI IMAPTransport_HandsOffCallback(IIMAPTransport *iface)
126 {
127     IMAPTransport *This = (IMAPTransport *)iface;
128 
129     TRACE("()\n");
130     return InternetTransport_HandsOffCallback(&This->InetTransport);
131 }
132 
IMAPTransport_Disconnect(IIMAPTransport * iface)133 static HRESULT WINAPI IMAPTransport_Disconnect(IIMAPTransport *iface)
134 {
135     FIXME("(): stub\n");
136     return E_NOTIMPL;
137 }
138 
IMAPTransport_DropConnection(IIMAPTransport * iface)139 static HRESULT WINAPI IMAPTransport_DropConnection(IIMAPTransport *iface)
140 {
141     IMAPTransport *This = (IMAPTransport *)iface;
142 
143     TRACE("()\n");
144     return InternetTransport_DropConnection(&This->InetTransport);
145 }
146 
IMAPTransport_GetStatus(IIMAPTransport * iface,IXPSTATUS * pCurrentStatus)147 static HRESULT WINAPI IMAPTransport_GetStatus(IIMAPTransport *iface,
148     IXPSTATUS *pCurrentStatus)
149 {
150     IMAPTransport *This = (IMAPTransport *)iface;
151 
152     TRACE("()\n");
153     return InternetTransport_GetStatus(&This->InetTransport, pCurrentStatus);
154 }
155 
IMAPTransport_InitNew(IIMAPTransport * iface,LPSTR pszLogFilePath,IIMAPCallback * pCallback)156 static HRESULT WINAPI IMAPTransport_InitNew(IIMAPTransport *iface,
157     LPSTR pszLogFilePath, IIMAPCallback *pCallback)
158 {
159     IMAPTransport *This = (IMAPTransport *)iface;
160 
161     TRACE("(%s, %p)\n", debugstr_a(pszLogFilePath), pCallback);
162 
163     if (!pCallback)
164         return E_INVALIDARG;
165 
166     if (pszLogFilePath)
167         FIXME("not using log file of %s, use Wine debug logging instead\n",
168             debugstr_a(pszLogFilePath));
169 
170     IIMAPCallback_AddRef(pCallback);
171     This->InetTransport.pCallback = (ITransportCallback *)pCallback;
172     This->InetTransport.fInitialised = TRUE;
173 
174     return S_OK;
175 }
176 
IMAPTransport_NewIRangeList(IIMAPTransport * iface,IRangeList ** pprlNewRangeList)177 static HRESULT WINAPI IMAPTransport_NewIRangeList(IIMAPTransport *iface,
178     IRangeList **pprlNewRangeList)
179 {
180     FIXME("(%p): stub\n", pprlNewRangeList);
181     return E_NOTIMPL;
182 }
183 
IMAPTransport_Capability(IIMAPTransport * iface,DWORD * pdwCapabilityFlags)184 static HRESULT WINAPI IMAPTransport_Capability(IIMAPTransport *iface,
185     DWORD *pdwCapabilityFlags)
186 {
187     FIXME("(%p): stub\n", pdwCapabilityFlags);
188     return E_NOTIMPL;
189 }
190 
IMAPTransport_Select(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszMailboxName)191 static HRESULT WINAPI IMAPTransport_Select(IIMAPTransport *iface,
192     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
193 {
194     FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
195     return E_NOTIMPL;
196 }
197 
IMAPTransport_Examine(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszMailboxName)198 static HRESULT WINAPI IMAPTransport_Examine(IIMAPTransport *iface,
199     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
200 {
201     FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
202     return E_NOTIMPL;
203 }
204 
IMAPTransport_Create(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszMailboxName)205 static HRESULT WINAPI IMAPTransport_Create(IIMAPTransport *iface,
206     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
207 {
208     FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
209     return E_NOTIMPL;
210 }
211 
IMAPTransport_Delete(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszMailboxName)212 static HRESULT WINAPI IMAPTransport_Delete(IIMAPTransport *iface,
213     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
214 {
215     FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
216     return E_NOTIMPL;
217 }
218 
IMAPTransport_Rename(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszMailboxName,LPSTR lpszNewMailboxName)219 static HRESULT WINAPI IMAPTransport_Rename(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
220     IIMAPCallback *pCBHandler, LPSTR lpszMailboxName, LPSTR lpszNewMailboxName)
221 {
222     FIXME("(%ld, %ld, %p, %s, %s): stub\n", wParam, lParam, pCBHandler,
223           debugstr_a(lpszMailboxName), debugstr_a(lpszNewMailboxName));
224     return E_NOTIMPL;
225 }
226 
IMAPTransport_Subscribe(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszMailboxName)227 static HRESULT WINAPI IMAPTransport_Subscribe(IIMAPTransport *iface,
228     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
229 {
230     FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
231     return E_NOTIMPL;
232 }
233 
IMAPTransport_Unsubscribe(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszMailboxName)234 static HRESULT WINAPI IMAPTransport_Unsubscribe(IIMAPTransport *iface,
235     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
236 {
237     FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
238     return E_NOTIMPL;
239 }
240 
IMAPTransport_List(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszMailboxNameReference,LPSTR lpszMailboxNamePattern)241 static HRESULT WINAPI IMAPTransport_List(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
242     IIMAPCallback *pCBHandler, LPSTR lpszMailboxNameReference, LPSTR lpszMailboxNamePattern)
243 {
244     FIXME("(%ld, %ld, %p, %s, %s): stub\n", wParam, lParam, pCBHandler,
245           debugstr_a(lpszMailboxNameReference), debugstr_a(lpszMailboxNamePattern));
246     return E_NOTIMPL;
247 }
248 
IMAPTransport_Lsub(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszMailboxNameReference,LPSTR lpszMailboxNamePattern)249 static HRESULT WINAPI IMAPTransport_Lsub(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
250     IIMAPCallback *pCBHandler, LPSTR lpszMailboxNameReference, LPSTR lpszMailboxNamePattern)
251 {
252     FIXME("(%ld, %ld, %p, %s, %s): stub\n", wParam, lParam, pCBHandler,
253           debugstr_a(lpszMailboxNameReference), debugstr_a(lpszMailboxNamePattern));
254     return E_NOTIMPL;
255 }
256 
IMAPTransport_Append(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszMailboxName,LPSTR lpszMessageFlags,FILETIME ftMessageDateTime,LPSTREAM lpstmMessageToSave)257 static HRESULT WINAPI IMAPTransport_Append(IIMAPTransport *iface,
258     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName,
259     LPSTR lpszMessageFlags, FILETIME ftMessageDateTime, LPSTREAM lpstmMessageToSave)
260 {
261     FIXME("(%ld, %ld, %p, %s, %s, %p): stub\n", wParam, lParam, pCBHandler,
262           debugstr_a(lpszMailboxName), debugstr_a(lpszMessageFlags), lpstmMessageToSave);
263     return E_NOTIMPL;
264 }
265 
IMAPTransport_Close(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler)266 static HRESULT WINAPI IMAPTransport_Close(IIMAPTransport *iface,
267     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler)
268 {
269     FIXME("(%ld, %ld, %p): stub\n", wParam, lParam, pCBHandler);
270     return E_NOTIMPL;
271 }
272 
IMAPTransport_Expunge(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler)273 static HRESULT WINAPI IMAPTransport_Expunge(IIMAPTransport *iface,
274     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler)
275 {
276     FIXME("(%ld, %ld, %p): stub\n", wParam, lParam, pCBHandler);
277     return E_NOTIMPL;
278 }
279 
IMAPTransport_Search(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR lpszSearchCriteria,boolean bReturnUIDs,IRangeList * pMsgRange,boolean bUIDRangeList)280 static HRESULT WINAPI IMAPTransport_Search(IIMAPTransport *iface,
281     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszSearchCriteria,
282     boolean bReturnUIDs, IRangeList *pMsgRange, boolean bUIDRangeList)
283 {
284     FIXME("(%ld, %ld, %p, %s, %d, %p, %d): stub\n", wParam, lParam, pCBHandler,
285           debugstr_a(lpszSearchCriteria), bReturnUIDs, pMsgRange, bUIDRangeList);
286     return E_NOTIMPL;
287 }
288 
IMAPTransport_Fetch(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,IRangeList * pMsgRange,boolean bUIDMsgRange,LPSTR lpszFetchArgs)289 static HRESULT WINAPI IMAPTransport_Fetch(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
290     IIMAPCallback *pCBHandler, IRangeList *pMsgRange, boolean bUIDMsgRange, LPSTR lpszFetchArgs)
291 {
292     FIXME("(%ld, %ld, %p, %p, %d, %s): stub\n", wParam, lParam, pCBHandler, pMsgRange,
293           bUIDMsgRange, debugstr_a(lpszFetchArgs));
294     return E_NOTIMPL;
295 }
296 
IMAPTransport_Store(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,IRangeList * pMsgRange,boolean bUIDRangeList,LPSTR lpszStoreArgs)297 static HRESULT WINAPI IMAPTransport_Store(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
298     IIMAPCallback *pCBHandler, IRangeList *pMsgRange, boolean bUIDRangeList, LPSTR lpszStoreArgs)
299 {
300     FIXME("(%ld, %ld, %p, %p, %d, %s): stub\n", wParam, lParam, pCBHandler, pMsgRange,
301           bUIDRangeList, debugstr_a(lpszStoreArgs));
302     return E_NOTIMPL;
303 }
304 
IMAPTransport_Copy(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,IRangeList * pMsgRange,boolean bUIDRangeList,LPSTR lpszMailboxName)305 static HRESULT WINAPI IMAPTransport_Copy(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
306     IIMAPCallback *pCBHandler, IRangeList *pMsgRange, boolean bUIDRangeList, LPSTR lpszMailboxName)
307 {
308     FIXME("(%ld, %ld, %p, %p, %d, %s): stub\n", wParam, lParam, pCBHandler, pMsgRange,
309           bUIDRangeList, debugstr_a(lpszMailboxName));
310     return E_NOTIMPL;
311 }
312 
IMAPTransport_Noop(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler)313 static HRESULT WINAPI IMAPTransport_Noop(IIMAPTransport *iface,
314     WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler)
315 {
316     FIXME("(%ld, %ld, %p): stub\n", wParam, lParam, pCBHandler);
317     return E_NOTIMPL;
318 }
319 
IMAPTransport_ResizeMsgSeqNumTable(IIMAPTransport * iface,DWORD dwSizeOfMbox)320 static HRESULT WINAPI IMAPTransport_ResizeMsgSeqNumTable(IIMAPTransport *iface, DWORD dwSizeOfMbox)
321 {
322     FIXME("(%u): stub\n", dwSizeOfMbox);
323     return E_NOTIMPL;
324 }
325 
IMAPTransport_UpdateSeqNumToUID(IIMAPTransport * iface,DWORD dwMsgSeqNum,DWORD dwUID)326 static HRESULT WINAPI IMAPTransport_UpdateSeqNumToUID(IIMAPTransport *iface,
327     DWORD dwMsgSeqNum, DWORD dwUID)
328 {
329     FIXME("(%u, %u): stub\n", dwMsgSeqNum, dwUID);
330     return E_NOTIMPL;
331 }
332 
IMAPTransport_RemoveSequenceNum(IIMAPTransport * iface,DWORD dwDeletedMsgSeqNum)333 static HRESULT WINAPI IMAPTransport_RemoveSequenceNum(IIMAPTransport *iface, DWORD dwDeletedMsgSeqNum)
334 {
335     FIXME("(%u): stub\n", dwDeletedMsgSeqNum);
336     return E_NOTIMPL;
337 }
338 
IMAPTransport_MsgSeqNumToUID(IIMAPTransport * iface,DWORD dwMsgSeqNum,DWORD * pdwUID)339 static HRESULT WINAPI IMAPTransport_MsgSeqNumToUID(IIMAPTransport *iface, DWORD dwMsgSeqNum,
340     DWORD *pdwUID)
341 {
342     FIXME("(%u, %p): stub\n", dwMsgSeqNum, pdwUID);
343     return E_NOTIMPL;
344 }
345 
IMAPTransport_GetMsgSeqNumToUIDArray(IIMAPTransport * iface,DWORD ** ppdwMsgSeqNumToUIDArray,DWORD * pdwNumberOfElements)346 static HRESULT WINAPI IMAPTransport_GetMsgSeqNumToUIDArray(IIMAPTransport *iface,
347     DWORD **ppdwMsgSeqNumToUIDArray, DWORD *pdwNumberOfElements)
348 {
349     FIXME("(%p, %p): stub\n", ppdwMsgSeqNumToUIDArray, pdwNumberOfElements);
350     return E_NOTIMPL;
351 }
352 
IMAPTransport_GetHighestMsgSeqNum(IIMAPTransport * iface,DWORD * pdwHighestMSN)353 static HRESULT WINAPI IMAPTransport_GetHighestMsgSeqNum(IIMAPTransport *iface, DWORD *pdwHighestMSN)
354 {
355     FIXME("(%p): stub\n", pdwHighestMSN);
356     return E_NOTIMPL;
357 }
358 
IMAPTransport_ResetMsgSeqNumToUID(IIMAPTransport * iface)359 static HRESULT WINAPI IMAPTransport_ResetMsgSeqNumToUID(IIMAPTransport *iface)
360 {
361     FIXME("(): stub\n");
362     return E_NOTIMPL;
363 }
364 
IMAPTransport_SetDefaultCBHandler(IIMAPTransport * iface,IIMAPCallback * pCBHandler)365 static HRESULT WINAPI IMAPTransport_SetDefaultCBHandler(IIMAPTransport *iface, IIMAPCallback *pCBHandler)
366 {
367     FIXME("(%p): stub\n", pCBHandler);
368     return E_NOTIMPL;
369 }
370 
IMAPTransport_Status(IIMAPTransport * iface,WPARAM wParam,LPARAM lParam,IIMAPCallback * pCBHandler,LPSTR pszMailboxName,LPSTR pszStatusCmdArgs)371 static HRESULT WINAPI IMAPTransport_Status(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
372     IIMAPCallback *pCBHandler, LPSTR pszMailboxName, LPSTR pszStatusCmdArgs)
373 {
374     FIXME("(%ld, %ld, %p, %s, %s): stub\n", wParam, lParam, pCBHandler,
375           debugstr_a(pszMailboxName), debugstr_a(pszStatusCmdArgs));
376     return E_NOTIMPL;
377 }
378 
379 static const IIMAPTransportVtbl IMAPTransportVtbl =
380 {
381     IMAPTransport_QueryInterface,
382     IMAPTransport_AddRef,
383     IMAPTransport_Release,
384     IMAPTransport_GetServerInfo,
385     IMAPTransport_GetIXPType,
386     IMAPTransport_IsState,
387     IMAPTransport_InetServerFromAccount,
388     IMAPTransport_Connect,
389     IMAPTransport_HandsOffCallback,
390     IMAPTransport_Disconnect,
391     IMAPTransport_DropConnection,
392     IMAPTransport_GetStatus,
393     IMAPTransport_InitNew,
394     IMAPTransport_NewIRangeList,
395     IMAPTransport_Capability,
396     IMAPTransport_Select,
397     IMAPTransport_Examine,
398     IMAPTransport_Create,
399     IMAPTransport_Delete,
400     IMAPTransport_Rename,
401     IMAPTransport_Subscribe,
402     IMAPTransport_Unsubscribe,
403     IMAPTransport_List,
404     IMAPTransport_Lsub,
405     IMAPTransport_Append,
406     IMAPTransport_Close,
407     IMAPTransport_Expunge,
408     IMAPTransport_Search,
409     IMAPTransport_Fetch,
410     IMAPTransport_Store,
411     IMAPTransport_Copy,
412     IMAPTransport_Noop,
413     IMAPTransport_ResizeMsgSeqNumTable,
414     IMAPTransport_UpdateSeqNumToUID,
415     IMAPTransport_RemoveSequenceNum,
416     IMAPTransport_MsgSeqNumToUID,
417     IMAPTransport_GetMsgSeqNumToUIDArray,
418     IMAPTransport_GetHighestMsgSeqNum,
419     IMAPTransport_ResetMsgSeqNumToUID,
420     IMAPTransport_SetDefaultCBHandler,
421     IMAPTransport_Status
422 };
423 
CreateIMAPTransport(IIMAPTransport ** ppTransport)424 HRESULT WINAPI CreateIMAPTransport(IIMAPTransport **ppTransport)
425 {
426     HRESULT hr;
427     IMAPTransport *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
428     if (!This)
429         return E_OUTOFMEMORY;
430 
431     This->InetTransport.u.vtblIMAP = &IMAPTransportVtbl;
432     This->refs = 0;
433     hr = InternetTransport_Init(&This->InetTransport);
434     if (FAILED(hr))
435     {
436         HeapFree(GetProcessHeap(), 0, This);
437         return hr;
438     }
439 
440     *ppTransport = (IIMAPTransport *)&This->InetTransport.u.vtblIMAP;
441     IIMAPTransport_AddRef(*ppTransport);
442 
443     return S_OK;
444 }
445 
IMAPTransportCF_QueryInterface(IClassFactory * iface,REFIID riid,LPVOID * ppv)446 static HRESULT WINAPI IMAPTransportCF_QueryInterface(IClassFactory *iface,
447     REFIID riid, LPVOID *ppv)
448 {
449     *ppv = NULL;
450     if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
451     {
452         *ppv = iface;
453         IClassFactory_AddRef(iface);
454         return S_OK;
455     }
456     return E_NOINTERFACE;
457 }
458 
IMAPTransportCF_AddRef(IClassFactory * iface)459 static ULONG WINAPI IMAPTransportCF_AddRef(IClassFactory *iface)
460 {
461     return 2; /* non-heap based object */
462 }
463 
IMAPTransportCF_Release(IClassFactory * iface)464 static ULONG WINAPI IMAPTransportCF_Release(IClassFactory *iface)
465 {
466     return 1; /* non-heap based object */
467 }
468 
IMAPTransportCF_CreateInstance(IClassFactory * iface,LPUNKNOWN pUnk,REFIID riid,LPVOID * ppv)469 static HRESULT WINAPI IMAPTransportCF_CreateInstance(IClassFactory *iface,
470     LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
471 {
472     HRESULT hr;
473     IIMAPTransport *pImapTransport;
474 
475     TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
476 
477     *ppv = NULL;
478 
479     if (pUnk)
480         return CLASS_E_NOAGGREGATION;
481 
482     hr = CreateIMAPTransport(&pImapTransport);
483     if (FAILED(hr))
484         return hr;
485 
486     hr = IIMAPTransport_QueryInterface(pImapTransport, riid, ppv);
487     IIMAPTransport_Release(pImapTransport);
488 
489     return hr;
490 }
491 
IMAPTransportCF_LockServer(IClassFactory * iface,BOOL fLock)492 static HRESULT WINAPI IMAPTransportCF_LockServer(IClassFactory *iface, BOOL fLock)
493 {
494     FIXME("(%d), stub!\n",fLock);
495     return S_OK;
496 }
497 
498 static const IClassFactoryVtbl IMAPTransportCFVtbl =
499 {
500     IMAPTransportCF_QueryInterface,
501     IMAPTransportCF_AddRef,
502     IMAPTransportCF_Release,
503     IMAPTransportCF_CreateInstance,
504     IMAPTransportCF_LockServer
505 };
506 static const IClassFactoryVtbl *IMAPTransportCF = &IMAPTransportCFVtbl;
507 
IMAPTransportCF_Create(REFIID riid,LPVOID * ppv)508 HRESULT IMAPTransportCF_Create(REFIID riid, LPVOID *ppv)
509 {
510     return IClassFactory_QueryInterface((IClassFactory *)&IMAPTransportCF, riid, ppv);
511 }
512