/****************************************************************************** * ClassMoniker_IsEqual ******************************************************************************/ static HRESULT WINAPI ClassMoniker_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker) { CLSID clsid; LPOLESTR dispName1,dispName2; IBindCtx* bind; HRESULT res = S_FALSE; TRACE("(%p,%p)\n",iface,pmkOtherMoniker); if (!pmkOtherMoniker) return S_FALSE; /* check if both are ClassMoniker */ if(FAILED (IMoniker_GetClassID(pmkOtherMoniker,&clsid))) return S_FALSE; if(!IsEqualCLSID(&clsid,&CLSID_ClassMoniker)) return S_FALSE; /* check if both displaynames are the same */ if(SUCCEEDED ((res = CreateBindCtx(0,&bind)))) { if(SUCCEEDED (IMoniker_GetDisplayName(iface,bind,NULL,&dispName1))) { if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2))) { if(lstrcmpW(dispName1,dispName2)==0) res = S_OK; CoTaskMemFree(dispName2); } CoTaskMemFree(dispName1); } } return res; }
/*********************************************************************** * HlinkResolveMonikerForData (HLINK.@) */ HRESULT WINAPI HlinkResolveMonikerForData(LPMONIKER pimkReference, DWORD reserved, LPBC pibc, ULONG cFmtetc, FORMATETC *rgFmtetc, IBindStatusCallback *pibsc, LPMONIKER pimkBase) { LPOLESTR name = NULL; IBindCtx *bctx; DWORD mksys = 0; void *obj = NULL; HRESULT hres; TRACE("(%p %x %p %d %p %p %p)\n", pimkReference, reserved, pibc, cFmtetc, rgFmtetc, pibsc, pimkBase); if(cFmtetc || rgFmtetc || pimkBase) FIXME("Unsupported args\n"); hres = RegisterBindStatusCallback(pibc, pibsc, NULL /* FIXME */, 0); if(FAILED(hres)) return hres; hres = IMoniker_IsSystemMoniker(pimkReference, &mksys); if(SUCCEEDED(hres) && mksys != MKSYS_URLMONIKER) WARN("sysmk = %x\n", mksys); /* FIXME: What is it for? */ CreateBindCtx(0, &bctx); hres = IMoniker_GetDisplayName(pimkReference, bctx, NULL, &name); IBindCtx_Release(bctx); if(SUCCEEDED(hres)) { TRACE("got display name %s\n", debugstr_w(name)); CoTaskMemFree(name); } return IMoniker_BindToStorage(pimkReference, pibc, NULL, &IID_IUnknown, &obj); }
static HRESULT WINAPI XMLView_Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName) { Moniker *This = impl_from_IMoniker(iface); TRACE("(%p)->(%p %p %p)\n", This, pbc, pmkToLeft, ppszDisplayName); return IMoniker_GetDisplayName(This->mon, pbc, pmkToLeft, ppszDisplayName); }
void set_current_mon(HTMLWindow *This, IMoniker *mon) { HRESULT hres; if(This->mon) { IMoniker_Release(This->mon); This->mon = NULL; } if(This->url) { CoTaskMemFree(This->url); This->url = NULL; } if(!mon) return; IMoniker_AddRef(mon); This->mon = mon; hres = IMoniker_GetDisplayName(mon, NULL, NULL, &This->url); if(FAILED(hres)) WARN("GetDisplayName failed: %08x\n", hres); set_script_mode(This, use_gecko_script(This->url) ? SCRIPTMODE_GECKO : SCRIPTMODE_ACTIVESCRIPT); }
static HRESULT WINAPI URLMoniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker) { URLMoniker *This = impl_from_IMoniker(iface); CLSID clsid; LPOLESTR urlPath; IBindCtx* bind; HRESULT res; TRACE("(%p,%p)\n",This, pmkOtherMoniker); if(pmkOtherMoniker==NULL) return E_INVALIDARG; IMoniker_GetClassID(pmkOtherMoniker,&clsid); if(!IsEqualCLSID(&clsid,&CLSID_StdURLMoniker)) return S_FALSE; res = CreateBindCtx(0,&bind); if(FAILED(res)) return res; res = S_FALSE; if(SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&urlPath))) { int result = lstrcmpiW(urlPath, This->URLName); CoTaskMemFree(urlPath); if(result == 0) res = S_OK; } IBindCtx_Release(bind); return res; }
/*********************************************************************** * CreateURLMonikerEx (URLMON.@) * * Create a url moniker. * * PARAMS * pmkContext [I] Context * szURL [I] Url to create the moniker for * ppmk [O] Destination for created moniker. * dwFlags [I] Flags. * * RETURNS * Success: S_OK. ppmk contains the created IMoniker object. * Failure: MK_E_SYNTAX if szURL is not a valid url, or * E_OUTOFMEMORY if memory allocation fails. */ HRESULT WINAPI CreateURLMonikerEx(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk, DWORD dwFlags) { URLMonikerImpl *obj; HRESULT hres; LPOLESTR lefturl = NULL; TRACE("(%p, %s, %p, %08x)\n", pmkContext, debugstr_w(szURL), ppmk, dwFlags); if (dwFlags & URL_MK_UNIFORM) FIXME("ignoring flag URL_MK_UNIFORM\n"); if(!(obj = heap_alloc(sizeof(*obj)))) return E_OUTOFMEMORY; if(pmkContext) { IBindCtx* bind; DWORD dwMksys = 0; IMoniker_IsSystemMoniker(pmkContext, &dwMksys); if(dwMksys == MKSYS_URLMONIKER && SUCCEEDED(CreateBindCtx(0, &bind))) { IMoniker_GetDisplayName(pmkContext, bind, NULL, &lefturl); TRACE("lefturl = %s\n", debugstr_w(lefturl)); IBindCtx_Release(bind); } } hres = URLMonikerImpl_Construct(obj, lefturl, szURL); CoTaskMemFree(lefturl); if(SUCCEEDED(hres)) hres = URLMonikerImpl_QueryInterface((IMoniker*)obj, &IID_IMoniker, (void**)ppmk); else heap_free(obj); return hres; }
static HRESULT WINAPI IHlink_fnGetFriendlyName (IHlink* iface, DWORD grfHLFNAMEF, LPWSTR* ppwzFriendlyName) { HlinkImpl *This = impl_from_IHlink(iface); TRACE("(%p) -> (%i %p)\n", This, grfHLFNAMEF, ppwzFriendlyName); /* FIXME: Only using explicitly set and cached friendly names */ if (This->FriendlyName) *ppwzFriendlyName = hlink_co_strdupW( This->FriendlyName ); else { IMoniker *moniker; HRESULT hres = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT); if (FAILED(hres)) { *ppwzFriendlyName = NULL; return hres; } if (moniker) { IBindCtx *bcxt; CreateBindCtx(0, &bcxt); IMoniker_GetDisplayName(moniker, bcxt, NULL, ppwzFriendlyName); IBindCtx_Release(bcxt); IMoniker_Release(moniker); } else *ppwzFriendlyName = NULL; } return S_OK; }
/****************************************************************************** * FileMoniker_IsEqual */ static HRESULT WINAPI FileMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker) { FileMonikerImpl *This = impl_from_IMoniker(iface); CLSID clsid; LPOLESTR filePath; IBindCtx* bind; HRESULT res; TRACE("(%p,%p)\n",iface,pmkOtherMoniker); if (pmkOtherMoniker==NULL) return S_FALSE; IMoniker_GetClassID(pmkOtherMoniker,&clsid); if (!IsEqualCLSID(&clsid,&CLSID_FileMoniker)) return S_FALSE; res = CreateBindCtx(0,&bind); if (FAILED(res)) return res; res = S_FALSE; if (SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath))) { if (!lstrcmpiW(filePath, This->filePathName)) res = S_OK; CoTaskMemFree(filePath); } IBindCtx_Release(bind); return res; }
void set_current_mon(HTMLOuterWindow *This, IMoniker *mon, DWORD flags) { IUriContainer *uri_container; IUri *uri = NULL; HRESULT hres; if(This->mon) { if(This->doc_obj && !(flags & (BINDING_REPLACE|BINDING_REFRESH))) { if(This == This->doc_obj->basedoc.window) notify_travellog_update(This->doc_obj); else TRACE("Skipping travellog update for frame navigation.\n"); } IMoniker_Release(This->mon); This->mon = NULL; } This->load_flags = flags; if(!mon) return; IMoniker_AddRef(mon); This->mon = mon; hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container); if(SUCCEEDED(hres)) { hres = IUriContainer_GetIUri(uri_container, &uri); IUriContainer_Release(uri_container); if(hres != S_OK) { WARN("GetIUri failed: %08x\n", hres); uri = NULL; } } if(!uri) { WCHAR *url; hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url); if(SUCCEEDED(hres)) { hres = create_uri(url, 0, &uri); if(FAILED(hres)) { WARN("CrateUri failed: %08x\n", hres); set_current_uri(This, NULL); This->url = SysAllocString(url); CoTaskMemFree(url); return; } CoTaskMemFree(url); }else { WARN("GetDisplayName failed: %08x\n", hres); } } set_current_uri(This, uri); if(uri) IUri_Release(uri); set_script_mode(This, use_gecko_script(This) ? SCRIPTMODE_GECKO : SCRIPTMODE_ACTIVESCRIPT); }
static NTSTATUS EnumRunningObjectTable( _In_ PVOID ThreadParam ) { IRunningObjectTable* iRunningObjectTable = NULL; IEnumMoniker* iEnumMoniker = NULL; IMoniker* iMoniker = NULL; IBindCtx* iBindCtx = NULL; IMalloc* iMalloc = NULL; ULONG count = 0; HWND listViewHandle = (HWND)ThreadParam; if (!SUCCEEDED(CoGetMalloc(1, &iMalloc))) return STATUS_INSUFFICIENT_RESOURCES; // Query the running object table address if (SUCCEEDED(GetRunningObjectTable(0, &iRunningObjectTable))) { // Enum the objects registered if (SUCCEEDED(IRunningObjectTable_EnumRunning(iRunningObjectTable, &iEnumMoniker))) { while (IEnumMoniker_Next(iEnumMoniker, 1, &iMoniker, &count) == S_OK) { if (SUCCEEDED(CreateBindCtx(0, &iBindCtx))) { OLECHAR* displayName = NULL; // Query the object name if (SUCCEEDED(IMoniker_GetDisplayName(iMoniker, iBindCtx, NULL, &displayName))) { // Set the items name column PhAddListViewItem(listViewHandle, MAXINT, displayName, NULL); // Free the object name IMalloc_Free(iMalloc, displayName); } IBindCtx_Release(iBindCtx); } IEnumMoniker_Release(iMoniker); } IEnumMoniker_Release(iEnumMoniker); } IRunningObjectTable_Release(iRunningObjectTable); } IMalloc_Release(iMalloc); return STATUS_SUCCESS; }
void set_current_mon(HTMLOuterWindow *This, IMoniker *mon) { IUriContainer *uri_container; IUri *uri = NULL; HRESULT hres; if(This->mon) { if(This->doc_obj) notify_travellog_update(This->doc_obj); IMoniker_Release(This->mon); This->mon = NULL; } if(!mon) return; IMoniker_AddRef(mon); This->mon = mon; hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container); if(SUCCEEDED(hres)) { hres = IUriContainer_GetIUri(uri_container, &uri); IUriContainer_Release(uri_container); if(hres != S_OK) { WARN("GetIUri failed: %08x\n", hres); uri = NULL; } } if(!uri) { WCHAR *url; hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url); if(SUCCEEDED(hres)) { hres = CreateUri(url, 0, 0, &uri); if(FAILED(hres)) { WARN("CrateUri failed: %08x\n", hres); set_current_uri(This, NULL); This->url = SysAllocString(url); CoTaskMemFree(url); return; } CoTaskMemFree(url); }else { WARN("GetDisplayName failed: %08x\n", hres); } } set_current_uri(This, uri); if(uri) IUri_Release(uri); set_script_mode(This, use_gecko_script(This) ? SCRIPTMODE_GECKO : SCRIPTMODE_ACTIVESCRIPT); }
static HRESULT navigate_hlink(DocHost *This, IMoniker *mon, IBindCtx *bindctx, IBindStatusCallback *callback) { IHttpNegotiate *http_negotiate; BindStatusCallback *bsc; PBYTE post_data = NULL; ULONG post_data_len = 0; LPWSTR headers = NULL, url; BINDINFO bindinfo; DWORD bindf = 0; HRESULT hres; TRACE("\n"); hres = IMoniker_GetDisplayName(mon, 0, NULL, &url); if(FAILED(hres)) FIXME("GetDisplayName failed: %08x\n", hres); hres = IBindStatusCallback_QueryInterface(callback, &IID_IHttpNegotiate, (void**)&http_negotiate); if(SUCCEEDED(hres)) { static const WCHAR null_string[] = {0}; IHttpNegotiate_BeginningTransaction(http_negotiate, null_string, null_string, 0, &headers); IHttpNegotiate_Release(http_negotiate); } memset(&bindinfo, 0, sizeof(bindinfo)); bindinfo.cbSize = sizeof(bindinfo); hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo); dump_BINDINFO(&bindinfo); if(bindinfo.dwBindVerb == BINDVERB_POST) { post_data_len = bindinfo.cbstgmedData; if(post_data_len) post_data = bindinfo.stgmedData.u.hGlobal; } if(This->doc_navigate) { hres = async_doc_navigate(This, url, headers, post_data, post_data_len, FALSE); }else { bsc = create_callback(This, url, post_data, post_data_len, headers); hres = navigate_bsc(This, bsc, mon); IBindStatusCallback_Release(&bsc->IBindStatusCallback_iface); } CoTaskMemFree(url); CoTaskMemFree(headers); ReleaseBindInfo(&bindinfo); return hres; }
static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCtx *bindctx, IBindStatusCallback *callback) { WCHAR schema[30]; DWORD schema_len; HRESULT hres; static const WCHAR httpW[] = {'h','t','t','p',0}; static const WCHAR httpsW[] = {'h','t','t','p','s',0}; static const WCHAR ftpW[]= {'f','t','p',0}; if(mon) { IMoniker_AddRef(mon); }else { hres = create_moniker(url, &mon); if(FAILED(hres)) return hres; } CoTaskMemFree(This->url); hres = IMoniker_GetDisplayName(mon, 0, NULL, &This->url); if(FAILED(hres)) FIXME("GetDisplayName failed: %08x\n", hres); IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, (IUnknown*)CLIENTSITE(This)); hres = CoInternetParseUrl(This->url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]), &schema_len, 0); if(SUCCEEDED(hres) && (!strcmpW(schema, httpW) || !strcmpW(schema, httpsW) || !strcmpW(schema, ftpW))) { hres = http_load_hack(This, mon, callback, bindctx); }else { IUnknown *unk = NULL; hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk); if(SUCCEEDED(hres)) { hres = S_OK; if(unk) IUnknown_Release(unk); }else if(try_application_url(url)) { hres = S_OK; }else { FIXME("BindToObject failed: %08x\n", hres); } } IMoniker_Release(mon); return S_OK; }
/****************************************************************************** * FileMoniker_BindToStorage */ static HRESULT WINAPI FileMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvObject) { LPOLESTR filePath=0; IStorage *pstg=0; HRESULT res; TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvObject); if (pmkToLeft==NULL){ if (IsEqualIID(&IID_IStorage, riid)){ /* get the file name */ IMoniker_GetDisplayName(iface,pbc,pmkToLeft,&filePath); /* verify if the file contains a storage object */ res=StgIsStorageFile(filePath); if(res==S_OK){ res=StgOpenStorage(filePath,NULL,STGM_READWRITE|STGM_SHARE_DENY_WRITE,NULL,0,&pstg); if (SUCCEEDED(res)){ *ppvObject=pstg; IStorage_AddRef(pstg); return res; } } CoTaskMemFree(filePath); } else if ( (IsEqualIID(&IID_IStream, riid)) || (IsEqualIID(&IID_ILockBytes, riid)) ) return E_FAIL; else return E_NOINTERFACE; } else { FIXME("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvObject); return E_NOTIMPL; } return res; }
static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener *iface, nsIURI *aURI, PRBool *_retval) { NSContainer *This = NSURICL_THIS(iface); nsIWineURI *wine_uri; nsACString spec_str; const char *spec; nsresult nsres; nsACString_Init(&spec_str, NULL); nsIURI_GetSpec(aURI, &spec_str); nsACString_GetData(&spec_str, &spec, NULL); TRACE("(%p)->(%p(%s) %p)\n", This, aURI, debugstr_a(spec), _retval); nsACString_Finish(&spec_str); nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri); if(NS_FAILED(nsres)) { WARN("Could not get nsIWineURI interface: %08lx\n", nsres); return NS_ERROR_NOT_IMPLEMENTED; } nsIWineURI_SetNSContainer(wine_uri, This); if(This->bscallback && This->bscallback->mon) { LPWSTR url; HRESULT hres; hres = IMoniker_GetDisplayName(This->bscallback->mon, NULL, 0, &url); if(SUCCEEDED(hres)) { IMoniker *mon = NULL; hres = CreateURLMoniker(NULL, url, &mon); if(SUCCEEDED(hres)) { nsIWineURI_SetMoniker(wine_uri, mon); IMoniker_Release(mon); }else { WARN("CreateURLMoniker failed: %08lx\n", hres); } }else { WARN("GetDisplayName failed: %08lx\n", hres); } } nsIWineURI_Release(wine_uri); return NS_ERROR_NOT_IMPLEMENTED; }
static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface, DWORD dwWhichRef, LPWSTR *ppwzTarget, LPWSTR *ppwzLocation) { HlinkImpl *This = impl_from_IHlink(iface); TRACE("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation); if(dwWhichRef != -1 && dwWhichRef & ~(HLINKGETREF_DEFAULT | HLINKGETREF_ABSOLUTE | HLINKGETREF_RELATIVE)) { if(ppwzTarget) *ppwzTarget = NULL; if(ppwzLocation) *ppwzLocation = NULL; return E_INVALIDARG; } if (ppwzTarget) { IMoniker* mon; HRESULT hres = __GetMoniker(This, &mon, dwWhichRef); if (FAILED(hres)) { if (ppwzLocation) *ppwzLocation = NULL; return hres; } if (mon) { IBindCtx *pbc; CreateBindCtx( 0, &pbc); IMoniker_GetDisplayName(mon, pbc, NULL, ppwzTarget); IBindCtx_Release(pbc); IMoniker_Release(mon); } else *ppwzTarget = NULL; } if (ppwzLocation) *ppwzLocation = hlink_co_strdupW( This->Location ); TRACE("(Target: %s Location: %s)\n", (ppwzTarget)?debugstr_w(*ppwzTarget):"<NULL>", (ppwzLocation)?debugstr_w(*ppwzLocation):"<NULL>"); return S_OK; }
/*********************************************************************** * HlinkSimpleNavigateToMoniker (URLMON.@) */ HRESULT WINAPI HlinkSimpleNavigateToMoniker(IMoniker *pmkTarget, LPCWSTR szLocation, LPCWSTR szTargetFrameName, IUnknown *pUnk, IBindCtx *pbc, IBindStatusCallback *pbsc, DWORD grfHLNF, DWORD dwReserved) { LPWSTR target; HRESULT hres; TRACE("\n"); hres = IMoniker_GetDisplayName(pmkTarget, pbc, 0, &target); if(hres == S_OK) hres = HlinkSimpleNavigateToString( target, szLocation, szTargetFrameName, pUnk, pbc, pbsc, grfHLNF, dwReserved ); CoTaskMemFree(target); return hres; }
static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCtx *bindctx, IBindStatusCallback *callback) { IUnknown *unk = NULL; WCHAR *display_name; HRESULT hres; if(mon) { IMoniker_AddRef(mon); }else { hres = create_moniker(url, &mon); if(FAILED(hres)) return hres; } hres = IMoniker_GetDisplayName(mon, 0, NULL, &display_name); if(FAILED(hres)) { FIXME("GetDisplayName failed: %08x\n", hres); return hres; } hres = set_dochost_url(This, display_name); CoTaskMemFree(display_name); if(FAILED(hres)) return hres; IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, (IUnknown*)&This->IOleClientSite_iface); hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk); if(SUCCEEDED(hres)) { hres = S_OK; if(unk) IUnknown_Release(unk); }else if(try_application_url(url)) { hres = S_OK; }else { FIXME("BindToObject failed: %08x\n", hres); } IMoniker_Release(mon); return S_OK; }
/****************************************************************************** * ItemMoniker_ParseDisplayName ******************************************************************************/ static HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut) { ItemMonikerImpl *This = impl_from_IMoniker(iface); IOleItemContainer* poic=0; IParseDisplayName* ppdn=0; LPOLESTR displayName; HRESULT res; TRACE("%s\n", debugstr_w(pszDisplayName)); /* If pmkToLeft is NULL, this method returns MK_E_SYNTAX */ if (pmkToLeft==NULL) return MK_E_SYNTAX; else{ /* Otherwise, the method calls IMoniker::BindToObject on the pmkToLeft parameter, requesting an */ /* IParseDisplayName interface pointer to the object identified by the moniker, and passes the display */ /* name to IParseDisplayName::ParseDisplayName */ res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); if (SUCCEEDED(res)){ res=IOleItemContainer_GetObject(poic,This->itemName,BINDSPEED_MODERATE,pbc,&IID_IParseDisplayName,(void**)&ppdn); res=IMoniker_GetDisplayName(iface,pbc,NULL,&displayName); res=IParseDisplayName_ParseDisplayName(ppdn,pbc,displayName,pchEaten,ppmkOut); IOleItemContainer_Release(poic); IParseDisplayName_Release(ppdn); } } return res; }
static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface, DWORD rfHLSETF, IMoniker *pmkTarget, LPCWSTR pwzLocation) { HlinkImpl *This = impl_from_IHlink(iface); TRACE("(%p)->(%i %p %s)\n", This, rfHLSETF, pmkTarget, debugstr_w(pwzLocation)); if(rfHLSETF == 0) return E_INVALIDARG; if(!(rfHLSETF & (HLINKSETF_TARGET | HLINKSETF_LOCATION))) return rfHLSETF; if(rfHLSETF & HLINKSETF_TARGET){ if (This->Moniker) IMoniker_Release(This->Moniker); This->Moniker = pmkTarget; if (This->Moniker) { IBindCtx *pbc; LPOLESTR display_name; IMoniker_AddRef(This->Moniker); CreateBindCtx( 0, &pbc); IMoniker_GetDisplayName(This->Moniker, pbc, NULL, &display_name); IBindCtx_Release(pbc); This->absolute = display_name && strchrW(display_name, ':'); CoTaskMemFree(display_name); } } if(rfHLSETF & HLINKSETF_LOCATION){ heap_free(This->Location); This->Location = hlink_strdupW( pwzLocation ); } return S_OK; }
HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download) { nsChannelBSC *bscallback; docobj_task_t *task; download_proc_task_t *download_task; nsWineURI *nsuri; LPOLESTR url; HRESULT hres; hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url); if(FAILED(hres)) { WARN("GetDiaplayName failed: %08x\n", hres); return hres; } TRACE("got url: %s\n", debugstr_w(url)); if(This->doc_obj->client) { VARIANT silent, offline; hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent); if(SUCCEEDED(hres)) { if(V_VT(&silent) != VT_BOOL) WARN("V_VT(silent) = %d\n", V_VT(&silent)); else if(V_BOOL(&silent)) FIXME("silent == true\n"); } hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline); if(SUCCEEDED(hres)) { if(V_VT(&offline) != VT_BOOL) WARN("V_VT(offline) = %d\n", V_VT(&offline)); else if(V_BOOL(&offline)) FIXME("offline == true\n"); } } if(This->window->mon) { update_doc(This, UPDATE_TITLE|UPDATE_UI); }else { update_doc(This, UPDATE_TITLE); set_current_mon(This->window, mon); } set_ready_state(This->window, READYSTATE_LOADING); if(This->doc_obj->client) { IOleCommandTarget *cmdtrg = NULL; hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget, (void**)&cmdtrg); if(SUCCEEDED(hres)) { VARIANT var, out; if(!async_bsc) { V_VT(&var) = VT_I4; V_I4(&var) = 0; IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL); }else { V_VT(&var) = VT_UNKNOWN; V_UNKNOWN(&var) = (IUnknown*)&This->window->IHTMLWindow2_iface; V_VT(&out) = VT_EMPTY; hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 63, 0, &var, &out); if(SUCCEEDED(hres)) VariantClear(&out); } IOleCommandTarget_Release(cmdtrg); } } hres = create_doc_uri(This->window, url, &nsuri); if(SUCCEEDED(hres)) { if(async_bsc) { bscallback = async_bsc; }else { hres = create_channelbsc(mon, NULL, NULL, 0, &bscallback); } } if(SUCCEEDED(hres)) { remove_target_tasks(This->task_magic); abort_document_bindings(This->doc_node); hres = load_nsuri(This->window, nsuri, bscallback, LOAD_INITIAL_DOCUMENT_URI); nsISupports_Release((nsISupports*)nsuri); /* FIXME */ if(SUCCEEDED(hres)) set_window_bscallback(This->window, bscallback); if(bscallback != async_bsc) IUnknown_Release((IUnknown*)bscallback); } if(FAILED(hres)) { CoTaskMemFree(url); return hres; } HTMLDocument_LockContainer(This->doc_obj, TRUE); if(This->doc_obj->frame) { task = heap_alloc(sizeof(docobj_task_t)); task->doc = This->doc_obj; push_task(&task->header, set_progress_proc, This->doc_obj->basedoc.task_magic); } download_task = heap_alloc(sizeof(download_proc_task_t)); download_task->doc = This->doc_obj; download_task->set_download = set_download; download_task->url = url; push_task(&download_task->header, set_downloading_proc, This->doc_obj->basedoc.task_magic); return S_OK; }
static void test_HlinkParseDisplayName(void) { IMoniker *mon = NULL; LPWSTR name; DWORD issys; ULONG eaten = 0; IBindCtx *bctx; HRESULT hres; static const WCHAR winehq_urlW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g', '/','s','i','t','e','/','a','b','o','u','t',0 }; static const WCHAR invalid_urlW[] = {'t','e','s','t',':','1','2','3','a','b','c',0}; static const WCHAR clsid_nameW[] = {'c','l','s','i','d',':', '2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8', '-','0','8','0','0','2','B','3','0','3','0','9','D',':',0 }; CreateBindCtx(0, &bctx); hres = HlinkParseDisplayName(bctx, winehq_urlW, FALSE, &eaten, &mon); ok(hres == S_OK, "HlinkParseDisplayName failed: %08x\n", hres); ok(eaten == sizeof(winehq_urlW)/sizeof(WCHAR)-1, "eaten=%d\n", eaten); ok(mon != NULL, "mon == NULL\n"); hres = IMoniker_GetDisplayName(mon, bctx, 0, &name); ok(hres == S_OK, "GetDiasplayName failed: %08x\n", hres); ok(!lstrcmpW(name, winehq_urlW), "wrong display name %s\n", debugstr_w(name)); CoTaskMemFree(name); hres = IMoniker_IsSystemMoniker(mon, &issys); ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres); ok(issys == MKSYS_URLMONIKER, "issys=%x\n", issys); IMoniker_Release(mon); hres = HlinkParseDisplayName(bctx, clsid_nameW, FALSE, &eaten, &mon); ok(hres == S_OK, "HlinkParseDisplayName failed: %08x\n", hres); ok(eaten == sizeof(clsid_nameW)/sizeof(WCHAR)-1, "eaten=%d\n", eaten); ok(mon != NULL, "mon == NULL\n"); hres = IMoniker_IsSystemMoniker(mon, &issys); ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres); ok(issys == MKSYS_CLASSMONIKER, "issys=%x\n", issys); IMoniker_Release(mon); hres = HlinkParseDisplayName(bctx, invalid_urlW, FALSE, &eaten, &mon); ok(hres == S_OK, "HlinkParseDisplayName failed: %08x\n", hres); ok(eaten == sizeof(invalid_urlW)/sizeof(WCHAR)-1, "eaten=%d\n", eaten); ok(mon != NULL, "mon == NULL\n"); hres = IMoniker_GetDisplayName(mon, bctx, 0, &name); ok(hres == S_OK, "GetDiasplayName failed: %08x\n", hres); ok(!lstrcmpW(name, invalid_urlW), "wrong display name %s\n", debugstr_w(name)); CoTaskMemFree(name); hres = IMoniker_IsSystemMoniker(mon, &issys); ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres); ok(issys == MKSYS_FILEMONIKER, "issys=%x\n", issys); IBindCtx_Release(bctx); }
/****************************************************************************** * FileMoniker_ComposeWith */ static HRESULT WINAPI FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight, BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite) { HRESULT res; LPOLESTR str1=0,str2=0,*strDec1=0,*strDec2=0,newStr=0; static const WCHAR twoPoint[]={'.','.',0}; static const WCHAR bkSlash[]={'\\',0}; IBindCtx *bind=0; int i=0,j=0,lastIdx1=0,lastIdx2=0; DWORD mkSys; TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite); if (ppmkComposite==NULL) return E_POINTER; if (pmkRight==NULL) return E_INVALIDARG; *ppmkComposite=0; IMoniker_IsSystemMoniker(pmkRight,&mkSys); /* check if we have two FileMonikers to compose or not */ if(mkSys==MKSYS_FILEMONIKER){ CreateBindCtx(0,&bind); IMoniker_GetDisplayName(iface,bind,NULL,&str1); IMoniker_GetDisplayName(pmkRight,bind,NULL,&str2); /* decompose pathnames of the two monikers : (to prepare the path merge operation ) */ lastIdx1=FileMonikerImpl_DecomposePath(str1,&strDec1)-1; lastIdx2=FileMonikerImpl_DecomposePath(str2,&strDec2)-1; if ((lastIdx1==-1 && lastIdx2>-1)||(lastIdx1==1 && lstrcmpW(strDec1[0],twoPoint)==0)) return MK_E_SYNTAX; if(lstrcmpW(strDec1[lastIdx1],bkSlash)==0) lastIdx1--; /* for etch "..\" in the left of str2 remove the right element from str1 */ for(i=0; ( (lastIdx1>=0) && (strDec2[i]!=NULL) && (lstrcmpW(strDec2[i],twoPoint)==0) ) ;i+=2){ lastIdx1-=2; } /* the length of the composed path string is raised by the sum of the two paths lengths */ newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1)); if (newStr) { /* new path is the concatenation of the rest of str1 and str2 */ for(*newStr=0,j=0;j<=lastIdx1;j++) strcatW(newStr,strDec1[j]); if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0) strcatW(newStr,bkSlash); for(j=i;j<=lastIdx2;j++) strcatW(newStr,strDec2[j]); /* create a new moniker with the new string */ res=CreateFileMoniker(newStr,ppmkComposite); /* free all strings space memory used by this function */ HeapFree(GetProcessHeap(),0,newStr); } else res = E_OUTOFMEMORY; free_stringtable(strDec1); free_stringtable(strDec2); CoTaskMemFree(str1); CoTaskMemFree(str2); return res; } else if(mkSys==MKSYS_ANTIMONIKER){ *ppmkComposite=NULL; return S_OK; } else if (fOnlyIfNotGeneric){ *ppmkComposite=NULL; return MK_E_NEEDGENERIC; } else return CreateGenericComposite(iface,pmkRight,ppmkComposite); }
/** * Cycle through available devices using the device enumerator devenum, * retrieve the device with type specified by devtype and return the * pointer to the object found in *pfilter. * If pfilter is NULL, list all device names. */ static int dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, enum dshowDeviceType devtype, enum dshowSourceFilterType sourcetype, IBaseFilter **pfilter) { struct dshow_ctx *ctx = avctx->priv_data; IBaseFilter *device_filter = NULL; IEnumMoniker *classenum = NULL; IMoniker *m = NULL; const char *device_name = ctx->device_name[devtype]; int skip = (devtype == VideoDevice) ? ctx->video_device_number : ctx->audio_device_number; int r; const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory, &CLSID_AudioInputDeviceCategory }; const char *devtypename = (devtype == VideoDevice) ? "video" : "audio only"; const char *sourcetypename = (sourcetype == VideoSourceDevice) ? "video" : "audio"; r = ICreateDevEnum_CreateClassEnumerator(devenum, device_guid[sourcetype], (IEnumMoniker **) &classenum, 0); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not enumerate %s devices (or none found).\n", devtypename); return AVERROR(EIO); } while (!device_filter && IEnumMoniker_Next(classenum, 1, &m, NULL) == S_OK) { IPropertyBag *bag = NULL; char *friendly_name = NULL; char *unique_name = NULL; VARIANT var; IBindCtx *bind_ctx = NULL; LPOLESTR olestr = NULL; LPMALLOC co_malloc = NULL; int i; r = CoGetMalloc(1, &co_malloc); if (r != S_OK) goto fail1; r = CreateBindCtx(0, &bind_ctx); if (r != S_OK) goto fail1; /* GetDisplayname works for both video and audio, DevicePath doesn't */ r = IMoniker_GetDisplayName(m, bind_ctx, NULL, &olestr); if (r != S_OK) goto fail1; unique_name = dup_wchar_to_utf8(olestr); /* replace ':' with '_' since we use : to delineate between sources */ for (i = 0; i < strlen(unique_name); i++) { if (unique_name[i] == ':') unique_name[i] = '_'; } r = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (void *) &bag); if (r != S_OK) goto fail1; var.vt = VT_BSTR; r = IPropertyBag_Read(bag, L"FriendlyName", &var, NULL); if (r != S_OK) goto fail1; friendly_name = dup_wchar_to_utf8(var.bstrVal); if (pfilter) { if (strcmp(device_name, friendly_name) && strcmp(device_name, unique_name)) goto fail1; if (!skip--) { r = IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Unable to BindToObject for %s\n", device_name); goto fail1; } } } else { av_log(avctx, AV_LOG_INFO, " \"%s\"\n", friendly_name); av_log(avctx, AV_LOG_INFO, " Alternative name \"%s\"\n", unique_name); } fail1: if (olestr && co_malloc) IMalloc_Free(co_malloc, olestr); if (bind_ctx) IBindCtx_Release(bind_ctx); av_free(friendly_name); av_free(unique_name); if (bag) IPropertyBag_Release(bag); IMoniker_Release(m); } IEnumMoniker_Release(classenum); if (pfilter) { if (!device_filter) { av_log(avctx, AV_LOG_ERROR, "Could not find %s device with name [%s] among source devices of type %s.\n", devtypename, device_name, sourcetypename); return AVERROR(EIO); } *pfilter = device_filter; } return 0; }
HRESULT set_moniker(HTMLOuterWindow *window, IMoniker *mon, IUri *nav_uri, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download) { download_proc_task_t *download_task; HTMLDocumentObj *doc_obj = NULL; nsChannelBSC *bscallback; nsWineURI *nsuri; LPOLESTR url; IUri *uri; HRESULT hres; if(window->doc_obj && window->doc_obj->basedoc.window == window) doc_obj = window->doc_obj; hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url); if(FAILED(hres)) { WARN("GetDiaplayName failed: %08x\n", hres); return hres; } if(nav_uri) { uri = nav_uri; }else { hres = create_uri(url, 0, &uri); if(FAILED(hres)) { CoTaskMemFree(url); return hres; } } TRACE("got url: %s\n", debugstr_w(url)); set_ready_state(window, READYSTATE_LOADING); hres = create_doc_uri(window, uri, &nsuri); if(!nav_uri) IUri_Release(uri); if(SUCCEEDED(hres)) { if(async_bsc) bscallback = async_bsc; else hres = create_channelbsc(mon, NULL, NULL, 0, TRUE, &bscallback); } if(SUCCEEDED(hres)) { if(window->base.inner_window->doc) remove_target_tasks(window->base.inner_window->task_magic); abort_window_bindings(window->base.inner_window); hres = load_nsuri(window, nsuri, bscallback, LOAD_FLAGS_BYPASS_CACHE); nsISupports_Release((nsISupports*)nsuri); /* FIXME */ if(SUCCEEDED(hres)) { hres = create_pending_window(window, bscallback); TRACE("pending window for %p %p %p\n", window, bscallback, window->pending_window); } if(bscallback != async_bsc) IBindStatusCallback_Release(&bscallback->bsc.IBindStatusCallback_iface); } if(FAILED(hres)) { CoTaskMemFree(url); return hres; } if(doc_obj) { HTMLDocument_LockContainer(doc_obj, TRUE); if(doc_obj->frame) { docobj_task_t *task; task = heap_alloc(sizeof(docobj_task_t)); task->doc = doc_obj; hres = push_task(&task->header, set_progress_proc, NULL, doc_obj->basedoc.task_magic); if(FAILED(hres)) { CoTaskMemFree(url); return hres; } } download_task = heap_alloc(sizeof(download_proc_task_t)); download_task->doc = doc_obj; download_task->set_download = set_download; download_task->url = url; return push_task(&download_task->header, set_downloading_proc, set_downloading_task_destr, doc_obj->basedoc.task_magic); } return S_OK; }
/****************************************************************************** * FileMoniker_CommonPrefixWith */ static HRESULT WINAPI FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix) { LPOLESTR pathThis = NULL, pathOther = NULL, *stringTable1 = NULL; LPOLESTR *stringTable2 = NULL, commonPath = NULL; IBindCtx *bindctx; DWORD mkSys; ULONG nb1,nb2,i,sameIdx; BOOL machineNameCase = FALSE; HRESULT ret; if (ppmkPrefix==NULL) return E_POINTER; if (pmkOther==NULL) return E_INVALIDARG; *ppmkPrefix=0; /* check if we have the same type of moniker */ IMoniker_IsSystemMoniker(pmkOther,&mkSys); if (mkSys != MKSYS_FILEMONIKER) return MonikerCommonPrefixWith(iface, pmkOther, ppmkPrefix); ret = CreateBindCtx(0, &bindctx); if (FAILED(ret)) return ret; /* create a string based on common part of the two paths */ ret = IMoniker_GetDisplayName(iface, bindctx, NULL, &pathThis); if (FAILED(ret)) goto failed; ret = IMoniker_GetDisplayName(pmkOther, bindctx, NULL, &pathOther); if (FAILED(ret)) goto failed; nb1 = FileMonikerImpl_DecomposePath(pathThis, &stringTable1); if (FAILED(nb1)) { ret = nb1; goto failed; } nb2 = FileMonikerImpl_DecomposePath(pathOther, &stringTable2); if (FAILED(nb2)) { ret = nb2; goto failed; } if (nb1 == 0 || nb2 == 0) { ret = MK_E_NOPREFIX; goto failed; } commonPath = CoTaskMemAlloc(sizeof(WCHAR)*(min(lstrlenW(pathThis),lstrlenW(pathOther))+1)); if (!commonPath) { ret = E_OUTOFMEMORY; goto failed; } *commonPath = 0; for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) && (stringTable2[sameIdx]!=NULL) && (lstrcmpiW(stringTable1[sameIdx],stringTable2[sameIdx])==0)); sameIdx++); if (sameIdx > 1 && *stringTable1[0]=='\\' && *stringTable2[1]=='\\'){ machineNameCase = TRUE; for(i=2;i<sameIdx;i++) if( (*stringTable1[i]=='\\') && (i+1 < sameIdx) && (*stringTable1[i+1]=='\\') ){ machineNameCase = FALSE; break; } } if (machineNameCase && *stringTable1[sameIdx-1]=='\\') sameIdx--; if (machineNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) ) ret = MK_E_NOPREFIX; else { for (i = 0; i < sameIdx; i++) strcatW(commonPath,stringTable1[i]); ret = CreateFileMoniker(commonPath, ppmkPrefix); } failed: IBindCtx_Release(bindctx); CoTaskMemFree(pathThis); CoTaskMemFree(pathOther); CoTaskMemFree(commonPath); if (stringTable1) free_stringtable(stringTable1); if (stringTable2) free_stringtable(stringTable2); return ret; }
HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download) { download_proc_task_t *download_task; nsChannelBSC *bscallback; nsWineURI *nsuri; LPOLESTR url; HRESULT hres; hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url); if(FAILED(hres)) { WARN("GetDiaplayName failed: %08x\n", hres); return hres; } TRACE("got url: %s\n", debugstr_w(url)); set_ready_state(This->window, READYSTATE_LOADING); hres = create_doc_uri(This->window, url, &nsuri); if(SUCCEEDED(hres)) { if(async_bsc) bscallback = async_bsc; else hres = create_channelbsc(mon, NULL, NULL, 0, &bscallback); } if(SUCCEEDED(hres)) { remove_target_tasks(This->task_magic); abort_document_bindings(This->doc_node); hres = load_nsuri(This->window, nsuri, bscallback, 0/*LOAD_INITIAL_DOCUMENT_URI*/); nsISupports_Release((nsISupports*)nsuri); /* FIXME */ if(SUCCEEDED(hres)) set_window_bscallback(This->window, bscallback); if(bscallback != async_bsc) IUnknown_Release((IUnknown*)bscallback); } if(FAILED(hres)) { CoTaskMemFree(url); return hres; } HTMLDocument_LockContainer(This->doc_obj, TRUE); if(This->doc_obj->frame) { docobj_task_t *task; task = heap_alloc(sizeof(docobj_task_t)); task->doc = This->doc_obj; push_task(&task->header, set_progress_proc, NULL, This->doc_obj->basedoc.task_magic); } download_task = heap_alloc(sizeof(download_proc_task_t)); download_task->doc = This->doc_obj; download_task->set_download = set_download; download_task->url = url; push_task(&download_task->header, set_downloading_proc, set_downloading_task_destr, This->doc_obj->basedoc.task_magic); return S_OK; }
static inline HRESULT handle_xml_load(BindStatusCallback *This) { static const WCHAR selectW[] = {'p','r','o','c','e','s','s','i','n','g','-', 'i','n','s','t','r','u','c','t','i','o','n','(','\'','x','m','l', '-','s','t','y','l','e','s','h','e','e','t','\'',')',0}; static const WCHAR hrefW[] = {'h','r','e','f','=',0}; IXMLDOMDocument3 *xml = NULL, *xsl = NULL; IXMLDOMNode *stylesheet; IBindCtx *pbc; IMoniker *mon; LPOLESTR xsl_url; LARGE_INTEGER off; VARIANT_BOOL succ; VARIANT var; WCHAR *href = NULL, *p; BSTR bstr; HRESULT hres; off.QuadPart = 0; hres = IStream_Seek(This->stream, off, STREAM_SEEK_SET, NULL); if(FAILED(hres)) return display_error_page(This); hres = DOMDocument_create(MSXML_DEFAULT, NULL, (void**)&xml); if(FAILED(hres)) return display_error_page(This); V_VT(&var) = VT_UNKNOWN; V_UNKNOWN(&var) = (IUnknown*)This->stream; hres = IXMLDOMDocument3_load(xml, var, &succ); if(FAILED(hres) || !succ) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } V_VT(&var) = VT_EMPTY; bstr = SysAllocString(selectW); hres = IXMLDOMDocument3_selectSingleNode(xml, bstr, &stylesheet); SysFreeString(bstr); if(hres != S_OK) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } hres = IXMLDOMNode_get_nodeValue(stylesheet, &var); IXMLDOMNode_Release(stylesheet); if(SUCCEEDED(hres) && V_VT(&var)!=VT_BSTR) { FIXME("Variant type %d not supported\n", V_VT(&var)); VariantClear(&var); hres = E_FAIL; } if(FAILED(hres)) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } /* TODO: fix parsing processing instruction value */ if((p = strstrW(V_BSTR(&var), hrefW))) { p += sizeof(hrefW)/sizeof(WCHAR)-1; if(*p!='\'' && *p!='\"') p = NULL; else { href = p+1; p = strchrW(href, *p); } } if(p) { *p = 0; } else { VariantClear(&var); IXMLDOMDocument3_Release(xml); return display_error_page(This); } hres = CreateURLMonikerEx(This->mon, href, &mon, 0); VariantClear(&var); if(FAILED(hres)) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } hres = CreateBindCtx(0, &pbc); if(SUCCEEDED(hres)) { hres = IMoniker_GetDisplayName(mon, pbc, NULL, &xsl_url); IMoniker_Release(mon); IBindCtx_Release(pbc); } if(FAILED(hres)) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } V_VT(&var) = VT_BSTR; V_BSTR(&var) = SysAllocString(xsl_url); CoTaskMemFree(xsl_url); if(!V_BSTR(&var)) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } hres = DOMDocument_create(MSXML_DEFAULT, NULL, (void**)&xsl); if(FAILED(hres)) { VariantClear(&var); IXMLDOMDocument3_Release(xml); return display_error_page(This); } /* TODO: do the binding asynchronously */ hres = IXMLDOMDocument3_load(xsl, var, &succ); VariantClear(&var); if(FAILED(hres) || !succ) { IXMLDOMDocument3_Release(xsl); IXMLDOMDocument3_Release(xml); return display_error_page(This); } hres = IXMLDOMDocument3_transformNode(xml, (IXMLDOMNode*)xsl, &bstr); IXMLDOMDocument3_Release(xsl); IXMLDOMDocument3_Release(xml); if(FAILED(hres)) return display_error_page(This); hres = IStream_Seek(This->stream, off, STREAM_SEEK_SET, NULL); if(FAILED(hres)) { SysFreeString(bstr); return display_error_page(This); } hres = IStream_Write(This->stream, (BYTE*)bstr, SysStringLen(bstr)*sizeof(WCHAR), NULL); SysFreeString(bstr); if(FAILED(hres)) return display_error_page(This); return report_data(This); }
/****************************************************************************** * FileMoniker_CommonPrefixWith */ static HRESULT WINAPI FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix) { LPOLESTR pathThis,pathOther,*stringTable1,*stringTable2,commonPath; IBindCtx *pbind; DWORD mkSys; ULONG nb1,nb2,i,sameIdx; BOOL machineNameCase = FALSE; if (ppmkPrefix==NULL) return E_POINTER; if (pmkOther==NULL) return E_INVALIDARG; *ppmkPrefix=0; /* check if we have the same type of moniker */ IMoniker_IsSystemMoniker(pmkOther,&mkSys); if(mkSys==MKSYS_FILEMONIKER){ HRESULT ret; ret = CreateBindCtx(0,&pbind); if (FAILED(ret)) return ret; /* create a string based on common part of the two paths */ ret = IMoniker_GetDisplayName(iface,pbind,NULL,&pathThis); if (FAILED(ret)) return ret; ret = IMoniker_GetDisplayName(pmkOther,pbind,NULL,&pathOther); if (FAILED(ret)) return ret; nb1=FileMonikerImpl_DecomposePath(pathThis,&stringTable1); if (FAILED(nb1)) return nb1; nb2=FileMonikerImpl_DecomposePath(pathOther,&stringTable2); if (FAILED(nb2)) { free_stringtable(stringTable1); return nb2; } if (nb1==0 || nb2==0) { free_stringtable(stringTable1); free_stringtable(stringTable2); return MK_E_NOPREFIX; } commonPath=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(min(lstrlenW(pathThis),lstrlenW(pathOther))+1)); if (!commonPath) return E_OUTOFMEMORY; *commonPath=0; for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) && (stringTable2[sameIdx]!=NULL) && (lstrcmpiW(stringTable1[sameIdx],stringTable2[sameIdx])==0)); sameIdx++); if (sameIdx > 1 && *stringTable1[0]=='\\' && *stringTable2[1]=='\\'){ machineNameCase = TRUE; for(i=2;i<sameIdx;i++) if( (*stringTable1[i]=='\\') && (i+1 < sameIdx) && (*stringTable1[i+1]=='\\') ){ machineNameCase = FALSE; break; } } if (machineNameCase && *stringTable1[sameIdx-1]=='\\') sameIdx--; if (machineNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) ) ret = MK_E_NOPREFIX; else { for(i=0;i<sameIdx;i++) strcatW(commonPath,stringTable1[i]); free_stringtable(stringTable1); free_stringtable(stringTable2); ret = CreateFileMoniker(commonPath,ppmkPrefix); } HeapFree(GetProcessHeap(),0,commonPath); return ret; } else return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix); }
/****************************************************************************** * FileMoniker_RelativePathTo */ static HRESULT WINAPI FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath) { IBindCtx *bind; HRESULT res; LPOLESTR str1=0,str2=0,*tabStr1=0,*tabStr2=0,relPath=0; DWORD len1=0,len2=0,sameIdx=0,j=0; static const WCHAR back[] ={'.','.','\\',0}; TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath); if (ppmkRelPath==NULL) return E_POINTER; if (pmOther==NULL) return E_INVALIDARG; res=CreateBindCtx(0,&bind); if (FAILED(res)) return res; res=IMoniker_GetDisplayName(iface,bind,NULL,&str1); if (FAILED(res)) return res; res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2); if (FAILED(res)) return res; len1=FileMonikerImpl_DecomposePath(str1,&tabStr1); if (FAILED(len1)) return E_OUTOFMEMORY; len2=FileMonikerImpl_DecomposePath(str2,&tabStr2); if (FAILED(len2)) { free_stringtable(tabStr1); return E_OUTOFMEMORY; } /* count the number of similar items from the begin of the two paths */ for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) && (tabStr2[sameIdx]!=NULL) && (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++); /* begin the construction of relativePath */ /* if the two paths have a consecutive similar item from the begin ! the relativePath will be composed */ /* by "..\\" in the begin */ relPath=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(1+lstrlenW(str1)+lstrlenW(str2))); *relPath=0; if (len2>0 && !(len1==1 && len2==1 && sameIdx==0)) for(j=sameIdx;(tabStr1[j] != NULL); j++) if (*tabStr1[j]!='\\') strcatW(relPath,back); /* add items of the second path (similar items with the first path are not included) to the relativePath */ for(j=sameIdx;tabStr2[j]!=NULL;j++) strcatW(relPath,tabStr2[j]); res=CreateFileMoniker(relPath,ppmkRelPath); free_stringtable(tabStr1); free_stringtable(tabStr2); CoTaskMemFree(str1); CoTaskMemFree(str2); HeapFree(GetProcessHeap(),0,relPath); if (len1==0 || len2==0 || (len1==1 && len2==1 && sameIdx==0)) return MK_S_HIM; return res; }