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.

154 lines
6.2 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) 1993-1998 Microsoft Corporation. All Rights Reserved.
  3. //
  4. // MODULE: watchtsk.h
  5. //
  6. // PURPOSE: Defines the spooler task that is responsible for checking
  7. // for watched messages.
  8. //
  9. #pragma once
  10. #include "spoolapi.h"
  11. #include "storutil.h"
  12. /////////////////////////////////////////////////////////////////////////////
  13. // States for the state machine
  14. //
  15. typedef enum tagWATCHTASKSTATE
  16. {
  17. WTS_IDLE = 0,
  18. WTS_CONNECTING,
  19. WTS_INIT,
  20. WTS_NEXTFOLDER,
  21. WTS_RESP,
  22. WTS_END,
  23. WTS_MAX
  24. } WATCHTASKSTATE;
  25. class CWatchTask;
  26. typedef HRESULT (CWatchTask::*PFNWSTATEFUNC)(THIS_ void);
  27. /////////////////////////////////////////////////////////////////////////////
  28. // class CWatchTask
  29. //
  30. // Overview:
  31. // This object is responsible for checking folders on the server for new
  32. // messages that might be part of a conversation the user is watching. If
  33. // one of these messages is found, then that message is downloaded into the
  34. // users's store and the user is notified.
  35. //
  36. class CWatchTask : public ISpoolerTask,
  37. public IStoreCallback,
  38. public ITimeoutCallback
  39. {
  40. public:
  41. /////////////////////////////////////////////////////////////////////////
  42. // Constructor, destructor, initialization
  43. //
  44. CWatchTask();
  45. ~CWatchTask();
  46. /////////////////////////////////////////////////////////////////////////
  47. // IUnknown Interface
  48. //
  49. STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
  50. STDMETHOD_(ULONG, AddRef)(void);
  51. STDMETHOD_(ULONG, Release)(void);
  52. /////////////////////////////////////////////////////////////////////////
  53. // ISpoolerTask Interface
  54. //
  55. STDMETHODIMP Init(DWORD dwFlags, ISpoolerBindContext *pBindCtx);
  56. STDMETHODIMP BuildEvents(ISpoolerUI *pSpoolerUI, IImnAccount *pAccount, FOLDERID idFolder);
  57. STDMETHODIMP Execute(EVENTID eid, DWORD_PTR dwTwinkie);
  58. STDMETHODIMP CancelEvent(EVENTID eid, DWORD_PTR dwTwinkie);
  59. STDMETHODIMP ShowProperties(HWND hwndParent, EVENTID eid, DWORD_PTR dwTwinkie);
  60. STDMETHODIMP GetExtendedDetails(EVENTID eid, DWORD_PTR dwTwinkie, LPSTR *ppszDetails);
  61. STDMETHODIMP Cancel(void);
  62. STDMETHODIMP IsDialogMessage(LPMSG pMsg);
  63. STDMETHODIMP OnFlagsChanged(DWORD dwFlags);
  64. /////////////////////////////////////////////////////////////////////////
  65. // IStoreCallback Interface
  66. //
  67. STDMETHODIMP OnBegin(STOREOPERATIONTYPE tyOperation, STOREOPERATIONINFO *pOpInfo, IOperationCancel *pCancel);
  68. STDMETHODIMP OnProgress(STOREOPERATIONTYPE tyOperation, DWORD dwCurrent, DWORD dwMax, LPCSTR pszStatus);
  69. STDMETHODIMP OnTimeout(LPINETSERVER pServer, LPDWORD pdwTimeout, IXPTYPE ixpServerType);
  70. STDMETHODIMP CanConnect(LPCSTR pszAccountId, DWORD dwFlags);
  71. STDMETHODIMP OnLogonPrompt(LPINETSERVER pServer, IXPTYPE ixpServerType);
  72. STDMETHODIMP OnComplete(STOREOPERATIONTYPE tyOperation, HRESULT hrComplete, LPSTOREOPERATIONINFO pOpInfo, LPSTOREERROR pErrorInfo);
  73. STDMETHODIMP OnPrompt(HRESULT hrError, LPCTSTR pszText, LPCTSTR pszCaption, UINT uType, INT *piUserResponse);
  74. STDMETHODIMP GetParentWindow(DWORD dwReserved, HWND *phwndParent);
  75. /////////////////////////////////////////////////////////////////////////
  76. // ITimeoutCallback Interface
  77. //
  78. STDMETHODIMP OnTimeoutResponse(TIMEOUTRESPONSE eResponse);
  79. protected:
  80. /////////////////////////////////////////////////////////////////////////
  81. // Window callback and message handling
  82. //
  83. static LRESULT CALLBACK _TaskWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  84. LPARAM lParam);
  85. /////////////////////////////////////////////////////////////////////////
  86. // General stuff
  87. //
  88. void CWatchTask::_NextState(void);
  89. BOOL _ChildFoldersHaveWatched(FOLDERID id);
  90. BOOL _FolderContainsWatched(FOLDERID id);
  91. /////////////////////////////////////////////////////////////////////////
  92. // State Machine functions, public but don't call 'em directly.
  93. //
  94. public:
  95. HRESULT _Watch_Init(void);
  96. HRESULT _Watch_NextFolder(void);
  97. HRESULT _Watch_Done(void);
  98. private:
  99. /////////////////////////////////////////////////////////////////////////
  100. // Private data
  101. //
  102. ULONG m_cRef; // Reference Count
  103. // State
  104. BOOL m_fInited; // TRUE if we've had our Init() member called
  105. DWORD m_dwFlags; // Execution flags from the spooler engine
  106. TCHAR m_szAccount[256];
  107. TCHAR m_szAccountId[256];
  108. FOLDERID m_idAccount;
  109. EVENTID m_eidCur; // The current executing event
  110. // Interfaces
  111. ISpoolerBindContext *m_pBindCtx; // Interface to communicate with the spooler engine
  112. ISpoolerUI *m_pUI; // Interface to communicate with the UI
  113. IImnAccount *m_pAccount; // Interface of the account we're checking
  114. IMessageServer *m_pServer; // Interface of the server object we're using
  115. IOperationCancel *m_pCancel; // Interface we use to cancel the current server op
  116. // Stuff
  117. FOLDERID m_idFolderCheck;// If the user just want's us to check one folder
  118. FOLDERID *m_rgidFolders; // Array of all of the folders we need to check
  119. DWORD m_cFolders; // Number of folders in m_rgidFolders
  120. HWND m_hwnd; // Handle of our window
  121. HTIMEOUT m_hTimeout; // Handle of the timeout dialog
  122. DWORD m_cMsgs; // Number of watched messages downloaded
  123. // State Machine goo
  124. DWORD m_state;
  125. BOOL m_fCancel; // TRUE if the user has pressed the Cancel button
  126. DWORD m_cCurFolder; // Current folder being checked. Index's into m_rgidFolders;
  127. DWORD m_cFailed; // Number of folders that could not be checked
  128. STOREOPERATIONTYPE m_tyOperation; // Current operation type
  129. };