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.

139 lines
5.0 KiB

  1. #include <wininet.h>
  2. #include "cifcomp.h"
  3. #include "cifmode.h"
  4. #include "cifgroup.h"
  5. #include "enum.h"
  6. class CInstallEngine;
  7. class CCifFile : public ICifFile
  8. {
  9. public:
  10. CCifFile();
  11. ~CCifFile();
  12. HRESULT Download();
  13. HRESULT Install(BOOL *pfOneInstalled);
  14. void SortEntries(); // sort the arrays
  15. void ReinsertComponent(CCifComponent *pComp);
  16. HRESULT DownloadCifFile(LPCSTR pszUrl, LPCSTR pszCif);
  17. HRESULT SetCifFile(LPCSTR pszCifPath, BOOL bRWFlag);
  18. void MarkCriticalComponents(CCifComponent *);
  19. void RemoveFromCriticalComponents(CCifComponent *);
  20. LPCSTR GetCifPath() { return _szCifPath; }
  21. LPCSTR GetDownloadDir() { return _szDLDir; }
  22. LPCSTR GetFilelist() { return _szFilelist; }
  23. void SetDownloadDir(LPCSTR pszDir);
  24. void SetInstallEngine(CInstallEngine *p) { _pInsEng = p; }
  25. BOOL CanCancel() { return ( _pLastCriticalComp == NULL); }
  26. void ClearQueueState();
  27. CInstallEngine *GetInstallEngine() { return _pInsEng; }
  28. CCifComponent **GetComponentList() { return _rpComp ? _rpComp:(CCifComponent **)_rpRWComp; }
  29. // *** IUnknown methods ***
  30. STDMETHOD(QueryInterface) (REFIID riid, LPVOID * ppvObj);
  31. STDMETHOD_(ULONG,AddRef) ();
  32. STDMETHOD_(ULONG,Release) ();
  33. // *** ICifFile methods ***
  34. STDMETHOD(EnumComponents)(IEnumCifComponents **, DWORD dwFilter, LPVOID pv);
  35. STDMETHOD(FindComponent)(LPCSTR pszID, ICifComponent **p);
  36. STDMETHOD(EnumGroups)(IEnumCifGroups **, DWORD dwFilter, LPVOID pv);
  37. STDMETHOD(FindGroup)(LPCSTR pszID, ICifGroup **p);
  38. STDMETHOD(EnumModes)(IEnumCifModes **, DWORD dwFilter, LPVOID pv);
  39. STDMETHOD(FindMode)(LPCSTR pszID, ICifMode **p);
  40. STDMETHOD(GetDescription)(LPSTR pszDesc, DWORD dwSize);
  41. STDMETHOD(GetDetDlls)(LPSTR pszDlls, DWORD dwSize);
  42. protected:
  43. // private data
  44. UINT _cRef; // ref count
  45. char _szCifPath[MAX_PATH]; // local path to cif
  46. char _szFilelist[MAX_PATH]; // filelist.dat
  47. char _szDLDir[MAX_PATH]; // download directory
  48. CInstallEngine *_pInsEng;
  49. CCifComponent **_rpComp; // array of components
  50. CCifGroup **_rpGroup; // array of groups
  51. CCifMode **_rpMode; // array of modes
  52. UINT _cComp;
  53. UINT _cGroup;
  54. UINT _cMode;
  55. CCifComponent *_pLastCriticalComp;
  56. // for read write arrays
  57. CCifRWComponent **_rpRWComp; // array of components
  58. CCifRWGroup **_rpRWGroup; // array of groups
  59. CCifRWMode **_rpRWMode; // array of modes
  60. BOOL _fCleanDir:1;
  61. // private methods
  62. HRESULT _ParseCifFile(BOOL bRWFlag); // parse cif into arrays
  63. void _SortComponents(CCifComponent **, UINT start, UINT finish);
  64. void _SortGroups(CCifGroup **, UINT start, UINT finish);
  65. HRESULT _ExtractDetDlls(LPCSTR pszCab, LPCSTR pszPath);
  66. HRESULT _CopyDetDlls(LPCSTR pszPath);
  67. HRESULT _FindCifComponent(LPCSTR pszID, CCifComponent **p);
  68. void _CheckDependencyPriority();
  69. };
  70. class CCifRWFile : public ICifRWFile, public CCifFile
  71. {
  72. public:
  73. // *** IUnknown methods ***
  74. STDMETHOD(QueryInterface) (REFIID riid, LPVOID * ppvObj);
  75. STDMETHOD_(ULONG,AddRef) ();
  76. STDMETHOD_(ULONG,Release) ();
  77. // *** ICifFile methods ***
  78. STDMETHOD(EnumComponents)(IEnumCifComponents **, DWORD dwFilter, LPVOID pv);
  79. STDMETHOD(FindComponent)(LPCSTR pszID, ICifComponent **p);
  80. STDMETHOD(EnumGroups)(IEnumCifGroups **, DWORD dwFilter, LPVOID pv);
  81. STDMETHOD(FindGroup)(LPCSTR pszID, ICifGroup **p);
  82. STDMETHOD(EnumModes)(IEnumCifModes **, DWORD dwFilter, LPVOID pv);
  83. STDMETHOD(FindMode)(LPCSTR pszID, ICifMode **p);
  84. STDMETHOD(GetDescription)(LPSTR pszDesc, DWORD dwSize);
  85. STDMETHOD(GetDetDlls)(LPSTR pszDlls, DWORD dwSize);
  86. //
  87. CCifRWFile();
  88. ~CCifRWFile();
  89. // ICifRWFile methods
  90. STDMETHOD(SetDescription)(THIS_ LPCSTR pszDesc);
  91. STDMETHOD(CreateComponent)(THIS_ LPCSTR pszID, ICifRWComponent **p);
  92. STDMETHOD(CreateGroup)(THIS_ LPCSTR pszID, ICifRWGroup **p);
  93. STDMETHOD(CreateMode)(THIS_ LPCSTR pszID, ICifRWMode **p);
  94. STDMETHOD(DeleteComponent)(THIS_ LPCSTR pszID);
  95. STDMETHOD(DeleteGroup)(THIS_ LPCSTR pszID);
  96. STDMETHOD(DeleteMode)(THIS_ LPCSTR pszID);
  97. STDMETHOD(Flush)();
  98. private:
  99. UINT _cCompUnused;
  100. UINT _cGroupUnused;
  101. UINT _cModeUnused;
  102. };
  103. typedef struct _SetCifArgs
  104. {
  105. char szUrl[INTERNET_MAX_URL_LENGTH];
  106. char szCif[MAX_PATH];
  107. CCifFile *pCif;
  108. } SETCIFARGS;
  109. DWORD WINAPI DownloadCifFile(LPVOID);