user32: Fix SPI_SETMOUSESPEED handling, the parameter is not a pointer.
[wine/wine64.git] / dlls / inetcomm / imaptransport.c
blob4cef0838d23ada494b967918d12976c3c93a8ed9
1 /*
2 * IMAP Transport
4 * Copyright 2008 Hans Leidekker for CodeWeavers
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.
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.
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
21 #define COBJMACROS
23 #include <stdarg.h>
24 #include <stdio.h>
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"
34 #include "inetcomm_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(inetcomm);
38 typedef struct
40 InternetTransport InetTransport;
41 ULONG refs;
42 } IMAPTransport;
44 static HRESULT WINAPI IMAPTransport_QueryInterface(IIMAPTransport *iface, REFIID riid, void **ppv)
46 TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
48 if (IsEqualIID(riid, &IID_IUnknown) ||
49 IsEqualIID(riid, &IID_IInternetTransport) ||
50 IsEqualIID(riid, &IID_IIMAPTransport))
52 *ppv = iface;
53 IUnknown_AddRef(iface);
54 return S_OK;
56 *ppv = NULL;
57 FIXME("no interface for %s\n", debugstr_guid(riid));
58 return E_NOINTERFACE;
61 static ULONG WINAPI IMAPTransport_AddRef(IIMAPTransport *iface)
63 IMAPTransport *This = (IMAPTransport *)iface;
64 return InterlockedIncrement((LONG *)&This->refs);
67 static ULONG WINAPI IMAPTransport_Release(IIMAPTransport *iface)
69 IMAPTransport *This = (IMAPTransport *)iface;
70 ULONG refs = InterlockedDecrement((LONG *)&This->refs);
71 if (!refs)
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);
79 return refs;
82 static HRESULT WINAPI IMAPTransport_GetServerInfo(IIMAPTransport *iface,
83 LPINETSERVER pInetServer)
85 IMAPTransport *This = (IMAPTransport *)iface;
87 TRACE("(%p)\n", pInetServer);
88 return InternetTransport_GetServerInfo(&This->InetTransport, pInetServer);
91 static IXPTYPE WINAPI IMAPTransport_GetIXPType(IIMAPTransport *iface)
93 TRACE("()\n");
94 return IXP_IMAP;
97 static HRESULT WINAPI IMAPTransport_IsState(IIMAPTransport *iface,
98 IXPISSTATE isstate)
100 FIXME("(%d): stub\n", isstate);
101 return E_NOTIMPL;
104 static HRESULT WINAPI IMAPTransport_InetServerFromAccount(
105 IIMAPTransport *iface, IImnAccount *pAccount, LPINETSERVER pInetServer)
107 IMAPTransport *This = (IMAPTransport *)iface;
109 TRACE("(%p, %p)\n", pAccount, pInetServer);
110 return InternetTransport_InetServerFromAccount(&This->InetTransport, pAccount, pInetServer);
113 static HRESULT WINAPI IMAPTransport_Connect(IIMAPTransport *iface,
114 LPINETSERVER pInetServer, boolean fAuthenticate, boolean fCommandLogging)
116 IMAPTransport *This = (IMAPTransport *)iface;
117 HRESULT hr;
119 TRACE("(%p, %s, %s)\n", pInetServer, fAuthenticate ? "TRUE" : "FALSE", fCommandLogging ? "TRUE" : "FALSE");
121 hr = InternetTransport_Connect(&This->InetTransport, pInetServer, fAuthenticate, fCommandLogging);
122 return hr;
125 static HRESULT WINAPI IMAPTransport_HandsOffCallback(IIMAPTransport *iface)
127 IMAPTransport *This = (IMAPTransport *)iface;
129 TRACE("()\n");
130 return InternetTransport_HandsOffCallback(&This->InetTransport);
133 static HRESULT WINAPI IMAPTransport_Disconnect(IIMAPTransport *iface)
135 FIXME("(): stub\n");
136 return E_NOTIMPL;
139 static HRESULT WINAPI IMAPTransport_DropConnection(IIMAPTransport *iface)
141 IMAPTransport *This = (IMAPTransport *)iface;
143 TRACE("()\n");
144 return InternetTransport_DropConnection(&This->InetTransport);
147 static HRESULT WINAPI IMAPTransport_GetStatus(IIMAPTransport *iface,
148 IXPSTATUS *pCurrentStatus)
150 IMAPTransport *This = (IMAPTransport *)iface;
152 TRACE("()\n");
153 return InternetTransport_GetStatus(&This->InetTransport, pCurrentStatus);
156 static HRESULT WINAPI IMAPTransport_InitNew(IIMAPTransport *iface,
157 LPSTR pszLogFilePath, IIMAPCallback *pCallback)
159 IMAPTransport *This = (IMAPTransport *)iface;
161 TRACE("(%s, %p)\n", debugstr_a(pszLogFilePath), pCallback);
163 if (!pCallback)
164 return E_INVALIDARG;
166 if (pszLogFilePath)
167 FIXME("not using log file of %s, use Wine debug logging instead\n",
168 debugstr_a(pszLogFilePath));
170 IIMAPCallback_AddRef(pCallback);
171 This->InetTransport.pCallback = (ITransportCallback *)pCallback;
172 This->InetTransport.fInitialised = TRUE;
174 return S_OK;
177 static HRESULT WINAPI IMAPTransport_NewIRangeList(IIMAPTransport *iface,
178 IRangeList **pprlNewRangeList)
180 FIXME("(%p): stub\n", pprlNewRangeList);
181 return E_NOTIMPL;
184 static HRESULT WINAPI IMAPTransport_Capability(IIMAPTransport *iface,
185 DWORD *pdwCapabilityFlags)
187 FIXME("(%p): stub\n", pdwCapabilityFlags);
188 return E_NOTIMPL;
191 static HRESULT WINAPI IMAPTransport_Select(IIMAPTransport *iface,
192 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
194 FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
195 return E_NOTIMPL;
198 static HRESULT WINAPI IMAPTransport_Examine(IIMAPTransport *iface,
199 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
201 FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
202 return E_NOTIMPL;
205 static HRESULT WINAPI IMAPTransport_Create(IIMAPTransport *iface,
206 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
208 FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
209 return E_NOTIMPL;
212 static HRESULT WINAPI IMAPTransport_Delete(IIMAPTransport *iface,
213 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
215 FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
216 return E_NOTIMPL;
219 static HRESULT WINAPI IMAPTransport_Rename(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
220 IIMAPCallback *pCBHandler, LPSTR lpszMailboxName, LPSTR lpszNewMailboxName)
222 FIXME("(%ld, %ld, %p, %s, %s): stub\n", wParam, lParam, pCBHandler,
223 debugstr_a(lpszMailboxName), debugstr_a(lpszNewMailboxName));
224 return E_NOTIMPL;
227 static HRESULT WINAPI IMAPTransport_Subscribe(IIMAPTransport *iface,
228 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
230 FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
231 return E_NOTIMPL;
234 static HRESULT WINAPI IMAPTransport_Unsubscribe(IIMAPTransport *iface,
235 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName)
237 FIXME("(%ld, %ld, %p, %s): stub\n", wParam, lParam, pCBHandler, debugstr_a(lpszMailboxName));
238 return E_NOTIMPL;
241 static HRESULT WINAPI IMAPTransport_List(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
242 IIMAPCallback *pCBHandler, LPSTR lpszMailboxNameReference, LPSTR lpszMailboxNamePattern)
244 FIXME("(%ld, %ld, %p, %s, %s): stub\n", wParam, lParam, pCBHandler,
245 debugstr_a(lpszMailboxNameReference), debugstr_a(lpszMailboxNamePattern));
246 return E_NOTIMPL;
249 static HRESULT WINAPI IMAPTransport_Lsub(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
250 IIMAPCallback *pCBHandler, LPSTR lpszMailboxNameReference, LPSTR lpszMailboxNamePattern)
252 FIXME("(%ld, %ld, %p, %s, %s): stub\n", wParam, lParam, pCBHandler,
253 debugstr_a(lpszMailboxNameReference), debugstr_a(lpszMailboxNamePattern));
254 return E_NOTIMPL;
257 static HRESULT WINAPI IMAPTransport_Append(IIMAPTransport *iface,
258 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszMailboxName,
259 LPSTR lpszMessageFlags, FILETIME ftMessageDateTime, LPSTREAM lpstmMessageToSave)
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;
266 static HRESULT WINAPI IMAPTransport_Close(IIMAPTransport *iface,
267 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler)
269 FIXME("(%ld, %ld, %p): stub\n", wParam, lParam, pCBHandler);
270 return E_NOTIMPL;
273 static HRESULT WINAPI IMAPTransport_Expunge(IIMAPTransport *iface,
274 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler)
276 FIXME("(%ld, %ld, %p): stub\n", wParam, lParam, pCBHandler);
277 return E_NOTIMPL;
280 static HRESULT WINAPI IMAPTransport_Search(IIMAPTransport *iface,
281 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler, LPSTR lpszSearchCriteria,
282 boolean bReturnUIDs, IRangeList *pMsgRange, boolean bUIDRangeList)
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;
289 static HRESULT WINAPI IMAPTransport_Fetch(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
290 IIMAPCallback *pCBHandler, IRangeList *pMsgRange, boolean bUIDMsgRange, LPSTR lpszFetchArgs)
292 FIXME("(%ld, %ld, %p, %p, %d, %s): stub\n", wParam, lParam, pCBHandler, pMsgRange,
293 bUIDMsgRange, debugstr_a(lpszFetchArgs));
294 return E_NOTIMPL;
297 static HRESULT WINAPI IMAPTransport_Store(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
298 IIMAPCallback *pCBHandler, IRangeList *pMsgRange, boolean bUIDRangeList, LPSTR lpszStoreArgs)
300 FIXME("(%ld, %ld, %p, %p, %d, %s): stub\n", wParam, lParam, pCBHandler, pMsgRange,
301 bUIDRangeList, debugstr_a(lpszStoreArgs));
302 return E_NOTIMPL;
305 static HRESULT WINAPI IMAPTransport_Copy(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
306 IIMAPCallback *pCBHandler, IRangeList *pMsgRange, boolean bUIDRangeList, LPSTR lpszMailboxName)
308 FIXME("(%ld, %ld, %p, %p, %d, %s): stub\n", wParam, lParam, pCBHandler, pMsgRange,
309 bUIDRangeList, debugstr_a(lpszMailboxName));
310 return E_NOTIMPL;
313 static HRESULT WINAPI IMAPTransport_Noop(IIMAPTransport *iface,
314 WPARAM wParam, LPARAM lParam, IIMAPCallback *pCBHandler)
316 FIXME("(%ld, %ld, %p): stub\n", wParam, lParam, pCBHandler);
317 return E_NOTIMPL;
320 static HRESULT WINAPI IMAPTransport_ResizeMsgSeqNumTable(IIMAPTransport *iface, DWORD dwSizeOfMbox)
322 FIXME("(%u): stub\n", dwSizeOfMbox);
323 return E_NOTIMPL;
326 static HRESULT WINAPI IMAPTransport_UpdateSeqNumToUID(IIMAPTransport *iface,
327 DWORD dwMsgSeqNum, DWORD dwUID)
329 FIXME("(%u, %u): stub\n", dwMsgSeqNum, dwUID);
330 return E_NOTIMPL;
333 static HRESULT WINAPI IMAPTransport_RemoveSequenceNum(IIMAPTransport *iface, DWORD dwDeletedMsgSeqNum)
335 FIXME("(%u): stub\n", dwDeletedMsgSeqNum);
336 return E_NOTIMPL;
339 static HRESULT WINAPI IMAPTransport_MsgSeqNumToUID(IIMAPTransport *iface, DWORD dwMsgSeqNum,
340 DWORD *pdwUID)
342 FIXME("(%u, %p): stub\n", dwMsgSeqNum, pdwUID);
343 return E_NOTIMPL;
346 static HRESULT WINAPI IMAPTransport_GetMsgSeqNumToUIDArray(IIMAPTransport *iface,
347 DWORD **ppdwMsgSeqNumToUIDArray, DWORD *pdwNumberOfElements)
349 FIXME("(%p, %p): stub\n", ppdwMsgSeqNumToUIDArray, pdwNumberOfElements);
350 return E_NOTIMPL;
353 static HRESULT WINAPI IMAPTransport_GetHighestMsgSeqNum(IIMAPTransport *iface, DWORD *pdwHighestMSN)
355 FIXME("(%p): stub\n", pdwHighestMSN);
356 return E_NOTIMPL;
359 static HRESULT WINAPI IMAPTransport_ResetMsgSeqNumToUID(IIMAPTransport *iface)
361 FIXME("(): stub\n");
362 return E_NOTIMPL;
365 static HRESULT WINAPI IMAPTransport_SetDefaultCBHandler(IIMAPTransport *iface, IIMAPCallback *pCBHandler)
367 FIXME("(%p): stub\n", pCBHandler);
368 return E_NOTIMPL;
371 static HRESULT WINAPI IMAPTransport_Status(IIMAPTransport *iface, WPARAM wParam, LPARAM lParam,
372 IIMAPCallback *pCBHandler, LPSTR pszMailboxName, LPSTR pszStatusCmdArgs)
374 FIXME("(%ld, %ld, %p, %s, %s): stub\n", wParam, lParam, pCBHandler,
375 debugstr_a(pszMailboxName), debugstr_a(pszStatusCmdArgs));
376 return E_NOTIMPL;
379 static const IIMAPTransportVtbl IMAPTransportVtbl =
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
424 HRESULT WINAPI CreateIMAPTransport(IIMAPTransport **ppTransport)
426 HRESULT hr;
427 IMAPTransport *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
428 if (!This)
429 return E_OUTOFMEMORY;
431 This->InetTransport.u.vtblIMAP = &IMAPTransportVtbl;
432 This->refs = 0;
433 hr = InternetTransport_Init(&This->InetTransport);
434 if (FAILED(hr))
436 HeapFree(GetProcessHeap(), 0, This);
437 return hr;
440 *ppTransport = (IIMAPTransport *)&This->InetTransport.u.vtblIMAP;
441 IIMAPTransport_AddRef(*ppTransport);
443 return S_OK;
446 static HRESULT WINAPI IMAPTransportCF_QueryInterface(LPCLASSFACTORY iface,
447 REFIID riid, LPVOID *ppv)
449 *ppv = NULL;
450 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
452 *ppv = iface;
453 IUnknown_AddRef(iface);
454 return S_OK;
456 return E_NOINTERFACE;
459 static ULONG WINAPI IMAPTransportCF_AddRef(LPCLASSFACTORY iface)
461 return 2; /* non-heap based object */
464 static ULONG WINAPI IMAPTransportCF_Release(LPCLASSFACTORY iface)
466 return 1; /* non-heap based object */
469 static HRESULT WINAPI IMAPTransportCF_CreateInstance(LPCLASSFACTORY iface,
470 LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
472 HRESULT hr;
473 IIMAPTransport *pImapTransport;
475 TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
477 *ppv = NULL;
479 if (pUnk)
480 return CLASS_E_NOAGGREGATION;
482 hr = CreateIMAPTransport(&pImapTransport);
483 if (FAILED(hr))
484 return hr;
486 hr = IIMAPTransport_QueryInterface(pImapTransport, riid, ppv);
487 IIMAPTransport_Release(pImapTransport);
489 return hr;
492 static HRESULT WINAPI IMAPTransportCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
494 FIXME("(%d), stub!\n",fLock);
495 return S_OK;
498 static const IClassFactoryVtbl IMAPTransportCFVtbl =
500 IMAPTransportCF_QueryInterface,
501 IMAPTransportCF_AddRef,
502 IMAPTransportCF_Release,
503 IMAPTransportCF_CreateInstance,
504 IMAPTransportCF_LockServer
506 static const IClassFactoryVtbl *IMAPTransportCF = &IMAPTransportCFVtbl;
508 HRESULT IMAPTransportCF_Create(REFIID riid, LPVOID *ppv)
510 return IClassFactory_QueryInterface((IClassFactory *)&IMAPTransportCF, riid, ppv);