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);
48 InternetTransport InetTransport;
55 enum parse_state state;
61 static HRESULT parse_response(POP3Transport *This)
67 if (strlen(This->response) < 3)
69 WARN("parse error\n");
70 This->state = STATE_DONE;
73 if (!memcmp(This->response, "+OK", 3))
75 This->ptr = This->response + 3;
76 This->state = STATE_OK;
79 This->state = STATE_DONE;
86 static HRESULT parse_uidl_response(POP3Transport *This, POP3UIDL *uidl)
96 if (This->type == POP3CMD_GET_POPID)
98 if ((p = strchr(This->ptr, ' ')))
100 while (*p == ' ') p++;
101 sscanf(p, "%u", &uidl->dwPopId);
102 if ((p = strchr(p, ' ')))
104 while (*p == ' ') p++;
106 This->valid_info = TRUE;
109 This->state = STATE_DONE;
112 This->state = STATE_MULTILINE;
115 case STATE_MULTILINE:
117 if (This->response[0] == '.' && !This->response[1])
119 This->valid_info = FALSE;
120 This->state = STATE_DONE;
123 sscanf(This->response, "%u", &uidl->dwPopId);
124 if ((p = strchr(This->response, ' ')))
126 while (*p == ' ') p++;
128 This->valid_info = TRUE;
134 WARN("parse error\n");
135 This->state = STATE_DONE;
141 static HRESULT parse_stat_response(POP3Transport *This, POP3STAT *stat)
146 stat->cbMessages = 0;
151 if ((p = strchr(This->ptr, ' ')))
153 while (*p == ' ') p++;
154 sscanf(p, "%u %u", &stat->cMessages, &stat->cbMessages);
155 This->valid_info = TRUE;
156 This->state = STATE_DONE;
162 WARN("parse error\n");
163 This->state = STATE_DONE;
169 static HRESULT parse_list_response(POP3Transport *This, POP3LIST *list)
179 if (This->type == POP3CMD_GET_POPID)
181 if ((p = strchr(This->ptr, ' ')))
183 while (*p == ' ') p++;
184 sscanf(p, "%u %u", &list->dwPopId, &list->cbSize);
185 This->valid_info = TRUE;
187 This->state = STATE_DONE;
190 This->state = STATE_MULTILINE;
193 case STATE_MULTILINE:
195 if (This->response[0] == '.' && !This->response[1])
197 This->valid_info = FALSE;
198 This->state = STATE_DONE;
201 sscanf(This->response, "%u", &list->dwPopId);
202 if ((p = strchr(This->response, ' ')))
204 while (*p == ' ') p++;
205 sscanf(p, "%u", &list->cbSize);
206 This->valid_info = TRUE;
212 WARN("parse error\n");
213 This->state = STATE_DONE;
219 static HRESULT parse_dele_response(POP3Transport *This, DWORD *dwPopId)
225 *dwPopId = 0; /* FIXME */
226 This->state = STATE_DONE;
231 WARN("parse error\n");
232 This->state = STATE_DONE;
238 static HRESULT parse_retr_response(POP3Transport *This, POP3RETR *retr)
244 retr->fHeader = FALSE;
246 retr->dwPopId = This->msgid;
248 retr->pszLines = This->response;
251 This->state = STATE_MULTILINE;
252 This->valid_info = FALSE;
255 case STATE_MULTILINE:
259 if (This->response[0] == '.' && !This->response[1])
261 retr->cbLines = retr->cbSoFar;
262 This->state = STATE_DONE;
265 retr->fHeader = TRUE;
266 if (!This->response[0]) retr->fBody = TRUE;
268 len = strlen(This->response);
269 retr->cbSoFar += len;
270 retr->pszLines = This->response;
273 This->valid_info = TRUE;
278 WARN("parse error\n");
279 This->state = STATE_DONE;
285 static HRESULT parse_top_response(POP3Transport *This, POP3TOP *top)
291 top->fHeader = FALSE;
293 top->dwPopId = This->msgid;
294 top->cPreviewLines = This->preview_lines;
296 top->pszLines = This->response;
299 This->state = STATE_MULTILINE;
300 This->valid_info = FALSE;
303 case STATE_MULTILINE:
307 if (This->response[0] == '.' && !This->response[1])
309 top->cbLines = top->cbSoFar;
310 This->state = STATE_DONE;
314 if (!This->response[0]) top->fBody = TRUE;
316 len = strlen(This->response);
318 top->pszLines = This->response;
321 This->valid_info = TRUE;
326 WARN("parse error\n");
327 This->state = STATE_DONE;
333 static void init_parser(POP3Transport *This, POP3COMMAND command, POP3CMDTYPE type)
335 This->state = STATE_NONE;
336 This->command = command;
340 static HRESULT POP3Transport_ParseResponse(POP3Transport *This, char *pszResponse, POP3RESPONSE *pResponse)
344 TRACE("response: %s\n", debugstr_a(pszResponse));
346 This->response = pszResponse;
347 This->valid_info = FALSE;
348 TRACE("state %u\n", This->state);
350 if (SUCCEEDED((hr = parse_response(This))))
352 switch (This->command)
354 case POP3_UIDL: hr = parse_uidl_response(This, &pResponse->rUidlInfo); break;
355 case POP3_STAT: hr = parse_stat_response(This, &pResponse->rStatInfo); break;
356 case POP3_LIST: hr = parse_list_response(This, &pResponse->rListInfo); break;
357 case POP3_DELE: hr = parse_dele_response(This, &pResponse->dwPopId); break;
358 case POP3_RETR: hr = parse_retr_response(This, &pResponse->rRetrInfo); break;
359 case POP3_TOP: hr = parse_top_response(This, &pResponse->rTopInfo); break;
361 This->state = STATE_DONE;
365 pResponse->command = This->command;
366 pResponse->fDone = (This->state == STATE_DONE);
367 pResponse->fValidInfo = This->valid_info;
368 pResponse->rIxpResult.hrResult = hr;
369 pResponse->rIxpResult.pszResponse = pszResponse;
370 pResponse->rIxpResult.uiServerError = 0;
371 pResponse->rIxpResult.hrServerError = pResponse->rIxpResult.hrResult;
372 pResponse->rIxpResult.dwSocketError = WSAGetLastError();
373 pResponse->rIxpResult.pszProblem = NULL;
374 pResponse->pTransport = (IPOP3Transport *)&This->InetTransport.u.vtblPOP3;
376 if (This->InetTransport.pCallback && This->InetTransport.fCommandLogging)
378 ITransportCallback_OnCommand(This->InetTransport.pCallback, CMD_RESP,
379 pResponse->rIxpResult.pszResponse, pResponse->rIxpResult.hrServerError,
380 (IInternetTransport *)&This->InetTransport.u.vtbl);
385 static void POP3Transport_CallbackProcessDELEResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
387 POP3Transport *This = (POP3Transport *)iface;
388 POP3RESPONSE response;
393 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
396 /* FIXME: handle error */
400 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
403 static void POP3Transport_CallbackRecvDELEResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
405 POP3Transport *This = (POP3Transport *)iface;
408 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessDELEResp);
411 static void POP3Transport_CallbackProcessLISTResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
413 POP3Transport *This = (POP3Transport *)iface;
414 POP3RESPONSE response;
419 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
422 /* FIXME: handle error */
426 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
429 static void POP3Transport_CallbackRecvLISTResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
431 POP3Transport *This = (POP3Transport *)iface;
434 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessLISTResp);
437 static void POP3Transport_CallbackProcessUIDLResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
439 POP3Transport *This = (POP3Transport *)iface;
440 POP3RESPONSE response;
445 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
448 /* FIXME: handle error */
452 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
455 static void POP3Transport_CallbackRecvUIDLResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
457 POP3Transport *This = (POP3Transport *)iface;
460 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessUIDLResp);
463 static void POP3Transport_CallbackProcessSTATResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
465 POP3Transport *This = (POP3Transport *)iface;
466 POP3RESPONSE response;
471 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
474 /* FIXME: handle error */
478 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
481 static void POP3Transport_CallbackRecvSTATResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
483 POP3Transport *This = (POP3Transport *)iface;
486 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessSTATResp);
489 static void POP3Transport_CallbackProcessPASSResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
491 POP3Transport *This = (POP3Transport *)iface;
492 POP3RESPONSE response;
497 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
500 /* FIXME: handle error */
504 InternetTransport_ChangeStatus(&This->InetTransport, IXP_AUTHORIZED);
505 InternetTransport_ChangeStatus(&This->InetTransport, IXP_CONNECTED);
507 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
510 static void POP3Transport_CallbackRecvPASSResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
512 POP3Transport *This = (POP3Transport *)iface;
515 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessPASSResp);
518 static void POP3Transport_CallbackProcessUSERResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
520 static char pass[] = "PASS ";
521 POP3Transport *This = (POP3Transport *)iface;
522 POP3RESPONSE response;
529 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
532 /* FIXME: handle error */
536 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
538 len = sizeof(pass) + strlen(This->server.szPassword) + 2; /* "\r\n" */
539 command = HeapAlloc(GetProcessHeap(), 0, len);
541 strcpy(command, pass);
542 strcat(command, This->server.szPassword);
543 strcat(command, "\r\n");
545 init_parser(This, POP3_PASS, POP3_NONE);
547 InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvPASSResp);
548 HeapFree(GetProcessHeap(), 0, command);
551 static void POP3Transport_CallbackRecvUSERResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
553 POP3Transport *This = (POP3Transport *)iface;
556 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessUSERResp);
559 static void POP3Transport_CallbackSendUSERCmd(IInternetTransport *iface, char *pBuffer, int cbBuffer)
561 static char user[] = "USER ";
562 POP3Transport *This = (POP3Transport *)iface;
568 len = sizeof(user) + strlen(This->server.szUserName) + 2; /* "\r\n" */
569 command = HeapAlloc(GetProcessHeap(), 0, len);
571 strcpy(command, user);
572 strcat(command, This->server.szUserName);
573 strcat(command, "\r\n");
574 InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvUSERResp);
576 HeapFree(GetProcessHeap(), 0, command);
579 static void POP3Transport_CallbackProcessQUITResponse(IInternetTransport *iface, char *pBuffer, int cbBuffer)
581 POP3Transport *This = (POP3Transport *)iface;
582 POP3RESPONSE response;
585 TRACE("%s\n", debugstr_an(pBuffer, cbBuffer));
587 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
590 /* FIXME: handle error */
594 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
595 InternetTransport_DropConnection(&This->InetTransport);
598 static void POP3Transport_CallbackRecvQUITResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
600 POP3Transport *This = (POP3Transport *)iface;
603 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessQUITResponse);
606 static HRESULT WINAPI POP3Transport_QueryInterface(IPOP3Transport *iface, REFIID riid, void **ppv)
608 TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
610 if (IsEqualIID(riid, &IID_IUnknown) ||
611 IsEqualIID(riid, &IID_IInternetTransport) ||
612 IsEqualIID(riid, &IID_IPOP3Transport))
615 IUnknown_AddRef(iface);
619 FIXME("no interface for %s\n", debugstr_guid(riid));
620 return E_NOINTERFACE;
623 static ULONG WINAPI POP3Transport_AddRef(IPOP3Transport *iface)
625 POP3Transport *This = (POP3Transport *)iface;
626 return InterlockedIncrement((LONG *)&This->refs);
629 static ULONG WINAPI POP3Transport_Release(IPOP3Transport *iface)
631 POP3Transport *This = (POP3Transport *)iface;
632 ULONG refs = InterlockedDecrement((LONG *)&This->refs);
635 TRACE("destroying %p\n", This);
636 if (This->InetTransport.Status != IXP_DISCONNECTED)
637 InternetTransport_DropConnection(&This->InetTransport);
638 if (This->InetTransport.pCallback) ITransportCallback_Release(This->InetTransport.pCallback);
639 HeapFree(GetProcessHeap(), 0, This);
644 static HRESULT WINAPI POP3Transport_GetServerInfo(IPOP3Transport *iface,
645 LPINETSERVER pInetServer)
647 POP3Transport *This = (POP3Transport *)iface;
649 TRACE("(%p)\n", pInetServer);
650 return InternetTransport_GetServerInfo(&This->InetTransport, pInetServer);
653 static IXPTYPE WINAPI POP3Transport_GetIXPType(IPOP3Transport *iface)
659 static HRESULT WINAPI POP3Transport_IsState(IPOP3Transport *iface, IXPISSTATE isstate)
661 FIXME("(%u)\n", isstate);
665 static HRESULT WINAPI POP3Transport_InetServerFromAccount(
666 IPOP3Transport *iface, IImnAccount *pAccount, LPINETSERVER pInetServer)
668 POP3Transport *This = (POP3Transport *)iface;
670 TRACE("(%p, %p)\n", pAccount, pInetServer);
671 return InternetTransport_InetServerFromAccount(&This->InetTransport, pAccount, pInetServer);
674 static HRESULT WINAPI POP3Transport_Connect(IPOP3Transport *iface,
675 LPINETSERVER pInetServer, boolean fAuthenticate, boolean fCommandLogging)
677 POP3Transport *This = (POP3Transport *)iface;
680 TRACE("(%p, %s, %s)\n", pInetServer, fAuthenticate ? "TRUE" : "FALSE", fCommandLogging ? "TRUE" : "FALSE");
682 hr = InternetTransport_Connect(&This->InetTransport, pInetServer, fAuthenticate, fCommandLogging);
686 init_parser(This, POP3_USER, POP3_NONE);
688 This->server = *pInetServer;
689 return InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackSendUSERCmd);
692 static HRESULT WINAPI POP3Transport_HandsOffCallback(IPOP3Transport *iface)
694 POP3Transport *This = (POP3Transport *)iface;
697 return InternetTransport_HandsOffCallback(&This->InetTransport);
700 static HRESULT WINAPI POP3Transport_Disconnect(IPOP3Transport *iface)
703 return IPOP3Transport_CommandQUIT(iface);
706 static HRESULT WINAPI POP3Transport_DropConnection(IPOP3Transport *iface)
708 POP3Transport *This = (POP3Transport *)iface;
711 return InternetTransport_DropConnection(&This->InetTransport);
714 static HRESULT WINAPI POP3Transport_GetStatus(IPOP3Transport *iface,
715 IXPSTATUS *pCurrentStatus)
717 POP3Transport *This = (POP3Transport *)iface;
720 return InternetTransport_GetStatus(&This->InetTransport, pCurrentStatus);
723 static HRESULT WINAPI POP3Transport_InitNew(IPOP3Transport *iface,
724 LPSTR pszLogFilePath, IPOP3Callback *pCallback)
726 POP3Transport *This = (POP3Transport *)iface;
728 TRACE("(%s, %p)\n", debugstr_a(pszLogFilePath), pCallback);
734 FIXME("not using log file of %s, use Wine debug logging instead\n",
735 debugstr_a(pszLogFilePath));
737 IPOP3Callback_AddRef(pCallback);
738 This->InetTransport.pCallback = (ITransportCallback *)pCallback;
739 This->InetTransport.fInitialised = TRUE;
744 static HRESULT WINAPI POP3Transport_MarkItem(IPOP3Transport *iface, POP3MARKTYPE marktype,
745 DWORD dwPopId, boolean fMarked)
747 FIXME("(%u, %u, %d)\n", marktype, dwPopId, fMarked);
751 static HRESULT WINAPI POP3Transport_CommandAUTH(IPOP3Transport *iface, LPSTR pszAuthType)
753 FIXME("(%s)\n", pszAuthType);
757 static HRESULT WINAPI POP3Transport_CommandUSER(IPOP3Transport *iface, LPSTR username)
759 static char user[] = "USER ";
760 POP3Transport *This = (POP3Transport *)iface;
764 TRACE("(%s)\n", username);
766 len = sizeof(user) + strlen(username) + 2; /* "\r\n" */
767 command = HeapAlloc(GetProcessHeap(), 0, len);
769 strcpy(command, user);
770 strcat(command, username);
771 strcat(command, "\r\n");
773 init_parser(This, POP3_USER, POP3_NONE);
774 InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvUSERResp);
776 HeapFree(GetProcessHeap(), 0, command);
780 static HRESULT WINAPI POP3Transport_CommandPASS(IPOP3Transport *iface, LPSTR password)
782 static char pass[] = "PASS ";
783 POP3Transport *This = (POP3Transport *)iface;
787 TRACE("(%p)\n", password);
789 len = sizeof(pass) + strlen(password) + 2; /* "\r\n" */
790 command = HeapAlloc(GetProcessHeap(), 0, len);
792 strcpy(command, pass);
793 strcat(command, password);
794 strcat(command, "\r\n");
796 init_parser(This, POP3_PASS, POP3_NONE);
797 InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvPASSResp);
799 HeapFree(GetProcessHeap(), 0, command);
803 static HRESULT WINAPI POP3Transport_CommandLIST(
804 IPOP3Transport *iface, POP3CMDTYPE cmdtype, DWORD dwPopId)
806 static char list[] = "LIST\r\n";
807 POP3Transport *This = (POP3Transport *)iface;
809 TRACE("(%u, %u)\n", cmdtype, dwPopId);
811 init_parser(This, POP3_LIST, cmdtype);
812 InternetTransport_DoCommand(&This->InetTransport, list, POP3Transport_CallbackRecvLISTResp);
816 static HRESULT WINAPI POP3Transport_CommandTOP(
817 IPOP3Transport *iface, POP3CMDTYPE cmdtype, DWORD dwPopId, DWORD cPreviewLines)
819 FIXME("(%u, %u, %u)\n", cmdtype, dwPopId, cPreviewLines);
823 static HRESULT WINAPI POP3Transport_CommandQUIT(IPOP3Transport *iface)
825 static char command[] = "QUIT\r\n";
826 POP3Transport *This = (POP3Transport *)iface;
830 init_parser(This, POP3_QUIT, POP3_NONE);
831 return InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvQUITResp);
834 static HRESULT WINAPI POP3Transport_CommandSTAT(IPOP3Transport *iface)
836 static char stat[] = "STAT\r\n";
837 POP3Transport *This = (POP3Transport *)iface;
841 init_parser(This, POP3_STAT, POP3_NONE);
842 InternetTransport_DoCommand(&This->InetTransport, stat, POP3Transport_CallbackRecvSTATResp);
846 static HRESULT WINAPI POP3Transport_CommandNOOP(IPOP3Transport *iface)
852 static HRESULT WINAPI POP3Transport_CommandRSET(IPOP3Transport *iface)
858 static HRESULT WINAPI POP3Transport_CommandUIDL(
859 IPOP3Transport *iface, POP3CMDTYPE cmdtype, DWORD dwPopId)
861 static char uidl[] = "UIDL\r\n";
862 POP3Transport *This = (POP3Transport *)iface;
864 TRACE("(%u, %u)\n", cmdtype, dwPopId);
866 init_parser(This, POP3_UIDL, cmdtype);
867 InternetTransport_DoCommand(&This->InetTransport, uidl, POP3Transport_CallbackRecvUIDLResp);
871 static HRESULT WINAPI POP3Transport_CommandDELE(
872 IPOP3Transport *iface, POP3CMDTYPE cmdtype, DWORD dwPopId)
874 static char dele[] = "DELE %u\r\n";
875 POP3Transport *This = (POP3Transport *)iface;
879 TRACE("(%u, %u)\n", cmdtype, dwPopId);
881 len = sizeof(dele) + 10 + 2; /* "4294967296" + "\r\n" */
882 if (!(command = HeapAlloc(GetProcessHeap(), 0, len))) return S_FALSE;
883 sprintf(command, dele, dwPopId);
885 init_parser(This, POP3_DELE, cmdtype);
886 InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvDELEResp);
888 HeapFree(GetProcessHeap(), 0, command);
892 static HRESULT WINAPI POP3Transport_CommandRETR(
893 IPOP3Transport *iface, POP3CMDTYPE cmdtype, DWORD dwPopId)
895 FIXME("(%u, %u)\n", cmdtype, dwPopId);
899 static const IPOP3TransportVtbl POP3TransportVtbl =
901 POP3Transport_QueryInterface,
902 POP3Transport_AddRef,
903 POP3Transport_Release,
904 POP3Transport_GetServerInfo,
905 POP3Transport_GetIXPType,
906 POP3Transport_IsState,
907 POP3Transport_InetServerFromAccount,
908 POP3Transport_Connect,
909 POP3Transport_HandsOffCallback,
910 POP3Transport_Disconnect,
911 POP3Transport_DropConnection,
912 POP3Transport_GetStatus,
913 POP3Transport_InitNew,
914 POP3Transport_MarkItem,
915 POP3Transport_CommandAUTH,
916 POP3Transport_CommandUSER,
917 POP3Transport_CommandPASS,
918 POP3Transport_CommandLIST,
919 POP3Transport_CommandTOP,
920 POP3Transport_CommandQUIT,
921 POP3Transport_CommandSTAT,
922 POP3Transport_CommandNOOP,
923 POP3Transport_CommandRSET,
924 POP3Transport_CommandUIDL,
925 POP3Transport_CommandDELE,
926 POP3Transport_CommandRETR
929 HRESULT WINAPI CreatePOP3Transport(IPOP3Transport **ppTransport)
932 POP3Transport *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
934 return E_OUTOFMEMORY;
936 This->InetTransport.u.vtblPOP3 = &POP3TransportVtbl;
938 hr = InternetTransport_Init(&This->InetTransport);
941 HeapFree(GetProcessHeap(), 0, This);
945 *ppTransport = (IPOP3Transport *)&This->InetTransport.u.vtblPOP3;
946 IPOP3Transport_AddRef(*ppTransport);
951 static HRESULT WINAPI POP3TransportCF_QueryInterface(LPCLASSFACTORY iface,
952 REFIID riid, LPVOID *ppv)
955 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
958 IUnknown_AddRef(iface);
961 return E_NOINTERFACE;
964 static ULONG WINAPI POP3TransportCF_AddRef(LPCLASSFACTORY iface)
966 return 2; /* non-heap based object */
969 static ULONG WINAPI POP3TransportCF_Release(LPCLASSFACTORY iface)
971 return 1; /* non-heap based object */
974 static HRESULT WINAPI POP3TransportCF_CreateInstance(LPCLASSFACTORY iface,
975 LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
978 IPOP3Transport *pPop3Transport;
980 TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
985 return CLASS_E_NOAGGREGATION;
987 hr = CreatePOP3Transport(&pPop3Transport);
991 hr = IPOP3Transport_QueryInterface(pPop3Transport, riid, ppv);
992 IPOP3Transport_Release(pPop3Transport);
997 static HRESULT WINAPI POP3TransportCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
999 FIXME("(%d)\n",fLock);
1003 static const IClassFactoryVtbl POP3TransportCFVtbl =
1005 POP3TransportCF_QueryInterface,
1006 POP3TransportCF_AddRef,
1007 POP3TransportCF_Release,
1008 POP3TransportCF_CreateInstance,
1009 POP3TransportCF_LockServer
1011 static const IClassFactoryVtbl *POP3TransportCF = &POP3TransportCFVtbl;
1013 HRESULT POP3TransportCF_Create(REFIID riid, LPVOID *ppv)
1015 return IClassFactory_QueryInterface((IClassFactory *)&POP3TransportCF, riid, ppv);