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.

245 lines
9.8 KiB

  1. #ifndef _ASINSCTL_H
  2. #define _ASINSCTL_H
  3. #include "ipserver.h"
  4. #include "ctrlobj.h"
  5. #include "internet.h"
  6. #include "iasctrls.h"
  7. #include "inseng.h"
  8. #include "progdlg.h"
  9. #define RESID_TOOLBOX_BITMAP 1
  10. #define FINALIZE_DOREBOOT 0x00000001
  11. #define FINALIZE_NOREBOOTPROMPT 0x00000002
  12. #define PROCESSCOMPONENT_DELAYREBOOT 0x00000001
  13. #define PROCESSCOMPONENT_NOPROGRESSUI 0x00000002
  14. #define PROCESSCOMPONENT_NOSUMMARYUI 0x00000004
  15. #define PROCESSCOMPONENT_NOINSTALLUI 0x00000080
  16. #define MAX_URLS 5
  17. #define ERROR_STRING_SIZE 2048
  18. #define ERROR_STRING_INCREMENT 2048
  19. //---------------------------------------------
  20. // AUTORUN SETTINGS FOR WIN
  21. //---------------------------------------------
  22. #define WINDOWS_DEFAULT_AUTOPLAY_VALUE 0x095
  23. #define WINDOWS_AUTOPLAY_OFF 0x0FF
  24. typedef struct
  25. {
  26. DWORD dwSize;
  27. DWORD dwStatus;
  28. DWORD dwSubstatus;
  29. DWORD dwPhase;
  30. DWORD dwResult;
  31. BSTR strID;
  32. BSTR strName;
  33. BSTR strString;
  34. BSTR chWin;
  35. BSTR chInstall;
  36. BSTR chDL;
  37. DWORD dwWin;
  38. DWORD dwInstall;
  39. DWORD dwDL;
  40. } CALLBACK_PARAMS;
  41. // Global needed in CInstallEngine for suppressing CD Auto Splash.
  42. extern UINT g_uCDAutorunMsg;
  43. extern unsigned long g_ulOldAutorunSetting;
  44. unsigned long SetAutorunSetting(unsigned long ulNewSettting);
  45. //=--------------------------------------------------------------------------=
  46. // CInstallEngine
  47. //=--------------------------------------------------------------------------=
  48. // our control.
  49. //
  50. class CInstallEngineCtl : public COleControl, public IInstallEngineCtl, public IInstallEngineCallback, public ISupportErrorInfo
  51. {
  52. friend class CProgressDlg;
  53. friend INT_PTR CALLBACK ProgressDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  54. friend DWORD WINAPI DoInstall(LPVOID pv);
  55. friend INT_PTR CALLBACK LocationDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  56. friend INT_PTR CALLBACK DiskSpaceDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  57. public:
  58. // IUnknown methods
  59. //
  60. DECLARE_STANDARD_UNKNOWN();
  61. // IDispatch methods
  62. //
  63. DECLARE_STANDARD_DISPATCH();
  64. // ISupportErrorInfo methods
  65. //
  66. DECLARE_STANDARD_SUPPORTERRORINFO();
  67. // IInstallEngine methods
  68. //
  69. STDMETHOD(get_ReadyState)(THIS_ long FAR* thestate);
  70. STDMETHOD(SetCifFile)(THIS_ BSTR strCabName, BSTR strCifName);
  71. STDMETHOD(put_BaseUrl)(THIS_ BSTR strBaseUrl);
  72. STDMETHOD(put_DownloadDir)(THIS_ BSTR strDownloadDir);
  73. STDMETHOD(SetAction)(THIS_ BSTR ComponentID, long action, long *lResult);
  74. STDMETHOD(IsComponentInstalled)(THIS_ BSTR ComponentID, long *lResult);
  75. STDMETHOD(ProcessComponents)(THIS_ long lFlag);
  76. STDMETHOD(get_Size)(THIS_ BSTR ComponentID, long FAR* thestate);
  77. STDMETHOD(get_DisplayName)(THIS_ BSTR ComponentID, BSTR *name);
  78. STDMETHOD(Abort)(THIS_ long lFlags);
  79. STDMETHOD(get_TotalDownloadSize)(THIS_ long FAR* totalsize);
  80. STDMETHOD(get_TotalDependencySize)(THIS_ long FAR* totaldepsize);
  81. STDMETHOD(FinalizeInstall)(THIS_ long lFlag);
  82. STDMETHOD(get_EngineStatus)(THIS_ long FAR* theenginestatus);
  83. STDMETHOD(HandleEngineProblem)(THIS_ long lFlag);
  84. STDMETHOD(CheckFreeSpace)(THIS_ long lPad, long FAR* lEnough);
  85. STDMETHOD(SetLocalCif)(THIS_ BSTR strCif, long FAR* lResult);
  86. STDMETHOD(SetSitesFile)(THIS_ BSTR strUrl, BSTR strRegion, BSTR strLocale, long FAR* lResult);
  87. // Install engine callbacks
  88. STDMETHOD(OnStartInstall)(DWORD dwDLSize, DWORD dwInstallSize);
  89. STDMETHOD(OnStartComponent)(LPCSTR pszID, DWORD dwDLSize, DWORD dwInstallSize, LPCSTR pszName);
  90. STDMETHOD(OnComponentProgress)(LPCSTR pszID, DWORD dwPhase, LPCSTR pszName, LPCSTR pszMsgString, ULONG progress, ULONG dwMax );
  91. STDMETHOD(OnStopComponent)(LPCSTR pszID, HRESULT hrError, DWORD dwPhase, LPCSTR pszString, DWORD dwStatus);
  92. STDMETHOD(OnStopInstall)(HRESULT hrError, LPCSTR szError, DWORD dwStatus);
  93. STDMETHOD(OnEngineStatusChange)(DWORD dwStatus, DWORD substatus);
  94. STDMETHOD(OnEngineProblem)(DWORD dwProblem, LPDWORD pdwAction);
  95. // OLE Control stuff follows:
  96. //
  97. CInstallEngineCtl(IUnknown *pUnkOuter, BOOL *pbSuccess);
  98. virtual ~CInstallEngineCtl();
  99. // static creation function. all controls must have one of these!
  100. //
  101. static IUnknown *Create(IUnknown *);
  102. // Helper functions to fire our events
  103. void _FireOnStartInstallEvent(DWORD dwTotalSize);
  104. void _FireOnStartComponentEvent(LPCSTR pszID, DWORD dwTotalSize, LPCSTR pszName);
  105. void _FireOnStopComponentEvent(LPCSTR pszID, HRESULT hrError, DWORD dwPhase, LPCSTR pszString, DWORD dwStatus);
  106. void _FireOnStopInstallEvent(HRESULT hrError, LPCSTR szError, DWORD dwStatus);
  107. void _FireEngineStatusChange(DWORD dwEngineStatus, DWORD substatus);
  108. void _FireOnEngineProblem(DWORD dwProblem);
  109. void _FireOnComponentProgressEvent(LPCSTR pszID, DWORD dwPhase, LPCSTR pszString, LPCSTR pszMsgString, ULONG progress, ULONG themax);
  110. void _FireOnComponentProgress(DWORD lPhase, DWORD lSoFar, DWORD lTotal);
  111. void _FireOnStartInstallExEvent(DWORD dwDLSize, DWORD dwInsSize);
  112. private:
  113. // overridables that the control must implement.
  114. //
  115. STDMETHOD(LoadBinaryState)(IStream *pStream);
  116. STDMETHOD(SaveBinaryState)(IStream *pStream);
  117. STDMETHOD(LoadTextState)(IPropertyBag *pPropertyBag, IErrorLog *pErrorLog);
  118. STDMETHOD(SaveTextState)(IPropertyBag *pPropertyBag, BOOL fWriteDefault);
  119. STDMETHOD(OnDraw)(DWORD dvAspect, HDC hdcDraw, LPCRECTL prcBounds, LPCRECTL prcWBounds, HDC hicTargetDev, BOOL fOptimize);
  120. STDMETHOD(FreezeEvents)(BOOL bFreeze);
  121. // Window stuff
  122. virtual LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam);
  123. virtual BOOL RegisterClassData(void);
  124. // internal QI
  125. virtual HRESULT InternalQueryInterface(REFIID, void **);
  126. // before and after window is created
  127. virtual void BeforeCreateWindow(void);
  128. virtual BOOL AfterCreateWindow(void);
  129. void _InitProgressDialog();
  130. void _DoInstall();
  131. HRESULT _CheckInstallPath(BOOL *pfNeedDownload);
  132. BOOL _PathIsIEInstallPoint(LPCSTR pszPath);
  133. HRESULT _PickWebSites(LPCSTR pszSites, LPCSTR pszLocale, LPCSTR pszRegion, BOOL bKeepExisting);
  134. BOOL _IsEnoughSpace(LPSTR szSpace1, DWORD dwSize1, LPSTR szSpace2, DWORD dwSize2,
  135. LPSTR szSpace3, DWORD dwSize3);
  136. HRESULT _CheckForDiskSpace();
  137. HRESULT _ShowDiskSpaceDialog();
  138. void _FireCancel(DWORD dwCancel);
  139. LONG _OpenJITKey(HKEY *hKey, REGSAM samAttr);
  140. void _DeleteURLList();
  141. void _WriteURLList();
  142. void _WriteRegionToReg(LPSTR szRegion);
  143. void _PickRegionAndFirstSite(IDownloadSite **ppISite, UINT uNumSites, LPSTR pszRegion, UINT *puFirstSite);
  144. void _PickRandomSites(IDownloadSite **ppISite, BYTE *pPicks, UINT uNumSites, UINT uNumToPick, LPSTR pszRegion);
  145. void MarkJITInstall();
  146. BOOL _fInOnEngineProblem:1;
  147. BOOL _fEventToFire:1;
  148. BOOL _fNeedReboot:1;
  149. BOOL _fLocalCifSet:1;
  150. BOOL _fReconcileCif:1;
  151. BOOL _fDoingIEInstall:1;
  152. BOOL _fInstalling:1;
  153. BOOL _fJITInstall:1;
  154. DWORD _dwOldStatus;
  155. DWORD _dwAction;
  156. DWORD _dwInstallStatus;
  157. UINT _uInstallMode;
  158. UINT _uInstallPad;
  159. HRESULT _hResult;
  160. DWORD _dwSavedEngineStatus;
  161. DWORD _dwSavedSubStatus;
  162. DWORD _dwFreezeEvents;
  163. DWORD _uAllowGrovel;
  164. BSTR _strCurrentID;
  165. BSTR _strCurrentName;
  166. BSTR _strCurrentString;
  167. DWORD m_readyState;
  168. LPSTR _pszErrorString;
  169. int _iErrorStringSize;
  170. DWORD _dwProcessComponentsFlags;
  171. HICON _hIcon;
  172. DWORD _dwLastPhase;
  173. CProgressDlg *_pProgDlg;
  174. IInstallEngine2 *_pinseng;
  175. DWORD _dwMSTrustKey;
  176. HANDLE _hDone;
  177. UINT _uCurrentUrl;
  178. LPSTR _rpszUrlList[MAX_URLS];
  179. char _szCifCab[MAX_PATH];
  180. char _szCifFile[MAX_PATH];
  181. char _szDownloadDir[MAX_PATH];
  182. BOOL _bCancelPending;
  183. BOOL _bDeleteURLList;
  184. BOOL _bNewWebSites;
  185. };
  186. DWORD WINAPI DoInstall(LPVOID pv);
  187. DEFINE_CONTROLOBJECT(InstallEngineCtl, // Name of object
  188. &CLSID_InstallEngineCtl, // CLSID of object
  189. "InstallEngineCtl", // ProgID
  190. CInstallEngineCtl::Create, // Static create function
  191. 1, // Version
  192. &IID_IInstallEngineCtl, // Primary dispatch
  193. NULL, // name of help file
  194. &DIID_DInstallEngineCtlEvents, // event interface
  195. OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_RECOMPOSEONRESIZE|OLEMISC_CANTLINKINSIDE|OLEMISC_INSIDEOUT,
  196. 0, // Activation policy
  197. RESID_TOOLBOX_BITMAP, // toolbox id
  198. "InstallEngineCtlWndClass", // Window class
  199. 0, // number of pages
  200. NULL, // array of property pages
  201. 0, // Number of verbs
  202. NULL); // Array of verbs
  203. #define OBJECT_INSTALLENGINECTL 0
  204. #endif