Source code of Windows XP (NT5)
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.

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