Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
7.7 KiB

  1. // --------------------------------------------------------------------------------
  2. // h t t p t a s k . h
  3. // Copyright (c)1998 Microsoft Corporation, All Rights Reserved
  4. // Greg S. Friedman
  5. // --------------------------------------------------------------------------------
  6. #ifndef __HTTPTASK_H
  7. #define __HTTPTASK_H
  8. // --------------------------------------------------------------------------------
  9. // Depends
  10. // --------------------------------------------------------------------------------
  11. #include "spoolapi.h"
  12. #include "srtarray.h"
  13. #include "taskutil.h"
  14. // --------------------------------------------------------------------------------
  15. // State
  16. // --------------------------------------------------------------------------------
  17. #define HTTPSTATE_CANCELED FLAG01
  18. #define HTTPSTATE_EVENTSUCCESS FLAG02 // one or more events succeeded
  19. // --------------------------------------------------------------------------------
  20. // HTTPEVENTINFO
  21. // --------------------------------------------------------------------------------
  22. typedef struct tagHTTPEVENTINFO {
  23. DWORD dwFlags; // Flags
  24. MESSAGEID idMessage; // Store Information
  25. BOOL fComplete; // has event been completed
  26. DWORD cbSentTotal; // running total of sent bytes
  27. } HTTPEVENTINFO, *LPHTTPEVENTINFO;
  28. // --------------------------------------------------------------------------------
  29. // CHTTPTask
  30. // --------------------------------------------------------------------------------
  31. class CHTTPTask: public ISpoolerTask, IHTTPMailCallback
  32. {
  33. public:
  34. // ----------------------------------------------------------------------------
  35. // CHTTPTask
  36. // ----------------------------------------------------------------------------
  37. CHTTPTask(void);
  38. private:
  39. ~CHTTPTask(void);
  40. public:
  41. // ---------------------------------------------------------------------------
  42. // IUnknown members
  43. // ---------------------------------------------------------------------------
  44. STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  45. STDMETHODIMP_(ULONG) AddRef(void);
  46. STDMETHODIMP_(ULONG) Release(void);
  47. // ---------------------------------------------------------------------------
  48. // ISpoolerTask
  49. // ---------------------------------------------------------------------------
  50. STDMETHODIMP Init(DWORD dwFlags, ISpoolerBindContext *pBindCtx);
  51. STDMETHODIMP BuildEvents(ISpoolerUI *pSpoolerUI, IImnAccount *pAccount, FOLDERID idFolder);
  52. STDMETHODIMP Execute(EVENTID eid, DWORD_PTR dwTwinkie);
  53. STDMETHODIMP CancelEvent(EVENTID eid, DWORD_PTR dwTwinkie);
  54. STDMETHODIMP ShowProperties(HWND hwndParent, EVENTID eid, DWORD_PTR dwTwinkie) { return TrapError(E_NOTIMPL); }
  55. STDMETHODIMP GetExtendedDetails(EVENTID eid, DWORD_PTR dwTwinkie, LPSTR *ppszDetails) { return TrapError(E_NOTIMPL); }
  56. STDMETHODIMP Cancel(void);
  57. STDMETHODIMP IsDialogMessage(LPMSG pMsg);
  58. STDMETHODIMP OnFlagsChanged(DWORD dwFlags);
  59. // ----------------------------------------------------------------------------
  60. // ITransportCallback methods
  61. // ----------------------------------------------------------------------------
  62. STDMETHODIMP OnLogonPrompt(
  63. LPINETSERVER pInetServer,
  64. IInternetTransport *pTransport);
  65. STDMETHODIMP_(INT) OnPrompt(
  66. HRESULT hrError,
  67. LPCTSTR pszText,
  68. LPCTSTR pszCaption,
  69. UINT uType,
  70. IInternetTransport *pTransport);
  71. STDMETHODIMP OnStatus(
  72. IXPSTATUS ixpstatus,
  73. IInternetTransport *pTransport);
  74. STDMETHODIMP OnError(
  75. IXPSTATUS ixpstatus,
  76. LPIXPRESULT pIxpResult,
  77. IInternetTransport *pTransport);
  78. STDMETHODIMP OnProgress(
  79. DWORD dwIncrement,
  80. DWORD dwCurrent,
  81. DWORD dwMaximum,
  82. IInternetTransport *pTransport);
  83. STDMETHODIMP OnCommand(
  84. CMDTYPE cmdtype,
  85. LPSTR pszLine,
  86. HRESULT hrResponse,
  87. IInternetTransport *pTransport);
  88. STDMETHODIMP OnTimeout(
  89. DWORD *pdwTimeout,
  90. IInternetTransport *pTransport);
  91. // ----------------------------------------------------------------------------
  92. // IHTTPMailCallback methods
  93. // ----------------------------------------------------------------------------
  94. STDMETHODIMP OnResponse(LPHTTPMAILRESPONSE pResponse);
  95. STDMETHODIMP GetParentWindow(HWND *phwndParent);
  96. private:
  97. // ---------------------------------------------------------------------------
  98. // Private Methods
  99. // ---------------------------------------------------------------------------
  100. void _Reset(void);
  101. TASKRESULTTYPE _CatchResult(HRESULT hr);
  102. TASKRESULTTYPE _CatchResult(LPIXPRESULT pResult);
  103. HRESULT _HrAppendOutboxMessage(LPCSTR pszAccount, LPMESSAGEINFO pmi);
  104. HRESULT _HrCreateSendProps(IMimeMessage *pMessage, LPSTR *ppszFrom, LPHTTPTARGETLIST *ppTargets);
  105. HRESULT _HrCreateHeaderStream(IMimeMessage *pMessage, IStream **ppStream);
  106. HRESULT _HrOpenMessage(MESSAGEID idMessage, IMimeMessage **ppMessage);
  107. HRESULT _HrPostCurrentMessage(void);
  108. HRESULT _HrExecuteSend(EVENTID eid, DWORD_PTR dwTwinkie);
  109. HRESULT _HrAdoptSendMsgUrl(LPSTR pszSendMsgUrl);
  110. HRESULT _HrFinishCurrentEvent(HRESULT hrResult, LPSTR pszLocationUrl);
  111. HRESULT _HrStartNextEvent(void);
  112. HRESULT _OnDisconnectComplete(void);
  113. void _UpdateSendMessageProgress(LPHTTPMAILRESPONSE pResponse);
  114. void _DoProgress(void);
  115. private:
  116. // ---------------------------------------------------------------------------
  117. // Private Data
  118. // ---------------------------------------------------------------------------
  119. LONG m_cRef; // Reference counting
  120. CRITICAL_SECTION m_cs; // thread safety
  121. DWORD m_dwFlags; // flags
  122. DWORD m_dwState; // state flags
  123. DWORD m_cbTotal; // total bytes to send
  124. DWORD m_cbSent; // number of bytes sent
  125. DWORD m_cbStart; // number of bytes sent at event start
  126. long m_cCompleted; // number of messages successfully sent
  127. WORD m_wProgress; // Current progress index
  128. ISpoolerBindContext *m_pSpoolCtx; // spooler bind context
  129. IImnAccount *m_pAccount; // account
  130. IMessageFolder *m_pOutbox; // The outbox
  131. IMessageFolder *m_pSentItems; // Sent items folder
  132. CSortedArray *m_psaEvents; // array of queued events
  133. long m_iEvent; // Current Event
  134. LPSTR m_pszSubject; // subject of current message
  135. IStream *m_pBody; // current message body
  136. IHTTPMailTransport *m_pTransport; // http data transport
  137. ISpoolerUI *m_pUI; // SpoolerUI
  138. EVENTID m_idSendEvent; // EventId for message send
  139. INETSERVER m_rServer; // Server information
  140. LPSTR m_pszAccountId; // Account Id
  141. LPSTR m_pszSendMsgUrl; // Url to post outbound messages to
  142. };
  143. #endif // __HTTPTASK_H