|
5 | 5 | * COPYRIGHT: Copyright 2024-2025 Vitaly Orekhov <[email protected]> |
6 | 6 | */ |
7 | 7 | #include "main.h" |
| 8 | +#include <xmllite.h> |
8 | 9 |
|
9 | 10 | LRESULT CWlanWizard::OnMeasureItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) |
10 | 11 | { |
@@ -97,7 +98,7 @@ LRESULT CWlanWizard::OnDrawItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b |
97 | 98 | HICON hSidebarIcon = NULL; |
98 | 99 |
|
99 | 100 | wParam == IDC_WLANWIZ_PREFERRED_APS |
100 | | - ? hSidebarIcon = LoadIconW(GetModuleHandleW(L"shell32.dll"), MAKEINTRESOURCE(44)) /* 'Favorites' icon */ |
| 101 | + ? hSidebarIcon = LoadIconW(GetModuleHandleW(L"shell32.dll"), MAKEINTRESOURCE(IDI_SHELL32_FAVORITES)) |
101 | 102 | : hSidebarIcon = LoadIconW(wlanwiz_hInstance, MAKEINTRESOURCEW(wParam + 20)); |
102 | 103 |
|
103 | 104 | DrawIconEx(this->hThemeEB ? hDCBtn : pdis->hDC, |
@@ -374,6 +375,82 @@ LRESULT CWlanWizard::OnDrawItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b |
374 | 375 | DrawTextW(pdis->hDC, cswExpandedText, cswExpandedText.GetLength(), &rcExpandedText, DT_WORDBREAK | DT_LEFT); |
375 | 376 | } |
376 | 377 |
|
| 378 | + /* Connection state or preference as set in saved profile */ |
| 379 | + ATL::CStringW cswConnState; |
| 380 | + GUID interfaceGuid; |
| 381 | + LPWSTR pstrProfileXml = NULL; |
| 382 | + DWORD dwFlags = 0, dwGrantedAccess = WLAN_READ_ACCESS; |
| 383 | + IIDFromString(this->m_sGUID, &interfaceGuid); |
| 384 | + |
| 385 | + if ( wcslen(pWlanNetwork->strProfileName) |
| 386 | + && SUCCEEDED(WlanGetProfile(this->hWlanClient, &interfaceGuid, pWlanNetwork->strProfileName, NULL, &pstrProfileXml, &dwFlags, &dwGrantedAccess)) |
| 387 | + && pstrProfileXml != NULL) |
| 388 | + { |
| 389 | + ATL::CComPtr<IStream> xmlStream = CreateDataStream(pstrProfileXml, wcslen(pstrProfileXml)); |
| 390 | + ATL::CComPtr<IXmlReader> xmlReader; |
| 391 | + WlanFreeMemory(pstrProfileXml); |
| 392 | + |
| 393 | + CreateXmlReader(IID_IXmlReader, reinterpret_cast<LPVOID*>(&xmlReader), 0); |
| 394 | + xmlReader->SetInput(xmlStream); |
| 395 | + |
| 396 | + bool bNodeFound = false; |
| 397 | + XmlNodeType xnType = XmlNodeType_None; |
| 398 | + while (!bNodeFound) |
| 399 | + { |
| 400 | + LPCWSTR pwszLocalName; |
| 401 | + xmlReader->Read(&xnType); |
| 402 | + |
| 403 | + switch(xnType) |
| 404 | + { |
| 405 | + case XmlNodeType_Element: |
| 406 | + { |
| 407 | + xmlReader->GetLocalName(&pwszLocalName, NULL); |
| 408 | + |
| 409 | + if (pwszLocalName && wcsicmp(pwszLocalName, L"connectionMode") == 0) |
| 410 | + { |
| 411 | + LPCWSTR pwszConnectionMode; |
| 412 | + xmlReader->GetValue(&pwszConnectionMode, NULL); |
| 413 | + |
| 414 | + cswConnState.LoadStringW(wcsicmp(pwszConnectionMode, L"auto") == 0 |
| 415 | + ? IDS_WLANWIZ_CONNECTED_AUTO |
| 416 | + : IDS_WLANWIZ_CONNECTED_MANU); |
| 417 | + |
| 418 | + RECT rcConnMode = |
| 419 | + { |
| 420 | + .left = pdis->rcItem.right - 70, |
| 421 | + .top = pdis->rcItem.top + 3, |
| 422 | + .right = pdis->rcItem.right - 25, |
| 423 | + .bottom = pdis->rcItem.top + 22 |
| 424 | + }; |
| 425 | + |
| 426 | + DrawTextW(pdis->hDC, cswConnState, cswConnState.GetLength(), &rcConnMode, DT_RIGHT); |
| 427 | + |
| 428 | + HICON hFav = LoadIconW(GetModuleHandleW(L"shell32.dll"), MAKEINTRESOURCE(IDI_SHELL32_FAVORITES)); |
| 429 | + |
| 430 | + DrawIconEx(pdis->hDC, |
| 431 | + pdis->rcItem.right - 20, pdis->rcItem.top + 3, |
| 432 | + hFav, |
| 433 | + 16, 16, |
| 434 | + 0, |
| 435 | + 0, |
| 436 | + DI_NORMAL |
| 437 | + ); |
| 438 | + |
| 439 | + DestroyIcon(hFav); |
| 440 | + bNodeFound = true; |
| 441 | + } |
| 442 | + |
| 443 | + break; |
| 444 | + } |
| 445 | + default: |
| 446 | + break; |
| 447 | + } |
| 448 | + } |
| 449 | + |
| 450 | + xmlReader.Release(); |
| 451 | + xmlStream.Release(); |
| 452 | + } |
| 453 | + |
377 | 454 | SetTextColor(pdis->hDC, crItemText); |
378 | 455 |
|
379 | 456 | /* Shrink focus rectangle for listbox items */ |
|
0 commit comments