Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47029 Signed-off-by: Gijs Vermeulen gijsvrm@codeweavers.com --- dlls/wmp/Makefile.in | 2 +- dlls/wmp/player.c | 61 +++++++++++++++++++++++++++++++++++++----- dlls/wmp/tests/media.c | 5 ---- dlls/wmp/wmp_private.h | 1 + 4 files changed, 56 insertions(+), 13 deletions(-)
diff --git a/dlls/wmp/Makefile.in b/dlls/wmp/Makefile.in index 5ed3d42cd8..e7312cf18b 100644 --- a/dlls/wmp/Makefile.in +++ b/dlls/wmp/Makefile.in @@ -1,5 +1,5 @@ MODULE = wmp.dll -IMPORTS = oleaut32 ole32 user32 gdi32 +IMPORTS = oleaut32 ole32 user32 gdi32 urlmon shlwapi
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/wmp/player.c b/dlls/wmp/player.c index 7a1befea21..5673d0e75a 100644 --- a/dlls/wmp/player.c +++ b/dlls/wmp/player.c @@ -21,6 +21,7 @@ #include "wine/debug.h" #include <nserror.h> #include "wmpids.h" +#include "shlwapi.h"
WINE_DEFAULT_DEBUG_CHANNEL(wmp);
@@ -1730,6 +1731,7 @@ static ULONG WINAPI WMPMedia_Release(IWMPMedia *iface)
if(!ref) { heap_free(This->url); + heap_free(This->name); heap_free(This); }
@@ -1789,17 +1791,21 @@ static HRESULT WINAPI WMPMedia_get_name(IWMPMedia *iface, BSTR *name) { WMPMedia *This = impl_from_IWMPMedia(iface);
- FIXME("(%p)->(%p)\n", This, name); + TRACE("(%p)->(%p)\n", This, name);
- /* FIXME: this should be a display name */ - return return_bstr(This->url, name); + return return_bstr(This->name, name); }
-static HRESULT WINAPI WMPMedia_put_name(IWMPMedia *iface, BSTR pbstrName) +static HRESULT WINAPI WMPMedia_put_name(IWMPMedia *iface, BSTR name) { WMPMedia *This = impl_from_IWMPMedia(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(pbstrName)); - return E_NOTIMPL; + + TRACE("(%p)->(%s)\n", This, debugstr_w(name)); + + if (!name) return E_POINTER; + + This->name = heap_strdupW(name); + return S_OK; }
static HRESULT WINAPI WMPMedia_get_imageSourceWidth(IWMPMedia *iface, LONG *pWidth) @@ -2022,13 +2028,54 @@ WMPMedia *unsafe_impl_from_IWMPMedia(IWMPMedia *iface) HRESULT create_media_from_url(BSTR url, double duration, IWMPMedia **ppMedia) { WMPMedia *media; + IUri *uri; + BSTR path; + HRESULT hr; + WCHAR *name_dup, slashW[] = {'/',0};
media = heap_alloc_zero(sizeof(*media)); if (!media) return E_OUTOFMEMORY;
media->IWMPMedia_iface.lpVtbl = &WMPMediaVtbl; - media->url = url ? heap_strdupW(url) : heap_strdupW(emptyW); + + if (url) + { + media->url = heap_strdupW(url); + name_dup = heap_strdupW(url); + + hr = CreateUri(name_dup, Uri_CREATE_ALLOW_RELATIVE | Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, 0, &uri); + if (FAILED(hr)) + { + heap_free(name_dup); + return hr; + } + hr = IUri_GetPath(uri, &path); + if (hr != S_OK) + { + heap_free(name_dup); + IUri_Release(uri); + return hr; + } + + /* GetPath() will return "/" for invalid uri's + * only strip extension when uri is valid + */ + if (wcscmp(path, slashW) != 0) + PathRemoveExtensionW(name_dup); + PathStripPathW(name_dup); + + media->name = name_dup; + + SysFreeString(path); + IUri_Release(uri); + } + else + { + media->url = heap_strdupW(emptyW); + media->name = heap_strdupW(emptyW); + } + media->duration = duration; media->ref = 1;
diff --git a/dlls/wmp/tests/media.c b/dlls/wmp/tests/media.c index c190eee9fc..3d750e13b2 100644 --- a/dlls/wmp/tests/media.c +++ b/dlls/wmp/tests/media.c @@ -573,15 +573,12 @@ todo_wine SysFreeString(str); hr = IWMPMedia_get_name(media, &str); ok(hr == S_OK, "Failed to get item name, hr %#x.\n", hr); -todo_wine ok(!lstrcmpW(str, testW), "Expected %s, got %s\n", wine_dbgstr_w(testW), wine_dbgstr_w(str)); SysFreeString(str); hr = IWMPMedia_put_name(media, NULL); -todo_wine ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); hr = IWMPMedia_get_name(media, &str); ok(hr == S_OK, "Failed to get item name, hr %#x.\n", hr); -todo_wine ok(!lstrcmpW(str, testW), "Expected %s, got %s\n", wine_dbgstr_w(testW), wine_dbgstr_w(str)); SysFreeString(str);
@@ -594,7 +591,6 @@ todo_wine ok(media2 != NULL, "Unexpected media instance.\n"); hr = IWMPMedia_get_name(media2, &str); ok(hr == S_OK, "Failed to get item name, hr %#x.\n", hr); -todo_wine ok(!lstrcmpW(str, testW), "Expected %s, got %s\n", wine_dbgstr_w(testW), wine_dbgstr_w(str)); SysFreeString(str); IWMPMedia_Release(media2); @@ -615,7 +611,6 @@ todo_wine SysFreeString(str); hr = IWMPMedia_get_name(media, &str); ok(hr == S_OK, "Failed to get item name, hr %#x.\n", hr); - todo_wine ok(!lstrcmpW(str, tests[i].expected), "Expected %s, got %s\n", wine_dbgstr_w(tests[i].expected), wine_dbgstr_w(str)); SysFreeString(str); IWMPMedia_Release(media); diff --git a/dlls/wmp/wmp_private.h b/dlls/wmp/wmp_private.h index 27ec55ecc3..5149d73942 100644 --- a/dlls/wmp/wmp_private.h +++ b/dlls/wmp/wmp_private.h @@ -56,6 +56,7 @@ typedef struct { LONG ref;
WCHAR *url; + WCHAR *name;
DOUBLE duration; } WMPMedia;