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
32 #include "wine/debug.h"
34 #include "inetcomm_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(inetcomm
);
40 InternetTransport InetTransport
;
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
))
53 IIMAPTransport_AddRef(iface
);
57 FIXME("no interface for %s\n", debugstr_guid(riid
));
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
);
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
);
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
)
97 static HRESULT WINAPI
IMAPTransport_IsState(IIMAPTransport
*iface
,
100 FIXME("(%d): stub\n", isstate
);
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
;
119 TRACE("(%p, %s, %s)\n", pInetServer
, fAuthenticate
? "TRUE" : "FALSE", fCommandLogging
? "TRUE" : "FALSE");
121 hr
= InternetTransport_Connect(&This
->InetTransport
, pInetServer
, fAuthenticate
, fCommandLogging
);
125 static HRESULT WINAPI
IMAPTransport_HandsOffCallback(IIMAPTransport
*iface
)
127 IMAPTransport
*This
= (IMAPTransport
*)iface
;
130 return InternetTransport_HandsOffCallback(&This
->InetTransport
);
133 static HRESULT WINAPI
IMAPTransport_Disconnect(IIMAPTransport
*iface
)
139 static HRESULT WINAPI
IMAPTransport_DropConnection(IIMAPTransport
*iface
)
141 IMAPTransport
*This
= (IMAPTransport
*)iface
;
144 return InternetTransport_DropConnection(&This
->InetTransport
);
147 static HRESULT WINAPI
IMAPTransport_GetStatus(IIMAPTransport
*iface
,
148 IXPSTATUS
*pCurrentStatus
)
150 IMAPTransport
*This
= (IMAPTransport
*)iface
;
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
);
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
;
177 static HRESULT WINAPI
IMAPTransport_NewIRangeList(IIMAPTransport
*iface
,
178 IRangeList
**pprlNewRangeList
)
180 FIXME("(%p): stub\n", pprlNewRangeList
);
184 static HRESULT WINAPI
IMAPTransport_Capability(IIMAPTransport
*iface
,
185 DWORD
*pdwCapabilityFlags
)
187 FIXME("(%p): stub\n", pdwCapabilityFlags
);
191 static HRESULT WINAPI
IMAPTransport_Select(IIMAPTransport
*iface
,
192 WPARAM wParam
, LPARAM lParam
, IIMAPCallback
*pCBHandler
, LPSTR lpszMailboxName
)
194 FIXME("(%Id, %Id, %p, %s): stub\n", wParam
, lParam
, pCBHandler
, debugstr_a(lpszMailboxName
));
198 static HRESULT WINAPI
IMAPTransport_Examine(IIMAPTransport
*iface
,
199 WPARAM wParam
, LPARAM lParam
, IIMAPCallback
*pCBHandler
, LPSTR lpszMailboxName
)
201 FIXME("(%Id, %Id, %p, %s): stub\n", wParam
, lParam
, pCBHandler
, debugstr_a(lpszMailboxName
));
205 static HRESULT WINAPI
IMAPTransport_Create(IIMAPTransport
*iface
,
206 WPARAM wParam
, LPARAM lParam
, IIMAPCallback
*pCBHandler
, LPSTR lpszMailboxName
)
208 FIXME("(%Id, %Id, %p, %s): stub\n", wParam
, lParam
, pCBHandler
, debugstr_a(lpszMailboxName
));
212 static HRESULT WINAPI
IMAPTransport_Delete(IIMAPTransport
*iface
,
213 WPARAM wParam
, LPARAM lParam
, IIMAPCallback
*pCBHandler
, LPSTR lpszMailboxName
)
215 FIXME("(%Id, %Id, %p, %s): stub\n", wParam
, lParam
, pCBHandler
, debugstr_a(lpszMailboxName
));
219 static HRESULT WINAPI
IMAPTransport_Rename(IIMAPTransport
*iface
, WPARAM wParam
, LPARAM lParam
,
220 IIMAPCallback
*pCBHandler
, LPSTR lpszMailboxName
, LPSTR lpszNewMailboxName
)
222 FIXME("(%Id, %Id, %p, %s, %s): stub\n", wParam
, lParam
, pCBHandler
,
223 debugstr_a(lpszMailboxName
), debugstr_a(lpszNewMailboxName
));
227 static HRESULT WINAPI
IMAPTransport_Subscribe(IIMAPTransport
*iface
,
228 WPARAM wParam
, LPARAM lParam
, IIMAPCallback
*pCBHandler
, LPSTR lpszMailboxName
)
230 FIXME("(%Id, %Id, %p, %s): stub\n", wParam
, lParam
, pCBHandler
, debugstr_a(lpszMailboxName
));
234 static HRESULT WINAPI
IMAPTransport_Unsubscribe(IIMAPTransport
*iface
,
235 WPARAM wParam
, LPARAM lParam
, IIMAPCallback
*pCBHandler
, LPSTR lpszMailboxName
)
237 FIXME("(%Id, %Id, %p, %s): stub\n", wParam
, lParam
, pCBHandler
, debugstr_a(lpszMailboxName
));
241 static HRESULT WINAPI
IMAPTransport_List(IIMAPTransport
*iface
, WPARAM wParam
, LPARAM lParam
,
242 IIMAPCallback
*pCBHandler
, LPSTR lpszMailboxNameReference
, LPSTR lpszMailboxNamePattern
)
244 FIXME("(%Id, %Id, %p, %s, %s): stub\n", wParam
, lParam
, pCBHandler
,
245 debugstr_a(lpszMailboxNameReference
), debugstr_a(lpszMailboxNamePattern
));
249 static HRESULT WINAPI
IMAPTransport_Lsub(IIMAPTransport
*iface
, WPARAM wParam
, LPARAM lParam
,
250 IIMAPCallback
*pCBHandler
, LPSTR lpszMailboxNameReference
, LPSTR lpszMailboxNamePattern
)
252 FIXME("(%Id, %Id, %p, %s, %s): stub\n", wParam
, lParam
, pCBHandler
,
253 debugstr_a(lpszMailboxNameReference
), debugstr_a(lpszMailboxNamePattern
));
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("(%Id, %Id, %p, %s, %s, %p): stub\n", wParam
, lParam
, pCBHandler
,
262 debugstr_a(lpszMailboxName
), debugstr_a(lpszMessageFlags
), lpstmMessageToSave
);
266 static HRESULT WINAPI
IMAPTransport_Close(IIMAPTransport
*iface
,
267 WPARAM wParam
, LPARAM lParam
, IIMAPCallback
*pCBHandler
)
269 FIXME("(%Id, %Id, %p): stub\n", wParam
, lParam
, pCBHandler
);
273 static HRESULT WINAPI
IMAPTransport_Expunge(IIMAPTransport
*iface
,
274 WPARAM wParam
, LPARAM lParam
, IIMAPCallback
*pCBHandler
)
276 FIXME("(%Id, %Id, %p): stub\n", wParam
, lParam
, pCBHandler
);
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("(%Id, %Id, %p, %s, %d, %p, %d): stub\n", wParam
, lParam
, pCBHandler
,
285 debugstr_a(lpszSearchCriteria
), bReturnUIDs
, pMsgRange
, bUIDRangeList
);
289 static HRESULT WINAPI
IMAPTransport_Fetch(IIMAPTransport
*iface
, WPARAM wParam
, LPARAM lParam
,
290 IIMAPCallback
*pCBHandler
, IRangeList
*pMsgRange
, boolean bUIDMsgRange
, LPSTR lpszFetchArgs
)
292 FIXME("(%Id, %Id, %p, %p, %d, %s): stub\n", wParam
, lParam
, pCBHandler
, pMsgRange
,
293 bUIDMsgRange
, debugstr_a(lpszFetchArgs
));
297 static HRESULT WINAPI
IMAPTransport_Store(IIMAPTransport
*iface
, WPARAM wParam
, LPARAM lParam
,
298 IIMAPCallback
*pCBHandler
, IRangeList
*pMsgRange
, boolean bUIDRangeList
, LPSTR lpszStoreArgs
)
300 FIXME("(%Id, %Id, %p, %p, %d, %s): stub\n", wParam
, lParam
, pCBHandler
, pMsgRange
,
301 bUIDRangeList
, debugstr_a(lpszStoreArgs
));
305 static HRESULT WINAPI
IMAPTransport_Copy(IIMAPTransport
*iface
, WPARAM wParam
, LPARAM lParam
,
306 IIMAPCallback
*pCBHandler
, IRangeList
*pMsgRange
, boolean bUIDRangeList
, LPSTR lpszMailboxName
)
308 FIXME("(%Id, %Id, %p, %p, %d, %s): stub\n", wParam
, lParam
, pCBHandler
, pMsgRange
,
309 bUIDRangeList
, debugstr_a(lpszMailboxName
));
313 static HRESULT WINAPI
IMAPTransport_Noop(IIMAPTransport
*iface
,
314 WPARAM wParam
, LPARAM lParam
, IIMAPCallback
*pCBHandler
)
316 FIXME("(%Id, %Id, %p): stub\n", wParam
, lParam
, pCBHandler
);
320 static HRESULT WINAPI
IMAPTransport_ResizeMsgSeqNumTable(IIMAPTransport
*iface
, DWORD dwSizeOfMbox
)
322 FIXME("(%lu): stub\n", dwSizeOfMbox
);
326 static HRESULT WINAPI
IMAPTransport_UpdateSeqNumToUID(IIMAPTransport
*iface
,
327 DWORD dwMsgSeqNum
, DWORD dwUID
)
329 FIXME("(%lu, %lu): stub\n", dwMsgSeqNum
, dwUID
);
333 static HRESULT WINAPI
IMAPTransport_RemoveSequenceNum(IIMAPTransport
*iface
, DWORD dwDeletedMsgSeqNum
)
335 FIXME("(%lu): stub\n", dwDeletedMsgSeqNum
);
339 static HRESULT WINAPI
IMAPTransport_MsgSeqNumToUID(IIMAPTransport
*iface
, DWORD dwMsgSeqNum
,
342 FIXME("(%lu, %p): stub\n", dwMsgSeqNum
, pdwUID
);
346 static HRESULT WINAPI
IMAPTransport_GetMsgSeqNumToUIDArray(IIMAPTransport
*iface
,
347 DWORD
**ppdwMsgSeqNumToUIDArray
, DWORD
*pdwNumberOfElements
)
349 FIXME("(%p, %p): stub\n", ppdwMsgSeqNumToUIDArray
, pdwNumberOfElements
);
353 static HRESULT WINAPI
IMAPTransport_GetHighestMsgSeqNum(IIMAPTransport
*iface
, DWORD
*pdwHighestMSN
)
355 FIXME("(%p): stub\n", pdwHighestMSN
);
359 static HRESULT WINAPI
IMAPTransport_ResetMsgSeqNumToUID(IIMAPTransport
*iface
)
365 static HRESULT WINAPI
IMAPTransport_SetDefaultCBHandler(IIMAPTransport
*iface
, IIMAPCallback
*pCBHandler
)
367 FIXME("(%p): stub\n", pCBHandler
);
371 static HRESULT WINAPI
IMAPTransport_Status(IIMAPTransport
*iface
, WPARAM wParam
, LPARAM lParam
,
372 IIMAPCallback
*pCBHandler
, LPSTR pszMailboxName
, LPSTR pszStatusCmdArgs
)
374 FIXME("(%Id, %Id, %p, %s, %s): stub\n", wParam
, lParam
, pCBHandler
,
375 debugstr_a(pszMailboxName
), debugstr_a(pszStatusCmdArgs
));
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
,
405 IMAPTransport_Append
,
407 IMAPTransport_Expunge
,
408 IMAPTransport_Search
,
413 IMAPTransport_ResizeMsgSeqNumTable
,
414 IMAPTransport_UpdateSeqNumToUID
,
415 IMAPTransport_RemoveSequenceNum
,
416 IMAPTransport_MsgSeqNumToUID
,
417 IMAPTransport_GetMsgSeqNumToUIDArray
,
418 IMAPTransport_GetHighestMsgSeqNum
,
419 IMAPTransport_ResetMsgSeqNumToUID
,
420 IMAPTransport_SetDefaultCBHandler
,
424 HRESULT WINAPI
CreateIMAPTransport(IIMAPTransport
**ppTransport
)
427 IMAPTransport
*This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
429 return E_OUTOFMEMORY
;
431 This
->InetTransport
.u
.vtblIMAP
= &IMAPTransportVtbl
;
433 hr
= InternetTransport_Init(&This
->InetTransport
);
436 HeapFree(GetProcessHeap(), 0, This
);
440 *ppTransport
= (IIMAPTransport
*)&This
->InetTransport
.u
.vtblIMAP
;
441 IIMAPTransport_AddRef(*ppTransport
);
446 static HRESULT WINAPI
IMAPTransportCF_QueryInterface(IClassFactory
*iface
,
447 REFIID riid
, LPVOID
*ppv
)
450 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
))
453 IClassFactory_AddRef(iface
);
456 return E_NOINTERFACE
;
459 static ULONG WINAPI
IMAPTransportCF_AddRef(IClassFactory
*iface
)
461 return 2; /* non-heap based object */
464 static ULONG WINAPI
IMAPTransportCF_Release(IClassFactory
*iface
)
466 return 1; /* non-heap based object */
469 static HRESULT WINAPI
IMAPTransportCF_CreateInstance(IClassFactory
*iface
,
470 LPUNKNOWN pUnk
, REFIID riid
, LPVOID
*ppv
)
473 IIMAPTransport
*pImapTransport
;
475 TRACE("(%p, %s, %p)\n", pUnk
, debugstr_guid(riid
), ppv
);
480 return CLASS_E_NOAGGREGATION
;
482 hr
= CreateIMAPTransport(&pImapTransport
);
486 hr
= IIMAPTransport_QueryInterface(pImapTransport
, riid
, ppv
);
487 IIMAPTransport_Release(pImapTransport
);
492 static HRESULT WINAPI
IMAPTransportCF_LockServer(IClassFactory
*iface
, BOOL fLock
)
494 FIXME("(%d), stub!\n",fLock
);
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
);