ReactOS  0.4.13-dev-563-g0561610
urlmon_main.h
Go to the documentation of this file.
1 /*
2  * Copyright 2002 Huw D M Davies for CodeWeavers
3  * Copyright 2009 Jacek Caban for CodeWeavers
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19 
20 #ifndef __WINE_URLMON_MAIN_H
21 #define __WINE_URLMON_MAIN_H
22 
23 #include <stdarg.h>
24 
25 #define COBJMACROS
26 
27 #ifdef __REACTOS__
28 #define PROXY_CLSID_IS {0x79EAC9F1,0xBAF9,0x11CE,{0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B}}
29 #endif
30 
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "ole2.h"
35 #include "urlmon.h"
36 #include "wininet.h"
37 
38 #include "wine/unicode.h"
39 #include "wine/heap.h"
40 #include "wine/list.h"
41 
42 extern HINSTANCE hProxyDll DECLSPEC_HIDDEN;
53 extern HRESULT Uri_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
54 
59 
60 extern GUID const CLSID_PSFactoryBuffer DECLSPEC_HIDDEN;
61 extern GUID const CLSID_CUri DECLSPEC_HIDDEN;
62 
63 /**********************************************************************
64  * Dll lifetime tracking declaration for urlmon.dll
65  */
67 static inline void URLMON_LockModule(void) { InterlockedIncrement( &URLMON_refCount ); }
68 static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_refCount ); }
69 
71 
80 void free_session(void) DECLSPEC_HIDDEN;
81 
83 
86 
90 
91 typedef HRESULT (*stop_cache_binding_proc_t)(void*,const WCHAR*,HRESULT,const WCHAR*);
93 
94 typedef struct ProtocolVtbl ProtocolVtbl;
95 
96 typedef struct {
98 
101 
103  BINDINFO bind_info;
104 
109 
114 
116 
118 } Protocol;
119 
120 struct ProtocolVtbl {
126 };
127 
128 /* Flags are needed for, among other things, return HRESULTs from the Read function
129  * to conform to native. For example, Read returns:
130  *
131  * 1. E_PENDING if called before the request has completed,
132  * (flags = 0)
133  * 2. S_FALSE after all data has been read and S_OK has been reported,
134  * (flags = FLAG_REQUEST_COMPLETE | FLAG_ALL_DATA_READ | FLAG_RESULT_REPORTED)
135  * 3. INET_E_DATA_NOT_AVAILABLE if InternetQueryDataAvailable fails. The first time
136  * this occurs, INET_E_DATA_NOT_AVAILABLE will also be reported to the sink,
137  * (flags = FLAG_REQUEST_COMPLETE)
138  * but upon subsequent calls to Read no reporting will take place, yet
139  * InternetQueryDataAvailable will still be called, and, on failure,
140  * INET_E_DATA_NOT_AVAILABLE will still be returned.
141  * (flags = FLAG_REQUEST_COMPLETE | FLAG_RESULT_REPORTED)
142  *
143  * FLAG_FIRST_DATA_REPORTED and FLAG_LAST_DATA_REPORTED are needed for proper
144  * ReportData reporting. For example, if OnResponse returns S_OK, Continue will
145  * report BSCF_FIRSTDATANOTIFICATION, and when all data has been read Read will
146  * report BSCF_INTERMEDIATEDATANOTIFICATION|BSCF_LASTDATANOTIFICATION. However,
147  * if OnResponse does not return S_OK, Continue will not report data, and Read
148  * will report BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION when all
149  * data has been read.
150  */
151 #define FLAG_REQUEST_COMPLETE 0x0001
152 #define FLAG_FIRST_CONTINUE_COMPLETE 0x0002
153 #define FLAG_FIRST_DATA_REPORTED 0x0004
154 #define FLAG_ALL_DATA_READ 0x0008
155 #define FLAG_LAST_DATA_REPORTED 0x0010
156 #define FLAG_RESULT_REPORTED 0x0020
157 #define FLAG_ERROR 0x0040
158 #define FLAG_SYNC_READ 0x0080
159 
168 
170 
172 
173 typedef struct {
179 
181 
184 
189 
190  struct {
192  IInternetProtocolSink IInternetProtocolSink_iface;
193  } default_protocol_handler;
196 
198 
202 
206 
210 
212  task_header_t *task_queue_head, *task_queue_tail;
213 
219 } BindProtocol;
220 
223 
224 typedef struct {
227 
228  struct list entry;
229 } tls_data_t;
230 
232 
236 
238 
239 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t size)
240 {
242 }
243 
245 {
246  LPWSTR ret = NULL;
247 
248  if(str) {
249  DWORD size;
250 
251  size = (strlenW(str)+1)*sizeof(WCHAR);
252  ret = heap_alloc(size);
253  if(ret)
254  memcpy(ret, str, size);
255  }
256 
257  return ret;
258 }
259 
260 static inline LPWSTR heap_strndupW(LPCWSTR str, int len)
261 {
262  LPWSTR ret = NULL;
263 
264  if(str) {
265  ret = heap_alloc((len+1)*sizeof(WCHAR));
266  if(ret) {
267  memcpy(ret, str, len*sizeof(WCHAR));
268  ret[len] = 0;
269  }
270  }
271 
272  return ret;
273 }
274 
275 static inline LPWSTR heap_strdupAtoW(const char *str)
276 {
277  LPWSTR ret = NULL;
278 
279  if(str) {
280  DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
281  ret = heap_alloc(len*sizeof(WCHAR));
282  if(ret)
283  MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
284  }
285 
286  return ret;
287 }
288 
289 static inline char *heap_strdupWtoA(const WCHAR *str)
290 {
291  char *ret = NULL;
292 
293  if(str) {
294  size_t size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
295  ret = heap_alloc(size);
296  if(ret)
298  }
299 
300  return ret;
301 }
302 
303 #endif /* __WINE_URLMON_MAIN_H */
HRESULT protocol_read(Protocol *, void *, ULONG, ULONG *) DECLSPEC_HIDDEN
Definition: protocol.c:423
HRESULT get_protocol_handler(IUri *, CLSID *, IClassFactory **) DECLSPEC_HIDDEN
Definition: session.c:220
ULONG content_length
Definition: urlmon_main.h:111
void set_binding_sink(BindProtocol *, IInternetProtocolSink *, IInternetBindInfo *) DECLSPEC_HIDDEN
Definition: bindprot.c:560
#define HRESULT
Definition: msvc.h:9
HRESULT WINAPI URLMON_DllRegisterServer(void) DECLSPEC_HIDDEN
HRESULT protocol_unlock_request(Protocol *) DECLSPEC_HIDDEN
Definition: protocol.c:506
LPVOID HINTERNET
Definition: winhttp.h:32
#define REFIID
Definition: guiddef.h:113
LONG priority
Definition: urlmon_main.h:117
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
BINDINFO bind_info
Definition: urlmon_main.h:103
IInternetProtocolSink * protocol_sink_handler
Definition: urlmon_main.h:195
#define WideCharToMultiByte
Definition: compat.h:101
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HRESULT protocol_lock_request(Protocol *) DECLSPEC_HIDDEN
Definition: protocol.c:498
HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
HRESULT(* end_request)(Protocol *)
Definition: urlmon_main.h:122
HWND notif_hwnd
Definition: urlmon_main.h:225
#define REFCLSID
Definition: guiddef.h:112
#define CP_ACP
Definition: compat.h:99
void free_session(void) DECLSPEC_HIDDEN
Definition: session.c:755
HRESULT download_to_cache(IUri *, stop_cache_binding_proc_t, void *, IBindStatusCallback *) DECLSPEC_HIDDEN
Definition: download.c:375
_In_ USHORT _In_ ULONG Protocol
Definition: wsk.h:182
REFIID LPVOID * ppv
Definition: atlbase.h:39
static LPWSTR heap_strndupW(LPCWSTR str, int len)
Definition: urlmon_main.h:260
HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
Definition: sec_mgr.c:1827
HRESULT create_default_callback(IBindStatusCallback **) DECLSPEC_HIDDEN
Definition: download.c:361
IInternetProtocol * protocol
Definition: urlmon_main.h:99
OLECHAR * BSTR
Definition: compat.h:1934
IInternetBindInfo IInternetBindInfo_iface
Definition: urlmon_main.h:175
IServiceProvider IServiceProvider_iface
Definition: urlmon_main.h:177
ULONG progress
Definition: urlmon_main.h:204
DWORD bindf
Definition: urlmon_main.h:102
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:56
IInternetPriority IInternetPriority_iface
Definition: urlmon_main.h:176
ULONG current_position
Definition: urlmon_main.h:110
static IN DWORD IN LPVOID lpvReserved
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
BSTR display_uri
Definition: urlmon_main.h:218
HINTERNET request
Definition: urlmon_main.h:105
DWORD flags
Definition: urlmon_main.h:107
LONG URLMON_refCount
Definition: urlmon_main.c:42
ULONG available_bytes
Definition: urlmon_main.h:112
HRESULT protocol_abort(Protocol *, HRESULT) DECLSPEC_HIDDEN
Definition: protocol.c:518
HRESULT(* stop_cache_binding_proc_t)(void *, const WCHAR *, HRESULT, const WCHAR *)
Definition: urlmon_main.h:91
HRESULT(* start_downloading)(Protocol *)
Definition: urlmon_main.h:123
HRESULT MimeFilter_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
Definition: mimefilter.c:246
const ProtocolVtbl * vtbl
Definition: urlmon_main.h:97
HRESULT StdURLMoniker_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
DWORD continue_call
Definition: urlmon_main.h:209
HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
unsigned int BOOL
Definition: ntddk_ex.h:94
IInternetProtocolInfo * get_protocol_info(LPCWSTR) DECLSPEC_HIDDEN
Definition: session.c:181
long LONG
Definition: pedump.c:60
HRESULT Uri_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
Definition: uri.c:5657
void(* close_connection)(Protocol *)
Definition: urlmon_main.h:124
HRESULT bind_to_object(IMoniker *, IUri *, IBindCtx *, REFIID, void **ppv) DECLSPEC_HIDDEN
Definition: binding.c:1646
BOOL is_registered_protocol(LPCWSTR) DECLSPEC_HIDDEN
Definition: session.c:168
void unregister_notif_wnd_class(void) DECLSPEC_HIDDEN
Definition: bindprot.c:105
const WCHAR * str
IInternetProtocol IInternetProtocol_iface
Definition: urlmon_main.h:191
smooth NULL
Definition: ftsmooth.c:416
HINSTANCE hProxyDll DECLSPEC_HIDDEN
Definition: urlmon_main.h:60
BOOL WINAPI URLMON_DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DECLSPEC_HIDDEN
HRESULT WINAPI URLMON_DllUnregisterServer(void) DECLSPEC_HIDDEN
void release_notif_hwnd(HWND) DECLSPEC_HIDDEN
Definition: bindprot.c:141
BOOL reported_mime
Definition: urlmon_main.h:200
HANDLE lock
Definition: urlmon_main.h:108
void find_domain_name(const WCHAR *, DWORD, INT *) DECLSPEC_HIDDEN
Definition: uri.c:519
HINTERNET connection
Definition: urlmon_main.h:106
HRESULT bind_to_storage(IUri *, IBindCtx *, REFIID, void **) DECLSPEC_HIDDEN
Definition: binding.c:1617
HRESULT protocol_syncbinding(Protocol *) DECLSPEC_HIDDEN
Definition: protocol.c:101
void(* on_error)(Protocol *, DWORD)
Definition: urlmon_main.h:125
HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
static void URLMON_UnlockModule(void)
Definition: urlmon_main.h:68
IInternetProtocolSink * protocol_sink
Definition: urlmon_main.h:186
GLsizeiptr size
Definition: glext.h:5919
HRESULT wrap_callback(IBindStatusCallback *, IBindStatusCallback **) DECLSPEC_HIDDEN
Definition: bindctx.c:578
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
HRESULT create_binding_protocol(BindProtocol **) DECLSPEC_HIDDEN
Definition: bindprot.c:1435
BOOL reported_result
Definition: urlmon_main.h:199
IInternetProtocolSink * protocol_sink
Definition: urlmon_main.h:100
IInternetProtocol * get_mime_filter(LPCWSTR) DECLSPEC_HIDDEN
Definition: session.c:250
HWND get_notif_hwnd(void) DECLSPEC_HIDDEN
Definition: bindprot.c:111
IBindCallbackRedirect * redirect_callback
Definition: urlmon_main.h:188
#define WINAPI
Definition: msvc.h:8
task_header_t * task_queue_tail
Definition: urlmon_main.h:212
HRESULT WINAPI URLMON_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) DECLSPEC_HIDDEN
unsigned long DWORD
Definition: ntddk_ex.h:95
IServiceProvider * service_provider
Definition: urlmon_main.h:187
WCHAR * get_useragent(void) DECLSPEC_HIDDEN
Definition: session.c:609
IInternetBindInfo * bind_info
Definition: urlmon_main.h:185
int ret
IInternetProtocolEx IInternetProtocolEx_iface
Definition: urlmon_main.h:174
#define InterlockedDecrement
Definition: armddk.h:52
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
IBindStatusCallback * bsc_from_bctx(IBindCtx *) DECLSPEC_HIDDEN
Definition: bindctx.c:70
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
Definition: _list.h:228
HINSTANCE urlmon_instance
Definition: urlmon_main.c:43
tls_data_t * get_tls_data(void) DECLSPEC_HIDDEN
Definition: urlmon_main.c:62
CRITICAL_SECTION section
Definition: urlmon_main.h:211
void protocol_close_connection(Protocol *) DECLSPEC_HIDDEN
Definition: protocol.c:531
DWORD notif_hwnd_cnt
Definition: urlmon_main.h:226
static LPWSTR heap_strdupAtoW(const char *str)
Definition: urlmon_main.h:275
HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
Definition: file.c:421
#define InterlockedIncrement
Definition: armddk.h:53
IUnknown * protocol_unk
Definition: urlmon_main.h:182
IInternetProtocol * protocol
Definition: urlmon_main.h:183
#define HeapReAlloc
Definition: compat.h:393
HRESULT protocol_continue(Protocol *, PROTOCOLDATA *) DECLSPEC_HIDDEN
Definition: protocol.c:355
IInternetProtocolSink IInternetProtocolSink_iface
Definition: urlmon_main.h:178
ULONG query_available
Definition: urlmon_main.h:113
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
DWORD buf_size
Definition: urlmon_main.h:215
#define MultiByteToWideChar
Definition: compat.h:100
HRESULT protocol_start(Protocol *, IInternetProtocol *, IUri *, IInternetProtocolSink *, IInternetBindInfo *) DECLSPEC_HIDDEN
Definition: protocol.c:313
Definition: mem.c:156
HINTERNET get_internet_session(IInternetBindInfo *) DECLSPEC_HIDDEN
Definition: protocol.c:290
ULONG progress_max
Definition: urlmon_main.h:205
DWORD apartment_thread
Definition: urlmon_main.h:207
unsigned int ULONG
Definition: retypes.h:1
HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
Definition: sec_mgr.c:1245
HRESULT find_mime_from_ext(const WCHAR *, WCHAR **) DECLSPEC_HIDDEN
Definition: mimefilter.c:425
static LPWSTR heap_strdupW(LPCWSTR str)
Definition: urlmon_main.h:244
static void size_t size
Definition: urlmon_main.h:240
IInternetProtocol * protocol_handler
Definition: urlmon_main.h:194
const char * debugstr_bindstatus(ULONG) DECLSPEC_HIDDEN
Definition: urlmon_main.c:175
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static void URLMON_LockModule(void)
Definition: urlmon_main.h:67
static char * heap_strdupWtoA(const WCHAR *str)
Definition: urlmon_main.h:289
HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
Definition: gopher.c:312
static void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem
void update_user_agent(WCHAR *) DECLSPEC_HIDDEN
Definition: protocol.c:307
HRESULT register_namespace(IClassFactory *, REFIID, LPCWSTR, BOOL) DECLSPEC_HIDDEN
Definition: session.c:122
IStream * post_stream
Definition: urlmon_main.h:115