ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

urlmon_main.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2002 Huw D M Davies for CodeWeavers
00003  * Copyright 2009 Jacek Caban for CodeWeavers
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00018  */
00019 
00020 #ifndef __WINE_URLMON_MAIN_H
00021 #define __WINE_URLMON_MAIN_H
00022 
00023 #include <stdarg.h>
00024 
00025 #define COBJMACROS
00026 #define NONAMELESSUNION
00027 #define NONAMELESSSTRUCT
00028 
00029 #include "windef.h"
00030 #include "winbase.h"
00031 #include "winuser.h"
00032 #include "ole2.h"
00033 #include "urlmon.h"
00034 #include "wininet.h"
00035 
00036 #include "wine/unicode.h"
00037 #include "wine/list.h"
00038 
00039 extern HINSTANCE hProxyDll DECLSPEC_HIDDEN;
00040 extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
00041 extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
00042 extern HRESULT StdURLMoniker_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
00043 extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
00044 extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
00045 extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
00046 extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
00047 extern HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
00048 extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
00049 extern HRESULT MimeFilter_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN;
00050 
00051 extern BOOL WINAPI URLMON_DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DECLSPEC_HIDDEN;
00052 extern HRESULT WINAPI URLMON_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) DECLSPEC_HIDDEN;
00053 extern HRESULT WINAPI URLMON_DllRegisterServer(void) DECLSPEC_HIDDEN;
00054 extern HRESULT WINAPI URLMON_DllUnregisterServer(void) DECLSPEC_HIDDEN;
00055 
00056 extern GUID const CLSID_PSFactoryBuffer DECLSPEC_HIDDEN;
00057 
00058 /**********************************************************************
00059  * Dll lifetime tracking declaration for urlmon.dll
00060  */
00061 extern LONG URLMON_refCount DECLSPEC_HIDDEN;
00062 static inline void URLMON_LockModule(void) { InterlockedIncrement( &URLMON_refCount ); }
00063 static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_refCount ); }
00064 
00065 IInternetProtocolInfo *get_protocol_info(LPCWSTR) DECLSPEC_HIDDEN;
00066 HRESULT get_protocol_handler(IUri*,CLSID*,BOOL*,IClassFactory**) DECLSPEC_HIDDEN;
00067 IInternetProtocol *get_mime_filter(LPCWSTR) DECLSPEC_HIDDEN;
00068 BOOL is_registered_protocol(LPCWSTR) DECLSPEC_HIDDEN;
00069 void register_urlmon_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL) DECLSPEC_HIDDEN;
00070 HINTERNET get_internet_session(IInternetBindInfo*) DECLSPEC_HIDDEN;
00071 LPWSTR get_useragent(void) DECLSPEC_HIDDEN;
00072 void free_session(void) DECLSPEC_HIDDEN;
00073 
00074 HRESULT bind_to_storage(IUri*,IBindCtx*,REFIID,void**) DECLSPEC_HIDDEN;
00075 HRESULT bind_to_object(IMoniker*,IUri*,IBindCtx*,REFIID,void**ppv) DECLSPEC_HIDDEN;
00076 
00077 HRESULT create_default_callback(IBindStatusCallback**) DECLSPEC_HIDDEN;
00078 HRESULT wrap_callback(IBindStatusCallback*,IBindStatusCallback**) DECLSPEC_HIDDEN;
00079 
00080 typedef struct ProtocolVtbl ProtocolVtbl;
00081 
00082 typedef struct {
00083     const ProtocolVtbl *vtbl;
00084 
00085     IInternetProtocol *protocol;
00086     IInternetProtocolSink *protocol_sink;
00087 
00088     DWORD bindf;
00089     BINDINFO bind_info;
00090 
00091     HINTERNET request;
00092     HINTERNET connection;
00093     DWORD flags;
00094     HANDLE lock;
00095 
00096     ULONG current_position;
00097     ULONG content_length;
00098     ULONG available_bytes;
00099 
00100     IStream *post_stream;
00101 
00102     LONG priority;
00103 } Protocol;
00104 
00105 struct ProtocolVtbl {
00106     HRESULT (*open_request)(Protocol*,IUri*,DWORD,HINTERNET,IInternetBindInfo*);
00107     HRESULT (*end_request)(Protocol*);
00108     HRESULT (*start_downloading)(Protocol*);
00109     void (*close_connection)(Protocol*);
00110     void (*on_error)(Protocol*,DWORD);
00111 };
00112 
00113 /* Flags are needed for, among other things, return HRESULTs from the Read function
00114  * to conform to native. For example, Read returns:
00115  *
00116  * 1. E_PENDING if called before the request has completed,
00117  *        (flags = 0)
00118  * 2. S_FALSE after all data has been read and S_OK has been reported,
00119  *        (flags = FLAG_REQUEST_COMPLETE | FLAG_ALL_DATA_READ | FLAG_RESULT_REPORTED)
00120  * 3. INET_E_DATA_NOT_AVAILABLE if InternetQueryDataAvailable fails. The first time
00121  *    this occurs, INET_E_DATA_NOT_AVAILABLE will also be reported to the sink,
00122  *        (flags = FLAG_REQUEST_COMPLETE)
00123  *    but upon subsequent calls to Read no reporting will take place, yet
00124  *    InternetQueryDataAvailable will still be called, and, on failure,
00125  *    INET_E_DATA_NOT_AVAILABLE will still be returned.
00126  *        (flags = FLAG_REQUEST_COMPLETE | FLAG_RESULT_REPORTED)
00127  *
00128  * FLAG_FIRST_DATA_REPORTED and FLAG_LAST_DATA_REPORTED are needed for proper
00129  * ReportData reporting. For example, if OnResponse returns S_OK, Continue will
00130  * report BSCF_FIRSTDATANOTIFICATION, and when all data has been read Read will
00131  * report BSCF_INTERMEDIATEDATANOTIFICATION|BSCF_LASTDATANOTIFICATION. However,
00132  * if OnResponse does not return S_OK, Continue will not report data, and Read
00133  * will report BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION when all
00134  * data has been read.
00135  */
00136 #define FLAG_REQUEST_COMPLETE         0x0001
00137 #define FLAG_FIRST_CONTINUE_COMPLETE  0x0002
00138 #define FLAG_FIRST_DATA_REPORTED      0x0004
00139 #define FLAG_ALL_DATA_READ            0x0008
00140 #define FLAG_LAST_DATA_REPORTED       0x0010
00141 #define FLAG_RESULT_REPORTED          0x0020
00142 #define FLAG_ERROR                    0x0040
00143 
00144 HRESULT protocol_start(Protocol*,IInternetProtocol*,IUri*,IInternetProtocolSink*,IInternetBindInfo*) DECLSPEC_HIDDEN;
00145 HRESULT protocol_continue(Protocol*,PROTOCOLDATA*) DECLSPEC_HIDDEN;
00146 HRESULT protocol_read(Protocol*,void*,ULONG,ULONG*) DECLSPEC_HIDDEN;
00147 HRESULT protocol_lock_request(Protocol*) DECLSPEC_HIDDEN;
00148 HRESULT protocol_unlock_request(Protocol*) DECLSPEC_HIDDEN;
00149 HRESULT protocol_abort(Protocol*,HRESULT) DECLSPEC_HIDDEN;
00150 void protocol_close_connection(Protocol*) DECLSPEC_HIDDEN;
00151 
00152 void find_domain_name(const WCHAR*,DWORD,INT*) DECLSPEC_HIDDEN;
00153 
00154 typedef struct {
00155     IInternetProtocol     IInternetProtocol_iface;
00156     IInternetProtocolSink IInternetProtocolSink_iface;
00157 
00158     LONG ref;
00159 
00160     IInternetProtocolSink *protocol_sink;
00161     IInternetProtocol *protocol;
00162 } ProtocolProxy;
00163 
00164 HRESULT create_protocol_proxy(IInternetProtocol*,IInternetProtocolSink*,ProtocolProxy**) DECLSPEC_HIDDEN;
00165 
00166 typedef struct _task_header_t task_header_t;
00167 
00168 typedef struct {
00169     IInternetProtocolEx   IInternetProtocolEx_iface;
00170     IInternetBindInfo     IInternetBindInfo_iface;
00171     IInternetPriority     IInternetPriority_iface;
00172     IServiceProvider      IServiceProvider_iface;
00173     IInternetProtocolSink IInternetProtocolSink_iface;
00174     IWinInetHttpInfo      IWinInetHttpInfo_iface;
00175 
00176     LONG ref;
00177 
00178     IInternetProtocol *protocol;
00179     IInternetBindInfo *bind_info;
00180     IInternetProtocolSink *protocol_sink;
00181     IServiceProvider *service_provider;
00182     IWinInetInfo *wininet_info;
00183     IWinInetHttpInfo *wininet_http_info;
00184 
00185     struct {
00186         IInternetProtocol IInternetProtocol_iface;
00187     } default_protocol_handler;
00188     IInternetProtocol *protocol_handler;
00189 
00190     LONG priority;
00191 
00192     BOOL reported_result;
00193     BOOL reported_mime;
00194     BOOL from_urlmon;
00195     DWORD pi;
00196 
00197     DWORD bscf;
00198     ULONG progress;
00199     ULONG progress_max;
00200 
00201     DWORD apartment_thread;
00202     HWND notif_hwnd;
00203     DWORD continue_call;
00204 
00205     CRITICAL_SECTION section;
00206     task_header_t *task_queue_head, *task_queue_tail;
00207 
00208     BYTE *buf;
00209     DWORD buf_size;
00210     LPWSTR mime;
00211     IUri *uri;
00212     ProtocolProxy *filter_proxy;
00213 }  BindProtocol;
00214 
00215 HRESULT create_binding_protocol(BOOL,BindProtocol**) DECLSPEC_HIDDEN;
00216 void set_binding_sink(BindProtocol*,IInternetProtocolSink*,IInternetBindInfo*) DECLSPEC_HIDDEN;
00217 
00218 typedef struct {
00219     HWND notif_hwnd;
00220     DWORD notif_hwnd_cnt;
00221 
00222     struct list entry;
00223 } tls_data_t;
00224 
00225 tls_data_t *get_tls_data(void) DECLSPEC_HIDDEN;
00226 
00227 HWND get_notif_hwnd(void) DECLSPEC_HIDDEN;
00228 void release_notif_hwnd(HWND) DECLSPEC_HIDDEN;
00229 
00230 static inline void *heap_alloc(size_t len)
00231 {
00232     return HeapAlloc(GetProcessHeap(), 0, len);
00233 }
00234 
00235 static inline void *heap_alloc_zero(size_t len)
00236 {
00237     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
00238 }
00239 
00240 static inline void *heap_realloc(void *mem, size_t len)
00241 {
00242     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
00243 }
00244 
00245 static inline void *heap_realloc_zero(void *mem, size_t len)
00246 {
00247     return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
00248 }
00249 
00250 static inline BOOL heap_free(void *mem)
00251 {
00252     return HeapFree(GetProcessHeap(), 0, mem);
00253 }
00254 
00255 static inline LPWSTR heap_strdupW(LPCWSTR str)
00256 {
00257     LPWSTR ret = NULL;
00258 
00259     if(str) {
00260         DWORD size;
00261 
00262         size = (strlenW(str)+1)*sizeof(WCHAR);
00263         ret = heap_alloc(size);
00264         memcpy(ret, str, size);
00265     }
00266 
00267     return ret;
00268 }
00269 
00270 static inline LPWSTR heap_strndupW(LPCWSTR str, int len)
00271 {
00272     LPWSTR ret = NULL;
00273 
00274     if(str) {
00275         ret = heap_alloc((len+1)*sizeof(WCHAR));
00276         if(ret) {
00277             memcpy(ret, str, len*sizeof(WCHAR));
00278             ret[len] = 0;
00279         }
00280     }
00281 
00282     return ret;
00283 }
00284 
00285 static inline LPWSTR heap_strdupAtoW(const char *str)
00286 {
00287     LPWSTR ret = NULL;
00288 
00289     if(str) {
00290         DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
00291         ret = heap_alloc(len*sizeof(WCHAR));
00292         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
00293     }
00294 
00295     return ret;
00296 }
00297 
00298 #endif /* __WINE_URLMON_MAIN_H */

Generated on Sat May 26 2012 04:25:17 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.