ReactOS 0.4.17-dev-573-g8315b8c
lanstatusui.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Shell
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: CLanStatus: Lan connection status dialog
5 * COPYRIGHT: Copyright 2008 Johannes Anderwald (johannes.anderwald@reactos.org)
6 */
7
8#include "precomp.h"
9
10#include <winsock.h>
11
12#define NETTIMERID 0xFABC
13
15 m_lpNetMan(NULL),
16 m_pHead(NULL)
17{
18}
19
20VOID
22 HWND hwndDlg,
23 MIB_IFROW *IfEntry,
24 LANSTATUSUI_CONTEXT *pContext)
25{
26 WCHAR szFormat[MAX_PATH] = {0};
27 WCHAR szBuffer[MAX_PATH] = {0};
28 SYSTEMTIME TimeConnected;
29 DWORD DurationSeconds;
30 WCHAR Buffer[100];
31 WCHAR DayBuffer[30];
32 WCHAR LocBuffer[50];
33
34#if 0
35 ULONGLONG Ticks;
36#else
37 DWORD Ticks;
38#endif
39
40 if (IfEntry->dwSpeed < 1000)
41 {
42 if (LoadStringW(netshell_hInstance, IDS_FORMAT_BIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
43 {
44 _swprintf(szBuffer, szFormat, IfEntry->dwSpeed);
45 SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
46 }
47 }
48 else if (IfEntry->dwSpeed < 1000000)
49 {
50 if (LoadStringW(netshell_hInstance, IDS_FORMAT_KBIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
51 {
52 _swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000);
53 SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
54 }
55 }
56 else if (IfEntry->dwSpeed < 1000000000)
57 {
58 if (LoadStringW(netshell_hInstance, IDS_FORMAT_MBIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
59 {
60 _swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000000);
61 SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
62 }
63 }
64 else
65 {
66 if (LoadStringW(netshell_hInstance, IDS_FORMAT_GBIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
67 {
68 _swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000000000);
69 SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
70 }
71 }
72
73 if (StrFormatByteSizeW(IfEntry->dwInOctets, szBuffer, _countof(szBuffer)))
74 {
75 SendDlgItemMessageW(hwndDlg, IDC_RECEIVED, WM_SETTEXT, 0, (LPARAM)szBuffer);
76 }
77
78 if (StrFormatByteSizeW(IfEntry->dwOutOctets, szBuffer, _countof(szBuffer)))
79 {
80 SendDlgItemMessageW(hwndDlg, IDC_SEND, WM_SETTEXT, 0, (LPARAM)szBuffer);
81 }
82
83#if 0
84 Ticks = GetTickCount64();
85#else
86 Ticks = GetTickCount();
87#endif
88
89 DurationSeconds = Ticks / 1000;
90 TimeConnected.wSecond = (DurationSeconds % 60);
91 TimeConnected.wMinute = (DurationSeconds / 60) % 60;
92 TimeConnected.wHour = (DurationSeconds / (60 * 60)) % 24;
93 TimeConnected.wDay = DurationSeconds / (60 * 60 * 24);
94
95 if (!GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &TimeConnected, L"HH':'mm':'ss", LocBuffer, sizeof(LocBuffer) / sizeof(LocBuffer[0])))
96 return;
97
98 if (!TimeConnected.wDay)
99 {
100 SendDlgItemMessageW(hwndDlg, IDC_DURATION, WM_SETTEXT, 0, (LPARAM)LocBuffer);
101 }
102 else
103 {
104 if (TimeConnected.wDay == 1)
105 {
106 if (!LoadStringW(netshell_hInstance, IDS_DURATION_DAY, DayBuffer, sizeof(DayBuffer) / sizeof(DayBuffer[0])))
107 DayBuffer[0] = L'\0';
108 }
109 else
110 {
111 if (!LoadStringW(netshell_hInstance, IDS_DURATION_DAYS, DayBuffer, sizeof(DayBuffer) / sizeof(DayBuffer[0])))
112 DayBuffer[0] = L'\0';
113 }
114 _swprintf(Buffer, DayBuffer, TimeConnected.wDay, LocBuffer);
116 }
117
118}
119
120VOID
122{
123 MIB_IFROW IfEntry;
124 HICON hIcon, hOldIcon = NULL;
126 NETCON_PROPERTIES * pProperties = NULL;
127
128 ZeroMemory(&IfEntry, sizeof(IfEntry));
129 IfEntry.dwIndex = pContext->dwAdapterIndex;
130 if (GetIfEntry(&IfEntry) != NO_ERROR)
131 {
132 return;
133 }
134
135 if (pContext->Status == (UINT)-1)
136 {
137 /*
138 * On first execution, pContext->dw[In|Out]Octets will be zero while
139 * the interface info is already refreshed with non-null data, so a
140 * gap is normal and does not correspond to an effective TX or RX packet.
141 */
142 pContext->dwInOctets = IfEntry.dwInOctets;
143 pContext->dwOutOctets = IfEntry.dwOutOctets;
144 }
145
146 hIcon = NULL;
148 {
149 if (pContext->dwInOctets == IfEntry.dwInOctets && pContext->dwOutOctets == IfEntry.dwOutOctets && pContext->Status != 0)
150 {
152 pContext->Status = 0;
153 }
154 else if (pContext->dwInOctets != IfEntry.dwInOctets && pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 1)
155 {
157 pContext->Status = 1;
158 }
159 else if (pContext->dwInOctets != IfEntry.dwInOctets && pContext->Status != 2)
160 {
162 pContext->Status = 2;
163 }
164 else if (pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 3)
165 {
167 pContext->Status = 3;
168 }
169 }
171 {
172 if (pContext->Status != 4)
173 {
175 pContext->Status = 4;
176 }
177 }
179 {
180 if (pContext->Status != 5)
181 {
183 pContext->Status = 5;
184 }
185 }
186
187 if (hwndDlg && hIcon)
188 {
189 hOldIcon = (HICON)SendDlgItemMessageW(hwndDlg, IDC_NETSTAT, STM_SETICON, (WPARAM)hIcon, 0);
190 if (hOldIcon)
191 DestroyIcon(hOldIcon);
192 }
193
194 ZeroMemory(&nid, sizeof(nid));
195 nid.cbSize = sizeof(nid);
196 nid.uID = pContext->uID;
197 nid.hWnd = pContext->hwndStatusDlg;
198 nid.uVersion = NOTIFYICON_VERSION;
199
200 if (pContext->pNet->GetProperties(&pProperties) == S_OK)
201 {
202 if (pProperties->dwCharacter & NCCF_SHOW_ICON)
203 {
204 if (hwndDlg)
206 else
207 nid.hIcon = hIcon;
208
209 if (nid.hIcon)
211
212 nid.uFlags |= NIF_STATE;
213 nid.dwState = 0;
214 nid.dwStateMask = NIS_HIDDEN;
215
216 if (pProperties->pszwName)
217 {
218 if (wcslen(pProperties->pszwName) * sizeof(WCHAR) < sizeof(nid.szTip))
219 {
220 nid.uFlags |= NIF_TIP;
221 wcscpy(nid.szTip, pProperties->pszwName);
222 }
223 else
224 {
225 CopyMemory(nid.szTip, pProperties->pszwName, sizeof(nid.szTip) - sizeof(WCHAR));
226 nid.szTip[(sizeof(nid.szTip)/sizeof(WCHAR))-1] = L'\0';
227 nid.uFlags |= NIF_TIP;
228 }
229 }
230 }
231 else
232 {
233 nid.uFlags |= NIF_STATE;
234 nid.dwState = NIS_HIDDEN;
235 nid.dwStateMask = NIS_HIDDEN;
236
237 }
238 NcFreeNetconProperties(pProperties);
239 }
240
242
243 if (nid.uFlags & NIF_ICON)
245
246 pContext->dwInOctets = IfEntry.dwInOctets;
247 pContext->dwOutOctets = IfEntry.dwOutOctets;
248
249 if (hwndDlg)
250 UpdateLanStatusUiDlg(hwndDlg, &IfEntry, pContext);
251}
252
253
254VOID
256{
257 WCHAR szBuffer[MAX_PATH] = {0};
258 NETCON_PROPERTIES * pProperties;
259
260 if (pContext->pNet->GetProperties(&pProperties) != S_OK)
261 return;
262
263 if (pProperties->Status == NCS_DISCONNECTED)
265 else if (pProperties->Status == NCS_MEDIA_DISCONNECTED)
267 else if (pProperties->Status == NCS_CONNECTING)
269 else if (pProperties->Status == NCS_CONNECTED)
271
272 SendDlgItemMessageW(hwndDlg, IDC_STATUS, WM_SETTEXT, 0, (LPARAM)szBuffer);
273
274 pContext->dwInOctets = 0;
275 pContext->dwOutOctets = 0;
276
277 /* update adapter info */
278 pContext->Status = -1;
279 UpdateLanStatus(hwndDlg, pContext);
280 NcFreeNetconProperties(pProperties);
281}
282
283static
284VOID
286 HWND hDlgCtrl,
287 UINT ResId,
288 UINT SubItem,
289 UINT Size)
290{
291 WCHAR szBuffer[200];
292 LVCOLUMNW lc;
293
294 if (!LoadStringW(netshell_hInstance, ResId, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
295 return;
296
297 memset(&lc, 0, sizeof(LV_COLUMN) );
299 lc.iSubItem = SubItem;
300 lc.fmt = LVCFMT_FIXED_WIDTH;
301 lc.cx = Size;
302 lc.cchTextMax = wcslen(szBuffer);
303 lc.pszText = szBuffer;
304
305 (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, SubItem, (LPARAM)&lc);
306}
307
308static
309VOID
311 HWND hDlgCtrl,
313 INT Index)
314{
315 LVITEMW li;
317 WCHAR szBuffer[100];
318 UINT SubIndex;
319
320 ZeroMemory(&li, sizeof(LVITEMW));
321 li.mask = LVIF_TEXT;
322 li.iItem = Index;
323 pCur = pAddr;
324 SubIndex = 0;
325
326 do
327 {
328 if (SubIndex)
329 {
330 ZeroMemory(&li, sizeof(LVITEMW));
331 li.mask = LVIF_TEXT;
332 li.iItem = Index;
333 li.iSubItem = 0;
334 li.pszText = (LPWSTR)L"";
335 li.iItem = SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&li);
336 }
337
338 if (MultiByteToWideChar(CP_ACP, 0, pCur->IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
339 {
340 li.pszText = szBuffer;
341 li.iSubItem = 1;
342 li.iItem = Index++;
343 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
344 }
345 SubIndex++;
346 pCur = pCur->Next;
347 } while (pCur && pCur->IpAddress.String[0]);
348}
349
350static
351INT
353 HWND hDlgCtrl,
354 UINT ResId)
355{
356 LVITEMW li;
357 WCHAR szBuffer[100];
358
359 ZeroMemory(&li, sizeof(LVITEMW));
360 li.mask = LVIF_TEXT;
361 li.iItem = ListView_GetItemCount(hDlgCtrl);
362 if (LoadStringW(netshell_hInstance, ResId, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
363 {
364 li.pszText = szBuffer;
365 return (INT)SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&li);
366 }
367 return -1;
368}
369
370static
371BOOL
373 IN struct tm *pTM,
374 OUT LPWSTR szBuffer,
375 IN UINT nBufferSize)
376{
377 SYSTEMTIME st;
378 CString strBufferDate;
379 CString strBufferTime;
380 UINT nCharDate, nCharTime;
381 BOOL bResult = FALSE;
382
383 st.wYear = pTM->tm_year + 1900;
384 st.wMonth = pTM->tm_mon + 1;
385 st.wDay = pTM->tm_mday;
386 st.wHour = pTM->tm_hour;
387 st.wMinute = pTM->tm_min;
388 st.wSecond = pTM->tm_sec;
389
390 /* Check required size before cpy/cat */
391 nCharDate = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, NULL, 0) + 1;
392 nCharTime = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, NULL, 0) + 1;
393
394 if (GetDateFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, strBufferDate.GetBuffer(nCharDate), nCharDate) &&
395 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, strBufferTime.GetBuffer(nCharTime), nCharTime))
396 {
397 StringCbCopy(szBuffer, nBufferSize, strBufferDate);
398 StringCbCat(szBuffer, nBufferSize, L" ");
399 StringCbCat(szBuffer, nBufferSize, strBufferTime);
400 bResult = TRUE;
401 }
402 strBufferDate.ReleaseBuffer();
403 strBufferTime.ReleaseBuffer();
404
405 return bResult;
406}
407
411 HWND hwndDlg,
412 UINT uMsg,
415)
416{
417 LANSTATUSUI_CONTEXT * pContext;
418 LVITEMW li;
419 WCHAR szBuffer[100];
420 PIP_ADAPTER_INFO pAdapterInfo, pCurAdapter;
421 PIP_PER_ADAPTER_INFO pPerAdapter;
423 HWND hDlgCtrl;
424 RECT rect;
425
426 switch (uMsg)
427 {
428 case WM_INITDIALOG:
429 pContext = (LANSTATUSUI_CONTEXT*)lParam;
430
431 hDlgCtrl = GetDlgItem(hwndDlg, IDC_DETAILS);
433
434 /* Calculate column width */
435 GetClientRect(hDlgCtrl, &rect);
436 dwSize = rect.right / 2;
437
440
441 dwSize = 0;
442 pCurAdapter = NULL;
443 pAdapterInfo = NULL;
445 {
446 pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
447 if (pAdapterInfo)
448 {
449 if (GetAdaptersInfo(pAdapterInfo, &dwSize) == NO_ERROR)
450 {
451 pCurAdapter = pAdapterInfo;
452 while (pCurAdapter && pCurAdapter->Index != pContext->dwAdapterIndex)
453 pCurAdapter = pCurAdapter->Next;
454
455 if (pCurAdapter->Index != pContext->dwAdapterIndex)
456 pCurAdapter = NULL;
457 }
458 }
459 }
460
461 ZeroMemory(&li, sizeof(LVITEMW));
462 li.mask = LVIF_TEXT;
463 li.iSubItem = 1;
464 li.pszText = szBuffer;
465
466 if (pCurAdapter)
467 {
469 if (li.iItem >= 0)
470 {
471 _swprintf(szBuffer, L"%02x-%02x-%02x-%02x-%02x-%02x",pCurAdapter->Address[0], pCurAdapter->Address[1],
472 pCurAdapter->Address[2], pCurAdapter->Address[3], pCurAdapter->Address[4], pCurAdapter->Address[5]);
473 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
474 }
475 li.iItem = InsertItemToListView(hDlgCtrl, IDS_IP_ADDRESS);
476 if (li.iItem >= 0)
477 if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->IpAddressList.IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
478 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
479
480 li.iItem = InsertItemToListView(hDlgCtrl, IDS_SUBNET_MASK);
481 if (li.iItem >= 0)
482 if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->IpAddressList.IpMask.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
483 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
484
485 li.iItem = InsertItemToListView(hDlgCtrl, IDS_DEF_GATEWAY);
486 if (li.iItem >= 0 && pCurAdapter->GatewayList.IpAddress.String[0] != '0')
487 {
488 if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->GatewayList.IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
489 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
490 }
491
492 li.iItem = InsertItemToListView(hDlgCtrl, IDS_DHCP_SERVER);
493 if (li.iItem >= 0 && pCurAdapter->DhcpServer.IpAddress.String[0] != '0')
494 {
495 if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->DhcpServer.IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
496 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
497 }
498
499 li.iItem = InsertItemToListView(hDlgCtrl, IDS_LEASE_OBTAINED);
500 if (li.iItem >= 0 && pCurAdapter->LeaseObtained != NULL)
501 {
502 struct tm *leaseOptained;
503
504 leaseOptained = localtime(&pCurAdapter->LeaseObtained);
505
506 if (tmToStr(leaseOptained, szBuffer, _countof(szBuffer)))
507 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
508 }
509
510 li.iItem = InsertItemToListView(hDlgCtrl, IDS_LEASE_EXPIRES);
511 if (li.iItem >= 0 && pCurAdapter->LeaseExpires != NULL)
512 {
513 struct tm *leaseExpire;
514
515 leaseExpire = localtime(&pCurAdapter->LeaseExpires);
516
517 if (tmToStr(leaseExpire, szBuffer, _countof(szBuffer)))
518 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
519 }
520 }
521
522 dwSize = 0;
523 li.iItem = InsertItemToListView(hDlgCtrl, IDS_DNS_SERVERS);
525 {
526 pPerAdapter = static_cast<PIP_PER_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
527 if (pPerAdapter)
528 {
529 if (GetPerAdapterInfo(pContext->dwAdapterIndex, pPerAdapter, &dwSize) == ERROR_SUCCESS)
530 {
531 if (li.iItem >= 0)
532 AddIPAddressToListView(hDlgCtrl, &pPerAdapter->DnsServerList, li.iItem);
533 }
534 CoTaskMemFree(pPerAdapter);
535 }
536 }
537
538 if (pCurAdapter)
539 {
540 li.iItem = InsertItemToListView(hDlgCtrl, IDS_WINS_SERVERS);
541 if (pCurAdapter->HaveWins)
542 {
543 AddIPAddressToListView(hDlgCtrl, &pCurAdapter->PrimaryWinsServer, li.iItem);
544 AddIPAddressToListView(hDlgCtrl, &pCurAdapter->SecondaryWinsServer, li.iItem+1);
545 }
546 }
547
548 CoTaskMemFree(pAdapterInfo);
549 break;
550
551 case WM_COMMAND:
552 if (LOWORD(wParam) == IDCANCEL)
553 {
554 EndDialog(hwndDlg, FALSE);
555 break;
556 }
557 }
558
559 return FALSE;
560}
561
565 HWND hwndDlg,
566 UINT uMsg,
569{
570 WCHAR szBuffer[100] = {0};
572 LANSTATUSUI_CONTEXT * pContext;
573 DWORD dwIpAddr;
574
575
576 switch (uMsg)
577 {
578 case WM_INITDIALOG:
580 pContext = (LANSTATUSUI_CONTEXT*)page->lParam;
581 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
582 if (pContext->DHCPEnabled)
583 LoadStringW(netshell_hInstance, IDS_ASSIGNED_DHCP, szBuffer, sizeof(szBuffer)/sizeof(WCHAR));
584 else
585 LoadStringW(netshell_hInstance, IDS_ASSIGNED_MANUAL, szBuffer, sizeof(szBuffer)/sizeof(WCHAR));
586
587 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
588 SendDlgItemMessageW(hwndDlg, IDC_DETAILSTYPE, WM_SETTEXT, 0, (LPARAM)szBuffer);
589
590
591 dwIpAddr = ntohl(pContext->IpAddress);
592 _swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
593 THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
594 SendDlgItemMessageW(hwndDlg, IDC_DETAILSIP, WM_SETTEXT, 0, (LPARAM)szBuffer);
595
596 dwIpAddr = ntohl(pContext->SubnetMask);
597 _swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
598 THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
600
601 dwIpAddr = ntohl(pContext->Gateway);
602 if (dwIpAddr)
603 {
604 _swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
605 THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
607 }
608 return TRUE;
609 case WM_COMMAND:
610 if (LOWORD(wParam) == IDC_DETAILS)
611 {
612 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
613 if (pContext)
614 {
616 LANStatusUiDetailsDlg, (LPARAM)pContext);
617 }
618 }
619 break;
620 default:
621 break;
622 }
623 return FALSE;
624}
625
626VOID
628{
629 HRESULT hr = pNet->Disconnect();
631 return;
632
634
636 ZeroMemory(&nid, sizeof(nid));
637 nid.cbSize = sizeof(nid);
638 nid.uID = pContext->uID;
639 nid.hWnd = pContext->hwndDlg;
640 nid.uFlags = NIF_STATE;
641 nid.dwState = NIS_HIDDEN;
642 nid.dwStateMask = NIS_HIDDEN;
643
645}
646
647
651 HWND hwndDlg,
652 UINT uMsg,
655{
657 LANSTATUSUI_CONTEXT * pContext;
658 LPPSHNOTIFY lppsn;
659
660 switch (uMsg)
661 {
662 case WM_INITDIALOG:
664 pContext = (LANSTATUSUI_CONTEXT*)page->lParam;
665 pContext->hwndDlg = hwndDlg;
666 InitializeLANStatusUiDlg(hwndDlg, pContext);
667 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
668 return TRUE;
669 case WM_COMMAND:
670 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
672 {
673 if (pContext)
674 {
675 ShowNetConnectionProperties(pContext->pNet, GetParent(pContext->hwndDlg));
676 BringWindowToTop(GetParent(pContext->hwndDlg));
677 }
678 break;
679 }
680 else if (LOWORD(wParam) == IDC_ENDISABLE)
681 {
682 DisableNetworkAdapter(pContext->pNet, pContext, hwndDlg);
683 break;
684 }
685 case WM_NOTIFY:
686 lppsn = (LPPSHNOTIFY) lParam;
687 if (lppsn->hdr.code == PSN_APPLY || lppsn->hdr.code == PSN_RESET)
688 {
689 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
691 pContext->hwndDlg = NULL;
692 return TRUE;
693 }
694 break;
695 }
696 return FALSE;
697}
698
699VOID
701 LANSTATUSUI_CONTEXT * pContext,
702 NETCON_PROPERTIES * pProperties)
703{
704 DWORD dwSize, dwAdapterIndex, dwResult;
705 LPOLESTR pStr;
706 IP_ADAPTER_INFO *pAdapterInfo, *pCurAdapter;
707
708 if (FAILED(StringFromCLSID((CLSID)pProperties->guidId, &pStr)))
709 {
710 return;
711 }
712
713 /* get the IfTable */
714 dwSize = 0;
715 dwResult = GetAdaptersInfo(NULL, &dwSize);
716 if (dwResult!= ERROR_BUFFER_OVERFLOW)
717 {
718 CoTaskMemFree(pStr);
719 return;
720 }
721
722 pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
723 if (!pAdapterInfo)
724 {
725 CoTaskMemFree(pAdapterInfo);
726 CoTaskMemFree(pStr);
727 return;
728 }
729
730 if (GetAdaptersInfo(pAdapterInfo, &dwSize) != NO_ERROR)
731 {
732 CoTaskMemFree(pAdapterInfo);
733 CoTaskMemFree(pStr);
734 return;
735 }
736
737 if (!GetAdapterIndexFromNetCfgInstanceId(pAdapterInfo, pStr, &dwAdapterIndex))
738 {
739 CoTaskMemFree(pAdapterInfo);
740 CoTaskMemFree(pStr);
741 return;
742 }
743
744 pCurAdapter = pAdapterInfo;
745 while (pCurAdapter->Index != dwAdapterIndex)
746 pCurAdapter = pCurAdapter->Next;
747
748
749 pContext->IpAddress = inet_addr(pCurAdapter->IpAddressList.IpAddress.String);
750 pContext->SubnetMask = inet_addr(pCurAdapter->IpAddressList.IpMask.String);
751 pContext->Gateway = inet_addr(pCurAdapter->GatewayList.IpAddress.String);
752 pContext->DHCPEnabled = pCurAdapter->DhcpEnabled;
753 CoTaskMemFree(pStr);
754 CoTaskMemFree(pAdapterInfo);
755 pContext->dwAdapterIndex = dwAdapterIndex;
756}
757
758static int CALLBACK
760{
761 // NOTE: This callback is needed to set large icon correctly.
762 HICON hIcon;
763 switch (uMsg)
764 {
765 case PSCB_INITIALIZED:
766 {
768 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
769 break;
770 }
771 }
772 return 0;
773}
774
775VOID
777 LANSTATUSUI_CONTEXT *pContext,
778 HWND hwndDlg)
779{
780 HPROPSHEETPAGE hppages[2];
781 PROPSHEETHEADERW pinfo;
782 NETCON_PROPERTIES * pProperties = NULL;
783
784 ZeroMemory(&pinfo, sizeof(PROPSHEETHEADERW));
785 ZeroMemory(hppages, sizeof(hppages));
786 pinfo.dwSize = sizeof(PROPSHEETHEADERW);
787 pinfo.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE | PSH_NOAPPLYNOW |
789 pinfo.phpage = hppages;
790 pinfo.hwndParent = hwndDlg;
794
795 if (pContext->pNet->GetProperties(&pProperties) == S_OK)
796 {
797 if (pProperties->pszwName)
798 {
799 pinfo.pszCaption = pProperties->pszwName;
800 pinfo.dwFlags |= PSH_PROPTITLE;
801 }
802 InitializePropertyDialog(pContext, pProperties);
803 if (pProperties->MediaType == NCM_LAN && pProperties->Status == NCS_CONNECTED)
804 {
806 if (hppages[0])
807 pinfo.nPages++;
808
810 if (hppages[pinfo.nPages])
811 pinfo.nPages++;
812
813 if (pinfo.nPages)
814 {
815 PropertySheetW(&pinfo);
816 }
817 }
818 else if (pProperties->Status == NCS_MEDIA_DISCONNECTED || pProperties->Status == NCS_DISCONNECTED ||
819 pProperties->Status == NCS_HARDWARE_DISABLED)
820 {
821 ShowNetConnectionProperties(pContext->pNet, pContext->hwndDlg);
822 }
823
824 NcFreeNetconProperties(pProperties);
825 }
826}
827
829 _In_ HWND hwndOwner,
830 _In_ LANSTATUSUI_CONTEXT *pContext)
831{
832 if (!pContext || !pContext->pNet)
833 return;
834
835 HMENU hMenu = CreatePopupMenu();
836 if (!hMenu)
837 return;
838
839 POINT pt;
841
842 SetForegroundWindow(hwndOwner);
843
844 // The context menu items, set to their default values.
845 struct
846 {
847 UINT uID;
848 UINT uFlags;
849 UINT_PTR uIDNewItem;
850 } MenuItems[] =
851 {
855 {UINT_MAX, 0, 0}, // Separator
858 };
859
860 NETCON_PROPERTIES *pProps = NULL;
861 HRESULT hr = pContext->pNet->GetProperties(&pProps);
862 if (SUCCEEDED(hr) && pProps)
863 {
864 if (pProps->Status == NCS_HARDWARE_DISABLED ||
865 pProps->Status == NCS_MEDIA_DISCONNECTED ||
866 pProps->Status == NCS_DISCONNECTED)
867 {
868 MenuItems[0].uID = IDS_NET_ACTIVATE;
869 MenuItems[0].uFlags = MF_ENABLED | MFS_DEFAULT;
870 MenuItems[0].uIDNewItem = IDM_NETICON_ENABLE;
871 MenuItems[5].uFlags = MF_ENABLED;
872 }
873 else
874 {
875 MenuItems[0].uID = IDS_NET_DEACTIVATE;
876 MenuItems[0].uFlags = MF_ENABLED;
877 MenuItems[0].uIDNewItem = IDM_NETICON_DISABLE;
878 }
879
880 if (pProps->Status == NCS_CONNECTED)
881 {
882 MenuItems[1].uFlags = MF_ENABLED;
883 MenuItems[2].uFlags = MF_ENABLED;
884 }
885 else if (pProps->Status == NCS_CONNECTING)
886 {
887 MenuItems[1].uFlags = MF_ENABLED;
888 MenuItems[2].uFlags = MF_GRAYED;
889 }
890 else
891 {
892 MenuItems[1].uFlags = MF_GRAYED;
893 MenuItems[2].uFlags = MF_GRAYED;
894 }
895
897 pProps = NULL;
898 }
899 else
900 {
901 MenuItems[0].uFlags = MF_GRAYED;
902 MenuItems[1].uFlags = MF_GRAYED;
903 MenuItems[2].uFlags = MF_GRAYED;
904 MenuItems[5].uFlags = MF_GRAYED;
905 }
906
907 // Set the "Properties" item as default, if the Network "Enable/Disable" item isn't.
908 if (!(MenuItems[0].uFlags & MFS_DEFAULT))
909 MenuItems[5].uFlags |= MFS_DEFAULT;
910
911 WCHAR szMenuItem[128];
912
913 for (USHORT i = 0; i < _countof(MenuItems); ++i)
914 {
915 if (MenuItems[i].uID != UINT_MAX)
916 {
917 if (LoadStringW(netshell_hInstance, MenuItems[i].uID, szMenuItem, _countof(szMenuItem)))
918 AppendMenuW(hMenu, MF_STRING | MenuItems[i].uFlags, MenuItems[i].uIDNewItem, szMenuItem);
919 }
920 else
921 {
922 AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL);
923 }
924 }
925
927
928 PostMessage(hwndOwner, WM_NULL, 0, 0);
929
930 DestroyMenu(hMenu);
931}
932
934{
936
937 return E_NOTIMPL;
938}
939
943 HWND hwndDlg,
944 UINT uMsg,
947{
948 LANSTATUSUI_CONTEXT * pContext;
949
950 switch (uMsg)
951 {
952 case WM_INITDIALOG:
953 pContext = (LANSTATUSUI_CONTEXT *)lParam;
955 pContext->hwndStatusDlg = hwndDlg;
956 pContext->nIDEvent = SetTimer(hwndDlg, NETTIMERID, 1000, NULL);
957 return TRUE;
958
959 case WM_DESTROY:
960 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
961 if (pContext && pContext->nIDEvent)
962 {
963 KillTimer(hwndDlg, pContext->nIDEvent);
964 pContext->nIDEvent = 0;
965 }
967 break;
968
969 case WM_TIMER:
970 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
971 if (wParam == (WPARAM)pContext->nIDEvent)
972 {
973 UpdateLanStatus(pContext->hwndDlg, pContext);
974 }
975 break;
976
977 case WM_SHOWSTATUSDLG:
978 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
979 if (!pContext)
980 break;
981
982 switch (LOWORD(lParam))
983 {
984 case WM_LBUTTONUP:
985 if (pContext->hwndDlg)
986 {
987 HWND hwndSheet = GetParent(pContext->hwndDlg);
988 if (hwndSheet)
989 {
990 ShowWindow(hwndSheet, SW_RESTORE);
991 SetForegroundWindow(hwndSheet);
992 BringWindowToTop(hwndSheet);
993 }
994 }
995 else
996 {
997 ShowStatusPropertyDialog(pContext, hwndDlg);
998 }
999 break;
1000
1001 if (pContext->hwndDlg)
1002 {
1003 ShowWindow(GetParent(pContext->hwndDlg), SW_SHOW);
1005 }
1006 else
1007 {
1008 ShowStatusPropertyDialog(pContext, hwndDlg);
1009 }
1010 break;
1011
1012 case WM_RBUTTONUP:
1013 case WM_CONTEXTMENU:
1014 ShowNetworkIconContextMenu(hwndDlg, pContext);
1015 break;
1016 }
1017 break;
1018
1019 case WM_COMMAND:
1020 {
1021 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
1022 if (!pContext || !pContext->pNet)
1023 break;
1024
1025 switch (LOWORD(wParam))
1026 {
1027 case IDM_NETICON_ENABLE:
1028 pContext->pNet->Connect();
1029 UpdateLanStatus(NULL, pContext);
1030 break;
1031
1033 pContext->pNet->Disconnect();
1034 UpdateLanStatus(NULL, pContext);
1035 break;
1036
1037 case IDM_NETICON_STATUS:
1038 if (pContext->hwndDlg)
1039 {
1040 HWND hwndSheet = GetParent(pContext->hwndDlg);
1041 if (hwndSheet)
1042 {
1043 ShowWindow(hwndSheet, SW_RESTORE);
1044 SetForegroundWindow(hwndSheet);
1045 BringWindowToTop(hwndSheet);
1046 }
1047 }
1048 else
1049 {
1050 ShowStatusPropertyDialog(pContext, hwndDlg);
1051 }
1052 break;
1053
1054 case IDM_NETICON_REPAIR:
1055 RepairConnection(pContext->pNet, hwndDlg);
1056 break;
1057
1059 ShowNetConnectionProperties(pContext->pNet, hwndDlg);
1060 break;
1061
1063 ShellExecuteW(hwndDlg, NULL, L"control", L"netconnections", NULL, SW_SHOWNORMAL);
1064 break;
1065 }
1066 break;
1067 }
1068 }
1069 return FALSE;
1070}
1071
1072HRESULT
1074{
1076 HWND hwndDlg;
1080 NETCON_PROPERTIES* pProps;
1081 HRESULT hr;
1082 ULONG Count;
1083 ULONG Index;
1084 NOTIFICATION_ITEM * pItem, *pLast = NULL;
1085 LANSTATUSUI_CONTEXT * pContext;
1086
1087 TRACE("InitializeNetTaskbarNotifications\n");
1088
1089 if (m_pHead)
1090 {
1091 pItem = m_pHead;
1092 while (pItem)
1093 {
1094 hr = pItem->pNet->GetProperties(&pProps);
1095 if (SUCCEEDED(hr))
1096 {
1097 ZeroMemory(&nid, sizeof(nid));
1098 nid.cbSize = sizeof(nid);
1099 nid.uID = pItem->uID;
1100 nid.hWnd = pItem->hwndDlg;
1101 nid.uFlags = NIF_STATE;
1102 if (pProps->dwCharacter & NCCF_SHOW_ICON)
1103 nid.dwState = 0;
1104 else
1105 nid.dwState = NIS_HIDDEN;
1106
1107 nid.dwStateMask = NIS_HIDDEN;
1109 NcFreeNetconProperties(pProps);
1110 }
1111 pItem = pItem->pNext;
1112 }
1113 return S_OK;
1114 }
1115 /* get an instance to of IConnectionManager */
1116 hr = CNetConnectionManager_CreateInstance(IID_PPV_ARG(INetConnectionManager, &pNetConMan));
1118 return hr;
1119
1120 hr = pNetConMan->EnumConnections(NCME_DEFAULT, &pEnumCon);
1122 return hr;
1123
1124 Index = 1;
1125 while (TRUE)
1126 {
1127 pNetCon.Release();
1128 hr = pEnumCon->Next(1, &pNetCon, &Count);
1129 if (hr != S_OK)
1130 break;
1131
1132 TRACE("new connection\n");
1133 pItem = static_cast<NOTIFICATION_ITEM*>(CoTaskMemAlloc(sizeof(NOTIFICATION_ITEM)));
1134 if (!pItem)
1135 break;
1136
1137 pContext = static_cast<LANSTATUSUI_CONTEXT*>(CoTaskMemAlloc(sizeof(LANSTATUSUI_CONTEXT)));
1138 if (!pContext)
1139 {
1140 CoTaskMemFree(pItem);
1141 break;
1142 }
1143
1144 ZeroMemory(pContext, sizeof(LANSTATUSUI_CONTEXT));
1145 pContext->uID = Index;
1146 pContext->pNet = pNetCon;
1147 pContext->Status = -1;
1148 pContext->dwAdapterIndex = Index;
1149 pItem->uID = Index;
1150 pItem->pNext = NULL;
1151 pItem->pNet = pNetCon;
1152 pItem->pNet->AddRef();
1154 if (!hwndDlg)
1155 {
1156 ERR("CreateDialogParamW failed\n");
1157 continue;
1158 }
1159
1160 ZeroMemory(&nid, sizeof(nid));
1161 nid.cbSize = sizeof(nid);
1162 nid.uID = Index++;
1164 nid.uVersion = NOTIFYICON_VERSION;
1166 nid.hWnd = hwndDlg;
1167
1168 hr = pNetCon->GetProperties(&pProps);
1169 if (SUCCEEDED(hr))
1170 {
1171 CopyMemory(&pItem->guidItem, &pProps->guidId, sizeof(GUID));
1172 if (!(pProps->dwCharacter & NCCF_SHOW_ICON))
1173 {
1174 nid.dwState = NIS_HIDDEN;
1175 nid.dwStateMask = NIS_HIDDEN;
1176 nid.uFlags |= NIF_STATE;
1177 }
1178 if (pProps->Status == NCS_MEDIA_DISCONNECTED || pProps->Status == NCS_DISCONNECTED || pProps->Status == NCS_HARDWARE_DISABLED)
1180 else if (pProps->Status == NCS_CONNECTED)
1182
1183 if (nid.hIcon)
1184 nid.uFlags |= NIF_ICON;
1185
1186 wcscpy(nid.szTip, pProps->pszwName);
1187 nid.uFlags |= NIF_TIP;
1188 }
1189 pContext->hwndStatusDlg = hwndDlg;
1190 pItem->hwndDlg = hwndDlg;
1191
1193 {
1194 if (pLast)
1195 pLast->pNext = pItem;
1196 else
1197 m_pHead = pItem;
1198
1199 pLast = pItem;
1200 Index++;
1201 }
1202 else
1203 {
1204 ERR("Shell_NotifyIconW failed\n");
1205 CoTaskMemFree(pItem);
1206 }
1207
1208 if (nid.uFlags & NIF_ICON)
1210 }
1211
1212 m_lpNetMan = pNetConMan;
1213 return S_OK;
1214}
1215
1216HRESULT
1218{
1219 NOTIFICATION_ITEM *pItem;
1220
1221 pItem = m_pHead;
1222 while (pItem)
1223 {
1224 if (IsEqualGUID(pItem->guidItem, *pguidCmdGroup))
1225 {
1227 return S_OK;
1228 }
1229 pItem = pItem->pNext;
1230 }
1231
1232 ERR("not found\n");
1233 return E_FAIL;
1234}
1235
1236HRESULT
1237WINAPI
1239 const GUID *pguidCmdGroup,
1240 ULONG cCmds,
1241 OLECMD *prgCmds,
1242 OLECMDTEXT *pCmdText)
1243{
1244 MessageBoxW(NULL, pCmdText->rgwz, L"IOleCommandTarget_fnQueryStatus", MB_OK);
1245 return E_NOTIMPL;
1246}
1247
1248HRESULT
1249WINAPI
1251 const GUID *pguidCmdGroup,
1252 DWORD nCmdID,
1253 DWORD nCmdexecopt,
1254 VARIANT *pvaIn,
1255 VARIANT *pvaOut)
1256{
1257 if (pguidCmdGroup)
1258 {
1259 if (IsEqualGUID(*pguidCmdGroup, CGID_ShellServiceObject))
1260 {
1262 }
1263 else
1264 {
1265 /* invoke status dialog */
1266 return ShowStatusDialogByCLSID(pguidCmdGroup);
1267 }
1268 }
1269 return S_OK;
1270}
#define IDC_DETAILS
Definition: resource.h:18
#define ERR(fmt,...)
Definition: precomp.h:57
void Release()
Definition: atlcomcli.h:170
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:387
Definition: bufpool.h:45
HRESULT InitializeNetTaskbarNotifications()
CComPtr< INetConnectionManager > m_lpNetMan
Definition: lanstatusui.h:50
NOTIFICATION_ITEM * m_pHead
Definition: lanstatusui.h:51
STDMETHOD() Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) override
HRESULT ShowStatusDialogByCLSID(const GUID *pguidCmdGroup)
STDMETHOD() QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD *prgCmds, OLECMDTEXT *pCmdText) override
RECT rect
Definition: combotst.c:67
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL GetAdapterIndexFromNetCfgInstanceId(PIP_ADAPTER_INFO pAdapterInfo, LPWSTR szNetCfg, PDWORD pIndex)
HRESULT WINAPI CNetConnectionManager_CreateInstance(REFIID riid, LPVOID *ppv)
#define NO_ERROR
Definition: dderror.h:5
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDS_VALUE
Definition: resource.h:28
#define IDD_LAN_NETSTATUSDETAILS
Definition: resource.h:24
#define IDD_STATUS
Definition: resource.h:22
#define IDS_DNS_SERVERS
Definition: resource.h:125
#define IDC_SPEED
Definition: resource.h:43
#define IDI_NET_TRANSREC
Definition: resource.h:14
#define IDS_NET_STATUS
Definition: resource.h:102
#define IDS_NET_PROPERTIES
Definition: resource.h:107
#define IDC_DURATION
Definition: resource.h:42
#define IDD_LAN_NETSTATUS
Definition: resource.h:21
#define IDS_FORMAT_BIT
Definition: resource.h:109
#define IDM_NETICON_ENABLE
Definition: resource.h:54
#define IDC_DETAILSTYPE
Definition: resource.h:46
#define IDS_NET_DEACTIVATE
Definition: resource.h:101
#define IDM_NETICON_DISABLE
Definition: resource.h:55
#define IDC_STATUS_PROPERTIES
Definition: resource.h:39
#define IDI_NET_TRANS
Definition: resource.h:13
#define IDS_STATUS_CONNECTED
Definition: resource.h:97
#define IDC_DETAILSGATEWAY
Definition: resource.h:49
#define IDC_STATUS
Definition: resource.h:41
#define IDS_ASSIGNED_MANUAL
Definition: resource.h:116
#define IDS_DEF_GATEWAY
Definition: resource.h:121
#define IDM_NETICON_PROPERTIES
Definition: resource.h:59
#define IDS_DURATION_DAY
Definition: resource.h:113
#define IDS_NET_OPEN_CONNECTIONS
Definition: resource.h:61
#define IDI_NET_OFF
Definition: resource.h:11
#define IDC_DETAILSIP
Definition: resource.h:47
#define IDI_NET_REC
Definition: resource.h:12
#define IDS_DURATION_DAYS
Definition: resource.h:114
#define IDD_LAN_NETSTATUSADVANCED
Definition: resource.h:23
#define IDC_NETSTAT
Definition: resource.h:44
#define IDS_ASSIGNED_DHCP
Definition: resource.h:115
#define IDS_NET_REPAIR
Definition: resource.h:103
#define IDC_DETAILSSUBNET
Definition: resource.h:48
#define IDS_IP_ADDRESS
Definition: resource.h:119
#define IDS_LEASE_EXPIRES
Definition: resource.h:124
#define IDC_SEND
Definition: resource.h:37
#define IDS_DHCP_SERVER
Definition: resource.h:122
#define IDM_NETICON_STATUS
Definition: resource.h:56
#define IDS_PHYSICAL_ADDRESS
Definition: resource.h:118
#define IDS_FORMAT_KBIT
Definition: resource.h:111
#define IDM_NETICON_REPAIR
Definition: resource.h:57
#define IDS_NET_ACTIVATE
Definition: resource.h:100
#define IDS_LEASE_OBTAINED
Definition: resource.h:123
#define IDS_SUBNET_MASK
Definition: resource.h:120
#define IDC_RECEIVED
Definition: resource.h:38
#define IDS_STATUS_DISCONNECTED
Definition: resource.h:95
#define IDS_PROPERTY
Definition: resource.h:127
#define IDI_NET_IDLE
Definition: resource.h:10
#define IDC_ENDISABLE
Definition: resource.h:40
#define IDM_NETICON_OPEN_CONNECTIONS
Definition: resource.h:58
#define IDS_FORMAT_MBIT
Definition: resource.h:110
#define IDS_WINS_SERVERS
Definition: resource.h:126
#define IDS_FORMAT_GBIT
Definition: resource.h:112
#define IDS_STATUS_UNREACHABLE
Definition: resource.h:94
#define IDS_STATUS_CONNECTING
Definition: resource.h:96
UINT uFlags
Definition: api.c:59
HRESULT WINAPI StringFromCLSID(REFCLSID clsid, LPOLESTR *str)
Definition: combase.c:1515
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2950
#define CP_ACP
Definition: compat.h:109
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define MultiByteToWideChar
Definition: compat.h:110
ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void)
Definition: sync.c:192
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
#define UINT_MAX
Definition: limits.h:27
static struct tm * localtime(const time_t *t)
Definition: time.h:121
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:854
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:33
#define pt(x, y)
Definition: drawing.c:79
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER pAddr
SINGLE_LIST_ENTRY * pCur
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: sysinfo.c:13
HRESULT Connect()
HRESULT Disconnect()
HRESULT GetProperties([out] NETCON_PROPERTIES **ppProps)
ULONG AddRef()
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
#define MIB_IF_OPER_STATUS_DISCONNECTED
Definition: ipifcons.h:248
#define MIB_IF_OPER_STATUS_CONNECTED
Definition: ipifcons.h:250
#define MIB_IF_OPER_STATUS_NON_OPERATIONAL
Definition: ipifcons.h:246
#define MIB_IF_OPER_STATUS_UNREACHABLE
Definition: ipifcons.h:247
#define MIB_IF_OPER_STATUS_OPERATIONAL
Definition: ipifcons.h:251
static BOOL tmToStr(IN struct tm *pTM, OUT LPWSTR szBuffer, IN UINT nBufferSize)
VOID ShowStatusPropertyDialog(LANSTATUSUI_CONTEXT *pContext, HWND hwndDlg)
VOID InitializeLANStatusUiDlg(HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
INT_PTR CALLBACK LANStatusUiDetailsDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define NETTIMERID
Definition: lanstatusui.cpp:12
VOID UpdateLanStatusUiDlg(HWND hwndDlg, MIB_IFROW *IfEntry, LANSTATUSUI_CONTEXT *pContext)
Definition: lanstatusui.cpp:21
static INT InsertItemToListView(HWND hDlgCtrl, UINT ResId)
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
INT_PTR CALLBACK LANStatusUiAdvancedDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
static VOID AddIPAddressToListView(HWND hDlgCtrl, PIP_ADDR_STRING pAddr, INT Index)
INT_PTR CALLBACK LANStatusUiDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
static VOID InsertColumnToListView(HWND hDlgCtrl, UINT ResId, UINT SubItem, UINT Size)
INT_PTR CALLBACK LANStatusDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
VOID DisableNetworkAdapter(INetConnection *pNet, LANSTATUSUI_CONTEXT *pContext, HWND hwndDlg)
VOID InitializePropertyDialog(LANSTATUSUI_CONTEXT *pContext, NETCON_PROPERTIES *pProperties)
VOID UpdateLanStatus(HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
VOID ShowNetworkIconContextMenu(_In_ HWND hwndOwner, _In_ LANSTATUSUI_CONTEXT *pContext)
HRESULT RepairConnection(INetConnection *pNet, HWND hwndOwner)
#define WM_SHOWSTATUSDLG
Definition: lanstatusui.h:6
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1101
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:1001
NOTIFYICONDATA nid
Definition: magnifier.c:44
#define ZeroMemory
Definition: minwinbase.h:31
#define CopyMemory
Definition: minwinbase.h:29
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR WPARAM
Definition: minwindef.h:174
#define ntohl(x)
Definition: module.h:205
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define _swprintf(buf, format,...)
Definition: sprintf.c:56
static HICON
Definition: imagelist.c:80
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
HICON hIcon
Definition: msconfig.c:44
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
@ NCCF_SHOW_ICON
Definition: netcon.h:20
@ NCS_CONNECTING
Definition: netcon.h:40
@ NCS_MEDIA_DISCONNECTED
Definition: netcon.h:46
@ NCS_CONNECTED
Definition: netcon.h:41
@ NCS_DISCONNECTED
Definition: netcon.h:39
@ NCS_HARDWARE_DISABLED
Definition: netcon.h:44
@ NCM_LAN
Definition: netcon.h:71
@ NCME_DEFAULT
Definition: netcon.h:10
HPROPSHEETPAGE InitializePropertySheetPage(LPWSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
Definition: netshell.cpp:29
HINSTANCE netshell_hInstance
Definition: netshell.cpp:12
VOID WINAPI NcFreeNetconProperties(NETCON_PROPERTIES *pProps)
Definition: netshell.cpp:119
#define _In_
Definition: no_sal2.h:158
int Count
Definition: noreturn.cpp:7
#define LOCALE_USER_DEFAULT
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define LOWORD(l)
Definition: pedump.c:82
short WCHAR
Definition: pedump.c:58
unsigned short USHORT
Definition: pedump.c:61
#define PSBTN_CANCEL
Definition: prsht.h:151
#define PSH_PROPTITLE
Definition: prsht.h:40
#define PropSheet_PressButton(d, i)
Definition: prsht.h:348
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PSN_APPLY
Definition: prsht.h:117
#define PSNRET_NOERROR
Definition: prsht.h:129
#define PSH_USEICONID
Definition: prsht.h:42
#define PSCB_INITIALIZED
Definition: prsht.h:75
struct _PROPSHEETHEADERW PROPSHEETHEADERW
#define PSN_RESET
Definition: prsht.h:118
struct _PSHNOTIFY * LPPSHNOTIFY
#define PSH_NOAPPLYNOW
Definition: prsht.h:47
#define PROPSHEETPAGE
Definition: prsht.h:389
#define FOURTH_IPADDRESS(x)
Definition: commctrl.h:4496
#define ListView_SetExtendedListViewStyleEx(hwndLV, dwMask, dw)
Definition: commctrl.h:2731
#define FIRST_IPADDRESS(x)
Definition: commctrl.h:4493
#define LVCF_WIDTH
Definition: commctrl.h:2592
#define LVM_SETITEMW
Definition: commctrl.h:2402
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2739
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2312
#define SECOND_IPADDRESS(x)
Definition: commctrl.h:4494
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2637
#define LVIF_TEXT
Definition: commctrl.h:2314
#define LVCF_FMT
Definition: commctrl.h:2591
#define THIRD_IPADDRESS(x)
Definition: commctrl.h:4495
#define LVCF_SUBITEM
Definition: commctrl.h:2594
#define LVM_INSERTITEMW
Definition: commctrl.h:2409
#define LVCF_TEXT
Definition: commctrl.h:2593
#define LV_COLUMN
Definition: commctrl.h:2552
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_In_ UINT uID
Definition: shlwapi.h:156
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_NOTIFY
Definition: richedit.h:61
wcscpy
#define LoadStringW
Definition: utils.h:64
#define memset(x, y, z)
Definition: compat.h:39
#define NIM_MODIFY
Definition: shellapi.h:95
#define NIF_ICON
Definition: shellapi.h:106
#define NIF_MESSAGE
Definition: shellapi.h:105
#define NIM_ADD
Definition: shellapi.h:94
#define NIF_TIP
Definition: shellapi.h:107
#define SHELL_ErrorBox
Definition: shellutils.h:126
HRESULT ShowNetConnectionProperties(INetConnection *pNetConnect, HWND hwnd)
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2778
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
#define StringCbCat
Definition: strsafe.h:334
#define StringCbCopy
Definition: strsafe.h:155
char String[4 *4]
Definition: iptypes.h:31
INetConnection * pNet
Definition: lanstatusui.h:19
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]
Definition: iptypes.h:47
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:42
IP_ADDR_STRING SecondaryWinsServer
Definition: iptypes.h:57
IP_ADDR_STRING IpAddressList
Definition: iptypes.h:52
IP_ADDR_STRING DhcpServer
Definition: iptypes.h:54
time_t LeaseObtained
Definition: iptypes.h:58
IP_ADDR_STRING GatewayList
Definition: iptypes.h:53
time_t LeaseExpires
Definition: iptypes.h:59
IP_ADDR_STRING PrimaryWinsServer
Definition: iptypes.h:56
UINT DhcpEnabled
Definition: iptypes.h:50
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:36
IP_MASK_STRING IpMask
Definition: iptypes.h:37
IP_ADDR_STRING DnsServerList
Definition: iptypes.h:66
DWORD dwSpeed
Definition: ifmib.h:41
DWORD dwInOctets
Definition: ifmib.h:47
INTERNAL_IF_OPER_STATUS dwOperStatus
Definition: ifmib.h:45
DWORD dwOutOctets
Definition: ifmib.h:53
DWORD dwIndex
Definition: ifmib.h:38
UINT uCallbackMessage
Definition: shellapi.h:231
DWORD dwStateMask
Definition: shellapi.h:239
CHAR szTip[128]
Definition: shellapi.h:237
HINSTANCE hInstance
Definition: prsht.h:296
DWORD dwSize
Definition: prsht.h:293
DWORD dwFlags
Definition: prsht.h:294
LPCWSTR pszIcon
Definition: prsht.h:299
HWND hwndParent
Definition: prsht.h:295
PFNPROPSHEETCALLBACK pfnCallback
Definition: prsht.h:311
HPROPSHEETPAGE * phpage
Definition: prsht.h:309
LPCWSTR pszCaption
Definition: prsht.h:301
NMHDR hdr
Definition: prsht.h:330
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:641
WORD wSecond
Definition: minwinbase.h:262
WORD wMinute
Definition: minwinbase.h:261
Definition: module.h:576
int cchTextMax
Definition: commctrl.h:2573
LPWSTR pszText
Definition: commctrl.h:2572
NETCON_STATUS Status
Definition: netcon.h:86
NETCON_MEDIATYPE MediaType
Definition: netcon.h:87
UINT code
Definition: winuser.h:3267
struct tagNotificationItem * pNext
Definition: lanstatusui.h:10
INetConnection * pNet
Definition: lanstatusui.h:14
LONG right
Definition: windef.h:108
BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
Definition: systray.cpp:128
#define ICON_BIG
Definition: tnclass.cpp:51
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
int32_t INT_PTR
Definition: typedefs.h:64
uint16_t * LPWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
uint64_t ULONGLONG
Definition: typedefs.h:67
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
#define WINAPI
Definition: msvc.h:6
u_long WINAPI inet_addr(const char *str)
Definition: wine.c:35
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:307
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define SW_SHOWNORMAL
Definition: winuser.h:781
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
#define DWLP_USER
Definition: winuser.h:883
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define STM_SETICON
Definition: winuser.h:2128
#define IDCANCEL
Definition: winuser.h:842
#define IMAGE_ICON
Definition: winuser.h:212
#define TPM_RIGHTBUTTON
Definition: winuser.h:2416
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1110
#define WM_COMMAND
Definition: winuser.h:1768
#define TPM_BOTTOMALIGN
Definition: winuser.h:2421
#define MF_STRING
Definition: winuser.h:138
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:3064
#define WM_RBUTTONUP
Definition: winuser.h:1808
#define WM_INITDIALOG
Definition: winuser.h:1767
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2307
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MFS_DEFAULT
Definition: winuser.h:759
#define WM_SETTEXT
Definition: winuser.h:1645
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define MF_ENABLED
Definition: winuser.h:128
#define MF_SEPARATOR
Definition: winuser.h:137
#define WM_TIMER
Definition: winuser.h:1770
#define TPM_LEFTALIGN
Definition: winuser.h:2413
#define LoadIcon
Definition: winuser.h:5979
#define WM_NULL
Definition: winuser.h:1635
#define LR_SHARED
Definition: winuser.h:1111
#define MB_OK
Definition: winuser.h:801
#define WM_LBUTTONUP
Definition: winuser.h:1805
#define PostMessage
Definition: winuser.h:5998
HWND WINAPI GetParent(_In_ HWND)
#define LoadImage
Definition: winuser.h:5981
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define DWLP_MSGRESULT
Definition: winuser.h:881
#define SW_RESTORE
Definition: winuser.h:790
#define SW_SHOW
Definition: winuser.h:786
#define WM_DESTROY
Definition: winuser.h:1637
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2444
BOOL WINAPI BringWindowToTop(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2422
#define MF_GRAYED
Definition: winuser.h:129
#define IID_PPV_ARG(Itype, ppType)