Author: janderwald
Date: Fri Nov 14 12:47:00 2008
New Revision: 37360
URL:
http://svn.reactos.org/svn/reactos?rev=37360&view=rev
Log:
- Implement IShellExecuteHookW
- Free NETCON_PROPERTIES on cleanup
- Show status dialog when clicking on startmenu->settings->network connections item
- Fixes bug 3782
See issue #3782 for more details.
Modified:
trunk/reactos/dll/win32/netshell/shfldr_netconnect.c
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] Fri Nov 14 12:47:00
2008
@@ -33,6 +33,7 @@
LONG ref;
const IPersistFolder2Vtbl *lpVtblPersistFolder2;
+ const IShellExecuteHookWVtbl *lpVtblShellExecuteHookW;
//const IPersistIDListVtbl *lpVtblPersistIDList;
/* both paths are parsible from the desktop */
@@ -71,6 +72,8 @@
#define COLUMN_PHONE 4
#define COLUMN_OWNER 5
+HRESULT ShowNetConnectionStatus(IOleCommandTarget * lpOleCmd, INetConnection *
pNetConnect, HWND hwnd);
+
static const IContextMenu3Vtbl vt_ContextMenu3;
static const IObjectWithSiteVtbl vt_ObjectWithSite;
static const IQueryInfoVtbl vt_QueryInfo;
@@ -92,6 +95,11 @@
return (LPIGenericSFImpl)((char *)iface - FIELD_OFFSET(IGenericSFImpl,
lpVtblPersistFolder2));
}
+static LPIGenericSFImpl __inline impl_from_IShellExecuteHookW(IShellExecuteHookW *iface)
+{
+ return (LPIGenericSFImpl)((char *)iface - FIELD_OFFSET(IGenericSFImpl,
lpVtblShellExecuteHookW));
+}
+
static LPIContextMenuImpl __inline impl_from_IQueryInfo(IQueryInfo *iface)
{
return (LPIContextMenuImpl)((char *)iface - FIELD_OFFSET(IContextMenuImpl,
lpVtblQueryInfo));
@@ -120,6 +128,10 @@
IsEqualIID (riid, &IID_IPersistFolder2))
{
*ppvObj = (LPVOID *)&This->lpVtblPersistFolder2;
+ }
+ else if (IsEqualIID(riid, &IID_IShellExecuteHookW))
+ {
+ *ppvObj = (LPVOID *)&This->lpVtblShellExecuteHookW;
}
#if 0
else if (IsEqualIID(riid, &IID_IPersistIDList))
@@ -382,12 +394,14 @@
pMenu->lpOleCmd = lpOleCmd;
pMenu->ref = 1;
- if (IsEqualIID(riid, &IID_IContextMenu) || IsEqualIID(riid,
&IID_IContextMenu2))// || IsEqualIID(riid, &IID_IContextMenu3))
+ if (IsEqualIID(riid, &IID_IContextMenu) || IsEqualIID(riid,
&IID_IContextMenu2)|| IsEqualIID(riid, &IID_IContextMenu3))
pObj = (IUnknown*)(&pMenu->lpVtblContextMenu);
else if(IsEqualIID(riid, &IID_IQueryInfo))
pObj = (IUnknown*)(&pMenu->lpVtblQueryInfo);
else if(IsEqualIID(riid, &IID_IExtractIconW))
pObj = (IUnknown*)(&pMenu->lpVtblExtractIconW);
+ else
+ return E_NOINTERFACE;
IUnknown_AddRef(pObj);
@@ -462,7 +476,7 @@
wcscpy(pszName, pProperties->pszwName);
hr = S_OK;
}
- //NcFreeNetconProperties(pProperties);
+ NcFreeNetconProperties(pProperties);
}
}
@@ -842,7 +856,7 @@
_InsertMenuItemW(hMenu, indexMenu++, TRUE, -1, MFT_SEPARATOR, NULL, MFS_ENABLED);
_InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_PROPERTIES, MFT_STRING,
MAKEINTRESOURCEW(IDS_NET_PROPERTIES), MFS_ENABLED);
-
+ NcFreeNetconProperties(pProperties);
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 9);
}
@@ -862,23 +876,23 @@
HRESULT
ShowNetConnectionStatus(
- IContextMenuImpl * This,
+ IOleCommandTarget * lpOleCmd,
INetConnection * pNetConnect,
HWND hwnd)
{
NETCON_PROPERTIES * pProperties;
HRESULT hr;
- if (!This->lpOleCmd)
+ if (!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);
+ hr = IOleCommandTarget_Exec(lpOleCmd, &pProperties->guidId, 2,
OLECMDEXECOPT_DODEFAULT, NULL, NULL);
NcFreeNetconProperties(pProperties);
- return E_FAIL;
+ return hr;
}
HRESULT
@@ -951,7 +965,7 @@
if (lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_NET_STATUS) ||
lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_NET_STATUS-1)) //HACK for Windows XP
{
- return ShowNetConnectionStatus(This, val->pItem, lpcmi->hwnd);
+ return ShowNetConnectionStatus(This->lpOleCmd, val->pItem,
lpcmi->hwnd);
}
else if (lpcmi->lpVerb == MAKEINTRESOURCEA(IDS_NET_PROPERTIES) ||
lpcmi->lpVerb == MAKEINTRESOURCEA(10099)) //HACK for Windows XP
@@ -1310,6 +1324,75 @@
ISF_NetConnect_PersistFolder2_GetCurFolder
};
+/************************************************************************
+ * ISF_NetConnect_ShellExecuteHookW_QueryInterface
+ */
+static HRESULT WINAPI ISF_NetConnect_ShellExecuteHookW_QueryInterface (IShellExecuteHookW
* iface,
+ REFIID iid, LPVOID * ppvObj)
+{
+ IGenericSFImpl * This = impl_from_IShellExecuteHookW(iface);
+
+ return IShellFolder2_QueryInterface ((IShellFolder2*)This, iid, ppvObj);
+}
+
+/************************************************************************
+ * ISF_NetConnect_ShellExecuteHookW_AddRef
+ */
+static ULONG WINAPI ISF_NetConnect_ShellExecuteHookW_AddRef (IShellExecuteHookW * iface)
+{
+ IGenericSFImpl * This = impl_from_IShellExecuteHookW(iface);
+
+ return IShellFolder2_AddRef((IShellFolder2*)This);
+}
+
+/************************************************************************
+ * ISF_NetConnect_PersistFolder2_Release
+ */
+static ULONG WINAPI ISF_NetConnect_ShellExecuteHookW_Release (IShellExecuteHookW *
iface)
+{
+ IGenericSFImpl * This = impl_from_IShellExecuteHookW(iface);
+
+ return IShellFolder2_Release((IShellFolder2*)This);
+}
+
+
+/************************************************************************
+ * ISF_NetConnect_ShellExecuteHookW_Execute
+ */
+static HRESULT WINAPI ISF_NetConnect_ShellExecuteHookW_Execute (IShellExecuteHookW *
iface,
+ LPSHELLEXECUTEINFOW pei)
+{
+ VALUEStruct * val;
+ NETCON_PROPERTIES * pProperties;
+ IGenericSFImpl * This = impl_from_IShellExecuteHookW(iface);
+
+ val = _ILGetValueStruct(ILFindLastID(pei->lpIDList));
+ if (!val)
+ return E_FAIL;
+
+ if (INetConnection_GetProperties((INetConnection*)val->pItem, &pProperties) !=
NOERROR)
+ return E_FAIL;
+
+ if (pProperties->Status == NCS_CONNECTED)
+ {
+ NcFreeNetconProperties(pProperties);
+ return ShowNetConnectionStatus(This->lpOleCmd, val->pItem, pei->hwnd);
+ }
+
+ NcFreeNetconProperties(pProperties);
+
+ return S_OK;
+}
+
+
+static const IShellExecuteHookWVtbl vt_ShellExecuteHookW =
+{
+ ISF_NetConnect_ShellExecuteHookW_QueryInterface,
+ ISF_NetConnect_ShellExecuteHookW_AddRef,
+ ISF_NetConnect_ShellExecuteHookW_Release,
+ ISF_NetConnect_ShellExecuteHookW_Execute
+};
+
#if 0
static const IPersistIDListVtbl vt_PersistIDList =
{
@@ -1413,6 +1496,7 @@
sf->ref = 1;
sf->lpVtbl = &vt_ShellFolder2;
sf->lpVtblPersistFolder2 = &vt_PersistFolder2;
+ sf->lpVtblShellExecuteHookW = &vt_ShellExecuteHookW;
hr = CoCreateInstance(&CLSID_LanConnectStatusUI, NULL, CLSCTX_INPROC_SERVER,
&IID_IOleCommandTarget, (LPVOID*)&sf->lpOleCmd);
if (FAILED(hr))