ReactOS 0.4.15-dev-8222-g9164419
umstream.c File Reference
#include "urlmon_main.h"
#include "winreg.h"
#include "wine/winternl.h"
#include "wininet.h"
#include "shlwapi.h"
#include "wine/debug.h"
Include dependency graph for umstream.c:

Go to the source code of this file.

Classes

struct  ProxyBindStatusCallback
 

Typedefs

typedef struct ProxyBindStatusCallback ProxyBindStatusCallback
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (urlmon)
 
static ProxyBindStatusCallbackimpl_from_IBindStatusCallback (IBindStatusCallback *iface)
 
static HRESULT WINAPI ProxyBindStatusCallback_QueryInterface (IBindStatusCallback *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI ProxyBindStatusCallback_AddRef (IBindStatusCallback *iface)
 
static ULONG WINAPI ProxyBindStatusCallback_Release (IBindStatusCallback *iface)
 
static HRESULT WINAPI ProxyBindStatusCallback_OnStartBinding (IBindStatusCallback *iface, DWORD dwReserved, IBinding *pib)
 
static HRESULT WINAPI ProxyBindStatusCallback_GetPriority (IBindStatusCallback *iface, LONG *pnPriority)
 
static HRESULT WINAPI ProxyBindStatusCallback_OnLowResource (IBindStatusCallback *iface, DWORD reserved)
 
static HRESULT WINAPI ProxyBindStatusCallback_OnProgress (IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
 
static HRESULT WINAPI ProxyBindStatusCallback_OnStopBinding (IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
 
static HRESULT WINAPI ProxyBindStatusCallback_GetBindInfo (IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
 
static HRESULT WINAPI ProxyBindStatusCallback_OnDataAvailable (IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
 
static HRESULT WINAPI ProxyBindStatusCallback_OnObjectAvailable (IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
 
static HRESULT WINAPI BlockingBindStatusCallback_OnDataAvailable (IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
 
static HRESULT WINAPI AsyncBindStatusCallback_GetBindInfo (IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
 
static HRESULT URLStartDownload (LPCWSTR szURL, LPSTREAM *ppStream, IBindStatusCallback *pBSC)
 
HRESULT WINAPI URLOpenBlockingStreamA (LPUNKNOWN pCaller, LPCSTR szURL, LPSTREAM *ppStream, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB)
 
HRESULT WINAPI URLOpenBlockingStreamW (LPUNKNOWN pCaller, LPCWSTR szURL, LPSTREAM *ppStream, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB)
 
HRESULT WINAPI URLOpenStreamA (LPUNKNOWN pCaller, LPCSTR szURL, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB)
 
HRESULT WINAPI URLOpenStreamW (LPUNKNOWN pCaller, LPCWSTR szURL, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB)
 

Variables

static const IBindStatusCallbackVtbl BlockingBindStatusCallbackVtbl
 
static const IBindStatusCallbackVtbl AsyncBindStatusCallbackVtbl
 

Typedef Documentation

◆ ProxyBindStatusCallback

Function Documentation

◆ AsyncBindStatusCallback_GetBindInfo()

static HRESULT WINAPI AsyncBindStatusCallback_GetBindInfo ( IBindStatusCallback iface,
DWORD grfBINDF,
BINDINFO *  pbindinfo 
)
static

Definition at line 182 of file umstream.c.

183{
185 HRESULT hr = S_OK;
186
187 if(This->pBSC)
188 hr = IBindStatusCallback_GetBindInfo(This->pBSC, grfBINDF, pbindinfo);
189 else{
190 DWORD size = pbindinfo->cbSize;
191 memset(pbindinfo, 0, size);
192 pbindinfo->cbSize = size;
193
194 *grfBINDF = 0;
195 }
196
197 *grfBINDF |= BINDF_PULLDATA | BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE;
198
199 return hr;
200}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
#define S_OK
Definition: intsafe.h:52
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
static ProxyBindStatusCallback * impl_from_IBindStatusCallback(IBindStatusCallback *iface)
Definition: umstream.c:40

◆ BlockingBindStatusCallback_OnDataAvailable()

static HRESULT WINAPI BlockingBindStatusCallback_OnDataAvailable ( IBindStatusCallback iface,
DWORD  grfBSCF,
DWORD  dwSize,
FORMATETC *  pformatetc,
STGMEDIUM *  pstgmed 
)
static

Definition at line 161 of file umstream.c.

163{
164 return S_OK;
165}

◆ impl_from_IBindStatusCallback()

◆ ProxyBindStatusCallback_AddRef()

static ULONG WINAPI ProxyBindStatusCallback_AddRef ( IBindStatusCallback iface)
static

Definition at line 59 of file umstream.c.

60{
61 return 2;
62}

◆ ProxyBindStatusCallback_GetBindInfo()

static HRESULT WINAPI ProxyBindStatusCallback_GetBindInfo ( IBindStatusCallback iface,
DWORD grfBINDF,
BINDINFO *  pbindinfo 
)
static

Definition at line 123 of file umstream.c.

124{
125 DWORD size = pbindinfo->cbSize;
127
128 if(This->pBSC)
129 return IBindStatusCallback_GetBindInfo(This->pBSC, grfBINDF, pbindinfo);
130
131 memset(pbindinfo, 0, size);
132 pbindinfo->cbSize = size;
133
134 *grfBINDF = 0;
135
136 return S_OK;
137}

◆ ProxyBindStatusCallback_GetPriority()

static HRESULT WINAPI ProxyBindStatusCallback_GetPriority ( IBindStatusCallback iface,
LONG pnPriority 
)
static

Definition at line 80 of file umstream.c.

81{
83
84 if(This->pBSC)
85 return IBindStatusCallback_GetPriority(This->pBSC, pnPriority);
86
87 return S_OK;
88}

◆ ProxyBindStatusCallback_OnDataAvailable()

static HRESULT WINAPI ProxyBindStatusCallback_OnDataAvailable ( IBindStatusCallback iface,
DWORD  grfBSCF,
DWORD  dwSize,
FORMATETC *  pformatetc,
STGMEDIUM *  pstgmed 
)
static

Definition at line 139 of file umstream.c.

141{
143
144 if(This->pBSC)
145 return IBindStatusCallback_OnDataAvailable(This->pBSC, grfBSCF, dwSize,
146 pformatetc, pstgmed);
147
148 return S_OK;
149}
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

◆ ProxyBindStatusCallback_OnLowResource()

static HRESULT WINAPI ProxyBindStatusCallback_OnLowResource ( IBindStatusCallback iface,
DWORD  reserved 
)
static

Definition at line 90 of file umstream.c.

91{
93
94 if(This->pBSC)
95 return IBindStatusCallback_OnLowResource(This->pBSC, reserved);
96
97 return S_OK;
98}
r reserved
Definition: btrfs.c:3006

◆ ProxyBindStatusCallback_OnObjectAvailable()

static HRESULT WINAPI ProxyBindStatusCallback_OnObjectAvailable ( IBindStatusCallback iface,
REFIID  riid,
IUnknown punk 
)
static

Definition at line 151 of file umstream.c.

152{
154
155 if(This->pBSC)
156 return IBindStatusCallback_OnObjectAvailable(This->pBSC, riid, punk);
157
158 return S_OK;
159}
REFIID riid
Definition: atlbase.h:39

◆ ProxyBindStatusCallback_OnProgress()

static HRESULT WINAPI ProxyBindStatusCallback_OnProgress ( IBindStatusCallback iface,
ULONG  ulProgress,
ULONG  ulProgressMax,
ULONG  ulStatusCode,
LPCWSTR  szStatusText 
)
static

Definition at line 100 of file umstream.c.

102{
104
105 if(This->pBSC)
106 return IBindStatusCallback_OnProgress(This->pBSC, ulProgress,
107 ulProgressMax, ulStatusCode,
108 szStatusText);
109
110 return S_OK;
111}

◆ ProxyBindStatusCallback_OnStartBinding()

static HRESULT WINAPI ProxyBindStatusCallback_OnStartBinding ( IBindStatusCallback iface,
DWORD  dwReserved,
IBinding pib 
)
static

Definition at line 69 of file umstream.c.

71{
73
74 if(This->pBSC)
75 return IBindStatusCallback_OnStartBinding(This->pBSC, dwReserved, pib);
76
77 return S_OK;
78}
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95

◆ ProxyBindStatusCallback_OnStopBinding()

static HRESULT WINAPI ProxyBindStatusCallback_OnStopBinding ( IBindStatusCallback iface,
HRESULT  hresult,
LPCWSTR  szError 
)
static

Definition at line 113 of file umstream.c.

114{
116
117 if(This->pBSC)
118 return IBindStatusCallback_OnStopBinding(This->pBSC, hresult, szError);
119
120 return S_OK;
121}

◆ ProxyBindStatusCallback_QueryInterface()

static HRESULT WINAPI ProxyBindStatusCallback_QueryInterface ( IBindStatusCallback iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 45 of file umstream.c.

46{
47 if (IsEqualGUID(&IID_IBindStatusCallback, riid) ||
49 {
50 *ppv = iface;
51 IBindStatusCallback_AddRef(iface);
52 return S_OK;
53 }
54
55 *ppv = NULL;
56 return E_NOINTERFACE;
57}
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ ProxyBindStatusCallback_Release()

static ULONG WINAPI ProxyBindStatusCallback_Release ( IBindStatusCallback iface)
static

Definition at line 64 of file umstream.c.

65{
66 return 1;
67}

◆ URLOpenBlockingStreamA()

HRESULT WINAPI URLOpenBlockingStreamA ( LPUNKNOWN  pCaller,
LPCSTR  szURL,
LPSTREAM ppStream,
DWORD  dwReserved,
LPBINDSTATUSCALLBACK  lpfnCB 
)

Definition at line 258 of file umstream.c.

261{
262 LPWSTR szURLW;
263 int len;
264 HRESULT hr;
265
266 TRACE("(%p, %s, %p, 0x%x, %p)\n", pCaller, szURL, ppStream, dwReserved, lpfnCB);
267
268 if (!szURL || !ppStream)
269 return E_INVALIDARG;
270
271 len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0);
272 szURLW = heap_alloc(len * sizeof(WCHAR));
273 if (!szURLW)
274 {
275 *ppStream = NULL;
276 return E_OUTOFMEMORY;
277 }
278 MultiByteToWideChar(CP_ACP, 0, szURL, -1, szURLW, len);
279
280 hr = URLOpenBlockingStreamW(pCaller, szURLW, ppStream, dwReserved, lpfnCB);
281
282 heap_free(szURLW);
283
284 return hr;
285}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI URLOpenBlockingStreamW(LPUNKNOWN pCaller, LPCWSTR szURL, LPSTREAM *ppStream, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB)
Definition: umstream.c:290
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ URLOpenBlockingStreamW()

HRESULT WINAPI URLOpenBlockingStreamW ( LPUNKNOWN  pCaller,
LPCWSTR  szURL,
LPSTREAM ppStream,
DWORD  dwReserved,
LPBINDSTATUSCALLBACK  lpfnCB 
)

Definition at line 290 of file umstream.c.

293{
294 ProxyBindStatusCallback blocking_bsc;
295
296 TRACE("(%p, %s, %p, 0x%x, %p)\n", pCaller, debugstr_w(szURL), ppStream,
297 dwReserved, lpfnCB);
298
299 if (!szURL || !ppStream)
300 return E_INVALIDARG;
301
303 blocking_bsc.pBSC = lpfnCB;
304
305 return URLStartDownload(szURL, ppStream, &blocking_bsc.IBindStatusCallback_iface);
306}
#define debugstr_w
Definition: kernel32.h:32
IBindStatusCallback IBindStatusCallback_iface
Definition: umstream.c:35
IBindStatusCallback * pBSC
Definition: umstream.c:37
static HRESULT URLStartDownload(LPCWSTR szURL, LPSTREAM *ppStream, IBindStatusCallback *pBSC)
Definition: umstream.c:217
static const IBindStatusCallbackVtbl BlockingBindStatusCallbackVtbl
Definition: umstream.c:167

Referenced by test_URLOpenBlockingStreamW(), and URLOpenBlockingStreamA().

◆ URLOpenStreamA()

HRESULT WINAPI URLOpenStreamA ( LPUNKNOWN  pCaller,
LPCSTR  szURL,
DWORD  dwReserved,
LPBINDSTATUSCALLBACK  lpfnCB 
)

Definition at line 311 of file umstream.c.

313{
314 LPWSTR szURLW;
315 int len;
316 HRESULT hr;
317
318 TRACE("(%p, %s, 0x%x, %p)\n", pCaller, szURL, dwReserved, lpfnCB);
319
320 if (!szURL)
321 return E_INVALIDARG;
322
323 len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0);
324 szURLW = heap_alloc(len * sizeof(WCHAR));
325 if (!szURLW)
326 return E_OUTOFMEMORY;
327 MultiByteToWideChar(CP_ACP, 0, szURL, -1, szURLW, len);
328
329 hr = URLOpenStreamW(pCaller, szURLW, dwReserved, lpfnCB);
330
331 heap_free(szURLW);
332
333 return hr;
334}
HRESULT WINAPI URLOpenStreamW(LPUNKNOWN pCaller, LPCWSTR szURL, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB)
Definition: umstream.c:339

◆ URLOpenStreamW()

HRESULT WINAPI URLOpenStreamW ( LPUNKNOWN  pCaller,
LPCWSTR  szURL,
DWORD  dwReserved,
LPBINDSTATUSCALLBACK  lpfnCB 
)

Definition at line 339 of file umstream.c.

341{
342 HRESULT hr;
343 ProxyBindStatusCallback async_bsc;
344 IStream *pStream;
345
346 TRACE("(%p, %s, 0x%x, %p)\n", pCaller, debugstr_w(szURL), dwReserved,
347 lpfnCB);
348
349 if (!szURL)
350 return E_INVALIDARG;
351
353 async_bsc.pBSC = lpfnCB;
354
355 hr = URLStartDownload(szURL, &pStream, &async_bsc.IBindStatusCallback_iface);
356 if (SUCCEEDED(hr) && pStream)
357 IStream_Release(pStream);
358
359 return hr;
360}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static const IBindStatusCallbackVtbl AsyncBindStatusCallbackVtbl
Definition: umstream.c:202

Referenced by test_URLOpenStreamW(), and URLOpenStreamA().

◆ URLStartDownload()

static HRESULT URLStartDownload ( LPCWSTR  szURL,
LPSTREAM ppStream,
IBindStatusCallback pBSC 
)
static

Definition at line 217 of file umstream.c.

218{
219 HRESULT hr;
220 IMoniker *pMoniker;
221 IBindCtx *pbc;
222
223 *ppStream = NULL;
224
225 hr = CreateURLMoniker(NULL, szURL, &pMoniker);
226 if (FAILED(hr))
227 return hr;
228
229 hr = CreateBindCtx(0, &pbc);
230 if (FAILED(hr))
231 {
232 IMoniker_Release(pMoniker);
233 return hr;
234 }
235
236 hr = RegisterBindStatusCallback(pbc, pBSC, NULL, 0);
237 if (FAILED(hr))
238 {
239 IBindCtx_Release(pbc);
240 IMoniker_Release(pMoniker);
241 return hr;
242 }
243
244 hr = IMoniker_BindToStorage(pMoniker, pbc, NULL, &IID_IStream, (void **)ppStream);
245
246 /* BindToStorage returning E_PENDING because it's asynchronous is not an error */
247 if (hr == E_PENDING) hr = S_OK;
248
249 IBindCtx_Release(pbc);
250 IMoniker_Release(pMoniker);
251
252 return hr;
253}
#define E_PENDING
Definition: dinput.h:172
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556
HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk)
Definition: umon.c:732
HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc, IBindStatusCallback **ppbscPrevious, DWORD dwReserved)
Definition: bindctx.c:615

Referenced by URLOpenBlockingStreamW(), and URLOpenStreamW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( urlmon  )

Variable Documentation

◆ AsyncBindStatusCallbackVtbl

const IBindStatusCallbackVtbl AsyncBindStatusCallbackVtbl
static
Initial value:
=
{
}
static HRESULT WINAPI ProxyBindStatusCallback_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved, IBinding *pib)
Definition: umstream.c:69
static HRESULT WINAPI ProxyBindStatusCallback_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
Definition: umstream.c:113
static HRESULT WINAPI ProxyBindStatusCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
Definition: umstream.c:100
static HRESULT WINAPI ProxyBindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
Definition: umstream.c:90
static ULONG WINAPI ProxyBindStatusCallback_AddRef(IBindStatusCallback *iface)
Definition: umstream.c:59
static HRESULT WINAPI ProxyBindStatusCallback_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
Definition: umstream.c:80
static ULONG WINAPI ProxyBindStatusCallback_Release(IBindStatusCallback *iface)
Definition: umstream.c:64
static HRESULT WINAPI ProxyBindStatusCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
Definition: umstream.c:139
static HRESULT WINAPI ProxyBindStatusCallback_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv)
Definition: umstream.c:45
static HRESULT WINAPI ProxyBindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
Definition: umstream.c:151
static HRESULT WINAPI AsyncBindStatusCallback_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
Definition: umstream.c:182

Definition at line 202 of file umstream.c.

Referenced by URLOpenStreamW().

◆ BlockingBindStatusCallbackVtbl

const IBindStatusCallbackVtbl BlockingBindStatusCallbackVtbl
static
Initial value:
=
{
}
static HRESULT WINAPI BlockingBindStatusCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
Definition: umstream.c:161
static HRESULT WINAPI ProxyBindStatusCallback_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
Definition: umstream.c:123

Definition at line 167 of file umstream.c.

Referenced by URLOpenBlockingStreamW().