Jacek Caban : wmp: Added SetClientSite implementation.

Alexandre Julliard julliard at winehq.org
Mon Feb 10 13:06:56 CST 2014


Module: wine
Branch: master
Commit: 54e3e0de4801639a7a39174b30147f18d6094cd4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=54e3e0de4801639a7a39174b30147f18d6094cd4

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Feb 10 11:50:34 2014 +0100

wmp: Added SetClientSite implementation.

---

 dlls/wmp/oleobj.c      |   45 +++++++++++++++++++++++++++++++++++++++++----
 dlls/wmp/wmp_private.h |    5 +++++
 2 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/dlls/wmp/oleobj.c b/dlls/wmp/oleobj.c
index 380ae1f..d5c2f85 100644
--- a/dlls/wmp/oleobj.c
+++ b/dlls/wmp/oleobj.c
@@ -28,8 +28,19 @@ struct WindowsMediaPlayer {
     IPersistStreamInit IPersistStreamInit_iface;
 
     LONG ref;
+
+    IOleClientSite *client_site;
 };
 
+static void release_client_site(WindowsMediaPlayer *This)
+{
+    if(!This->client_site)
+        return;
+
+    IOleClientSite_Release(This->client_site);
+    This->client_site = NULL;
+}
+
 static inline WindowsMediaPlayer *impl_from_IOleObject(IOleObject *iface)
 {
     return CONTAINING_RECORD(iface, WindowsMediaPlayer, IOleObject_iface);
@@ -84,8 +95,10 @@ static ULONG WINAPI OleObject_Release(IOleObject *iface)
 
     TRACE("(%p) ref=%d\n", This, ref);
 
-    if(!ref)
+    if(!ref) {
+        release_client_site(This);
         heap_free(This);
+    }
 
     return ref;
 }
@@ -93,8 +106,32 @@ static ULONG WINAPI OleObject_Release(IOleObject *iface)
 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
 {
     WindowsMediaPlayer *This = impl_from_IOleObject(iface);
-    FIXME("(%p)->(%p)\n", This, pClientSite);
-    return E_NOTIMPL;
+    IOleControlSite *control_site;
+    HRESULT hres;
+
+    TRACE("(%p)->(%p)\n", This, pClientSite);
+
+    release_client_site(This);
+    if(!pClientSite)
+        return S_OK;
+
+    IOleClientSite_AddRef(pClientSite);
+    This->client_site = pClientSite;
+
+    hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleControlSite, (void**)&control_site);
+    if(SUCCEEDED(hres)) {
+        IDispatch *disp;
+
+        hres = IOleControlSite_GetExtendedControl(control_site, &disp);
+        if(SUCCEEDED(hres) && disp) {
+            FIXME("Use extended control\n");
+            IDispatch_Release(disp);
+        }
+
+        IOleControlSite_Release(control_site);
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
@@ -407,7 +444,7 @@ HRESULT WINAPI WMPFactory_CreateInstance(IClassFactory *iface, IUnknown *outer,
 
     TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
 
-    wmp = heap_alloc(sizeof(*wmp));
+    wmp = heap_alloc_zero(sizeof(*wmp));
     if(!wmp)
         return E_OUTOFMEMORY;
 
diff --git a/dlls/wmp/wmp_private.h b/dlls/wmp/wmp_private.h
index f294519..68c3dd2 100644
--- a/dlls/wmp/wmp_private.h
+++ b/dlls/wmp/wmp_private.h
@@ -29,6 +29,11 @@ static inline void *heap_alloc(size_t len)
     return HeapAlloc(GetProcessHeap(), 0, len);
 }
 
+static inline void *heap_alloc_zero(size_t len)
+{
+    return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
+}
+
 static inline BOOL heap_free(void *mem)
 {
     return HeapFree(GetProcessHeap(), 0, mem);




More information about the wine-cvs mailing list