Author: janderwald
Date: Wed Sep 17 10:20:04 2008
New Revision: 36287
URL:
http://svn.reactos.org/svn/reactos?rev=36287&view=rev
Log:
- Preload NetworkConnection Taskbar Notification
- Use Notification as a singleton
- Execute the status dialog by using the NetCfgInstanceId of the connection
Modified:
trunk/reactos/dll/win32/netshell/lanstatusui.c
trunk/reactos/dll/win32/netshell/precomp.h
trunk/reactos/dll/win32/netshell/shfldr_netconnect.c
Modified: trunk/reactos/dll/win32/netshell/lanstatusui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/lanstat…
==============================================================================
--- trunk/reactos/dll/win32/netshell/lanstatusui.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/lanstatusui.c [iso-8859-1] Wed Sep 17 10:20:04 2008
@@ -5,17 +5,28 @@
// IID B722BCCB-4E68-101B-A2BC-00AA00404770
#define WM_SHOWSTATUSDLG (WM_USER+10)
+
+typedef struct tagNotificationItem
+{
+ struct tagNotificationItem *pNext;
+ CLSID guidItem;
+ HWND hwndDlg;
+}NOTIFICATION_ITEM;
+
typedef struct
{
IOleCommandTarget * lpVtbl;
INetConnectionManager * lpNetMan;
LONG ref;
+ NOTIFICATION_ITEM * pHead;
}ILanStatusImpl, *LPILanStatusImpl;
typedef struct
{
INetConnection *pNet;
HWND hwndDlg;
+ DWORD dwInOctets;
+ DWORD dwOutOctets;
}LANSTATUSUI_CONTEXT;
VOID
@@ -290,7 +301,7 @@
}
static
HRESULT
-InitializeNetConnectTray(
+InitializeNetTaskbarNotifications(
ILanStatusImpl * This)
{
NOTIFYICONDATAW nid;
@@ -302,6 +313,7 @@
HRESULT hr;
ULONG Count;
ULONG Index;
+ NOTIFICATION_ITEM * pItem, *pLast = NULL;
/* get an instance to of IConnectionManager */
hr = INetConnectionManager_Constructor(NULL, &IID_INetConnectionManager,
(LPVOID*)&INetConMan);
@@ -321,6 +333,11 @@
hr = IEnumNetConnection_Next(IEnumCon, 1, &INetCon, &Count);
if (hr == S_OK)
{
+ pItem = (NOTIFICATION_ITEM*)CoTaskMemAlloc(sizeof(NOTIFICATION_ITEM));
+ if (!pItem)
+ break;
+ pItem->pNext = NULL;
+
hwndDlg = CreateDialogParamW(netshell_hInstance,
MAKEINTRESOURCEW(IDD_STATUS), NULL, LANStatusDlg, (LPARAM)INetCon);
if (hwndDlg)
{
@@ -335,13 +352,28 @@
hr = INetConnection_GetProperties(INetCon, &pProps);
if (SUCCEEDED(hr))
{
+ CopyMemory(&pItem->guidItem, &pProps->guidId,
sizeof(GUID));
+ pItem->hwndDlg = hwndDlg;
if (!(pProps->dwCharacter & NCCF_SHOW_ICON))
{
nid.dwState = NIS_HIDDEN;
}
}
+
if (Shell_NotifyIconW(NIM_ADD, &nid))
+ {
+ if (pLast)
+ pLast->pNext = pItem;
+ else
+ This->pHead = pItem;
+
+ pLast = pItem;
Index++;
+ }
+ else
+ {
+ CoTaskMemFree(pItem);
+ }
}
}
}while(hr == S_OK);
@@ -349,6 +381,26 @@
This->lpNetMan = INetConMan;
IEnumNetConnection_Release(IEnumCon);
return S_OK;
+}
+
+HRESULT
+ShowStatusDialogByCLSID(
+ ILanStatusImpl * This,
+ const GUID *pguidCmdGroup)
+{
+ NOTIFICATION_ITEM * pItem;
+
+ pItem = This->pHead;
+ while(pItem)
+ {
+ if (IsEqualGUID(&pItem->guidItem, pguidCmdGroup))
+ {
+ SendMessageW(pItem->hwndDlg, WM_SHOWSTATUSDLG, 0, WM_LBUTTONDOWN);
+ return S_OK;
+ }
+ pItem = pItem->pNext;
+ }
+ return E_FAIL;
}
static
HRESULT
@@ -390,6 +442,7 @@
IOleCommandTarget_fnRelease(
IOleCommandTarget * iface)
{
+#if 0
ILanStatusImpl * This = (ILanStatusImpl*)iface;
ULONG refCount = InterlockedDecrement(&This->ref);
@@ -398,6 +451,9 @@
CoTaskMemFree (This);
}
return refCount;
+#else
+ return 1;
+#endif
}
static
@@ -410,7 +466,6 @@
OLECMD *prgCmds,
OLECMDTEXT *pCmdText)
{
- MessageBoxW(NULL, L"222222222222222222222",
L"IOleCommandTarget_fnQueryStatus", MB_OK);
MessageBoxW(NULL, pCmdText->rgwz, L"IOleCommandTarget_fnQueryStatus",
MB_OK);
return E_NOTIMPL;
}
@@ -432,7 +487,12 @@
{
if (IsEqualIID(pguidCmdGroup, &CGID_ShellServiceObject))
{
- return InitializeNetConnectTray(This);
+ return InitializeNetTaskbarNotifications(This);
+ }
+ else
+ {
+ /* invoke status dialog */
+ return ShowStatusDialogByCLSID(This, pguidCmdGroup);
}
}
return S_OK;
@@ -452,6 +512,7 @@
HRESULT WINAPI LanConnectStatusUI_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID
* ppv)
{
ILanStatusImpl * This;
+ static ILanStatusImpl *cached_This = NULL;
if (!ppv)
return E_POINTER;
@@ -466,15 +527,13 @@
This->ref = 1;
This->lpVtbl = (IOleCommandTarget*)&vt_OleCommandTarget;
This->lpNetMan = NULL;
-
- if (FAILED(IOleCommandTarget_fnQueryInterface ((IOleCommandTarget*)This, riid,
ppv)))
- {
- IOleCommandTarget_Release((IUnknown*)This);
- return E_NOINTERFACE;
- }
- IOleCommandTarget_Release((IUnknown*)This);
- return S_OK;
-}
-
-
-
+ This->pHead = NULL;
+
+ if (InterlockedCompareExchangePointer((void *)&cached_This, This, NULL) != NULL)
+ {
+ CoTaskMemFree(This);
+ }
+
+ return IOleCommandTarget_fnQueryInterface ((IOleCommandTarget*)cached_This, riid,
ppv);
+}
+
Modified: trunk/reactos/dll/win32/netshell/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/precomp…
==============================================================================
--- trunk/reactos/dll/win32/netshell/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/precomp.h [iso-8859-1] Wed Sep 17 10:20:04 2008
@@ -77,6 +77,7 @@
extern HINSTANCE netshell_hInstance;
extern const GUID CLSID_NetworkConnections;
extern const GUID CLSID_LANConnectUI;
+extern const GUID CLSID_LanConnectStatusUI;
extern const GUID GUID_DEVCLASS_NET;
Modified: trunk/reactos/dll/win32/netshell/shfldr_netconnect.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/shfldr_…
==============================================================================
--- trunk/reactos/dll/win32/netshell/shfldr_netconnect.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/shfldr_netconnect.c [iso-8859-1] Wed Sep 17 10:20:04
2008
@@ -37,6 +37,7 @@
/* both paths are parsible from the desktop */
LPITEMIDLIST pidlRoot; /* absolute pidl */
LPCITEMIDLIST apidl; /* currently focused font item */
+ IOleCommandTarget * lpOleCmd;
} IGenericSFImpl, *LPIGenericSFImpl;
@@ -749,6 +750,27 @@
}
HRESULT
+ShowNetConnectionStatus(
+ IGenericSFImpl * This,
+ INetConnection * pNetConnect,
+ HWND hwnd)
+{
+ NETCON_PROPERTIES * pProperties;
+ HRESULT hr;
+
+ if (!This->lpOleCmd)
+ return E_FAIL;
+
+ if (INetConnection_GetProperties(pNetConnect, &pProperties) != NOERROR)
+ return E_FAIL;
+
+ hr = IOleCommandTarget_Exec(This->lpOleCmd, &pProperties->guidId, 2,
OLECMDEXECOPT_DODEFAULT, NULL, NULL);
+
+ NcFreeNetconProperties(pProperties);
+ return hr;
+}
+
+HRESULT
ShowNetConnectionProperties(
INetConnection * pNetConnect,
HWND hwnd)
@@ -810,7 +832,6 @@
{
IGenericSFImpl * This = impl_from_IContextMenu2(iface);
VALUEStruct * val;
- HRESULT hr = S_OK;
val = _ILGetValueStruct(This->apidl);
@@ -819,13 +840,7 @@
if (lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_NET_STATUS))
{
-#if 0
- if (pProperties->MediaType == NCM_LAN)
- {
- hr = ShowLANConnectionStatusDialog(pProperties);
- }
-#endif
- return hr;
+ return ShowNetConnectionStatus(This, val->pItem, lpcmi->hwnd);
}
else if (lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_NET_PROPERTIES))
{
@@ -977,6 +992,7 @@
HRESULT WINAPI ISF_NetConnect_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID *
ppv)
{
IGenericSFImpl *sf;
+ HRESULT hr;
if (!ppv)
return E_POINTER;
@@ -991,6 +1007,14 @@
sf->lpVtbl = &vt_ShellFolder2;
sf->lpVtblPersistFolder2 = &vt_PersistFolder2;
sf->lpVtblContextMenu = &vt_ContextMenu2;
+
+ hr = CoCreateInstance(&CLSID_LanConnectStatusUI, NULL, CLSCTX_INPROC_SERVER,
&IID_IOleCommandTarget, (LPVOID*)&sf->lpOleCmd);
+ if (FAILED(hr))
+ sf->lpOleCmd = NULL;
+ else
+ IOleCommandTarget_Exec(sf->lpOleCmd, &CGID_ShellServiceObject, 2,
OLECMDEXECOPT_DODEFAULT, NULL, NULL);
+
+
sf->pidlRoot = _ILCreateNetConnect(); /* my qualified pidl */
if (!SUCCEEDED (IShellFolder2_QueryInterface ((IShellFolder2*)sf, riid, ppv)))