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.

195 lines
7.1 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) 1993-1996 Microsoft Corporation. All Rights Reserved.
  3. //
  4. // MODULE: ontask.h
  5. //
  6. // PURPOSE: Defines the Offline News task.
  7. //
  8. #ifndef __ONTASK_H__
  9. #define __ONTASK_H__
  10. #include "spoolapi.h"
  11. #include <storutil.h>
  12. /////////////////////////////////////////////////////////////////////////////
  13. // Forward references
  14. //
  15. class CNewsStore;
  16. /////////////////////////////////////////////////////////////////////////////
  17. // Types of events we support
  18. //
  19. typedef struct tagONEVENTINFO
  20. {
  21. char szGroup[256];
  22. FOLDERID idGroup;
  23. DWORD dwFlags;
  24. BOOL fMarked;
  25. BOOL fIMAP;
  26. } ONEVENTINFO;
  27. typedef enum tagONTASKSTATE
  28. {
  29. ONTS_IDLE = 0, // Idle
  30. ONTS_CONNECTING, // Waiting for a connect response
  31. ONTS_INIT, // Initializing
  32. ONTS_HEADERRESP, // Waiting for the header download
  33. ONTS_ALLMSGS, // Downloading all messages
  34. ONTS_NEWMSGS, // Downloading new messages
  35. ONTS_MARKEDMSGS, // Downloading marked messages
  36. ONTS_END, // Cleanup
  37. ONTS_MAX
  38. } ONTASKSTATE;
  39. typedef enum tagARTICLESTATE
  40. {
  41. ARTICLE_GETNEXT,
  42. ARTICLE_ONRESP,
  43. ARTICLE_END,
  44. ARTICLE_MAX
  45. } ARTICLESTATE;
  46. class COfflineTask;
  47. typedef HRESULT (COfflineTask::*PFNONSTATEFUNC)(THIS_ void);
  48. typedef HRESULT (COfflineTask::*PFNARTICLEFUNC)(THIS_ void);
  49. /////////////////////////////////////////////////////////////////////////////
  50. // class COfflineTask
  51. //
  52. // Overview:
  53. // This object defines and implements the ISpoolerTask interface to handle
  54. // offline news functions. This is a separate object from CNewsTask to
  55. // provide a logical separation between what needs to be done online versus
  56. // what is only done offline in news.
  57. //
  58. class COfflineTask : public ISpoolerTask, public IStoreCallback, public ITimeoutCallback
  59. {
  60. public:
  61. /////////////////////////////////////////////////////////////////////////
  62. // Constructor, destructor, initialization
  63. COfflineTask();
  64. ~COfflineTask();
  65. /////////////////////////////////////////////////////////////////////////
  66. // IUnknown Interface
  67. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj);
  68. STDMETHOD_(ULONG, AddRef)(THIS);
  69. STDMETHOD_(ULONG, Release)(THIS);
  70. /////////////////////////////////////////////////////////////////////////
  71. // ISpoolerTask Interface
  72. STDMETHOD(Init)(THIS_ DWORD dwFlags, ISpoolerBindContext *pBindCtx);
  73. STDMETHOD(BuildEvents)(THIS_ ISpoolerUI *pSpoolerUI, IImnAccount *pAccount, FOLDERID idFolder);
  74. STDMETHOD(Execute)(THIS_ EVENTID eid, DWORD_PTR dwTwinkie);
  75. STDMETHOD(CancelEvent)(THIS_ EVENTID eid, DWORD_PTR dwTwinkie);
  76. STDMETHOD(ShowProperties)(THIS_ HWND hwndParent, EVENTID eid, DWORD_PTR dwTwinkie);
  77. STDMETHOD(GetExtendedDetails)(THIS_ EVENTID eid, DWORD_PTR dwTwinkie, LPSTR *ppszDetails);
  78. STDMETHOD(Cancel)(THIS);
  79. STDMETHOD(IsDialogMessage)(THIS_ LPMSG pMsg);
  80. STDMETHOD(OnFlagsChanged)(THIS_ DWORD dwFlags);
  81. /////////////////////////////////////////////////////////////////////////
  82. // IStoreCallback Interface
  83. STDMETHODIMP OnBegin(STOREOPERATIONTYPE tyOperation, STOREOPERATIONINFO *pOpInfo, IOperationCancel *pCancel);
  84. STDMETHODIMP OnProgress(STOREOPERATIONTYPE tyOperation, DWORD dwCurrent, DWORD dwMax, LPCSTR pszStatus);
  85. STDMETHODIMP OnTimeout(LPINETSERVER pServer, LPDWORD pdwTimeout, IXPTYPE ixpServerType);
  86. STDMETHODIMP CanConnect(LPCSTR pszAccountId, DWORD dwFlags);
  87. STDMETHODIMP OnLogonPrompt(LPINETSERVER pServer, IXPTYPE ixpServerType);
  88. STDMETHODIMP OnComplete(STOREOPERATIONTYPE tyOperation, HRESULT hrComplete, LPSTOREOPERATIONINFO pOpInfo, LPSTOREERROR pErrorInfo);
  89. STDMETHODIMP OnPrompt(HRESULT hrError, LPCTSTR pszText, LPCTSTR pszCaption, UINT uType, INT *piUserResponse);
  90. STDMETHODIMP GetParentWindow(DWORD dwReserved, HWND *phwndParent);
  91. /////////////////////////////////////////////////////////////////////////
  92. // ITimeoutCallback Interface
  93. STDMETHODIMP OnTimeoutResponse(TIMEOUTRESPONSE eResponse);
  94. private:
  95. /////////////////////////////////////////////////////////////////////////
  96. // Window callback and message handling
  97. static LRESULT CALLBACK TaskWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  98. /////////////////////////////////////////////////////////////////////////
  99. // These functions build the event list
  100. HRESULT InsertGroups(IImnAccount *pAccount, FOLDERID idFolder);
  101. HRESULT InsertAllGroups(FOLDERID idParent, IImnAccount *pAccount, BOOL fIMAP);
  102. /////////////////////////////////////////////////////////////////////////
  103. // State Machine Stuff
  104. void NextState(void);
  105. HRESULT Download_Init(void);
  106. HRESULT Download_AllMsgs(void);
  107. HRESULT Download_NewMsgs(void);
  108. HRESULT Download_MarkedMsgs(void);
  109. HRESULT Download_Done(void);
  110. HRESULT Article_Init(MESSAGEIDLIST *pList);
  111. HRESULT Article_GetNext(void);
  112. HRESULT Article_OnResp(WPARAM wParam, LPARAM lParam);
  113. HRESULT Article_OnError(WPARAM wParam, LPARAM lParam);
  114. HRESULT Article_Done(void);
  115. /////////////////////////////////////////////////////////////////////////
  116. // Utility functions
  117. void SetGeneralProgress(const TCHAR *pFmt, ...);
  118. void SetSpecificProgress(const TCHAR *pFmt, ...);
  119. void InsertError(const TCHAR *pFmt, ...);
  120. private:
  121. /////////////////////////////////////////////////////////////////////////
  122. // Private member data
  123. ULONG m_cRef;
  124. // State
  125. BOOL m_fInited;
  126. DWORD m_dwFlags;
  127. ONTASKSTATE m_state;
  128. ARTICLESTATE m_as;
  129. EVENTID m_eidCur;
  130. ONEVENTINFO *m_pInfo;
  131. char m_szAccount[CCHMAX_ACCOUNT_NAME];
  132. char m_szAccountId[CCHMAX_ACCOUNT_NAME];
  133. FOLDERID m_idAccount;
  134. DWORD m_cEvents;
  135. BOOL m_fDownloadErrors;
  136. BOOL m_fFailed;
  137. DWORD m_fNewHeaders;
  138. BOOL m_fCancel;
  139. // Spooler Interfaces
  140. ISpoolerBindContext *m_pBindCtx;
  141. ISpoolerUI *m_pUI;
  142. IMessageFolder *m_pFolder;
  143. // Windows
  144. HWND m_hwnd;
  145. // State table
  146. static const PFNONSTATEFUNC m_rgpfnState[ONTS_MAX];
  147. static const PFNARTICLEFUNC m_rgpfnArticle[ARTICLE_MAX];
  148. // Used during event execution
  149. DWORD m_dwLast;
  150. DWORD m_dwPrev;
  151. DWORD m_cDownloaded;
  152. DWORD m_cCur;
  153. DWORD_PTR m_dwPrevHigh;
  154. DWORD m_dwNewInboxMsgs;
  155. LPMESSAGEIDLIST m_pList;
  156. // Callback
  157. HTIMEOUT m_hTimeout;
  158. IOperationCancel *m_pCancel;
  159. STOREOPERATIONTYPE m_tyOperation;
  160. };
  161. #endif // __ONTASK_H__