4 * Copyright 1999 Ulrich Czekalla for Corel Corporation
5 * Copyright 2002 Huw D M Davies for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define COM_NO_WINDOWS_H
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
37 #include "urlmon_main.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(urlmon
);
41 /* native urlmon.dll uses this key, too */
42 static WCHAR BSCBHolder
[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
44 /*static BOOL registered_wndclass = FALSE;*/
46 /* filemoniker data structure */
47 typedef struct URLMonikerImpl
{
49 ICOM_VTABLE(IMoniker
)* lpvtbl1
; /* VTable relative to the IMoniker interface.*/
50 ICOM_VTABLE(IBinding
)* lpvtbl2
; /* VTable to IBinding interface */
52 ULONG ref
; /* reference counter for this object */
54 LPOLESTR URLName
; /* URL string identified by this URLmoniker */
58 HINTERNET hinternet
, hconnect
, hrequest
;
61 /********************************************************************************/
62 /* URLMoniker prototype functions : */
64 /* IUnknown prototype functions */
65 static HRESULT WINAPI
URLMonikerImpl_QueryInterface(IMoniker
* iface
,REFIID riid
,void** ppvObject
);
66 static ULONG WINAPI
URLMonikerImpl_AddRef(IMoniker
* iface
);
67 static ULONG WINAPI
URLMonikerImpl_Release(IMoniker
* iface
);
69 /* IPersist prototype functions */
70 static HRESULT WINAPI
URLMonikerImpl_GetClassID(IMoniker
* iface
, CLSID
*pClassID
);
72 /* IPersistStream prototype functions */
73 static HRESULT WINAPI
URLMonikerImpl_IsDirty(IMoniker
* iface
);
74 static HRESULT WINAPI
URLMonikerImpl_Load(IMoniker
* iface
, IStream
* pStm
);
75 static HRESULT WINAPI
URLMonikerImpl_Save(IMoniker
* iface
, IStream
* pStm
, BOOL fClearDirty
);
76 static HRESULT WINAPI
URLMonikerImpl_GetSizeMax(IMoniker
* iface
, ULARGE_INTEGER
* pcbSize
);
78 /* IMoniker prototype functions */
79 static HRESULT WINAPI
URLMonikerImpl_BindToObject(IMoniker
* iface
,IBindCtx
* pbc
, IMoniker
* pmkToLeft
, REFIID riid
, VOID
** ppvResult
);
80 static HRESULT WINAPI
URLMonikerImpl_BindToStorage(IMoniker
* iface
,IBindCtx
* pbc
, IMoniker
* pmkToLeft
, REFIID riid
, VOID
** ppvResult
);
81 static HRESULT WINAPI
URLMonikerImpl_Reduce(IMoniker
* iface
,IBindCtx
* pbc
, DWORD dwReduceHowFar
,IMoniker
** ppmkToLeft
, IMoniker
** ppmkReduced
);
82 static HRESULT WINAPI
URLMonikerImpl_ComposeWith(IMoniker
* iface
,IMoniker
* pmkRight
,BOOL fOnlyIfNotGeneric
, IMoniker
** ppmkComposite
);
83 static HRESULT WINAPI
URLMonikerImpl_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
);
84 static HRESULT WINAPI
URLMonikerImpl_IsEqual(IMoniker
* iface
,IMoniker
* pmkOtherMoniker
);
85 static HRESULT WINAPI
URLMonikerImpl_Hash(IMoniker
* iface
,DWORD
* pdwHash
);
86 static HRESULT WINAPI
URLMonikerImpl_IsRunning(IMoniker
* iface
,IBindCtx
* pbc
, IMoniker
* pmkToLeft
, IMoniker
* pmkNewlyRunning
);
87 static HRESULT WINAPI
URLMonikerImpl_GetTimeOfLastChange(IMoniker
* iface
, IBindCtx
* pbc
, IMoniker
* pmkToLeft
, FILETIME
* pFileTime
);
88 static HRESULT WINAPI
URLMonikerImpl_Inverse(IMoniker
* iface
,IMoniker
** ppmk
);
89 static HRESULT WINAPI
URLMonikerImpl_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
, IMoniker
** ppmkPrefix
);
90 static HRESULT WINAPI
URLMonikerImpl_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
);
91 static HRESULT WINAPI
URLMonikerImpl_GetDisplayName(IMoniker
* iface
,IBindCtx
* pbc
, IMoniker
* pmkToLeft
, LPOLESTR
*ppszDisplayName
);
92 static HRESULT WINAPI
URLMonikerImpl_ParseDisplayName(IMoniker
* iface
,IBindCtx
* pbc
, IMoniker
* pmkToLeft
, LPOLESTR pszDisplayName
, ULONG
* pchEaten
, IMoniker
** ppmkOut
);
93 static HRESULT WINAPI
URLMonikerImpl_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
);
95 /* IBinding interface to moniker */
96 static HRESULT WINAPI
URLMonikerImpl_IBinding_QueryInterface(IBinding
* iface
,REFIID riid
,void** ppvObject
);
97 static ULONG WINAPI
URLMonikerImpl_IBinding_AddRef(IBinding
* iface
);
98 static ULONG WINAPI
URLMonikerImpl_IBinding_Release(IBinding
* iface
);
99 static HRESULT WINAPI
URLMonikerImpl_IBinding_Abort(IBinding
* iface
);
100 static HRESULT WINAPI
URLMonikerImpl_IBinding_Suspend(IBinding
* iface
);
101 static HRESULT WINAPI
URLMonikerImpl_IBinding_Resume(IBinding
* iface
);
102 static HRESULT WINAPI
URLMonikerImpl_IBinding_SetPriority(IBinding
* iface
, LONG nPriority
);
103 static HRESULT WINAPI
URLMonikerImpl_IBinding_GetPriority(IBinding
* iface
, LONG
* pnPriority
);
104 static HRESULT WINAPI
URLMonikerImpl_IBinding_GetBindResult(IBinding
* iface
, CLSID
* pclsidProtocol
, DWORD
* pdwResult
, LPOLESTR
* pszResult
, DWORD
* pdwReserved
);
106 /* Local function used by urlmoniker implementation */
107 static HRESULT
URLMonikerImpl_Construct(URLMonikerImpl
* iface
, LPCOLESTR lpszURL
);
108 static HRESULT
URLMonikerImpl_Destroy(URLMonikerImpl
* iface
);
110 /********************************************************************************/
111 /* Virtual function table for the URLMonikerImpl class which include IPersist,*/
112 /* IPersistStream and IMoniker functions. */
113 static ICOM_VTABLE(IMoniker
) VT_URLMonikerImpl
=
115 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
116 URLMonikerImpl_QueryInterface
,
117 URLMonikerImpl_AddRef
,
118 URLMonikerImpl_Release
,
119 URLMonikerImpl_GetClassID
,
120 URLMonikerImpl_IsDirty
,
123 URLMonikerImpl_GetSizeMax
,
124 URLMonikerImpl_BindToObject
,
125 URLMonikerImpl_BindToStorage
,
126 URLMonikerImpl_Reduce
,
127 URLMonikerImpl_ComposeWith
,
129 URLMonikerImpl_IsEqual
,
131 URLMonikerImpl_IsRunning
,
132 URLMonikerImpl_GetTimeOfLastChange
,
133 URLMonikerImpl_Inverse
,
134 URLMonikerImpl_CommonPrefixWith
,
135 URLMonikerImpl_RelativePathTo
,
136 URLMonikerImpl_GetDisplayName
,
137 URLMonikerImpl_ParseDisplayName
,
138 URLMonikerImpl_IsSystemMoniker
141 static ICOM_VTABLE(IBinding
) VTBinding_URLMonikerImpl
=
143 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
144 URLMonikerImpl_IBinding_QueryInterface
,
145 URLMonikerImpl_IBinding_AddRef
,
146 URLMonikerImpl_IBinding_Release
,
147 URLMonikerImpl_IBinding_Abort
,
148 URLMonikerImpl_IBinding_Suspend
,
149 URLMonikerImpl_IBinding_Resume
,
150 URLMonikerImpl_IBinding_SetPriority
,
151 URLMonikerImpl_IBinding_GetPriority
,
152 URLMonikerImpl_IBinding_GetBindResult
156 /*******************************************************************************
157 * URLMoniker_QueryInterface
158 *******************************************************************************/
159 static HRESULT WINAPI
URLMonikerImpl_QueryInterface(IMoniker
* iface
,REFIID riid
,void** ppvObject
)
161 ICOM_THIS(URLMonikerImpl
,iface
);
163 TRACE("(%p)->(%s,%p)\n",This
,debugstr_guid(riid
),ppvObject
);
165 /* Perform a sanity check on the parameters.*/
166 if ( (This
==0) || (ppvObject
==0) )
169 /* Initialize the return parameter */
172 /* Compare the riid with the interface IDs implemented by this object.*/
173 if (IsEqualIID(&IID_IUnknown
, riid
) ||
174 IsEqualIID(&IID_IPersist
, riid
) ||
175 IsEqualIID(&IID_IPersistStream
,riid
) ||
176 IsEqualIID(&IID_IMoniker
, riid
)
180 /* Check that we obtained an interface.*/
182 return E_NOINTERFACE
;
184 /* Query Interface always increases the reference count by one when it is successful */
185 URLMonikerImpl_AddRef(iface
);
190 /******************************************************************************
192 ******************************************************************************/
193 static ULONG WINAPI
URLMonikerImpl_AddRef(IMoniker
* iface
)
195 ICOM_THIS(URLMonikerImpl
,iface
);
197 TRACE("(%p)\n",This
);
199 return ++(This
->ref
);
202 /******************************************************************************
204 ******************************************************************************/
205 static ULONG WINAPI
URLMonikerImpl_Release(IMoniker
* iface
)
207 ICOM_THIS(URLMonikerImpl
,iface
);
209 TRACE("(%p)\n",This
);
213 /* destroy the object if there's no more reference on it */
216 URLMonikerImpl_Destroy(This
);
223 /******************************************************************************
224 * URLMoniker_GetClassID
225 ******************************************************************************/
226 static HRESULT WINAPI
URLMonikerImpl_GetClassID(IMoniker
* iface
,
227 CLSID
*pClassID
)/* Pointer to CLSID of object */
229 ICOM_THIS(URLMonikerImpl
,iface
);
231 FIXME("(%p)->(%p): stub\n",This
,pClassID
);
239 /******************************************************************************
241 ******************************************************************************/
242 static HRESULT WINAPI
URLMonikerImpl_IsDirty(IMoniker
* iface
)
244 ICOM_THIS(URLMonikerImpl
,iface
);
245 /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
246 method in the OLE-provided moniker interfaces always return S_FALSE because
247 their internal state never changes. */
249 TRACE("(%p)\n",This
);
254 /******************************************************************************
256 ******************************************************************************/
257 static HRESULT WINAPI
URLMonikerImpl_Load(IMoniker
* iface
,IStream
* pStm
)
259 ICOM_THIS(URLMonikerImpl
,iface
);
261 FIXME("(%p)->(%p): stub\n",This
,pStm
);
266 /******************************************************************************
268 ******************************************************************************/
269 static HRESULT WINAPI
URLMonikerImpl_Save(IMoniker
* iface
,
270 IStream
* pStm
,/* pointer to the stream where the object is to be saved */
271 BOOL fClearDirty
)/* Specifies whether to clear the dirty flag */
273 ICOM_THIS(URLMonikerImpl
,iface
);
275 FIXME("(%p)->(%p,%d): stub\n",This
,pStm
,fClearDirty
);
281 /******************************************************************************
282 * URLMoniker_GetSizeMax
283 ******************************************************************************/
284 static HRESULT WINAPI
URLMonikerImpl_GetSizeMax(IMoniker
* iface
,
285 ULARGE_INTEGER
* pcbSize
)/* Pointer to size of stream needed to save object */
287 ICOM_THIS(URLMonikerImpl
,iface
);
289 FIXME("(%p)->(%p): stub\n",This
,pcbSize
);
294 /******************************************************************************
295 * URLMoniker_Construct (local function)
296 *******************************************************************************/
297 static HRESULT
URLMonikerImpl_Construct(URLMonikerImpl
* This
, LPCOLESTR lpszURLName
)
299 int sizeStr
= strlenW(lpszURLName
);
301 TRACE("(%p,%s)\n",This
,debugstr_w(lpszURLName
));
302 memset(This
, 0, sizeof(*This
));
304 /* Initialize the virtual fgunction table. */
305 This
->lpvtbl1
= &VT_URLMonikerImpl
;
306 This
->lpvtbl2
= &VTBinding_URLMonikerImpl
;
309 This
->URLName
=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*(sizeStr
+1));
311 if (This
->URLName
==NULL
)
312 return E_OUTOFMEMORY
;
314 strcpyW(This
->URLName
,lpszURLName
);
321 /******************************************************************************
322 * URLMoniker_Destroy (local function)
323 *******************************************************************************/
324 static HRESULT
URLMonikerImpl_Destroy(URLMonikerImpl
* This
)
326 TRACE("(%p)\n",This
);
328 if (This
->URLName
!=NULL
)
329 HeapFree(GetProcessHeap(),0,This
->URLName
);
331 HeapFree(GetProcessHeap(),0,This
);
336 /******************************************************************************
337 * URLMoniker_BindToObject
338 ******************************************************************************/
339 static HRESULT WINAPI
URLMonikerImpl_BindToObject(IMoniker
* iface
,
345 ICOM_THIS(URLMonikerImpl
,iface
);
349 FIXME("(%p)->(%p,%p,%s,%p): stub\n",This
,pbc
,pmkToLeft
,debugstr_guid(riid
),
356 enum {OnProgress
, OnDataAvailable
} callback
;
357 } URLMON_CallbackData
;
361 static LRESULT CALLBACK
URLMON_WndProc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
363 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
366 static void PostOnProgress(URLMonikerImpl
*This
, UINT progress
, UINT maxprogress
, DWORD status
, LPCWSTR
*str
)
370 static void CALLBACK
URLMON_InternetCallback(HINTERNET hinet
, /*DWORD_PTR*/ DWORD context
, DWORD status
,
371 void *status_info
, DWORD status_info_len
)
373 URLMonikerImpl
*This
= (URLMonikerImpl
*)context
;
374 TRACE("handle %p this %p status %08lx\n", hinet
, This
, status
);
376 if(This
->filesize
== -1) {
378 case INTERNET_STATUS_RESOLVING_NAME
:
379 PostOnProgess(This
, 0, 0, BINDSTATUS_FINDINGRESOURCE
, status_info
);
381 case INTERNET_STATUS_CONNECTING_TO_SERVER
:
382 PostOnProgress(This
, 0, 0, BINDSTATUS_CONNECTING
, NULL
);
384 case INTERNET_STATUS_SENDING_REQUEST
:
385 PostOnProgress(This
, 0, 0, BINDSTATUS_SENDINGREQUEST
, NULL
);
387 case INTERNET_REQUEST_COMPLETE
:
389 DWORD len
, lensz
= sizeof(len
);
391 HttpQueryInfoW(hrequest
, HTTP_QUERY_CONTENT_LENGTH
| HTTP_QUERY_FLAG_NUMBER
, &len
, &lensz
, NULL
);
392 TRACE("res = %ld gle = %08lx url len = %ld\n", hres
, GetLastError(), len
);
393 This
->filesize
= len
;
402 /******************************************************************************
403 * URLMoniker_BindToStorage
404 ******************************************************************************/
405 static HRESULT WINAPI
URLMonikerImpl_BindToStorage(IMoniker
* iface
,
411 ICOM_THIS(URLMonikerImpl
,iface
);
413 IBindStatusCallback
*pbscb
;
417 FIXME("(%p)->(%p,%p,%s,%p): stub\n",This
,pbc
,pmkToLeft
,debugstr_guid(riid
),ppvObject
);
419 FIXME("pmkToLeft != NULL\n");
422 if(!IsEqualIID(&IID_IStream
, riid
)) {
423 FIXME("unsupported iid\n");
427 /* FIXME This is a bad hack (tm). We should clearly download to a temporary file.
428 We also need to implement IStream ourselves so that IStream_Read can return
431 hres
= CreateStreamOnHGlobal(0, TRUE
, (IStream
**)ppvObject
);
434 if(SUCCEEDED(hres
)) {
435 TRACE("Created dummy stream...\n");
437 hres
= IBindCtx_GetObjectParam(pbc
, BSCBHolder
, (IUnknown
**)&pbscb
);
438 if(SUCCEEDED(hres
)) {
439 TRACE("Got IBindStatusCallback...\n");
441 memset(&bi
, 0, sizeof(bi
));
442 bi
.cbSize
= sizeof(bi
);
444 hres
= IBindStatusCallback_GetBindInfo(pbscb
, &bindf
, &bi
);
445 if(SUCCEEDED(hres
)) {
448 DWORD len
, lensz
= sizeof(len
), total_read
= 0;
449 LARGE_INTEGER last_read_pos
;
453 TRACE("got bindinfo. bindf = %08lx extrainfo = %s bindinfof = %08lx bindverb = %08lx iid %s\n",
454 bindf
, debugstr_w(bi
.szExtraInfo
), bi
.grfBindInfoF
, bi
.dwBindVerb
, debugstr_guid(&bi
.iid
));
455 hres
= IBindStatusCallback_OnStartBinding(pbscb
, 0, (IBinding
*)&This
->lpvtbl2
);
456 TRACE("OnStartBinding rets %08lx\n", hres
);
459 if(!registered_wndclass
) {
460 WNDCLASSA urlmon_wndclass
= {0, URLMON_WndProc
,0, 0, URLMON_hInstance
, 0, 0, 0, NULL
, "URLMON_Callback_Window_Class"};
461 RegisterClassA(&urlmon_wndclass
);
462 registered_wndclass
= TRUE
;
465 This
->hwndCallback
= CreateWindowA("URLMON_Callback_Window_Class", NULL
, 0, 0, 0, 0, 0, 0, 0,
466 URLMON_hInstance
, NULL
);
469 memset(&url
, 0, sizeof(url
));
470 url
.dwStructSize
= sizeof(url
);
471 url
.dwSchemeLength
= url
.dwHostNameLength
= url
.dwUrlPathLength
= 1;
472 InternetCrackUrlW(This
->URLName
, 0, 0, &url
);
473 host
= HeapAlloc(GetProcessHeap(), 0, (url
.dwHostNameLength
+ 1) * sizeof(WCHAR
));
474 memcpy(host
, url
.lpszHostName
, url
.dwHostNameLength
* sizeof(WCHAR
));
475 host
[url
.dwHostNameLength
] = '\0';
476 path
= HeapAlloc(GetProcessHeap(), 0, (url
.dwUrlPathLength
+ 1) * sizeof(WCHAR
));
477 memcpy(path
, url
.lpszUrlPath
, url
.dwUrlPathLength
* sizeof(WCHAR
));
478 path
[url
.dwUrlPathLength
] = '\0';
480 This
->hinternet
= InternetOpenA("User Agent", 0, NULL
, NULL
, 0 /*INTERNET_FLAG_ASYNC*/);
481 /* InternetSetStatusCallback(This->hinternet, URLMON_InternetCallback);*/
483 This
->hconnect
= InternetConnectW(This
->hinternet
, host
, INTERNET_DEFAULT_HTTP_PORT
, NULL
, NULL
,
484 INTERNET_SERVICE_HTTP
, 0, (DWORD
)This
);
485 This
->hrequest
= HttpOpenRequestW(This
->hconnect
, NULL
, path
, NULL
, NULL
, NULL
, 0, (DWORD
)This
);
487 hres
= IBindStatusCallback_OnProgress(pbscb
, 0, 0, 0x22, NULL
);
488 hres
= IBindStatusCallback_OnProgress(pbscb
, 0, 0, BINDSTATUS_FINDINGRESOURCE
, NULL
);
489 hres
= IBindStatusCallback_OnProgress(pbscb
, 0, 0, BINDSTATUS_CONNECTING
, NULL
);
490 hres
= IBindStatusCallback_OnProgress(pbscb
, 0, 0, BINDSTATUS_SENDINGREQUEST
, NULL
);
491 hres
= E_OUTOFMEMORY
; /* FIXME */
492 if(HttpSendRequestW(This
->hrequest
, NULL
, 0, NULL
, 0)) {
495 HttpQueryInfoW(This
->hrequest
, HTTP_QUERY_CONTENT_LENGTH
| HTTP_QUERY_FLAG_NUMBER
, &len
, &lensz
, NULL
);
497 TRACE("res = %ld gle = %08lx url len = %ld\n", hres
, GetLastError(), len
);
499 last_read_pos
.s
.LowPart
= last_read_pos
.s
.HighPart
= 0;
504 fmt
.tymed
= TYMED_ISTREAM
;
505 stg
.tymed
= TYMED_ISTREAM
;
506 stg
.u
.pstm
= *(IStream
**)ppvObject
;
507 stg
.pUnkForRelease
= NULL
;
513 if(InternetReadFile(This
->hrequest
, buf
, sizeof(buf
), &bufread
)) {
514 TRACE("read %ld bytes %s...\n", bufread
, debugstr_an(buf
, 10));
515 if(bufread
== 0) break;
516 IStream_Write(*(IStream
**)ppvObject
, buf
, bufread
, &written
);
517 total_read
+= bufread
;
518 IStream_Seek(*(IStream
**)ppvObject
, last_read_pos
, STREAM_SEEK_SET
, NULL
);
519 hres
= IBindStatusCallback_OnProgress(pbscb
, total_read
, len
, (total_read
== bufread
) ?
520 BINDSTATUS_BEGINDOWNLOADDATA
:
521 BINDSTATUS_DOWNLOADINGDATA
, NULL
);
522 hres
= IBindStatusCallback_OnDataAvailable(pbscb
,
523 (total_read
== bufread
) ? BSCF_FIRSTDATANOTIFICATION
:
524 BSCF_INTERMEDIATEDATANOTIFICATION
,
525 total_read
, &fmt
, &stg
);
526 last_read_pos
.s
.LowPart
+= bufread
; /* FIXME */
530 hres
= IBindStatusCallback_OnProgress(pbscb
, total_read
, len
, BINDSTATUS_ENDDOWNLOADDATA
, NULL
);
531 hres
= IBindStatusCallback_OnDataAvailable(pbscb
, BSCF_LASTDATANOTIFICATION
, total_read
, &fmt
, &stg
);
532 TRACE("OnDataAvail rets %08lx\n", hres
);
533 hres
= IBindStatusCallback_OnStopBinding(pbscb
, S_OK
, NULL
);
534 TRACE("OnStop rets %08lx\n", hres
);
537 InternetCloseHandle(This
->hrequest
);
538 InternetCloseHandle(This
->hconnect
);
539 InternetCloseHandle(This
->hinternet
);
546 /******************************************************************************
548 ******************************************************************************/
549 static HRESULT WINAPI
URLMonikerImpl_Reduce(IMoniker
* iface
,
551 DWORD dwReduceHowFar
,
552 IMoniker
** ppmkToLeft
,
553 IMoniker
** ppmkReduced
)
555 ICOM_THIS(URLMonikerImpl
,iface
);
556 FIXME("(%p)->(%p,%ld,%p,%p): stub\n",This
,pbc
,dwReduceHowFar
,ppmkToLeft
,ppmkReduced
);
561 /******************************************************************************
562 * URLMoniker_ComposeWith
563 ******************************************************************************/
564 static HRESULT WINAPI
URLMonikerImpl_ComposeWith(IMoniker
* iface
,
566 BOOL fOnlyIfNotGeneric
,
567 IMoniker
** ppmkComposite
)
569 ICOM_THIS(URLMonikerImpl
,iface
);
570 FIXME("(%p)->(%p,%d,%p): stub\n",This
,pmkRight
,fOnlyIfNotGeneric
,ppmkComposite
);
575 /******************************************************************************
577 ******************************************************************************/
578 static HRESULT WINAPI
URLMonikerImpl_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
)
580 ICOM_THIS(URLMonikerImpl
,iface
);
581 FIXME("(%p)->(%d,%p): stub\n",This
,fForward
,ppenumMoniker
);
586 /******************************************************************************
588 ******************************************************************************/
589 static HRESULT WINAPI
URLMonikerImpl_IsEqual(IMoniker
* iface
,IMoniker
* pmkOtherMoniker
)
591 ICOM_THIS(URLMonikerImpl
,iface
);
592 FIXME("(%p)->(%p): stub\n",This
,pmkOtherMoniker
);
598 /******************************************************************************
600 ******************************************************************************/
601 static HRESULT WINAPI
URLMonikerImpl_Hash(IMoniker
* iface
,DWORD
* pdwHash
)
603 ICOM_THIS(URLMonikerImpl
,iface
);
604 FIXME("(%p)->(%p): stub\n",This
,pdwHash
);
609 /******************************************************************************
610 * URLMoniker_IsRunning
611 ******************************************************************************/
612 static HRESULT WINAPI
URLMonikerImpl_IsRunning(IMoniker
* iface
,
615 IMoniker
* pmkNewlyRunning
)
617 ICOM_THIS(URLMonikerImpl
,iface
);
618 FIXME("(%p)->(%p,%p,%p): stub\n",This
,pbc
,pmkToLeft
,pmkNewlyRunning
);
623 /******************************************************************************
624 * URLMoniker_GetTimeOfLastChange
625 ******************************************************************************/
626 static HRESULT WINAPI
URLMonikerImpl_GetTimeOfLastChange(IMoniker
* iface
,
631 ICOM_THIS(URLMonikerImpl
,iface
);
632 FIXME("(%p)->(%p,%p,%p): stub\n",This
,pbc
,pmkToLeft
,pFileTime
);
637 /******************************************************************************
639 ******************************************************************************/
640 static HRESULT WINAPI
URLMonikerImpl_Inverse(IMoniker
* iface
,IMoniker
** ppmk
)
642 ICOM_THIS(URLMonikerImpl
,iface
);
643 FIXME("(%p)->(%p): stub\n",This
,ppmk
);
648 /******************************************************************************
649 * URLMoniker_CommonPrefixWith
650 ******************************************************************************/
651 static HRESULT WINAPI
URLMonikerImpl_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
,IMoniker
** ppmkPrefix
)
653 ICOM_THIS(URLMonikerImpl
,iface
);
654 FIXME("(%p)->(%p,%p): stub\n",This
,pmkOther
,ppmkPrefix
);
659 /******************************************************************************
660 * URLMoniker_RelativePathTo
661 ******************************************************************************/
662 static HRESULT WINAPI
URLMonikerImpl_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
)
664 ICOM_THIS(URLMonikerImpl
,iface
);
665 FIXME("(%p)->(%p,%p): stub\n",This
,pmOther
,ppmkRelPath
);
670 /******************************************************************************
671 * URLMoniker_GetDisplayName
672 ******************************************************************************/
673 static HRESULT WINAPI
URLMonikerImpl_GetDisplayName(IMoniker
* iface
,
676 LPOLESTR
*ppszDisplayName
)
678 ICOM_THIS(URLMonikerImpl
,iface
);
679 FIXME("(%p)->(%p,%p,%p): stub\n",This
,pbc
,pmkToLeft
,ppszDisplayName
);
684 /******************************************************************************
685 * URLMoniker_ParseDisplayName
686 ******************************************************************************/
687 static HRESULT WINAPI
URLMonikerImpl_ParseDisplayName(IMoniker
* iface
,
690 LPOLESTR pszDisplayName
,
694 ICOM_THIS(URLMonikerImpl
,iface
);
695 FIXME("(%p)->(%p,%p,%p,%p,%p): stub\n",This
,pbc
,pmkToLeft
,pszDisplayName
,pchEaten
,ppmkOut
);
700 /******************************************************************************
701 * URLMoniker_IsSystemMoniker
702 ******************************************************************************/
703 static HRESULT WINAPI
URLMonikerImpl_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
)
705 ICOM_THIS(URLMonikerImpl
,iface
);
706 FIXME("(%p)->(%p)\n",This
,pwdMksys
);
711 static HRESULT WINAPI
URLMonikerImpl_IBinding_QueryInterface(IBinding
* iface
,REFIID riid
,void** ppvObject
)
713 ICOM_THIS_MULTI(URLMonikerImpl
, lpvtbl2
, iface
);
715 TRACE("(%p)->(%s,%p)\n",This
,debugstr_guid(riid
),ppvObject
);
717 /* Perform a sanity check on the parameters.*/
718 if ( (This
==0) || (ppvObject
==0) )
721 /* Initialize the return parameter */
724 /* Compare the riid with the interface IDs implemented by this object.*/
725 if (IsEqualIID(&IID_IUnknown
, riid
) || IsEqualIID(&IID_IBinding
, riid
))
728 /* Check that we obtained an interface.*/
730 return E_NOINTERFACE
;
732 /* Query Interface always increases the reference count by one when it is successful */
733 URLMonikerImpl_IBinding_AddRef(iface
);
739 static ULONG WINAPI
URLMonikerImpl_IBinding_AddRef(IBinding
* iface
)
741 ICOM_THIS_MULTI(URLMonikerImpl
, lpvtbl2
, iface
);
742 TRACE("(%p)\n",This
);
744 return URLMonikerImpl_AddRef((IMoniker
*)This
);
747 static ULONG WINAPI
URLMonikerImpl_IBinding_Release(IBinding
* iface
)
749 ICOM_THIS_MULTI(URLMonikerImpl
, lpvtbl2
, iface
);
750 TRACE("(%p)\n",This
);
752 return URLMonikerImpl_Release((IMoniker
*)This
);
755 static HRESULT WINAPI
URLMonikerImpl_IBinding_Abort(IBinding
* iface
)
757 ICOM_THIS_MULTI(URLMonikerImpl
, lpvtbl2
, iface
);
758 FIXME("(%p): stub\n", This
);
763 static HRESULT WINAPI
URLMonikerImpl_IBinding_GetBindResult(IBinding
* iface
, CLSID
* pclsidProtocol
, DWORD
* pdwResult
, LPOLESTR
* pszResult
, DWORD
* pdwReserved
)
765 ICOM_THIS_MULTI(URLMonikerImpl
, lpvtbl2
, iface
);
766 FIXME("(%p)->(%s, %p, %p, %p): stub\n", This
, debugstr_guid(pclsidProtocol
), pdwResult
, pszResult
, pdwReserved
);
771 static HRESULT WINAPI
URLMonikerImpl_IBinding_GetPriority(IBinding
* iface
, LONG
* pnPriority
)
773 ICOM_THIS_MULTI(URLMonikerImpl
, lpvtbl2
, iface
);
774 FIXME("(%p)->(%p): stub\n", This
, pnPriority
);
779 static HRESULT WINAPI
URLMonikerImpl_IBinding_Resume(IBinding
* iface
)
781 ICOM_THIS_MULTI(URLMonikerImpl
, lpvtbl2
, iface
);
782 FIXME("(%p): stub\n", This
);
787 static HRESULT WINAPI
URLMonikerImpl_IBinding_SetPriority(IBinding
* iface
, LONG nPriority
)
789 ICOM_THIS_MULTI(URLMonikerImpl
, lpvtbl2
, iface
);
790 FIXME("(%p)->(%ld): stub\n", This
, nPriority
);
795 static HRESULT WINAPI
URLMonikerImpl_IBinding_Suspend(IBinding
* iface
)
797 ICOM_THIS_MULTI(URLMonikerImpl
, lpvtbl2
, iface
);
798 FIXME("(%p): stub\n", This
);
803 /***********************************************************************
804 * CreateAsyncBindCtxEx (URLMON.@)
806 * Create an asynchronous bind context.
811 HRESULT WINAPI
CreateAsyncBindCtxEx(IBindCtx
*ibind
, DWORD options
,
812 IBindStatusCallback
*callback
, IEnumFORMATETC
*format
, IBindCtx
** pbind
,
815 FIXME("stub, returns failure\n");
820 /***********************************************************************
821 * CreateURLMoniker (URLMON.@)
823 * Create a url moniker.
826 * pmkContext [I] Context
827 * szURL [I] Url to create the moniker for
828 * ppmk [O] Destination for created moniker.
831 * Success: S_OK. ppmk contains the created IMoniker object.
832 * Failure: MK_E_SYNTAX if szURL is not a valid url, or
833 * E_OUTOFMEMORY if memory allocation fails.
835 HRESULT WINAPI
CreateURLMoniker(IMoniker
*pmkContext
, LPCWSTR szURL
, IMoniker
**ppmk
)
839 IID iid
= IID_IMoniker
;
841 TRACE("(%p, %s, %p)\n", pmkContext
, debugstr_w(szURL
), ppmk
);
843 if (NULL
!= pmkContext
)
844 FIXME("Non-null pmkContext not implemented\n");
846 if(!(obj
= HeapAlloc(GetProcessHeap(), 0, sizeof(*obj
))))
847 return E_OUTOFMEMORY
;
849 hres
= URLMonikerImpl_Construct(obj
, szURL
);
851 hres
= URLMonikerImpl_QueryInterface((IMoniker
*)obj
, &iid
, (void**)ppmk
);
853 HeapFree(GetProcessHeap(), 0, obj
);
858 /***********************************************************************
859 * CoInternetGetSession (URLMON.@)
861 * Create a new internet session and return an IInternetSession interface
865 * dwSessionMode [I] Mode for the internet session
866 * ppIInternetSession [O] Destination for creates IInternetSession object
867 * dwReserved [I] Reserved, must be 0.
870 * Success: S_OK. ppIInternetSession contains the IInternetSession interface.
871 * Failure: E_INVALIDARG, if any argument is invalid, or
872 * E_OUTOFMEMORY if memory allocation fails.
874 HRESULT WINAPI
CoInternetGetSession(DWORD dwSessionMode
, /*IInternetSession*/void **ppIInternetSession
, DWORD dwReserved
)
876 FIXME("(%ld, %p, %ld): stub\n", dwSessionMode
, ppIInternetSession
, dwReserved
);
879 ERR("dwSessionMode: %ld, must be zero\n", dwSessionMode
);
883 ERR("dwReserved: %ld, must be zero\n", dwReserved
);
886 *ppIInternetSession
=NULL
;
887 return E_OUTOFMEMORY
;
890 /***********************************************************************
891 * CoInternetQueryInfo (URLMON.@)
893 * Retrieves information relevant to a specified URL
897 * S_FALSE buffer too small
898 * INET_E_QUERYOPTIONUNKNOWN invalid option
901 HRESULT WINAPI
CoInternetQueryInfo(LPCWSTR pwzUrl
, QUERYOPTION QueryOption
,
902 DWORD dwQueryFlags
, LPVOID pvBuffer
, DWORD cbBuffer
, DWORD
* pcbBuffer
,
905 FIXME("(%s, %x, %lx, %p, %lx, %p, %lx): stub\n", debugstr_w(pwzUrl
),
906 QueryOption
, dwQueryFlags
, pvBuffer
, cbBuffer
, pcbBuffer
, dwReserved
);
910 /***********************************************************************
911 * FindMimeFromData (URLMON.@)
913 * Determines the Multipurpose Internet Mail Extensions (MIME) type from the data provided.
916 HRESULT WINAPI
FindMimeFromData(LPBC pBC
, LPCWSTR pwzUrl
, LPVOID pBuffer
,
917 DWORD cbSize
, LPCWSTR pwzMimeProposed
, DWORD dwMimeFlags
,
918 LPWSTR
* ppwzMimeOut
, DWORD dwReserved
)
921 return E_OUTOFMEMORY
;
924 /***********************************************************************
925 * RegisterBindStatusCallback (URLMON.@)
927 * Register a bind status callback.
930 * pbc [I] Binding context
931 * pbsc [I] Callback to register
932 * ppbscPrevious [O] Destination for previous callback
933 * dwReserved [I] Reserved, must be 0.
937 * Failure: E_INVALIDARG, if any argument is invalid, or
938 * E_OUTOFMEMORY if memory allocation fails.
940 HRESULT WINAPI
RegisterBindStatusCallback(
942 IBindStatusCallback
*pbsc
,
943 IBindStatusCallback
**ppbscPrevious
,
946 IBindStatusCallback
*prev
;
948 TRACE("(%p,%p,%p,%lu)\n", pbc
, pbsc
, ppbscPrevious
, dwReserved
);
950 if (pbc
== NULL
|| pbsc
== NULL
)
953 if (SUCCEEDED(IBindCtx_GetObjectParam(pbc
, BSCBHolder
, (IUnknown
**)&prev
)))
955 IBindCtx_RevokeObjectParam(pbc
, BSCBHolder
);
957 *ppbscPrevious
= prev
;
959 IBindStatusCallback_Release(prev
);
962 return IBindCtx_RegisterObjectParam(pbc
, BSCBHolder
, (IUnknown
*)pbsc
);
965 /***********************************************************************
966 * RevokeBindStatusCallback (URLMON.@)
968 * Unregister a bind status callback.
970 * pbc [I] Binding context
971 * pbsc [I] Callback to unregister
975 * Failure: E_INVALIDARG, if any argument is invalid, or
976 * E_FAIL if pbsc wasn't registered with pbc.
978 HRESULT WINAPI
RevokeBindStatusCallback(
980 IBindStatusCallback
*pbsc
)
982 IBindStatusCallback
*callback
;
985 TRACE("(%p,%p)\n", pbc
, pbsc
);
987 if (pbc
== NULL
|| pbsc
== NULL
)
990 if (SUCCEEDED(IBindCtx_GetObjectParam(pbc
, BSCBHolder
, (IUnknown
**)&callback
)))
992 if (callback
== pbsc
)
994 IBindCtx_RevokeObjectParam(pbc
, BSCBHolder
);
997 IBindStatusCallback_Release(pbsc
);
1003 /***********************************************************************
1004 * ReleaseBindInfo (URLMON.@)
1006 * Release the resources used by the specified BINDINFO structure.
1009 * pbindinfo [I] BINDINFO to release.
1014 void WINAPI
ReleaseBindInfo(BINDINFO
* pbindinfo
)
1016 FIXME("(%p)stub!\n", pbindinfo
);
1019 /***********************************************************************
1020 * URLDownloadToFileA (URLMON.@)
1022 * Downloads URL szURL to rile szFileName and call lpfnCB callback to
1026 * pCaller [I] controlling IUnknown interface.
1027 * szURL [I] URL of the file to download
1028 * szFileName [I] file name to store the content of the URL
1029 * dwReserved [I] reserved - set to 0
1030 * lpfnCB [I] callback for progress report
1034 * E_OUTOFMEMORY when going out of memory
1036 HRESULT WINAPI
URLDownloadToFileA(LPUNKNOWN pCaller
,
1040 LPBINDSTATUSCALLBACK lpfnCB
)
1042 UNICODE_STRING szURL_w
, szFileName_w
;
1044 if ((szURL
== NULL
) || (szFileName
== NULL
)) {
1045 FIXME("(%p,%s,%s,%08lx,%p) cannot accept NULL strings !\n", pCaller
, debugstr_a(szURL
), debugstr_a(szFileName
), dwReserved
, lpfnCB
);
1046 return E_INVALIDARG
; /* The error code is not specified in this case... */
1049 if (RtlCreateUnicodeStringFromAsciiz(&szURL_w
, szURL
)) {
1050 if (RtlCreateUnicodeStringFromAsciiz(&szFileName_w
, szFileName
)) {
1051 HRESULT ret
= URLDownloadToFileW(pCaller
, szURL_w
.Buffer
, szFileName_w
.Buffer
, dwReserved
, lpfnCB
);
1053 RtlFreeUnicodeString(&szURL_w
);
1054 RtlFreeUnicodeString(&szFileName_w
);
1058 RtlFreeUnicodeString(&szURL_w
);
1062 FIXME("(%p,%s,%s,%08lx,%p) could not allocate W strings !\n", pCaller
, szURL
, szFileName
, dwReserved
, lpfnCB
);
1063 return E_OUTOFMEMORY
;
1066 /***********************************************************************
1067 * URLDownloadToFileW (URLMON.@)
1069 * Downloads URL szURL to rile szFileName and call lpfnCB callback to
1073 * pCaller [I] controlling IUnknown interface.
1074 * szURL [I] URL of the file to download
1075 * szFileName [I] file name to store the content of the URL
1076 * dwReserved [I] reserved - set to 0
1077 * lpfnCB [I] callback for progress report
1081 * E_OUTOFMEMORY when going out of memory
1083 HRESULT WINAPI
URLDownloadToFileW(LPUNKNOWN pCaller
,
1087 LPBINDSTATUSCALLBACK lpfnCB
)
1089 HINTERNET hinternet
, hcon
, hreq
;
1091 CHAR buffer
[0x1000];
1092 DWORD sz
, total
, written
;
1093 DWORD total_size
= 0xFFFFFFFF, arg_size
= sizeof(total_size
);
1094 URL_COMPONENTSW url
;
1095 WCHAR host
[0x80], path
[0x100];
1097 WCHAR wszAppName
[]={'u','r','l','m','o','n','.','d','l','l',0};
1099 /* Note: all error codes would need to be checked agains real Windows behaviour... */
1100 TRACE("(%p,%s,%s,%08lx,%p) stub!\n", pCaller
, debugstr_w(szURL
), debugstr_w(szFileName
), dwReserved
, lpfnCB
);
1102 if ((szURL
== NULL
) || (szFileName
== NULL
)) {
1103 FIXME(" cannot accept NULL strings !\n");
1104 return E_INVALIDARG
;
1107 /* Would be better to use the application name here rather than 'urlmon' :-/ */
1108 hinternet
= InternetOpenW(wszAppName
, INTERNET_OPEN_TYPE_PRECONFIG
, NULL
, NULL
, 0);
1109 if (hinternet
== NULL
) {
1110 return E_OUTOFMEMORY
;
1113 memset(&url
, 0, sizeof(url
));
1114 url
.dwStructSize
= sizeof(url
);
1115 url
.lpszHostName
= host
;
1116 url
.dwHostNameLength
= sizeof(host
);
1117 url
.lpszUrlPath
= path
;
1118 url
.dwUrlPathLength
= sizeof(path
);
1120 if (!InternetCrackUrlW(szURL
, 0, 0, &url
)) {
1121 InternetCloseHandle(hinternet
);
1122 return E_OUTOFMEMORY
;
1126 if (IBindStatusCallback_OnProgress(lpfnCB
, 0, 0, BINDSTATUS_CONNECTING
, url
.lpszHostName
) == E_ABORT
) {
1127 InternetCloseHandle(hinternet
);
1132 hcon
= InternetConnectW(hinternet
, url
.lpszHostName
, url
.nPort
,
1133 url
.lpszUserName
, url
.lpszPassword
,
1134 INTERNET_SERVICE_HTTP
, 0, 0);
1136 InternetCloseHandle(hinternet
);
1137 return E_OUTOFMEMORY
;
1140 hreq
= HttpOpenRequestW(hcon
, NULL
, url
.lpszUrlPath
, NULL
, NULL
, NULL
, 0, 0);
1142 InternetCloseHandle(hinternet
);
1143 InternetCloseHandle(hcon
);
1144 return E_OUTOFMEMORY
;
1147 if (!HttpSendRequestW(hreq
, NULL
, 0, NULL
, 0)) {
1148 InternetCloseHandle(hinternet
);
1149 InternetCloseHandle(hcon
);
1150 InternetCloseHandle(hreq
);
1151 return E_OUTOFMEMORY
;
1154 if (HttpQueryInfoW(hreq
, HTTP_QUERY_CONTENT_LENGTH
| HTTP_QUERY_FLAG_NUMBER
,
1155 &total_size
, &arg_size
, NULL
)) {
1156 TRACE(" total size : %ld\n", total_size
);
1159 hfile
= CreateFileW(szFileName
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
1160 FILE_ATTRIBUTE_NORMAL
, NULL
);
1161 if (hfile
== INVALID_HANDLE_VALUE
) {
1162 return E_ACCESSDENIED
;
1166 if (IBindStatusCallback_OnProgress(lpfnCB
, 0, total_size
!= 0xFFFFFFFF ? total_size
: 0,
1167 BINDSTATUS_BEGINDOWNLOADDATA
, szURL
) == E_ABORT
) {
1168 InternetCloseHandle(hreq
);
1169 InternetCloseHandle(hcon
);
1170 InternetCloseHandle(hinternet
);
1178 r
= InternetReadFile(hreq
, buffer
, sizeof(buffer
), &sz
);
1180 InternetCloseHandle(hreq
);
1181 InternetCloseHandle(hcon
);
1182 InternetCloseHandle(hinternet
);
1185 return E_OUTOFMEMORY
;
1193 if (IBindStatusCallback_OnProgress(lpfnCB
, total
, total_size
!= 0xFFFFFFFF ? total_size
: 0,
1194 BINDSTATUS_DOWNLOADINGDATA
, szURL
) == E_ABORT
) {
1195 InternetCloseHandle(hreq
);
1196 InternetCloseHandle(hcon
);
1197 InternetCloseHandle(hinternet
);
1203 if (!WriteFile(hfile
, buffer
, sz
, &written
, NULL
)) {
1204 InternetCloseHandle(hreq
);
1205 InternetCloseHandle(hcon
);
1206 InternetCloseHandle(hinternet
);
1209 return E_OUTOFMEMORY
;
1214 if (IBindStatusCallback_OnProgress(lpfnCB
, total
, total_size
!= 0xFFFFFFFF ? total_size
: 0,
1215 BINDSTATUS_ENDDOWNLOADDATA
, szURL
) == E_ABORT
) {
1216 InternetCloseHandle(hreq
);
1217 InternetCloseHandle(hcon
);
1218 InternetCloseHandle(hinternet
);
1224 InternetCloseHandle(hreq
);
1225 InternetCloseHandle(hcon
);
1226 InternetCloseHandle(hinternet
);