From: Jeff Latimer Subject: [2/2]wmvcore: add WMMetadataEditor stub implementation - Try 3 Message-Id: <5348B411.10501@yless4u.com.au> Date: Sat, 12 Apr 2014 13:33:37 +1000 Free the implementation rather that the interface --- dlls/wmvcore/wmvcore_main.c | 99 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 3 deletions(-) diff --git a/dlls/wmvcore/wmvcore_main.c b/dlls/wmvcore/wmvcore_main.c index 5903bf8..5c45b07 100644 --- a/dlls/wmvcore/wmvcore_main.c +++ b/dlls/wmvcore/wmvcore_main.c @@ -25,7 +25,9 @@ #include "windef.h" #include "winbase.h" #include "initguid.h" + #include "wmsdkidl.h" +#include "nserror.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(wmvcore); @@ -63,15 +65,106 @@ HRESULT WINAPI DllRegisterServer(void) return S_OK; } +typedef struct { + IWMMetadataEditor IWMMetadataEditor_iface; + LONG ref; +} WMMetadataEditor; + +static inline WMMetadataEditor *impl_from_IWMMetadataEditor(IWMMetadataEditor *iface) +{ + return CONTAINING_RECORD(iface, WMMetadataEditor, IWMMetadataEditor_iface); +} + +static HRESULT WINAPI WMCreateEditor_QueryInterface(IWMMetadataEditor *iface, + REFIID riid, void **ppv) +{ + + WMMetadataEditor *This = impl_from_IWMMetadataEditor(iface); + TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv); + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = &This->IWMMetadataEditor_iface; + }else if(IsEqualGUID(&IID_IWMMetadataEditor, riid)) { + TRACE("(%p)->(IID_IWMMetadataEditor %p)\n", This, ppv); + *ppv = &This->IWMMetadataEditor_iface; + }else { + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + + return S_OK; +} + +static ULONG WINAPI WMCreateEditor_AddRef(IWMMetadataEditor *iface) +{ + WMMetadataEditor *This = impl_from_IWMMetadataEditor(iface); + ULONG ref; + ref = InterlockedIncrement(&This->ref); + TRACE("(%p) ref=%d\n", iface, ref); + + return ref; +} + +HRESULT WINAPI WMCreateEditor_close(IWMMetadataEditor *iface) +{ + WMMetadataEditor *This = impl_from_IWMMetadataEditor(iface); + FIXME("(%p)\n", iface); + heap_free(This); + return S_OK; +} + +static ULONG WINAPI WMCreateEditor_Release(IWMMetadataEditor *iface) +{ + WMMetadataEditor *This = impl_from_IWMMetadataEditor(iface); + ULONG ref = InterlockedDecrement(&This->ref); + TRACE("(%p) ref=%d\n", iface, ref); + + if (ref == 0) WMCreateEditor_close(iface); + return ref; +} + +HRESULT WINAPI WMCreateEditor_open(IWMMetadataEditor *iface, const WCHAR *filename) +{ + if (!filename) return E_POINTER; + FIXME("(%p) filename=%s\n", iface, debugstr_w(filename)); + return NS_E_FILE_OPEN_FAILED; +} + +HRESULT WINAPI WMCreateEditor_flush(IWMMetadataEditor *iface) +{ + FIXME("(%p)\n", iface); + HeapFree(GetProcessHeap(), 0, iface); + return S_OK; +} + +static const IWMMetadataEditorVtbl VT_Editor = { + WMCreateEditor_QueryInterface, + WMCreateEditor_AddRef, + WMCreateEditor_Release, + WMCreateEditor_open, + WMCreateEditor_flush, + WMCreateEditor_close +}; + HRESULT WINAPI WMCreateEditor(IWMMetadataEditor **editor) { - FIXME("(%p): stub\n", editor); + WMMetadataEditor *metadata_editor; + TRACE("(%p)\n", editor); - *editor = NULL; + metadata_editor = heap_alloc(sizeof(WMMetadataEditor)); + if (!metadata_editor) return E_OUTOFMEMORY; - return E_NOTIMPL; + metadata_editor->IWMMetadataEditor_iface.lpVtbl = &VT_Editor; + metadata_editor->ref = 1; + *editor = &metadata_editor->IWMMetadataEditor_iface; + + return S_OK; } + HRESULT WINAPI WMCreateReader(IUnknown *reserved, DWORD rights, IWMReader **reader) { FIXME("(%p, %x, %p): stub\n", reserved, rights, reader);