dinput: COM cleanup - use interface instead of lpvtbl in joystick effects.
[wine/multimedia.git] / dlls / urlmon / urlmon_main.h
blob719c2ebdb8f9745c8b6a79ac81abce434bc39049
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
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "ole2.h"
33 #include "urlmon.h"
34 #include "wininet.h"
36 #include "wine/unicode.h"
37 #include "wine/list.h"
39 extern HINSTANCE hProxyDll DECLSPEC_HIDDEN;
40 extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
41 extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
42 extern HRESULT StdURLMoniker_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
43 extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
44 extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
45 extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
46 extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
47 extern HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
48 extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
49 extern HRESULT MimeFilter_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
51 extern BOOL WINAPI URLMON_DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DECLSPEC_HIDDEN;
52 extern HRESULT WINAPI URLMON_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) DECLSPEC_HIDDEN;
53 extern HRESULT WINAPI URLMON_DllRegisterServer(void) DECLSPEC_HIDDEN;
54 extern HRESULT WINAPI URLMON_DllUnregisterServer(void) DECLSPEC_HIDDEN;
56 extern GUID const CLSID_PSFactoryBuffer DECLSPEC_HIDDEN;
58 /**********************************************************************
59 * Dll lifetime tracking declaration for urlmon.dll
61 extern LONG URLMON_refCount;
62 static inline void URLMON_LockModule(void) { InterlockedIncrement( &URLMON_refCount ); }
63 static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_refCount ); }
65 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
66 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
68 IInternetProtocolInfo *get_protocol_info(LPCWSTR);
69 HRESULT get_protocol_handler(IUri*,CLSID*,BOOL*,IClassFactory**);
70 IInternetProtocol *get_mime_filter(LPCWSTR);
71 BOOL is_registered_protocol(LPCWSTR);
72 void register_urlmon_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL);
73 HINTERNET get_internet_session(IInternetBindInfo*);
74 LPWSTR get_useragent(void);
75 void free_session(void);
77 HRESULT bind_to_storage(IUri*,IBindCtx*,REFIID,void**);
78 HRESULT bind_to_object(IMoniker*,IUri*,IBindCtx*,REFIID,void**ppv);
80 HRESULT create_binding_protocol(BOOL,IInternetProtocolEx**);
81 void set_binding_sink(IInternetProtocolEx*,IInternetProtocolSink*,IInternetBindInfo*);
82 IWinInetInfo *get_wininet_info(IInternetProtocolEx*);
83 HRESULT create_default_callback(IBindStatusCallback**);
84 HRESULT wrap_callback(IBindStatusCallback*,IBindStatusCallback**);
86 typedef struct ProtocolVtbl ProtocolVtbl;
88 typedef struct {
89 const ProtocolVtbl *vtbl;
91 IInternetProtocol *protocol;
92 IInternetProtocolSink *protocol_sink;
94 DWORD bindf;
95 BINDINFO bind_info;
97 HINTERNET request;
98 HINTERNET connection;
99 DWORD flags;
100 HANDLE lock;
102 ULONG current_position;
103 ULONG content_length;
104 ULONG available_bytes;
106 IStream *post_stream;
108 LONG priority;
109 } Protocol;
111 struct ProtocolVtbl {
112 HRESULT (*open_request)(Protocol*,IUri*,DWORD,HINTERNET,IInternetBindInfo*);
113 HRESULT (*end_request)(Protocol*);
114 HRESULT (*start_downloading)(Protocol*);
115 void (*close_connection)(Protocol*);
116 void (*on_error)(Protocol*,DWORD);
119 /* Flags are needed for, among other things, return HRESULTs from the Read function
120 * to conform to native. For example, Read returns:
122 * 1. E_PENDING if called before the request has completed,
123 * (flags = 0)
124 * 2. S_FALSE after all data has been read and S_OK has been reported,
125 * (flags = FLAG_REQUEST_COMPLETE | FLAG_ALL_DATA_READ | FLAG_RESULT_REPORTED)
126 * 3. INET_E_DATA_NOT_AVAILABLE if InternetQueryDataAvailable fails. The first time
127 * this occurs, INET_E_DATA_NOT_AVAILABLE will also be reported to the sink,
128 * (flags = FLAG_REQUEST_COMPLETE)
129 * but upon subsequent calls to Read no reporting will take place, yet
130 * InternetQueryDataAvailable will still be called, and, on failure,
131 * INET_E_DATA_NOT_AVAILABLE will still be returned.
132 * (flags = FLAG_REQUEST_COMPLETE | FLAG_RESULT_REPORTED)
134 * FLAG_FIRST_DATA_REPORTED and FLAG_LAST_DATA_REPORTED are needed for proper
135 * ReportData reporting. For example, if OnResponse returns S_OK, Continue will
136 * report BSCF_FIRSTDATANOTIFICATION, and when all data has been read Read will
137 * report BSCF_INTERMEDIATEDATANOTIFICATION|BSCF_LASTDATANOTIFICATION. However,
138 * if OnResponse does not return S_OK, Continue will not report data, and Read
139 * will report BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION when all
140 * data has been read.
142 #define FLAG_REQUEST_COMPLETE 0x0001
143 #define FLAG_FIRST_CONTINUE_COMPLETE 0x0002
144 #define FLAG_FIRST_DATA_REPORTED 0x0004
145 #define FLAG_ALL_DATA_READ 0x0008
146 #define FLAG_LAST_DATA_REPORTED 0x0010
147 #define FLAG_RESULT_REPORTED 0x0020
148 #define FLAG_ERROR 0x0040
150 HRESULT protocol_start(Protocol*,IInternetProtocol*,IUri*,IInternetProtocolSink*,IInternetBindInfo*);
151 HRESULT protocol_continue(Protocol*,PROTOCOLDATA*);
152 HRESULT protocol_read(Protocol*,void*,ULONG,ULONG*);
153 HRESULT protocol_lock_request(Protocol*);
154 HRESULT protocol_unlock_request(Protocol*);
155 HRESULT protocol_abort(Protocol*,HRESULT);
156 void protocol_close_connection(Protocol*);
158 typedef struct {
159 const IInternetProtocolVtbl *lpIInternetProtocolVtbl;
160 const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl;
162 LONG ref;
164 IInternetProtocolSink *protocol_sink;
165 IInternetProtocol *protocol;
166 } ProtocolProxy;
168 #define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpIInternetProtocolVtbl)
169 #define PROTSINK(x) ((IInternetProtocolSink*) &(x)->lpIInternetProtocolSinkVtbl)
171 HRESULT create_protocol_proxy(IInternetProtocol*,IInternetProtocolSink*,ProtocolProxy**);
173 typedef struct {
174 HWND notif_hwnd;
175 DWORD notif_hwnd_cnt;
177 struct list entry;
178 } tls_data_t;
180 tls_data_t *get_tls_data(void);
182 HWND get_notif_hwnd(void);
183 void release_notif_hwnd(HWND);
185 static inline void *heap_alloc(size_t len)
187 return HeapAlloc(GetProcessHeap(), 0, len);
190 static inline void *heap_alloc_zero(size_t len)
192 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
195 static inline void *heap_realloc(void *mem, size_t len)
197 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
200 static inline void *heap_realloc_zero(void *mem, size_t len)
202 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
205 static inline BOOL heap_free(void *mem)
207 return HeapFree(GetProcessHeap(), 0, mem);
210 static inline LPWSTR heap_strdupW(LPCWSTR str)
212 LPWSTR ret = NULL;
214 if(str) {
215 DWORD size;
217 size = (strlenW(str)+1)*sizeof(WCHAR);
218 ret = heap_alloc(size);
219 memcpy(ret, str, size);
222 return ret;
225 static inline LPWSTR heap_strndupW(LPCWSTR str, int len)
227 LPWSTR ret = NULL;
229 if(str) {
230 ret = heap_alloc((len+1)*sizeof(WCHAR));
231 if(ret) {
232 memcpy(ret, str, len*sizeof(WCHAR));
233 ret[len] = 0;
237 return ret;
240 static inline LPWSTR heap_strdupAtoW(const char *str)
242 LPWSTR ret = NULL;
244 if(str) {
245 DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
246 ret = heap_alloc(len*sizeof(WCHAR));
247 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
250 return ret;
253 #endif /* __WINE_URLMON_MAIN_H */