Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygengopher.c
Go to the documentation of this file.
00001 /* 00002 * Copyright 2009 Jacek Caban for CodeWeavers 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00017 */ 00018 00019 #include "urlmon_main.h" 00020 #include "wine/debug.h" 00021 00022 WINE_DEFAULT_DEBUG_CHANNEL(urlmon); 00023 00024 typedef struct { 00025 Protocol base; 00026 00027 IInternetProtocol IInternetProtocol_iface; 00028 IInternetPriority IInternetPriority_iface; 00029 00030 LONG ref; 00031 } GopherProtocol; 00032 00033 static inline GopherProtocol *impl_from_Protocol(Protocol *prot) 00034 { 00035 return CONTAINING_RECORD(prot, GopherProtocol, base); 00036 } 00037 00038 static HRESULT GopherProtocol_open_request(Protocol *prot, IUri *uri, DWORD request_flags, 00039 HINTERNET internet_session, IInternetBindInfo *bind_info) 00040 { 00041 GopherProtocol *This = impl_from_Protocol(prot); 00042 BSTR url; 00043 HRESULT hres; 00044 00045 hres = IUri_GetAbsoluteUri(uri, &url); 00046 if(FAILED(hres)) 00047 return hres; 00048 00049 This->base.request = InternetOpenUrlW(internet_session, url, NULL, 0, 00050 request_flags, (DWORD_PTR)&This->base); 00051 SysFreeString(url); 00052 if (!This->base.request && GetLastError() != ERROR_IO_PENDING) { 00053 WARN("InternetOpenUrl failed: %d\n", GetLastError()); 00054 return INET_E_RESOURCE_NOT_FOUND; 00055 } 00056 00057 return S_OK; 00058 } 00059 00060 static HRESULT GopherProtocol_end_request(Protocol *prot) 00061 { 00062 return E_NOTIMPL; 00063 } 00064 00065 static HRESULT GopherProtocol_start_downloading(Protocol *prot) 00066 { 00067 return S_OK; 00068 } 00069 00070 static void GopherProtocol_close_connection(Protocol *prot) 00071 { 00072 } 00073 00074 static void GopherProtocol_on_error(Protocol *prot, DWORD error) 00075 { 00076 FIXME("(%p) %d - stub\n", prot, error); 00077 } 00078 00079 static const ProtocolVtbl AsyncProtocolVtbl = { 00080 GopherProtocol_open_request, 00081 GopherProtocol_end_request, 00082 GopherProtocol_start_downloading, 00083 GopherProtocol_close_connection, 00084 GopherProtocol_on_error 00085 }; 00086 00087 static inline GopherProtocol *impl_from_IInternetProtocol(IInternetProtocol *iface) 00088 { 00089 return CONTAINING_RECORD(iface, GopherProtocol, IInternetProtocol_iface); 00090 } 00091 00092 static HRESULT WINAPI GopherProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) 00093 { 00094 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00095 00096 *ppv = NULL; 00097 if(IsEqualGUID(&IID_IUnknown, riid)) { 00098 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); 00099 *ppv = &This->IInternetProtocol_iface; 00100 }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { 00101 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); 00102 *ppv = &This->IInternetProtocol_iface; 00103 }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) { 00104 TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv); 00105 *ppv = &This->IInternetProtocol_iface; 00106 }else if(IsEqualGUID(&IID_IInternetPriority, riid)) { 00107 TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv); 00108 *ppv = &This->IInternetPriority_iface; 00109 } 00110 00111 if(*ppv) { 00112 IInternetProtocol_AddRef(iface); 00113 return S_OK; 00114 } 00115 00116 WARN("not supported interface %s\n", debugstr_guid(riid)); 00117 return E_NOINTERFACE; 00118 } 00119 00120 static ULONG WINAPI GopherProtocol_AddRef(IInternetProtocol *iface) 00121 { 00122 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00123 LONG ref = InterlockedIncrement(&This->ref); 00124 TRACE("(%p) ref=%d\n", This, ref); 00125 return ref; 00126 } 00127 00128 static ULONG WINAPI GopherProtocol_Release(IInternetProtocol *iface) 00129 { 00130 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00131 LONG ref = InterlockedDecrement(&This->ref); 00132 00133 TRACE("(%p) ref=%d\n", This, ref); 00134 00135 if(!ref) { 00136 heap_free(This); 00137 00138 URLMON_UnlockModule(); 00139 } 00140 00141 return ref; 00142 } 00143 00144 static HRESULT WINAPI GopherProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, 00145 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, 00146 DWORD grfPI, HANDLE_PTR dwReserved) 00147 { 00148 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00149 IUri *uri; 00150 HRESULT hres; 00151 00152 TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink, 00153 pOIBindInfo, grfPI, dwReserved); 00154 00155 hres = CreateUri(szUrl, 0, 0, &uri); 00156 if(FAILED(hres)) 00157 return hres; 00158 00159 hres = protocol_start(&This->base, &This->IInternetProtocol_iface, uri, pOIProtSink, 00160 pOIBindInfo); 00161 00162 IUri_Release(uri); 00163 return hres; 00164 } 00165 00166 static HRESULT WINAPI GopherProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData) 00167 { 00168 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00169 00170 TRACE("(%p)->(%p)\n", This, pProtocolData); 00171 00172 return protocol_continue(&This->base, pProtocolData); 00173 } 00174 00175 static HRESULT WINAPI GopherProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason, 00176 DWORD dwOptions) 00177 { 00178 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00179 00180 TRACE("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); 00181 00182 return protocol_abort(&This->base, hrReason); 00183 } 00184 00185 static HRESULT WINAPI GopherProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions) 00186 { 00187 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00188 00189 TRACE("(%p)->(%08x)\n", This, dwOptions); 00190 00191 protocol_close_connection(&This->base); 00192 return S_OK; 00193 } 00194 00195 static HRESULT WINAPI GopherProtocol_Suspend(IInternetProtocol *iface) 00196 { 00197 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00198 FIXME("(%p)\n", This); 00199 return E_NOTIMPL; 00200 } 00201 00202 static HRESULT WINAPI GopherProtocol_Resume(IInternetProtocol *iface) 00203 { 00204 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00205 FIXME("(%p)\n", This); 00206 return E_NOTIMPL; 00207 } 00208 00209 static HRESULT WINAPI GopherProtocol_Read(IInternetProtocol *iface, void *pv, 00210 ULONG cb, ULONG *pcbRead) 00211 { 00212 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00213 00214 TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); 00215 00216 return protocol_read(&This->base, pv, cb, pcbRead); 00217 } 00218 00219 static HRESULT WINAPI GopherProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove, 00220 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) 00221 { 00222 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00223 FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition); 00224 return E_NOTIMPL; 00225 } 00226 00227 static HRESULT WINAPI GopherProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions) 00228 { 00229 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00230 00231 TRACE("(%p)->(%08x)\n", This, dwOptions); 00232 00233 return protocol_lock_request(&This->base); 00234 } 00235 00236 static HRESULT WINAPI GopherProtocol_UnlockRequest(IInternetProtocol *iface) 00237 { 00238 GopherProtocol *This = impl_from_IInternetProtocol(iface); 00239 00240 TRACE("(%p)\n", This); 00241 00242 return protocol_unlock_request(&This->base); 00243 } 00244 00245 static const IInternetProtocolVtbl GopherProtocolVtbl = { 00246 GopherProtocol_QueryInterface, 00247 GopherProtocol_AddRef, 00248 GopherProtocol_Release, 00249 GopherProtocol_Start, 00250 GopherProtocol_Continue, 00251 GopherProtocol_Abort, 00252 GopherProtocol_Terminate, 00253 GopherProtocol_Suspend, 00254 GopherProtocol_Resume, 00255 GopherProtocol_Read, 00256 GopherProtocol_Seek, 00257 GopherProtocol_LockRequest, 00258 GopherProtocol_UnlockRequest 00259 }; 00260 00261 static inline GopherProtocol *impl_from_IInternetPriority(IInternetPriority *iface) 00262 { 00263 return CONTAINING_RECORD(iface, GopherProtocol, IInternetPriority_iface); 00264 } 00265 00266 static HRESULT WINAPI GopherPriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv) 00267 { 00268 GopherProtocol *This = impl_from_IInternetPriority(iface); 00269 return IInternetProtocol_QueryInterface(&This->IInternetProtocol_iface, riid, ppv); 00270 } 00271 00272 static ULONG WINAPI GopherPriority_AddRef(IInternetPriority *iface) 00273 { 00274 GopherProtocol *This = impl_from_IInternetPriority(iface); 00275 return IInternetProtocol_AddRef(&This->IInternetProtocol_iface); 00276 } 00277 00278 static ULONG WINAPI GopherPriority_Release(IInternetPriority *iface) 00279 { 00280 GopherProtocol *This = impl_from_IInternetPriority(iface); 00281 return IInternetProtocol_Release(&This->IInternetProtocol_iface); 00282 } 00283 00284 static HRESULT WINAPI GopherPriority_SetPriority(IInternetPriority *iface, LONG nPriority) 00285 { 00286 GopherProtocol *This = impl_from_IInternetPriority(iface); 00287 00288 TRACE("(%p)->(%d)\n", This, nPriority); 00289 00290 This->base.priority = nPriority; 00291 return S_OK; 00292 } 00293 00294 static HRESULT WINAPI GopherPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority) 00295 { 00296 GopherProtocol *This = impl_from_IInternetPriority(iface); 00297 00298 TRACE("(%p)->(%p)\n", This, pnPriority); 00299 00300 *pnPriority = This->base.priority; 00301 return S_OK; 00302 } 00303 00304 static const IInternetPriorityVtbl GopherPriorityVtbl = { 00305 GopherPriority_QueryInterface, 00306 GopherPriority_AddRef, 00307 GopherPriority_Release, 00308 GopherPriority_SetPriority, 00309 GopherPriority_GetPriority 00310 }; 00311 00312 HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) 00313 { 00314 GopherProtocol *ret; 00315 00316 TRACE("(%p %p)\n", pUnkOuter, ppobj); 00317 00318 URLMON_LockModule(); 00319 00320 ret = heap_alloc_zero(sizeof(GopherProtocol)); 00321 00322 ret->base.vtbl = &AsyncProtocolVtbl; 00323 ret->IInternetProtocol_iface.lpVtbl = &GopherProtocolVtbl; 00324 ret->IInternetPriority_iface.lpVtbl = &GopherPriorityVtbl; 00325 ret->ref = 1; 00326 00327 *ppobj = &ret->IInternetProtocol_iface; 00328 00329 return S_OK; 00330 } Generated on Sat May 26 2012 04:25:12 for ReactOS by
1.7.6.1
|