Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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