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.

1550 lines
47 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: S M R A S P S P . C P P
  7. //
  8. // Contents: The rendering of the UI for the network status monitor's RAS
  9. // property page
  10. //
  11. // Notes:
  12. //
  13. // Author: CWill 02/03/1998
  14. //
  15. //----------------------------------------------------------------------------
  16. #include "pch.h"
  17. #pragma hdrstop
  18. #include "sminc.h"
  19. #include "smpsh.h"
  20. #include "smutil.h"
  21. #include "nsres.h"
  22. #include "ncatlui.h"
  23. #include "ncnetcon.h"
  24. #include "ncras.h"
  25. #include "mprapi.h"
  26. const int c_nColumns=2;
  27. HRESULT HrRasGetSubEntryHandle(HRASCONN hrasconn, DWORD dwSubEntry,
  28. HRASCONN* prasconnSub);
  29. HRESULT HrRasHangUp(HRASCONN hrasconn);
  30. //+---------------------------------------------------------------------------
  31. //
  32. // Member: CPspStatusMonitorRas::CPspStatusMonitorRas
  33. //
  34. // Purpose: Creator
  35. //
  36. // Arguments: None
  37. //
  38. // Returns: Nil
  39. //
  40. CPspStatusMonitorRas::CPspStatusMonitorRas() :
  41. m_hRasConn(NULL)
  42. {
  43. TraceFileFunc(ttidStatMon);
  44. m_pGenPage = NULL;
  45. }
  46. //+---------------------------------------------------------------------------
  47. //
  48. // Member: CPspStatusMonitorRas::~CPspStatusMonitorTool
  49. //
  50. // Purpose: Destructor
  51. //
  52. // Arguments: None
  53. //
  54. // Returns: Nil
  55. //
  56. CPspStatusMonitorRas::~CPspStatusMonitorRas(VOID)
  57. {
  58. ::FreeCollectionAndItem(m_lstprdi);
  59. }
  60. //+---------------------------------------------------------------------------
  61. //
  62. // Member: CPspStatusMonitorRas::HrInitRasPage
  63. //
  64. // Purpose: Initialize the RAS page class before the page has been
  65. // created
  66. //
  67. // Arguments: pncInit - The connection associated with this monitor
  68. // pGenPage - The general page that contains the persistent info
  69. // for retrieving the INetConnection on disconnect
  70. //
  71. // Returns: Error code
  72. //
  73. HRESULT CPspStatusMonitorRas::HrInitRasPage(INetConnection* pncInit,
  74. CPspStatusMonitorGen * pGenPage,
  75. const DWORD * adwHelpIDs)
  76. {
  77. TraceFileFunc(ttidStatMon);
  78. HRESULT hr = S_OK;
  79. // set context help IDs
  80. m_adwHelpIDs = adwHelpIDs;
  81. // Stash the connection name for later use.
  82. // Note: Failures are handled and are not fatal
  83. //
  84. NETCON_PROPERTIES* pProps;
  85. hr = pncInit->GetProperties(&pProps);
  86. if (SUCCEEDED(hr))
  87. {
  88. m_strConnectionName = pProps->pszwName;
  89. m_ncmType = pProps->MediaType;
  90. m_dwCharacter = pProps->dwCharacter;
  91. FreeNetconProperties(pProps);
  92. }
  93. // Get a point to the General page where we can disconnect the connection
  94. // when suspending the last link in multilink RAS connection
  95. AssertSz(pGenPage, "We should have a valid pointer to the General page.");
  96. if (SUCCEEDED(hr))
  97. {
  98. m_pGenPage = pGenPage;
  99. }
  100. // Get RAS specific data
  101. //
  102. if (m_dwCharacter & NCCF_OUTGOING_ONLY)
  103. {
  104. INetRasConnection* pnrcNew = NULL;
  105. hr = HrQIAndSetProxyBlanket(pncInit, &pnrcNew);
  106. if (SUCCEEDED(hr))
  107. {
  108. RASCON_INFO rciPage = { 0 };
  109. // Find out what entry in what phone book this connection is on
  110. //
  111. hr = pnrcNew->GetRasConnectionInfo (&rciPage);
  112. if (SUCCEEDED(hr))
  113. {
  114. RASENTRY* pRasEntry = NULL;
  115. AssertSz(rciPage.pszwPbkFile, "We should have a pszwPbkFile");
  116. AssertSz(rciPage.pszwEntryName, "We should have a pszwEntryName");
  117. // Save for later use
  118. //
  119. m_strPbkFile = rciPage.pszwPbkFile;
  120. m_strEntryName = rciPage.pszwEntryName;
  121. // Get the handle to the connection
  122. //
  123. hr = pnrcNew->GetRasConnectionHandle(
  124. reinterpret_cast<ULONG_PTR*>(&m_hRasConn));
  125. if (SUCCEEDED(hr))
  126. {
  127. // We only allow user to dial/resume individual links
  128. // if DialAll is set (i.e. neither "DialAsNeeded" or
  129. // "Dial first available device only")
  130. //
  131. hr = ::HrRasGetEntryProperties(
  132. rciPage.pszwPbkFile,
  133. rciPage.pszwEntryName,
  134. &pRasEntry,
  135. NULL);
  136. if (SUCCEEDED(hr))
  137. {
  138. if (pRasEntry->dwDialMode == RASEDM_DialAll)
  139. {
  140. DWORD iSubEntry = 1;
  141. // clear up the current list before we add any new new entry
  142. // $REVIEW(tongl 5/12): to fix bug # 170789
  143. ::FreeCollectionAndItem(m_lstprdi);
  144. // This is a one based count, so we have to have less than or
  145. // equal to
  146. //
  147. for (; SUCCEEDED(hr) && iSubEntry <= pRasEntry->dwSubEntries;
  148. iSubEntry++)
  149. {
  150. RASSUBENTRY* pRasSubEntry = NULL;
  151. // The name of the subentry
  152. //
  153. hr = ::HrRasGetSubEntryProperties(
  154. rciPage.pszwPbkFile,
  155. rciPage.pszwEntryName,
  156. iSubEntry,
  157. &pRasSubEntry);
  158. if (SUCCEEDED(hr))
  159. {
  160. CRasDeviceInfo* prdiNew = NULL;
  161. // If we have all the info we need, create
  162. // a new entry add it to the list
  163. //
  164. prdiNew = new CRasDeviceInfo;
  165. if (prdiNew)
  166. {
  167. prdiNew->SetSubEntry(iSubEntry);
  168. prdiNew->SetDeviceName(pRasSubEntry->szDeviceName);
  169. m_lstprdi.push_back(prdiNew);
  170. }
  171. // Free the subentry data
  172. //
  173. MemFree(pRasSubEntry);
  174. }
  175. }
  176. }
  177. MemFree(pRasEntry);
  178. }
  179. }
  180. ::RciFree(&rciPage);
  181. }
  182. ::ReleaseObj(pnrcNew);
  183. }
  184. }
  185. else if (m_dwCharacter & NCCF_INCOMING_ONLY)
  186. {
  187. // for incoming connection only
  188. // save the handle
  189. INetInboundConnection* pnicNew;
  190. hr = HrQIAndSetProxyBlanket(pncInit, &pnicNew);
  191. if (SUCCEEDED(hr))
  192. {
  193. hr = pnicNew->GetServerConnectionHandle(
  194. reinterpret_cast<ULONG_PTR*>(&m_hRasConn));
  195. if (SUCCEEDED(hr))
  196. {
  197. // Find out what ports are in this connection
  198. //
  199. // NTRAID#NTBUG9-84706-2000/09/28-sumeetb
  200. }
  201. ReleaseObj(pnicNew);
  202. }
  203. }
  204. else
  205. {
  206. AssertSz(FALSE, "Invalid connection type..");
  207. }
  208. TraceError("CPspStatusMonitorRas::HrInitRasPage",hr);
  209. return hr;
  210. }
  211. //+---------------------------------------------------------------------------
  212. //
  213. // Member: CPspStatusMonitorRas::OnInitDialog
  214. //
  215. // Purpose: Do the initialization required when the page has just been created
  216. //
  217. // Arguments: Standard window messsage parameters
  218. //
  219. // Returns: Standard window message return value
  220. //
  221. LRESULT CPspStatusMonitorRas::OnInitDialog(UINT uMsg, WPARAM wParam,
  222. LPARAM lParam, BOOL& bHandled)
  223. {
  224. TraceFileFunc(ttidStatMon);
  225. // Fill the property list view
  226. //
  227. FillPropertyList();
  228. // Fill the device list
  229. //
  230. FillDeviceDropDown();
  231. return 0;
  232. }
  233. //+---------------------------------------------------------------------------
  234. //
  235. // Member: CPspStatusMonitorRas::OnDestroy
  236. //
  237. // Purpose: Clean up the dialog before the window goes away
  238. //
  239. // Arguments: Standard window messsage parameters
  240. //
  241. // Returns: Standard window message return value
  242. //
  243. LRESULT CPspStatusMonitorRas::OnDestroy(UINT uMsg, WPARAM wParam,
  244. LPARAM lParam, BOOL& bHandled)
  245. {
  246. TraceFileFunc(ttidStatMon);
  247. ::FreeCollectionAndItem(m_lstprdi);
  248. return 0;
  249. }
  250. //+---------------------------------------------------------------------------
  251. //
  252. // Member: CPspStatusMonitorRas::OnContextMenu
  253. //
  254. // Purpose: When right click a control, bring up help
  255. //
  256. // Arguments: Standard command parameters
  257. //
  258. // Returns: Standard return
  259. //
  260. LRESULT
  261. CPspStatusMonitorRas::OnContextMenu(UINT uMsg,
  262. WPARAM wParam,
  263. LPARAM lParam,
  264. BOOL& fHandled)
  265. {
  266. TraceFileFunc(ttidStatMon);
  267. if (m_adwHelpIDs != NULL)
  268. {
  269. ::WinHelp(m_hWnd,
  270. c_szNetCfgHelpFile,
  271. HELP_CONTEXTMENU,
  272. (ULONG_PTR)m_adwHelpIDs);
  273. }
  274. return 0;
  275. }
  276. //+---------------------------------------------------------------------------
  277. //
  278. // Member: CPspStatusMonitorRas::OnHelp
  279. //
  280. // Purpose: When drag context help icon over a control, bring up help
  281. //
  282. // Arguments: Standard command parameters
  283. //
  284. // Returns: Standard return
  285. //
  286. LRESULT
  287. CPspStatusMonitorRas::OnHelp(UINT uMsg,
  288. WPARAM wParam,
  289. LPARAM lParam,
  290. BOOL& fHandled)
  291. {
  292. TraceFileFunc(ttidStatMon);
  293. LPHELPINFO lphi = reinterpret_cast<LPHELPINFO>(lParam);
  294. Assert(lphi);
  295. if ((m_adwHelpIDs != NULL) && (HELPINFO_WINDOW == lphi->iContextType))
  296. {
  297. ::WinHelp(static_cast<HWND>(lphi->hItemHandle),
  298. c_szNetCfgHelpFile,
  299. HELP_WM_HELP,
  300. (ULONG_PTR)m_adwHelpIDs);
  301. }
  302. return 0;
  303. }
  304. //+---------------------------------------------------------------------------
  305. //
  306. // Member: CPspStatusMonitorRas::OnSetCursor
  307. //
  308. // Purpose: Ensure the mouse cursor over the Property Sheet is an Arrow.
  309. //
  310. // Arguments: Standard command parameters
  311. //
  312. // Returns: Standard return
  313. //
  314. LRESULT
  315. CPspStatusMonitorRas::OnSetCursor (
  316. UINT uMsg,
  317. WPARAM wParam,
  318. LPARAM lParam,
  319. BOOL& bHandled)
  320. {
  321. TraceFileFunc(ttidStatMon);
  322. if (LOWORD(lParam) == HTCLIENT)
  323. {
  324. SetCursor(LoadCursor(NULL, IDC_ARROW));
  325. }
  326. return FALSE;
  327. }
  328. //+---------------------------------------------------------------------------
  329. //
  330. // Member: CPspStatusMonitorRas::GetActiveDeviceCount
  331. //
  332. // Purpose: Return the number of active devices
  333. //
  334. // Arguments: none
  335. //
  336. // Returns: UINT
  337. //
  338. UINT CPspStatusMonitorRas::GetActiveDeviceCount()
  339. {
  340. TraceFileFunc(ttidStatMon);
  341. INT nCntDevices;
  342. INT iCmb;
  343. INT nCnt = 0;
  344. nCntDevices = (INT)SendDlgItemMessage(IDC_CMB_SM_RAS_DEVICES, CB_GETCOUNT, 0L, 0L);
  345. if ((CB_ERR != nCntDevices) && (nCntDevices > 1))
  346. {
  347. for (iCmb = 0; iCmb < nCntDevices; iCmb++)
  348. {
  349. CRasDeviceInfo* prdiSelect = NULL;
  350. NETCON_STATUS ncsTemp = NCS_DISCONNECTED;
  351. // Get the object from the selection
  352. //
  353. prdiSelect = reinterpret_cast<CRasDeviceInfo*>(
  354. SendDlgItemMessage(IDC_CMB_SM_RAS_DEVICES,
  355. CB_GETITEMDATA, iCmb, 0L));
  356. AssertSz(prdiSelect, "We should have a prdiSelect");
  357. // Count the connected devices
  358. //
  359. ncsTemp = NcsGetDeviceStatus(prdiSelect);
  360. if (fIsConnectedStatus(ncsTemp))
  361. {
  362. nCnt++;
  363. }
  364. }
  365. }
  366. return nCnt;
  367. }
  368. //+---------------------------------------------------------------------------
  369. //
  370. // Member: CPspStatusMonitorRas::FillPropertyList
  371. //
  372. // Purpose: Fill in the list of RAS properties
  373. //
  374. // Arguments: None
  375. //
  376. // Returns: Nil
  377. //
  378. VOID CPspStatusMonitorRas::FillPropertyList(VOID)
  379. {
  380. TraceFileFunc(ttidStatMon);
  381. HWND hList = GetDlgItem(IDC_LVW_RAS_PROPERTY);
  382. // list view column structure
  383. RECT rect;
  384. LV_COLUMN lvCol;
  385. int index, iNewItem;
  386. // Calculate column width
  387. ::GetClientRect(hList, &rect);
  388. int colWidthFirst = (int)(rect.right * 0.4); // First column is 40%
  389. int colWidthSubsequent = (rect.right-colWidthFirst)/(c_nColumns-1); // Divide remaining space between other columns equally
  390. // The mask specifies that the fmt, width and pszText members
  391. // of the structure are valid
  392. lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT ;
  393. lvCol.fmt = LVCFMT_LEFT; // left-align column
  394. // Add the two columns and header text.
  395. for (index = 0; index < c_nColumns; index++)
  396. {
  397. // column header text
  398. if (0==index) // first column
  399. {
  400. lvCol.cx = colWidthFirst;
  401. lvCol.pszText = (PWSTR) SzLoadIds(IDS_PROPERTY);
  402. }
  403. else
  404. {
  405. lvCol.cx = colWidthSubsequent;
  406. lvCol.pszText = (PWSTR) SzLoadIds(IDS_VALUE);
  407. }
  408. iNewItem = ListView_InsertColumn(hList, index, &lvCol);
  409. AssertSz((iNewItem == index), "Invalid item inserted to list view !");
  410. }
  411. // Get RAS property data
  412. if (m_dwCharacter & NCCF_OUTGOING_ONLY)
  413. {
  414. FillRasClientProperty();
  415. }
  416. else
  417. {
  418. FillRasServerProperty();
  419. }
  420. }
  421. //+---------------------------------------------------------------------------
  422. //
  423. // Member: CPspStatusMonitorRas::FillRasClientProperty
  424. //
  425. // Purpose: Fill in the list of RAS properties for a RAS client
  426. //
  427. // Arguments: None
  428. //
  429. // Returns: Nil
  430. //
  431. VOID CPspStatusMonitorRas::FillRasClientProperty(VOID)
  432. {
  433. TraceFileFunc(ttidStatMon);
  434. BOOLEAN bSlipConnection = FALSE;
  435. HWND hList = GetDlgItem(IDC_LVW_RAS_PROPERTY);
  436. tstring strServerType = (PWSTR) SzLoadIds(IDS_PPP);
  437. tstring strProtocolList = c_szEmpty;
  438. tstring strDeviceName = c_szEmpty;
  439. tstring strDeviceType = c_szEmpty;
  440. DWORD dwRetCode;
  441. DWORD dwSize;
  442. RASCONNSTATUS rcs;
  443. rcs.dwSize = sizeof(RASCONNSTATUS);
  444. dwRetCode = RasGetConnectStatus (m_hRasConn, &rcs);
  445. if (dwRetCode == NO_ERROR)
  446. {
  447. strDeviceName = rcs.szDeviceName;
  448. strDeviceType = rcs.szDeviceType;
  449. TraceTag(ttidStatMon, "RASCONNSTATUS.szDeviceName = %s", rcs.szDeviceName);
  450. TraceTag(ttidStatMon, "RASCONNSTATUS.szDeviceType = %s", rcs.szDeviceType);
  451. }
  452. // RASP_PppIp
  453. tstring strServerIp = c_szEmpty;
  454. tstring strClientIp = c_szEmpty;
  455. RASPPPIP RasPppIp;
  456. RasPppIp.dwSize = sizeof( RasPppIp );
  457. dwSize = sizeof( RasPppIp );
  458. dwRetCode = RasGetProjectionInfo (m_hRasConn, RASP_PppIp, &RasPppIp, &dwSize);
  459. if ((dwRetCode == NO_ERROR) && (NO_ERROR == RasPppIp.dwError))
  460. {
  461. if (!strProtocolList.empty())
  462. strProtocolList += SzLoadIds(IDS_COMMA);
  463. strProtocolList += SzLoadIds(IDS_TCPIP);
  464. TraceTag(ttidStatMon, "RasPppIp.szServerIpAddress = %S", RasPppIp.szServerIpAddress);
  465. TraceTag(ttidStatMon, "RasPppIp.szIpAddress = %S", RasPppIp.szIpAddress);
  466. strServerIp = RasPppIp.szServerIpAddress;
  467. strClientIp = RasPppIp.szIpAddress;
  468. }
  469. // RASP_PppIpx
  470. tstring strClientIpx = c_szEmpty;
  471. RASPPPIPX RasPppIpx;
  472. RasPppIpx.dwSize = sizeof( RasPppIpx );
  473. dwSize = sizeof( RasPppIpx );
  474. dwRetCode = RasGetProjectionInfo (m_hRasConn, RASP_PppIpx, &RasPppIpx, &dwSize);
  475. if ((dwRetCode == NO_ERROR) && (NO_ERROR == RasPppIpx.dwError))
  476. {
  477. if (!strProtocolList.empty())
  478. strProtocolList += SzLoadIds(IDS_COMMA);
  479. strProtocolList += SzLoadIds(IDS_IPX);
  480. TraceTag(ttidStatMon, "RasPppIpx.szIpxAddress = %S", RasPppIpx.szIpxAddress);
  481. strClientIpx = RasPppIpx.szIpxAddress;
  482. }
  483. // RASP_PppNbf
  484. tstring strComputerName = c_szEmpty;
  485. RASPPPNBF RasPppNbf;
  486. RasPppNbf.dwSize = sizeof( RasPppNbf );
  487. dwSize = sizeof( RasPppNbf );
  488. dwRetCode = RasGetProjectionInfo (m_hRasConn, RASP_PppNbf, &RasPppNbf, &dwSize);
  489. if ((dwRetCode == NO_ERROR) && (NO_ERROR == RasPppNbf.dwError))
  490. {
  491. if (!strProtocolList.empty())
  492. strProtocolList += SzLoadIds(IDS_COMMA);
  493. strProtocolList += SzLoadIds(IDS_NBF);
  494. TraceTag(ttidStatMon, "RasPppNbf.szWorkstationName = %S", RasPppNbf.szWorkstationName);
  495. strComputerName = RasPppNbf.szWorkstationName;
  496. }
  497. // RASP_Slip
  498. RASSLIP RasSlip;
  499. RasSlip.dwSize = sizeof( RasSlip );
  500. dwSize = sizeof( RasSlip );
  501. dwRetCode = RasGetProjectionInfo (m_hRasConn, RASP_Slip, &RasSlip, &dwSize);
  502. if ((dwRetCode == NO_ERROR) && (NO_ERROR == RasSlip.dwError))
  503. {
  504. AssertSz(strProtocolList.empty(), "How could this connection be both PPP and SLIP ?");
  505. strServerType = SzLoadIds(IDS_SLIP);
  506. strProtocolList = SzLoadIds(IDS_TCPIP);
  507. // Get the client IP address. The server IP is not exposed in this
  508. // structure.
  509. strClientIp = RasSlip.szIpAddress;
  510. // Remember that this is a SLIP connection and not a PPP connection.
  511. bSlipConnection = TRUE;
  512. }
  513. // Authentication, Encryption and Compression info
  514. tstring strAuthentication = c_szEmpty;
  515. tstring strEncryption = c_szEmpty;
  516. tstring strIPSECEncryption = c_szEmpty;
  517. tstring strCompression = SzLoadIds(IDS_NONE);
  518. tstring strFraming = c_szEmpty;
  519. // RASP_PppLcp
  520. RASPPPLCP RasLcp;
  521. RasLcp.dwSize = sizeof( RasLcp );
  522. dwSize = sizeof( RasLcp );
  523. dwRetCode = RasGetProjectionInfo (m_hRasConn, RASP_PppLcp, &RasLcp, &dwSize);
  524. if ((dwRetCode == NO_ERROR) && (NO_ERROR == RasLcp.dwError))
  525. {
  526. TraceTag(ttidStatMon, "Getting RASP_PppLcp info");
  527. TraceTag(ttidStatMon, "RasLcp.dwServerAuthenticationProtocol = %d", RasLcp.dwAuthenticationProtocol);
  528. TraceTag(ttidStatMon, "RasLcp.dwServerAuthenticationData = %d", RasLcp.dwAuthenticationData);
  529. TraceTag(ttidStatMon, "RasLcp.fMultilink = %d", RasLcp.fMultilink);
  530. TraceTag(ttidStatMon, "RasLcp.dwOptions = %d", RasLcp.dwOptions);
  531. switch(RasLcp.dwServerAuthenticationProtocol)
  532. {
  533. case RASLCPAP_PAP:
  534. strAuthentication = SzLoadIds(IDS_PAP);
  535. break;
  536. case RASLCPAP_SPAP:
  537. strAuthentication = SzLoadIds(IDS_SPAP);
  538. break;
  539. case RASLCPAP_CHAP:
  540. {
  541. // get more specifics
  542. switch(RasLcp.dwServerAuthenticationData)
  543. {
  544. case RASLCPAD_CHAP_MS:
  545. strAuthentication = SzLoadIds(IDS_CHAP);
  546. break;
  547. case RASLCPAD_CHAP_MD5:
  548. strAuthentication = SzLoadIds(IDS_CHAP_MD5);
  549. break;
  550. case RASLCPAD_CHAP_MSV2:
  551. strAuthentication = SzLoadIds(IDS_CHAP_V2);
  552. break;
  553. }
  554. }
  555. break;
  556. case RASLCPAP_EAP:
  557. strAuthentication = SzLoadIds(IDS_EAP);
  558. break;
  559. }
  560. if (bSlipConnection == FALSE )
  561. {
  562. // Only PPP connections have the multilink property.
  563. if (RasLcp.fMultilink)
  564. strFraming = SzLoadIds(IDS_ON);
  565. else
  566. strFraming = SzLoadIds(IDS_OFF);
  567. }
  568. if (RasLcp.dwOptions & RASLCPO_DES_56)
  569. {
  570. strIPSECEncryption = SzLoadIds(IDS_EncryptionDES56);
  571. }
  572. else if (RasLcp.dwOptions & RASLCPO_3_DES)
  573. {
  574. strIPSECEncryption = SzLoadIds(IDS_Encryption3DES);
  575. }
  576. }
  577. // RASP_PppCcp
  578. RASPPPCCP RasCcp;
  579. RasCcp.dwSize = sizeof( RasCcp );
  580. dwSize = sizeof( RasCcp );
  581. dwRetCode = RasGetProjectionInfo (m_hRasConn, RASP_PppCcp, &RasCcp, &dwSize);
  582. if ((dwRetCode == NO_ERROR) && (NO_ERROR == RasCcp.dwError))
  583. {
  584. TraceTag(ttidStatMon, "Getting RASP_PppCcp info");
  585. TraceTag(ttidStatMon, "RasCcp.dwOptions = %x", RasCcp.dwOptions);
  586. TraceTag(ttidStatMon, "RasCcp.dwCompressionAlgorithm = %d", RasCcp.dwCompressionAlgorithm);
  587. if (RasCcp.dwOptions & RASCCPO_Encryption56bit)
  588. {
  589. strEncryption = SzLoadIds(IDS_Encryption56bit);
  590. }
  591. else if (RasCcp.dwOptions & RASCCPO_Encryption40bit)
  592. {
  593. strEncryption = SzLoadIds(IDS_Encryption40bit);
  594. }
  595. else if (RasCcp.dwOptions & RASCCPO_Encryption128bit)
  596. {
  597. strEncryption = SzLoadIds(IDS_Encryption128bit);
  598. }
  599. if (RasCcp.dwOptions & RASCCPO_Compression)
  600. {
  601. switch(RasCcp.dwCompressionAlgorithm)
  602. {
  603. case RASCCPCA_MPPC:
  604. strCompression = SzLoadIds(IDS_MPPC);
  605. break;
  606. case RASCCPCA_STAC:
  607. strCompression = SzLoadIds(IDS_STAC);
  608. break;
  609. }
  610. }
  611. }
  612. // Fill the list view
  613. ListView_DeleteAllItems(hList);
  614. int iItem =0;
  615. // Device name
  616. int iListviewItem = InsertProperty(&iItem, IDS_DeviceName, strDeviceName);
  617. if (-1 != iListviewItem)
  618. {
  619. ListView_SetItemState(hList, iListviewItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
  620. }
  621. // Device type
  622. InsertProperty(&iItem, IDS_DeviceType, strDeviceType);
  623. // Server type
  624. InsertProperty(&iItem, IDS_ServerType, strServerType);
  625. // Transports
  626. InsertProperty(&iItem, IDS_Transports, strProtocolList);
  627. // Authentication
  628. InsertProperty(&iItem, IDS_Authentication, strAuthentication);
  629. // Encryption
  630. InsertProperty(&iItem, IDS_Encryption, strEncryption);
  631. // IPSEC Encryption
  632. InsertProperty(&iItem, IDS_IPSECEncryption, strIPSECEncryption);
  633. // Compression
  634. InsertProperty(&iItem, IDS_Compression, strCompression);
  635. // PPP Multilink Framing
  636. InsertProperty(&iItem, IDS_ML_Framing, strFraming);
  637. // Server IP address
  638. InsertProperty(&iItem, IDS_ServerIP, strServerIp);
  639. // Client IP address
  640. InsertProperty(&iItem, IDS_ClientIP, strClientIp);
  641. // Client IPX address
  642. InsertProperty(&iItem, IDS_ClientIPX, strClientIpx);
  643. // Client computer name
  644. InsertProperty(&iItem, IDS_ComputerName, strComputerName);
  645. }
  646. //+---------------------------------------------------------------------------
  647. //
  648. // Member: CPspStatusMonitorRas::FillRasServerProperty
  649. //
  650. // Purpose: Fill in the list of RAS properties for a RAS server
  651. //
  652. // Arguments: None
  653. //
  654. // Returns: Nil
  655. //
  656. VOID CPspStatusMonitorRas::FillRasServerProperty(VOID)
  657. {
  658. TraceFileFunc(ttidStatMon);
  659. HWND hList = GetDlgItem(IDC_LVW_RAS_PROPERTY);
  660. RAS_SERVER_HANDLE hMprAdmin;
  661. DWORD dwError = MprAdminServerConnect(NULL, &hMprAdmin);
  662. if (dwError == NO_ERROR)
  663. {
  664. // Initialize the list view
  665. ListView_DeleteAllItems(hList);
  666. int iItem =0;
  667. //
  668. // Level 1 info
  669. //
  670. // Only PPP is supported on the RAS server
  671. tstring strServerType = (PWSTR) SzLoadIds(IDS_PPP);
  672. tstring strProtocolList = c_szEmpty;
  673. // IP info
  674. tstring strServerIp = c_szEmpty;
  675. tstring strClientIp = c_szEmpty;
  676. // IPX info
  677. tstring strClientIpx = c_szEmpty;
  678. // Nbf info
  679. tstring strComputerName = c_szEmpty;
  680. RAS_CONNECTION_1 * pConn1;
  681. dwError = MprAdminConnectionGetInfo(hMprAdmin,
  682. 1,
  683. m_hRasConn,
  684. (LPBYTE*)&pConn1);
  685. if (dwError == NO_ERROR)
  686. {
  687. PPP_INFO * pInfo = &(pConn1->PppInfo);
  688. // PPP_IPCP_INFO
  689. if (!(pInfo->ip).dwError)
  690. {
  691. if (!strProtocolList.empty())
  692. strProtocolList += SzLoadIds(IDS_COMMA);
  693. strProtocolList += SzLoadIds(IDS_TCPIP);
  694. strServerIp = pInfo->ip.wszAddress;
  695. strClientIp = pInfo->ip.wszRemoteAddress;
  696. }
  697. // PPP_IPXCP_INFO
  698. if (!pInfo->ipx.dwError)
  699. {
  700. if (!strProtocolList.empty())
  701. strProtocolList += SzLoadIds(IDS_COMMA);
  702. strProtocolList += SzLoadIds(IDS_IPX);
  703. strClientIpx = pInfo->ipx.wszAddress;
  704. }
  705. // PPP_NBFCP_INFO
  706. if (!pInfo->nbf.dwError)
  707. {
  708. if (!strProtocolList.empty())
  709. strProtocolList += SzLoadIds(IDS_COMMA);
  710. strProtocolList += SzLoadIds(IDS_NBF);
  711. strComputerName = pInfo->nbf.wszWksta;
  712. }
  713. // PPP_ATCP_INFO
  714. if (!pInfo->at.dwError)
  715. {
  716. if (!strProtocolList.empty())
  717. strProtocolList += SzLoadIds(IDS_COMMA);
  718. strProtocolList += SzLoadIds(IDS_APPLETALK);
  719. }
  720. MprAdminBufferFree(pConn1);
  721. }
  722. //
  723. // Level 2 info
  724. //
  725. // Authentication, Encryption and Compression
  726. tstring strAuthentication = c_szEmpty;
  727. tstring strEncryption = c_szEmpty;
  728. tstring strCompression = c_szEmpty;
  729. tstring strIPSECEncryption = c_szEmpty;
  730. RAS_CONNECTION_2 * pConn2;
  731. dwError = MprAdminConnectionGetInfo(hMprAdmin,
  732. 2,
  733. m_hRasConn,
  734. (LPBYTE*)&pConn2);
  735. if (dwError == NO_ERROR)
  736. {
  737. PPP_INFO_2 * pInfo2 = &(pConn2->PppInfo2);
  738. // PPP_LCP_INFO
  739. if (!(pInfo2->lcp).dwError)
  740. {
  741. TraceTag(ttidStatMon, "Getting PPP_LCP_INFO");
  742. TraceTag(ttidStatMon, "lcp.dwAuthenticationProtocol = %d", (pInfo2->lcp).dwAuthenticationProtocol);
  743. TraceTag(ttidStatMon, "lcp.dwAuthenticationData = %d", (pInfo2->lcp).dwAuthenticationData);
  744. TraceTag(ttidStatMon, "lcp.dwOptions = %d", (pInfo2->lcp).dwOptions);
  745. switch((pInfo2->lcp).dwAuthenticationProtocol)
  746. {
  747. case PPP_LCP_PAP:
  748. strAuthentication = SzLoadIds(IDS_PAP);
  749. break;
  750. case PPP_LCP_SPAP:
  751. strAuthentication = SzLoadIds(IDS_SPAP);
  752. break;
  753. case PPP_LCP_CHAP:
  754. {
  755. // get more specifics
  756. switch((pInfo2->lcp).dwAuthenticationData)
  757. {
  758. case RASLCPAD_CHAP_MS:
  759. strAuthentication = SzLoadIds(IDS_CHAP);
  760. break;
  761. case RASLCPAD_CHAP_MD5:
  762. strAuthentication = SzLoadIds(IDS_CHAP_MD5);
  763. break;
  764. case RASLCPAD_CHAP_MSV2:
  765. strAuthentication = SzLoadIds(IDS_CHAP_V2);
  766. break;
  767. }
  768. }
  769. break;
  770. case PPP_LCP_EAP:
  771. strAuthentication = SzLoadIds(IDS_EAP);
  772. break;
  773. }
  774. if ((pInfo2->lcp).dwOptions & PPP_LCP_DES_56)
  775. {
  776. strIPSECEncryption = SzLoadIds(IDS_EncryptionDES56);
  777. }
  778. else if ((pInfo2->lcp).dwOptions & PPP_LCP_3_DES)
  779. {
  780. strIPSECEncryption = SzLoadIds(IDS_Encryption3DES);
  781. }
  782. }
  783. // PPP_CCP_INFO
  784. if (!(pInfo2->ccp).dwError)
  785. {
  786. TraceTag(ttidStatMon, "Getting PPP_CCP_INFO");
  787. TraceTag(ttidStatMon, "ccp.dwOptions = %x", pInfo2->ccp.dwOptions);
  788. TraceTag(ttidStatMon, "ccp.dwCompressionAlgorithm = %d", pInfo2->ccp.dwCompressionAlgorithm);
  789. if ((pInfo2->ccp.dwOptions) & PPP_CCP_ENCRYPTION56BIT)
  790. {
  791. strEncryption = SzLoadIds(IDS_Encryption56bit);
  792. }
  793. else if ((pInfo2->ccp.dwOptions) & PPP_CCP_ENCRYPTION40BIT)
  794. {
  795. strEncryption = SzLoadIds(IDS_Encryption40bit);
  796. }
  797. else if ((pInfo2->ccp.dwOptions) & PPP_CCP_ENCRYPTION128BIT)
  798. {
  799. strEncryption = SzLoadIds(IDS_Encryption128bit);
  800. }
  801. if ((pInfo2->ccp.dwOptions) & PPP_CCP_COMPRESSION)
  802. {
  803. switch(pInfo2->ccp.dwCompressionAlgorithm)
  804. {
  805. case RASCCPCA_MPPC:
  806. strCompression = SzLoadIds(IDS_MPPC);
  807. break;
  808. case RASCCPCA_STAC:
  809. strCompression = SzLoadIds(IDS_STAC);
  810. break;
  811. }
  812. }
  813. }
  814. MprAdminBufferFree(pConn2);
  815. }
  816. MprAdminServerDisconnect(hMprAdmin);
  817. // Now add to the list view
  818. // Server type
  819. InsertProperty(&iItem, IDS_ServerType, strServerType);
  820. // Transports
  821. InsertProperty(&iItem, IDS_Transports, strProtocolList);
  822. // Authentication
  823. InsertProperty(&iItem, IDS_Authentication, strAuthentication);
  824. // Encryption
  825. InsertProperty(&iItem, IDS_Encryption, strEncryption);
  826. // IPSEC Encryption
  827. InsertProperty(&iItem, IDS_IPSECEncryption, strIPSECEncryption);
  828. // Compression
  829. InsertProperty(&iItem, IDS_Compression, strCompression);
  830. // Server IP address
  831. InsertProperty(&iItem, IDS_ServerIP, strServerIp);
  832. // Client IP address
  833. InsertProperty(&iItem, IDS_ClientIP, strClientIp);
  834. // Client IPX address
  835. InsertProperty(&iItem, IDS_ClientIPX, strClientIpx);
  836. // Client computer name
  837. InsertProperty(&iItem, IDS_ComputerName, strComputerName);
  838. }
  839. }
  840. //+---------------------------------------------------------------------------
  841. //
  842. // Member: CPspStatusMonitorRas::InsertProperty
  843. //
  844. // Purpose: Fill one RAS properties to the list
  845. //
  846. // Arguments: piItem - the index ofthe item
  847. // unId - the property name
  848. // strValue - the property value
  849. //
  850. // Returns: Nil
  851. //
  852. int CPspStatusMonitorRas::InsertProperty(int * piItem,
  853. UINT unId,
  854. tstring& strValue)
  855. {
  856. TraceFileFunc(ttidStatMon);
  857. int lres = 0;
  858. if (!strValue.empty())
  859. {
  860. int iItem = *piItem;
  861. LV_ITEM lvItem;
  862. lvItem.mask = LVIF_TEXT;
  863. lvItem.iItem=iItem;
  864. lvItem.iSubItem=0;
  865. lvItem.pszText = (PWSTR) SzLoadIds(unId);
  866. lres = static_cast<int>(SendDlgItemMessage(IDC_LVW_RAS_PROPERTY, LVM_INSERTITEM,
  867. iItem, (LPARAM)&lvItem));
  868. lvItem.iSubItem=1;
  869. lvItem.pszText=(PWSTR)strValue.c_str();
  870. SendDlgItemMessage(IDC_LVW_RAS_PROPERTY, LVM_SETITEMTEXT,
  871. iItem, (LPARAM)&lvItem);
  872. ++(*piItem);
  873. }
  874. return lres;
  875. }
  876. //+---------------------------------------------------------------------------
  877. //
  878. // Member: CPspStatusMonitorRas::FillDeviceDropDown
  879. //
  880. // Purpose: Do the initialization required when the page has just been created
  881. //
  882. // Arguments: None
  883. //
  884. // Returns: Nil
  885. //
  886. VOID CPspStatusMonitorRas::FillDeviceDropDown(VOID)
  887. {
  888. TraceFileFunc(ttidStatMon);
  889. INT iCmb = 0;
  890. list<CRasDeviceInfo*>::iterator iterLstprdi;
  891. // Clear out the control
  892. //
  893. SendDlgItemMessage(IDC_CMB_SM_RAS_DEVICES, CB_RESETCONTENT, 0, 0L);
  894. // Put the devices in our list
  895. //
  896. iterLstprdi = m_lstprdi.begin();
  897. while (iterLstprdi != m_lstprdi.end())
  898. {
  899. // Create a new entry in the list
  900. //
  901. iCmb = (INT)SendDlgItemMessage(IDC_CMB_SM_RAS_DEVICES, CB_ADDSTRING, 0,
  902. (LPARAM)((*iterLstprdi)->PszGetDeviceName()));
  903. if (CB_ERR != iCmb)
  904. {
  905. // Store the vaule on the selection to make it easy to read later
  906. //
  907. SendDlgItemMessage(IDC_CMB_SM_RAS_DEVICES, CB_SETITEMDATA, iCmb,
  908. (LPARAM)(*iterLstprdi));
  909. }
  910. iterLstprdi++;
  911. }
  912. // Set the first selection
  913. //
  914. SendDlgItemMessage(IDC_CMB_SM_RAS_DEVICES, CB_SETCURSEL, 0L, 0L);
  915. // Make sure the state of the button is correct
  916. //
  917. iCmb = (INT)SendDlgItemMessage(IDC_CMB_SM_RAS_DEVICES, CB_GETCURSEL,
  918. 0L, 0L);
  919. if (CB_ERR != iCmb)
  920. {
  921. CRasDeviceInfo* prdiSelect = NULL;
  922. // Get the object from the selection
  923. //
  924. prdiSelect = reinterpret_cast<CRasDeviceInfo*>(
  925. SendDlgItemMessage(
  926. IDC_CMB_SM_RAS_DEVICES,
  927. CB_GETITEMDATA,
  928. iCmb,
  929. 0L));
  930. SetButtonStatus(prdiSelect);
  931. }
  932. // If the number of devices is less than or equal to one then
  933. // hide the device related group of controls
  934. //
  935. if (m_lstprdi.size() <= 1)
  936. {
  937. int nrgIdc[] = {IDC_CMB_SM_RAS_DEVICES, IDC_TXT_SM_NUM_DEVICES,
  938. IDC_TXT_SM_NUM_DEVICES_VAL, IDC_BTN_SM_SUSPEND_DEVICE,
  939. IDC_GB_SM_DEVICES};
  940. for (int nIdx=0; nIdx < celems(nrgIdc); nIdx++)
  941. ::ShowWindow(GetDlgItem(nrgIdc[nIdx]), SW_HIDE);
  942. // We can now display a larger properties window
  943. RECT rcRectDialog;
  944. if (GetWindowRect(&rcRectDialog))
  945. {
  946. RECT rcRectRasProperty;
  947. if (::GetWindowRect(GetDlgItem(IDC_LVW_RAS_PROPERTY), &rcRectRasProperty))
  948. {
  949. DWORD dwTopDiff = rcRectRasProperty.top - rcRectDialog.top;
  950. DWORD dwLeftDiff = rcRectRasProperty.left - rcRectDialog.left;
  951. DWORD dwRightDiff = rcRectDialog.right - rcRectRasProperty.right;
  952. DWORD dwBottomDiff = rcRectDialog.bottom - rcRectRasProperty.bottom;
  953. DWORD dwDialogWidth = rcRectDialog.right - rcRectDialog.left;
  954. DWORD dwDialogHeight = rcRectDialog.bottom - rcRectDialog.top;
  955. rcRectRasProperty.top = dwTopDiff;
  956. rcRectRasProperty.left = dwLeftDiff;
  957. rcRectRasProperty.right = dwDialogWidth - dwRightDiff;
  958. rcRectRasProperty.bottom = dwDialogHeight - dwRightDiff;
  959. ::MoveWindow(GetDlgItem(IDC_LVW_RAS_PROPERTY), rcRectRasProperty.left, rcRectRasProperty.top,
  960. rcRectRasProperty.right - rcRectRasProperty.left, rcRectRasProperty.bottom - rcRectRasProperty.top, TRUE);
  961. }
  962. }
  963. // Disable the suspend button, so no one can activate it by keystroke
  964. //
  965. ::EnableWindow(GetDlgItem(IDC_BTN_SM_SUSPEND_DEVICE), FALSE);
  966. }
  967. else
  968. {
  969. // Set the number of active devices
  970. //
  971. UINT unActiveDeviceCount = GetActiveDeviceCount();
  972. SetDlgItemInt(
  973. IDC_TXT_SM_NUM_DEVICES_VAL,
  974. unActiveDeviceCount,
  975. FALSE);
  976. }
  977. }
  978. //+---------------------------------------------------------------------------
  979. //
  980. // Member: CPspStatusMonitorRas::OnSuspendDevice
  981. //
  982. // Purpose: Suspend the device that is in the combo box
  983. //
  984. // Arguments: Standard window message
  985. //
  986. // Returns: Standard return.
  987. //
  988. LRESULT CPspStatusMonitorRas::OnSuspendDevice(WORD wNotifyCode, WORD wID,
  989. HWND hWndCtl, BOOL& fHandled)
  990. {
  991. TraceFileFunc(ttidStatMon);
  992. HRESULT hr = S_OK;
  993. if (BN_CLICKED == wNotifyCode)
  994. {
  995. // Get the item in the drop down
  996. //
  997. INT iCmb = (INT)SendDlgItemMessage(IDC_CMB_SM_RAS_DEVICES, CB_GETCURSEL,
  998. 0L, 0L);
  999. if (CB_ERR != iCmb)
  1000. {
  1001. CRasDeviceInfo* prdiSelect = NULL;
  1002. NETCON_STATUS ncsTemp = NCS_DISCONNECTED;
  1003. // Get the object from the selection
  1004. //
  1005. prdiSelect = reinterpret_cast<CRasDeviceInfo*>(
  1006. SendDlgItemMessage(
  1007. IDC_CMB_SM_RAS_DEVICES,
  1008. CB_GETITEMDATA,
  1009. iCmb,
  1010. 0L));
  1011. AssertSz(prdiSelect, "We should have a prdiSelect");
  1012. AssertSz(m_hRasConn, "We should have a m_hRasConn");
  1013. // Disable the button till the suspend/resume is done
  1014. ::EnableWindow(GetDlgItem(IDC_BTN_SM_SUSPEND_DEVICE), FALSE);
  1015. ncsTemp = NcsGetDeviceStatus(prdiSelect);
  1016. if (fIsConnectedStatus(ncsTemp))
  1017. {
  1018. // If more than one active link exists, allow the hang up
  1019. //
  1020. UINT unActiveDeviceCount = GetActiveDeviceCount();
  1021. if ( unActiveDeviceCount >1)
  1022. {
  1023. HRASCONN hrasconnSub = NULL;
  1024. // Get the handle to the sub entry and hangup
  1025. //
  1026. hr = ::HrRasGetSubEntryHandle(m_hRasConn,
  1027. prdiSelect->DwGetSubEntry(), &hrasconnSub);
  1028. if (SUCCEEDED(hr))
  1029. {
  1030. hr = ::HrRasHangUp(hrasconnSub);
  1031. }
  1032. }
  1033. else
  1034. {
  1035. // Only one active link exists, prompt the user if
  1036. // they really wish to disconnect
  1037. //
  1038. HWND hwndPS = ::GetParent(m_hWnd);
  1039. if (IDYES == ::NcMsgBox(hwndPS,
  1040. IDS_SM_ERROR_CAPTION, IDS_SM_DISCONNECT_PROMPT,
  1041. MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2,
  1042. m_strConnectionName.c_str()))
  1043. {
  1044. AssertSz(m_pGenPage, "We should have a pointer to the general page.");
  1045. if (m_pGenPage)
  1046. {
  1047. hr = m_pGenPage->HrDisconnectConnection(TRUE);
  1048. }
  1049. }
  1050. }
  1051. }
  1052. else
  1053. {
  1054. // if the link was disconnected, "resume"
  1055. BOOL fRet = FALSE;
  1056. RASDIALDLG rdiTemp = { 0 };
  1057. // Initialize the structure
  1058. //
  1059. rdiTemp.dwSize = sizeof(RASDIALDLG);
  1060. rdiTemp.hwndOwner = m_hWnd;
  1061. rdiTemp.dwSubEntry = prdiSelect->DwGetSubEntry();
  1062. // Dial the entry
  1063. //
  1064. fRet = RasDialDlg(
  1065. const_cast<PWSTR>(m_strPbkFile.c_str()),
  1066. const_cast<PWSTR>(m_strEntryName.c_str()),
  1067. NULL,
  1068. &rdiTemp);
  1069. // We have an error. See if the user canceled
  1070. //
  1071. if (ERROR_CANCELLED != rdiTemp.dwError)
  1072. {
  1073. hr = HRESULT_FROM_WIN32(rdiTemp.dwError);
  1074. }
  1075. }
  1076. // Regardless of what happened, set the status to it's new
  1077. // state
  1078. //
  1079. SetButtonStatus(prdiSelect);
  1080. // Re-Enable the button till the suspend/resume is done
  1081. ::EnableWindow(GetDlgItem(IDC_BTN_SM_SUSPEND_DEVICE), TRUE);
  1082. // Also update the active device count
  1083. UINT unActiveDeviceCount = GetActiveDeviceCount();
  1084. SetDlgItemInt(
  1085. IDC_TXT_SM_NUM_DEVICES_VAL,
  1086. unActiveDeviceCount,
  1087. FALSE);
  1088. }
  1089. }
  1090. return 0;
  1091. }
  1092. //+---------------------------------------------------------------------------
  1093. //
  1094. // Member: CPspStatusMonitorRas::OnDeviceDropDown
  1095. //
  1096. // Purpose: Update the push button text when the combo-box selection changes
  1097. //
  1098. // Arguments: Standard window messsage parameters
  1099. //
  1100. // Returns: Standard window message return value
  1101. //
  1102. LRESULT CPspStatusMonitorRas::OnDeviceDropDown(WORD wNotifyCode, WORD wID,
  1103. HWND hWndCtl, BOOL& fHandled)
  1104. {
  1105. TraceFileFunc(ttidStatMon);
  1106. if (CBN_SELCHANGE == wNotifyCode)
  1107. {
  1108. INT iCmb = (INT)SendDlgItemMessage(IDC_CMB_SM_RAS_DEVICES, CB_GETCURSEL,
  1109. 0L, 0L);
  1110. if (CB_ERR != iCmb)
  1111. {
  1112. CRasDeviceInfo* prdiSelect = NULL;
  1113. INT idsButton = 0;
  1114. prdiSelect = reinterpret_cast<CRasDeviceInfo*>(
  1115. SendDlgItemMessage(
  1116. IDC_CMB_SM_RAS_DEVICES,
  1117. CB_GETITEMDATA,
  1118. iCmb,
  1119. 0L));
  1120. AssertSz(prdiSelect, "We should have a prdiSelect");
  1121. if (fIsConnectedStatus(NcsGetDeviceStatus(prdiSelect)))
  1122. {
  1123. idsButton = IDS_SM_SUSPEND;
  1124. }
  1125. else
  1126. {
  1127. idsButton = IDS_SM_RESUME;
  1128. }
  1129. // Set the new name
  1130. //
  1131. SetDlgItemText(IDC_BTN_SM_SUSPEND_DEVICE,
  1132. ::SzLoadIds(idsButton));
  1133. }
  1134. }
  1135. return 0;
  1136. }
  1137. //+---------------------------------------------------------------------------
  1138. //
  1139. // Member: CPspStatusMonitorRas::NcsGetDeviceStatus
  1140. //
  1141. // Purpose: Gets the status of one of the RAS subentries
  1142. //
  1143. // Arguments: prdiStatus - Device to get status of
  1144. //
  1145. // Returns: The status of the device
  1146. //
  1147. LRESULT CPspStatusMonitorRas::OnUpdateRasLinkList(UINT uMsg, WPARAM wParam,
  1148. LPARAM lParam, BOOL& bHandled)
  1149. {
  1150. TraceFileFunc(ttidStatMon);
  1151. // Get the item in the drop down
  1152. //
  1153. INT iCmb = (INT)SendDlgItemMessage(IDC_CMB_SM_RAS_DEVICES, CB_GETCURSEL,
  1154. 0L, 0L);
  1155. if (CB_ERR != iCmb)
  1156. {
  1157. CRasDeviceInfo* prdiSelect = NULL;
  1158. // Get the object from the selection
  1159. //
  1160. prdiSelect = reinterpret_cast<CRasDeviceInfo*>(
  1161. SendDlgItemMessage(
  1162. IDC_CMB_SM_RAS_DEVICES,
  1163. CB_GETITEMDATA,
  1164. iCmb,
  1165. 0L));
  1166. if (prdiSelect)
  1167. {
  1168. // Regardless of what happened, set the status to it's new
  1169. // state
  1170. //
  1171. SetButtonStatus(prdiSelect);
  1172. // Also update the active device count
  1173. UINT unActiveDeviceCount = GetActiveDeviceCount();
  1174. SetDlgItemInt(
  1175. IDC_TXT_SM_NUM_DEVICES_VAL,
  1176. unActiveDeviceCount,
  1177. FALSE);
  1178. }
  1179. }
  1180. return 0;
  1181. }
  1182. //+---------------------------------------------------------------------------
  1183. //
  1184. // Member: CPspStatusMonitorRas::NcsGetDeviceStatus
  1185. //
  1186. // Purpose: Gets the status of one of the RAS subentries
  1187. //
  1188. // Arguments: prdiStatus - Device to get status of
  1189. //
  1190. // Returns: The status of the device
  1191. //
  1192. NETCON_STATUS
  1193. CPspStatusMonitorRas::NcsGetDeviceStatus(
  1194. CRasDeviceInfo* prdiStatus)
  1195. {
  1196. TraceFileFunc(ttidStatMon);
  1197. NETCON_STATUS ncsStatus = NCS_DISCONNECTED;
  1198. HRESULT hr = S_OK;
  1199. HRASCONN hrasconnSub = NULL;
  1200. TraceTag(ttidStatMon, " === Calling NcsGetDeviceStatus on device: %S, subentry: %d ===",
  1201. prdiStatus->PszGetDeviceName(), prdiStatus->DwGetSubEntry());
  1202. // Get the handle to the subentry so that we can
  1203. // tell what state the connection is in. If we
  1204. // can't do that, assume it is disconnected
  1205. //
  1206. hr = HrRasGetSubEntryHandle(m_hRasConn,
  1207. prdiStatus->DwGetSubEntry(), &hrasconnSub);
  1208. TraceTag(ttidStatMon, "HrRasGetSubEntryHandle returns, hr = %x", hr);
  1209. if (SUCCEEDED(hr))
  1210. {
  1211. hr = HrRasGetNetconStatusFromRasConnectStatus (
  1212. hrasconnSub, &ncsStatus);
  1213. TraceTag(ttidStatMon, "HrRasGetNetconStatusFromRasConnectStatus returns hr = %x, Status = %d",
  1214. hr, ncsStatus);
  1215. }
  1216. return ncsStatus;
  1217. }
  1218. //+---------------------------------------------------------------------------
  1219. //
  1220. // Member: CPspStatusMonitorRas::SetButtonStatus
  1221. //
  1222. // Purpose: Change the suspend/resume button to the correct state
  1223. //
  1224. // Arguments: prdiSelect - The device that is selected
  1225. //
  1226. // Returns: Nil
  1227. //
  1228. VOID CPspStatusMonitorRas::SetButtonStatus(CRasDeviceInfo* prdiSelect)
  1229. {
  1230. TraceFileFunc(ttidStatMon);
  1231. //$ REVIEW : CWill : 02/25/98 : Common function?
  1232. INT idsButton = 0;
  1233. if (fIsConnectedStatus(NcsGetDeviceStatus(prdiSelect)))
  1234. {
  1235. idsButton = IDS_SM_SUSPEND;
  1236. }
  1237. else
  1238. {
  1239. idsButton = IDS_SM_RESUME;
  1240. }
  1241. // Set the new name
  1242. //
  1243. SetDlgItemText(IDC_BTN_SM_SUSPEND_DEVICE,
  1244. ::SzLoadIds(idsButton));
  1245. }
  1246. //+---------------------------------------------------------------------------
  1247. //
  1248. // Function: HrRasGetSubEntryHandle
  1249. //
  1250. // Purpose: Wrapper around RasGetSubEntryHandle
  1251. //
  1252. // Arguments: RasGetSubEntryHandle arguements
  1253. //
  1254. // Returns: Error code
  1255. //
  1256. HRESULT HrRasGetSubEntryHandle(HRASCONN hrasconn, DWORD dwSubEntry,
  1257. HRASCONN* prasconnSub)
  1258. {
  1259. TraceFileFunc(ttidStatMon);
  1260. HRESULT hr = S_OK;
  1261. DWORD dwRet = ::RasGetSubEntryHandle(hrasconn, dwSubEntry,
  1262. prasconnSub);
  1263. if (dwRet)
  1264. {
  1265. hr = HRESULT_FROM_WIN32(dwRet);
  1266. }
  1267. TraceError("HrRasGetSubEntryHandle", hr);
  1268. return hr;
  1269. }
  1270. //+---------------------------------------------------------------------------
  1271. //
  1272. // Function: HrRasHangUp
  1273. //
  1274. // Purpose: Wrapper around RasHangUp
  1275. //
  1276. // Arguments: RasHangUp arguements
  1277. //
  1278. // Returns: Error code
  1279. //
  1280. HRESULT HrRasHangUp(HRASCONN hrasconn)
  1281. {
  1282. TraceFileFunc(ttidStatMon);
  1283. HRESULT hr = S_OK;
  1284. DWORD dwRet = ::RasHangUp(hrasconn);
  1285. if (dwRet)
  1286. {
  1287. hr = HRESULT_FROM_WIN32(dwRet);
  1288. }
  1289. TraceError("HrRasHangUp", hr);
  1290. return hr;
  1291. }