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_CallbackProcessNOOPResp(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_CallbackRecvNOOPResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
431 POP3Transport *This = (POP3Transport *)iface;
434 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessNOOPResp);
437 static void POP3Transport_CallbackProcessRSETResp(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_CallbackRecvRSETResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
457 POP3Transport *This = (POP3Transport *)iface;
460 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessRSETResp);
463 static void POP3Transport_CallbackProcessLISTResp(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_CallbackRecvLISTResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
483 POP3Transport *This = (POP3Transport *)iface;
486 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessLISTResp);
489 static void POP3Transport_CallbackProcessUIDLResp(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 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
507 static void POP3Transport_CallbackRecvUIDLResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
509 POP3Transport *This = (POP3Transport *)iface;
512 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessUIDLResp);
515 static void POP3Transport_CallbackProcessSTATResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
517 POP3Transport *This = (POP3Transport *)iface;
518 POP3RESPONSE response;
523 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
526 /* FIXME: handle error */
530 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
533 static void POP3Transport_CallbackRecvSTATResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
535 POP3Transport *This = (POP3Transport *)iface;
538 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessSTATResp);
541 static void POP3Transport_CallbackProcessPASSResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
543 POP3Transport *This = (POP3Transport *)iface;
544 POP3RESPONSE response;
549 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
552 /* FIXME: handle error */
556 InternetTransport_ChangeStatus(&This->InetTransport, IXP_AUTHORIZED);
557 InternetTransport_ChangeStatus(&This->InetTransport, IXP_CONNECTED);
559 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
562 static void POP3Transport_CallbackRecvPASSResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
564 POP3Transport *This = (POP3Transport *)iface;
567 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessPASSResp);
570 static void POP3Transport_CallbackProcessUSERResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
572 static char pass[] = "PASS ";
573 POP3Transport *This = (POP3Transport *)iface;
574 POP3RESPONSE response;
581 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
584 /* FIXME: handle error */
588 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
590 len = sizeof(pass) + strlen(This->server.szPassword) + 2; /* "\r\n" */
591 command = HeapAlloc(GetProcessHeap(), 0, len);
593 strcpy(command, pass);
594 strcat(command, This->server.szPassword);
595 strcat(command, "\r\n");
597 init_parser(This, POP3_PASS, POP3_NONE);
599 InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvPASSResp);
600 HeapFree(GetProcessHeap(), 0, command);
603 static void POP3Transport_CallbackRecvUSERResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
605 POP3Transport *This = (POP3Transport *)iface;
608 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessUSERResp);
611 static void POP3Transport_CallbackSendUSERCmd(IInternetTransport *iface, char *pBuffer, int cbBuffer)
613 static char user[] = "USER ";
614 POP3Transport *This = (POP3Transport *)iface;
620 len = sizeof(user) + strlen(This->server.szUserName) + 2; /* "\r\n" */
621 command = HeapAlloc(GetProcessHeap(), 0, len);
623 strcpy(command, user);
624 strcat(command, This->server.szUserName);
625 strcat(command, "\r\n");
626 InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvUSERResp);
628 HeapFree(GetProcessHeap(), 0, command);
631 static void POP3Transport_CallbackProcessQUITResponse(IInternetTransport *iface, char *pBuffer, int cbBuffer)
633 POP3Transport *This = (POP3Transport *)iface;
634 POP3RESPONSE response;
637 TRACE("%s\n", debugstr_an(pBuffer, cbBuffer));
639 hr = POP3Transport_ParseResponse(This, pBuffer, &response);
642 /* FIXME: handle error */
646 IPOP3Callback_OnResponse((IPOP3Callback *)This->InetTransport.pCallback, &response);
647 InternetTransport_DropConnection(&This->InetTransport);
650 static void POP3Transport_CallbackRecvQUITResp(IInternetTransport *iface, char *pBuffer, int cbBuffer)
652 POP3Transport *This = (POP3Transport *)iface;
655 InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackProcessQUITResponse);
658 static HRESULT WINAPI POP3Transport_QueryInterface(IPOP3Transport *iface, REFIID riid, void **ppv)
660 TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
662 if (IsEqualIID(riid, &IID_IUnknown) ||
663 IsEqualIID(riid, &IID_IInternetTransport) ||
664 IsEqualIID(riid, &IID_IPOP3Transport))
667 IUnknown_AddRef(iface);
671 FIXME("no interface for %s\n", debugstr_guid(riid));
672 return E_NOINTERFACE;
675 static ULONG WINAPI POP3Transport_AddRef(IPOP3Transport *iface)
677 POP3Transport *This = (POP3Transport *)iface;
678 return InterlockedIncrement((LONG *)&This->refs);
681 static ULONG WINAPI POP3Transport_Release(IPOP3Transport *iface)
683 POP3Transport *This = (POP3Transport *)iface;
684 ULONG refs = InterlockedDecrement((LONG *)&This->refs);
687 TRACE("destroying %p\n", This);
688 if (This->InetTransport.Status != IXP_DISCONNECTED)
689 InternetTransport_DropConnection(&This->InetTransport);
690 if (This->InetTransport.pCallback) ITransportCallback_Release(This->InetTransport.pCallback);
691 HeapFree(GetProcessHeap(), 0, This);
696 static HRESULT WINAPI POP3Transport_GetServerInfo(IPOP3Transport *iface,
697 LPINETSERVER pInetServer)
699 POP3Transport *This = (POP3Transport *)iface;
701 TRACE("(%p)\n", pInetServer);
702 return InternetTransport_GetServerInfo(&This->InetTransport, pInetServer);
705 static IXPTYPE WINAPI POP3Transport_GetIXPType(IPOP3Transport *iface)
711 static HRESULT WINAPI POP3Transport_IsState(IPOP3Transport *iface, IXPISSTATE isstate)
713 FIXME("(%u)\n", isstate);
717 static HRESULT WINAPI POP3Transport_InetServerFromAccount(
718 IPOP3Transport *iface, IImnAccount *pAccount, LPINETSERVER pInetServer)
720 POP3Transport *This = (POP3Transport *)iface;
722 TRACE("(%p, %p)\n", pAccount, pInetServer);
723 return InternetTransport_InetServerFromAccount(&This->InetTransport, pAccount, pInetServer);
726 static HRESULT WINAPI POP3Transport_Connect(IPOP3Transport *iface,
727 LPINETSERVER pInetServer, boolean fAuthenticate, boolean fCommandLogging)
729 POP3Transport *This = (POP3Transport *)iface;
732 TRACE("(%p, %s, %s)\n", pInetServer, fAuthenticate ? "TRUE" : "FALSE", fCommandLogging ? "TRUE" : "FALSE");
734 hr = InternetTransport_Connect(&This->InetTransport, pInetServer, fAuthenticate, fCommandLogging);
738 init_parser(This, POP3_USER, POP3_NONE);
740 This->server = *pInetServer;
741 return InternetTransport_ReadLine(&This->InetTransport, POP3Transport_CallbackSendUSERCmd);
744 static HRESULT WINAPI POP3Transport_HandsOffCallback(IPOP3Transport *iface)
746 POP3Transport *This = (POP3Transport *)iface;
749 return InternetTransport_HandsOffCallback(&This->InetTransport);
752 static HRESULT WINAPI POP3Transport_Disconnect(IPOP3Transport *iface)
755 return IPOP3Transport_CommandQUIT(iface);
758 static HRESULT WINAPI POP3Transport_DropConnection(IPOP3Transport *iface)
760 POP3Transport *This = (POP3Transport *)iface;
763 return InternetTransport_DropConnection(&This->InetTransport);
766 static HRESULT WINAPI POP3Transport_GetStatus(IPOP3Transport *iface,
767 IXPSTATUS *pCurrentStatus)
769 POP3Transport *This = (POP3Transport *)iface;
772 return InternetTransport_GetStatus(&This->InetTransport, pCurrentStatus);
775 static HRESULT WINAPI POP3Transport_InitNew(IPOP3Transport *iface,
776 LPSTR pszLogFilePath, IPOP3Callback *pCallback)
778 POP3Transport *This = (POP3Transport *)iface;
780 TRACE("(%s, %p)\n", debugstr_a(pszLogFilePath), pCallback);
786 FIXME("not using log file of %s, use Wine debug logging instead\n",
787 debugstr_a(pszLogFilePath));
789 IPOP3Callback_AddRef(pCallback);
790 This->InetTransport.pCallback = (ITransportCallback *)pCallback;
791 This->InetTransport.fInitialised = TRUE;
796 static HRESULT WINAPI POP3Transport_MarkItem(IPOP3Transport *iface, POP3MARKTYPE marktype,
797 DWORD dwPopId, boolean fMarked)
799 FIXME("(%u, %u, %d)\n", marktype, dwPopId, fMarked);
803 static HRESULT WINAPI POP3Transport_CommandAUTH(IPOP3Transport *iface, LPSTR pszAuthType)
805 FIXME("(%s)\n", pszAuthType);
809 static HRESULT WINAPI POP3Transport_CommandUSER(IPOP3Transport *iface, LPSTR username)
811 static char user[] = "USER ";
812 POP3Transport *This = (POP3Transport *)iface;
816 TRACE("(%s)\n", username);
818 len = sizeof(user) + strlen(username) + 2; /* "\r\n" */
819 command = HeapAlloc(GetProcessHeap(), 0, len);
821 strcpy(command, user);
822 strcat(command, username);
823 strcat(command, "\r\n");
825 init_parser(This, POP3_USER, POP3_NONE);
826 InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvUSERResp);
828 HeapFree(GetProcessHeap(), 0, command);
832 static HRESULT WINAPI POP3Transport_CommandPASS(IPOP3Transport *iface, LPSTR password)
834 static char pass[] = "PASS ";
835 POP3Transport *This = (POP3Transport *)iface;
839 TRACE("(%p)\n", password);
841 len = sizeof(pass) + strlen(password) + 2; /* "\r\n" */
842 command = HeapAlloc(GetProcessHeap(), 0, len);
844 strcpy(command, pass);
845 strcat(command, password);
846 strcat(command, "\r\n");
848 init_parser(This, POP3_PASS, POP3_NONE);
849 InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvPASSResp);
851 HeapFree(GetProcessHeap(), 0, command);
855 static HRESULT WINAPI POP3Transport_CommandLIST(
856 IPOP3Transport *iface, POP3CMDTYPE cmdtype, DWORD dwPopId)
858 static char list[] = "LIST\r\n";
859 POP3Transport *This = (POP3Transport *)iface;
861 TRACE("(%u, %u)\n", cmdtype, dwPopId);
863 init_parser(This, POP3_LIST, cmdtype);
864 InternetTransport_DoCommand(&This->InetTransport, list, POP3Transport_CallbackRecvLISTResp);
868 static HRESULT WINAPI POP3Transport_CommandTOP(
869 IPOP3Transport *iface, POP3CMDTYPE cmdtype, DWORD dwPopId, DWORD cPreviewLines)
871 FIXME("(%u, %u, %u)\n", cmdtype, dwPopId, cPreviewLines);
875 static HRESULT WINAPI POP3Transport_CommandQUIT(IPOP3Transport *iface)
877 static char command[] = "QUIT\r\n";
878 POP3Transport *This = (POP3Transport *)iface;
882 init_parser(This, POP3_QUIT, POP3_NONE);
883 return InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvQUITResp);
886 static HRESULT WINAPI POP3Transport_CommandSTAT(IPOP3Transport *iface)
888 static char stat[] = "STAT\r\n";
889 POP3Transport *This = (POP3Transport *)iface;
893 init_parser(This, POP3_STAT, POP3_NONE);
894 InternetTransport_DoCommand(&This->InetTransport, stat, POP3Transport_CallbackRecvSTATResp);
898 static HRESULT WINAPI POP3Transport_CommandNOOP(IPOP3Transport *iface)
900 static char noop[] = "NOOP\r\n";
901 POP3Transport *This = (POP3Transport *)iface;
905 init_parser(This, POP3_NOOP, POP3_NONE);
906 InternetTransport_DoCommand(&This->InetTransport, noop, POP3Transport_CallbackRecvNOOPResp);
910 static HRESULT WINAPI POP3Transport_CommandRSET(IPOP3Transport *iface)
912 static char rset[] = "RSET\r\n";
913 POP3Transport *This = (POP3Transport *)iface;
917 init_parser(This, POP3_RSET, POP3_NONE);
918 InternetTransport_DoCommand(&This->InetTransport, rset, POP3Transport_CallbackRecvRSETResp);
922 static HRESULT WINAPI POP3Transport_CommandUIDL(
923 IPOP3Transport *iface, POP3CMDTYPE cmdtype, DWORD dwPopId)
925 static char uidl[] = "UIDL\r\n";
926 POP3Transport *This = (POP3Transport *)iface;
928 TRACE("(%u, %u)\n", cmdtype, dwPopId);
930 init_parser(This, POP3_UIDL, cmdtype);
931 InternetTransport_DoCommand(&This->InetTransport, uidl, POP3Transport_CallbackRecvUIDLResp);
935 static HRESULT WINAPI POP3Transport_CommandDELE(
936 IPOP3Transport *iface, POP3CMDTYPE cmdtype, DWORD dwPopId)
938 static char dele[] = "DELE %u\r\n";
939 POP3Transport *This = (POP3Transport *)iface;
943 TRACE("(%u, %u)\n", cmdtype, dwPopId);
945 len = sizeof(dele) + 10 + 2; /* "4294967296" + "\r\n" */
946 if (!(command = HeapAlloc(GetProcessHeap(), 0, len))) return S_FALSE;
947 sprintf(command, dele, dwPopId);
949 init_parser(This, POP3_DELE, cmdtype);
950 InternetTransport_DoCommand(&This->InetTransport, command, POP3Transport_CallbackRecvDELEResp);
952 HeapFree(GetProcessHeap(), 0, command);
956 static HRESULT WINAPI POP3Transport_CommandRETR(
957 IPOP3Transport *iface, POP3CMDTYPE cmdtype, DWORD dwPopId)
959 FIXME("(%u, %u)\n", cmdtype, dwPopId);
963 static const IPOP3TransportVtbl POP3TransportVtbl =
965 POP3Transport_QueryInterface,
966 POP3Transport_AddRef,
967 POP3Transport_Release,
968 POP3Transport_GetServerInfo,
969 POP3Transport_GetIXPType,
970 POP3Transport_IsState,
971 POP3Transport_InetServerFromAccount,
972 POP3Transport_Connect,
973 POP3Transport_HandsOffCallback,
974 POP3Transport_Disconnect,
975 POP3Transport_DropConnection,
976 POP3Transport_GetStatus,
977 POP3Transport_InitNew,
978 POP3Transport_MarkItem,
979 POP3Transport_CommandAUTH,
980 POP3Transport_CommandUSER,
981 POP3Transport_CommandPASS,
982 POP3Transport_CommandLIST,
983 POP3Transport_CommandTOP,
984 POP3Transport_CommandQUIT,
985 POP3Transport_CommandSTAT,
986 POP3Transport_CommandNOOP,
987 POP3Transport_CommandRSET,
988 POP3Transport_CommandUIDL,
989 POP3Transport_CommandDELE,
990 POP3Transport_CommandRETR
993 HRESULT WINAPI CreatePOP3Transport(IPOP3Transport **ppTransport)
996 POP3Transport *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
998 return E_OUTOFMEMORY;
1000 This->InetTransport.u.vtblPOP3 = &POP3TransportVtbl;
1002 hr = InternetTransport_Init(&This->InetTransport);
1005 HeapFree(GetProcessHeap(), 0, This);
1009 *ppTransport = (IPOP3Transport *)&This->InetTransport.u.vtblPOP3;
1010 IPOP3Transport_AddRef(*ppTransport);
1015 static HRESULT WINAPI POP3TransportCF_QueryInterface(LPCLASSFACTORY iface,
1016 REFIID riid, LPVOID *ppv)
1019 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
1022 IUnknown_AddRef(iface);
1025 return E_NOINTERFACE;
1028 static ULONG WINAPI POP3TransportCF_AddRef(LPCLASSFACTORY iface)
1030 return 2; /* non-heap based object */
1033 static ULONG WINAPI POP3TransportCF_Release(LPCLASSFACTORY iface)
1035 return 1; /* non-heap based object */
1038 static HRESULT WINAPI POP3TransportCF_CreateInstance(LPCLASSFACTORY iface,
1039 LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
1042 IPOP3Transport *pPop3Transport;
1044 TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
1049 return CLASS_E_NOAGGREGATION;
1051 hr = CreatePOP3Transport(&pPop3Transport);
1055 hr = IPOP3Transport_QueryInterface(pPop3Transport, riid, ppv);
1056 IPOP3Transport_Release(pPop3Transport);
1061 static HRESULT WINAPI POP3TransportCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
1063 FIXME("(%d)\n",fLock);
1067 static const IClassFactoryVtbl POP3TransportCFVtbl =
1069 POP3TransportCF_QueryInterface,
1070 POP3TransportCF_AddRef,
1071 POP3TransportCF_Release,
1072 POP3TransportCF_CreateInstance,
1073 POP3TransportCF_LockServer
1075 static const IClassFactoryVtbl *POP3TransportCF = &POP3TransportCFVtbl;
1077 HRESULT POP3TransportCF_Create(REFIID riid, LPVOID *ppv)
1079 return IClassFactory_QueryInterface((IClassFactory *)&POP3TransportCF, riid, ppv);