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.

2078 lines
55 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. srvlatpp.cpp
  7. Brings up the property page for the server node
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "winssnap.h"
  12. #include "shlobj.h"
  13. #include "srvlatpp.h"
  14. #include "server.h"
  15. #include "service.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. #define MAX_HOURS 23
  22. #define MAX_MINUTES 59
  23. #define MAX_SECONDS 59
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CServerPropGeneral property page
  26. IMPLEMENT_DYNCREATE(CServerPropGeneral, CPropertyPageBase)
  27. CServerPropGeneral::CServerPropGeneral() : CPropertyPageBase(CServerPropGeneral::IDD)
  28. {
  29. //{{AFX_DATA_INIT(CServerPropGeneral)
  30. m_fBackupDB = FALSE;
  31. m_fEnableAutoRefresh = FALSE;
  32. m_strBackupPath = _T("");
  33. m_nRefreshHours = 0;
  34. m_nRefreshMinutes = 0;
  35. m_nRefreshSeconds = 0;
  36. //}}AFX_DATA_INIT
  37. m_fUpdateConfig = FALSE;
  38. }
  39. CServerPropGeneral::~CServerPropGeneral()
  40. {
  41. }
  42. void
  43. CServerPropGeneral::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CPropertyPageBase::DoDataExchange(pDX);
  46. //{{AFX_DATA_MAP(CServerPropGeneral)
  47. DDX_Control(pDX, IDC_EDIT_REFRESH_MINUTES2, m_editRefreshMn);
  48. DDX_Control(pDX, IDC_EDIT_REFRESH_HOURS2, m_editRefreshHr);
  49. DDX_Control(pDX, IDC_EDIT_REFRESH_SECONDS2, m_editRefreshSc);
  50. DDX_Control(pDX, IDC_SPIN_REFRESH_SECONDS2, m_spinRefreshSc);
  51. DDX_Control(pDX, IDC_SPIN_REFRESH_MINUTES2, m_spinRefreshmn);
  52. DDX_Control(pDX, IDC_SPIN_REFRESH_HOURS2, m_spinRefreshHr);
  53. DDX_Control(pDX, IDC_EDIT_BACKUPPATH, m_editBackupPath);
  54. DDX_Control(pDX, IDC_CHECK_BACKUPDB, m_check_BackupOnTermination);
  55. DDX_Control(pDX, IDC_CHECK_ENABLE_AUTOREFRESH, m_check_EnableAutoRefresh);
  56. DDX_Control(pDX, IDC_BUTTON_BROWSE, m_button_Browse);
  57. DDX_Check(pDX, IDC_CHECK_BACKUPDB, m_fBackupDB);
  58. DDX_Check(pDX, IDC_CHECK_ENABLE_AUTOREFRESH, m_fEnableAutoRefresh);
  59. DDX_Text(pDX, IDC_EDIT_BACKUPPATH, m_strBackupPath);
  60. DDX_Text(pDX, IDC_EDIT_REFRESH_HOURS2, m_nRefreshHours);
  61. DDV_MinMaxInt(pDX, m_nRefreshHours, 0, MAX_HOURS);
  62. DDX_Text(pDX, IDC_EDIT_REFRESH_MINUTES2, m_nRefreshMinutes);
  63. DDV_MinMaxInt(pDX, m_nRefreshMinutes, 0, MAX_MINUTES);
  64. DDX_Text(pDX, IDC_EDIT_REFRESH_SECONDS2, m_nRefreshSeconds);
  65. DDV_MinMaxInt(pDX, m_nRefreshSeconds, 0, MAX_SECONDS);
  66. //}}AFX_DATA_MAP
  67. }
  68. BEGIN_MESSAGE_MAP(CServerPropGeneral, CPropertyPageBase)
  69. //{{AFX_MSG_MAP(CServerPropGeneral)
  70. ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
  71. ON_BN_CLICKED(IDC_CHECK_ENABLE_AUTOREFRESH, OnCheckEnableAutorefresh)
  72. ON_EN_CHANGE(IDC_EDIT_BACKUPPATH, OnChangeEditBackuppath)
  73. ON_EN_CHANGE(IDC_EDIT_REFRESH_HOURS2, OnChangeRefresh)
  74. ON_EN_CHANGE(IDC_EDIT_REFRESH_MINUTES2, OnChangeRefresh)
  75. ON_EN_CHANGE(IDC_EDIT_REFRESH_SECONDS2, OnChangeRefresh)
  76. ON_BN_CLICKED(IDC_CHECK_BACKUPDB, OnChangeCheckBackupdb)
  77. //}}AFX_MSG_MAP
  78. END_MESSAGE_MAP()
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CServerPropGeneral message handlers
  81. BOOL
  82. CServerPropGeneral::OnApply()
  83. {
  84. HRESULT hr = UpdateServerConfiguration();
  85. if (FAILED(hr))
  86. {
  87. return FALSE;
  88. }
  89. else
  90. {
  91. m_fUpdateConfig = FALSE;
  92. return CPropertyPageBase::OnApply();
  93. }
  94. }
  95. void
  96. CServerPropGeneral::OnOK()
  97. {
  98. HRESULT hr = UpdateServerConfiguration();
  99. if (SUCCEEDED(hr))
  100. {
  101. CPropertyPageBase::OnOK();
  102. }
  103. }
  104. BOOL
  105. CServerPropGeneral::OnInitDialog()
  106. {
  107. CPropertyPageBase::OnInitDialog();
  108. GetConfig();
  109. m_fBackupDB = m_pConfig->m_fBackupOnTermination;
  110. // get the server
  111. SPITFSNode spNode;
  112. CWinsServerHandler *pServer;
  113. spNode = GetHolder()->GetNode();
  114. pServer = GETHANDLER(CWinsServerHandler, spNode);
  115. SetRefreshData();
  116. if (pServer->m_dwFlags & FLAG_AUTO_REFRESH)
  117. {
  118. m_fEnableAutoRefresh = TRUE;
  119. m_check_EnableAutoRefresh.SetCheck(1);
  120. }
  121. else
  122. {
  123. m_fEnableAutoRefresh = FALSE;
  124. m_check_EnableAutoRefresh.SetCheck(0);
  125. // diable the controls
  126. m_spinRefreshHr.EnableWindow(FALSE);
  127. m_spinRefreshmn.EnableWindow(FALSE);
  128. m_spinRefreshSc.EnableWindow(FALSE);
  129. m_editRefreshHr.EnableWindow(FALSE);
  130. m_editRefreshMn.EnableWindow(FALSE);
  131. m_editRefreshSc.EnableWindow(FALSE);
  132. }
  133. m_spinRefreshHr.SetRange(0, 23);
  134. m_spinRefreshmn.SetRange(0, 59);
  135. m_spinRefreshSc.SetRange(0, 59);
  136. // browse only available on local machine
  137. m_button_Browse.EnableWindow(IsLocalConnection());
  138. m_check_BackupOnTermination.SetCheck(m_pConfig->m_fBackupOnTermination);
  139. m_editBackupPath.SetWindowText(m_pConfig->m_strBackupPath);
  140. // load the correct icon
  141. for (int i = 0; i < ICON_IDX_MAX; i++)
  142. {
  143. if (g_uIconMap[i][1] == m_uImage)
  144. {
  145. HICON hIcon = LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(g_uIconMap[i][0]));
  146. if (hIcon)
  147. ((CStatic *) GetDlgItem(IDC_STATIC_ICON))->SetIcon(hIcon);
  148. break;
  149. }
  150. }
  151. m_fUpdateConfig = FALSE;
  152. SetDirty(FALSE);
  153. return TRUE;
  154. }
  155. void CServerPropGeneral::OnChangeEditBackuppath()
  156. {
  157. m_fUpdateConfig = TRUE;
  158. SetDirty(TRUE);
  159. }
  160. void CServerPropGeneral::OnChangeRefresh()
  161. {
  162. SetDirty(TRUE);
  163. }
  164. void CServerPropGeneral::OnChangeCheckBackupdb()
  165. {
  166. m_fUpdateConfig = TRUE;
  167. SetDirty(TRUE);
  168. }
  169. /*---------------------------------------------------------------------------
  170. CServerPropGeneral::IsLocalConnection()
  171. Checks if the local machine is being monitored
  172. ---------------------------------------------------------------------------*/
  173. BOOL
  174. CServerPropGeneral::IsLocalConnection()
  175. {
  176. // get the server
  177. SPITFSNode spNode;
  178. CWinsServerHandler *pServer;
  179. spNode = GetHolder()->GetNode();
  180. pServer = GETHANDLER(CWinsServerHandler, spNode);
  181. return pServer->IsLocalConnection();
  182. }
  183. void
  184. CServerPropGeneral::OnButtonBrowse()
  185. {
  186. TCHAR szBuffer[MAX_PATH];
  187. LPITEMIDLIST pidlPrograms = NULL; //CSIDL_DRIVES
  188. SHGetSpecialFolderLocation(m_hWnd, CSIDL_DRIVES, &pidlPrograms);
  189. BROWSEINFO browseInfo;
  190. browseInfo.hwndOwner = m_hWnd;
  191. browseInfo.pidlRoot = pidlPrograms;
  192. browseInfo.pszDisplayName = szBuffer;
  193. CString strSel;
  194. strSel.LoadString(IDS_SELECT_FOLDER);
  195. browseInfo.lpszTitle = strSel;
  196. browseInfo.ulFlags = BIF_NEWDIALOGSTYLE | BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS ;
  197. browseInfo.lpfn = NULL;
  198. browseInfo.lParam = 0;
  199. LPITEMIDLIST pidlBrowse = SHBrowseForFolder(&browseInfo);
  200. if (pidlBrowse)
  201. {
  202. SHGetPathFromIDList(pidlBrowse, szBuffer);
  203. CString strBackupPath(szBuffer);
  204. // check if it's a network drive, if yes, don't allow.
  205. /* int nPos = strBackupPath.Find(_T("\\"));
  206. if (nPos != -1)
  207. {
  208. CString strDrive = strBackupPath.Left(nPos);
  209. UINT uType = GetDriveType(strDrive);
  210. if(uType == DRIVE_REMOTE)
  211. {
  212. // tell the user that the files ccanot be backed up the location chosen
  213. CString strBackup;
  214. AfxFormatString1(strBackup, IDS_BACKUP_LOCATION, strBackupPath);
  215. AfxMessageBox(strBackup, MB_OK | MB_ICONINFORMATION);
  216. return;
  217. }
  218. }
  219. */
  220. if (!strBackupPath.IsEmpty())
  221. m_editBackupPath.SetWindowText(strBackupPath);
  222. }
  223. }
  224. /*---------------------------------------------------------------------------
  225. CServerPropGeneral::UpdateServerConfiguration()
  226. Updates the variables in the Server Handler
  227. ---------------------------------------------------------------------------*/
  228. HRESULT
  229. CServerPropGeneral::UpdateServerConfiguration()
  230. {
  231. UpdateData();
  232. // Reflect the changes in the server's CConfiguration object
  233. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  234. // get the server
  235. SPITFSNode spNode;
  236. CWinsServerHandler *pServer;
  237. spNode = GetHolder()->GetNode();
  238. pServer = GETHANDLER(CWinsServerHandler, spNode);
  239. // update config displays any necessary error dialogs
  240. if (!UpdateConfig())
  241. return E_FAIL;
  242. DWORD err = ERROR_SUCCESS;
  243. // now write to server
  244. if (m_fUpdateConfig)
  245. {
  246. err = m_pConfig->Store();
  247. if (err != ERROR_SUCCESS)
  248. {
  249. // something bad happened
  250. WinsMessageBox(err);
  251. }
  252. else
  253. {
  254. // success update our local copy
  255. pServer->SetConfig(*m_pConfig);
  256. }
  257. }
  258. return HRESULT_FROM_WIN32(err);
  259. }
  260. /*---------------------------------------------------------------------------
  261. CServerPropGeneral::UpdateConfig()
  262. Updates the Config object in the server handler
  263. ---------------------------------------------------------------------------*/
  264. BOOL
  265. CServerPropGeneral::UpdateConfig()
  266. {
  267. // get the server
  268. SPITFSNode spNode;
  269. CWinsServerHandler *pServer;
  270. spNode = GetHolder()->GetNode();
  271. pServer = GETHANDLER(CWinsServerHandler, spNode);
  272. CString strTemp;
  273. m_editBackupPath.GetWindowText(strTemp);
  274. // backup path needs to be non-null when backup on termination is set
  275. if (m_fBackupDB && strTemp.IsEmpty())
  276. {
  277. CThemeContextActivator themeActivator;
  278. AfxMessageBox(IDS_SPECIFY_DEFAULT_BACKUP_PATH);
  279. return FALSE;
  280. }
  281. if (m_fUpdateConfig)
  282. {
  283. m_pConfig->m_strBackupPath = strTemp;
  284. m_pConfig->m_fBackupOnTermination = m_fBackupDB;
  285. }
  286. pServer->m_dwRefreshInterval = CalculateRefrInt();
  287. if (m_fEnableAutoRefresh)
  288. {
  289. pServer->m_dwFlags |= FLAG_AUTO_REFRESH;
  290. }
  291. else
  292. {
  293. pServer->m_dwFlags &= ~FLAG_AUTO_REFRESH;
  294. }
  295. // since these settins are stored in the console file, mark it as dirty
  296. SPITFSNode spRootNode;
  297. spNode->GetParent(&spRootNode);
  298. spRootNode->SetData(TFS_DATA_DIRTY, TRUE);
  299. return TRUE;
  300. }
  301. /*---------------------------------------------------------------------------
  302. CServerPropGeneral::CalculateRefrInt()
  303. Rteurns the refresh interval in seconds
  304. ---------------------------------------------------------------------------*/
  305. int
  306. CServerPropGeneral::CalculateRefrInt()
  307. {
  308. UpdateData();
  309. CString strValue;
  310. // get the server
  311. SPITFSNode spNode;
  312. CWinsServerHandler *pServer;
  313. spNode = GetHolder()->GetNode();
  314. pServer = GETHANDLER(CWinsServerHandler, spNode);
  315. int nHour = m_spinRefreshHr.GetPos();
  316. int nMinute = m_spinRefreshmn.GetPos();
  317. int nSecond = m_spinRefreshSc.GetPos();
  318. int nRenewInterval = nHour * SEC_PER_HOUR +
  319. nMinute * SEC_PER_MINUTE +
  320. nSecond;
  321. pServer->m_dwRefreshInterval = nRenewInterval;
  322. pServer->m_dlgStats.ReInitRefresherThread();
  323. return nRenewInterval;
  324. }
  325. /*---------------------------------------------------------------------------
  326. CServerPropGeneral::ToString(int nNumber)
  327. Returns string value of an integer
  328. ---------------------------------------------------------------------------*/
  329. CString
  330. CServerPropGeneral::ToString(int nNumber)
  331. {
  332. TCHAR szStr[20];
  333. _itot(nNumber, szStr, 10);
  334. CString str(szStr);
  335. return str;
  336. }
  337. /*---------------------------------------------------------------------------
  338. CServerPropGeneral::SetRefreshData()
  339. Sets the variables' dtata for the refresh group.
  340. ---------------------------------------------------------------------------*/
  341. void
  342. CServerPropGeneral::SetRefreshData()
  343. {
  344. // get the server
  345. SPITFSNode spNode;
  346. CWinsServerHandler *pServer;
  347. spNode = GetHolder()->GetNode();
  348. pServer = GETHANDLER(CWinsServerHandler, spNode);
  349. DWORD dwInterval = pServer->m_dwRefreshInterval;
  350. m_spinRefreshmn.SetRange(0, MAX_MINUTES);
  351. m_spinRefreshSc.SetRange(0, MAX_SECONDS);
  352. m_spinRefreshHr.SetRange(0, UD_MAXVAL);
  353. int nHours, nMinutes, nSeconds;
  354. nHours = dwInterval / SEC_PER_HOUR;
  355. dwInterval -= nHours * SEC_PER_HOUR;
  356. nMinutes = dwInterval / SEC_PER_MINUTE;
  357. dwInterval -= nMinutes * SEC_PER_MINUTE;
  358. nSeconds = dwInterval ;
  359. // convert them to strings
  360. CString strHr = ToString(nHours);
  361. CString strMn = ToString(nMinutes);
  362. CString strSc = ToString(nSeconds);
  363. m_spinRefreshHr.SetPos(nHours);
  364. m_spinRefreshmn.SetPos(nMinutes);
  365. m_spinRefreshSc.SetPos(nSeconds);
  366. }
  367. /*---------------------------------------------------------------------------
  368. CServerPropGeneral::GetConfig()
  369. Gets the Configuration object from the server
  370. ---------------------------------------------------------------------------*/
  371. HRESULT
  372. CServerPropGeneral::GetConfig()
  373. {
  374. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  375. HRESULT hr = hrOK;
  376. m_pConfig = ((CServerProperties *) GetHolder())->GetConfig();
  377. return hr;
  378. }
  379. void CServerPropGeneral::OnCheckEnableAutorefresh()
  380. {
  381. SetDirty(TRUE);
  382. UpdateData();
  383. if (m_check_EnableAutoRefresh.GetCheck() == 1)
  384. {
  385. m_fEnableAutoRefresh = TRUE;
  386. m_spinRefreshHr.EnableWindow(TRUE);
  387. m_spinRefreshmn.EnableWindow(TRUE);
  388. m_spinRefreshSc.EnableWindow(TRUE);
  389. m_editRefreshHr.EnableWindow(TRUE);
  390. m_editRefreshMn.EnableWindow(TRUE);
  391. m_editRefreshSc.EnableWindow(TRUE);
  392. }
  393. else
  394. {
  395. m_fEnableAutoRefresh = FALSE;
  396. m_spinRefreshHr.EnableWindow(FALSE);
  397. m_spinRefreshmn.EnableWindow(FALSE);
  398. m_spinRefreshSc.EnableWindow(FALSE);
  399. m_editRefreshHr.EnableWindow(FALSE);
  400. m_editRefreshMn.EnableWindow(FALSE);
  401. m_editRefreshSc.EnableWindow(FALSE);
  402. }
  403. // mark the snap-in as dirty, so as to prompt the user
  404. // mark the snap-in as dirty
  405. SPITFSNode spNode ;
  406. spNode = GetHolder()->GetNode();
  407. SPITFSNodeMgr spNodeManager;
  408. SPITFSNode spRootNode;
  409. spNode->GetNodeMgr(&spNodeManager);
  410. spNodeManager->GetRootNode(&spRootNode);
  411. // mark the data as dirty so that we'll ask the user to save.
  412. spRootNode->SetData(TFS_DATA_DIRTY, TRUE);
  413. }
  414. /////////////////////////////////////////////////////////////////////////////
  415. // CServerPropDBRecord property page
  416. IMPLEMENT_DYNCREATE(CServerPropDBRecord, CPropertyPageBase)
  417. CServerPropDBRecord::CServerPropDBRecord() : CPropertyPageBase(CServerPropDBRecord::IDD)
  418. {
  419. //{{AFX_DATA_INIT(CServerPropDBRecord)
  420. m_nExtintDay = 0;
  421. m_nExtIntHour = 0;
  422. m_nExtIntMinute = 0;
  423. m_nExtTmDay = 0;
  424. m_nExtTmHour = 0;
  425. m_nExtTmMinute = 0;
  426. m_nRenewDay = 0;
  427. m_nrenewMinute = 0;
  428. m_nRenewMinute = 0;
  429. m_nVerifyDay = 0;
  430. m_nVerifyHour = 0;
  431. m_nVerifyMinute = 0;
  432. //}}AFX_DATA_INIT
  433. }
  434. CServerPropDBRecord::~CServerPropDBRecord()
  435. {
  436. }
  437. void CServerPropDBRecord::DoDataExchange(CDataExchange* pDX)
  438. {
  439. CPropertyPageBase::DoDataExchange(pDX);
  440. //{{AFX_DATA_MAP(CServerPropDBRecord)
  441. DDX_Control(pDX, IDC_EDIT_EXTINCT_INT_MINUTE, m_editExtIntMinute);
  442. DDX_Control(pDX, IDC_SPIN_VERIFY_INT_MINUTE, m_spinVerifyMinute);
  443. DDX_Control(pDX, IDC_SPIN_VERIFY_INT_HOUR, m_spinVerifyHour);
  444. DDX_Control(pDX, IDC_SPIN_VERIFY_INT_DAY, m_spinVerifyDay);
  445. DDX_Control(pDX, IDC_SPIN_RENEW_INT_MINUTE, m_spinRefrIntMinute);
  446. DDX_Control(pDX, IDC_SPIN_RENEW_INT_HOUR, m_spinRefrIntHour);
  447. DDX_Control(pDX, IDC_SPIN_RENEW_INT_DAY, m_spinRefrIntDay);
  448. DDX_Control(pDX, IDC_SPIN_EXTINCT_TM_MINUTE, m_spinExtTmMinute);
  449. DDX_Control(pDX, IDC_SPIN_EXTINCT_TM_HOUR, m_spinExtTmHour);
  450. DDX_Control(pDX, IDC_SPIN_EXTINCT_TM_DAY, m_spinExtTmDay);
  451. DDX_Control(pDX, IDC_SPIN_EXTINCT_INT_MINUTE, m_spinExtIntMinute);
  452. DDX_Control(pDX, IDC_SPIN_EXTINCT_INT_HOUR, m_spinExtIntHour);
  453. DDX_Control(pDX, IDC_SPIN_EXTINCT_INT_DAY, m_spinExtIntDay);
  454. DDX_Control(pDX, IDC_EDIT_VERIFY_MINUTE, m_editVerifyMinute);
  455. DDX_Control(pDX, IDC_EDIT_VERIFY_HOUR, m_editVerifyHour);
  456. DDX_Control(pDX, IDC_EDIT_VERIFY_DAY, m_editVerifyDay);
  457. DDX_Control(pDX, IDC_EDIT_RENEW_MINUTE, m_editRefrIntMinute);
  458. DDX_Control(pDX, IDC_EDIT_RENEW_HOUR, m_editRefrIntHour);
  459. DDX_Control(pDX, IDC_EDIT_RENEW_DAY, m_editRefrIntDay);
  460. DDX_Control(pDX, IDC_EDIT_EXTINCT_TIMEOUT_HOUR, m_editExtTmHour);
  461. DDX_Control(pDX, IDC_EDIT_EXTINCT_TIMEOUT_MINUTE, m_editExtTmMinute);
  462. DDX_Control(pDX, IDC_EDIT_EXTINCT_TIMEOUT_DAY, m_editExtTmDay);
  463. DDX_Control(pDX, IDC_EDIT_EXTINCT_INT_HOUR, m_editExtIntHour);
  464. DDX_Control(pDX, IDC_EDIT_EXTINCT_INT_DAY, m_editExtIntDay);
  465. DDX_Text(pDX, IDC_EDIT_EXTINCT_INT_DAY, m_nExtintDay);
  466. DDV_MinMaxInt(pDX, m_nExtintDay, 0, 365);
  467. DDX_Text(pDX, IDC_EDIT_EXTINCT_INT_HOUR, m_nExtIntHour);
  468. DDV_MinMaxInt(pDX, m_nExtIntHour, 0, MAX_HOURS);
  469. DDX_Text(pDX, IDC_EDIT_EXTINCT_INT_MINUTE, m_nExtIntMinute);
  470. DDV_MinMaxInt(pDX, m_nExtIntMinute, 0, MAX_MINUTES);
  471. DDX_Text(pDX, IDC_EDIT_EXTINCT_TIMEOUT_DAY, m_nExtTmDay);
  472. DDV_MinMaxInt(pDX, m_nExtTmDay, 0, 365);
  473. DDX_Text(pDX, IDC_EDIT_EXTINCT_TIMEOUT_HOUR, m_nExtTmHour);
  474. DDV_MinMaxInt(pDX, m_nExtTmHour, 0, MAX_HOURS);
  475. DDX_Text(pDX, IDC_EDIT_EXTINCT_TIMEOUT_MINUTE, m_nExtTmMinute);
  476. DDV_MinMaxInt(pDX, m_nExtTmMinute, 0, MAX_MINUTES);
  477. DDX_Text(pDX, IDC_EDIT_RENEW_DAY, m_nRenewDay);
  478. DDV_MinMaxInt(pDX, m_nRenewDay, 0, 365);
  479. DDX_Text(pDX, IDC_EDIT_RENEW_HOUR, m_nrenewMinute);
  480. DDV_MinMaxInt(pDX, m_nrenewMinute, 0, MAX_HOURS);
  481. DDX_Text(pDX, IDC_EDIT_RENEW_MINUTE, m_nRenewMinute);
  482. DDV_MinMaxInt(pDX, m_nRenewMinute, 0, MAX_MINUTES);
  483. DDX_Text(pDX, IDC_EDIT_VERIFY_DAY, m_nVerifyDay);
  484. DDV_MinMaxInt(pDX, m_nVerifyDay, 0, 365);
  485. DDX_Text(pDX, IDC_EDIT_VERIFY_HOUR, m_nVerifyHour);
  486. DDV_MinMaxInt(pDX, m_nVerifyHour, 0, MAX_HOURS);
  487. DDX_Text(pDX, IDC_EDIT_VERIFY_MINUTE, m_nVerifyMinute);
  488. DDV_MinMaxInt(pDX, m_nVerifyMinute, 0, MAX_MINUTES);
  489. //}}AFX_DATA_MAP
  490. }
  491. BEGIN_MESSAGE_MAP(CServerPropDBRecord, CPropertyPageBase)
  492. //{{AFX_MSG_MAP(CServerPropDBRecord)
  493. ON_BN_CLICKED(IDC_BUTTON_SET_DEFAULT, OnButtonSetDefault)
  494. ON_EN_CHANGE(IDC_EDIT_EXTINCT_INT_DAY, OnChangeEditExtinctIntHour)
  495. ON_EN_CHANGE(IDC_EDIT_EXTINCT_INT_HOUR, OnChangeEditExtinctIntHour)
  496. ON_EN_CHANGE(IDC_EDIT_EXTINCT_INT_MINUTE, OnChangeEditExtinctIntHour)
  497. ON_EN_CHANGE(IDC_EDIT_EXTINCT_TIMEOUT_DAY, OnChangeEditExtinctIntHour)
  498. ON_EN_CHANGE(IDC_EDIT_EXTINCT_TIMEOUT_HOUR, OnChangeEditExtinctIntHour)
  499. ON_EN_CHANGE(IDC_EDIT_EXTINCT_TIMEOUT_MINUTE, OnChangeEditExtinctIntHour)
  500. ON_EN_CHANGE(IDC_EDIT_RENEW_DAY, OnChangeEditExtinctIntHour)
  501. ON_EN_CHANGE(IDC_EDIT_RENEW_HOUR, OnChangeEditExtinctIntHour)
  502. ON_EN_CHANGE(IDC_EDIT_RENEW_MINUTE, OnChangeEditExtinctIntHour)
  503. ON_EN_CHANGE(IDC_EDIT_VERIFY_DAY, OnChangeEditExtinctIntHour)
  504. ON_EN_CHANGE(IDC_EDIT_VERIFY_HOUR, OnChangeEditExtinctIntHour)
  505. ON_EN_CHANGE(IDC_EDIT_VERIFY_MINUTE, OnChangeEditExtinctIntHour)
  506. //}}AFX_MSG_MAP
  507. END_MESSAGE_MAP()
  508. /////////////////////////////////////////////////////////////////////////////
  509. // CServerPropDBRecord message handlers
  510. BOOL
  511. CServerPropDBRecord::OnInitDialog()
  512. {
  513. CPropertyPageBase::OnInitDialog();
  514. // get the server
  515. SPITFSNode spNode;
  516. CWinsServerHandler *pServer;
  517. spNode = GetHolder()->GetNode();
  518. pServer = GETHANDLER(CWinsServerHandler, spNode);
  519. // get the interval stuff from the server and display in the spinner controlss
  520. HRESULT hr = GetConfig();
  521. DWORD m_dwRefreshInterval = m_pConfig->m_dwRefreshInterval;
  522. m_spinRefrIntHour.SetRange(0, MAX_HOURS);
  523. m_spinRefrIntMinute.SetRange(0, MAX_MINUTES);
  524. m_spinRefrIntDay.SetRange(0, UD_MAXVAL);
  525. int nDays = 0, nHours = 0, nMinutes = 0;
  526. nDays = m_dwRefreshInterval /86400;// SEC_PER_DAY;
  527. m_dwRefreshInterval -= (nDays * SEC_PER_DAY);
  528. if (m_dwRefreshInterval)
  529. {
  530. nHours = m_dwRefreshInterval / SEC_PER_HOUR;
  531. m_dwRefreshInterval -= (nHours * SEC_PER_HOUR);
  532. if(m_dwRefreshInterval)
  533. {
  534. nMinutes = m_dwRefreshInterval / SEC_PER_MINUTE;
  535. m_dwRefreshInterval -= (nMinutes * SEC_PER_MINUTE);
  536. }
  537. }
  538. m_spinRefrIntDay.SetPos(nDays);
  539. m_spinRefrIntHour.SetPos(nHours);
  540. m_spinRefrIntMinute.SetPos(nMinutes);
  541. SetVerifyData();
  542. SetExtTimeData();
  543. SetExtIntData();
  544. SetDirty(FALSE);
  545. return TRUE;
  546. }
  547. BOOL
  548. CServerPropDBRecord::OnApply()
  549. {
  550. if (!CheckValues())
  551. {
  552. return FALSE;
  553. }
  554. HRESULT hr = UpdateServerConfiguration();
  555. if (FAILED(hr))
  556. {
  557. return FALSE;
  558. }
  559. else
  560. {
  561. return CPropertyPageBase::OnApply();
  562. }
  563. }
  564. void
  565. CServerPropDBRecord::OnOK()
  566. {
  567. HRESULT hr = UpdateServerConfiguration();
  568. if (FAILED(hr))
  569. {
  570. return;
  571. }
  572. else
  573. {
  574. CPropertyPageBase::OnOK();
  575. }
  576. }
  577. /*---------------------------------------------------------------------------
  578. CServerPropDBRecord::CalculateRenewInt()
  579. Returns the Renew interval in seconds
  580. ---------------------------------------------------------------------------*/
  581. DWORD
  582. CServerPropDBRecord::CalculateRenewInt()
  583. {
  584. UpdateData();
  585. int nDay = m_spinRefrIntDay.GetPos();
  586. int nHour = m_spinRefrIntHour.GetPos();
  587. int nMinute = m_spinRefrIntMinute.GetPos();
  588. int nRenewInterval = nDay * SEC_PER_DAY +
  589. nHour * SEC_PER_HOUR +
  590. nMinute * SEC_PER_MINUTE;
  591. return nRenewInterval;
  592. }
  593. /*---------------------------------------------------------------------------
  594. CServerPropDBRecord::CalculateExtInt()
  595. Returns the Extinction interval in seconds
  596. ---------------------------------------------------------------------------*/
  597. DWORD
  598. CServerPropDBRecord::CalculateExtInt()
  599. {
  600. UpdateData();
  601. int nDay = m_spinExtIntDay.GetPos();
  602. int nHour = m_spinExtIntHour.GetPos();
  603. int nMinute = m_spinExtIntMinute.GetPos();
  604. int nExtInterval = nDay * SEC_PER_DAY +
  605. nHour * SEC_PER_HOUR +
  606. nMinute * SEC_PER_MINUTE;
  607. return nExtInterval;
  608. }
  609. /*---------------------------------------------------------------------------
  610. CServerPropDBRecord::CalculateExtTm()
  611. Returns the Extinction timeout interval in seconds
  612. ---------------------------------------------------------------------------*/
  613. DWORD
  614. CServerPropDBRecord::CalculateExtTm()
  615. {
  616. UpdateData();
  617. int nDay = m_spinExtTmDay.GetPos();
  618. int nHour = m_spinExtTmHour.GetPos();
  619. int nMinute = m_spinExtTmMinute.GetPos();
  620. int nExtTm = nDay * SEC_PER_DAY +
  621. nHour * SEC_PER_HOUR +
  622. nMinute * SEC_PER_MINUTE;
  623. return nExtTm;
  624. }
  625. /*----------------------------------------------------------------------------
  626. CServerPropDBRecord::CalculateVerifyInt()
  627. Returns the Verify interval in seconds
  628. ---------------------------------------------------------------------------*/
  629. DWORD
  630. CServerPropDBRecord::CalculateVerifyInt()
  631. {
  632. UpdateData();
  633. int nDay = m_spinVerifyDay.GetPos();
  634. int nHour = m_spinVerifyHour.GetPos();
  635. int nMinute = m_spinVerifyMinute.GetPos();
  636. int nVerifyInt = nDay * SEC_PER_DAY +
  637. nHour * SEC_PER_HOUR +
  638. nMinute * SEC_PER_MINUTE;
  639. return nVerifyInt;
  640. }
  641. /*---------------------------------------------------------------------------
  642. CServerPropDBRecord::UpdateServerConfiguration()
  643. Updates the server handler variables
  644. ---------------------------------------------------------------------------*/
  645. HRESULT
  646. CServerPropDBRecord::UpdateServerConfiguration()
  647. {
  648. UpdateData();
  649. // Reflect the changes in the server's CConfiguration object
  650. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  651. // get the server
  652. SPITFSNode spNode;
  653. CWinsServerHandler *pServer;
  654. spNode = GetHolder()->GetNode();
  655. pServer = GETHANDLER(CWinsServerHandler, spNode);
  656. m_pConfig->m_dwRefreshInterval = CalculateRenewInt();
  657. m_pConfig->m_dwTombstoneInterval = CalculateExtInt();
  658. m_pConfig->m_dwTombstoneTimeout = CalculateExtTm();
  659. m_pConfig->m_dwVerifyInterval = CalculateVerifyInt();
  660. // now write to server
  661. DWORD err = m_pConfig->Store();
  662. if (err != ERROR_SUCCESS)
  663. {
  664. // something bad happened
  665. WinsMessageBox(err);
  666. }
  667. else
  668. {
  669. // success update our local copy
  670. pServer->SetConfig(*m_pConfig);
  671. }
  672. return HRESULT_FROM_WIN32(err);
  673. }
  674. void
  675. CServerPropDBRecord::OnButtonSetDefault()
  676. {
  677. SetDefaultRenewInt();
  678. SetDefaultExtInt();
  679. SetDefaultExtTm();
  680. SetDefaultVerifyInt();
  681. }
  682. //
  683. // note, these defaults come from winscnf.c in the wins server code.
  684. // if that code changes, these function will need to change as well.
  685. //
  686. /*---------------------------------------------------------------------------
  687. CServerPropDBRecord::SetDefaultRenewInt()
  688. Sets the defalut values for the Renew interval
  689. ---------------------------------------------------------------------------*/
  690. void
  691. CServerPropDBRecord::SetDefaultRenewInt()
  692. {
  693. int nValue = WINSCNF_DEF_REFRESH_INTERVAL;
  694. int nDays = 0, nHours = 0, nMinutes = 0;
  695. CalcDaysHoursMinutes(nValue, nDays, nHours, nMinutes);
  696. m_spinRefrIntDay.SetPos(nDays);
  697. m_spinRefrIntHour.SetPos(nHours);
  698. m_spinRefrIntMinute.SetPos(nMinutes);
  699. }
  700. /*---------------------------------------------------------------------------
  701. CServerPropDBRecord::SetDefaultExtInt()
  702. Sets the defalut values for the Extinction interval
  703. ---------------------------------------------------------------------------*/
  704. void
  705. CServerPropDBRecord::SetDefaultExtInt()
  706. {
  707. int nValue = WINSCNF_MAKE_TOMB_INTVL_M(WINSCNF_DEF_REFRESH_INTERVAL, 0);
  708. int nDays = 0, nHours = 0, nMinutes = 0;
  709. CalcDaysHoursMinutes(nValue, nDays, nHours, nMinutes);
  710. m_spinExtIntDay.SetPos(nDays);
  711. m_spinExtIntHour.SetPos(nHours);
  712. m_spinExtIntMinute.SetPos(nMinutes);
  713. }
  714. /*---------------------------------------------------------------------------
  715. CServerPropDBRecord::SetDefaultExtTm()
  716. Sets the defalut values for the Extinction timeout interval
  717. ---------------------------------------------------------------------------*/
  718. void
  719. CServerPropDBRecord::SetDefaultExtTm()
  720. {
  721. int nValue = WINSCNF_DEF_REFRESH_INTERVAL;
  722. int nDays = 0, nHours = 0, nMinutes = 0;
  723. CalcDaysHoursMinutes(nValue, nDays, nHours, nMinutes);
  724. m_spinExtTmDay.SetPos(nDays);
  725. m_spinExtTmHour.SetPos(nHours);
  726. m_spinExtTmMinute.SetPos(nMinutes);
  727. }
  728. /*---------------------------------------------------------------------------
  729. CServerPropDBRecord::SetDefaultExtTm()
  730. Sets the defalut values for the verify interval
  731. ---------------------------------------------------------------------------*/
  732. void
  733. CServerPropDBRecord::SetDefaultVerifyInt()
  734. {
  735. int nValue = WINSCNF_MAKE_VERIFY_INTVL_M(WINSCNF_MAKE_TOMB_INTVL_M(WINSCNF_DEF_REFRESH_INTERVAL, 0));
  736. int nDays = 0, nHours = 0, nMinutes = 0;
  737. CalcDaysHoursMinutes(nValue, nDays, nHours, nMinutes);
  738. m_spinVerifyDay.SetPos(nDays);
  739. m_spinVerifyHour.SetPos(nHours);
  740. m_spinVerifyMinute.SetPos(nMinutes);
  741. }
  742. void
  743. CServerPropDBRecord::CalcDaysHoursMinutes(int nValue, int & nDays, int & nHours, int & nMinutes)
  744. {
  745. nDays = 0;
  746. nHours = 0;
  747. nMinutes = 0;
  748. nDays = nValue / SEC_PER_DAY; // 86400;
  749. nValue -= (nDays * SEC_PER_DAY);
  750. if (nValue)
  751. {
  752. nHours = nValue / SEC_PER_HOUR;
  753. nValue -= (nHours * SEC_PER_HOUR);
  754. if (nValue)
  755. {
  756. nMinutes = nValue / SEC_PER_MINUTE;
  757. nValue -= (nMinutes * SEC_PER_MINUTE);
  758. }
  759. }
  760. }
  761. /*---------------------------------------------------------------------------
  762. CServerPropDBRecord::GetConfig()
  763. Updates the configuration object from the server handler
  764. ---------------------------------------------------------------------------*/
  765. HRESULT
  766. CServerPropDBRecord::GetConfig()
  767. {
  768. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  769. HRESULT hr = hrOK;
  770. m_pConfig = ((CServerProperties *) GetHolder())->GetConfig();
  771. return hr;
  772. }
  773. /*---------------------------------------------------------------------------
  774. CServerPropDBRecord::SetVerifyData()
  775. Sets the controls' data for verify interval
  776. ---------------------------------------------------------------------------*/
  777. void
  778. CServerPropDBRecord::SetVerifyData()
  779. {
  780. DWORD dwInterval = m_pConfig->m_dwVerifyInterval;
  781. m_spinVerifyHour.SetRange(0, MAX_HOURS);
  782. m_spinVerifyMinute.SetRange(0, MAX_MINUTES);
  783. m_spinVerifyDay.SetRange(0, UD_MAXVAL);
  784. int nDays =0, nHours =0, nMinutes =0;
  785. if(dwInterval)
  786. {
  787. nDays = dwInterval / SEC_PER_DAY;
  788. dwInterval -= nDays * SEC_PER_DAY;
  789. if(dwInterval)
  790. {
  791. nHours = dwInterval / SEC_PER_HOUR;
  792. dwInterval -= nHours * SEC_PER_HOUR;
  793. if(dwInterval)
  794. {
  795. nMinutes = dwInterval / SEC_PER_MINUTE;
  796. dwInterval -= nMinutes * SEC_PER_MINUTE;
  797. }
  798. }
  799. }
  800. m_spinVerifyDay.SetPos(nDays);
  801. m_spinVerifyHour.SetPos(nHours);
  802. m_spinVerifyMinute.SetPos(nMinutes);
  803. }
  804. /*---------------------------------------------------------------------------
  805. CServerPropDBRecord::SetExtTimeData()
  806. Sets the controls' data for extinction timeout interval
  807. ---------------------------------------------------------------------------*/
  808. void
  809. CServerPropDBRecord::SetExtTimeData()
  810. {
  811. DWORD dwInterval = m_pConfig->m_dwTombstoneTimeout;
  812. m_spinExtTmHour.SetRange(0, MAX_HOURS);
  813. m_spinExtTmMinute.SetRange(0, MAX_MINUTES);
  814. m_spinExtTmDay.SetRange(0, UD_MAXVAL);
  815. int nHours = 0, nMinutes =0, nDays =0;
  816. if(dwInterval)
  817. {
  818. nDays = dwInterval / SEC_PER_DAY;
  819. dwInterval -= nDays * SEC_PER_DAY;
  820. if(dwInterval)
  821. {
  822. nHours = dwInterval / SEC_PER_HOUR;
  823. dwInterval -= nHours * SEC_PER_HOUR;
  824. if(dwInterval)
  825. {
  826. nMinutes = dwInterval / SEC_PER_MINUTE;
  827. dwInterval -= nMinutes * SEC_PER_MINUTE;
  828. }
  829. }
  830. }
  831. m_spinExtTmDay.SetPos(nDays);
  832. m_spinExtTmHour.SetPos(nHours);
  833. m_spinExtTmMinute.SetPos(nMinutes);
  834. }
  835. /*---------------------------------------------------------------------------
  836. CServerPropDBRecord::SetExtData()
  837. Sets the controls' data for extinction interval
  838. ---------------------------------------------------------------------------*/
  839. void
  840. CServerPropDBRecord::SetExtIntData()
  841. {
  842. DWORD dwInterval = m_pConfig->m_dwTombstoneInterval;
  843. m_spinExtIntHour.SetRange(0, MAX_HOURS);
  844. m_spinExtIntMinute.SetRange(0, MAX_MINUTES);
  845. m_spinExtIntDay.SetRange(0, UD_MAXVAL);
  846. int nHours =0, nMinutes =0, nDays =0;
  847. if(dwInterval)
  848. {
  849. nDays = dwInterval / SEC_PER_DAY;
  850. dwInterval -= nDays * SEC_PER_DAY;
  851. if(dwInterval)
  852. {
  853. nHours = dwInterval / SEC_PER_HOUR;
  854. dwInterval -= nHours * SEC_PER_HOUR;
  855. if(dwInterval)
  856. {
  857. nMinutes = dwInterval / SEC_PER_MINUTE;
  858. dwInterval -= nMinutes * SEC_PER_MINUTE;
  859. }
  860. }
  861. }
  862. m_spinExtIntDay.SetPos(nDays);
  863. m_spinExtIntHour.SetPos(nHours);
  864. m_spinExtIntMinute.SetPos(nMinutes);
  865. }
  866. void CServerPropDBRecord::OnChangeEditExtinctIntHour()
  867. {
  868. SetDirty(TRUE);
  869. }
  870. /*---------------------------------------------------------------------------
  871. CServerPropDBRecord::CheckValues()
  872. checks if the values are valid
  873. NOTE: All of these checks mimic what the server does since we write
  874. directly to the registry and don't go through an API. If these
  875. every change, the error messages will need to be updated as well.
  876. Author: EricDav
  877. ---------------------------------------------------------------------------*/
  878. BOOL
  879. CServerPropDBRecord::CheckValues()
  880. {
  881. BOOL fValid = TRUE;
  882. UpdateData();
  883. do
  884. {
  885. DWORD dwRenew = CalculateRenewInt();
  886. if (dwRenew < WINSCNF_MIN_REFRESH_INTERVAL)
  887. {
  888. AfxMessageBox(IDS_ERR_RENEW_INTERVAL);
  889. fValid = FALSE;
  890. break;
  891. }
  892. DWORD dwExtTm = CalculateExtTm();
  893. if (dwExtTm < WINSCNF_MIN_TOMBSTONE_TIMEOUT)
  894. {
  895. // minimum value
  896. AfxMessageBox(IDS_ERR_EXTINCTION_TIMEOUT_MIN);
  897. fValid = FALSE;
  898. break;
  899. }
  900. if (dwExtTm < dwRenew)
  901. {
  902. // bad... must be at least this value
  903. AfxMessageBox(IDS_ERR_EXTINCTION_TIMEOUT);
  904. fValid = FALSE;
  905. break;
  906. }
  907. DWORD dwExtInt = CalculateExtInt();
  908. //--ft:07/10/00--
  909. // replaced WINSCNF_MAKE_TOMB_INTVL_M macro with its expansion..
  910. // otherwise, the compiler with CLEAN64_BIT=1 reports an error
  911. // since max(any_dword, 0) is always true - and the compiler is dumb enough
  912. // to signal this as an error..
  913. //
  914. //if (dwExtInt < WINSCNF_MAKE_TOMB_INTVL_M(dwRenew, 0))
  915. if (dwExtInt < min(dwRenew, FOUR_DAYS))
  916. {
  917. // bad... must be at least that value
  918. AfxMessageBox(IDS_ERR_EXTINCTION_INTERVAL);
  919. fValid = FALSE;
  920. break;
  921. }
  922. DWORD dwVerifyInt = CalculateVerifyInt();
  923. if (dwVerifyInt < WINSCNF_MAKE_VERIFY_INTVL_M(dwExtInt))
  924. {
  925. // bad... must be at least this value
  926. if (WINSCNF_MAKE_VERIFY_INTVL_M(dwExtInt) == TWENTY_FOUR_DAYS)
  927. {
  928. AfxMessageBox(IDS_ERR_VERIFY_INTERVAL_24_DAYS);
  929. }
  930. else
  931. {
  932. CString strTemp;
  933. strTemp.Format(IDS_ERR_VERIFY_INTERVAL_CALC, TOMB_MULTIPLIER_FOR_VERIFY);
  934. AfxMessageBox(strTemp);
  935. }
  936. fValid = FALSE;
  937. break;
  938. }
  939. }
  940. while (FALSE);
  941. return fValid;
  942. }
  943. /////////////////////////////////////////////////////////////////////////////
  944. // CServerPropDBVerification property page
  945. IMPLEMENT_DYNCREATE(CServerPropDBVerification, CPropertyPageBase)
  946. CServerPropDBVerification::CServerPropDBVerification() : CPropertyPageBase(CServerPropDBVerification::IDD)
  947. {
  948. //{{AFX_DATA_INIT(CServerPropDBVerification)
  949. m_fCCPeriodic = FALSE;
  950. m_nCCCheckRandom = -1;
  951. m_nCCHour = 0;
  952. m_nCCMinute = 0;
  953. m_nCCSecond = 0;
  954. m_nCCMaxChecked = 0;
  955. m_nCCTimeInterval = 0;
  956. //}}AFX_DATA_INIT
  957. }
  958. CServerPropDBVerification::~CServerPropDBVerification()
  959. {
  960. }
  961. void CServerPropDBVerification::DoDataExchange(CDataExchange* pDX)
  962. {
  963. CPropertyPageBase::DoDataExchange(pDX);
  964. //{{AFX_DATA_MAP(CServerPropDBVerification)
  965. DDX_Control(pDX, IDC_EDIT_CC_START_SECOND, m_editCCSecond);
  966. DDX_Control(pDX, IDC_EDIT_CC_START_MINUTE, m_editCCMinute);
  967. DDX_Control(pDX, IDC_EDIT_CC_START_HOUR, m_editCCHour);
  968. DDX_Control(pDX, IDC_SPIN_CC_START_MINUTE, m_spinCCMinute);
  969. DDX_Control(pDX, IDC_EDIT_CC_INTERVAL, m_editCCInterval);
  970. DDX_Control(pDX, IDC_EDIT_CC_MAX_CHECKED, m_editCCMaxChecked);
  971. DDX_Control(pDX, IDC_RADIO_CHECK_OWNER, m_radioCheckOwner);
  972. DDX_Control(pDX, IDC_CHECK_PERIODIC_CC, m_checkEnableCC);
  973. DDX_Control(pDX, IDC_SPIN_CC_START_SECOND, m_spinCCSecond);
  974. DDX_Control(pDX, IDC_SPIN_CC_START_HOUR, m_spinCCHour);
  975. DDX_Check(pDX, IDC_CHECK_PERIODIC_CC, m_fCCPeriodic);
  976. DDX_Radio(pDX, IDC_RADIO_CHECK_OWNER, m_nCCCheckRandom);
  977. DDX_Text(pDX, IDC_EDIT_CC_START_HOUR, m_nCCHour);
  978. DDV_MinMaxInt(pDX, m_nCCHour, 0, MAX_HOURS);
  979. DDX_Text(pDX, IDC_EDIT_CC_START_MINUTE, m_nCCMinute);
  980. DDV_MinMaxInt(pDX, m_nCCMinute, 0, MAX_MINUTES);
  981. DDX_Text(pDX, IDC_EDIT_CC_START_SECOND, m_nCCSecond);
  982. DDV_MinMaxInt(pDX, m_nCCSecond, 0, MAX_SECONDS);
  983. DDX_Text(pDX, IDC_EDIT_CC_MAX_CHECKED, m_nCCMaxChecked);
  984. DDV_MinMaxUInt(pDX, m_nCCMaxChecked, WINSCNF_CC_MIN_RECS_AAT, 4294967295);
  985. DDX_Text(pDX, IDC_EDIT_CC_INTERVAL, m_nCCTimeInterval);
  986. DDV_MinMaxUInt(pDX, m_nCCTimeInterval, WINSCNF_CC_MIN_INTERVAL/(60*60), 24);
  987. //}}AFX_DATA_MAP
  988. }
  989. BEGIN_MESSAGE_MAP(CServerPropDBVerification, CPropertyPageBase)
  990. //{{AFX_MSG_MAP(CServerPropDBVerification)
  991. ON_BN_CLICKED(IDC_CHECK_PERIODIC_CC, OnCheckPeriodicCc)
  992. ON_EN_CHANGE(IDC_EDIT_CC_INTERVAL, OnChangeEditCcInterval)
  993. ON_EN_CHANGE(IDC_EDIT_CC_MAX_CHECKED, OnChangeEditCcMaxChecked)
  994. ON_EN_CHANGE(IDC_EDIT_CC_START_HOUR, OnChangeEditCcStartHour)
  995. ON_EN_CHANGE(IDC_EDIT_CC_START_MINUTE, OnChangeEditCcStartMinute)
  996. ON_EN_CHANGE(IDC_EDIT_CC_START_SECOND, OnChangeEditCcStartSecond)
  997. ON_BN_CLICKED(IDC_RADIO_CHECK_OWNER, OnRadioCheckOwner)
  998. ON_BN_CLICKED(IDC_RADIO_CHECK_RANDOM, OnRadioCheckRandom)
  999. //}}AFX_MSG_MAP
  1000. END_MESSAGE_MAP()
  1001. /////////////////////////////////////////////////////////////////////////////
  1002. // CServerPropDBVerification message handlers
  1003. BOOL
  1004. CServerPropDBVerification::OnInitDialog()
  1005. {
  1006. CPropertyPageBase::OnInitDialog();
  1007. // get the server
  1008. SPITFSNode spNode;
  1009. CWinsServerHandler *pServer;
  1010. spNode = GetHolder()->GetNode();
  1011. pServer = GETHANDLER(CWinsServerHandler, spNode);
  1012. // get the interval stuff from the server and display in the spinner controlss
  1013. HRESULT hr = GetConfig();
  1014. m_spinCCHour.SetRange(0, MAX_HOURS);
  1015. m_spinCCMinute.SetRange(0, MAX_MINUTES);
  1016. m_spinCCSecond.SetRange(0, MAX_SECONDS);
  1017. SetCCInfo();
  1018. UpdateCCControls();
  1019. SetDirty(FALSE);
  1020. return TRUE;
  1021. }
  1022. BOOL
  1023. CServerPropDBVerification::OnApply()
  1024. {
  1025. HRESULT hr = UpdateServerConfiguration();
  1026. if (FAILED(hr))
  1027. {
  1028. return FALSE;
  1029. }
  1030. else
  1031. {
  1032. return CPropertyPageBase::OnApply();
  1033. }
  1034. }
  1035. void
  1036. CServerPropDBVerification::OnOK()
  1037. {
  1038. HRESULT hr = UpdateServerConfiguration();
  1039. if (FAILED(hr))
  1040. {
  1041. return;
  1042. }
  1043. else
  1044. {
  1045. CPropertyPageBase::OnOK();
  1046. }
  1047. }
  1048. void CServerPropDBVerification::OnCheckPeriodicCc()
  1049. {
  1050. UpdateCCControls();
  1051. SetDirty(TRUE);
  1052. }
  1053. void CServerPropDBVerification::OnChangeEditCcInterval()
  1054. {
  1055. SetDirty(TRUE);
  1056. }
  1057. void CServerPropDBVerification::OnChangeEditCcMaxChecked()
  1058. {
  1059. SetDirty(TRUE);
  1060. }
  1061. void CServerPropDBVerification::OnChangeEditCcStartHour()
  1062. {
  1063. SetDirty(TRUE);
  1064. }
  1065. void CServerPropDBVerification::OnChangeEditCcStartMinute()
  1066. {
  1067. SetDirty(TRUE);
  1068. }
  1069. void CServerPropDBVerification::OnChangeEditCcStartSecond()
  1070. {
  1071. SetDirty(TRUE);
  1072. }
  1073. void CServerPropDBVerification::OnRadioCheckOwner()
  1074. {
  1075. SetDirty(TRUE);
  1076. }
  1077. void CServerPropDBVerification::OnRadioCheckRandom()
  1078. {
  1079. SetDirty(TRUE);
  1080. }
  1081. /*---------------------------------------------------------------------------
  1082. CServerPropDBVerification::UpdateServerConfiguration()
  1083. Updates the server handler variables
  1084. ---------------------------------------------------------------------------*/
  1085. HRESULT
  1086. CServerPropDBVerification::UpdateServerConfiguration()
  1087. {
  1088. UpdateData();
  1089. // Reflect the changes in the server's CConfiguration object
  1090. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1091. // get the server
  1092. SPITFSNode spNode;
  1093. CWinsServerHandler *pServer;
  1094. spNode = GetHolder()->GetNode();
  1095. pServer = GETHANDLER(CWinsServerHandler, spNode);
  1096. // consistency check
  1097. m_pConfig->m_fPeriodicConsistencyCheck = m_fCCPeriodic;
  1098. m_pConfig->m_fCCUseRplPnrs = m_nCCCheckRandom;
  1099. m_pConfig->m_dwMaxRecsAtATime = m_nCCMaxChecked;
  1100. // convert to seconds
  1101. m_pConfig->m_dwCCTimeInterval = m_nCCTimeInterval * (60*60);
  1102. // start time
  1103. CTime curTime = CTime::GetCurrentTime();
  1104. int nYear = curTime.GetYear();
  1105. int nMonth = curTime.GetMonth();
  1106. int nDay = curTime.GetDay();
  1107. CTime tempTime(nYear, nMonth, nDay, m_nCCHour, m_nCCMinute, m_nCCSecond);
  1108. m_pConfig->m_itmCCStartTime = tempTime;
  1109. // now write to server
  1110. DWORD err = m_pConfig->Store();
  1111. if (err != ERROR_SUCCESS)
  1112. {
  1113. // something bad happened
  1114. WinsMessageBox(err);
  1115. }
  1116. else
  1117. {
  1118. // success update our local copy
  1119. pServer->SetConfig(*m_pConfig);
  1120. }
  1121. return HRESULT_FROM_WIN32(err);
  1122. }
  1123. /*---------------------------------------------------------------------------
  1124. CServerPropDBVerification::GetConfig()
  1125. Updates the configuration object from the server handler
  1126. ---------------------------------------------------------------------------*/
  1127. HRESULT
  1128. CServerPropDBVerification::GetConfig()
  1129. {
  1130. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1131. HRESULT hr = hrOK;
  1132. m_pConfig = ((CServerProperties *) GetHolder())->GetConfig();
  1133. return hr;
  1134. }
  1135. /*---------------------------------------------------------------------------
  1136. CServerPropDBVerification::UpdateCCControls()
  1137. Enables/disables depending on checkbox
  1138. Author: EricDav
  1139. ---------------------------------------------------------------------------*/
  1140. void
  1141. CServerPropDBVerification::UpdateCCControls()
  1142. {
  1143. UpdateData();
  1144. BOOL fEnable = FALSE;
  1145. if (m_fCCPeriodic)
  1146. {
  1147. fEnable = TRUE;
  1148. }
  1149. m_spinCCHour.EnableWindow(fEnable);
  1150. m_spinCCMinute.EnableWindow(fEnable);
  1151. m_spinCCSecond.EnableWindow(fEnable);
  1152. m_editCCHour.EnableWindow(fEnable);
  1153. m_editCCMinute.EnableWindow(fEnable);
  1154. m_editCCSecond.EnableWindow(fEnable);
  1155. m_editCCMaxChecked.EnableWindow(fEnable);
  1156. m_editCCInterval.EnableWindow(fEnable);
  1157. m_radioCheckOwner.EnableWindow(fEnable);
  1158. GetDlgItem(IDC_RADIO_CHECK_RANDOM)->EnableWindow(fEnable);
  1159. // TODO: static text
  1160. }
  1161. /*---------------------------------------------------------------------------
  1162. CServerPropDBVerification::SetCCInfo()
  1163. Sets the interval values for Consistency checking
  1164. Author: EricDav
  1165. ---------------------------------------------------------------------------*/
  1166. void
  1167. CServerPropDBVerification::SetCCInfo()
  1168. {
  1169. CString strTemp;
  1170. CButton * pRadio;
  1171. m_checkEnableCC.SetCheck(m_pConfig->m_fPeriodicConsistencyCheck);
  1172. if (m_pConfig->m_fCCUseRplPnrs)
  1173. {
  1174. pRadio = (CButton *) GetDlgItem(IDC_RADIO_CHECK_RANDOM);
  1175. }
  1176. else
  1177. {
  1178. pRadio = (CButton *) GetDlgItem(IDC_RADIO_CHECK_OWNER);
  1179. }
  1180. pRadio->SetCheck(TRUE);
  1181. strTemp.Format(_T("%lu"), m_pConfig->m_dwMaxRecsAtATime);
  1182. m_editCCMaxChecked.SetWindowText(strTemp);
  1183. // convert the TimeInterval into hours from seconds
  1184. int nTimeTemp = m_pConfig->m_dwCCTimeInterval / (60 * 60);
  1185. strTemp.Format(_T("%lu"), nTimeTemp);
  1186. m_editCCInterval.SetWindowText(strTemp);
  1187. m_spinCCHour.SetPos(m_pConfig->m_itmCCStartTime.GetHour());
  1188. m_spinCCMinute.SetPos(m_pConfig->m_itmCCStartTime.GetMinute());
  1189. m_spinCCSecond.SetPos(m_pConfig->m_itmCCStartTime.GetSecond());
  1190. }
  1191. /////////////////////////////////////////////////////////////////////////////
  1192. // CServerPropAdvanced property page
  1193. IMPLEMENT_DYNCREATE(CServerPropAdvanced, CPropertyPageBase)
  1194. CServerPropAdvanced::CServerPropAdvanced() : CPropertyPageBase(CServerPropAdvanced::IDD)
  1195. {
  1196. //{{AFX_DATA_INIT(CServerPropAdvanced)
  1197. m_fLogEvents = FALSE;
  1198. m_strStartVersion = _T("");
  1199. m_fLanNames = FALSE;
  1200. m_fBurstHandling = FALSE;
  1201. m_nQueSelection = -1;
  1202. m_strDbPath = _T("");
  1203. //}}AFX_DATA_INIT
  1204. m_fRestart = FALSE;
  1205. }
  1206. CServerPropAdvanced::~CServerPropAdvanced()
  1207. {
  1208. }
  1209. void CServerPropAdvanced::DoDataExchange(CDataExchange* pDX)
  1210. {
  1211. CPropertyPageBase::DoDataExchange(pDX);
  1212. //{{AFX_DATA_MAP(CServerPropAdvanced)
  1213. DDX_Control(pDX, IDC_BUTTON_BROWSE_DATABASE, m_buttonBrowse);
  1214. DDX_Control(pDX, IDC_EDIT_DATABASE_PATH, m_editDbPath);
  1215. DDX_Control(pDX, IDC_CHECK_BURST_HANDLING, m_checkBurstHandling);
  1216. DDX_Control(pDX, IDC_CHECK_LANNAMES, m_checkLanNames);
  1217. DDX_Control(pDX, IDC_EDIT_START_VERSION, m_editVersionCount);
  1218. DDX_Control(pDX, IDC_CHECK_LOGEVENTS, m_checkLogDetailedEvents);
  1219. DDX_Check(pDX, IDC_CHECK_LOGEVENTS, m_fLogEvents);
  1220. DDX_Text(pDX, IDC_EDIT_START_VERSION, m_strStartVersion);
  1221. DDV_MaxChars(pDX, m_strStartVersion, 16);
  1222. DDX_Check(pDX, IDC_CHECK_LANNAMES, m_fLanNames);
  1223. DDX_Check(pDX, IDC_CHECK_BURST_HANDLING, m_fBurstHandling);
  1224. DDX_Radio(pDX, IDC_RADIO_LOW, m_nQueSelection);
  1225. DDX_Text(pDX, IDC_EDIT_DATABASE_PATH, m_strDbPath);
  1226. //}}AFX_DATA_MAP
  1227. }
  1228. BEGIN_MESSAGE_MAP(CServerPropAdvanced, CPropertyPageBase)
  1229. //{{AFX_MSG_MAP(CServerPropAdvanced)
  1230. ON_BN_CLICKED(IDC_CHECK_LANNAMES, OnCheckLannames)
  1231. ON_BN_CLICKED(IDC_CHECK_BURST_HANDLING, OnCheckBurstHandling)
  1232. ON_BN_CLICKED(IDC_RADIO_CUSTOM, OnRadioCustom)
  1233. ON_BN_CLICKED(IDC_RADIO_HIGH, OnRadioHigh)
  1234. ON_BN_CLICKED(IDC_RADIO_LOW, OnRadioLow)
  1235. ON_BN_CLICKED(IDC_RADIO_MEDIUM, OnRadioMedium)
  1236. ON_EN_CHANGE(IDC_EDIT_CUSTOM_VALUE, OnChangeEditCustomValue)
  1237. ON_BN_CLICKED(IDC_BUTTON_BROWSE_DATABASE, OnButtonBrowseDatabase)
  1238. ON_BN_CLICKED(IDC_CHECK_LOGEVENTS, MarkDirty)
  1239. ON_EN_CHANGE(IDC_EDIT_START_VERSION, MarkDirty)
  1240. ON_EN_CHANGE(IDC_EDIT_DATABASE_PATH, OnChangeEditDatabasePath)
  1241. //}}AFX_MSG_MAP
  1242. END_MESSAGE_MAP()
  1243. /////////////////////////////////////////////////////////////////////////////
  1244. // CServerPropAdvanced message handlers
  1245. BOOL
  1246. CServerPropAdvanced::OnInitDialog()
  1247. {
  1248. CPropertyPageBase::OnInitDialog();
  1249. GetConfig();
  1250. // get the server
  1251. SPITFSNode spNode;
  1252. CWinsServerHandler *pServer;
  1253. spNode = GetHolder()->GetNode();
  1254. pServer = GETHANDLER(CWinsServerHandler, spNode);
  1255. m_fLogEvents = m_pConfig->m_fLogDetailedEvents;
  1256. if (m_fLogEvents)
  1257. {
  1258. m_checkLogDetailedEvents.SetCheck(1);
  1259. }
  1260. else
  1261. {
  1262. m_checkLogDetailedEvents.SetCheck(0);
  1263. }
  1264. if (pServer->m_dwFlags & FLAG_LANMAN_COMPATIBLE)
  1265. {
  1266. m_fLanNames = TRUE;
  1267. m_checkLanNames.SetCheck(TRUE);
  1268. }
  1269. else
  1270. {
  1271. m_fLanNames = FALSE;
  1272. m_checkLanNames.SetCheck(FALSE);
  1273. }
  1274. LONG lLowWord = m_pConfig->m_dwVersCountStart_LowWord;
  1275. LONG lHighWord = m_pConfig->m_dwVersCountStart_HighWord;
  1276. CString strVersion = GetVersionInfo(lLowWord, lHighWord);
  1277. m_editVersionCount.SetWindowText(strVersion);
  1278. // burst que stuff
  1279. m_checkBurstHandling.SetCheck(m_pConfig->m_fBurstHandling);
  1280. ((CEdit *) GetDlgItem(IDC_EDIT_CUSTOM_VALUE))->LimitText(5);
  1281. SetQueSize();
  1282. UpdateBurstHandling();
  1283. // db path stuff
  1284. // browse only available on local machine
  1285. // get the server
  1286. m_buttonBrowse.ShowWindow(FALSE); // we may add this back in later
  1287. m_buttonBrowse.EnableWindow(pServer->IsLocalConnection());
  1288. m_editDbPath.EnableWindow(pServer->IsLocalConnection());
  1289. m_editDbPath.SetWindowText(m_pConfig->m_strDbPath);
  1290. SetDirty(FALSE);
  1291. m_fRestart = FALSE;
  1292. return TRUE;
  1293. }
  1294. void
  1295. CServerPropAdvanced::OnOK()
  1296. {
  1297. HRESULT hr = UpdateServerConfiguration();
  1298. if (FAILED(hr))
  1299. {
  1300. return;
  1301. }
  1302. else
  1303. {
  1304. CPropertyPageBase::OnOK();
  1305. }
  1306. }
  1307. BOOL
  1308. CServerPropAdvanced::OnApply()
  1309. {
  1310. BOOL fRestartNow = FALSE;
  1311. UpdateData();
  1312. // validate the value for Hex
  1313. for (int i=0; i < m_strStartVersion.GetLength(); i++)
  1314. {
  1315. if (!(((m_strStartVersion[i] >= _T('0') ) &&
  1316. (m_strStartVersion[i] <= _T('9') )) ||
  1317. ((m_strStartVersion[i] >= _T('A') ) &&
  1318. (m_strStartVersion[i] <= _T('F') )) ||
  1319. ((m_strStartVersion[i] >= _T('a') ) &&
  1320. (m_strStartVersion[i] <= _T('f') ))
  1321. ))
  1322. {
  1323. ::WinsMessageBox(IDS_ERR_VERSION_NUMBER);
  1324. m_editVersionCount.SetFocus();
  1325. m_editVersionCount.SetSel(0,-1);
  1326. return FALSE;
  1327. }
  1328. }
  1329. DWORD dwSize = GetQueSize();
  1330. if (dwSize < WINS_QUEUE_HWM_MIN ||
  1331. dwSize > WINS_QUEUE_HWM_MAX)
  1332. {
  1333. CString strMin, strMax, strDisplay;
  1334. strMin.Format(_T("%d"), WINS_QUEUE_HWM_MIN);
  1335. strMax.Format(_T("%d"), WINS_QUEUE_HWM_MAX);
  1336. AfxFormatString2(strDisplay, IDS_ERR_BURST_QUE_SIZE, strMin, strMax);
  1337. AfxMessageBox(strDisplay);
  1338. GetDlgItem(IDC_EDIT_CUSTOM_VALUE)->SetFocus();
  1339. return FALSE;
  1340. }
  1341. // warn the user
  1342. if (m_fRestart)
  1343. {
  1344. int nRet = AfxMessageBox(IDS_DATABASE_PATH_CHANGE, MB_YESNOCANCEL);
  1345. if (nRet == IDCANCEL)
  1346. {
  1347. return FALSE;
  1348. }
  1349. else
  1350. if (nRet == IDYES)
  1351. {
  1352. fRestartNow = TRUE;
  1353. }
  1354. }
  1355. HRESULT hr = UpdateServerConfiguration();
  1356. if (FAILED(hr))
  1357. {
  1358. return FALSE;
  1359. }
  1360. if (fRestartNow)
  1361. {
  1362. CString strServiceName;
  1363. strServiceName.LoadString(IDS_SERVICE_NAME);
  1364. // get the server
  1365. SPITFSNode spNode;
  1366. CWinsServerHandler *pServer;
  1367. spNode = GetHolder()->GetNode();
  1368. pServer = GETHANDLER(CWinsServerHandler, spNode);
  1369. DWORD dwError = TFSStopServiceEx(m_pConfig->GetOwner(), _T("WINS"), _T("WINS Service"), strServiceName);
  1370. if (dwError)
  1371. {
  1372. WinsMessageBox(dwError);
  1373. }
  1374. else
  1375. {
  1376. dwError = TFSStartServiceEx(m_pConfig->GetOwner(), _T("WINS"), _T("WINS Service"), strServiceName);
  1377. if (dwError)
  1378. {
  1379. WinsMessageBox(dwError);
  1380. }
  1381. }
  1382. pServer->ConnectToWinsServer(spNode);
  1383. }
  1384. m_fRestart = FALSE;
  1385. return CPropertyPageBase::OnApply();
  1386. }
  1387. /*---------------------------------------------------------------------------
  1388. CServerPropAdvanced::GetConfig()
  1389. Updates the configuration object from the server handler
  1390. ---------------------------------------------------------------------------*/
  1391. HRESULT
  1392. CServerPropAdvanced::GetConfig()
  1393. {
  1394. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1395. HRESULT hr = hrOK;
  1396. m_pConfig = ((CServerProperties *) GetHolder())->GetConfig();
  1397. return hr;
  1398. }
  1399. /*---------------------------------------------------------------------------
  1400. CServerPropAdvanced::UpdateServerConfiguration()
  1401. Updates the variables in the server handler
  1402. ---------------------------------------------------------------------------*/
  1403. HRESULT
  1404. CServerPropAdvanced::UpdateServerConfiguration()
  1405. {
  1406. UpdateData();
  1407. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1408. // get the server
  1409. SPITFSNode spNode;
  1410. CWinsServerHandler * pServer;
  1411. spNode = GetHolder()->GetNode();
  1412. pServer = GETHANDLER(CWinsServerHandler, spNode);
  1413. // update our settings
  1414. m_pConfig->m_fLogDetailedEvents = m_fLogEvents;
  1415. if (m_fLanNames)
  1416. {
  1417. pServer->m_dwFlags |= FLAG_LANMAN_COMPATIBLE;
  1418. }
  1419. else
  1420. {
  1421. pServer->m_dwFlags &= (~FLAG_LANMAN_COMPATIBLE);
  1422. }
  1423. // version stuff
  1424. LONG lLowWord, lHighWord;
  1425. FillVersionInfo(lLowWord, lHighWord);
  1426. m_pConfig->m_dwVersCountStart_HighWord = lHighWord;
  1427. m_pConfig->m_dwVersCountStart_LowWord = lLowWord;
  1428. // burst handling
  1429. m_pConfig->m_fBurstHandling = m_fBurstHandling;
  1430. m_pConfig->m_dwBurstQueSize = GetQueSize();
  1431. // db path
  1432. if (m_fRestart)
  1433. {
  1434. m_pConfig->m_strDbPath = m_strDbPath;
  1435. }
  1436. // now write to server
  1437. DWORD err = m_pConfig->Store();
  1438. if (err != ERROR_SUCCESS)
  1439. {
  1440. // something bad happened
  1441. WinsMessageBox(err);
  1442. }
  1443. else
  1444. {
  1445. // success update our local copy
  1446. pServer->SetConfig(*m_pConfig);
  1447. }
  1448. return HRESULT_FROM_WIN32(err);
  1449. }
  1450. /*---------------------------------------------------------------------------
  1451. CServerPropAdvanced::FillVersionInfo(LONG &lLowValue, LONG &lHighValue)
  1452. fills the version info in the related controls
  1453. ---------------------------------------------------------------------------*/
  1454. void
  1455. CServerPropAdvanced::FillVersionInfo(LONG &lLowValue, LONG &lHighValue)
  1456. {
  1457. CString str ;
  1458. m_editVersionCount.GetWindowText(str);
  1459. int j = str.GetLength();
  1460. if ( j > 16 || !j )
  1461. {
  1462. //
  1463. // Invalid string
  1464. //
  1465. return;
  1466. }
  1467. TCHAR sz[] = _T("0000000000000000");
  1468. TCHAR *pch;
  1469. ::_tcscpy(sz + 16 - j, (LPCTSTR)str);
  1470. pch = sz + 8;
  1471. ::_stscanf(pch, _T("%08lX"),&lLowValue);
  1472. *pch = '\0';
  1473. ::_stscanf(sz, _T("%08lX"),&lHighValue);
  1474. return;
  1475. }
  1476. CString
  1477. CServerPropAdvanced::GetVersionInfo(LONG lLowWord, LONG lHighWord)
  1478. {
  1479. CString strVersionCount;
  1480. TCHAR sz[20];
  1481. TCHAR *pch = sz;
  1482. ::wsprintf(sz, _T("%08lX%08lX"), lHighWord, lLowWord);
  1483. // Kill leading zero's
  1484. while (*pch == '0')
  1485. {
  1486. ++pch;
  1487. }
  1488. // At least one digit...
  1489. if (*pch == '\0')
  1490. {
  1491. --pch;
  1492. }
  1493. strVersionCount = pch;
  1494. return strVersionCount;
  1495. }
  1496. void CServerPropAdvanced::OnCheckLannames()
  1497. {
  1498. SetDirty(TRUE);
  1499. // mark the snap-in as dirty
  1500. SPITFSNode spNode ;
  1501. spNode = GetHolder()->GetNode();
  1502. SPITFSNodeMgr spNodeManager;
  1503. SPITFSNode spRootNode;
  1504. spNode->GetNodeMgr(&spNodeManager);
  1505. spNodeManager->GetRootNode(&spRootNode);
  1506. // mark the data as dirty so that we'll ask the user to save.
  1507. spRootNode->SetData(TFS_DATA_DIRTY, TRUE);
  1508. }
  1509. void CServerPropAdvanced::MarkDirty()
  1510. {
  1511. SetDirty(TRUE);
  1512. }
  1513. void CServerPropAdvanced::OnCheckBurstHandling()
  1514. {
  1515. SetDirty(TRUE);
  1516. UpdateBurstHandling();
  1517. }
  1518. void CServerPropAdvanced::OnRadioCustom()
  1519. {
  1520. SetDirty(TRUE);
  1521. EnableCustomEntry();
  1522. }
  1523. void CServerPropAdvanced::OnRadioHigh()
  1524. {
  1525. SetDirty(TRUE);
  1526. EnableCustomEntry();
  1527. }
  1528. void CServerPropAdvanced::OnRadioLow()
  1529. {
  1530. SetDirty(TRUE);
  1531. EnableCustomEntry();
  1532. }
  1533. void CServerPropAdvanced::OnRadioMedium()
  1534. {
  1535. SetDirty(TRUE);
  1536. EnableCustomEntry();
  1537. }
  1538. void CServerPropAdvanced::OnChangeEditCustomValue()
  1539. {
  1540. SetDirty(TRUE);
  1541. }
  1542. void CServerPropAdvanced::OnButtonBrowseDatabase()
  1543. {
  1544. // TODO: browse for a path
  1545. }
  1546. void CServerPropAdvanced::OnChangeEditDatabasePath()
  1547. {
  1548. SetDirty(TRUE);
  1549. m_fRestart = TRUE;
  1550. }
  1551. void CServerPropAdvanced::UpdateBurstHandling()
  1552. {
  1553. if (IsWindow(m_checkBurstHandling.GetSafeHwnd()))
  1554. {
  1555. EnableQueSelection(m_checkBurstHandling.GetCheck());
  1556. }
  1557. }
  1558. void CServerPropAdvanced::EnableQueSelection(BOOL bEnable)
  1559. {
  1560. GetDlgItem(IDC_RADIO_LOW)->EnableWindow(bEnable);
  1561. GetDlgItem(IDC_RADIO_MEDIUM)->EnableWindow(bEnable);
  1562. GetDlgItem(IDC_RADIO_HIGH)->EnableWindow(bEnable);
  1563. GetDlgItem(IDC_RADIO_CUSTOM)->EnableWindow(bEnable);
  1564. GetDlgItem(IDC_EDIT_CUSTOM_VALUE)->EnableWindow(bEnable);
  1565. EnableCustomEntry();
  1566. }
  1567. void CServerPropAdvanced::EnableCustomEntry()
  1568. {
  1569. BOOL bEnable = ((CButton *)GetDlgItem(IDC_RADIO_CUSTOM))->GetCheck() &&
  1570. m_checkBurstHandling.GetSafeHwnd() &&
  1571. m_checkBurstHandling.GetCheck();
  1572. GetDlgItem(IDC_EDIT_CUSTOM_VALUE)->EnableWindow(bEnable);
  1573. }
  1574. void CServerPropAdvanced::SetQueSize()
  1575. {
  1576. UINT uControlID = IDC_RADIO_CUSTOM;
  1577. switch (m_pConfig->m_dwBurstQueSize)
  1578. {
  1579. case BURST_QUE_SIZE_LOW:
  1580. uControlID = IDC_RADIO_LOW;
  1581. m_nQueSelection = 0;
  1582. break;
  1583. case BURST_QUE_SIZE_MEDIUM:
  1584. uControlID = IDC_RADIO_MEDIUM;
  1585. m_nQueSelection = 1;
  1586. break;
  1587. case BURST_QUE_SIZE_HIGH:
  1588. uControlID = IDC_RADIO_HIGH;
  1589. m_nQueSelection = 2;
  1590. break;
  1591. default:
  1592. {
  1593. TCHAR szBuf[10];
  1594. _itot(m_pConfig->m_dwBurstQueSize, szBuf, 10);
  1595. m_nQueSelection = 3;
  1596. GetDlgItem(IDC_EDIT_CUSTOM_VALUE)->SetWindowText(szBuf);
  1597. }
  1598. break;
  1599. }
  1600. ((CButton *) GetDlgItem(uControlID))->SetCheck(TRUE);
  1601. }
  1602. DWORD CServerPropAdvanced::GetQueSize()
  1603. {
  1604. DWORD dwSize = 0;
  1605. UpdateData();
  1606. if (IsDlgButtonChecked(IDC_RADIO_LOW))
  1607. {
  1608. dwSize = BURST_QUE_SIZE_LOW;
  1609. }
  1610. else
  1611. if (IsDlgButtonChecked(IDC_RADIO_MEDIUM))
  1612. {
  1613. dwSize = BURST_QUE_SIZE_MEDIUM;
  1614. }
  1615. else
  1616. if (IsDlgButtonChecked(IDC_RADIO_HIGH))
  1617. {
  1618. dwSize = BURST_QUE_SIZE_HIGH;
  1619. }
  1620. else
  1621. {
  1622. // must be custom
  1623. CString strText;
  1624. GetDlgItem(IDC_EDIT_CUSTOM_VALUE)->GetWindowText(strText);
  1625. dwSize = (DWORD) _ttoi(strText);
  1626. }
  1627. return dwSize;
  1628. }
  1629. /////////////////////////////////////////////////////////////////////////////
  1630. //
  1631. // CServerProperties holder
  1632. //
  1633. /////////////////////////////////////////////////////////////////////////////
  1634. CServerProperties::CServerProperties
  1635. (
  1636. ITFSNode * pNode,
  1637. IComponentData * pComponentData,
  1638. ITFSComponentData * pTFSCompData,
  1639. LPCTSTR pszSheetName
  1640. ) : CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  1641. {
  1642. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  1643. m_bTheme = TRUE;
  1644. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  1645. AddPageToList((CPropertyPageBase*) &m_pageDBRecord);
  1646. AddPageToList((CPropertyPageBase*) &m_pageDBVerification);
  1647. AddPageToList((CPropertyPageBase*) &m_pageAdvanced);
  1648. Assert(pTFSCompData != NULL);
  1649. m_spTFSCompData.Set(pTFSCompData);
  1650. }
  1651. CServerProperties::~CServerProperties()
  1652. {
  1653. RemovePageFromList((CPropertyPageBase*) &m_pageGeneral, FALSE);
  1654. RemovePageFromList((CPropertyPageBase*) &m_pageDBRecord, FALSE);
  1655. RemovePageFromList((CPropertyPageBase*) &m_pageDBVerification, FALSE);
  1656. RemovePageFromList((CPropertyPageBase*) &m_pageAdvanced, FALSE);
  1657. }