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.

342 lines
12 KiB

  1. /******************************************************************************
  2. Header File: Project Record.H
  3. This defines the CProjectRecord class, which tracks and controls the progress
  4. and content of a single project workspace in the studio.
  5. Copyright (c) 1997 by Microsoft Corporation. All Rights Reserved.
  6. A Pretty Penny Enterprises Production.
  7. Change History:
  8. 02-03-1997 Bob_Kjelgaard@Prodigy.Net Created it
  9. ******************************************************************************/
  10. #if !defined(AFX_PROJREC_H__50303D0C_EKE1_11D2_AB62_00C04FA30E4A__INCLUDED_)
  11. #define AFX_PROJREC_H__50303D0C_EKE1_11D2_AB62_00C04FA30E4A__INCLUDED_
  12. #if defined(LONG_NAMES)
  13. #include "Driver Resources.H"
  14. #else
  15. #include "RCFile.H"
  16. #endif
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //
  19. // MDT Workspace Versioning
  20. //
  21. // The MDT uses MFC's Serialization support to save and restore the state of a
  22. // driver's workspace. This data is saved in an MDW file. The Serialization
  23. // support is supposed to include versioning but it doesn't seem to be working
  24. // so I have implemented my own versioning support for workspace files.
  25. //
  26. // A version stamp in the form of the following structure
  27. // (plus related definitions) will be added to the beginning of each MDW file.
  28. // The CProjectRecord::Serialize() will read and write the version stamp. The
  29. // version info is saved in a member variable (m_mvMDWVersion) and the number
  30. // is accessible via GetMDWVersion(). A version number of 0 is put into
  31. // m_nMDWVersion if the an old MDW with no version is read. In this case, the
  32. // workspace is marked as being dirty so that it can be updated later.
  33. //
  34. // The current version number is set by the value for MDW_CURRENT_VERSION.
  35. // Version numbers are unsigned integers. Each time the version number is
  36. // changed, an entry should be made in the following table describing the
  37. // reason for the change.
  38. //
  39. //
  40. // MDW VERSION HISTORY
  41. //
  42. // Version Date Description
  43. // ----------------------------------------------------------------------------
  44. // 0 02/01/98 Contains no version info. Should be the MDW
  45. // version that has UFM and GTT RC IDs in it.
  46. // 1 04/21/98 String table RC IDs were added to the MDW files.
  47. // 2 10/08/98 Default code page number added to the MDW files.
  48. // 3 09/15/98 RC file timestamp was added to the MDW file.
  49. // 4 12/14/98 Resource DLL name changed from xxxxxRES.DLL to
  50. // xxxxxxxx.DLL.
  51. // 5 03/02/99 Driver file paths removed from the MDW file.
  52. // 6 08/16/99 Changed the root of the driver files' subtree from
  53. // NT5 to W2K so that the directory name matches the
  54. // OS name.
  55. //
  56. //
  57. // The version information below is used to determine what is in an MDW file
  58. // and when to upgrade that file and other parts of a driver's workspace; most
  59. // notably the RC file. Upgrade determination and work (or at least the code
  60. // that manages the upgrading) are in CProjectRecord::OnOpenDocument(). See
  61. // that member function for more information.
  62. //
  63. // Definitions for the current MDW version, each MDW version that has been
  64. // used, the first upgradable version, and the default MDW version.
  65. #define MDW_CURRENT_VERSION 7 // See table above for more info
  66. #define MDW_VER_YES_FILE_PATHS 7 // Give .mdw file saving place flexibility. //raid 123448
  67. #define MDW_VER_FILES_IN_W2K_TREE 6 // Driver files in W2K tree
  68. #define MDW_VER_NO_FILE_PATHS 5 // Removed file paths from MDW file
  69. #define MDW_VER_NEW_DLLNAME 4 // Ver # when resource DLL name changed
  70. #define MDW_VER_RC_TIMESTAMP 3 // Ver # when RC file timestamp added
  71. #define MDW_VER_DEFAULT_CPAGE 2 // Ver # when default code page added
  72. #define MDW_VER_STRING_RCIDS 1 // Ver # when string IDs added
  73. #define MDW_FIRST_UPGRADABLE_VER 1 // All vers >= to this can be upgraded
  74. #define MDW_DEFAULT_VERSION 0 // Ver # when no ver info in MDW file
  75. #define VERTAGLEN 12 // Length of the version tag
  76. #define VERTAGSTR "EKE MDW VER" // Version tag string
  77. typedef struct mdwversioninfo {
  78. char acvertag[VERTAGLEN] ; // Used to identify version stamp
  79. unsigned uvernum ; // Version number
  80. } MDWVERSION, *PMDWVERSION ;
  81. #define MDWVERSIONSIZE sizeof(MDWVERSION)
  82. enum {Win95 = 1, WinNT3x, WinNT40 = 4, Win2000 = 8, NotW2000 = 16};
  83. class CProjectRecord : public CDocument {
  84. CString m_csSourceRCFile, m_csRCName;
  85. CString m_csW2000Path, m_csNT40Path, m_csNT3xPath, m_csWin95Path;
  86. CString m_csProjFSpec ; // Location of project file.
  87. // True iff the RC file should be rewritten whenever the project workspace
  88. // file is saved.
  89. BOOL m_bRCModifiedFlag ;
  90. UINT m_ufTargets;
  91. CDriverResources m_cdr; // A record of the RC file contents
  92. // Enumerated flags for the project's status
  93. enum {UniToolRun = 1, ConversionsDone = 2, NTGPCDone = 4};
  94. UINT m_ufStatus;
  95. MDWVERSION m_mvMDWVersion ; // MDW version information
  96. virtual BOOL OnSaveDocument( LPCTSTR lpszPathName ) ;
  97. // Last time RC file was changed by MDT.
  98. CTime m_ctRCFileTimeStamp ;
  99. // The next two variables are used to save the default code page number.
  100. // Two variables are used because the Far East code pages are built into
  101. // the MDT as resources so - in these cases - the Far East code pages'
  102. // resource number (actually negative resource number) is needed too.
  103. DWORD m_dwDefaultCodePage ; // Code page number / neg resource ID
  104. DWORD m_dwDefaultCodePageNum ;// Code page number
  105. protected: // create from serialization only
  106. CProjectRecord();
  107. DECLARE_DYNCREATE(CProjectRecord)
  108. // Attributes
  109. public:
  110. void SetRCModifiedFlag(BOOL bsetting) {m_bRCModifiedFlag = bsetting ; }
  111. BOOL IsTargetEnabled(UINT ufTarget) const {
  112. return m_ufTargets & ufTarget;
  113. }
  114. BOOL UniToolHasBeenRun() const { return m_ufStatus & UniToolRun; }
  115. BOOL ConversionsComplete() const {
  116. return m_ufStatus & ConversionsDone;
  117. }
  118. BOOL NTGPCCompleted() const { return m_ufStatus & NTGPCDone; }
  119. CString SourceFile() const { return m_csSourceRCFile; }
  120. CString DriverName() { return m_cdr.Name(); }
  121. CString TargetPath(UINT ufTarget) const;
  122. CString RCName(UINT ufTarget) const {
  123. return TargetPath(ufTarget) + _TEXT("\\") + m_csRCName;
  124. }
  125. unsigned MapCount() const { return m_cdr.MapCount(); }
  126. CGlyphMap& GlyphMap(unsigned u) { return m_cdr.GlyphTable(u); }
  127. unsigned ModelCount() const { return m_cdr.Models(); }
  128. CModelData& Model(unsigned u) { return m_cdr.Model(u); }
  129. CString GetW2000Path() { return m_csW2000Path ; }
  130. unsigned GetMDWVersion() { return m_mvMDWVersion.uvernum ; }
  131. void SetMDWVersion(unsigned nver) { m_mvMDWVersion.uvernum = nver ; }
  132. CStringTable* GetStrTable() { return m_cdr.GetStrTable() ; }
  133. bool RCFileChanged() ;
  134. bool GetRCFileTimeStamp(CTime& ct) ;
  135. // See variable declarations for more info about these functions.
  136. DWORD GetDefaultCodePage() { return m_dwDefaultCodePage ; }
  137. DWORD GetDefaultCodePageNum() { return m_dwDefaultCodePageNum ; }
  138. void SetDefaultCodePage(DWORD dwcp) { m_dwDefaultCodePage = dwcp ; }
  139. void SetDefaultCodePageNum(DWORD dwcp) { m_dwDefaultCodePageNum = dwcp ; }
  140. CString GetProjFSpec() { return m_csProjFSpec ; }
  141. // Operations
  142. public:
  143. void EnableTarget(UINT ufTarget, BOOL bOn = TRUE) {
  144. UINT ufCurrent = m_ufTargets;
  145. if (bOn)
  146. m_ufTargets |= ufTarget;
  147. else
  148. m_ufTargets &= ~ufTarget;
  149. if (ufCurrent == m_ufTargets)
  150. return;
  151. if (ufTarget & (WinNT3x | WinNT40 | Win2000) ) { //raid 105917
  152. m_ufStatus &=~(ConversionsDone | NTGPCDone);
  153. return;
  154. }
  155. }
  156. void SetSourceRCFile(LPCTSTR lpstrSource);
  157. BOOL LoadResources();
  158. BOOL LoadFontData() { return m_cdr.LoadFontData(*this); }
  159. // The next 3 functions support the GPD Selection feature in the Conversion
  160. // Wizard.
  161. BOOL GetGPDModelInfo(CStringArray* pcsamodels, CStringArray* pcsafiles) {
  162. return m_cdr.GetGPDModelInfo(pcsamodels, pcsafiles) ;
  163. }
  164. int SaveVerGPDFNames(CStringArray& csafiles, bool bverifydata) {
  165. return m_cdr.SaveVerGPDFNames(csafiles, bverifydata) ;
  166. } ;
  167. void GenerateGPDFileNames(CStringArray& csamodels, CStringArray& csafiles) {
  168. m_cdr.GenerateGPDFileNames(csamodels, csafiles) ;
  169. }
  170. BOOL SetPath(UINT ufTarget, LPCTSTR lpstrNewPath);
  171. BOOL BuildStructure(unsigned uVersion);
  172. BOOL GenerateTargets(WORD wfGPDConvert);
  173. void OldStuffDone() { m_ufStatus |= NTGPCDone; }
  174. void Rename(LPCTSTR lpstrNewName) { m_cdr.Rename(lpstrNewName); }
  175. void InitUI(CTreeCtrl *pctc) { m_cdr.Fill(pctc, *this); }
  176. void GPDConversionCheck(BOOL bReportSuccess = FALSE);
  177. // Conversion log file management routines
  178. bool OpenConvLogFile(void) {
  179. return m_cdr.OpenConvLogFile(m_csSourceRCFile) ;
  180. }
  181. void CloseConvLogFile(void) { m_cdr.CloseConvLogFile() ; }
  182. CString GetConvLogFileName() const {return m_cdr.GetConvLogFileName() ; }
  183. bool ThereAreConvErrors() {return m_cdr.ThereAreConvErrors() ; }
  184. bool WorkspaceChecker(bool bclosing) {
  185. return m_cdr.WorkspaceChecker(bclosing) ;
  186. }
  187. // Upgrade management routines.
  188. bool UpdateRCFile() ;
  189. bool UpdateDfltCodePage() ;
  190. bool UpdateDrvSubtreeRootName() ;
  191. // Overrides
  192. // ClassWizard generated virtual function overrides
  193. //{{AFX_VIRTUAL(CProjectRecord)
  194. public:
  195. virtual BOOL OnNewDocument();
  196. virtual void Serialize(CArchive& ar);
  197. virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
  198. protected:
  199. virtual BOOL SaveModified();
  200. //}}AFX_VIRTUAL
  201. // Implementation
  202. public:
  203. CGlyphMap& GlyphTable(unsigned u) { return m_cdr.GlyphTable(u) ; } ;
  204. BOOL CreateFromNew(CStringArray& csaUFMFiles,CStringArray& csaGTTFiles,CString& csGpdPath,CString& csModelName,CString& csResourceDll,CStringArray& csaRcid );
  205. bool VerUpdateFilePaths(void);
  206. virtual ~CProjectRecord();
  207. #ifdef _DEBUG
  208. virtual void AssertValid() const;
  209. virtual void Dump(CDumpContext& dc) const;
  210. #endif
  211. protected:
  212. // Generated message map functions
  213. protected:
  214. //{{AFX_MSG(CProjectRecord)
  215. // NOTE - the ClassWizard will add and remove member functions here.
  216. // DO NOT EDIT what you see in these blocks of generated code !
  217. //}}AFX_MSG
  218. DECLARE_MESSAGE_MAP()
  219. };
  220. /////////////////////////////////////////////////////////////////////////////
  221. // CGetDefCodePage dialog
  222. class CGetDefCodePage : public CDialog
  223. {
  224. // The next two variables are used to save the default code page number.
  225. // Two variables are used because the Far East code pages are built into
  226. // the MDT as resources so - in these cases - the Far East code pages'
  227. // resource number (actually negative resource number) is needed too.
  228. DWORD m_dwDefaultCodePage ; // Code page number / neg resource ID
  229. DWORD m_dwDefaultCodePageNum ;// Code page number
  230. // Construction
  231. public:
  232. CGetDefCodePage(CWnd* pParent = NULL); // standard constructor
  233. // Dialog Data
  234. //{{AFX_DATA(CGetDefCodePage)
  235. enum { IDD = IDD_UpgDefCPage };
  236. CListBox m_clbCodePages;
  237. //}}AFX_DATA
  238. // Overrides
  239. // ClassWizard generated virtual function overrides
  240. //{{AFX_VIRTUAL(CGetDefCodePage)
  241. protected:
  242. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  243. //}}AFX_VIRTUAL
  244. // Implementation
  245. public:
  246. // See variable declarations for more info about these functions.
  247. DWORD GetDefaultCodePage() { return m_dwDefaultCodePage ; }
  248. DWORD GetDefaultCodePageNum() { return m_dwDefaultCodePageNum ; }
  249. protected:
  250. // Generated message map functions
  251. //{{AFX_MSG(CGetDefCodePage)
  252. virtual BOOL OnInitDialog();
  253. virtual void OnOK();
  254. //}}AFX_MSG
  255. DECLARE_MESSAGE_MAP()
  256. };
  257. #endif // !defined(AFX_PROJREC_H__50303D0C_EKE1_11D2_AB62_00C04FA30E4A__INCLUDED_)