Source code of Windows XP (NT5)
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.

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