shell32: Check for ICommDlgBrowser from site and use it in the IExplorerBrowser control.

This commit is contained in:
David Hedberg 2010-08-26 13:58:16 +02:00 committed by Alexandre Julliard
parent 89646084ba
commit ddcd619f6c
2 changed files with 247 additions and 21 deletions

View File

@ -73,6 +73,9 @@ typedef struct _ExplorerBrowserImpl {
LPITEMIDLIST current_pidl;
IUnknown *punk_site;
ICommDlgBrowser *pcdb_site;
ICommDlgBrowser2 *pcdb2_site;
ICommDlgBrowser3 *pcdb3_site;
} ExplorerBrowserImpl;
/**************************************************************************
@ -340,19 +343,39 @@ static void get_interfaces_from_site(ExplorerBrowserImpl *This)
* release any previously fetched interfaces.
*/
if(This->punk_site)
if(This->pcdb_site)
{
hr = IUnknown_QueryInterface(This->punk_site, &IID_IServiceProvider, (void**)&psp);
if(SUCCEEDED(hr))
{
FIXME("Not requesting any interfaces.\n");
IServiceProvider_Release(psp);
}
else
ERR("Failed to get IServiceProvider from site.\n");
IUnknown_Release(This->pcdb_site);
if(This->pcdb2_site) IUnknown_Release(This->pcdb2_site);
if(This->pcdb3_site) IUnknown_Release(This->pcdb3_site);
This->pcdb_site = NULL;
This->pcdb2_site = NULL;
This->pcdb3_site = NULL;
}
if(!This->punk_site)
return;
hr = IUnknown_QueryInterface(This->punk_site, &IID_IServiceProvider, (void**)&psp);
if(FAILED(hr))
{
ERR("Failed to get IServiceProvider from site.\n");
return;
}
/* ICommDlgBrowser */
IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser,
(void**)&This->pcdb_site);
IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser2,
(void**)&This->pcdb2_site);
IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser3,
(void**)&This->pcdb3_site);
IServiceProvider_Release(psp);
}
/**************************************************************************
* Main window related functions.
*/
@ -1154,20 +1177,33 @@ static HRESULT WINAPI ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3 *ifac
} else
ERR("Failed to get IDataObject.\n");
/* If we didn't handle the default command, check if we have a
* client that does */
if(ret == S_FALSE && This->pcdb_site)
return ICommDlgBrowser_OnDefaultCommand(This->pcdb_site, shv);
return ret;
}
static HRESULT WINAPI ICommDlgBrowser3_fnOnStateChange(ICommDlgBrowser3 *iface,
IShellView *shv, ULONG uChange)
{
ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
FIXME("stub, %p (%p, %d)\n", This, shv, uChange);
TRACE("%p (%p, %d)\n", This, shv, uChange);
if(This->pcdb_site)
return ICommDlgBrowser_OnStateChange(This->pcdb_site, shv, uChange);
return E_NOTIMPL;
}
static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(ICommDlgBrowser3 *iface,
IShellView *pshv, LPCITEMIDLIST pidl)
{
ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
FIXME("stub, %p (%p, %p)\n", This, pshv, pidl);
TRACE("%p (%p, %p)\n", This, pshv, pidl);
if(This->pcdb_site)
return ICommDlgBrowser_IncludeObject(This->pcdb_site, pshv, pidl);
return S_OK;
}
@ -1176,7 +1212,11 @@ static HRESULT WINAPI ICommDlgBrowser3_fnNotify(ICommDlgBrowser3 *iface,
DWORD dwNotifyType)
{
ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
FIXME("stub, %p (%p, 0x%x)\n", This, pshv, dwNotifyType);
TRACE("%p (%p, 0x%x)\n", This, pshv, dwNotifyType);
if(This->pcdb2_site)
return ICommDlgBrowser2_Notify(This->pcdb2_site, pshv, dwNotifyType);
return S_OK;
}
@ -1185,7 +1225,11 @@ static HRESULT WINAPI ICommDlgBrowser3_fnGetDefaultMenuText(ICommDlgBrowser3 *if
LPWSTR pszText, int cchMax)
{
ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
FIXME("stub, %p (%p, %s, %d)\n", This, pshv, debugstr_w(pszText), cchMax);
TRACE("%p (%p, %s, %d)\n", This, pshv, debugstr_w(pszText), cchMax);
if(This->pcdb2_site)
return ICommDlgBrowser2_GetDefaultMenuText(This->pcdb2_site, pshv, pszText, cchMax);
return S_OK;
}
@ -1193,7 +1237,11 @@ static HRESULT WINAPI ICommDlgBrowser3_fnGetViewFlags(ICommDlgBrowser3 *iface,
DWORD *pdwFlags)
{
ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
FIXME("stub, %p (%p)\n", This, pdwFlags);
TRACE("%p (%p)\n", This, pdwFlags);
if(This->pcdb2_site)
return ICommDlgBrowser2_GetViewFlags(This->pcdb2_site, pdwFlags);
return S_OK;
}
@ -1201,7 +1249,11 @@ static HRESULT WINAPI ICommDlgBrowser3_fnOnColumnClicked(ICommDlgBrowser3 *iface
IShellView *pshv, int iColumn)
{
ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
FIXME("stub, %p (%p, %d)\n", This, pshv, iColumn);
TRACE("%p (%p, %d)\n", This, pshv, iColumn);
if(This->pcdb3_site)
return ICommDlgBrowser3_OnColumnClicked(This->pcdb3_site, pshv, iColumn);
return S_OK;
}
@ -1210,7 +1262,11 @@ static HRESULT WINAPI ICommDlgBrowser3_fnGetCurrentFilter(ICommDlgBrowser3 *ifac
int cchFileSpec)
{
ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
FIXME("stub, %p (%s, %d)\n", This, debugstr_w(pszFileSpec), cchFileSpec);
TRACE("%p (%s, %d)\n", This, debugstr_w(pszFileSpec), cchFileSpec);
if(This->pcdb3_site)
return ICommDlgBrowser3_GetCurrentFilter(This->pcdb3_site, pszFileSpec, cchFileSpec);
return S_OK;
}
@ -1218,7 +1274,11 @@ static HRESULT WINAPI ICommDlgBrowser3_fnOnPreviewCreated(ICommDlgBrowser3 *ifac
IShellView *pshv)
{
ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
FIXME("stub, %p (%p)\n", This, pshv);
TRACE("%p (%p)\n", This, pshv);
if(This->pcdb3_site)
return ICommDlgBrowser3_OnPreviewCreated(This->pcdb3_site, pshv);
return S_OK;
}

View File

@ -187,6 +187,156 @@ static const IExplorerBrowserEventsVtbl ebevents =
IExplorerBrowserEvents_fnOnNavigationFailed
};
/*********************************************************************
* ICommDlgBrowser3 implementation
*/
typedef struct
{
const ICommDlgBrowser3Vtbl *lpVtbl;
LONG ref;
UINT OnDefaultCommand, OnStateChange, IncludeObject;
UINT Notify, GetDefaultMenuText, GetViewFlags;
UINT OnColumnClicked, GetCurrentFilter, OnPreviewCreated;
} ICommDlgBrowser3Impl;
static HRESULT WINAPI ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3 *iface, REFIID riid, LPVOID *ppvObj)
{
ok(0, "Not called.\n");
trace("riid:"); dbg_print_guid(riid);
*ppvObj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI ICommDlgBrowser3_fnAddRef(ICommDlgBrowser3 *iface)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI ICommDlgBrowser3_fnRelease(ICommDlgBrowser3 *iface)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
if(!ref)
HeapFree(GetProcessHeap(), 0, This);
return ref;
}
static HRESULT WINAPI ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3* iface, IShellView *shv)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
This->OnDefaultCommand++;
return E_NOTIMPL;
}
static HRESULT WINAPI ICommDlgBrowser3_fnOnStateChange(
ICommDlgBrowser3* iface,
IShellView *shv,
ULONG uChange)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
This->OnStateChange++;
return E_NOTIMPL;
}
static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(
ICommDlgBrowser3* iface,
IShellView *shv,
LPCITEMIDLIST pidl)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
This->IncludeObject++;
return S_OK;
}
static HRESULT WINAPI ICommDlgBrowser3_fnNotify(
ICommDlgBrowser3* iface,
IShellView *ppshv,
DWORD dwNotifyType)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
This->Notify++;
return E_NOTIMPL;
}
static HRESULT WINAPI ICommDlgBrowser3_fnGetDefaultMenuText(
ICommDlgBrowser3* iface,
IShellView *ppshv,
LPWSTR pszText,
int cchMax)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
This->GetDefaultMenuText++;
return E_NOTIMPL;
}
static HRESULT WINAPI ICommDlgBrowser3_fnGetViewFlags(
ICommDlgBrowser3* iface,
DWORD *pdwFlags)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
This->GetViewFlags++;
return E_NOTIMPL;
}
static HRESULT WINAPI ICommDlgBrowser3_fnOnColumnClicked(
ICommDlgBrowser3* iface,
IShellView *ppshv,
int iColumn)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
This->OnColumnClicked++;
return E_NOTIMPL;
}
static HRESULT WINAPI ICommDlgBrowser3_fnGetCurrentFilter(
ICommDlgBrowser3* iface,
LPWSTR pszFileSpec,
int cchFileSpec)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
This->GetCurrentFilter++;
return E_NOTIMPL;
}
static HRESULT WINAPI ICommDlgBrowser3_fnOnPreviewCreated(
ICommDlgBrowser3* iface,
IShellView *ppshv)
{
ICommDlgBrowser3Impl *This = (ICommDlgBrowser3Impl *)iface;
This->OnPreviewCreated++;
return E_NOTIMPL;
}
static const ICommDlgBrowser3Vtbl cdbvtbl =
{
ICommDlgBrowser3_fnQueryInterface,
ICommDlgBrowser3_fnAddRef,
ICommDlgBrowser3_fnRelease,
ICommDlgBrowser3_fnOnDefaultCommand,
ICommDlgBrowser3_fnOnStateChange,
ICommDlgBrowser3_fnIncludeObject,
ICommDlgBrowser3_fnNotify,
ICommDlgBrowser3_fnGetDefaultMenuText,
ICommDlgBrowser3_fnGetViewFlags,
ICommDlgBrowser3_fnOnColumnClicked,
ICommDlgBrowser3_fnGetCurrentFilter,
ICommDlgBrowser3_fnOnPreviewCreated
};
ICommDlgBrowser3Impl *create_commdlgbrowser3(void)
{
ICommDlgBrowser3Impl *cdb;
cdb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ICommDlgBrowser3Impl));
cdb->lpVtbl = &cdbvtbl;
cdb->ref = 1;
return cdb;
}
/*********************************************************************
* IServiceProvider Implementation
*/
@ -636,22 +786,23 @@ static void test_SetSite(void)
{
IExplorerBrowser *peb;
IServiceProviderImpl *spimpl = create_serviceprovider();
ICommDlgBrowser3Impl *cdbimpl = create_commdlgbrowser3();
IObjectWithSite *pow;
HRESULT hr;
LONG ref;
UINT i;
struct services expected[] = {
/* Win 7 */
{ &SID_STopLevelBrowser, &IID_ICommDlgBrowser2, 0, NULL },
{ &SID_STopLevelBrowser, &IID_ICommDlgBrowser2, 0, cdbimpl },
{ &SID_STopLevelBrowser, &IID_IShellBrowserService, 0, NULL },
{ &SID_STopLevelBrowser, &IID_IShellBrowser, 0, NULL },
{ &SID_STopLevelBrowser, &IID_UnknownInterface8, 0, NULL },
{ &SID_STopLevelBrowser, &IID_IConnectionPointContainer, 0, NULL },
{ &SID_STopLevelBrowser, &IID_IProfferService, 0, NULL },
{ &SID_STopLevelBrowser, &IID_UnknownInterface9, 0, NULL },
{ &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser2, 0, NULL },
{ &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser3, 0, NULL },
{ &SID_ExplorerPaneVisibility, &IID_IExplorerPaneVisibility, 0, NULL },
{ &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser2, 0, cdbimpl },
{ &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser3, 0, cdbimpl },
{ &IID_IFileDialogPrivate, &IID_IFileDialogPrivate, 0, NULL },
{ &IID_IFileDialogPrivate, &IID_IFileDialog, 0, NULL },
{ &IID_IShellTaskScheduler, &IID_IShellTaskScheduler, 0, NULL },
@ -672,7 +823,7 @@ static void test_SetSite(void)
{ &IID_IFolderTypeModifier, &IID_IFolderTypeModifier, 0, NULL },
{ &SID_STopLevelBrowser, &IID_IShellBrowserService_Vista, 0, NULL },
{ &IID_UnknownInterface5, &IID_UnknownInterface5, 0, NULL },
{ &IID_ICommDlgBrowser, &IID_ICommDlgBrowser, 0, NULL },
{ &IID_ICommDlgBrowser, &IID_ICommDlgBrowser, 0, cdbimpl },
{ &IID_IFileDialogPrivate_Vista,&IID_IFileDialogPrivate_Vista, 0, NULL},
{ &IID_IFileDialogPrivate_Vista,&IID_IFileDialog, 0, NULL},
{ &IID_UnknownInterface10, &IID_IHTMLDocument2, 0, NULL},
@ -704,6 +855,7 @@ static void test_SetSite(void)
skip("Failed to set site.\n");
IServiceProvider_Release((IServiceProvider*)spimpl);
ICommDlgBrowser3_Release((ICommDlgBrowser3*)cdbimpl);
IExplorerBrowser_Destroy(peb);
ref = IExplorerBrowser_Release(peb);
ok(ref == 0, "Got ref %d\n", ref);
@ -722,6 +874,17 @@ static void test_SetSite(void)
}
ShowWindow(hwnd, FALSE);
/* ICommDlgBrowser3 */
ok(!cdbimpl->OnDefaultCommand, "Got %d\n", cdbimpl->OnDefaultCommand);
todo_wine ok(cdbimpl->OnStateChange, "Got %d\n", cdbimpl->OnStateChange);
ok(cdbimpl->IncludeObject, "Got %d\n", cdbimpl->IncludeObject);
ok(!cdbimpl->Notify, "Got %d\n", cdbimpl->Notify);
ok(!cdbimpl->GetDefaultMenuText, "Got %d\n", cdbimpl->GetDefaultMenuText);
todo_wine ok(cdbimpl->GetViewFlags, "Got %d\n", cdbimpl->GetViewFlags);
ok(!cdbimpl->OnColumnClicked, "Got %d\n", cdbimpl->OnColumnClicked);
ok(!cdbimpl->GetCurrentFilter, "Got %d\n", cdbimpl->GetCurrentFilter);
todo_wine ok(cdbimpl->OnPreviewCreated, "Got %d\n", cdbimpl->OnPreviewCreated);
if(0)
{
for(i = 0; expected[i].service != NULL; i++)
@ -759,6 +922,9 @@ static void test_SetSite(void)
ref = IServiceProvider_Release((IServiceProvider*)spimpl);
ok(ref == 0, "Got ref %d\n", ref);
ref = ICommDlgBrowser3_Release((ICommDlgBrowser3*)cdbimpl);
ok(ref == 0, "Got ref %d\n", ref);
}
static void test_basics(void)