kernel32: Add stub for GetSystemTimes.
[wine.git] / dlls / urlmon / umon.c
blobfe60c75471677f4c5aa30e34131cced7be4e3d9d
1 /*
2 * UrlMon
4 * Copyright 1999 Ulrich Czekalla for Corel Corporation
5 * Copyright 2002 Huw D M Davies for CodeWeavers
6 * Copyright 2005 Jacek Caban for CodeWeavers
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <stdio.h>
25 #include "urlmon_main.h"
27 #include "winreg.h"
28 #include "winternl.h"
29 #include "wininet.h"
30 #include "shlwapi.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
36 typedef struct {
37 const IMonikerVtbl *lpIMonikerVtbl;
39 LONG ref;
41 LPOLESTR URLName; /* URL string identified by this URLmoniker */
42 } URLMoniker;
44 #define MONIKER_THIS(iface) DEFINE_THIS(URLMoniker, IMoniker, iface)
46 static HRESULT WINAPI URLMoniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
48 URLMoniker *This = MONIKER_THIS(iface);
50 if(!ppv)
51 return E_INVALIDARG;
53 if(IsEqualIID(&IID_IUnknown, riid)) {
54 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
55 *ppv = iface;
56 }else if(IsEqualIID(&IID_IPersist, riid)) {
57 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
58 *ppv = iface;
59 }else if(IsEqualIID(&IID_IPersistStream,riid)) {
60 TRACE("(%p)->(IID_IPersistStream %p)\n", This, ppv);
61 *ppv = iface;
62 }else if(IsEqualIID(&IID_IMoniker, riid)) {
63 TRACE("(%p)->(IID_IMoniker %p)\n", This, ppv);
64 *ppv = iface;
65 }else if(IsEqualIID(&IID_IAsyncMoniker, riid)) {
66 TRACE("(%p)->(IID_IAsyncMoniker %p)\n", This, ppv);
67 *ppv = iface;
68 }else {
69 WARN("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppv);
70 *ppv = NULL;
71 return E_NOINTERFACE;
74 IMoniker_AddRef((IUnknown*)*ppv);
75 return S_OK;
78 static ULONG WINAPI URLMoniker_AddRef(IMoniker *iface)
80 URLMoniker *This = MONIKER_THIS(iface);
81 ULONG refCount = InterlockedIncrement(&This->ref);
83 TRACE("(%p) ref=%u\n",This, refCount);
85 return refCount;
88 static ULONG WINAPI URLMoniker_Release(IMoniker *iface)
90 URLMoniker *This = MONIKER_THIS(iface);
91 ULONG refCount = InterlockedDecrement(&This->ref);
93 TRACE("(%p) ref=%u\n",This, refCount);
95 if (!refCount) {
96 heap_free(This->URLName);
97 heap_free(This);
99 URLMON_UnlockModule();
102 return refCount;
105 static HRESULT WINAPI URLMoniker_GetClassID(IMoniker *iface, CLSID *pClassID)
107 URLMoniker *This = MONIKER_THIS(iface);
109 TRACE("(%p,%p)\n", This, pClassID);
111 if(!pClassID)
112 return E_POINTER;
114 /* Windows always returns CLSID_StdURLMoniker */
115 *pClassID = CLSID_StdURLMoniker;
116 return S_OK;
119 static HRESULT WINAPI URLMoniker_IsDirty(IMoniker *iface)
121 URLMoniker *This = MONIKER_THIS(iface);
123 TRACE("(%p)\n",This);
125 /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
126 method in the OLE-provided moniker interfaces always return S_FALSE because
127 their internal state never changes. */
128 return S_FALSE;
131 static HRESULT WINAPI URLMoniker_Load(IMoniker* iface,IStream* pStm)
133 URLMoniker *This = MONIKER_THIS(iface);
134 HRESULT res;
135 ULONG size;
136 ULONG got;
138 TRACE("(%p,%p)\n",This,pStm);
140 if(!pStm)
141 return E_INVALIDARG;
144 * NOTE
145 * Writes a ULONG containing length of unicode string, followed
146 * by that many unicode characters
148 res = IStream_Read(pStm, &size, sizeof(ULONG), &got);
149 if(SUCCEEDED(res)) {
150 if(got == sizeof(ULONG)) {
151 heap_free(This->URLName);
152 This->URLName = heap_alloc(size);
153 if(!This->URLName)
154 res = E_OUTOFMEMORY;
155 else {
156 res = IStream_Read(pStm, This->URLName, size, NULL);
157 This->URLName[size/sizeof(WCHAR) - 1] = 0;
160 else
161 res = E_FAIL;
164 return res;
167 static HRESULT WINAPI URLMoniker_Save(IMoniker *iface, IStream* pStm, BOOL fClearDirty)
169 URLMoniker *This = MONIKER_THIS(iface);
170 HRESULT res;
171 ULONG size;
173 TRACE("(%p,%p,%d)\n", This, pStm, fClearDirty);
175 if(!pStm)
176 return E_INVALIDARG;
178 size = (strlenW(This->URLName) + 1)*sizeof(WCHAR);
179 res=IStream_Write(pStm,&size,sizeof(ULONG),NULL);
180 if(SUCCEEDED(res))
181 res=IStream_Write(pStm,This->URLName,size,NULL);
183 return res;
187 static HRESULT WINAPI URLMoniker_GetSizeMax(IMoniker* iface, ULARGE_INTEGER *pcbSize)
189 URLMoniker *This = MONIKER_THIS(iface);
191 TRACE("(%p,%p)\n",This,pcbSize);
193 if(!pcbSize)
194 return E_INVALIDARG;
196 pcbSize->QuadPart = sizeof(ULONG) + ((strlenW(This->URLName)+1) * sizeof(WCHAR));
197 return S_OK;
200 static HRESULT WINAPI URLMoniker_BindToObject(IMoniker *iface, IBindCtx* pbc, IMoniker *pmkToLeft,
201 REFIID riid, void **ppv)
203 URLMoniker *This = MONIKER_THIS(iface);
204 IRunningObjectTable *obj_tbl;
205 HRESULT hres;
207 TRACE("(%p)->(%p,%p,%s,%p): stub\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppv);
209 hres = IBindCtx_GetRunningObjectTable(pbc, &obj_tbl);
210 if(SUCCEEDED(hres)) {
211 FIXME("use running object table\n");
212 IRunningObjectTable_Release(obj_tbl);
215 return bind_to_object(iface, This->URLName, pbc, riid, ppv);
218 static HRESULT WINAPI URLMoniker_BindToStorage(IMoniker* iface, IBindCtx* pbc,
219 IMoniker* pmkToLeft, REFIID riid, void **ppvObject)
221 URLMoniker *This = MONIKER_THIS(iface);
223 TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObject);
225 if(pmkToLeft)
226 FIXME("Unsupported pmkToLeft\n");
228 return bind_to_storage(This->URLName, pbc, riid, ppvObject);
231 static HRESULT WINAPI URLMoniker_Reduce(IMoniker *iface, IBindCtx *pbc,
232 DWORD dwReduceHowFar, IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
234 URLMoniker *This = MONIKER_THIS(iface);
236 TRACE("(%p,%p,%d,%p,%p)\n", This, pbc, dwReduceHowFar, ppmkToLeft, ppmkReduced);
238 if(!ppmkReduced)
239 return E_INVALIDARG;
241 IMoniker_AddRef(iface);
242 *ppmkReduced = iface;
243 return MK_S_REDUCED_TO_SELF;
246 static HRESULT WINAPI URLMoniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
247 BOOL fOnlyIfNotGeneric, IMoniker **ppmkComposite)
249 URLMoniker *This = MONIKER_THIS(iface);
250 FIXME("(%p)->(%p,%d,%p): stub\n",This,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
251 return E_NOTIMPL;
254 static HRESULT WINAPI URLMoniker_Enum(IMoniker *iface, BOOL fForward, IEnumMoniker **ppenumMoniker)
256 URLMoniker *This = MONIKER_THIS(iface);
258 TRACE("(%p,%d,%p)\n", This, fForward, ppenumMoniker);
260 if(!ppenumMoniker)
261 return E_INVALIDARG;
263 /* Does not support sub-monikers */
264 *ppenumMoniker = NULL;
265 return S_OK;
268 static HRESULT WINAPI URLMoniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
270 URLMoniker *This = MONIKER_THIS(iface);
271 CLSID clsid;
272 LPOLESTR urlPath;
273 IBindCtx* bind;
274 HRESULT res;
276 TRACE("(%p,%p)\n",This, pmkOtherMoniker);
278 if(pmkOtherMoniker==NULL)
279 return E_INVALIDARG;
281 IMoniker_GetClassID(pmkOtherMoniker,&clsid);
283 if(!IsEqualCLSID(&clsid,&CLSID_StdURLMoniker))
284 return S_FALSE;
286 res = CreateBindCtx(0,&bind);
287 if(FAILED(res))
288 return res;
290 res = S_FALSE;
291 if(SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&urlPath))) {
292 int result = lstrcmpiW(urlPath, This->URLName);
293 CoTaskMemFree(urlPath);
294 if(result == 0)
295 res = S_OK;
297 IUnknown_Release(bind);
298 return res;
302 static HRESULT WINAPI URLMoniker_Hash(IMoniker *iface, DWORD *pdwHash)
304 URLMoniker *This = MONIKER_THIS(iface);
305 int h = 0,i,skip,len;
306 int off = 0;
307 LPOLESTR val;
309 TRACE("(%p,%p)\n",This,pdwHash);
311 if(!pdwHash)
312 return E_INVALIDARG;
314 val = This->URLName;
315 len = lstrlenW(val);
317 if(len < 16) {
318 for(i = len ; i > 0; i--) {
319 h = (h * 37) + val[off++];
321 }else {
322 /* only sample some characters */
323 skip = len / 8;
324 for(i = len; i > 0; i -= skip, off += skip) {
325 h = (h * 39) + val[off];
328 *pdwHash = h;
329 return S_OK;
332 static HRESULT WINAPI URLMoniker_IsRunning(IMoniker* iface, IBindCtx* pbc,
333 IMoniker *pmkToLeft, IMoniker *pmkNewlyRunning)
335 URLMoniker *This = MONIKER_THIS(iface);
336 FIXME("(%p)->(%p,%p,%p): stub\n",This,pbc,pmkToLeft,pmkNewlyRunning);
337 return E_NOTIMPL;
340 static HRESULT WINAPI URLMoniker_GetTimeOfLastChange(IMoniker *iface,
341 IBindCtx *pbc, IMoniker *pmkToLeft, FILETIME *pFileTime)
343 URLMoniker *This = MONIKER_THIS(iface);
344 FIXME("(%p)->(%p,%p,%p): stub\n", This, pbc, pmkToLeft, pFileTime);
345 return E_NOTIMPL;
348 static HRESULT WINAPI URLMoniker_Inverse(IMoniker *iface, IMoniker **ppmk)
350 URLMoniker *This = MONIKER_THIS(iface);
351 TRACE("(%p,%p)\n",This,ppmk);
352 return MK_E_NOINVERSE;
355 static HRESULT WINAPI URLMoniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther, IMoniker **ppmkPrefix)
357 URLMoniker *This = MONIKER_THIS(iface);
358 FIXME("(%p)->(%p,%p): stub\n",This,pmkOther,ppmkPrefix);
359 return E_NOTIMPL;
362 static HRESULT WINAPI URLMoniker_RelativePathTo(IMoniker *iface, IMoniker *pmOther, IMoniker **ppmkRelPath)
364 URLMoniker *This = MONIKER_THIS(iface);
365 FIXME("(%p)->(%p,%p): stub\n",This,pmOther,ppmkRelPath);
366 return E_NOTIMPL;
369 static HRESULT WINAPI URLMoniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
370 LPOLESTR *ppszDisplayName)
372 URLMoniker *This = MONIKER_THIS(iface);
373 int len;
375 TRACE("(%p,%p,%p,%p)\n", This, pbc, pmkToLeft, ppszDisplayName);
377 if(!ppszDisplayName)
378 return E_INVALIDARG;
380 if(!This->URLName)
381 return E_OUTOFMEMORY;
383 /* FIXME: If this is a partial URL, try and get a URL moniker from SZ_URLCONTEXT in the bind context,
384 then look at pmkToLeft to try and complete the URL
386 len = lstrlenW(This->URLName)+1;
387 *ppszDisplayName = CoTaskMemAlloc(len*sizeof(WCHAR));
388 if(!*ppszDisplayName)
389 return E_OUTOFMEMORY;
390 lstrcpyW(*ppszDisplayName, This->URLName);
391 return S_OK;
394 static HRESULT WINAPI URLMoniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
395 LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
397 URLMoniker *This = MONIKER_THIS(iface);
398 FIXME("(%p)->(%p,%p,%p,%p,%p): stub\n",This,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
399 return E_NOTIMPL;
402 static HRESULT WINAPI URLMoniker_IsSystemMoniker(IMoniker *iface, DWORD *pwdMksys)
404 URLMoniker *This = MONIKER_THIS(iface);
406 TRACE("(%p,%p)\n",This,pwdMksys);
408 if(!pwdMksys)
409 return E_INVALIDARG;
411 *pwdMksys = MKSYS_URLMONIKER;
412 return S_OK;
415 static const IMonikerVtbl URLMonikerVtbl =
417 URLMoniker_QueryInterface,
418 URLMoniker_AddRef,
419 URLMoniker_Release,
420 URLMoniker_GetClassID,
421 URLMoniker_IsDirty,
422 URLMoniker_Load,
423 URLMoniker_Save,
424 URLMoniker_GetSizeMax,
425 URLMoniker_BindToObject,
426 URLMoniker_BindToStorage,
427 URLMoniker_Reduce,
428 URLMoniker_ComposeWith,
429 URLMoniker_Enum,
430 URLMoniker_IsEqual,
431 URLMoniker_Hash,
432 URLMoniker_IsRunning,
433 URLMoniker_GetTimeOfLastChange,
434 URLMoniker_Inverse,
435 URLMoniker_CommonPrefixWith,
436 URLMoniker_RelativePathTo,
437 URLMoniker_GetDisplayName,
438 URLMoniker_ParseDisplayName,
439 URLMoniker_IsSystemMoniker
442 static URLMoniker *alloc_moniker(void)
444 URLMoniker *ret;
446 ret = heap_alloc(sizeof(URLMoniker));
447 if(!ret)
448 return NULL;
450 ret->lpIMonikerVtbl = &URLMonikerVtbl;
451 ret->ref = 1;
452 ret->URLName = NULL;
454 return ret;
457 static HRESULT URLMoniker_Init(URLMoniker *This, LPCOLESTR lpszLeftURLName, LPCOLESTR lpszURLName)
459 HRESULT hres;
460 DWORD sizeStr = 0;
462 TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszLeftURLName),debugstr_w(lpszURLName));
464 This->URLName = heap_alloc(INTERNET_MAX_URL_LENGTH*sizeof(WCHAR));
466 if(lpszLeftURLName)
467 hres = CoInternetCombineUrl(lpszLeftURLName, lpszURLName, URL_FILE_USE_PATHURL,
468 This->URLName, INTERNET_MAX_URL_LENGTH, &sizeStr, 0);
469 else
470 hres = CoInternetParseUrl(lpszURLName, PARSE_CANONICALIZE, URL_FILE_USE_PATHURL,
471 This->URLName, INTERNET_MAX_URL_LENGTH, &sizeStr, 0);
473 if(FAILED(hres)) {
474 heap_free(This->URLName);
475 return hres;
478 URLMON_LockModule();
480 if(sizeStr != INTERNET_MAX_URL_LENGTH)
481 This->URLName = heap_realloc(This->URLName, (sizeStr+1)*sizeof(WCHAR));
483 TRACE("URLName = %s\n", debugstr_w(This->URLName));
485 return S_OK;
488 HRESULT StdURLMoniker_Construct(IUnknown *outer, void **ppv)
490 TRACE("(%p %p)\n", outer, ppv);
492 *ppv = alloc_moniker();
493 return *ppv ? S_OK : E_OUTOFMEMORY;
496 /***********************************************************************
497 * CreateURLMonikerEx (URLMON.@)
499 * Create a url moniker.
501 * PARAMS
502 * pmkContext [I] Context
503 * szURL [I] Url to create the moniker for
504 * ppmk [O] Destination for created moniker.
505 * dwFlags [I] Flags.
507 * RETURNS
508 * Success: S_OK. ppmk contains the created IMoniker object.
509 * Failure: MK_E_SYNTAX if szURL is not a valid url, or
510 * E_OUTOFMEMORY if memory allocation fails.
512 HRESULT WINAPI CreateURLMonikerEx(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk, DWORD dwFlags)
514 URLMoniker *obj;
515 HRESULT hres;
516 LPOLESTR lefturl = NULL;
518 TRACE("(%p, %s, %p, %08x)\n", pmkContext, debugstr_w(szURL), ppmk, dwFlags);
520 if (dwFlags & URL_MK_UNIFORM) FIXME("ignoring flag URL_MK_UNIFORM\n");
522 if(!(obj = alloc_moniker()))
523 return E_OUTOFMEMORY;
525 if(pmkContext) {
526 IBindCtx* bind;
527 DWORD dwMksys = 0;
528 IMoniker_IsSystemMoniker(pmkContext, &dwMksys);
529 if(dwMksys == MKSYS_URLMONIKER && SUCCEEDED(CreateBindCtx(0, &bind))) {
530 IMoniker_GetDisplayName(pmkContext, bind, NULL, &lefturl);
531 TRACE("lefturl = %s\n", debugstr_w(lefturl));
532 IBindCtx_Release(bind);
536 hres = URLMoniker_Init(obj, lefturl, szURL);
537 CoTaskMemFree(lefturl);
538 if(SUCCEEDED(hres))
539 hres = URLMoniker_QueryInterface((IMoniker*)obj, &IID_IMoniker, (void**)ppmk);
540 IMoniker_Release((IMoniker*)obj);
541 return hres;
544 /**********************************************************************
545 * CreateURLMoniker (URLMON.@)
547 * Create a url moniker.
549 * PARAMS
550 * pmkContext [I] Context
551 * szURL [I] Url to create the moniker for
552 * ppmk [O] Destination for created moniker.
554 * RETURNS
555 * Success: S_OK. ppmk contains the created IMoniker object.
556 * Failure: MK_E_SYNTAX if szURL is not a valid url, or
557 * E_OUTOFMEMORY if memory allocation fails.
559 HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk)
561 return CreateURLMonikerEx(pmkContext, szURL, ppmk, URL_MK_LEGACY);
564 /***********************************************************************
565 * IsAsyncMoniker (URLMON.@)
567 HRESULT WINAPI IsAsyncMoniker(IMoniker *pmk)
569 IUnknown *am;
571 TRACE("(%p)\n", pmk);
572 if(!pmk)
573 return E_INVALIDARG;
574 if(SUCCEEDED(IMoniker_QueryInterface(pmk, &IID_IAsyncMoniker, (void**)&am))) {
575 IUnknown_Release(am);
576 return S_OK;
578 return S_FALSE;
581 /***********************************************************************
582 * BindAsyncMoniker (URLMON.@)
584 * Bind a bind status callback to an asynchronous URL Moniker.
586 * PARAMS
587 * pmk [I] Moniker object to bind status callback to
588 * grfOpt [I] Options, seems not used
589 * pbsc [I] Status callback to bind
590 * iidResult [I] Interface to return
591 * ppvResult [O] Resulting asynchronous moniker object
593 * RETURNS
594 * Success: S_OK.
595 * Failure: E_INVALIDARG, if any argument is invalid, or
596 * E_OUTOFMEMORY if memory allocation fails.
598 HRESULT WINAPI BindAsyncMoniker(IMoniker *pmk, DWORD grfOpt, IBindStatusCallback *pbsc, REFIID iidResult, LPVOID *ppvResult)
600 LPBC pbc = NULL;
601 HRESULT hr = E_INVALIDARG;
603 TRACE("(%p %08x %p %s %p)\n", pmk, grfOpt, pbsc, debugstr_guid(iidResult), ppvResult);
605 if (pmk && ppvResult)
607 *ppvResult = NULL;
609 hr = CreateAsyncBindCtx(0, pbsc, NULL, &pbc);
610 if (hr == NOERROR)
612 hr = IMoniker_BindToObject(pmk, pbc, NULL, iidResult, ppvResult);
613 IBindCtx_Release(pbc);
616 return hr;
619 /***********************************************************************
620 * MkParseDisplayNameEx (URLMON.@)
622 HRESULT WINAPI MkParseDisplayNameEx(IBindCtx *pbc, LPCWSTR szDisplayName, ULONG *pchEaten, LPMONIKER *ppmk)
624 TRACE("(%p %s %p %p)\n", pbc, debugstr_w(szDisplayName), pchEaten, ppmk);
626 if(is_registered_protocol(szDisplayName)) {
627 HRESULT hres;
629 hres = CreateURLMoniker(NULL, szDisplayName, ppmk);
630 if(SUCCEEDED(hres)) {
631 *pchEaten = strlenW(szDisplayName);
632 return hres;
636 return MkParseDisplayName(pbc, szDisplayName, pchEaten, ppmk);
640 /***********************************************************************
641 * URLDownloadToCacheFileA (URLMON.@)
643 HRESULT WINAPI URLDownloadToCacheFileA(LPUNKNOWN lpUnkCaller, LPCSTR szURL, LPSTR szFileName,
644 DWORD dwBufLength, DWORD dwReserved, LPBINDSTATUSCALLBACK pBSC)
646 LPWSTR url = NULL, file_name = NULL;
647 int len;
648 HRESULT hres;
650 TRACE("(%p %s %p %d %d %p)\n", lpUnkCaller, debugstr_a(szURL), szFileName,
651 dwBufLength, dwReserved, pBSC);
653 if(szURL) {
654 len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0);
655 url = heap_alloc(len*sizeof(WCHAR));
656 MultiByteToWideChar(CP_ACP, 0, szURL, -1, url, len);
659 if(szFileName)
660 file_name = heap_alloc(dwBufLength*sizeof(WCHAR));
662 hres = URLDownloadToCacheFileW(lpUnkCaller, url, file_name, dwBufLength*sizeof(WCHAR),
663 dwReserved, pBSC);
665 if(SUCCEEDED(hres) && file_name)
666 WideCharToMultiByte(CP_ACP, 0, file_name, -1, szFileName, dwBufLength, NULL, NULL);
668 heap_free(url);
669 heap_free(file_name);
671 return hres;
674 /***********************************************************************
675 * URLDownloadToCacheFileW (URLMON.@)
677 HRESULT WINAPI URLDownloadToCacheFileW(LPUNKNOWN lpUnkCaller, LPCWSTR szURL, LPWSTR szFileName,
678 DWORD dwBufLength, DWORD dwReserved, LPBINDSTATUSCALLBACK pBSC)
680 WCHAR cache_path[MAX_PATH + 1];
681 FILETIME expire, modified;
682 HRESULT hr;
683 LPWSTR ext;
685 static WCHAR header[] = {
686 'H','T','T','P','/','1','.','0',' ','2','0','0',' ',
687 'O','K','\\','r','\\','n','\\','r','\\','n',0
690 TRACE("(%p, %s, %p, %d, %d, %p)\n", lpUnkCaller, debugstr_w(szURL),
691 szFileName, dwBufLength, dwReserved, pBSC);
693 if (!szURL || !szFileName)
694 return E_INVALIDARG;
696 ext = PathFindExtensionW(szURL);
698 if (!CreateUrlCacheEntryW(szURL, 0, ext, cache_path, 0))
699 return E_FAIL;
701 hr = URLDownloadToFileW(lpUnkCaller, szURL, cache_path, 0, pBSC);
702 if (FAILED(hr))
703 return hr;
705 expire.dwHighDateTime = 0;
706 expire.dwLowDateTime = 0;
707 modified.dwHighDateTime = 0;
708 modified.dwLowDateTime = 0;
710 if (!CommitUrlCacheEntryW(szURL, cache_path, expire, modified, NORMAL_CACHE_ENTRY,
711 header, sizeof(header), NULL, NULL))
712 return E_FAIL;
714 if (strlenW(cache_path) > dwBufLength)
715 return E_OUTOFMEMORY;
717 lstrcpyW(szFileName, cache_path);
719 return S_OK;
722 /***********************************************************************
723 * HlinkSimpleNavigateToMoniker (URLMON.@)
725 HRESULT WINAPI HlinkSimpleNavigateToMoniker(IMoniker *pmkTarget,
726 LPCWSTR szLocation, LPCWSTR szTargetFrameName, IUnknown *pUnk,
727 IBindCtx *pbc, IBindStatusCallback *pbsc, DWORD grfHLNF, DWORD dwReserved)
729 FIXME("stub\n");
730 return E_NOTIMPL;
733 /***********************************************************************
734 * HlinkSimpleNavigateToString (URLMON.@)
736 HRESULT WINAPI HlinkSimpleNavigateToString( LPCWSTR szTarget,
737 LPCWSTR szLocation, LPCWSTR szTargetFrameName, IUnknown *pUnk,
738 IBindCtx *pbc, IBindStatusCallback *pbsc, DWORD grfHLNF, DWORD dwReserved)
740 FIXME("%s\n", debugstr_w( szTarget ) );
741 return E_NOTIMPL;
744 /***********************************************************************
745 * HlinkNavigateString (URLMON.@)
747 HRESULT WINAPI HlinkNavigateString( IUnknown *pUnk, LPCWSTR szTarget )
749 TRACE("%p %s\n", pUnk, debugstr_w( szTarget ) );
750 return HlinkSimpleNavigateToString(
751 szTarget, NULL, NULL, pUnk, NULL, NULL, 0, 0 );
754 /***********************************************************************
755 * GetSoftwareUpdateInfo (URLMON.@)
757 HRESULT WINAPI GetSoftwareUpdateInfo( LPCWSTR szDistUnit, LPSOFTDISTINFO psdi )
759 FIXME("%s %p\n", debugstr_w(szDistUnit), psdi );
760 return E_FAIL;