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.

4140 lines
86 KiB

  1. /*++
  2. Copyright (c) 1994-95 Microsoft Corporation
  3. Module Name:
  4. llsview.cpp
  5. Abstract:
  6. View window implementation.
  7. Author:
  8. Don Ryan (donryan) 12-Feb-1995
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. Jeff Parham (jeffparh) 16-Jan-1996
  13. o Ported to CCF API to add/remove licenses.
  14. o Added new element to LV_COLUMN_ENTRY to differentiate the string
  15. used for the column header from the string used in the menus
  16. (so that the menu option can contain hot keys).
  17. o Added better error message in case where a server being expanded
  18. in the server browser is not configured for the License Service.
  19. --*/
  20. #include "stdafx.h"
  21. #include "llsmgr.h"
  22. #include "llsdoc.h"
  23. #include "llsview.h"
  24. #include "prdpsht.h"
  25. #include "usrpsht.h"
  26. #include "mappsht.h"
  27. #include "srvpsht.h"
  28. #include "sdomdlg.h"
  29. #include "lmoddlg.h"
  30. #include "lgrpdlg.h"
  31. #include "nmapdlg.h"
  32. #include <strsafe.h>
  33. static const TCHAR szRegKeyLlsmgr[] = REG_KEY_LLSMGR;
  34. static const TCHAR szRegKeyLlsmgrMruList[] = REG_KEY_LLSMGR_MRU_LIST;
  35. static const TCHAR szRegKeyLlsmgrFontFaceName[] = REG_KEY_LLSMGR_FONT_FACENAME;
  36. static const TCHAR szRegKeyLlsmgrFontHeight[] = REG_KEY_LLSMGR_FONT_HEIGHT;
  37. static const TCHAR szRegKeyLlsmgrFontWeight[] = REG_KEY_LLSMGR_FONT_WEIGHT;
  38. static const TCHAR szRegKeyLlsmgrFontItalic[] = REG_KEY_LLSMGR_FONT_ITALIC;
  39. static const TCHAR szRegKeyLlsmgrSaveSettings[] = REG_KEY_LLSMGR_SAVE_SETTINGS;
  40. static const TCHAR szRegKeyLlsmgrFontCharset[] = REG_KEY_LLSMGR_FONT_CHARSET;
  41. static LV_COLUMN_INFO g_licenseColumnInfo = {
  42. 0, 1, LVID_PURCHASE_HISTORY_TOTAL_COLUMNS,
  43. {{LVID_SEPARATOR, 0, 0, 0 },
  44. {LVID_PURCHASE_HISTORY_DATE, IDS_DATE, IDS_DATE_MENUOPT, LVCX_PURCHASE_HISTORY_DATE },
  45. {LVID_PURCHASE_HISTORY_PRODUCT, IDS_PRODUCT, IDS_PRODUCT_MENUOPT, LVCX_PURCHASE_HISTORY_PRODUCT },
  46. {LVID_PURCHASE_HISTORY_QUANTITY, IDS_QUANTITY, IDS_QUANTITY_MENUOPT, LVCX_PURCHASE_HISTORY_QUANTITY },
  47. {LVID_PURCHASE_HISTORY_ADMINISTRATOR, IDS_ADMINISTRATOR, IDS_ADMINISTRATOR_MENUOPT, LVCX_PURCHASE_HISTORY_ADMINISTRATOR},
  48. {LVID_PURCHASE_HISTORY_COMMENT, IDS_COMMENT, IDS_COMMENT_MENUOPT, LVCX_PURCHASE_HISTORY_COMMENT }},
  49. };
  50. static LV_COLUMN_INFO g_productColumnInfo = {
  51. 0, 0, LVID_PRODUCTS_VIEW_TOTAL_COLUMNS,
  52. {{LVID_PRODUCTS_VIEW_NAME, IDS_PRODUCT, IDS_PRODUCT_MENUOPT, LVCX_PRODUCTS_VIEW_NAME },
  53. {LVID_PRODUCTS_VIEW_PER_SEAT_PURCHASED, IDS_PER_SEAT_PURCHASED, IDS_PER_SEAT_PURCHASED_MENUOPT, LVCX_PRODUCTS_VIEW_PER_SEAT_PURCHASED },
  54. {LVID_PRODUCTS_VIEW_PER_SEAT_CONSUMED, IDS_PER_SEAT_CONSUMED, IDS_PER_SEAT_CONSUMED_MENUOPT, LVCX_PRODUCTS_VIEW_PER_SEAT_CONSUMED },
  55. {LVID_PRODUCTS_VIEW_PER_SERVER_PURCHASED, IDS_PER_SERVER_PURCHASED, IDS_PER_SERVER_PURCHASED_MENUOPT, LVCX_PRODUCTS_VIEW_PER_SERVER_PURCHASED},
  56. {LVID_PRODUCTS_VIEW_PER_SERVER_REACHED, IDS_PER_SERVER_REACHED, IDS_PER_SERVER_REACHED_MENUOPT, LVCX_PRODUCTS_VIEW_PER_SERVER_REACHED }},
  57. };
  58. static LV_COLUMN_INFO g_userColumnInfo = {
  59. 0, 0, LVID_PER_SEAT_CLIENTS_TOTAL_COLUMNS,
  60. {{LVID_PER_SEAT_CLIENTS_NAME, IDS_USER_NAME, IDS_USER_NAME_MENUOPT, LVCX_PER_SEAT_CLIENTS_NAME },
  61. {LVID_PER_SEAT_CLIENTS_LICENSED_USAGE, IDS_LICENSED_USAGE, IDS_LICENSED_USAGE_MENUOPT, LVCX_PER_SEAT_CLIENTS_LICENSED_USAGE },
  62. {LVID_PER_SEAT_CLIENTS_UNLICENSED_USAGE, IDS_UNLICENSED_USAGE, IDS_UNLICENSED_USAGE_MENUOPT, LVCX_PER_SEAT_CLIENTS_UNLICENSED_USAGE},
  63. {LVID_PER_SEAT_CLIENTS_SERVER_PRODUCTS, IDS_PRODUCTS, IDS_PRODUCTS_MENUOPT, LVCX_PER_SEAT_CLIENTS_SERVER_PRODUCTS }},
  64. };
  65. static TC_TAB_INFO g_tcTabInfo = {
  66. TCID_TOTAL_TABS,
  67. {{TCID_PURCHASE_HISTORY, IDS_PURCHASE_HISTORY, TCE_LISTVIEW|TCE_FORMAT_REPORT|TCE_SUPPORTS_SORT, NULL, &g_licenseColumnInfo},
  68. {TCID_PRODUCTS_VIEW, IDS_PRODUCTS_VIEW, TCE_LISTVIEW|TCE_FORMAT_REPORT|TCE_SUPPORTS_ALL, NULL, &g_productColumnInfo},
  69. {TCID_PER_SEAT_CLIENTS, IDS_PER_SEAT_CLIENTS, TCE_LISTVIEW|TCE_FORMAT_REPORT|TCE_SUPPORTS_ALL, NULL, &g_userColumnInfo },
  70. {TCID_SERVER_BROWSER, IDS_SERVER_BROWSER, TCE_TREEVIEW|TCE_SUPPORTS_EDIT, NULL, NULL }},
  71. };
  72. #ifdef _DEBUG
  73. #undef THIS_FILE
  74. static char BASED_CODE THIS_FILE[] = __FILE__;
  75. #endif
  76. IMPLEMENT_DYNCREATE(CLlsmgrView, CView)
  77. BEGIN_MESSAGE_MAP(CLlsmgrView, CView)
  78. //{{AFX_MSG_MAP(CLlsmgrView)
  79. ON_WM_SIZE()
  80. ON_COMMAND(ID_SELECT_FONT, OnSelectFont)
  81. ON_COMMAND(ID_VIEW_LICENSES, OnViewLicenses)
  82. ON_COMMAND(ID_VIEW_MAPPINGS, OnViewMappings)
  83. ON_COMMAND(ID_VIEW_PRODUCTS, OnViewProducts)
  84. ON_COMMAND(ID_VIEW_SERVERS, OnViewServers)
  85. ON_COMMAND(ID_VIEW_USERS, OnViewUsers)
  86. ON_COMMAND(ID_VIEW_DELETE, OnDelete)
  87. ON_COMMAND(ID_VIEW_ICONS, OnFormatIcons)
  88. ON_COMMAND(MY_ID_VIEW_LIST, OnFormatList)
  89. ON_COMMAND(ID_VIEW_PROPERTIES, OnViewProperties)
  90. ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh)
  91. ON_COMMAND(ID_VIEW_REPORT, OnFormatReport)
  92. ON_COMMAND(ID_VIEW_SMALL_ICONS, OnFormatSmallIcons)
  93. ON_WM_CREATE()
  94. ON_COMMAND(ID_SORT_COLUMN0, OnSortColumn0)
  95. ON_COMMAND(ID_SORT_COLUMN1, OnSortColumn1)
  96. ON_COMMAND(ID_SORT_COLUMN2, OnSortColumn2)
  97. ON_COMMAND(ID_SORT_COLUMN3, OnSortColumn3)
  98. ON_COMMAND(ID_SORT_COLUMN4, OnSortColumn4)
  99. ON_COMMAND(ID_SORT_COLUMN5, OnSortColumn5)
  100. ON_COMMAND(ID_NEW_LICENSE, OnNewLicense)
  101. ON_COMMAND(ID_NEW_MAPPING, OnNewMapping)
  102. ON_COMMAND(ID_SELECT_DOMAIN, OnSelectDomain)
  103. ON_COMMAND(ID_SAVE_SETTINGS, OnSaveSettings)
  104. ON_UPDATE_COMMAND_UI(ID_SAVE_SETTINGS, OnUpdateSaveSettings)
  105. ON_UPDATE_COMMAND_UI(ID_VIEW_DELETE, OnUpdateViewDelete)
  106. ON_UPDATE_COMMAND_UI(ID_VIEW_PROPERTIES, OnUpdateViewProperties)
  107. ON_WM_ERASEBKGND()
  108. ON_WM_DESTROY()
  109. //}}AFX_MSG_MAP
  110. ON_NOTIFY(TCN_SELCHANGING, IDC_VIEW_TAB_CTRL, OnSelChangingTabCtrl)
  111. ON_NOTIFY(TCN_SELCHANGE, IDC_VIEW_TAB_CTRL, OnSelChangeTabCtrl)
  112. ON_NOTIFY(TCN_KEYDOWN, IDC_VIEW_TAB_CTRL, OnKeyDownTabCtrl)
  113. ON_NOTIFY(NM_SETFOCUS, IDC_VIEW_TAB_CTRL, OnSetFocusTabCtrl)
  114. ON_NOTIFY(LVN_KEYDOWN, IDC_VIEW_LICENSE_LIST, OnKeyDownLicenseList)
  115. ON_NOTIFY(LVN_COLUMNCLICK, IDC_VIEW_LICENSE_LIST, OnColumnClickLicenseList)
  116. ON_NOTIFY(LVN_GETDISPINFO, IDC_VIEW_LICENSE_LIST, OnGetDispInfoLicenseList)
  117. ON_NOTIFY(NM_SETFOCUS, IDC_VIEW_LICENSE_LIST, OnSetFocusLicenseList)
  118. ON_NOTIFY(LVN_KEYDOWN, IDC_VIEW_PRODUCT_LIST, OnKeyDownProductList)
  119. ON_NOTIFY(NM_DBLCLK, IDC_VIEW_PRODUCT_LIST, OnDblClkProductList)
  120. ON_NOTIFY(NM_RETURN, IDC_VIEW_PRODUCT_LIST, OnReturnProductList)
  121. ON_NOTIFY(LVN_COLUMNCLICK, IDC_VIEW_PRODUCT_LIST, OnColumnClickProductList)
  122. ON_NOTIFY(LVN_GETDISPINFO, IDC_VIEW_PRODUCT_LIST, OnGetDispInfoProductList)
  123. ON_NOTIFY(NM_SETFOCUS, IDC_VIEW_PRODUCT_LIST, OnSetFocusProductList)
  124. ON_NOTIFY(LVN_KEYDOWN, IDC_VIEW_USER_LIST, OnKeyDownUserList)
  125. ON_NOTIFY(NM_DBLCLK, IDC_VIEW_USER_LIST, OnDblClkUserList)
  126. ON_NOTIFY(NM_RETURN, IDC_VIEW_USER_LIST, OnReturnUserList)
  127. ON_NOTIFY(LVN_COLUMNCLICK, IDC_VIEW_USER_LIST, OnColumnClickUserList)
  128. ON_NOTIFY(LVN_GETDISPINFO, IDC_VIEW_USER_LIST, OnGetDispInfoUserList)
  129. ON_NOTIFY(NM_SETFOCUS, IDC_VIEW_USER_LIST, OnSetFocusUserList)
  130. ON_NOTIFY(TVN_KEYDOWN, IDC_VIEW_SERVER_TREE, OnKeyDownServerTree)
  131. ON_NOTIFY(NM_DBLCLK, IDC_VIEW_SERVER_TREE, OnDblClkServerTree)
  132. ON_NOTIFY(NM_RETURN, IDC_VIEW_SERVER_TREE, OnReturnServerTree)
  133. ON_NOTIFY(TVN_ITEMEXPANDING, IDC_VIEW_SERVER_TREE, OnItemExpandingServerTree)
  134. ON_NOTIFY(TVN_GETDISPINFO, IDC_VIEW_SERVER_TREE, OnGetDispInfoServerTree)
  135. ON_NOTIFY(NM_SETFOCUS, IDC_VIEW_SERVER_TREE, OnSetFocusServerTree)
  136. ON_MESSAGE(WM_CONTEXTMENU, OnContextMenu)
  137. ON_COMMAND_EX_RANGE(ID_MRU_DOMAIN0, ID_MRU_DOMAIN15, OnSelMruDomain)
  138. END_MESSAGE_MAP()
  139. CLlsmgrView::CLlsmgrView()
  140. /*++
  141. Routine Description:
  142. Constructor for view window.
  143. Arguments:
  144. None.
  145. Return Values:
  146. None.
  147. --*/
  148. {
  149. m_pTabEntry = g_tcTabInfo.tcTabEntry;
  150. m_bOrder = FALSE;
  151. LoadSettings();
  152. }
  153. CLlsmgrView::~CLlsmgrView()
  154. /*++
  155. Routine Description:
  156. Destructor for view window.
  157. Arguments:
  158. None.
  159. Return Values:
  160. None.
  161. --*/
  162. {
  163. SaveSettings();
  164. }
  165. void CLlsmgrView::AddToMRU(LPCTSTR lpszDomainName)
  166. /*++
  167. Routine Description:
  168. Adds domain to mru list.
  169. Arguments:
  170. lpszDomainName - domain of focus.
  171. Return Values:
  172. None.
  173. --*/
  174. {
  175. if (lpszDomainName && *lpszDomainName)
  176. {
  177. POSITION curPos;
  178. POSITION nextPos;
  179. nextPos = m_mruDomainList.GetHeadPosition();
  180. while (NULL != (curPos = nextPos))
  181. {
  182. CString strDomain = m_mruDomainList.GetNext(nextPos);
  183. if (!strDomain.CompareNoCase(lpszDomainName))
  184. m_mruDomainList.RemoveAt(curPos);
  185. }
  186. m_mruDomainList.AddHead(lpszDomainName);
  187. if (m_mruDomainList.GetCount() > MAX_MRU_ENTRIES)
  188. m_mruDomainList.RemoveTail();
  189. }
  190. }
  191. #ifdef _DEBUG
  192. void CLlsmgrView::AssertValid() const
  193. /*++
  194. Routine Description:
  195. Validates object.
  196. Arguments:
  197. None.
  198. Return Values:
  199. None.
  200. --*/
  201. {
  202. CView::AssertValid();
  203. }
  204. #endif //_DEBUG
  205. #ifdef _DEBUG
  206. void CLlsmgrView::Dump(CDumpContext& dc) const
  207. /*++
  208. Routine Description:
  209. Dumps contents of object.
  210. Arguments:
  211. dc - dump context.
  212. Return Values:
  213. None.
  214. --*/
  215. {
  216. CView::Dump(dc);
  217. }
  218. #endif //_DEBUG
  219. void CLlsmgrView::EnableCurSelTab(BOOL bEnable)
  220. /*++
  221. Routine Description:
  222. Enables or disables currently selected control.
  223. Arguments:
  224. bEnable - enable control if true.
  225. Return Values:
  226. None.
  227. --*/
  228. {
  229. if (bEnable)
  230. {
  231. m_pTabEntry = g_tcTabInfo.tcTabEntry + m_tabCtrl.GetCurSel();
  232. m_pTabEntry->pWnd->EnableWindow(TRUE);
  233. m_pTabEntry->pWnd->ShowWindow(SW_SHOW);
  234. m_pTabEntry->pWnd->UpdateWindow();
  235. if (!IsTabUpdated(m_pTabEntry))
  236. {
  237. DWORD fUpdateHint = UPDATE_INFO_NONE;
  238. switch (m_pTabEntry->iItem)
  239. {
  240. case TCID_PURCHASE_HISTORY:
  241. fUpdateHint = UPDATE_INFO_LICENSES;
  242. break;
  243. case TCID_PRODUCTS_VIEW:
  244. fUpdateHint = UPDATE_INFO_PRODUCTS;
  245. break;
  246. case TCID_PER_SEAT_CLIENTS:
  247. fUpdateHint = UPDATE_INFO_USERS;
  248. break;
  249. case TCID_SERVER_BROWSER:
  250. fUpdateHint = UPDATE_INFO_SERVERS;
  251. break;
  252. }
  253. OnUpdate(this, fUpdateHint, NULL);
  254. }
  255. }
  256. else
  257. {
  258. m_pTabEntry->pWnd->EnableWindow(FALSE);
  259. m_pTabEntry->pWnd->ShowWindow(SW_HIDE);
  260. }
  261. }
  262. #ifdef _DEBUG
  263. CLlsmgrDoc* CLlsmgrView::GetDocument()
  264. /*++
  265. Routine Description:
  266. Returns document object associated with view.
  267. Arguments:
  268. None.
  269. Return Values:
  270. Returns object pointer or NULL.
  271. --*/
  272. {
  273. VALIDATE_OBJECT(m_pDocument, CLlsmgrDoc);
  274. return (CLlsmgrDoc*)m_pDocument;
  275. }
  276. #endif //_DEBUG
  277. void CLlsmgrView::InitLicenseList()
  278. /*++
  279. Routine Description:
  280. Initializes license list control.
  281. Arguments:
  282. None.
  283. Return Values:
  284. None.
  285. --*/
  286. {
  287. CRect emptyRect;
  288. emptyRect.SetRectEmpty();
  289. m_licenseList.Create(
  290. WS_CHILD|
  291. WS_BORDER|
  292. WS_VISIBLE|
  293. WS_CLIPSIBLINGS|
  294. LVS_REPORT|
  295. LVS_SINGLESEL|
  296. LVS_SHOWSELALWAYS|
  297. LVS_SHAREIMAGELISTS|
  298. LVS_AUTOARRANGE,
  299. emptyRect,
  300. &m_tabCtrl,
  301. IDC_VIEW_LICENSE_LIST
  302. );
  303. ::LvInitColumns(&m_licenseList, &g_licenseColumnInfo);
  304. g_tcTabInfo.tcTabEntry[TCID_PURCHASE_HISTORY].pWnd = &m_licenseList;
  305. }
  306. void CLlsmgrView::InitProductList()
  307. /*++
  308. Routine Description:
  309. Initializes product list control.
  310. Arguments:
  311. None.
  312. Return Values:
  313. None.
  314. --*/
  315. {
  316. CRect emptyRect;
  317. emptyRect.SetRectEmpty();
  318. m_productList.Create(
  319. WS_CHILD|
  320. WS_BORDER|
  321. WS_DISABLED|
  322. WS_CLIPSIBLINGS|
  323. LVS_REPORT|
  324. LVS_SINGLESEL|
  325. LVS_SHOWSELALWAYS|
  326. LVS_SHAREIMAGELISTS|
  327. LVS_AUTOARRANGE,
  328. emptyRect,
  329. &m_tabCtrl,
  330. IDC_VIEW_PRODUCT_LIST
  331. );
  332. ::LvInitColumns(&m_productList, &g_productColumnInfo);
  333. g_tcTabInfo.tcTabEntry[TCID_PRODUCTS_VIEW].pWnd = &m_productList;
  334. }
  335. void CLlsmgrView::InitServerTree()
  336. /*++
  337. Routine Description:
  338. Initializes tree ctrl.
  339. Arguments:
  340. None.
  341. Return Values:
  342. None.
  343. --*/
  344. {
  345. CRect emptyRect;
  346. emptyRect.SetRectEmpty();
  347. m_serverTree.Create(
  348. WS_CHILD|
  349. WS_BORDER|
  350. WS_DISABLED|
  351. WS_CLIPSIBLINGS|
  352. TVS_LINESATROOT|
  353. TVS_HASBUTTONS|
  354. TVS_HASLINES|
  355. TVS_DISABLEDRAGDROP|
  356. TVS_SHOWSELALWAYS,
  357. emptyRect,
  358. &m_tabCtrl,
  359. IDC_VIEW_SERVER_TREE
  360. );
  361. m_serverTree.SetImageList(&theApp.m_smallImages, TVSIL_NORMAL);
  362. ::SetDefaultFont(&m_serverTree);
  363. g_tcTabInfo.tcTabEntry[TCID_SERVER_BROWSER].pWnd = &m_serverTree;
  364. }
  365. void CLlsmgrView::InitTabCtrl()
  366. /*++
  367. Routine Description:
  368. Initializes tab control.
  369. Arguments:
  370. None.
  371. Return Values:
  372. None.
  373. --*/
  374. {
  375. CRect emptyRect;
  376. emptyRect.SetRectEmpty();
  377. m_tabCtrl.Create(
  378. WS_CHILD|
  379. WS_VISIBLE|
  380. WS_CLIPCHILDREN|
  381. TCS_SINGLELINE|
  382. TCS_FOCUSONBUTTONDOWN|
  383. TCS_TABS,
  384. emptyRect,
  385. this,
  386. IDC_VIEW_TAB_CTRL
  387. );
  388. ::TcInitTabs(&m_tabCtrl, &g_tcTabInfo);
  389. }
  390. void CLlsmgrView::InitUserList()
  391. /*++
  392. Routine Description:
  393. Initializes user list control.
  394. Arguments:
  395. None.
  396. Return Values:
  397. None.
  398. --*/
  399. {
  400. CRect emptyRect;
  401. emptyRect.SetRectEmpty();
  402. m_userList.Create(
  403. WS_CHILD|
  404. WS_BORDER|
  405. WS_DISABLED|
  406. LVS_REPORT|
  407. LVS_SINGLESEL|
  408. LVS_SHOWSELALWAYS|
  409. LVS_SHAREIMAGELISTS|
  410. LVS_AUTOARRANGE,
  411. emptyRect,
  412. &m_tabCtrl,
  413. IDC_VIEW_USER_LIST
  414. );
  415. ::LvInitColumns(&m_userList, &g_userColumnInfo);
  416. g_tcTabInfo.tcTabEntry[TCID_PER_SEAT_CLIENTS].pWnd = &m_userList;
  417. }
  418. void CLlsmgrView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
  419. /*++
  420. Routine Description:
  421. Called by framework when view is activated.
  422. Arguments:
  423. bActivate - activated or deactivated.
  424. pActivateView - view being activated.
  425. pDeactiveView - view being deactivated.
  426. Return Values:
  427. None.
  428. --*/
  429. {
  430. UNREFERENCED_PARAMETER(pDeactiveView);
  431. if (bActivate && (pActivateView == this))
  432. {
  433. if (IsTabInFocus(m_pTabEntry))
  434. {
  435. m_tabCtrl.SetFocus();
  436. }
  437. else
  438. {
  439. m_pTabEntry->pWnd->SetFocus();
  440. }
  441. }
  442. }
  443. void CLlsmgrView::OnColumnClickLicenseList(NMHDR* pNMHDR, LRESULT* pResult)
  444. /*++
  445. Routine Description:
  446. Notification handler for LVN_COLUMNCLICK.
  447. Arguments:
  448. pNMHDR - notification header.
  449. pResult - return code.
  450. Return Values:
  451. None.
  452. --*/
  453. {
  454. //g_licenseColumnInfo.bSortOrder = GetKeyState(VK_CONTROL) < 0;
  455. g_licenseColumnInfo.bSortOrder = !g_licenseColumnInfo.bSortOrder;
  456. g_licenseColumnInfo.nSortedItem = ((NM_LISTVIEW*)pNMHDR)->iSubItem;
  457. m_licenseList.SortItems(CompareLicenses, 0); // use column info
  458. *pResult = 0;
  459. }
  460. void CLlsmgrView::OnDestroy()
  461. /*++
  462. Routine Description:
  463. Message handler for WM_DESTROY.
  464. Arguments:
  465. None.
  466. Return Values:
  467. None.
  468. --*/
  469. {
  470. ResetLicenseList();
  471. ResetProductList();
  472. ResetUserList();
  473. ResetServerTree();
  474. m_userList.DestroyWindow();
  475. m_serverTree.DestroyWindow();
  476. m_productList.DestroyWindow();
  477. m_licenseList.DestroyWindow();
  478. m_tabCtrl.DestroyWindow();
  479. CView::OnDestroy();
  480. }
  481. void CLlsmgrView::LoadSettings()
  482. /*++
  483. Routine Description:
  484. Load settings from registry.
  485. Arguments:
  486. None.
  487. Return Values:
  488. None.
  489. --*/
  490. {
  491. long Status;
  492. HKEY hKeyLlsmgr;
  493. HRESULT hr;
  494. m_bSaveSettings = TRUE;
  495. m_mruDomainList.RemoveAll();
  496. ZeroMemory(&m_lFont, sizeof(m_lFont));
  497. m_lFont.lfHeight = FONT_HEIGHT_DEFAULT;
  498. m_lFont.lfWeight = FONT_WEIGHT_DEFAULT;
  499. CHARSETINFO csi;
  500. DWORD dw = ::GetACP();
  501. if (!::TranslateCharsetInfo((DWORD*)UIntToPtr(dw), &csi, TCI_SRCCODEPAGE))
  502. csi.ciCharset = ANSI_CHARSET;
  503. m_lFont.lfCharSet = (BYTE)csi.ciCharset; // default charset
  504. hr = StringCbCopy(m_lFont.lfFaceName, sizeof(m_lFont.lfFaceName), TEXT("MS Shell Dlg"));
  505. ASSERT(SUCCEEDED(hr));
  506. Status = RegOpenKeyEx(HKEY_CURRENT_USER, szRegKeyLlsmgr, 0, KEY_READ, &hKeyLlsmgr);
  507. if (Status == ERROR_SUCCESS)
  508. {
  509. DWORD dwType;
  510. DWORD dwSize;
  511. DWORD dwValue;
  512. TCHAR szValue[512];
  513. //
  514. // Load save settings on exit
  515. //
  516. dwType = REG_DWORD;
  517. dwSize = sizeof(DWORD);
  518. if (!RegQueryValueEx(hKeyLlsmgr, szRegKeyLlsmgrSaveSettings, 0, &dwType, (LPBYTE)&dwValue, &dwSize))
  519. m_bSaveSettings = (BOOL)dwValue;
  520. //
  521. // Load font information
  522. //
  523. dwType = REG_DWORD;
  524. dwSize = sizeof(DWORD);
  525. if (!RegQueryValueEx(hKeyLlsmgr, szRegKeyLlsmgrFontHeight, 0, &dwType, (LPBYTE)&dwValue, &dwSize))
  526. m_lFont.lfHeight = ((LONG)dwValue > 0) ? -((LONG)dwValue) : 0;
  527. dwType = REG_DWORD;
  528. dwSize = sizeof(DWORD);
  529. if (!RegQueryValueEx(hKeyLlsmgr, szRegKeyLlsmgrFontWeight, 0, &dwType, (LPBYTE)&dwValue, &dwSize))
  530. m_lFont.lfWeight = ((LONG)dwValue > 0) ? ((LONG)dwValue) : 0;
  531. dwType = REG_DWORD;
  532. dwSize = sizeof(DWORD);
  533. if (!RegQueryValueEx(hKeyLlsmgr, szRegKeyLlsmgrFontItalic, 0, &dwType, (LPBYTE)&dwValue, &dwSize))
  534. {
  535. #pragma warning (push)
  536. #pragma warning (disable : 4244 ) // avoid W4 warning for loss of data from the following cast I would do *((BYTE*)&dwValue) however since it is a working code so I keep the cast here
  537. m_lFont.lfItalic = (BYTE)dwValue;
  538. #pragma warning (pop)
  539. }
  540. dwType = REG_SZ;
  541. dwSize = sizeof(szValue);
  542. if (!RegQueryValueEx(hKeyLlsmgr, szRegKeyLlsmgrFontFaceName, 0, &dwType, (LPBYTE)szValue, &dwSize))
  543. lstrcpyn(m_lFont.lfFaceName, szValue, 32);
  544. dwType = REG_DWORD;
  545. dwSize = sizeof(DWORD);
  546. if (!::RegQueryValueEx(hKeyLlsmgr, szRegKeyLlsmgrFontCharset, 0, &dwType, (LPBYTE)&dwValue, &dwSize))
  547. {
  548. #pragma warning (push)
  549. #pragma warning (disable : 4244 ) // avoid W4 warning for loss of data from the following cast I would do *((BYTE*)&dwValue) however since it is a working code so I keep the cast here
  550. m_lFont.lfCharSet = (BYTE)dwValue;
  551. #pragma warning (pop)
  552. }
  553. //
  554. // MRU domain list
  555. //
  556. dwType = REG_MULTI_SZ;
  557. dwSize = sizeof(szValue);
  558. if (!RegQueryValueEx(hKeyLlsmgr, szRegKeyLlsmgrMruList, 0, &dwType, (LPBYTE)szValue, &dwSize))
  559. {
  560. LPTSTR psz = szValue;
  561. while (*psz)
  562. {
  563. AddToMRU(psz);
  564. psz += lstrlen(psz) + 1;
  565. }
  566. }
  567. RegCloseKey(hKeyLlsmgr);
  568. }
  569. }
  570. void CLlsmgrView::OnColumnClickProductList(NMHDR* pNMHDR, LRESULT* pResult)
  571. /*++
  572. Routine Description:
  573. Notification handler for LVN_COLUMNCLICK.
  574. Arguments:
  575. pNMHDR - notification header.
  576. pResult - return code.
  577. Return Values:
  578. None.
  579. --*/
  580. {
  581. // g_productColumnInfo.bSortOrder = GetKeyState(VK_CONTROL) < 0;
  582. g_productColumnInfo.bSortOrder = !g_productColumnInfo.bSortOrder;
  583. ASSERT(NULL != pNMHDR);
  584. g_productColumnInfo.nSortedItem = ((NM_LISTVIEW*)pNMHDR)->iSubItem;
  585. m_productList.SortItems(CompareProducts, 0); // use column info
  586. ASSERT(NULL != pResult);
  587. *pResult = 0;
  588. }
  589. void CLlsmgrView::OnColumnClickUserList(NMHDR* pNMHDR, LRESULT* pResult)
  590. /*++
  591. Routine Description:
  592. Notification handler for LVN_COLUMNCLICK.
  593. Arguments:
  594. pNMHDR - notification header.
  595. pResult - return code.
  596. Return Values:
  597. None.
  598. --*/
  599. {
  600. // g_userColumnInfo.bSortOrder = GetKeyState(VK_CONTROL) < 0;
  601. g_userColumnInfo.bSortOrder = !g_userColumnInfo.bSortOrder;
  602. ASSERT(NULL != pNMHDR);
  603. g_userColumnInfo.nSortedItem = ((NM_LISTVIEW*)pNMHDR)->iSubItem;
  604. m_userList.SortItems(CompareUsers, 0); // use column info
  605. ASSERT(NULL != pResult);
  606. *pResult = 0;
  607. }
  608. LRESULT CLlsmgrView::OnContextMenu(WPARAM wParam, LPARAM lParam)
  609. /*++
  610. Routine Description:
  611. Message handler for WM_CONTEXTMENU.
  612. Arguments:
  613. wParam - control window handle.
  614. lParam - screen coordinates of mouse.
  615. Return Values:
  616. Returns 0 if successful.
  617. --*/
  618. {
  619. UNREFERENCED_PARAMETER(wParam);
  620. if (IsEditSupported(m_pTabEntry))
  621. {
  622. POINT pt;
  623. POINTS pts = MAKEPOINTS(lParam);
  624. pt.x = (long)(short)pts.x;
  625. pt.y = (long)(short)pts.y;
  626. CRect wndRect;
  627. m_pTabEntry->pWnd->GetWindowRect(wndRect);
  628. if (wndRect.PtInRect(pt) && IsItemSelected(m_pTabEntry))
  629. {
  630. CMenu optionMenu;
  631. optionMenu.LoadMenu(IDM_POPUP);
  632. CMenu* pPopupMenu = optionMenu.GetSubMenu(m_pTabEntry->iItem);
  633. if (pPopupMenu)
  634. {
  635. pPopupMenu->TrackPopupMenu(
  636. TPM_LEFTALIGN|
  637. TPM_RIGHTBUTTON,
  638. pt.x,
  639. pt.y,
  640. GetParentFrame(),
  641. NULL
  642. );
  643. }
  644. }
  645. }
  646. return 0;
  647. }
  648. BOOL CLlsmgrView::PreCreateWindow(CREATESTRUCT& cs)
  649. /*++
  650. Routine Description:
  651. Called by framework before window created.
  652. Arguments:
  653. cs - window creation information.
  654. Return Values:
  655. Returns 0 if successful.
  656. --*/
  657. {
  658. cs.style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
  659. return CView::PreCreateWindow(cs);
  660. }
  661. int CLlsmgrView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  662. /*++
  663. Routine Description:
  664. Message handler for WM_CREATE.
  665. Arguments:
  666. lpCreateStruct - window creation information.
  667. Return Values:
  668. Returns 0 if successful.
  669. --*/
  670. {
  671. if (CView::OnCreate(lpCreateStruct) == -1)
  672. return -1;
  673. InitTabCtrl();
  674. InitLicenseList();
  675. InitProductList();
  676. InitUserList();
  677. InitServerTree();
  678. CFont* pFont;
  679. pFont = CFont::FromHandle(::CreateFontIndirect(&m_lFont));
  680. if (NULL != pFont)
  681. {
  682. m_tabCtrl.SetFont(pFont);
  683. m_licenseList.SetFont(pFont);
  684. m_productList.SetFont(pFont);
  685. m_userList.SetFont(pFont);
  686. m_serverTree.SetFont(pFont);
  687. }
  688. return 0;
  689. }
  690. void CLlsmgrView::OnDblClkProductList(NMHDR* pNMHDR, LRESULT* pResult)
  691. /*++
  692. Routine Description:
  693. Notification handler for NM_DBLCLK.
  694. Arguments:
  695. pNMHDR - notification header.
  696. pResult - return code.
  697. Return Values:
  698. None.
  699. --*/
  700. {
  701. UNREFERENCED_PARAMETER(pNMHDR);
  702. ViewProductProperties();
  703. ASSERT(NULL != pResult);
  704. *pResult = 0;
  705. }
  706. void CLlsmgrView::OnDblClkServerTree(NMHDR* pNMHDR, LRESULT* pResult)
  707. /*++
  708. Routine Description:
  709. Notification handler for NM_DBLCLK.
  710. Arguments:
  711. pNMHDR - notification header.
  712. pResult - return code.
  713. Return Values:
  714. None.
  715. --*/
  716. {
  717. UNREFERENCED_PARAMETER(pNMHDR);
  718. CService* pService;
  719. pService = (CService*)::TvGetSelObj(&m_serverTree);
  720. if (NULL != pService)
  721. {
  722. ASSERT_VALID(pService);
  723. if (pService->IsKindOf(RUNTIME_CLASS(CService)))
  724. {
  725. ViewServerProperties(); // only support dblclk services
  726. }
  727. }
  728. ASSERT(NULL != pResult);
  729. *pResult = 0;
  730. }
  731. void CLlsmgrView::OnDblClkUserList(NMHDR* pNMHDR, LRESULT* pResult)
  732. /*++
  733. Routine Description:
  734. Notification handler for NM_DBLCLK.
  735. Arguments:
  736. pNMHDR - notification header.
  737. pResult - return code.
  738. Return Values:
  739. None.
  740. --*/
  741. {
  742. UNREFERENCED_PARAMETER(pNMHDR);
  743. ViewUserProperties();
  744. ASSERT(NULL != pResult);
  745. *pResult = 0;
  746. }
  747. void CLlsmgrView::OnDelete()
  748. /*++
  749. Routine Description:
  750. Message handler for ID_VIEW_DELETE.
  751. Arguments:
  752. None.
  753. Return Values:
  754. None.
  755. --*/
  756. {
  757. HRESULT hr;
  758. size_t cch;
  759. if (m_pTabEntry->iItem == TCID_PER_SEAT_CLIENTS)
  760. {
  761. CUser* pUser;
  762. CString strConfirm;
  763. pUser = (CUser*)::LvGetSelObj(&m_userList);
  764. if (NULL != pUser)
  765. {
  766. AfxFormatString1(strConfirm, IDP_CONFIRM_DELETE_USER, pUser->m_strName);
  767. if (AfxMessageBox(strConfirm, MB_YESNO) == IDYES)
  768. {
  769. NTSTATUS NtStatus;
  770. NtStatus = ::LlsUserDelete(
  771. LlsGetActiveHandle(),
  772. MKSTR(pUser->m_strName)
  773. );
  774. if (NtStatus == STATUS_OBJECT_NAME_NOT_FOUND)
  775. NtStatus = STATUS_SUCCESS;
  776. if (NT_SUCCESS(NtStatus))
  777. {
  778. OnUpdate(this, UPDATE_LICENSE_DELETED, NULL);
  779. }
  780. else
  781. {
  782. theApp.DisplayStatus(NtStatus);
  783. }
  784. }
  785. }
  786. }
  787. else if (m_pTabEntry->iItem == TCID_PRODUCTS_VIEW)
  788. {
  789. CProduct* pProduct;
  790. pProduct = (CProduct*)::LvGetSelObj(&m_productList);
  791. if (NULL != pProduct)
  792. {
  793. CController* pController = (CController*)MKOBJ(LlsGetApp()->GetActiveController());
  794. VALIDATE_OBJECT(pController, CController);
  795. BSTR pszUniServerName = pController->GetName();
  796. if ( NULL == pszUniServerName )
  797. {
  798. theApp.DisplayStatus( STATUS_NO_MEMORY );
  799. }
  800. else
  801. {
  802. cch = 1 + lstrlen(pszUniServerName);
  803. LPSTR pszAscServerName = (LPSTR) LocalAlloc( LMEM_FIXED, cch );
  804. if ( NULL == pszAscServerName )
  805. {
  806. theApp.DisplayStatus( STATUS_NO_MEMORY );
  807. }
  808. else
  809. {
  810. hr = StringCchPrintfA(pszAscServerName, cch, "%ls", pszUniServerName);
  811. ASSERT(SUCCEEDED(hr));
  812. LPSTR pszAscProductName = NULL;
  813. BSTR pszUniProductName = pProduct->GetName();
  814. if ( NULL != pszUniProductName )
  815. {
  816. cch = 1 + lstrlen( pszUniProductName );
  817. pszAscProductName = (LPSTR) LocalAlloc( LMEM_FIXED, cch );
  818. if ( NULL != pszAscProductName )
  819. {
  820. hr = StringCchPrintfA( pszAscProductName, cch, "%ls", pszUniProductName );
  821. ASSERT(SUCCEEDED(hr));
  822. }
  823. SysFreeString( pszUniProductName );
  824. }
  825. CCFCertificateRemoveUI( m_hWnd, pszAscServerName, pszAscProductName, pszAscProductName ? "Microsoft" : NULL, NULL, NULL );
  826. OnUpdate(this, UPDATE_LICENSE_DELETED, NULL);
  827. LocalFree( pszAscServerName );
  828. if ( NULL != pszAscProductName )
  829. {
  830. LocalFree( pszAscProductName );
  831. }
  832. }
  833. SysFreeString( pszUniServerName );
  834. }
  835. }
  836. }
  837. }
  838. void CLlsmgrView::OnDraw(CDC* pDC)
  839. /*++
  840. Routine Description:
  841. Message handler for WM_DRAW.
  842. Arguments:
  843. pDC - device context.
  844. Return Values:
  845. None.
  846. --*/
  847. {
  848. UNREFERENCED_PARAMETER(pDC);
  849. //
  850. // Nothing to do here...
  851. //
  852. }
  853. BOOL CLlsmgrView::OnEraseBkgnd(CDC* pDC)
  854. /*++
  855. Routine Description:
  856. Message handler for WM_ERASEBKGND.
  857. Arguments:
  858. pDC - device context.
  859. Return Values:
  860. None.
  861. --*/
  862. {
  863. CBrush grayBrush(RGB(192,192,192));
  864. CBrush* pOldBrush = pDC->SelectObject(&grayBrush);
  865. CRect clientRect;
  866. GetClientRect(clientRect);
  867. pDC->FillRect(clientRect, &grayBrush);
  868. pDC->SelectObject(pOldBrush);
  869. return TRUE;
  870. }
  871. void CLlsmgrView::OnFormatIcons()
  872. /*++
  873. Routine Description:
  874. Message handler for ID_VIEW_ICONS.
  875. Arguments:
  876. None.
  877. Return Values:
  878. None.
  879. --*/
  880. {
  881. if (IsFormatSupported(m_pTabEntry) && !IsFormatLargeIcons(m_pTabEntry))
  882. {
  883. VALIDATE_OBJECT(m_pTabEntry->pWnd, CWnd);
  884. ::LvChangeFormat((CListCtrl*)m_pTabEntry->pWnd, LVS_ICON);
  885. SetFormatLargeIcons(m_pTabEntry);
  886. }
  887. }
  888. void CLlsmgrView::OnFormatList()
  889. /*++
  890. Routine Description:
  891. Message handler for MY_ID_VIEW_LIST.
  892. Arguments:
  893. None.
  894. Return Values:
  895. None.
  896. --*/
  897. {
  898. if (IsFormatSupported(m_pTabEntry) && !IsFormatList(m_pTabEntry))
  899. {
  900. VALIDATE_OBJECT(m_pTabEntry->pWnd, CWnd);
  901. ::LvChangeFormat((CListCtrl*)m_pTabEntry->pWnd, LVS_LIST);
  902. SetFormatList(m_pTabEntry);
  903. }
  904. }
  905. void CLlsmgrView::OnFormatReport()
  906. /*++
  907. Routine Description:
  908. Message handler for ID_VIEW_REPORT.
  909. Arguments:
  910. None.
  911. Return Values:
  912. None.
  913. --*/
  914. {
  915. if (IsFormatSupported(m_pTabEntry) && !IsFormatReport(m_pTabEntry))
  916. {
  917. VALIDATE_OBJECT(m_pTabEntry->pWnd, CWnd);
  918. ::LvChangeFormat((CListCtrl*)m_pTabEntry->pWnd, LVS_REPORT);
  919. SetFormatReport(m_pTabEntry);
  920. }
  921. }
  922. void CLlsmgrView::OnFormatSmallIcons()
  923. /*++
  924. Routine Description:
  925. Message handler for ID_VIEW_SMALL_ICON
  926. Arguments:
  927. None.
  928. Return Values:
  929. None.
  930. --*/
  931. {
  932. if (IsFormatSupported(m_pTabEntry) && !IsFormatSmallIcons(m_pTabEntry))
  933. {
  934. VALIDATE_OBJECT(m_pTabEntry->pWnd, CWnd);
  935. ::LvChangeFormat((CListCtrl*)m_pTabEntry->pWnd, LVS_SMALLICON);
  936. SetFormatSmallIcons(m_pTabEntry);
  937. }
  938. }
  939. void CLlsmgrView::OnGetDispInfoLicenseList(NMHDR* pNMHDR, LRESULT* pResult)
  940. /*++
  941. Routine Description:
  942. Notification handler for LVN_GETDISPINFO.
  943. Arguments:
  944. pNMHDR - notification header.
  945. pResult - return code.
  946. Return Values:
  947. None.
  948. --*/
  949. {
  950. ASSERT(NULL != pNMHDR);
  951. LV_ITEM* plvItem = &((LV_DISPINFO*)pNMHDR)->item;
  952. ASSERT(plvItem);
  953. CLicense* pLicense = (CLicense*)plvItem->lParam;
  954. VALIDATE_OBJECT(pLicense, CLicense);
  955. switch (plvItem->iSubItem)
  956. {
  957. case LVID_SEPARATOR:
  958. {
  959. plvItem->iImage = 0;
  960. CString strLabel = _T("");
  961. lstrcpyn(plvItem->pszText, strLabel, plvItem->cchTextMax);
  962. }
  963. break;
  964. case LVID_PURCHASE_HISTORY_DATE:
  965. {
  966. BSTR bstrDate = pLicense->GetDateString();
  967. if(bstrDate != NULL )
  968. {
  969. lstrcpyn(plvItem->pszText, bstrDate, plvItem->cchTextMax);
  970. SysFreeString(bstrDate);
  971. }
  972. }
  973. break;
  974. case LVID_PURCHASE_HISTORY_PRODUCT:
  975. lstrcpyn(plvItem->pszText, pLicense->m_strProduct, plvItem->cchTextMax);
  976. break;
  977. case LVID_PURCHASE_HISTORY_QUANTITY:
  978. {
  979. CString strLabel;
  980. strLabel.Format(_T("%ld"), pLicense->m_lQuantity);
  981. lstrcpyn(plvItem->pszText, strLabel, plvItem->cchTextMax);
  982. }
  983. break;
  984. case LVID_PURCHASE_HISTORY_ADMINISTRATOR:
  985. lstrcpyn(plvItem->pszText, pLicense->m_strUser, plvItem->cchTextMax);
  986. break;
  987. case LVID_PURCHASE_HISTORY_COMMENT:
  988. lstrcpyn(plvItem->pszText, pLicense->m_strDescription, plvItem->cchTextMax);
  989. break;
  990. }
  991. ASSERT(NULL != pResult);
  992. *pResult = 0;
  993. }
  994. void CLlsmgrView::OnGetDispInfoProductList(NMHDR* pNMHDR, LRESULT* pResult)
  995. /*++
  996. Routine Description:
  997. Notification handler for LVN_GETDISPINFO.
  998. Arguments:
  999. pNMHDR - notification header.
  1000. pResult - return code.
  1001. Return Values:
  1002. None.
  1003. --*/
  1004. {
  1005. LV_ITEM* plvItem = &((LV_DISPINFO*)pNMHDR)->item;
  1006. ASSERT(plvItem);
  1007. CProduct* pProduct = (CProduct*)plvItem->lParam;
  1008. VALIDATE_OBJECT(pProduct, CProduct);
  1009. switch (plvItem->iSubItem)
  1010. {
  1011. case LVID_PRODUCTS_VIEW_NAME:
  1012. plvItem->iImage = CalcProductBitmap(pProduct);
  1013. lstrcpyn(plvItem->pszText, pProduct->m_strName, plvItem->cchTextMax);
  1014. break;
  1015. case LVID_PRODUCTS_VIEW_PER_SEAT_CONSUMED:
  1016. {
  1017. CString strLabel;
  1018. strLabel.Format(_T("%ld"), pProduct->m_lInUse);
  1019. lstrcpyn(plvItem->pszText, strLabel, plvItem->cchTextMax);
  1020. }
  1021. break;
  1022. case LVID_PRODUCTS_VIEW_PER_SEAT_PURCHASED:
  1023. {
  1024. CString strLabel;
  1025. strLabel.Format(_T("%ld"), pProduct->m_lLimit);
  1026. lstrcpyn(plvItem->pszText, strLabel, plvItem->cchTextMax);
  1027. }
  1028. break;
  1029. case LVID_PRODUCTS_VIEW_PER_SERVER_PURCHASED:
  1030. {
  1031. CString strLabel;
  1032. strLabel.Format(_T("%ld"), pProduct->m_lConcurrent);
  1033. lstrcpyn(plvItem->pszText, strLabel, plvItem->cchTextMax);
  1034. }
  1035. break;
  1036. case LVID_PRODUCTS_VIEW_PER_SERVER_REACHED:
  1037. {
  1038. CString strLabel;
  1039. strLabel.Format(_T("%ld"), pProduct->m_lHighMark);
  1040. lstrcpyn(plvItem->pszText, strLabel, plvItem->cchTextMax);
  1041. }
  1042. break;
  1043. }
  1044. ASSERT(NULL != pResult);
  1045. *pResult = 0;
  1046. }
  1047. void CLlsmgrView::OnGetDispInfoServerTree(NMHDR* pNMHDR, LRESULT* pResult)
  1048. /*++
  1049. Routine Description:
  1050. Notification handler for TVN_GETDISPINFO.
  1051. Arguments:
  1052. pNMHDR - notification header.
  1053. pResult - return code.
  1054. Return Values:
  1055. None.
  1056. --*/
  1057. {
  1058. ASSERT(NULL != pNMHDR);
  1059. TV_ITEM* ptvItem = &((TV_DISPINFO*)pNMHDR)->item;
  1060. CCmdTarget *pObject = (CCmdTarget*)ptvItem->lParam;
  1061. VALIDATE_OBJECT(pObject, CCmdTarget);
  1062. if (pObject->IsKindOf(RUNTIME_CLASS(CDomain)))
  1063. {
  1064. lstrcpyn(ptvItem->pszText, ((CDomain*)pObject)->m_strName, ptvItem->cchTextMax);
  1065. ptvItem->iImage = BMPI_DOMAIN;
  1066. ptvItem->iSelectedImage = ptvItem->iImage;
  1067. }
  1068. else if (pObject->IsKindOf(RUNTIME_CLASS(CServer)))
  1069. {
  1070. lstrcpyn(ptvItem->pszText, ((CServer*)pObject)->m_strName, ptvItem->cchTextMax);
  1071. ptvItem->iImage = BMPI_SERVER;
  1072. ptvItem->iSelectedImage = ptvItem->iImage;
  1073. }
  1074. else if (pObject->IsKindOf(RUNTIME_CLASS(CService)))
  1075. {
  1076. BSTR bstrServiceName = ((CService*)pObject)->GetDisplayName();
  1077. lstrcpyn(ptvItem->pszText, bstrServiceName, ptvItem->cchTextMax);
  1078. SysFreeString(bstrServiceName);
  1079. ptvItem->iImage = CalcServiceBitmap((CService*)pObject);
  1080. ptvItem->iSelectedImage = ptvItem->iImage;
  1081. }
  1082. ASSERT(NULL != pResult);
  1083. *pResult = 0;
  1084. }
  1085. void CLlsmgrView::OnGetDispInfoUserList(NMHDR* pNMHDR, LRESULT* pResult)
  1086. /*++
  1087. Routine Description:
  1088. Notification handler for LVN_GETDISPINFO.
  1089. Arguments:
  1090. pNMHDR - notification header.
  1091. pResult - return code.
  1092. Return Values:
  1093. None.
  1094. --*/
  1095. {
  1096. ASSERT(NULL != pNMHDR);
  1097. LV_ITEM* plvItem = &((LV_DISPINFO*)pNMHDR)->item;
  1098. ASSERT(plvItem);
  1099. CUser* pUser = (CUser*)plvItem->lParam;
  1100. VALIDATE_OBJECT(pUser, CUser);
  1101. switch (plvItem->iSubItem)
  1102. {
  1103. case LVID_PER_SEAT_CLIENTS_NAME:
  1104. plvItem->iImage = CalcUserBitmap(pUser);
  1105. lstrcpyn(plvItem->pszText, pUser->m_strName, plvItem->cchTextMax);
  1106. break;
  1107. case LVID_PER_SEAT_CLIENTS_LICENSED_USAGE:
  1108. {
  1109. CString strLabel;
  1110. strLabel.Format(_T("%ld"), pUser->m_lInUse);
  1111. lstrcpyn(plvItem->pszText, strLabel, plvItem->cchTextMax);
  1112. }
  1113. break;
  1114. case LVID_PER_SEAT_CLIENTS_UNLICENSED_USAGE:
  1115. {
  1116. CString strLabel;
  1117. strLabel.Format(_T("%ld"), pUser->m_lUnlicensed);
  1118. lstrcpyn(plvItem->pszText, strLabel, plvItem->cchTextMax);
  1119. }
  1120. break;
  1121. case LVID_PER_SEAT_CLIENTS_SERVER_PRODUCTS:
  1122. lstrcpyn(plvItem->pszText, pUser->m_strProducts, plvItem->cchTextMax);
  1123. break;
  1124. }
  1125. ASSERT(NULL != pResult);
  1126. *pResult = 0;
  1127. }
  1128. void CLlsmgrView::OnItemExpandingServerTree(NMHDR* pNMHDR, LRESULT* pResult)
  1129. /*++
  1130. Routine Description:
  1131. Notification handler for TVN_ITEMEXPANDING.
  1132. Arguments:
  1133. pNMHDR - notification header.
  1134. pResult - return code.
  1135. Return Values:
  1136. None.
  1137. --*/
  1138. {
  1139. ASSERT(NULL != pNMHDR);
  1140. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  1141. TV_ITEM tvItem = pNMTreeView->itemNew;
  1142. if (!(tvItem.state & TVIS_EXPANDEDONCE))
  1143. {
  1144. BeginWaitCursor();
  1145. CCmdTarget* pParent = (CCmdTarget*)tvItem.lParam;
  1146. VALIDATE_OBJECT(pParent, CCmdTarget);
  1147. VARIANT va;
  1148. VariantInit(&va);
  1149. BOOL bIsInserted = FALSE;
  1150. BOOL bDisplayError = TRUE;
  1151. if (pParent->IsKindOf(RUNTIME_CLASS(CApplication)))
  1152. {
  1153. CDomains* pDomains = (CDomains*)MKOBJ(((CApplication*)pParent)->GetDomains(va));
  1154. if (pDomains)
  1155. {
  1156. if (::TvInsertObArray(&m_serverTree, tvItem.hItem, pDomains->m_pObArray))
  1157. {
  1158. bIsInserted = TRUE;
  1159. }
  1160. pDomains->InternalRelease(); // objects AddRef'd individually
  1161. }
  1162. }
  1163. else if (pParent->IsKindOf(RUNTIME_CLASS(CDomain)))
  1164. {
  1165. CServers* pServers = (CServers*)MKOBJ(((CDomain*)pParent)->GetServers(va));
  1166. if (pServers)
  1167. {
  1168. if (::TvInsertObArray(&m_serverTree, tvItem.hItem, pServers->m_pObArray))
  1169. {
  1170. bIsInserted = TRUE;
  1171. }
  1172. pServers->InternalRelease(); // objects AddRef'd individually
  1173. }
  1174. }
  1175. else if (pParent->IsKindOf(RUNTIME_CLASS(CServer)))
  1176. {
  1177. CServices* pServices = (CServices*)MKOBJ(((CServer*)pParent)->GetServices(va));
  1178. if (pServices)
  1179. {
  1180. if (::TvInsertObArray(&m_serverTree, tvItem.hItem, pServices->m_pObArray, FALSE))
  1181. {
  1182. bIsInserted = TRUE;
  1183. }
  1184. pServices->InternalRelease(); // objects AddRef'd individually
  1185. }
  1186. else if ( ( ERROR_FILE_NOT_FOUND == LlsGetLastStatus() )
  1187. || ( STATUS_NOT_FOUND == LlsGetLastStatus() ) )
  1188. {
  1189. // license service not configured on the target server
  1190. AfxMessageBox( IDP_ERROR_SERVER_NOT_CONFIGURED, MB_OK | MB_ICONEXCLAMATION, 0 );
  1191. bDisplayError = FALSE;
  1192. }
  1193. }
  1194. EndWaitCursor();
  1195. if (!bIsInserted && bDisplayError)
  1196. {
  1197. theApp.DisplayLastStatus();
  1198. }
  1199. }
  1200. ASSERT(NULL != pResult);
  1201. *pResult = 0;
  1202. }
  1203. void CLlsmgrView::OnInitialUpdate()
  1204. /*++
  1205. Routine Description:
  1206. Called by framework after the view is first attached
  1207. to the document but before it is initially displayed.
  1208. Arguments:
  1209. None.
  1210. Return Values:
  1211. None.
  1212. --*/
  1213. {
  1214. if (LlsGetApp()->IsConnected())
  1215. {
  1216. OnUpdate(this, UPDATE_MAIN_TABS, NULL);
  1217. }
  1218. }
  1219. void CLlsmgrView::OnKeyDownLicenseList(NMHDR* pNMHDR, LRESULT* pResult)
  1220. /*++
  1221. Routine Description:
  1222. Notification handler for LVN_KEYDOWN.
  1223. Arguments:
  1224. pNMHDR - notification header.
  1225. pResult - return code.
  1226. Return Values:
  1227. None.
  1228. --*/
  1229. {
  1230. ASSERT(NULL != pNMHDR);
  1231. if (((LV_KEYDOWN*)pNMHDR)->wVKey == VK_TAB)
  1232. {
  1233. m_tabCtrl.SetFocus();
  1234. }
  1235. ASSERT(NULL != pResult);
  1236. *pResult = 0;
  1237. }
  1238. void CLlsmgrView::OnKeyDownProductList(NMHDR* pNMHDR, LRESULT* pResult)
  1239. /*++
  1240. Routine Description:
  1241. Notification handler for LVN_KEYDOWN.
  1242. Arguments:
  1243. pNMHDR - notification header.
  1244. pResult - return code.
  1245. Return Values:
  1246. None.
  1247. --*/
  1248. {
  1249. ASSERT(NULL != pNMHDR);
  1250. if (((LV_KEYDOWN*)pNMHDR)->wVKey == VK_TAB)
  1251. {
  1252. m_tabCtrl.SetFocus();
  1253. }
  1254. ASSERT(NULL != pResult);
  1255. *pResult = 0;
  1256. }
  1257. void CLlsmgrView::OnKeyDownServerTree(NMHDR* pNMHDR, LRESULT* pResult)
  1258. /*++
  1259. Routine Description:
  1260. Notification handler for TVN_KEYDOWN.
  1261. Arguments:
  1262. pNMHDR - notification header.
  1263. pResult - return code.
  1264. Return Values:
  1265. None.
  1266. --*/
  1267. {
  1268. ASSERT(NULL != pNMHDR);
  1269. if (((TV_KEYDOWN*)pNMHDR)->wVKey == VK_TAB)
  1270. {
  1271. m_tabCtrl.SetFocus();
  1272. }
  1273. ASSERT(NULL != pResult);
  1274. *pResult = TRUE;
  1275. }
  1276. void CLlsmgrView::OnKeyDownTabCtrl(NMHDR* pNMHDR, LRESULT* pResult)
  1277. /*++
  1278. Routine Description:
  1279. Notification handler for TCN_KEYDOWN.
  1280. Arguments:
  1281. pNMHDR - notification header.
  1282. pResult - return code.
  1283. Return Values:
  1284. None.
  1285. --*/
  1286. {
  1287. ASSERT(NULL != pNMHDR);
  1288. TC_KEYDOWN* tcKeyDown = (TC_KEYDOWN*)pNMHDR;
  1289. if (tcKeyDown->wVKey == VK_TAB)
  1290. {
  1291. m_pTabEntry->pWnd->SetFocus();
  1292. }
  1293. else if ((tcKeyDown->wVKey == VK_LEFT) &&
  1294. (m_pTabEntry->iItem == TCID_PURCHASE_HISTORY))
  1295. {
  1296. PostMessage(WM_COMMAND, ID_VIEW_SERVERS);
  1297. }
  1298. else if ((tcKeyDown->wVKey == VK_RIGHT) &&
  1299. (m_pTabEntry->iItem == TCID_SERVER_BROWSER))
  1300. {
  1301. PostMessage(WM_COMMAND, ID_VIEW_LICENSES);
  1302. }
  1303. ASSERT(NULL != pResult);
  1304. *pResult = 0;
  1305. }
  1306. void CLlsmgrView::OnKeyDownUserList(NMHDR* pNMHDR, LRESULT* pResult)
  1307. /*++
  1308. Routine Description:
  1309. Notification handler for LVN_KEYDOWN.
  1310. Arguments:
  1311. pNMHDR - notification header.
  1312. pResult - return code.
  1313. Return Values:
  1314. None.
  1315. --*/
  1316. {
  1317. ASSERT(NULL != pNMHDR);
  1318. if (((LV_KEYDOWN*)pNMHDR)->wVKey == VK_TAB)
  1319. {
  1320. m_tabCtrl.SetFocus();
  1321. }
  1322. ASSERT(NULL != pResult);
  1323. *pResult = 0;
  1324. }
  1325. void CLlsmgrView::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
  1326. /*++
  1327. Routine Description:
  1328. Message handler for WM_INITMENU.
  1329. Arguments:
  1330. pPopupMenu - menu object.
  1331. nIndex - menu position.
  1332. bSysMenu - true if system menu.
  1333. Return Values:
  1334. None.
  1335. --*/
  1336. {
  1337. #define SUBMENU_LICENSE 0
  1338. #define SUBMENU_LICENSE_DELETE 2
  1339. #define SUBMENU_LICENSE_PROPERTIES 3
  1340. #define SUBMENU_LICENSE_INSERT_MRU 7
  1341. #define SUBMENU_LICENSE_ITEM_ID0 ID_NEW_LICENSE
  1342. #define SUBMENU_OPTIONS 2
  1343. #define SUBMENU_OPTIONS_FORMAT 2
  1344. #define SUBMENU_OPTIONS_SORTBY 3
  1345. #define SUBMENU_OPTIONS_ITEM_ID0 ID_SELECT_FONT
  1346. #define SUBMENU_FORMAT_LARGE_ICON 0
  1347. #define SUBMENU_FORMAT_SMALL_ICON 1
  1348. #define SUBMENU_FORMAT_LIST 2
  1349. #define SUBMENU_FORMAT_DETAILS 3
  1350. if (bSysMenu)
  1351. return; // bail...
  1352. if ((nIndex != SUBMENU_LICENSE) && (nIndex != SUBMENU_OPTIONS))
  1353. return; // bail...
  1354. ASSERT(NULL != pPopupMenu);
  1355. int nMenuItemId = pPopupMenu->GetMenuItemID(0); // check first item
  1356. if (nMenuItemId == SUBMENU_LICENSE_ITEM_ID0)
  1357. {
  1358. UINT CmdId;
  1359. UINT MenuId;
  1360. CmdId = ID_MRU_DOMAIN0;
  1361. while (pPopupMenu->RemoveMenu(CmdId++, MF_BYCOMMAND))
  1362. ;
  1363. POSITION position;
  1364. position = m_mruDomainList.GetHeadPosition();
  1365. CmdId = ID_MRU_DOMAIN0;
  1366. MenuId = SUBMENU_LICENSE_INSERT_MRU;
  1367. while (position)
  1368. {
  1369. TCHAR num[10];
  1370. HRESULT hr;
  1371. hr = StringCbPrintf(num, sizeof(num), _T("&%d "), CmdId - ID_MRU_DOMAIN0 + 1);
  1372. ASSERT(SUCCEEDED(hr));
  1373. CString strDomain = m_mruDomainList.GetNext(position);
  1374. pPopupMenu->InsertMenu(MenuId++, MF_BYPOSITION, CmdId++, CString(num) + strDomain);
  1375. }
  1376. }
  1377. else if (nMenuItemId == SUBMENU_OPTIONS_ITEM_ID0)
  1378. {
  1379. UINT fEnableFormat = IsFormatSupported(m_pTabEntry) ? MF_ENABLED : MF_GRAYED;
  1380. UINT fEnableSortBy = IsSortSupported(m_pTabEntry) ? MF_ENABLED : MF_GRAYED;
  1381. pPopupMenu->EnableMenuItem(SUBMENU_OPTIONS_FORMAT, MF_BYPOSITION|fEnableFormat);
  1382. pPopupMenu->EnableMenuItem(SUBMENU_OPTIONS_SORTBY, MF_BYPOSITION|fEnableSortBy);
  1383. if (fEnableSortBy == MF_ENABLED)
  1384. {
  1385. ASSERT(m_pTabEntry->plvColumnInfo);
  1386. PLV_COLUMN_ENTRY plvColumnEntry = m_pTabEntry->plvColumnInfo->lvColumnEntry;
  1387. CMenu* pSortByMenu = pPopupMenu->GetSubMenu(SUBMENU_OPTIONS_SORTBY);
  1388. while (pSortByMenu->RemoveMenu(0, MF_BYPOSITION))
  1389. ;
  1390. int index;
  1391. int nStringId;
  1392. CString strMenu;
  1393. for (index = 0; index < m_pTabEntry->plvColumnInfo->nColumns; index++)
  1394. {
  1395. nStringId = plvColumnEntry->nMenuStringId;
  1396. if (0 < nStringId)
  1397. {
  1398. strMenu.LoadString(nStringId);
  1399. pSortByMenu->AppendMenu(MF_STRING, ID_SORT_COLUMN0+index, strMenu);
  1400. }
  1401. plvColumnEntry++;
  1402. }
  1403. pSortByMenu->CheckMenuItem(ID_SORT_COLUMN0+m_pTabEntry->plvColumnInfo->nSortedItem, MF_BYCOMMAND|MF_CHECKED);
  1404. }
  1405. if (fEnableFormat == MF_ENABLED)
  1406. {
  1407. CMenu* pFormatMenu = pPopupMenu->GetSubMenu(SUBMENU_OPTIONS_FORMAT);
  1408. pFormatMenu->CheckMenuItem(SUBMENU_FORMAT_LARGE_ICON, MF_BYPOSITION|(IsFormatLargeIcons(m_pTabEntry) ? MF_CHECKED : MF_UNCHECKED));
  1409. pFormatMenu->CheckMenuItem(SUBMENU_FORMAT_SMALL_ICON, MF_BYPOSITION|(IsFormatSmallIcons(m_pTabEntry) ? MF_CHECKED : MF_UNCHECKED));
  1410. pFormatMenu->CheckMenuItem(SUBMENU_FORMAT_LIST , MF_BYPOSITION|(IsFormatList(m_pTabEntry) ? MF_CHECKED : MF_UNCHECKED));
  1411. pFormatMenu->CheckMenuItem(SUBMENU_FORMAT_DETAILS , MF_BYPOSITION|(IsFormatReport(m_pTabEntry) ? MF_CHECKED : MF_UNCHECKED));
  1412. }
  1413. }
  1414. }
  1415. void CLlsmgrView::OnNewLicense()
  1416. /*++
  1417. Routine Description:
  1418. Message handler for ID_NEW_LICENSE.
  1419. Arguments:
  1420. None.
  1421. Return Values:
  1422. None.
  1423. --*/
  1424. {
  1425. HRESULT hr;
  1426. size_t cch;
  1427. CController* pController = (CController*)MKOBJ(LlsGetApp()->GetActiveController());
  1428. VALIDATE_OBJECT(pController, CController);
  1429. BSTR pszUniServerName = pController->GetName();
  1430. if ( NULL == pszUniServerName )
  1431. {
  1432. theApp.DisplayStatus( STATUS_NO_MEMORY );
  1433. }
  1434. else
  1435. {
  1436. cch = 1 + lstrlen( pszUniServerName );
  1437. LPSTR pszAscServerName = (LPSTR) LocalAlloc( LMEM_FIXED, cch );
  1438. if ( NULL == pszAscServerName )
  1439. {
  1440. theApp.DisplayStatus( STATUS_NO_MEMORY );
  1441. }
  1442. else
  1443. {
  1444. hr = StringCchPrintfA( pszAscServerName, cch, "%ls", pszUniServerName );
  1445. ASSERT(SUCCEEDED(hr));
  1446. LPSTR pszAscProductName = NULL;
  1447. if ( m_pTabEntry->iItem == TCID_PRODUCTS_VIEW )
  1448. {
  1449. CProduct* pProduct = (CProduct*) ::LvGetSelObj(&m_productList);
  1450. if ( NULL != pProduct )
  1451. {
  1452. BSTR pszUniProductName = pProduct->GetName();
  1453. if ( NULL != pszUniProductName )
  1454. {
  1455. cch = 1 + lstrlen( pszUniProductName );
  1456. pszAscProductName = (LPSTR) LocalAlloc( LMEM_FIXED, cch );
  1457. if ( NULL != pszAscProductName )
  1458. {
  1459. hr = StringCchPrintfA( pszAscProductName, cch, "%ls", pszUniProductName );
  1460. ASSERT(SUCCEEDED(hr));
  1461. }
  1462. SysFreeString( pszUniProductName );
  1463. }
  1464. }
  1465. }
  1466. DWORD dwError = CCFCertificateEnterUI( m_hWnd, pszAscServerName, pszAscProductName, pszAscProductName ? "Microsoft" : NULL, CCF_ENTER_FLAG_PER_SEAT_ONLY | CCF_ENTER_FLAG_SERVER_IS_ES, NULL );
  1467. DWORD fUpdateHint;
  1468. if ( ERROR_SUCCESS == dwError )
  1469. {
  1470. fUpdateHint = UPDATE_LICENSE_ADDED;
  1471. }
  1472. else
  1473. {
  1474. fUpdateHint = UPDATE_INFO_NONE;
  1475. }
  1476. OnUpdate(this, fUpdateHint, NULL);
  1477. LocalFree( pszAscServerName );
  1478. if ( NULL != pszAscProductName )
  1479. {
  1480. LocalFree( pszAscProductName );
  1481. }
  1482. }
  1483. SysFreeString( pszUniServerName );
  1484. }
  1485. }
  1486. void CLlsmgrView::OnNewMapping()
  1487. /*++
  1488. Routine Description:
  1489. Message handler for ID_NEW_MAPPING.
  1490. Arguments:
  1491. None.
  1492. Return Values:
  1493. None.
  1494. --*/
  1495. {
  1496. CNewMappingDialog newmDlg;
  1497. newmDlg.DoModal();
  1498. OnUpdate(this, newmDlg.m_fUpdateHint, NULL);
  1499. }
  1500. void CLlsmgrView::OnReturnProductList(NMHDR* pNMHDR, LRESULT* pResult)
  1501. /*++
  1502. Routine Description:
  1503. Notification handler for NM_RETURN.
  1504. Arguments:
  1505. pNMHDR - notification header.
  1506. pResult - return code.
  1507. Return Values:
  1508. None.
  1509. --*/
  1510. {
  1511. UNREFERENCED_PARAMETER(pNMHDR);
  1512. ViewProductProperties();
  1513. ASSERT(NULL != pResult);
  1514. *pResult = 0;
  1515. }
  1516. void CLlsmgrView::OnReturnServerTree(NMHDR* pNMHDR, LRESULT* pResult)
  1517. /*++
  1518. Routine Description:
  1519. Notification handler for NM_RETURN.
  1520. Arguments:
  1521. pNMHDR - notification header.
  1522. pResult - return code.
  1523. Return Values:
  1524. None.
  1525. --*/
  1526. {
  1527. UNREFERENCED_PARAMETER(pNMHDR);
  1528. ViewServerProperties();
  1529. ASSERT(NULL != pResult);
  1530. *pResult = 0;
  1531. }
  1532. void CLlsmgrView::OnReturnUserList(NMHDR* pNMHDR, LRESULT* pResult)
  1533. /*++
  1534. Routine Description:
  1535. Notification handler for NM_RETURN.
  1536. Arguments:
  1537. pNMHDR - notification header.
  1538. pResult - return code.
  1539. Return Values:
  1540. None.
  1541. --*/
  1542. {
  1543. UNREFERENCED_PARAMETER(pNMHDR);
  1544. ViewUserProperties();
  1545. ASSERT(NULL != pResult);
  1546. *pResult = 0;
  1547. }
  1548. void CLlsmgrView::OnSaveSettings()
  1549. /*++
  1550. Routine Description:
  1551. Message handler for ID_SAVE_SETTINGS.
  1552. Arguments:
  1553. None.
  1554. Return Values:
  1555. None.
  1556. --*/
  1557. {
  1558. m_bSaveSettings = !m_bSaveSettings;
  1559. }
  1560. void CLlsmgrView::OnSelChangeTabCtrl(NMHDR* pNMHDR, LRESULT* pResult)
  1561. /*++
  1562. Routine Description:
  1563. Notification handler for TCN_SELCHANGE.
  1564. Arguments:
  1565. pNMHDR - notification header.
  1566. pResult - return code.
  1567. Return Values:
  1568. None.
  1569. --*/
  1570. {
  1571. UNREFERENCED_PARAMETER(pNMHDR);
  1572. EnableCurSelTab(TRUE);
  1573. ASSERT(NULL != pResult);
  1574. *pResult = 0;
  1575. }
  1576. void CLlsmgrView::OnSelChangingTabCtrl(NMHDR* pNMHDR, LRESULT* pResult)
  1577. /*++
  1578. Routine Description:
  1579. Notification handler for TCN_SELCHANGING.
  1580. Arguments:
  1581. pNMHDR - notification header.
  1582. pResult - return code.
  1583. Return Values:
  1584. None.
  1585. --*/
  1586. {
  1587. UNREFERENCED_PARAMETER(pNMHDR);
  1588. EnableCurSelTab(FALSE);
  1589. ASSERT(NULL != pResult);
  1590. *pResult = 0;
  1591. }
  1592. void CLlsmgrView::OnSelectDomain()
  1593. /*++
  1594. Routine Description:
  1595. Message handler for ID_SELECT_DOMAIN.
  1596. Arguments:
  1597. None.
  1598. Return Values:
  1599. None.
  1600. --*/
  1601. {
  1602. CSelectDomainDialog domainDlg;
  1603. domainDlg.DoModal();
  1604. OnUpdate(this, domainDlg.m_fUpdateHint, NULL);
  1605. }
  1606. void CLlsmgrView::OnSelectFont()
  1607. /*++
  1608. Routine Description:
  1609. Message handler for ID_SELECT_FONT.
  1610. Arguments:
  1611. None.
  1612. Return Values:
  1613. None.
  1614. --*/
  1615. {
  1616. LOGFONT lFont = m_lFont;
  1617. CFontDialog fontDlg(&lFont, CF_SCREENFONTS|CF_LIMITSIZE, NULL, NULL);
  1618. fontDlg.m_cf.nSizeMin = 8;
  1619. fontDlg.m_cf.nSizeMax = 20;
  1620. if (fontDlg.DoModal() == IDOK)
  1621. {
  1622. CFont* pNewFont;
  1623. if (!*(m_lFont.lfFaceName))
  1624. lFont.lfCharSet = m_lFont.lfCharSet;
  1625. pNewFont = CFont::FromHandle(::CreateFontIndirect(&lFont));
  1626. if (NULL != pNewFont)
  1627. {
  1628. m_lFont = lFont;
  1629. BeginWaitCursor();
  1630. m_tabCtrl.SetFont(pNewFont);
  1631. m_licenseList.SetFont(pNewFont);
  1632. m_productList.SetFont(pNewFont);
  1633. m_userList.SetFont(pNewFont);
  1634. m_serverTree.SetFont(pNewFont);
  1635. EndWaitCursor();
  1636. }
  1637. }
  1638. }
  1639. BOOL CLlsmgrView::OnSelMruDomain(UINT nID)
  1640. /*++
  1641. Routine Description:
  1642. Message handler for ID_MRU_DOMAIN*.
  1643. Arguments:
  1644. nID - id of domain.
  1645. Return Values:
  1646. Returns true always.
  1647. --*/
  1648. {
  1649. POSITION position;
  1650. position = m_mruDomainList.FindIndex(nID - ID_MRU_DOMAIN0);
  1651. if (NULL != position)
  1652. theApp.OpenDocumentFile(m_mruDomainList.GetAt(position));
  1653. return TRUE;
  1654. }
  1655. void CLlsmgrView::OnSetFocusLicenseList(NMHDR* pNMHDR, LRESULT* pResult)
  1656. /*++
  1657. Routine Description:
  1658. Notification handler for NM_SETFOCUS.
  1659. Arguments:
  1660. pNMHDR - notification header.
  1661. pResult - return code.
  1662. Return Values:
  1663. None.
  1664. --*/
  1665. {
  1666. UNREFERENCED_PARAMETER(pNMHDR);
  1667. ClrTabInFocus(m_pTabEntry);
  1668. ASSERT(NULL != pResult);
  1669. *pResult = 0;
  1670. }
  1671. void CLlsmgrView::OnSetFocusProductList(NMHDR* pNMHDR, LRESULT* pResult)
  1672. /*++
  1673. Routine Description:
  1674. Notification handler for NM_SETFOCUS.
  1675. Arguments:
  1676. pNMHDR - notification header.
  1677. pResult - return code.
  1678. Return Values:
  1679. None.
  1680. --*/
  1681. {
  1682. UNREFERENCED_PARAMETER(pNMHDR);
  1683. ClrTabInFocus(m_pTabEntry);
  1684. ASSERT(NULL != pResult);
  1685. *pResult = 0;
  1686. }
  1687. void CLlsmgrView::OnSetFocusTabCtrl(NMHDR* pNMHDR, LRESULT* pResult)
  1688. /*++
  1689. Routine Description:
  1690. Notification handler for NM_SETFOCUS.
  1691. Arguments:
  1692. pNMHDR - notification header.
  1693. pResult - return code.
  1694. Return Values:
  1695. None.
  1696. --*/
  1697. {
  1698. UNREFERENCED_PARAMETER(pNMHDR);
  1699. SetTabInFocus(m_pTabEntry);
  1700. ASSERT(NULL != pResult);
  1701. *pResult = 0;
  1702. }
  1703. void CLlsmgrView::OnSetFocusServerTree(NMHDR* pNMHDR, LRESULT* pResult)
  1704. /*++
  1705. Routine Description:
  1706. Notification handler for NM_SETFOCUS.
  1707. Arguments:
  1708. pNMHDR - notification header.
  1709. pResult - return code.
  1710. Return Values:
  1711. None.
  1712. --*/
  1713. {
  1714. UNREFERENCED_PARAMETER(pNMHDR);
  1715. ClrTabInFocus(m_pTabEntry);
  1716. ASSERT(NULL != pResult);
  1717. *pResult = 0;
  1718. }
  1719. void CLlsmgrView::OnSetFocusUserList(NMHDR* pNMHDR, LRESULT* pResult)
  1720. /*++
  1721. Routine Description:
  1722. Notification handler for NM_SETFOCUS.
  1723. Arguments:
  1724. pNMHDR - notification header.
  1725. pResult - return code.
  1726. Return Values:
  1727. None.
  1728. --*/
  1729. {
  1730. UNREFERENCED_PARAMETER(pNMHDR);
  1731. ClrTabInFocus(m_pTabEntry);
  1732. ASSERT(NULL != pResult);
  1733. *pResult = 0;
  1734. }
  1735. void CLlsmgrView::OnSize(UINT nType, int cx, int cy)
  1736. /*++
  1737. Routine Description:
  1738. Message handler for WM_SIZE.
  1739. Arguments:
  1740. nType - type of resizing.
  1741. cx - new width of client area.
  1742. cy - new height of client area.
  1743. Return Values:
  1744. None.
  1745. --*/
  1746. {
  1747. int x, y;
  1748. CView::OnSize(nType, cx, cy);
  1749. #define INDENT_FROM_FRAME 5
  1750. #define INDENT_FROM_TAB_CTRL 10
  1751. if (m_tabCtrl.GetSafeHwnd())
  1752. {
  1753. CRect clientRect;
  1754. GetClientRect(clientRect);
  1755. x = INDENT_FROM_FRAME;
  1756. y = INDENT_FROM_FRAME;
  1757. cx = clientRect.Width() - ((2 * x) + 1);
  1758. cy = clientRect.Height() - ((2 * y) + 1);
  1759. m_tabCtrl.MoveWindow(x, y, cx, cy, TRUE);
  1760. RECT tabRect;
  1761. m_tabCtrl.GetClientRect(clientRect);
  1762. m_tabCtrl.GetItemRect(0, &tabRect);
  1763. int tabHeight = tabRect.bottom - tabRect.top;
  1764. x = INDENT_FROM_TAB_CTRL;
  1765. y = (2 * tabHeight);
  1766. cx = clientRect.Width() - ((2 * x) + 1);
  1767. cy = clientRect.Height() - ((2 * tabHeight) + INDENT_FROM_TAB_CTRL + 1);
  1768. m_licenseList.MoveWindow(x, y, cx, cy, TRUE);
  1769. m_productList.MoveWindow(x, y, cx, cy, TRUE);
  1770. m_userList.MoveWindow (x, y, cx, cy, TRUE);
  1771. m_serverTree.MoveWindow (x, y, cx, cy, TRUE);
  1772. RecalcListColumns();
  1773. }
  1774. }
  1775. void CLlsmgrView::OnSortColumn(int iColumn)
  1776. /*++
  1777. Routine Description:
  1778. Sort dispatcher.
  1779. Arguments:
  1780. iColumn - sort criteria.
  1781. Return Values:
  1782. None.
  1783. --*/
  1784. {
  1785. //BOOL bOrder = GetKeyState(VK_CONTROL) < 0;
  1786. switch (m_pTabEntry->iItem)
  1787. {
  1788. case TCID_PURCHASE_HISTORY:
  1789. g_licenseColumnInfo.bSortOrder = m_bOrder;
  1790. g_licenseColumnInfo.nSortedItem = iColumn;
  1791. m_licenseList.SortItems(CompareLicenses, 0); // use column info
  1792. break;
  1793. case TCID_PRODUCTS_VIEW:
  1794. g_productColumnInfo.bSortOrder = m_bOrder;
  1795. g_productColumnInfo.nSortedItem = iColumn;
  1796. m_productList.SortItems(CompareProducts, 0); // use column info
  1797. break;
  1798. case TCID_PER_SEAT_CLIENTS:
  1799. g_userColumnInfo.bSortOrder = m_bOrder;
  1800. g_userColumnInfo.nSortedItem = iColumn;
  1801. m_userList.SortItems(CompareUsers, 0); // use column info
  1802. break;
  1803. }
  1804. m_bOrder = !m_bOrder;
  1805. }
  1806. void CLlsmgrView::OnSortColumn0()
  1807. { OnSortColumn(0); }
  1808. void CLlsmgrView::OnSortColumn1()
  1809. { OnSortColumn(1); }
  1810. void CLlsmgrView::OnSortColumn2()
  1811. { OnSortColumn(2); }
  1812. void CLlsmgrView::OnSortColumn3()
  1813. { OnSortColumn(3); }
  1814. void CLlsmgrView::OnSortColumn4()
  1815. { OnSortColumn(4); }
  1816. void CLlsmgrView::OnSortColumn5()
  1817. { OnSortColumn(5); }
  1818. void CLlsmgrView::OnUpdate(CView* pSender, LPARAM fUpdateHint, CObject* pIgnore)
  1819. /*++
  1820. Routine Description:
  1821. Called by framework when view needs to be refreshed.
  1822. Arguments:
  1823. pSender - view that modified document (only one).
  1824. fUpdateHint - hints about modifications.
  1825. pIgnore - not used.
  1826. Return Values:
  1827. None.
  1828. --*/
  1829. {
  1830. UNREFERENCED_PARAMETER(pSender);
  1831. UNREFERENCED_PARAMETER(pIgnore);
  1832. BeginWaitCursor();
  1833. if (IsLicenseInfoUpdated(fUpdateHint))
  1834. {
  1835. if (RefreshLicenseList())
  1836. {
  1837. SetTabUpdated(&g_tcTabInfo.tcTabEntry[TCID_PURCHASE_HISTORY]);
  1838. }
  1839. else
  1840. {
  1841. fUpdateHint = UPDATE_INFO_ABORT;
  1842. theApp.DisplayLastStatus();
  1843. }
  1844. }
  1845. if (IsProductInfoUpdated(fUpdateHint))
  1846. {
  1847. if (RefreshProductList())
  1848. {
  1849. SetTabUpdated(&g_tcTabInfo.tcTabEntry[TCID_PRODUCTS_VIEW]);
  1850. }
  1851. else
  1852. {
  1853. fUpdateHint = UPDATE_INFO_ABORT;
  1854. theApp.DisplayLastStatus();
  1855. }
  1856. }
  1857. if (IsUserInfoUpdated(fUpdateHint))
  1858. {
  1859. if (RefreshUserList())
  1860. {
  1861. SetTabUpdated(&g_tcTabInfo.tcTabEntry[TCID_PER_SEAT_CLIENTS]);
  1862. }
  1863. else
  1864. {
  1865. fUpdateHint = UPDATE_INFO_ABORT;
  1866. theApp.DisplayLastStatus();
  1867. }
  1868. }
  1869. if (IsUpdateAborted(fUpdateHint))
  1870. {
  1871. ResetLicenseList();
  1872. ResetProductList();
  1873. ResetUserList();
  1874. CSelectDomainDialog sdomDlg;
  1875. if (sdomDlg.DoModal() != IDOK)
  1876. {
  1877. theApp.m_pMainWnd->PostMessage(WM_CLOSE);
  1878. }
  1879. }
  1880. else if (IsServerInfoUpdated(fUpdateHint))
  1881. {
  1882. if (RefreshServerTree())
  1883. {
  1884. SetTabUpdated(&g_tcTabInfo.tcTabEntry[TCID_SERVER_BROWSER]);
  1885. }
  1886. else
  1887. {
  1888. ResetServerTree();
  1889. theApp.DisplayLastStatus();
  1890. }
  1891. }
  1892. EndWaitCursor();
  1893. }
  1894. void CLlsmgrView::OnUpdateSaveSettings(CCmdUI* pCmdUI)
  1895. /*++
  1896. Routine Description:
  1897. Notification handler for ID_SAVE_SETTINGS.
  1898. Arguments:
  1899. pCmdUI - interface for updating menu.
  1900. Return Values:
  1901. None.
  1902. --*/
  1903. {
  1904. ASSERT(NULL != pCmdUI);
  1905. pCmdUI->SetCheck(m_bSaveSettings);
  1906. }
  1907. void CLlsmgrView::OnUpdateViewDelete(CCmdUI* pCmdUI)
  1908. /*++
  1909. Routine Description:
  1910. Notification handler for ID_VIEW_DELETE.
  1911. Arguments:
  1912. pCmdUI - interface for updating menu.
  1913. Return Values:
  1914. None.
  1915. --*/
  1916. {
  1917. if (!(IsItemSelected(m_pTabEntry) && IsDeleteSupported(m_pTabEntry)))
  1918. {
  1919. ASSERT(NULL != pCmdUI);
  1920. pCmdUI->Enable(FALSE);
  1921. }
  1922. else if (m_pTabEntry->iItem == TCID_PRODUCTS_VIEW)
  1923. {
  1924. //
  1925. // Make sure they are licenses to delete...
  1926. //
  1927. CProduct* pProduct = (CProduct*)::LvGetSelObj(&m_productList);
  1928. VALIDATE_OBJECT(pProduct, CProduct);
  1929. if ( pProduct )
  1930. {
  1931. pCmdUI->Enable(pProduct->m_lLimit);
  1932. }
  1933. }
  1934. else
  1935. {
  1936. pCmdUI->Enable(TRUE);
  1937. }
  1938. }
  1939. void CLlsmgrView::OnUpdateViewProperties(CCmdUI* pCmdUI)
  1940. /*++
  1941. Routine Description:
  1942. Notification handler for ID_VIEW_PROPERTIES.
  1943. Arguments:
  1944. pCmdUI - interface for updating menu.
  1945. Return Values:
  1946. None.
  1947. --*/
  1948. {
  1949. if (!(IsItemSelected(m_pTabEntry) && IsEditSupported(m_pTabEntry)))
  1950. {
  1951. ASSERT(NULL != pCmdUI);
  1952. pCmdUI->Enable(FALSE);
  1953. }
  1954. else if (m_pTabEntry->iItem == TCID_SERVER_BROWSER)
  1955. {
  1956. //
  1957. // No properties for enterprise or domain...
  1958. //
  1959. CCmdTarget* pObject = (CCmdTarget*)::TvGetSelObj(&m_serverTree);
  1960. VALIDATE_OBJECT(pObject, CCmdTarget);
  1961. if ( pObject )
  1962. {
  1963. pCmdUI->Enable(pObject->IsKindOf(RUNTIME_CLASS(CServer)) ||
  1964. pObject->IsKindOf(RUNTIME_CLASS(CService)));
  1965. }
  1966. }
  1967. else
  1968. {
  1969. pCmdUI->Enable(TRUE);
  1970. }
  1971. }
  1972. void CLlsmgrView::OnViewLicenses()
  1973. /*++
  1974. Routine Description:
  1975. Message handler for ID_VIEW_LICENSES.
  1976. Arguments:
  1977. None.
  1978. Return Values:
  1979. None.
  1980. --*/
  1981. {
  1982. EnableCurSelTab(FALSE);
  1983. m_tabCtrl.SetCurSel(TCID_PURCHASE_HISTORY);
  1984. EnableCurSelTab(TRUE);
  1985. }
  1986. void CLlsmgrView::OnViewMappings()
  1987. /*++
  1988. Routine Description:
  1989. Message handler for ID_VIEW_MAPPINGS.
  1990. Arguments:
  1991. None.
  1992. Return Values:
  1993. None.
  1994. --*/
  1995. {
  1996. CLicenseGroupsDialog lgrpDlg;
  1997. lgrpDlg.DoModal();
  1998. OnUpdate(this, lgrpDlg.m_fUpdateHint, NULL);
  1999. }
  2000. void CLlsmgrView::OnViewProducts()
  2001. /*++
  2002. Routine Description:
  2003. Message handler for ID_VIEW_PRODUCTS.
  2004. Arguments:
  2005. None.
  2006. Return Values:
  2007. None.
  2008. --*/
  2009. {
  2010. EnableCurSelTab(FALSE);
  2011. m_tabCtrl.SetCurSel(TCID_PRODUCTS_VIEW);
  2012. EnableCurSelTab(TRUE);
  2013. }
  2014. void CLlsmgrView::OnViewProperties()
  2015. /*++
  2016. Routine Description:
  2017. View the properties of selected object.
  2018. Arguments:
  2019. None.
  2020. Return Values:
  2021. None.
  2022. --*/
  2023. {
  2024. switch (m_pTabEntry->iItem)
  2025. {
  2026. case TCID_PRODUCTS_VIEW:
  2027. ViewProductProperties();
  2028. return;
  2029. case TCID_PER_SEAT_CLIENTS:
  2030. ViewUserProperties();
  2031. return;
  2032. case TCID_SERVER_BROWSER:
  2033. ViewServerProperties();
  2034. return;
  2035. }
  2036. }
  2037. void CLlsmgrView::OnViewRefresh()
  2038. /*++
  2039. Routine Description:
  2040. Message handler for ID_VIEW_REFRESH.
  2041. Arguments:
  2042. None.
  2043. Return Values:
  2044. None.
  2045. --*/
  2046. {
  2047. GetDocument()->Update();
  2048. OnUpdate(
  2049. this,
  2050. (m_pTabEntry->iItem == TCID_SERVER_BROWSER)
  2051. ? UPDATE_BROWSER_TAB
  2052. : UPDATE_MAIN_TABS,
  2053. NULL
  2054. );
  2055. }
  2056. void CLlsmgrView::OnViewServers()
  2057. /*++
  2058. Routine Description:
  2059. Message handler for ID_VIEW_SERVERS.
  2060. Arguments:
  2061. None.
  2062. Return Values:
  2063. None.
  2064. --*/
  2065. {
  2066. EnableCurSelTab(FALSE);
  2067. m_tabCtrl.SetCurSel(TCID_SERVER_BROWSER);
  2068. EnableCurSelTab(TRUE);
  2069. m_serverTree.SetFocus();
  2070. }
  2071. void CLlsmgrView::OnViewUsers()
  2072. /*++
  2073. Routine Description:
  2074. Message handler for ID_VIEW_USERS.
  2075. Arguments:
  2076. None.
  2077. Return Values:
  2078. None.
  2079. --*/
  2080. {
  2081. EnableCurSelTab(FALSE);
  2082. m_tabCtrl.SetCurSel(TCID_PER_SEAT_CLIENTS);
  2083. EnableCurSelTab(TRUE);
  2084. }
  2085. void CLlsmgrView::RecalcListColumns()
  2086. /*++
  2087. Routine Description:
  2088. Adjusts list columns to client area.
  2089. Arguments:
  2090. None.
  2091. Return Values:
  2092. None.
  2093. --*/
  2094. {
  2095. ::LvResizeColumns(&m_licenseList, &g_licenseColumnInfo);
  2096. ::LvResizeColumns(&m_productList, &g_productColumnInfo);
  2097. ::LvResizeColumns(&m_userList, &g_userColumnInfo);
  2098. }
  2099. BOOL CLlsmgrView::RefreshLicenseList()
  2100. /*++
  2101. Routine Description:
  2102. Refreshs license list control.
  2103. Arguments:
  2104. None.
  2105. Return Values:
  2106. Returns true if licenses successfully updated.
  2107. --*/
  2108. {
  2109. CLicenses* pLicenses = GetDocument()->GetLicenses();
  2110. if (NULL != pLicenses)
  2111. {
  2112. return ::LvRefreshObArray(
  2113. &m_licenseList,
  2114. &g_licenseColumnInfo,
  2115. pLicenses->m_pObArray
  2116. );
  2117. }
  2118. return FALSE;
  2119. }
  2120. BOOL CLlsmgrView::RefreshProductList()
  2121. /*++
  2122. Routine Description:
  2123. Refreshs product list control.
  2124. Arguments:
  2125. None.
  2126. Return Values:
  2127. Returns true if products successfully updated.
  2128. --*/
  2129. {
  2130. CProducts* pProducts = GetDocument()->GetProducts();
  2131. if (NULL != pProducts)
  2132. {
  2133. return ::LvRefreshObArray(
  2134. &m_productList,
  2135. &g_productColumnInfo,
  2136. pProducts->m_pObArray
  2137. );
  2138. }
  2139. return FALSE;
  2140. }
  2141. BOOL CLlsmgrView::RefreshServerTree()
  2142. /*++
  2143. Routine Description:
  2144. Refreshs server tree control.
  2145. Arguments:
  2146. None.
  2147. Return Values:
  2148. Returns true if servers successfully updated.
  2149. --*/
  2150. {
  2151. HTREEITEM hRoot;
  2152. HTREEITEM hDomain;
  2153. TV_ITEM tvItem = {0};
  2154. TV_INSERTSTRUCT tvInsert;
  2155. BOOL bIsRefreshed = FALSE;
  2156. hRoot = m_serverTree.GetRootItem();
  2157. if (NULL != hRoot)
  2158. {
  2159. VARIANT va;
  2160. VariantInit(&va);
  2161. CDomain* pDomain;
  2162. CDomains* pDomains = (CDomains*)MKOBJ(LlsGetApp()->GetDomains(va));
  2163. m_serverTree.SetRedraw( FALSE );
  2164. if (pDomains)
  2165. {
  2166. TV_EXPANDED_INFO tvExpandedInfo;
  2167. if (::TvRefreshObArray(
  2168. &m_serverTree,
  2169. hRoot,
  2170. pDomains->m_pObArray,
  2171. &tvExpandedInfo))
  2172. {
  2173. TV_EXPANDED_ITEM* pExpandedItem = tvExpandedInfo.pExpandedItems;
  2174. while (tvExpandedInfo.nExpandedItems--)
  2175. {
  2176. pDomain = (CDomain*)pExpandedItem->pObject;
  2177. VALIDATE_OBJECT(pDomain, CDomain);
  2178. hDomain = ::TvGetDomain(&m_serverTree, hRoot, pDomain);
  2179. if (NULL != hDomain)
  2180. {
  2181. ::TvSwitchItem(&m_serverTree, hDomain, pExpandedItem);
  2182. if (!RefreshServerTreeServers(pExpandedItem->hItem))
  2183. {
  2184. ::TvReleaseObArray(&m_serverTree, pExpandedItem->hItem);
  2185. }
  2186. }
  2187. else
  2188. {
  2189. ::TvReleaseObArray(&m_serverTree, pExpandedItem->hItem);
  2190. }
  2191. pDomain->InternalRelease(); // release now...
  2192. pExpandedItem++;
  2193. }
  2194. delete [] tvExpandedInfo.pExpandedItems;
  2195. bIsRefreshed = TRUE;
  2196. }
  2197. pDomains->InternalRelease(); // release now...
  2198. }
  2199. if (bIsRefreshed)
  2200. {
  2201. TV_SORTCB tvSortCB;
  2202. tvSortCB.hParent = hRoot;
  2203. tvSortCB.lpfnCompare = CompareDomains;
  2204. tvSortCB.lParam = 0L; // ignored...
  2205. m_serverTree.SortChildrenCB(&tvSortCB);
  2206. }
  2207. m_serverTree.SetRedraw( TRUE );
  2208. }
  2209. else
  2210. {
  2211. CString strLabel;
  2212. tvItem.mask = TVIF_TEXT|
  2213. TVIF_PARAM|
  2214. TVIF_CHILDREN|
  2215. TVIF_SELECTEDIMAGE|
  2216. TVIF_IMAGE;
  2217. tvItem.cChildren = TRUE;
  2218. tvItem.iImage = BMPI_ENTERPRISE;
  2219. tvItem.iSelectedImage = BMPI_ENTERPRISE;
  2220. strLabel.LoadString(IDS_ENTERPRISE);
  2221. tvItem.pszText = MKSTR(strLabel);
  2222. tvItem.lParam = (LPARAM)(LPVOID)LlsGetApp();
  2223. tvInsert.item = tvItem;
  2224. tvInsert.hInsertAfter = (HTREEITEM)TVI_ROOT;
  2225. tvInsert.hParent = (HTREEITEM)NULL;
  2226. hRoot = m_serverTree.InsertItem(&tvInsert);
  2227. if (NULL != hRoot)
  2228. {
  2229. hDomain = hRoot; // initialize...
  2230. if (m_serverTree.Expand(hRoot, TVE_EXPAND))
  2231. {
  2232. if (LlsGetApp()->IsFocusDomain())
  2233. {
  2234. CDomain* pActiveDomain = GetDocument()->GetDomain();
  2235. ASSERT(pActiveDomain);
  2236. hDomain = ::TvGetDomain(&m_serverTree, hRoot, pActiveDomain);
  2237. if (NULL != hDomain)
  2238. {
  2239. m_serverTree.Expand(hDomain, TVE_EXPAND);
  2240. }
  2241. }
  2242. }
  2243. else
  2244. {
  2245. theApp.DisplayLastStatus(); // display warning...
  2246. }
  2247. VERIFY(m_serverTree.Select(hDomain, TVGN_FIRSTVISIBLE));
  2248. VERIFY(m_serverTree.Select(hDomain, TVGN_CARET));
  2249. bIsRefreshed = TRUE;
  2250. }
  2251. else
  2252. {
  2253. LlsSetLastStatus(STATUS_NO_MEMORY);
  2254. }
  2255. }
  2256. return bIsRefreshed;
  2257. }
  2258. BOOL CLlsmgrView::RefreshServerTreeServers(HTREEITEM hParent)
  2259. /*++
  2260. Routine Description:
  2261. Refreshs servers of domain.
  2262. Arguments:
  2263. hParent - handle of expanded domain.
  2264. Return Values:
  2265. Returns true if successful.
  2266. --*/
  2267. {
  2268. TV_ITEM tvItem;
  2269. HTREEITEM hServer;
  2270. BOOL bIsRefreshed = FALSE;
  2271. VARIANT va;
  2272. VariantInit(&va);
  2273. tvItem.hItem = hParent;
  2274. tvItem.mask = LVIF_PARAM;
  2275. VERIFY(m_serverTree.GetItem(&tvItem));
  2276. CDomain* pDomain = (CDomain*)tvItem.lParam;
  2277. VALIDATE_OBJECT(pDomain, CDomain);
  2278. CServer* pServer;
  2279. CServers* pServers = (CServers*)MKOBJ(pDomain->GetServers(va));
  2280. if (pServers)
  2281. {
  2282. TV_EXPANDED_INFO tvExpandedInfo;
  2283. if (::TvRefreshObArray(
  2284. &m_serverTree,
  2285. hParent,
  2286. pServers->m_pObArray,
  2287. &tvExpandedInfo))
  2288. {
  2289. TV_EXPANDED_ITEM* pExpandedItem = tvExpandedInfo.pExpandedItems;
  2290. while (0 < tvExpandedInfo.nExpandedItems--)
  2291. {
  2292. pServer = (CServer*)pExpandedItem->pObject;
  2293. VALIDATE_OBJECT(pServer, CServer);
  2294. hServer = ::TvGetServer(&m_serverTree, hParent, pServer);
  2295. if (NULL != hServer)
  2296. {
  2297. ::TvSwitchItem(&m_serverTree, hServer, pExpandedItem);
  2298. if (!RefreshServerTreeServices(pExpandedItem->hItem))
  2299. {
  2300. ::TvReleaseObArray(&m_serverTree, pExpandedItem->hItem);
  2301. }
  2302. }
  2303. else
  2304. {
  2305. ::TvReleaseObArray(&m_serverTree, pExpandedItem->hItem);
  2306. }
  2307. pServer->InternalRelease(); // release now...
  2308. pExpandedItem++;
  2309. }
  2310. delete [] tvExpandedInfo.pExpandedItems;
  2311. bIsRefreshed = TRUE;
  2312. }
  2313. pServers->InternalRelease(); // release now...
  2314. }
  2315. if (bIsRefreshed)
  2316. {
  2317. TV_SORTCB tvSortCB;
  2318. tvSortCB.hParent = hParent;
  2319. tvSortCB.lpfnCompare = CompareServers;
  2320. tvSortCB.lParam = 0L; // ignored...
  2321. m_serverTree.SortChildrenCB(&tvSortCB);
  2322. }
  2323. else
  2324. {
  2325. theApp.DisplayLastStatus();
  2326. }
  2327. return bIsRefreshed;
  2328. }
  2329. BOOL CLlsmgrView::RefreshServerTreeServices(HTREEITEM hParent)
  2330. /*++
  2331. Routine Description:
  2332. Refreshs services of server.
  2333. Arguments:
  2334. hParent - handle of expanded server.
  2335. Return Values:
  2336. Returns true if successful.
  2337. --*/
  2338. {
  2339. TV_ITEM tvItem;
  2340. BOOL bIsRefreshed = FALSE;
  2341. VARIANT va;
  2342. VariantInit(&va);
  2343. tvItem.hItem = hParent;
  2344. tvItem.mask = LVIF_PARAM;
  2345. VERIFY(m_serverTree.GetItem(&tvItem));
  2346. CServer* pServer = (CServer*)tvItem.lParam;
  2347. VALIDATE_OBJECT(pServer, CServer);
  2348. CServices* pServices = (CServices*)MKOBJ(pServer->GetServices(va));
  2349. if (pServices)
  2350. {
  2351. TV_EXPANDED_INFO tvExpandedInfo;
  2352. if (::TvRefreshObArray(&m_serverTree, hParent, pServices->m_pObArray, &tvExpandedInfo))
  2353. {
  2354. ASSERT(!tvExpandedInfo.nExpandedItems);
  2355. ASSERT(!tvExpandedInfo.pExpandedItems);
  2356. bIsRefreshed = TRUE; // should be no expanded items...
  2357. }
  2358. pServices->InternalRelease(); // release now...
  2359. }
  2360. if (bIsRefreshed)
  2361. {
  2362. TV_SORTCB tvSortCB;
  2363. tvSortCB.hParent = hParent;
  2364. tvSortCB.lpfnCompare = CompareServices;
  2365. tvSortCB.lParam = 0L; // ignored...
  2366. m_serverTree.SortChildrenCB(&tvSortCB);
  2367. }
  2368. else
  2369. {
  2370. theApp.DisplayLastStatus();
  2371. }
  2372. return bIsRefreshed;
  2373. }
  2374. BOOL CLlsmgrView::RefreshUserList()
  2375. /*++
  2376. Routine Description:
  2377. Refreshs user list control.
  2378. Arguments:
  2379. None.
  2380. Return Values:
  2381. Returns true if users successfully updated.
  2382. --*/
  2383. {
  2384. CUsers* pUsers = GetDocument()->GetUsers();
  2385. if (NULL != pUsers)
  2386. {
  2387. return ::LvRefreshObArray(
  2388. &m_userList,
  2389. &g_userColumnInfo,
  2390. pUsers->m_pObArray
  2391. );
  2392. }
  2393. return FALSE;
  2394. }
  2395. void CLlsmgrView::SaveSettings()
  2396. /*++
  2397. Routine Description:
  2398. Save settings to registry.
  2399. Arguments:
  2400. None.
  2401. Return Values:
  2402. None.
  2403. --*/
  2404. {
  2405. long Status;
  2406. HKEY hKeyLlsmgr;
  2407. DWORD dwDisposition;
  2408. Status = RegCreateKeyEx(
  2409. HKEY_CURRENT_USER,
  2410. szRegKeyLlsmgr,
  2411. 0,
  2412. NULL,
  2413. REG_OPTION_NON_VOLATILE,
  2414. KEY_ALL_ACCESS,
  2415. NULL,
  2416. &hKeyLlsmgr,
  2417. &dwDisposition
  2418. );
  2419. if (Status == ERROR_SUCCESS)
  2420. {
  2421. //
  2422. // Save settings on exit
  2423. //
  2424. RegSetValueEx(hKeyLlsmgr, szRegKeyLlsmgrSaveSettings, 0, REG_DWORD, (LPBYTE)&m_bSaveSettings, sizeof(DWORD));
  2425. if (m_bSaveSettings)
  2426. {
  2427. //
  2428. // Save font information
  2429. //
  2430. long lValue;
  2431. lValue = (m_lFont.lfHeight < 0) ? -m_lFont.lfHeight : 0;
  2432. RegSetValueEx(hKeyLlsmgr, szRegKeyLlsmgrFontHeight, 0, REG_DWORD, (LPBYTE)&lValue, sizeof(DWORD));
  2433. lValue = (m_lFont.lfWeight > 0) ? m_lFont.lfWeight : 0;
  2434. RegSetValueEx(hKeyLlsmgr, szRegKeyLlsmgrFontWeight, 0, REG_DWORD, (LPBYTE)&lValue, sizeof(DWORD));
  2435. lValue = (m_lFont.lfItalic > 0) ? TRUE : FALSE;
  2436. RegSetValueEx(hKeyLlsmgr, szRegKeyLlsmgrFontItalic, 0, REG_DWORD, (LPBYTE)&lValue, sizeof(DWORD));
  2437. RegSetValueEx(hKeyLlsmgr, szRegKeyLlsmgrFontFaceName, 0, REG_SZ, (LPBYTE)m_lFont.lfFaceName, (lstrlen(m_lFont.lfFaceName) + 1) * sizeof(TCHAR));
  2438. lValue = (LONG)m_lFont.lfCharSet;
  2439. ::RegSetValueEx(hKeyLlsmgr, szRegKeyLlsmgrFontCharset, 0, REG_DWORD, (LPBYTE)&lValue, sizeof(DWORD));
  2440. //
  2441. // MRU domain list
  2442. //
  2443. TCHAR szValue[512];
  2444. LPTSTR pszValue = szValue;
  2445. DWORD cbValue = 2 * sizeof(TCHAR); // terminators
  2446. CString strDomain;
  2447. UINT cchDomain;
  2448. POSITION position;
  2449. position = m_mruDomainList.GetTailPosition();
  2450. while (position)
  2451. {
  2452. strDomain = m_mruDomainList.GetPrev(position);
  2453. cchDomain = strDomain.GetLength() + 1;
  2454. lstrcpyn(pszValue, strDomain, cchDomain);
  2455. pszValue += cchDomain;
  2456. cbValue += cchDomain * sizeof(TCHAR);
  2457. }
  2458. *pszValue = _T('\0');
  2459. *(pszValue+1) = _T('\0');
  2460. RegSetValueEx(hKeyLlsmgr, szRegKeyLlsmgrMruList, 0, REG_MULTI_SZ, (LPBYTE)szValue, cbValue);
  2461. }
  2462. RegCloseKey(hKeyLlsmgr);
  2463. }
  2464. }
  2465. void CLlsmgrView::ViewProductProperties()
  2466. /*++
  2467. Routine Description:
  2468. View properties of selected product.
  2469. Arguments:
  2470. None.
  2471. Return Values:
  2472. None.
  2473. --*/
  2474. {
  2475. CProduct* pProduct = (CProduct*)::LvGetSelObj(&m_productList);
  2476. if (NULL != pProduct)
  2477. {
  2478. VALIDATE_OBJECT(pProduct, CProduct);
  2479. CString strTitle;
  2480. AfxFormatString1(strTitle, IDS_PROPERTIES_OF, pProduct->m_strName);
  2481. CProductPropertySheet productProperties(strTitle);
  2482. productProperties.InitPages(pProduct);
  2483. productProperties.DoModal();
  2484. OnUpdate(this, productProperties.m_fUpdateHint, NULL);
  2485. }
  2486. }
  2487. void CLlsmgrView::ViewServerProperties()
  2488. /*++
  2489. Routine Description:
  2490. View properties of selected server.
  2491. Arguments:
  2492. None.
  2493. Return Values:
  2494. None.
  2495. --*/
  2496. {
  2497. CObject* pObject = (CObject*)::TvGetSelObj(&m_serverTree);
  2498. if (NULL != pObject)
  2499. {
  2500. CString strTitle;
  2501. ASSERT_VALID(pObject);
  2502. if (pObject->IsKindOf(RUNTIME_CLASS(CServer)))
  2503. {
  2504. CServer* pServer = (CServer*)pObject;
  2505. AfxFormatString1(strTitle, IDS_PROPERTIES_OF, pServer->m_strName);
  2506. CServerPropertySheet serverProperties(strTitle);
  2507. serverProperties.InitPages(pServer);
  2508. serverProperties.DoModal();
  2509. OnUpdate(this, serverProperties.m_fUpdateHint, NULL);
  2510. }
  2511. else if (pObject->IsKindOf(RUNTIME_CLASS(CService)))
  2512. {
  2513. CService* pService = (CService*)pObject;
  2514. CLicensingModeDialog lmodDlg;
  2515. lmodDlg.InitDialog(pService);
  2516. lmodDlg.DoModal();
  2517. if (lmodDlg.m_fUpdateHint)
  2518. {
  2519. TV_ITEM tvItem;
  2520. tvItem.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE;
  2521. tvItem.hItem = m_serverTree.GetSelectedItem();
  2522. tvItem.iImage = pService->IsPerServer() ? BMPI_PRODUCT_PER_SERVER : BMPI_PRODUCT_PER_SEAT;
  2523. tvItem.iSelectedImage = tvItem.iImage;
  2524. VERIFY(m_serverTree.SetItem(&tvItem));
  2525. VERIFY(m_serverTree.Select(tvItem.hItem, TVGN_CARET));
  2526. }
  2527. OnUpdate(this, lmodDlg.m_fUpdateHint, NULL);
  2528. }
  2529. }
  2530. }
  2531. void CLlsmgrView::ViewUserProperties()
  2532. /*++
  2533. Routine Description:
  2534. View properties of selected user.
  2535. Arguments:
  2536. None.
  2537. Return Values:
  2538. None.
  2539. --*/
  2540. {
  2541. CUser* pUser = (CUser*)::LvGetSelObj(&m_userList);
  2542. if (NULL != pUser)
  2543. {
  2544. VALIDATE_OBJECT(pUser, CUser);
  2545. CString strTitle;
  2546. AfxFormatString1(strTitle, IDS_PROPERTIES_OF, pUser->m_strName);
  2547. CUserPropertySheet userProperties(strTitle);
  2548. userProperties.InitPages(pUser);
  2549. userProperties.DoModal();
  2550. OnUpdate(this, userProperties.m_fUpdateHint, NULL);
  2551. }
  2552. }
  2553. int CALLBACK CompareLicenses(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  2554. /*++
  2555. Routine Description:
  2556. Notification handler for LVM_SORTITEMS.
  2557. Arguments:
  2558. lParam1 - object to sort.
  2559. lParam2 - object to sort.
  2560. lParamSort - sort criteria.
  2561. Return Values:
  2562. Same as lstrcmp.
  2563. --*/
  2564. {
  2565. UNREFERENCED_PARAMETER(lParamSort);
  2566. #define pLicense1 ((CLicense*)lParam1)
  2567. #define pLicense2 ((CLicense*)lParam2)
  2568. VALIDATE_OBJECT(pLicense1, CLicense);
  2569. VALIDATE_OBJECT(pLicense2, CLicense);
  2570. int iResult;
  2571. switch (g_licenseColumnInfo.nSortedItem)
  2572. {
  2573. case LVID_PURCHASE_HISTORY_DATE:
  2574. iResult = pLicense1->m_lDate - pLicense2->m_lDate;
  2575. break;
  2576. case LVID_PURCHASE_HISTORY_PRODUCT:
  2577. iResult = pLicense1->m_strProduct.CompareNoCase(pLicense2->m_strProduct);
  2578. break;
  2579. case LVID_PURCHASE_HISTORY_QUANTITY:
  2580. iResult = pLicense1->m_lQuantity - pLicense2->m_lQuantity;
  2581. break;
  2582. case LVID_PURCHASE_HISTORY_ADMINISTRATOR:
  2583. iResult = pLicense1->m_strUser.CompareNoCase(pLicense2->m_strUser);
  2584. break;
  2585. case LVID_PURCHASE_HISTORY_COMMENT:
  2586. iResult = pLicense1->m_strDescription.CompareNoCase(pLicense2->m_strDescription);
  2587. break;
  2588. default:
  2589. iResult = 0;
  2590. break;
  2591. }
  2592. return g_licenseColumnInfo.bSortOrder ? -iResult : iResult;
  2593. }
  2594. int CALLBACK CompareProducts(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  2595. /*++
  2596. Routine Description:
  2597. Notification handler for LVM_SORTITEMS.
  2598. Arguments:
  2599. lParam1 - object to sort.
  2600. lParam2 - object to sort.
  2601. lParamSort - sort criteria.
  2602. Return Values:
  2603. Same as lstrcmp.
  2604. --*/
  2605. {
  2606. UNREFERENCED_PARAMETER(lParamSort);
  2607. #define pProduct1 ((CProduct*)lParam1)
  2608. #define pProduct2 ((CProduct*)lParam2)
  2609. VALIDATE_OBJECT(pProduct1, CProduct);
  2610. VALIDATE_OBJECT(pProduct2, CProduct);
  2611. int iResult;
  2612. switch (g_productColumnInfo.nSortedItem)
  2613. {
  2614. case LVID_PRODUCTS_VIEW_NAME:
  2615. iResult = pProduct1->m_strName.CompareNoCase(pProduct2->m_strName);
  2616. break;
  2617. case LVID_PRODUCTS_VIEW_PER_SEAT_CONSUMED:
  2618. iResult = pProduct1->m_lInUse - pProduct2->m_lInUse;
  2619. break;
  2620. case LVID_PRODUCTS_VIEW_PER_SEAT_PURCHASED:
  2621. iResult = pProduct1->m_lLimit - pProduct2->m_lLimit;
  2622. break;
  2623. case LVID_PRODUCTS_VIEW_PER_SERVER_PURCHASED:
  2624. iResult = pProduct1->m_lConcurrent - pProduct2->m_lConcurrent;
  2625. break;
  2626. case LVID_PRODUCTS_VIEW_PER_SERVER_REACHED:
  2627. iResult = pProduct1->m_lHighMark - pProduct2->m_lHighMark;
  2628. break;
  2629. default:
  2630. iResult = 0;
  2631. break;
  2632. }
  2633. return g_productColumnInfo.bSortOrder ? -iResult : iResult;
  2634. }
  2635. int CALLBACK CompareUsers(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  2636. /*++
  2637. Routine Description:
  2638. Notification handler for LVM_SORTITEMS.
  2639. Arguments:
  2640. lParam1 - object to sort.
  2641. lParam2 - object to sort.
  2642. lParamSort - sort criteria.
  2643. Return Values:
  2644. Same as lstrcmp.
  2645. --*/
  2646. {
  2647. UNREFERENCED_PARAMETER(lParamSort);
  2648. #define pUser1 ((CUser*)lParam1)
  2649. #define pUser2 ((CUser*)lParam2)
  2650. VALIDATE_OBJECT(pUser1, CUser);
  2651. VALIDATE_OBJECT(pUser2, CUser);
  2652. int iResult;
  2653. switch (g_userColumnInfo.nSortedItem)
  2654. {
  2655. case LVID_PER_SEAT_CLIENTS_NAME:
  2656. iResult = pUser1->m_strName.CompareNoCase(pUser2->m_strName);
  2657. break;
  2658. case LVID_PER_SEAT_CLIENTS_LICENSED_USAGE:
  2659. iResult = pUser1->m_lInUse - pUser2->m_lInUse;
  2660. break;
  2661. case LVID_PER_SEAT_CLIENTS_UNLICENSED_USAGE:
  2662. iResult = pUser1->m_lUnlicensed - pUser2->m_lUnlicensed;
  2663. break;
  2664. case LVID_PER_SEAT_CLIENTS_SERVER_PRODUCTS:
  2665. iResult = pUser1->m_strProducts.CompareNoCase(pUser2->m_strProducts);
  2666. break;
  2667. default:
  2668. iResult = 0;
  2669. break;
  2670. }
  2671. return g_userColumnInfo.bSortOrder ? -iResult : iResult;
  2672. }
  2673. int CALLBACK CompareDomains(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  2674. /*++
  2675. Routine Description:
  2676. Notification handler for TVM_SORTCHILDRENCB.
  2677. Arguments:
  2678. lParam1 - object to sort.
  2679. lParam2 - object to sort.
  2680. lParamSort - sort criteria.
  2681. Return Values:
  2682. Same as lstrcmp.
  2683. --*/
  2684. {
  2685. UNREFERENCED_PARAMETER(lParamSort);
  2686. #define pDomain1 ((CDomain*)lParam1)
  2687. #define pDomain2 ((CDomain*)lParam2)
  2688. VALIDATE_OBJECT(pDomain1, CDomain);
  2689. VALIDATE_OBJECT(pDomain2, CDomain);
  2690. return pDomain1->m_strName.CompareNoCase(pDomain2->m_strName);
  2691. }
  2692. int CALLBACK CompareServers(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  2693. /*++
  2694. Routine Description:
  2695. Notification handler for TVM_SORTCHILDRENCB.
  2696. Arguments:
  2697. lParam1 - object to sort.
  2698. lParam2 - object to sort.
  2699. lParamSort - sort criteria.
  2700. Return Values:
  2701. Same as lstrcmp.
  2702. --*/
  2703. {
  2704. UNREFERENCED_PARAMETER(lParamSort);
  2705. #define pServer1 ((CServer*)lParam1)
  2706. #define pServer2 ((CServer*)lParam2)
  2707. VALIDATE_OBJECT(pServer1, CServer);
  2708. VALIDATE_OBJECT(pServer2, CServer);
  2709. return pServer1->m_strName.CompareNoCase(pServer2->m_strName);
  2710. }
  2711. int CALLBACK CompareServices(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  2712. /*++
  2713. Routine Description:
  2714. Notification handler for TVM_SORTCHILDRENCB.
  2715. Arguments:
  2716. lParam1 - object to sort.
  2717. lParam2 - object to sort.
  2718. lParamSort - sort criteria.
  2719. Return Values:
  2720. Same as lstrcmp.
  2721. --*/
  2722. {
  2723. UNREFERENCED_PARAMETER(lParamSort);
  2724. #define pService1 ((CService*)lParam1)
  2725. #define pService2 ((CService*)lParam2)
  2726. VALIDATE_OBJECT(pService1, CService);
  2727. VALIDATE_OBJECT(pService2, CService);
  2728. return pService1->m_strName.CompareNoCase(pService2->m_strName);
  2729. }