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.

140 lines
5.1 KiB

  1. //
  2. // Delivery Agents base class
  3. #ifndef _DELAGENT_H
  4. #define _DELAGENT_H
  5. #include "offline.h"
  6. #define INET_S_AGENT_BASIC_SUCCESS _HRESULT_TYPEDEF_(0x000C0FFEL)
  7. class CDeliveryAgent : public ISubscriptionAgentControl,
  8. public IShellPropSheetExt,
  9. public IExtractIconA,
  10. public IExtractIcon,
  11. public ISubscriptionAgentShellExt
  12. {
  13. private:
  14. // Data for our OLE support
  15. ULONG m_cRef;
  16. #ifdef AGENT_AUTODIAL
  17. enum DIALER_STATUS { DIALER_OFFLINE, DIALER_CONNECTING, DIALER_ONLINE };
  18. DIALER_STATUS m_iDialerStatus;
  19. #endif
  20. enum {
  21. FLAG_BUSY =0x00010000, // addrefed ourselves; between begin & end reports
  22. FLAG_PAUSED =0x00020000, // We are paused
  23. FLAG_OPSTARTED =0x00040000, // We've entered StartOperation
  24. };
  25. // Derived agents can use high 8 bits of this field
  26. DWORD m_dwAgentFlags;
  27. void SendUpdateBegin();
  28. void SendUpdateEnd();
  29. HRESULT ProcessEndItem(ISubscriptionItem *pEndItem);
  30. protected:
  31. // Upper 16 bits allowable here
  32. enum {
  33. FLAG_HOSTED =0x00100000, // hosted by another delivery agent
  34. FLAG_CHANGESONLY =0x00200000, // We're in "Changes Only" mode
  35. FLAG_WAITING_FOR_INCREASED_CACHE = 0x00400000, // Special paused state
  36. };
  37. POOEBuf m_pBuf;
  38. HPROPSHEETPAGE m_hPage[MAX_WC_AGENT_PAGES];
  39. ISubscriptionAgentEvents *m_pAgentEvents;
  40. ISubscriptionItem *m_pSubscriptionItem;
  41. SUBSCRIPTIONCOOKIE m_SubscriptionCookie;
  42. long m_lSizeDownloadedKB; // Size downloaded in KB
  43. SCODE m_scEndStatus;
  44. void SendUpdateNone(); // Call from StartOperation if we won't be doing anything
  45. void SendUpdateProgress(LPCWSTR pwszURL, long lProgress, long lMax, long lCurSizeKB=-1);
  46. BOOL IsAgentFlagSet(int iFlag) { return (m_dwAgentFlags & iFlag); }
  47. void ClearAgentFlag(int iFlag) { m_dwAgentFlags &= ~iFlag; }
  48. void SetAgentFlag(int iFlag) { m_dwAgentFlags |= iFlag; }
  49. HRESULT CheckResponseCode(DWORD dwHttpResponseCode); // Also sets EndStatus. E_ABORT on error.
  50. // DIALER_STATUS GetDialerStatus() { return m_iDialerStatus; }
  51. void SetEndStatus(SCODE sc) { m_scEndStatus = sc; }
  52. virtual ~CDeliveryAgent();
  53. public:
  54. CDeliveryAgent();
  55. BOOL GetBusy() { return IsAgentFlagSet(FLAG_BUSY); }
  56. BOOL IsPaused() { return IsAgentFlagSet(FLAG_PAUSED); }
  57. SCODE GetEndStatus() { return m_scEndStatus; }
  58. // IUnknown members
  59. STDMETHODIMP QueryInterface(REFIID riid, void **punk);
  60. STDMETHODIMP_(ULONG) AddRef(void);
  61. STDMETHODIMP_(ULONG) Release(void);
  62. // ISubscriptionAgentControl members
  63. STDMETHODIMP StartUpdate(IUnknown *pItem, IUnknown *punkAdvise);
  64. STDMETHODIMP PauseUpdate(DWORD dwFlags);
  65. STDMETHODIMP ResumeUpdate(DWORD dwFlags);
  66. STDMETHODIMP AbortUpdate(DWORD dwFlags);
  67. STDMETHODIMP SubscriptionControl(IUnknown *pItem, DWORD dwControl); // Called on delete
  68. // IShellPropSheetExt members
  69. STDMETHODIMP AddPages(LPFNADDPROPSHEETPAGE, LPARAM);
  70. STDMETHODIMP ReplacePage(UINT, LPFNADDPROPSHEETPAGE, LPARAM);
  71. // ISubscriptionAgentShellExt
  72. STDMETHODIMP Initialize(SUBSCRIPTIONCOOKIE *pSubscriptionCookie,
  73. LPCWSTR pwszURL, LPCWSTR pwszName,
  74. SUBSCRIPTIONTYPE subsType);
  75. STDMETHODIMP RemovePages(HWND hdlg);
  76. STDMETHODIMP SaveSubscription();
  77. STDMETHODIMP URLChange(LPCWSTR pwszNewURL);
  78. // IExtractIconA
  79. STDMETHODIMP GetIconLocation(UINT uFlags, LPSTR szIconFile, UINT cchMax, int * piIndex, UINT * pwFlags);
  80. STDMETHODIMP Extract(LPCSTR pszFile, UINT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIconSize);
  81. // IExtractIconT
  82. STDMETHODIMP GetIconLocation(UINT uFlags, LPTSTR szIconFile, UINT cchMax, int * piIndex, UINT * pwFlags);
  83. STDMETHODIMP Extract(LPCTSTR pszFile, UINT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIconSize);
  84. private:
  85. // Functions we provide common implementations for
  86. HRESULT DoStartDownload();
  87. #ifdef AGENT_AUTODIAL
  88. HRESULT NotifyAutoDialer();
  89. HRESULT OnInetOnline();
  90. HRESULT OnInetOffline();
  91. #endif
  92. protected:
  93. // Virtual functions for our derived classes to override as necessary
  94. // We provide implementations which should be called after processing
  95. virtual HRESULT AgentPause(DWORD dwFlags);
  96. virtual HRESULT AgentResume(DWORD dwFlags);
  97. virtual HRESULT AgentAbort(DWORD dwFlags);
  98. virtual HRESULT ModifyUpdateEnd(ISubscriptionItem *pEndItem, UINT *puiRes);
  99. virtual HRESULT StartOperation(); // connects to internet
  100. virtual HRESULT StartDownload() = 0; // we just got connected
  101. virtual void CleanUp();
  102. };
  103. #endif // _DELAGENT_H