ddraw/tests: Add another invalid arguments test for surface QI.
[wine.git] / dlls / urlmon / urlmon_main.h
blobee26beddde88c72fbf66336f16caf9011ea11dc5
1 /*
2 * Copyright 2002 Huw D M Davies for CodeWeavers
3 * Copyright 2009 Jacek Caban for CodeWeavers
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.
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.
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
20 #ifndef __WINE_URLMON_MAIN_H
21 #define __WINE_URLMON_MAIN_H
23 #include <stdarg.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "ole2.h"
31 #include "urlmon.h"
32 #include "wininet.h"
34 #include "wine/unicode.h"
35 #include "wine/list.h"
37 extern HINSTANCE hProxyDll DECLSPEC_HIDDEN;
38 extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
39 extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
40 extern HRESULT StdURLMoniker_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
41 extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
42 extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
43 extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
44 extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
45 extern HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
46 extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
47 extern HRESULT MimeFilter_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
48 extern HRESULT Uri_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
50 extern BOOL WINAPI URLMON_DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DECLSPEC_HIDDEN;
51 extern HRESULT WINAPI URLMON_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) DECLSPEC_HIDDEN;
52 extern HRESULT WINAPI URLMON_DllRegisterServer(void) DECLSPEC_HIDDEN;
53 extern HRESULT WINAPI URLMON_DllUnregisterServer(void) DECLSPEC_HIDDEN;
55 extern GUID const CLSID_PSFactoryBuffer DECLSPEC_HIDDEN;
56 extern GUID const CLSID_CUri DECLSPEC_HIDDEN;
58 /**********************************************************************
59 * Dll lifetime tracking declaration for urlmon.dll
61 extern LONG URLMON_refCount DECLSPEC_HIDDEN;
62 static inline void URLMON_LockModule(void) { InterlockedIncrement( &URLMON_refCount ); }
63 static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_refCount ); }
65 extern HINSTANCE urlmon_instance;
67 IInternetProtocolInfo *get_protocol_info(LPCWSTR) DECLSPEC_HIDDEN;
68 HRESULT get_protocol_handler(IUri*,CLSID*,BOOL*,IClassFactory**) DECLSPEC_HIDDEN;
69 IInternetProtocol *get_mime_filter(LPCWSTR) DECLSPEC_HIDDEN;
70 BOOL is_registered_protocol(LPCWSTR) DECLSPEC_HIDDEN;
71 HRESULT register_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL) DECLSPEC_HIDDEN;
72 HINTERNET get_internet_session(IInternetBindInfo*) DECLSPEC_HIDDEN;
73 WCHAR *get_useragent(void) DECLSPEC_HIDDEN;
74 void update_user_agent(WCHAR*) DECLSPEC_HIDDEN;
75 void free_session(void) DECLSPEC_HIDDEN;
77 HRESULT find_mime_from_ext(const WCHAR*,WCHAR**) DECLSPEC_HIDDEN;
79 HRESULT bind_to_storage(IUri*,IBindCtx*,REFIID,void**) DECLSPEC_HIDDEN;
80 HRESULT bind_to_object(IMoniker*,IUri*,IBindCtx*,REFIID,void**ppv) DECLSPEC_HIDDEN;
82 HRESULT create_default_callback(IBindStatusCallback**) DECLSPEC_HIDDEN;
83 HRESULT wrap_callback(IBindStatusCallback*,IBindStatusCallback**) DECLSPEC_HIDDEN;
84 IBindStatusCallback *bsc_from_bctx(IBindCtx*) DECLSPEC_HIDDEN;
86 typedef HRESULT (*stop_cache_binding_proc_t)(void*,const WCHAR*,HRESULT,const WCHAR*);
87 HRESULT download_to_cache(IUri*,stop_cache_binding_proc_t,void*,IBindStatusCallback*) DECLSPEC_HIDDEN;
89 typedef struct ProtocolVtbl ProtocolVtbl;
91 typedef struct {
92 const ProtocolVtbl *vtbl;
94 IInternetProtocol *protocol;
95 IInternetProtocolSink *protocol_sink;
97 DWORD bindf;
98 BINDINFO bind_info;
100 HINTERNET request;
101 HINTERNET connection;
102 DWORD flags;
103 HANDLE lock;
105 ULONG current_position;
106 ULONG content_length;
107 ULONG available_bytes;
108 ULONG query_available;
110 IStream *post_stream;
112 LONG priority;
113 } Protocol;
115 struct ProtocolVtbl {
116 HRESULT (*open_request)(Protocol*,IUri*,DWORD,HINTERNET,IInternetBindInfo*);
117 HRESULT (*end_request)(Protocol*);
118 HRESULT (*start_downloading)(Protocol*);
119 void (*close_connection)(Protocol*);
120 void (*on_error)(Protocol*,DWORD);
123 /* Flags are needed for, among other things, return HRESULTs from the Read function
124 * to conform to native. For example, Read returns:
126 * 1. E_PENDING if called before the request has completed,
127 * (flags = 0)
128 * 2. S_FALSE after all data has been read and S_OK has been reported,
129 * (flags = FLAG_REQUEST_COMPLETE | FLAG_ALL_DATA_READ | FLAG_RESULT_REPORTED)
130 * 3. INET_E_DATA_NOT_AVAILABLE if InternetQueryDataAvailable fails. The first time
131 * this occurs, INET_E_DATA_NOT_AVAILABLE will also be reported to the sink,
132 * (flags = FLAG_REQUEST_COMPLETE)
133 * but upon subsequent calls to Read no reporting will take place, yet
134 * InternetQueryDataAvailable will still be called, and, on failure,
135 * INET_E_DATA_NOT_AVAILABLE will still be returned.
136 * (flags = FLAG_REQUEST_COMPLETE | FLAG_RESULT_REPORTED)
138 * FLAG_FIRST_DATA_REPORTED and FLAG_LAST_DATA_REPORTED are needed for proper
139 * ReportData reporting. For example, if OnResponse returns S_OK, Continue will
140 * report BSCF_FIRSTDATANOTIFICATION, and when all data has been read Read will
141 * report BSCF_INTERMEDIATEDATANOTIFICATION|BSCF_LASTDATANOTIFICATION. However,
142 * if OnResponse does not return S_OK, Continue will not report data, and Read
143 * will report BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION when all
144 * data has been read.
146 #define FLAG_REQUEST_COMPLETE 0x0001
147 #define FLAG_FIRST_CONTINUE_COMPLETE 0x0002
148 #define FLAG_FIRST_DATA_REPORTED 0x0004
149 #define FLAG_ALL_DATA_READ 0x0008
150 #define FLAG_LAST_DATA_REPORTED 0x0010
151 #define FLAG_RESULT_REPORTED 0x0020
152 #define FLAG_ERROR 0x0040
153 #define FLAG_SYNC_READ 0x0080
155 HRESULT protocol_start(Protocol*,IInternetProtocol*,IUri*,IInternetProtocolSink*,IInternetBindInfo*) DECLSPEC_HIDDEN;
156 HRESULT protocol_continue(Protocol*,PROTOCOLDATA*) DECLSPEC_HIDDEN;
157 HRESULT protocol_read(Protocol*,void*,ULONG,ULONG*) DECLSPEC_HIDDEN;
158 HRESULT protocol_lock_request(Protocol*) DECLSPEC_HIDDEN;
159 HRESULT protocol_unlock_request(Protocol*) DECLSPEC_HIDDEN;
160 HRESULT protocol_abort(Protocol*,HRESULT) DECLSPEC_HIDDEN;
161 HRESULT protocol_syncbinding(Protocol*) DECLSPEC_HIDDEN;
162 void protocol_close_connection(Protocol*) DECLSPEC_HIDDEN;
164 void find_domain_name(const WCHAR*,DWORD,INT*) DECLSPEC_HIDDEN;
166 typedef struct _task_header_t task_header_t;
168 typedef struct {
169 IInternetProtocolEx IInternetProtocolEx_iface;
170 IInternetBindInfo IInternetBindInfo_iface;
171 IInternetPriority IInternetPriority_iface;
172 IServiceProvider IServiceProvider_iface;
173 IInternetProtocolSink IInternetProtocolSink_iface;
174 IWinInetHttpInfo IWinInetHttpInfo_iface;
176 LONG ref;
178 IInternetProtocol *protocol;
179 IWinInetInfo *wininet_info;
180 IWinInetHttpInfo *wininet_http_info;
182 IInternetBindInfo *bind_info;
183 IInternetProtocolSink *protocol_sink;
184 IServiceProvider *service_provider;
185 IBindCallbackRedirect *redirect_callback;
187 struct {
188 IInternetProtocol IInternetProtocol_iface;
189 IInternetProtocolSink IInternetProtocolSink_iface;
190 } default_protocol_handler;
191 IInternetProtocol *protocol_handler;
192 IInternetProtocolSink *protocol_sink_handler;
194 LONG priority;
196 BOOL reported_result;
197 BOOL reported_mime;
198 BOOL from_urlmon;
199 DWORD pi;
201 DWORD bscf;
202 ULONG progress;
203 ULONG progress_max;
205 DWORD apartment_thread;
206 HWND notif_hwnd;
207 DWORD continue_call;
209 CRITICAL_SECTION section;
210 task_header_t *task_queue_head, *task_queue_tail;
212 BYTE *buf;
213 DWORD buf_size;
214 LPWSTR mime;
215 IUri *uri;
216 BSTR display_uri;
217 } BindProtocol;
219 HRESULT create_binding_protocol(BOOL,BindProtocol**) DECLSPEC_HIDDEN;
220 void set_binding_sink(BindProtocol*,IInternetProtocolSink*,IInternetBindInfo*) DECLSPEC_HIDDEN;
222 typedef struct {
223 HWND notif_hwnd;
224 DWORD notif_hwnd_cnt;
226 struct list entry;
227 } tls_data_t;
229 tls_data_t *get_tls_data(void) DECLSPEC_HIDDEN;
231 void unregister_notif_wnd_class(void) DECLSPEC_HIDDEN;
232 HWND get_notif_hwnd(void) DECLSPEC_HIDDEN;
233 void release_notif_hwnd(HWND) DECLSPEC_HIDDEN;
235 const char *debugstr_bindstatus(ULONG) DECLSPEC_HIDDEN;
237 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
239 return HeapAlloc(GetProcessHeap(), 0, size);
242 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size)
244 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
247 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size)
249 return HeapReAlloc(GetProcessHeap(), 0, mem, size);
252 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t size)
254 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size);
257 static inline BOOL heap_free(void *mem)
259 return HeapFree(GetProcessHeap(), 0, mem);
262 static inline LPWSTR heap_strdupW(LPCWSTR str)
264 LPWSTR ret = NULL;
266 if(str) {
267 DWORD size;
269 size = (strlenW(str)+1)*sizeof(WCHAR);
270 ret = heap_alloc(size);
271 if(ret)
272 memcpy(ret, str, size);
275 return ret;
278 static inline LPWSTR heap_strndupW(LPCWSTR str, int len)
280 LPWSTR ret = NULL;
282 if(str) {
283 ret = heap_alloc((len+1)*sizeof(WCHAR));
284 if(ret) {
285 memcpy(ret, str, len*sizeof(WCHAR));
286 ret[len] = 0;
290 return ret;
293 static inline LPWSTR heap_strdupAtoW(const char *str)
295 LPWSTR ret = NULL;
297 if(str) {
298 DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
299 ret = heap_alloc(len*sizeof(WCHAR));
300 if(ret)
301 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
304 return ret;
307 static inline char *heap_strdupWtoA(const WCHAR *str)
309 char *ret = NULL;
311 if(str) {
312 size_t size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
313 ret = heap_alloc(size);
314 if(ret)
315 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
318 return ret;
321 #endif /* __WINE_URLMON_MAIN_H */