Commit 4d2d627c authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

- forward AddRef, Release, QueryInterface and GetClassID to internal

implementations - implement GetClassID properly
parent 399300a1
......@@ -213,6 +213,102 @@ inline static LPWSTR HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str)
}
/**************************************************************************
* ShellLink::QueryInterface implementation
*/
static HRESULT ShellLink_QueryInterface( IShellLinkImpl *This, REFIID riid, LPVOID *ppvObj)
{
TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLinkA))
{
*ppvObj = This;
}
else if(IsEqualIID(riid, &IID_IShellLinkW))
{
*ppvObj = &(This->lpvtblw);
}
else if(IsEqualIID(riid, &IID_IPersistFile))
{
*ppvObj = &(This->lpvtblPersistFile);
}
else if(IsEqualIID(riid, &IID_IPersistStream))
{
*ppvObj = &(This->lpvtblPersistStream);
}
else if(IsEqualIID(riid, &IID_IShellLinkDataList))
{
*ppvObj = &(This->lpvtblShellLinkDataList);
}
else if(IsEqualIID(riid, &IID_IShellExtInit))
{
*ppvObj = &(This->lpvtblShellExtInit);
}
else if(IsEqualIID(riid, &IID_IContextMenu))
{
*ppvObj = &(This->lpvtblContextMenu);
}
if(*ppvObj)
{
IUnknown_AddRef((IUnknown*)(*ppvObj));
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
return S_OK;
}
ERR("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
/**************************************************************************
* ShellLink::AddRef implementation
*/
static ULONG ShellLink_AddRef( IShellLinkImpl *This )
{
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
return refCount;
}
/**************************************************************************
* ShellLink::Release implementation
*/
static ULONG ShellLink_Release( IShellLinkImpl *This )
{
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
if (refCount)
return refCount;
TRACE("-- destroying IShellLink(%p)\n",This);
HeapFree(GetProcessHeap(), 0, This->sIcoPath);
HeapFree(GetProcessHeap(), 0, This->sArgs);
HeapFree(GetProcessHeap(), 0, This->sWorkDir);
HeapFree(GetProcessHeap(), 0, This->sDescription);
HeapFree(GetProcessHeap(),0,This->sPath);
if (This->pPidl)
ILFree(This->pPidl);
LocalFree((HANDLE)This);
return 0;
}
static HRESULT ShellLink_GetClassID( IShellLinkImpl *This, CLSID *pclsid )
{
TRACE("%p %p\n", This, pclsid);
memcpy( pclsid, &CLSID_ShellLink, sizeof (CLSID) );
return S_OK;
}
/**************************************************************************
* IPersistFile_QueryInterface
*/
static HRESULT WINAPI IPersistFile_fnQueryInterface(
......@@ -221,7 +317,7 @@ static HRESULT WINAPI IPersistFile_fnQueryInterface(
LPVOID *ppvObj)
{
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObj);
return ShellLink_QueryInterface( This, riid, ppvObj );
}
/******************************************************************************
......@@ -230,7 +326,7 @@ static HRESULT WINAPI IPersistFile_fnQueryInterface(
static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile* iface)
{
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
return IShellLinkA_AddRef((IShellLinkA*)This);
return ShellLink_AddRef( This );
}
/******************************************************************************
......@@ -245,8 +341,7 @@ static ULONG WINAPI IPersistFile_fnRelease(IPersistFile* iface)
static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile* iface, CLSID *pClassID)
{
_ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
FIXME("(%p)\n",This);
return NOERROR;
return ShellLink_GetClassID( This, pClassID );
}
static HRESULT WINAPI IPersistFile_fnIsDirty(IPersistFile* iface)
......@@ -384,10 +479,10 @@ static const IPersistFileVtbl pfvt =
static HRESULT WINAPI IPersistStream_fnQueryInterface(
IPersistStream* iface,
REFIID riid,
VOID** ppvoid)
VOID** ppvObj)
{
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvoid);
return ShellLink_QueryInterface( This, riid, ppvObj );
}
/************************************************************************
......@@ -407,7 +502,7 @@ static ULONG WINAPI IPersistStream_fnAddRef(
IPersistStream* iface)
{
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
return IShellLinkA_AddRef((IShellLinkA*)This);
return ShellLink_AddRef( This );
}
/************************************************************************
......@@ -419,15 +514,7 @@ static HRESULT WINAPI IPersistStream_fnGetClassID(
CLSID* pClassID)
{
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
TRACE("(%p)\n", This);
if (pClassID==0)
return E_POINTER;
/* memcpy(pClassID, &CLSID_???, sizeof(CLSID_???)); */
return S_OK;
return ShellLink_GetClassID( This, pClassID );
}
/************************************************************************
......@@ -1218,49 +1305,7 @@ HRESULT WINAPI IShellLink_ConstructFromFile( IUnknown* pUnkOuter, REFIID riid,
static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID riid, LPVOID *ppvObj)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IShellLinkA))
{
*ppvObj = This;
}
else if(IsEqualIID(riid, &IID_IShellLinkW))
{
*ppvObj = &(This->lpvtblw);
}
else if(IsEqualIID(riid, &IID_IPersistFile))
{
*ppvObj = &(This->lpvtblPersistFile);
}
else if(IsEqualIID(riid, &IID_IPersistStream))
{
*ppvObj = &(This->lpvtblPersistStream);
}
else if(IsEqualIID(riid, &IID_IShellLinkDataList))
{
*ppvObj = &(This->lpvtblShellLinkDataList);
}
else if(IsEqualIID(riid, &IID_IShellExtInit))
{
*ppvObj = &(This->lpvtblShellExtInit);
}
else if(IsEqualIID(riid, &IID_IContextMenu))
{
*ppvObj = &(This->lpvtblContextMenu);
}
if(*ppvObj)
{
IUnknown_AddRef((IUnknown*)(*ppvObj));
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
return S_OK;
}
ERR("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
return ShellLink_QueryInterface( This, riid, ppvObj );
}
/******************************************************************************
......@@ -1269,11 +1314,7 @@ static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID
static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
return refCount;
return ShellLink_AddRef( This );
}
/******************************************************************************
......@@ -1282,27 +1323,7 @@ static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface)
static ULONG WINAPI IShellLinkA_fnRelease(IShellLinkA * iface)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
if (refCount)
return refCount;
TRACE("-- destroying IShellLink(%p)\n",This);
HeapFree(GetProcessHeap(), 0, This->sIcoPath);
HeapFree(GetProcessHeap(), 0, This->sArgs);
HeapFree(GetProcessHeap(), 0, This->sWorkDir);
HeapFree(GetProcessHeap(), 0, This->sDescription);
HeapFree(GetProcessHeap(),0,This->sPath);
if (This->pPidl)
ILFree(This->pPidl);
LocalFree((HANDLE)This);
return 0;
return ShellLink_Release( This );
}
static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA * iface, LPSTR pszFile,
......@@ -1655,7 +1676,7 @@ static HRESULT WINAPI IShellLinkW_fnQueryInterface(
IShellLinkW * iface, REFIID riid, LPVOID *ppvObj)
{
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObj);
return ShellLink_QueryInterface( This, riid, ppvObj );
}
/******************************************************************************
......@@ -1664,16 +1685,16 @@ static HRESULT WINAPI IShellLinkW_fnQueryInterface(
static ULONG WINAPI IShellLinkW_fnAddRef(IShellLinkW * iface)
{
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
return IShellLinkA_AddRef((IShellLinkA*)This);
return ShellLink_AddRef( This );
}
/******************************************************************************
* IShellLinkW_fnRelease
*/
static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
{
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
return IShellLinkA_Release((IShellLinkA*)This);
return ShellLink_Release( This );
}
static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAW *pfd, DWORD fFlags)
......@@ -2201,7 +2222,7 @@ static ULONG WINAPI
ShellLink_DataList_Release( IShellLinkDataList* iface )
{
_ICOM_THIS_From_IShellLinkDataList(IShellLinkImpl, iface);
return IShellLinkA_Release((IShellLinkA*)This);
return ShellLink_Release( This );
}
static HRESULT WINAPI
......@@ -2269,7 +2290,7 @@ static ULONG WINAPI
ShellLink_ExtInit_Release( IShellExtInit* iface )
{
_ICOM_THIS_From_IShellExtInit(IShellLinkImpl, iface);
return IShellLinkA_Release((IShellLinkA*)This);
return ShellLink_Release( This );
}
/**************************************************************************
......@@ -2349,7 +2370,7 @@ static ULONG WINAPI
ShellLink_ContextMenu_Release( IContextMenu* iface )
{
_ICOM_THIS_From_IContextMenu(IShellLinkImpl, iface);
return IShellLinkA_Release((IShellLinkA*)This);
return ShellLink_Release( This );
}
static HRESULT WINAPI
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment