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.

434 lines
9.1 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. metaback.h
  5. Abstract:
  6. Metabase backup and restore dialog definitions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Sergei Antonov (sergeia)
  10. Project:
  11. Internet Services Manager
  12. Revision History:
  13. --*/
  14. #ifndef __METABACK_H__
  15. #define __METABACK_H__
  16. class CBackupFile : public CObjectPlus
  17. /*++
  18. Class Description:
  19. Backup location object
  20. Public Interface:
  21. CBackupFile : Constructor
  22. QueryVersion : Get the version number
  23. QueryLocation : Get the location name
  24. GetTime : Get the time
  25. --*/
  26. {
  27. //
  28. // Constructor
  29. //
  30. public:
  31. CBackupFile(
  32. IN LPCTSTR lpszLocation,
  33. IN DWORD dwVersion,
  34. IN FILETIME * pft
  35. );
  36. CBackupFile(
  37. IN LPCTSTR lpszLocation,
  38. IN DWORD dwMajorVersion,
  39. IN DWORD dwMinorVersion,
  40. IN FILETIME * pft
  41. );
  42. public:
  43. DWORD QueryVersion() const { return m_dwVersion; }
  44. DWORD QueryMajorVersion() const { return m_dwMajorVersion; }
  45. DWORD QueryMinorVersion() const { return m_dwMinorVersion; }
  46. LPCTSTR QueryLocation() const { return m_strLocation; }
  47. void GetTime(OUT CTime & tim);
  48. BOOL m_bIsAutomaticBackupType; // FALSE = manual backup, TRUE = Automatic backup
  49. CString m_csAuotmaticBackupText;
  50. //
  51. // Sorting helper
  52. //
  53. int OrderByDateTime(
  54. IN const CObjectPlus * pobAccess
  55. ) const;
  56. private:
  57. DWORD m_dwVersion;
  58. DWORD m_dwMajorVersion;
  59. DWORD m_dwMinorVersion;
  60. CString m_strLocation;
  61. FILETIME m_ft;
  62. };
  63. class CBackupsListBox : public CHeaderListBox
  64. /*++
  65. Class Description:
  66. A listbox of CBackupFile objects
  67. Public Interface:
  68. CBackupsListBox : Constructor
  69. GetItem : Get backup object at index
  70. AddItem : Add item to listbox
  71. InsertItem : Insert item into the listbox
  72. Initialize : Initialize the listbox
  73. --*/
  74. {
  75. DECLARE_DYNAMIC(CBackupsListBox);
  76. public:
  77. static const nBitmaps; // Number of bitmaps
  78. public:
  79. CBackupsListBox();
  80. public:
  81. CBackupFile * GetItem(UINT nIndex);
  82. CBackupFile * GetNextSelectedItem(int * pnStartingIndex);
  83. int AddItem(CBackupFile * pItem);
  84. int InsertItem(int nPos, CBackupFile * pItem);
  85. virtual BOOL Initialize();
  86. int CALLBACK CompareItems(LPARAM lp1, LPARAM lp2, LPARAM lpSortData);
  87. protected:
  88. virtual void DrawItemEx(CRMCListBoxDrawStruct & s);
  89. };
  90. class CBkupPropDlg : public CDialog
  91. /*++
  92. Class Description:
  93. Backup file properties dialog
  94. Public Interface:
  95. CBkupPropDlg : Constructor
  96. QueryName : Return the name of the backup file
  97. --*/
  98. {
  99. //
  100. // Construction
  101. //
  102. public:
  103. //
  104. // Standard Constructor
  105. //
  106. CBkupPropDlg(
  107. IN CIISMachine * pMachine,
  108. IN CWnd * pParent = NULL
  109. );
  110. //
  111. // Access
  112. //
  113. public:
  114. LPCTSTR QueryName() const { return m_strName; }
  115. //
  116. // Dialog Data
  117. //
  118. protected:
  119. //{{AFX_DATA(CBkupPropDlg)
  120. enum { IDD = IDD_BACKUP };
  121. CEdit m_edit_Name;
  122. CButton m_button_OK;
  123. CStrPassword m_strPassword;
  124. CEdit m_edit_Password;
  125. CStrPassword m_strPasswordConfirm;
  126. CEdit m_edit_PasswordConfirm;
  127. CButton m_button_Password;
  128. CString m_strName;
  129. //}}AFX_DATA
  130. //
  131. // Overrides
  132. //
  133. protected:
  134. //{{AFX_VIRTUAL(CBkupPropDlg)
  135. protected:
  136. virtual void DoDataExchange(CDataExchange * pDX);
  137. //}}AFX_VIRTUAL
  138. //
  139. // Implementation
  140. //
  141. protected:
  142. //{{AFX_MSG(CBkupPropDlg)
  143. afx_msg void OnChangeEditBackupName();
  144. afx_msg void OnChangeEditPassword();
  145. virtual BOOL OnInitDialog();
  146. virtual void OnOK();
  147. virtual void OnUsePassword();
  148. //}}AFX_MSG
  149. DECLARE_MESSAGE_MAP()
  150. private:
  151. CIISMachine * m_pMachine;
  152. };
  153. #define MIN_PASSWORD_LENGTH 1
  154. class CBackupPassword : public CDialog
  155. {
  156. public:
  157. CBackupPassword(CWnd * pParent);
  158. //{{AFX_DATA(CBackupPassword)
  159. enum { IDD = IDD_PASSWORD };
  160. CEdit m_edit;
  161. CButton m_button_OK;
  162. CStrPassword m_password;
  163. //}}AFX_DATA
  164. virtual void DoDataExchange(CDataExchange * pDX);
  165. protected:
  166. //{{AFX_MSG(CBackupPassword)
  167. afx_msg void OnChangedPassword();
  168. virtual BOOL OnInitDialog();
  169. //}}AFX_MSG
  170. DECLARE_MESSAGE_MAP()
  171. CString m_confirm_password;
  172. };
  173. class CBackupDlg : public CDialog
  174. /*++
  175. Class Description:
  176. Metabase backup/restore dialog
  177. Public Interface:
  178. CBackupDlg : Constructor
  179. HasChangedMetabase : TRUE if the metabase was changed
  180. --*/
  181. {
  182. //
  183. // Construction
  184. //
  185. public:
  186. //
  187. // Standard Constructor
  188. //
  189. CBackupDlg(
  190. IN CIISMachine * pMachine,
  191. IN LPCTSTR szMachineName,
  192. IN CWnd * pParent = NULL
  193. );
  194. //
  195. // Access
  196. //
  197. public:
  198. BOOL HasChangedMetabase() const { return m_fChangedMetabase; }
  199. BOOL ServicesWereRestarted() const { return m_fServicesRestarted;}
  200. //
  201. // Dialog Data
  202. //
  203. protected:
  204. //{{AFX_DATA(CBackupDlg)
  205. enum { IDD = IDD_METABACKREST };
  206. CButton m_button_Restore;
  207. CButton m_button_Delete;
  208. CButton m_button_Close;
  209. //}}AFX_DATA
  210. CBackupsListBox m_list_Backups;
  211. //
  212. // Overrides
  213. //
  214. protected:
  215. //{{AFX_VIRTUAL(CBackupDlg)
  216. protected:
  217. virtual void DoDataExchange(CDataExchange * pDX);
  218. //}}AFX_VIRTUAL
  219. //
  220. // Implementation
  221. //
  222. protected:
  223. //{{AFX_MSG(CBackupDlg)
  224. virtual BOOL OnInitDialog();
  225. afx_msg void OnButtonCreate();
  226. afx_msg void OnButtonDelete();
  227. afx_msg void OnButtonRestore();
  228. afx_msg void OnDblclkListBackups();
  229. afx_msg void OnSelchangeListBackups();
  230. //}}AFX_MSG
  231. DECLARE_MESSAGE_MAP()
  232. void SetControlStates();
  233. HRESULT EnumerateBackups(IN LPCTSTR lpszSelect = NULL);
  234. CBackupFile * GetSelectedListItem(OUT int * pnSel = NULL);
  235. private:
  236. BOOL m_fChangedMetabase;
  237. BOOL m_fServicesRestarted;
  238. CIISMachine * m_pMachine;
  239. CObListPlus m_oblBackups;
  240. CObListPlus m_oblAutoBackups;
  241. CRMCListBoxResources m_ListBoxRes;
  242. CString m_csMachineName;
  243. };
  244. //
  245. // Inline Expansion
  246. //
  247. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  248. inline CBackupFile::CBackupFile(
  249. IN LPCTSTR lpszLocation,
  250. IN DWORD dwVersion,
  251. IN FILETIME * pft
  252. )
  253. {
  254. CopyMemory(&m_ft, pft, sizeof(m_ft));
  255. m_strLocation = lpszLocation;
  256. m_bIsAutomaticBackupType = FALSE;
  257. m_dwVersion = dwVersion;
  258. m_dwMajorVersion = 0;
  259. m_dwMinorVersion = 0;
  260. }
  261. inline CBackupFile::CBackupFile(
  262. IN LPCTSTR lpszLocation,
  263. IN DWORD dwMajorVersion,
  264. IN DWORD dwMinorVersion,
  265. IN FILETIME * pft
  266. )
  267. {
  268. CopyMemory(&m_ft, pft, sizeof(m_ft));
  269. m_strLocation = lpszLocation;
  270. m_csAuotmaticBackupText.LoadString(IDS_AUTO_HISTORY_RESTORE_NAME);
  271. m_bIsAutomaticBackupType = TRUE;
  272. m_dwVersion = 0;
  273. m_dwMajorVersion = dwMajorVersion;
  274. m_dwMinorVersion = dwMinorVersion;
  275. }
  276. inline void CBackupFile::GetTime(CTime & tim)
  277. {
  278. tim = m_ft;
  279. }
  280. inline CBackupFile * CBackupsListBox::GetItem(UINT nIndex)
  281. {
  282. return (CBackupFile *)GetItemDataPtr(nIndex);
  283. }
  284. inline CBackupFile * CBackupsListBox::GetNextSelectedItem(int * pnStartingIndex)
  285. {
  286. return (CBackupFile *)CHeaderListBox::GetNextSelectedItem(pnStartingIndex);
  287. }
  288. inline int CBackupsListBox::AddItem(CBackupFile * pItem)
  289. {
  290. return AddString((LPCTSTR)pItem);
  291. }
  292. inline int CBackupsListBox::InsertItem(int nPos, CBackupFile * pItem)
  293. {
  294. return InsertString(nPos, (LPCTSTR)pItem);
  295. }
  296. inline CBackupFile * CBackupDlg::GetSelectedListItem(int * pnSel)
  297. {
  298. return (CBackupFile *)m_list_Backups.GetSelectedListItem(pnSel);
  299. }
  300. inline int CBackupFile::OrderByDateTime(
  301. IN const CObjectPlus * pobAccess
  302. ) const
  303. /*++
  304. Routine Description:
  305. Compare two ??? against each other, and sort
  306. Arguments:
  307. const CObjectPlus * pobAccess : This really refers to another
  308. CBackupFile to be compared to.
  309. Return Value:
  310. Sort (+1, 0, -1) return value
  311. --*/
  312. {
  313. CBackupFile * pob = (CBackupFile *) pobAccess;
  314. CTime tm1 = m_ft;
  315. SYSTEMTIME timeDest1;
  316. FILETIME fileTime1;
  317. ULARGE_INTEGER uliCurrentTime1;
  318. CTime tm2;
  319. SYSTEMTIME timeDest2;
  320. FILETIME fileTime2;
  321. ULARGE_INTEGER uliCurrentTime2;
  322. pob->GetTime(tm2);
  323. tm1.GetAsSystemTime(timeDest1);
  324. ::SystemTimeToFileTime(&timeDest1, &fileTime1);
  325. uliCurrentTime1.LowPart = fileTime1.dwLowDateTime;
  326. uliCurrentTime1.HighPart = fileTime1.dwHighDateTime;
  327. tm2.GetAsSystemTime(timeDest2);
  328. ::SystemTimeToFileTime(&timeDest2, &fileTime2);
  329. uliCurrentTime2.LowPart = fileTime2.dwLowDateTime;
  330. uliCurrentTime2.HighPart = fileTime2.dwHighDateTime;
  331. if (uliCurrentTime1.QuadPart > uliCurrentTime2.QuadPart)
  332. {
  333. return +1;
  334. }
  335. else
  336. {
  337. return -1;
  338. }
  339. }
  340. #endif // __METABACK_H__