[PATCH 1/5] shell32: Check for ICommDlgBrowser from Site and use it in the IExplorerBrowser control.

David Hedberg david.hedberg at gmail.com
Thu Aug 26 05:53:53 CDT 2010


---
 dlls/shell32/ebrowser.c       |   98 +++++++++++++++++++----
 dlls/shell32/tests/ebrowser.c |  174 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 251 insertions(+), 21 deletions(-)

diff --git a/dlls/shell32/ebrowser.c b/dlls/shell32/ebrowser.c
index b243aa0..1137880 100644
--- a/dlls/shell32/ebrowser.c
+++ b/dlls/shell32/ebrowser.c
@@ -73,6 +73,8 @@ typedef struct _ExplorerBrowserImpl {
     LPITEMIDLIST current_pidl;
 
     IUnknown *punk_site;
+    ICommDlgBrowser3 *pcdb3_site;
+    UINT cdb_site_supported;
 } ExplorerBrowserImpl;
 
 /**************************************************************************
@@ -340,19 +342,44 @@ static void get_interfaces_from_site(ExplorerBrowserImpl *This)
      * release any previously fetched interfaces.
      */
 
-    if(This->punk_site)
+    if(This->pcdb3_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->pcdb3_site);
+        This->pcdb3_site = NULL;
+        This->cdb_site_supported = 0;
     }
+
+    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 */
+    if(SUCCEEDED(IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser3,
+                                               (void**)&This->pcdb3_site)))
+    {
+        This->cdb_site_supported = 3;
+    }
+    else if(SUCCEEDED(IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser2,
+                                                    (void**)&This->pcdb3_site)))
+    {
+        This->cdb_site_supported = 2;
+    }
+    else if(SUCCEEDED(IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser,
+                                                    (void**)&This->pcdb3_site)))
+    {
+        This->cdb_site_supported = 1;
+    }
+
+    IServiceProvider_Release(psp);
 }
 
+
 /**************************************************************************
  * Main window related functions.
  */
@@ -1154,20 +1181,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->cdb_site_supported >= 1)
+        return ICommDlgBrowser_OnDefaultCommand(This->pcdb3_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->cdb_site_supported >= 1)
+        return ICommDlgBrowser_OnStateChange(This->pcdb3_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->cdb_site_supported >= 1)
+        return ICommDlgBrowser_IncludeObject(This->pcdb3_site, pshv, pidl);
+
     return S_OK;
 }
 
@@ -1176,7 +1216,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->cdb_site_supported >= 2)
+        return ICommDlgBrowser2_Notify(This->pcdb3_site, pshv, dwNotifyType);
+
     return S_OK;
 }
 
@@ -1185,7 +1229,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->cdb_site_supported >= 2)
+        return ICommDlgBrowser2_GetDefaultMenuText(This->pcdb3_site, pshv, pszText, cchMax);
+
     return S_OK;
 }
 
@@ -1193,7 +1241,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->cdb_site_supported >= 2)
+        return ICommDlgBrowser2_GetViewFlags(This->pcdb3_site, pdwFlags);
+
     return S_OK;
 }
 
@@ -1201,7 +1253,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->cdb_site_supported >= 3)
+        return ICommDlgBrowser3_OnColumnClicked(This->pcdb3_site, pshv, iColumn);
+
     return S_OK;
 }
 
@@ -1210,7 +1266,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->cdb_site_supported >= 3)
+        return ICommDlgBrowser3_GetCurrentFilter(This->pcdb3_site, pszFileSpec, cchFileSpec);
+
     return S_OK;
 }
 
@@ -1218,7 +1278,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->cdb_site_supported >= 3)
+        return ICommDlgBrowser3_OnPreviewCreated(This->pcdb3_site, pshv);
+
     return S_OK;
 }
 
diff --git a/dlls/shell32/tests/ebrowser.c b/dlls/shell32/tests/ebrowser.c
index e98ced6..ab66103 100644
--- a/dlls/shell32/tests/ebrowser.c
+++ b/dlls/shell32/tests/ebrowser.c
@@ -188,6 +188,156 @@ static const IExplorerBrowserEventsVtbl ebevents =
 };
 
 /*********************************************************************
+ * 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
  */
 typedef struct {
@@ -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)
-- 
1.7.2.2




More information about the wine-patches mailing list