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
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
36 #include "wine/unicode.h"
37 #include "wine/list.h"
39 extern HINSTANCE URLMON_hInstance;
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 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;
57 /**********************************************************************
58 * Dll lifetime tracking declaration for urlmon.dll
60 extern LONG URLMON_refCount;
61 static inline void URLMON_LockModule(void) { InterlockedIncrement( &URLMON_refCount ); }
62 static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_refCount ); }
64 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
65 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
67 IInternetProtocolInfo *get_protocol_info(LPCWSTR);
68 HRESULT get_protocol_handler(LPCWSTR,CLSID*,BOOL*,IClassFactory**);
69 IInternetProtocol *get_mime_filter(LPCWSTR);
70 BOOL is_registered_protocol(LPCWSTR);
71 void register_urlmon_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL);
72 HINTERNET get_internet_session(IInternetBindInfo*);
73 LPWSTR get_useragent(void);
74 void free_session(void);
76 HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
77 HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
79 HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol);
80 void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink);
81 IWinInetInfo *get_wininet_info(IInternetProtocol*);
83 typedef struct ProtocolVtbl ProtocolVtbl;
86 const ProtocolVtbl *vtbl;
88 IInternetProtocol *protocol;
89 IInternetProtocolSink *protocol_sink;
99 ULONG current_position;
100 ULONG content_length;
101 ULONG available_bytes;
106 struct ProtocolVtbl {
107 HRESULT (*open_request)(Protocol*,LPCWSTR,DWORD,HINTERNET,IInternetBindInfo*);
108 HRESULT (*start_downloading)(Protocol*);
109 void (*close_connection)(Protocol*);
112 HRESULT protocol_start(Protocol*,IInternetProtocol*,LPCWSTR,IInternetProtocolSink*,IInternetBindInfo*);
113 HRESULT protocol_continue(Protocol*,PROTOCOLDATA*);
114 HRESULT protocol_read(Protocol*,void*,ULONG,ULONG*);
115 HRESULT protocol_lock_request(Protocol*);
116 HRESULT protocol_unlock_request(Protocol*);
117 void protocol_close_connection(Protocol*);
120 const IInternetProtocolVtbl *lpIInternetProtocolVtbl;
121 const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl;
125 IInternetProtocolSink *protocol_sink;
126 IInternetProtocol *protocol;
129 #define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpIInternetProtocolVtbl)
130 #define PROTSINK(x) ((IInternetProtocolSink*) &(x)->lpIInternetProtocolSinkVtbl)
132 HRESULT create_protocol_proxy(IInternetProtocol*,IInternetProtocolSink*,ProtocolProxy**);
136 DWORD notif_hwnd_cnt;
141 tls_data_t *get_tls_data(void);
143 HWND get_notif_hwnd(void);
144 void release_notif_hwnd(HWND);
146 static inline void *heap_alloc(size_t len)
148 return HeapAlloc(GetProcessHeap(), 0, len);
151 static inline void *heap_alloc_zero(size_t len)
153 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
156 static inline void *heap_realloc(void *mem, size_t len)
158 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
161 static inline void *heap_realloc_zero(void *mem, size_t len)
163 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
166 static inline BOOL heap_free(void *mem)
168 return HeapFree(GetProcessHeap(), 0, mem);
171 static inline LPWSTR heap_strdupW(LPCWSTR str)
178 size = (strlenW(str)+1)*sizeof(WCHAR);
179 ret = heap_alloc(size);
180 memcpy(ret, str, size);
186 static inline LPWSTR heap_strndupW(LPCWSTR str, int len)
191 ret = heap_alloc((len+1)*sizeof(WCHAR));
193 memcpy(ret, str, len*sizeof(WCHAR));
201 static inline LPWSTR heap_strdupAtoW(const char *str)
206 DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
207 ret = heap_alloc(len*sizeof(WCHAR));
208 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
214 #endif /* __WINE_URLMON_MAIN_H */