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.

911 lines
22 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. logdatapp.cpp
  7. Log data properties implementation file
  8. FILE HISTORY:
  9. oct/11/2001 - vbhanu modified
  10. */
  11. #include "stdafx.h"
  12. #include "logdatapp.h"
  13. #include "logdatanode.h"
  14. #include "spdutil.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. //
  22. // CLogDataProperties holder
  23. //
  24. /////////////////////////////////////////////////////////////////////////////
  25. CLogDataProperties::CLogDataProperties(
  26. ITFSNode *pNode,
  27. IComponentData *pComponentData,
  28. ITFSComponentData *pTFSCompData,
  29. CLogDataInfo *pLogDataInfo,
  30. ISpdInfo *pSpdInfo,
  31. LPCTSTR pszSheetName,
  32. LPDATAOBJECT pDataObject,
  33. ITFSNodeMgr *pNodeMgr,
  34. ITFSComponent *pComponent)
  35. : CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  36. {
  37. //ASSERT(pFolderNode == GetContainerNode());
  38. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  39. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  40. Assert(pTFSCompData != NULL);
  41. m_spTFSCompData.Set(pTFSCompData);
  42. m_spSpdInfo.Set(pSpdInfo);
  43. m_LogDataInfo = *pLogDataInfo;
  44. m_bTheme = TRUE;
  45. m_pDataObject = pDataObject;
  46. m_pNodeMgr = pNodeMgr;
  47. m_pComponent = pComponent;
  48. m_pageGeneral.SetLogDataProperties(this);
  49. }
  50. CLogDataProperties::~CLogDataProperties()
  51. {
  52. RemovePageFromList((CPropertyPageBase*) &m_pageGeneral, FALSE);
  53. }
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CLogDataGenProp property page
  56. IMPLEMENT_DYNCREATE(CLogDataGenProp, CPropertyPageBase)
  57. CLogDataGenProp::CLogDataGenProp()
  58. : CPropertyPageBase(CLogDataGenProp::IDD)
  59. {
  60. //{{AFX_DATA_INIT(CLogDataGenProp)
  61. // NOTE: the ClassWizard will add member initialization here
  62. //}}AFX_DATA_INIT
  63. m_hgCopy = NULL;
  64. }
  65. CLogDataGenProp::~CLogDataGenProp()
  66. {
  67. if (m_hgCopy != NULL)
  68. GlobalFree(m_hgCopy);
  69. }
  70. void
  71. CLogDataGenProp::DoDataExchange(
  72. CDataExchange* pDX)
  73. {
  74. CPropertyPageBase::DoDataExchange(pDX);
  75. //{{AFX_DATA_MAP(CLogDataGenProp)
  76. //DDX_Control(pDX, IDC_LIST_SPECIFIC, m_listSpecificFilters);
  77. //}}AFX_DATA_MAP
  78. }
  79. BEGIN_MESSAGE_MAP(CLogDataGenProp, CPropertyPageBase)
  80. //{{AFX_MSG_MAP(CLogDataGenProp)
  81. ON_BN_CLICKED(IDC_BTN_MOVE_UP, OnButtonUp)
  82. ON_BN_CLICKED(IDC_BTN_MOVE_DOWN, OnButtonDown)
  83. ON_BN_CLICKED(IDC_BTN_COPY, OnButtonCopy)
  84. //}}AFX_MSG_MAP
  85. END_MESSAGE_MAP()
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CLogDataGenProp message handlers
  88. BOOL
  89. CLogDataGenProp::OnInitDialog()
  90. {
  91. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  92. CPropertyPageBase::OnInitDialog();
  93. PopulateLogInfo();
  94. SetDirty(FALSE);
  95. return TRUE; // return TRUE unless you set the focus to a control
  96. // EXCEPTION: OCX Property Pages should return FALSE
  97. }
  98. HRESULT
  99. CLogDataGenProp::SetLogDataProperties(
  100. CLogDataProperties *pLogDataProp)
  101. /*++
  102. CLogDataGenProp::SetLogDataProperties - Sets member var to parent
  103. Arguments:
  104. pLogDataProp - A pointer to the parent class
  105. Returns:
  106. S_OK on success
  107. --*/
  108. {
  109. HRESULT hr = S_OK;
  110. if (NULL == pLogDataProp)
  111. hr = HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
  112. else
  113. m_pLogDataProp = pLogDataProp;
  114. return hr;
  115. }
  116. HRESULT
  117. CLogDataGenProp::GetSelectedItemState(
  118. int *pnSelIndex,
  119. PUINT puiState,
  120. IResultData *pResultData)
  121. /*++
  122. CLogDataGenProp::GetSelectedItemState - Gets the list item state for the
  123. selected item
  124. Arguments:
  125. [out] puiState - holds the state of the item
  126. [out] nIndex - Returns the index to the selected item
  127. [in] pResultData - Pointer to result data to use for the search
  128. Returns:
  129. S_OK on success
  130. --*/
  131. {
  132. HRESULT hr = S_OK;
  133. RESULTDATAITEM rdi;
  134. if ( (NULL == puiState) || (NULL == pResultData) )
  135. {
  136. hr = HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
  137. goto Error;
  138. }
  139. memset(&rdi, 0, sizeof(RESULTDATAITEM));
  140. rdi.mask = RDI_STATE | RDI_INDEX;
  141. //search from the beginning
  142. rdi.nIndex = -1;
  143. //for a selected item
  144. rdi.nState = LVIS_SELECTED;
  145. //start the search
  146. CORg(pResultData->GetNextItem(&rdi));
  147. //copy out the state
  148. *puiState = (UINT) rdi.nState;
  149. *pnSelIndex = rdi.nIndex;
  150. COM_PROTECT_ERROR_LABEL;
  151. return hr;
  152. }
  153. #if 0
  154. HRESULT
  155. CLogDataGenProp::MoveSelection(
  156. int nIndexTo
  157. )
  158. /*++
  159. Routine Description:
  160. CLogDataGenProp::UpdateSelection:
  161. Moves the selection to the specified index
  162. Arguments:
  163. nIndexTo - A valid virtual index to move to
  164. Returns:
  165. S_OK on success
  166. --*/
  167. {
  168. int nIndexFrom = 0;
  169. UINT uiState = 0;
  170. HRESULT hr = S_OK;
  171. SPIResultData spResultData;
  172. CORg(m_pLogDataProp->m_pComponent->GetResultData(&spResultData));
  173. CORg(GetSelectedItemState(&nIndexFrom, &uiState, spResultData));
  174. CORg(spResultData->ModifyItemState(nIndexFrom, 0, 0,
  175. LVIS_SELECTED | LVIS_FOCUSED));
  176. CORg(spResultData->ModifyItemState(nIndexTo, 0, uiState, 0));
  177. COM_PROTECT_ERROR_LABEL;
  178. return hr;
  179. }
  180. void
  181. CLogDataGenProp::OnButtonUp()
  182. {
  183. int nIndex = 0;
  184. HRESULT hr = hrOK;
  185. CLogDataInfo *pLogDataInfo = NULL;
  186. CLogDataProperties *pLogDataProp = (CLogDataProperties *)GetHolder();
  187. CDataObject *pDataObject = NULL;
  188. SPIConsole spConsole;
  189. int nCount = 0;
  190. pDataObject = reinterpret_cast<CDataObject *>(pLogDataProp->m_pDataObject);
  191. nIndex = pDataObject->GetVirtualIndex();
  192. nIndex--;
  193. pLogDataProp->GetLogDataInfo(&pLogDataInfo);
  194. ASSERT(pLogDataInfo != NULL);
  195. //
  196. // Free up the space occupied by the previous log entry
  197. //
  198. pLogDataInfo->Deallocate();
  199. CORg(pLogDataProp->m_spSpdInfo->GetSpecificLog(
  200. nIndex,
  201. pLogDataInfo));
  202. //
  203. // Refresh the contents
  204. //
  205. ShowSpecificInfo(pLogDataInfo);
  206. pDataObject->SetVirtualIndex(nIndex);
  207. MoveSelection(nIndex);
  208. //
  209. // Force the listbox to update its status
  210. //
  211. pLogDataProp->m_pNodeMgr->GetConsole(&spConsole);
  212. nCount = pLogDataProp->m_spSpdInfo->GetLogDataCount();
  213. spConsole->UpdateAllViews(pDataObject, nCount, IPFWMON_UPDATE_STATUS);
  214. COM_PROTECT_ERROR_LABEL;
  215. if (FAILED(hr))
  216. {
  217. switch(hr)
  218. {
  219. case HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND):
  220. //
  221. // Get the old log back
  222. //
  223. nIndex++;
  224. hr = pLogDataProp->m_spSpdInfo->GetSpecificLog(
  225. nIndex,
  226. pLogDataInfo);
  227. ASSERT(SUCCEEDED(hr));
  228. //
  229. // Display a warning
  230. //
  231. AfxMessageBox(IDS_LOGDATA_WARN_BOF, MB_OK | MB_ICONEXCLAMATION, 0);
  232. break;
  233. default:
  234. //
  235. // Unexpected error
  236. //
  237. ASSERT(FALSE);
  238. break;
  239. }
  240. }
  241. }
  242. void
  243. CLogDataGenProp::OnButtonDown()
  244. {
  245. int nIndex = 0;
  246. HRESULT hr = hrOK;
  247. CLogDataInfo *pLogDataInfo = NULL;
  248. CLogDataProperties *pLogDataProp = (CLogDataProperties *)GetHolder();
  249. CDataObject *pDataObject = NULL;
  250. SPIConsole spConsole;
  251. int nCount = 0;
  252. pDataObject = reinterpret_cast<CDataObject *>(pLogDataProp->m_pDataObject);
  253. nIndex = pDataObject->GetVirtualIndex();
  254. nIndex++;
  255. pLogDataProp->GetLogDataInfo(&pLogDataInfo);
  256. ASSERT(pLogDataInfo != NULL);
  257. //
  258. // Free up the space occupied by the previous log entry
  259. //
  260. pLogDataInfo->Deallocate();
  261. CORg(pLogDataProp->m_spSpdInfo->GetSpecificLog(
  262. nIndex,
  263. pLogDataInfo));
  264. //
  265. // Refresh the contents
  266. //
  267. ShowSpecificInfo(pLogDataInfo);
  268. pDataObject->SetVirtualIndex(nIndex);
  269. MoveSelection(nIndex);
  270. //
  271. // Force the listbox to update its status
  272. //
  273. pLogDataProp->m_pNodeMgr->GetConsole(&spConsole);
  274. nCount = pLogDataProp->m_spSpdInfo->GetLogDataCount();
  275. spConsole->UpdateAllViews(pDataObject, nCount, IPFWMON_UPDATE_STATUS);
  276. COM_PROTECT_ERROR_LABEL;
  277. if (FAILED(hr))
  278. {
  279. switch(hr)
  280. {
  281. case HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND):
  282. //
  283. // Get the old log back
  284. //
  285. nIndex--;
  286. hr = pLogDataProp->m_spSpdInfo->GetSpecificLog(
  287. nIndex,
  288. pLogDataInfo);
  289. ASSERT(SUCCEEDED(hr));
  290. //
  291. // Display a warning
  292. //
  293. AfxMessageBox(IDS_LOGDATA_WARN_EOF, MB_OK | MB_ICONEXCLAMATION, 0);
  294. break;
  295. default:
  296. //
  297. // Unexpected error
  298. //
  299. ASSERT(FALSE);
  300. break;
  301. }
  302. }
  303. }
  304. #endif //0
  305. HRESULT
  306. CLogDataGenProp::MoveSelection(
  307. CLogDataProperties *pLogDataProp,
  308. CDataObject *pDataObj,
  309. int nIndexTo
  310. )
  311. /*++
  312. Routine Description:
  313. CLogDataGenProp::MoveSelection:
  314. Moves the selection to the specified index
  315. Arguments:
  316. nIndexTo - A valid virtual index to move to
  317. Returns:
  318. S_OK on success
  319. HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) if the index could not be located
  320. --*/
  321. {
  322. HRESULT hr = S_OK;
  323. HRESULT hrErr = S_OK;
  324. int nIndexFrom = 0;
  325. int nCount = 0;
  326. UINT uiState = 0;
  327. CLogDataInfo *pLogDataInfo = NULL;
  328. SPIConsole spConsole;
  329. SPIResultData spResultData;
  330. //
  331. // Blow the old record away
  332. //
  333. pLogDataProp->GetLogDataInfo(&pLogDataInfo);
  334. ASSERT(pLogDataInfo != NULL);
  335. pLogDataInfo->Deallocate();
  336. //
  337. // Attempt to get the new record at nIndexTo
  338. //
  339. CORg(pLogDataProp->m_spSpdInfo->GetSpecificLog(
  340. nIndexTo,
  341. pLogDataInfo));
  342. //
  343. // Refresh the contents and the selection
  344. //
  345. ShowSpecificInfo(pLogDataInfo);
  346. pDataObj->SetVirtualIndex(nIndexTo);
  347. CORg(m_pLogDataProp->m_pComponent->GetResultData(&spResultData));
  348. CORg(GetSelectedItemState(&nIndexFrom, &uiState, spResultData));
  349. CORg(spResultData->ModifyItemState(nIndexFrom, 0, 0,
  350. LVIS_SELECTED | LVIS_FOCUSED));
  351. CORg(spResultData->ModifyItemState(nIndexTo, 0, uiState, 0));
  352. //
  353. // Force the listbox to update its status
  354. //
  355. pLogDataProp->m_pNodeMgr->GetConsole(&spConsole);
  356. nCount = pLogDataProp->m_spSpdInfo->GetLogDataCount();
  357. spConsole->UpdateAllViews(
  358. pDataObj,
  359. nCount,
  360. IPFWMON_UPDATE_STATUS);
  361. COM_PROTECT_ERROR_LABEL;
  362. if (FAILED(hr))
  363. {
  364. switch(hr)
  365. {
  366. case HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND):
  367. //
  368. // Get the old log back, we have not yet updated the display or
  369. // the virtual index.
  370. //
  371. hrErr = pLogDataProp->m_spSpdInfo->GetSpecificLog(
  372. nIndexFrom,
  373. pLogDataInfo);
  374. ASSERT(SUCCEEDED(hrErr));
  375. break;
  376. default:
  377. //
  378. // Should never happen.
  379. //
  380. ASSERT(FALSE);
  381. break;
  382. }
  383. }
  384. return hr;
  385. }
  386. void
  387. CLogDataGenProp::OnButtonUp()
  388. /*++
  389. Routine Description:
  390. CLogDataGenProp::OnButtonUp:
  391. Moves the selection up by a single record
  392. Arguments:
  393. None.
  394. Returns:
  395. Nothing.
  396. --*/
  397. {
  398. HRESULT hr = S_OK;
  399. int nIndex = 0;
  400. CLogDataProperties *pLogDataProp = NULL;
  401. CDataObject *pDataObj = NULL;
  402. //
  403. // Get the parent class, data object and the new index
  404. //
  405. pLogDataProp = (CLogDataProperties *)GetHolder();
  406. pDataObj = reinterpret_cast<CDataObject *>(pLogDataProp->m_pDataObject);
  407. nIndex = pDataObj->GetVirtualIndex();
  408. nIndex--;
  409. //
  410. // Try moving the selection up
  411. //
  412. CORg(MoveSelection(
  413. pLogDataProp,
  414. pDataObj,
  415. nIndex));
  416. COM_PROTECT_ERROR_LABEL;
  417. if (FAILED(hr))
  418. {
  419. switch(hr)
  420. {
  421. case HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND):
  422. //
  423. // Display a warning, indicating BOF as this is the only possible
  424. // reason for this error.
  425. //
  426. AfxMessageBox(
  427. IDS_LOGDATA_WARN_BOF,
  428. MB_OK | MB_ICONEXCLAMATION,
  429. 0);
  430. break;
  431. default:
  432. //
  433. // Unexpected error
  434. //
  435. ASSERT(FALSE);
  436. break;
  437. }
  438. }
  439. }
  440. void
  441. CLogDataGenProp::OnButtonDown()
  442. /*++
  443. Routine Description:
  444. CLogDataGenProp::OnButtonDown:
  445. Moves the selection down by a single record
  446. Arguments:
  447. None.
  448. Returns:
  449. Nothing.
  450. --*/
  451. {
  452. HRESULT hr = S_OK;
  453. int nIndex = 0;
  454. CLogDataProperties *pLogDataProp = NULL;
  455. CDataObject *pDataObj = NULL;
  456. //
  457. // Get the parent class, data object and the new index
  458. //
  459. pLogDataProp = (CLogDataProperties *)GetHolder();
  460. pDataObj = reinterpret_cast<CDataObject *>(pLogDataProp->m_pDataObject);
  461. nIndex = pDataObj->GetVirtualIndex();
  462. nIndex++;
  463. //
  464. // Try moving the selection down
  465. //
  466. CORg(MoveSelection(
  467. pLogDataProp,
  468. pDataObj,
  469. nIndex));
  470. COM_PROTECT_ERROR_LABEL;
  471. if (FAILED(hr))
  472. {
  473. switch(hr)
  474. {
  475. case HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND):
  476. //
  477. // Display a warning, indicating BOF as this is the only possible
  478. // reason for this error.
  479. //
  480. AfxMessageBox(
  481. IDS_LOGDATA_WARN_EOF,
  482. MB_OK | MB_ICONEXCLAMATION,
  483. 0);
  484. break;
  485. default:
  486. //
  487. // Unexpected error
  488. //
  489. ASSERT(FALSE);
  490. break;
  491. }
  492. }
  493. }
  494. #if 0
  495. void
  496. CLogDataGenProp::OnSelectionJump(
  497. int nIndex
  498. )
  499. /*++
  500. Routine Description:
  501. CLogDataGenProp::OnSelectionJump:
  502. Changes the selection to a specific index
  503. Arguments:
  504. nIndex - The index to jump to
  505. Returns:
  506. Nothing.
  507. --*/
  508. {
  509. HRESULT hr = S_OK;
  510. CLogDataProperties *pLogDataProp = NULL;
  511. CDataObject *pDataObj = NULL;
  512. //
  513. // Get the parent class, data object and the new index
  514. //
  515. pLogDataProp = (CLogDataProperties *)GetHolder();
  516. pDataObj = reinterpret_cast<CDataObject *>(pLogDataProp->m_pDataObject);
  517. //
  518. // Try moving the selection
  519. //
  520. CORg(MoveSelection(
  521. pLogDataProp,
  522. pDataObj,
  523. nIndex));
  524. COM_PROTECT_ERROR_LABEL;
  525. ASSERT(SUCCEDED(hr));
  526. }
  527. #endif //0
  528. #define PRECOMPUTED_STATIC_SIZE 200
  529. void
  530. CLogDataGenProp::OnButtonCopy()
  531. {
  532. DWORD dwErr = ERROR_SUCCESS;
  533. int nNumBytes = 0;
  534. BOOL bClipOpened = FALSE;
  535. BOOL bErr = FALSE;
  536. LPTSTR lptstrCopy = NULL;
  537. DWORD dwSize = PRECOMPUTED_STATIC_SIZE * sizeof(TCHAR);
  538. CString csTemp;
  539. CLogDataInfo *pLogDataInfo = NULL;
  540. CLogDataProperties *pLogDataProp = (CLogDataProperties *)GetHolder();
  541. HANDLE hData = NULL;
  542. Assert(pLogDataProp);
  543. pLogDataProp->GetLogDataInfo(&pLogDataInfo);
  544. dwSize += pLogDataInfo->m_wzcDbRecord.message.dwDataLen +
  545. pLogDataInfo->m_wzcDbRecord.ssid.dwDataLen +
  546. pLogDataInfo->m_wzcDbRecord.context.dwDataLen;
  547. //open the clipboard
  548. bClipOpened = ::OpenClipboard(NULL);
  549. if (FALSE == bClipOpened)
  550. goto exit;
  551. bErr = EmptyClipboard();
  552. if (FALSE == bErr)
  553. {
  554. dwErr = GetLastError();
  555. goto exit;
  556. }
  557. //copy
  558. if (m_hgCopy != NULL)
  559. GlobalFree(m_hgCopy);
  560. m_hgCopy = GlobalAlloc(GMEM_MOVEABLE, dwSize);
  561. if (NULL == m_hgCopy)
  562. goto exit;
  563. lptstrCopy = (LPTSTR) GlobalLock(m_hgCopy);
  564. ComponentIDToString(pLogDataInfo->m_wzcDbRecord.componentid, csTemp);
  565. nNumBytes = _stprintf(lptstrCopy, _T("Source: %s\r\n"), (LPCTSTR)csTemp);
  566. lptstrCopy += nNumBytes;
  567. CategoryToString(pLogDataInfo->m_wzcDbRecord.category, csTemp);
  568. nNumBytes = _stprintf(lptstrCopy, _T("Type: %s\r\n"),(LPCTSTR)csTemp);
  569. lptstrCopy += nNumBytes;
  570. FileTimeToString(pLogDataInfo->m_wzcDbRecord.timestamp, &csTemp);
  571. nNumBytes = _stprintf(lptstrCopy, _T("Timestamp: %s\r\n"),(LPCTSTR)csTemp);
  572. lptstrCopy += nNumBytes;
  573. nNumBytes = _stprintf(lptstrCopy, _T("Description: %s\r\n"),
  574. (LPCTSTR) pLogDataInfo->m_wzcDbRecord.message.pData);
  575. lptstrCopy += nNumBytes;
  576. nNumBytes = _stprintf(lptstrCopy, _T("Local MAC: %s\r\n"),
  577. (LPCTSTR)pLogDataInfo->m_wzcDbRecord.localmac.pData);
  578. lptstrCopy += nNumBytes;
  579. nNumBytes = _stprintf(lptstrCopy, _T("Remote MAC: %s\r\n"),
  580. (LPCTSTR)pLogDataInfo->m_wzcDbRecord.remotemac.pData);
  581. lptstrCopy += nNumBytes;
  582. nNumBytes = _stprintf(lptstrCopy, _T("SSID: "));
  583. lptstrCopy += nNumBytes;
  584. CopyAndStripNULL(lptstrCopy,
  585. (LPTSTR)pLogDataInfo->m_wzcDbRecord.ssid.pData,
  586. pLogDataInfo->m_wzcDbRecord.ssid.dwDataLen);
  587. lptstrCopy += pLogDataInfo->m_wzcDbRecord.ssid.dwDataLen/sizeof(TCHAR) - 1;
  588. nNumBytes = _stprintf(lptstrCopy, _T("\r\n"));
  589. lptstrCopy += nNumBytes;
  590. nNumBytes = _stprintf(lptstrCopy, _T("Details: %s\r\n"),
  591. (LPWSTR) pLogDataInfo->m_wzcDbRecord.context.pData);
  592. GlobalUnlock(m_hgCopy);
  593. hData = SetClipboardData(CF_UNICODETEXT, m_hgCopy);
  594. if (NULL == hData)
  595. dwErr = GetLastError();
  596. exit:
  597. //close clipboard
  598. if (TRUE == bClipOpened)
  599. CloseClipboard();
  600. }
  601. void
  602. CLogDataGenProp::ShowSpecificInfo(
  603. CLogDataInfo *pLogDataInfo)
  604. {
  605. LPTSTR lptstrTemp = NULL;
  606. CString csTemp;
  607. ComponentIDToString(pLogDataInfo->m_wzcDbRecord.componentid, csTemp);
  608. GetDlgItem(IDC_LOGDATA_EDIT1)->SetWindowText(csTemp);
  609. CategoryToString(pLogDataInfo->m_wzcDbRecord.category, csTemp);
  610. GetDlgItem(IDC_LOGDATA_EDIT2)->SetWindowText(csTemp);
  611. FileTimeToString(pLogDataInfo->m_wzcDbRecord.timestamp, &csTemp);
  612. GetDlgItem(IDC_LOGDATA_EDIT3)->SetWindowText(csTemp);
  613. if (NULL != pLogDataInfo->m_wzcDbRecord.message.pData)
  614. csTemp = (LPWSTR) pLogDataInfo->m_wzcDbRecord.message.pData;
  615. else
  616. csTemp = _T("");
  617. GetDlgItem(IDC_LOGDATA_EDIT4)->SetWindowText(csTemp);
  618. if (NULL != pLogDataInfo->m_wzcDbRecord.localmac.pData)
  619. csTemp = (LPWSTR) pLogDataInfo->m_wzcDbRecord.localmac.pData;
  620. else
  621. csTemp = _T("");
  622. GetDlgItem(IDC_LOGDATA_EDIT5)->SetWindowText(csTemp);
  623. if (NULL != pLogDataInfo->m_wzcDbRecord.remotemac.pData)
  624. csTemp = (LPWSTR) pLogDataInfo->m_wzcDbRecord.remotemac.pData;
  625. else
  626. csTemp = _T("");
  627. GetDlgItem(IDC_LOGDATA_EDIT6)->SetWindowText(csTemp);
  628. if (NULL != pLogDataInfo->m_wzcDbRecord.ssid.pData)
  629. {
  630. lptstrTemp = csTemp.GetBuffer(pLogDataInfo->
  631. m_wzcDbRecord.ssid.dwDataLen);
  632. CopyAndStripNULL(lptstrTemp,
  633. (LPTSTR)pLogDataInfo->m_wzcDbRecord.ssid.pData,
  634. pLogDataInfo->m_wzcDbRecord.ssid.dwDataLen);
  635. csTemp.ReleaseBuffer();
  636. }
  637. else
  638. csTemp = _T("");
  639. GetDlgItem(IDC_LOGDATA_EDIT7)->SetWindowText(csTemp);
  640. if (NULL != pLogDataInfo->m_wzcDbRecord.context.pData)
  641. csTemp = (LPWSTR) pLogDataInfo->m_wzcDbRecord.context.pData;
  642. else
  643. csTemp = _T("");
  644. GetDlgItem(IDC_LOGDATA_EDIT8)->SetWindowText(csTemp);
  645. }
  646. void
  647. CLogDataGenProp::SetButtonIcon(
  648. HWND hwndBtn,
  649. ULONG ulIconID)
  650. {
  651. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  652. HICON hIcon = NULL;
  653. HICON hIconPrev = NULL;
  654. hIcon = (HICON) LoadImage(AfxGetInstanceHandle(),
  655. MAKEINTRESOURCE(ulIconID), IMAGE_ICON,
  656. 16, 16, LR_DEFAULTCOLOR);
  657. if (hIcon != NULL)
  658. {
  659. hIconPrev = (HICON) ::SendMessage(hwndBtn, BM_SETIMAGE,
  660. (WPARAM) IMAGE_ICON,
  661. (LPARAM) hIcon);
  662. if (hIconPrev != NULL)
  663. DestroyIcon(hIconPrev);
  664. }
  665. }
  666. void
  667. CLogDataGenProp::PopulateLogInfo()
  668. {
  669. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  670. CWnd *pWnd = NULL;
  671. CLogDataInfo *pLogDataInfo = NULL;
  672. CLogDataProperties *pLogDataProp = (CLogDataProperties *)GetHolder();
  673. Assert(pLogDataProp);
  674. pLogDataProp->GetLogDataInfo(&pLogDataInfo);
  675. //set fancy buttons
  676. pWnd = GetDlgItem(IDC_BTN_MOVE_UP);
  677. SetButtonIcon(pWnd->m_hWnd, IDI_LOG_UP_ARROW);
  678. pWnd = GetDlgItem(IDC_BTN_MOVE_DOWN);
  679. SetButtonIcon(pWnd->m_hWnd, IDI_LOG_DOWN_ARROW);
  680. pWnd = GetDlgItem(IDC_BTN_COPY);
  681. SetButtonIcon(pWnd->m_hWnd, IDI_LOG_COPY);
  682. ShowSpecificInfo(pLogDataInfo);
  683. }
  684. BOOL
  685. CLogDataGenProp::OnApply()
  686. {
  687. if (!IsDirty())
  688. return TRUE;
  689. UpdateData();
  690. //TODO
  691. //Do nothing at this time
  692. //CPropertyPageBase::OnApply();
  693. return TRUE;
  694. }
  695. BOOL
  696. CLogDataGenProp::OnPropertyChange(
  697. BOOL bScope,
  698. LONG_PTR *ChangeMask)
  699. {
  700. return FALSE;
  701. }