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

protproxy.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 static inline ProtocolProxy *impl_from_IInternetProtocol(IInternetProtocol *iface)
00025 {
00026     return CONTAINING_RECORD(iface, ProtocolProxy, IInternetProtocol_iface);
00027 }
00028 
00029 static HRESULT WINAPI ProtocolProxy_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
00030 {
00031     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00032 
00033     *ppv = NULL;
00034     if(IsEqualGUID(&IID_IUnknown, riid)) {
00035         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
00036         *ppv = &This->IInternetProtocol_iface;
00037     }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
00038         TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
00039         *ppv = &This->IInternetProtocol_iface;
00040     }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
00041         TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
00042         *ppv = &This->IInternetProtocol_iface;
00043     }else if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
00044         TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This, ppv);
00045         *ppv = &This->IInternetProtocolSink_iface;
00046     }
00047 
00048     if(*ppv) {
00049         IInternetProtocol_AddRef(iface);
00050         return S_OK;
00051     }
00052 
00053     WARN("not supported interface %s\n", debugstr_guid(riid));
00054     return E_NOINTERFACE;
00055 }
00056 
00057 static ULONG WINAPI ProtocolProxy_AddRef(IInternetProtocol *iface)
00058 {
00059     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00060     LONG ref = InterlockedIncrement(&This->ref);
00061     TRACE("(%p) ref=%d\n", This, ref);
00062     return ref;
00063 }
00064 
00065 static ULONG WINAPI ProtocolProxy_Release(IInternetProtocol *iface)
00066 {
00067     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00068     LONG ref = InterlockedDecrement(&This->ref);
00069 
00070     TRACE("(%p) ref=%d\n", This, ref);
00071 
00072     if(!ref) {
00073         if(This->protocol_sink)
00074             IInternetProtocolSink_Release(This->protocol_sink);
00075         if(This->protocol)
00076             IInternetProtocol_Release(This->protocol);
00077 
00078         heap_free(This);
00079 
00080         URLMON_UnlockModule();
00081     }
00082 
00083     return ref;
00084 }
00085 
00086 static HRESULT WINAPI ProtocolProxy_Start(IInternetProtocol *iface, LPCWSTR szUrl,
00087         IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
00088         DWORD grfPI, HANDLE_PTR dwReserved)
00089 {
00090     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00091 
00092     TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
00093           pOIBindInfo, grfPI, dwReserved);
00094 
00095     return IInternetProtocol_Start(This->protocol, szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved);
00096 }
00097 
00098 static HRESULT WINAPI ProtocolProxy_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
00099 {
00100     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00101 
00102     TRACE("(%p)->(%p)\n", This, pProtocolData);
00103 
00104     return IInternetProtocol_Continue(This->protocol, pProtocolData);
00105 }
00106 
00107 static HRESULT WINAPI ProtocolProxy_Abort(IInternetProtocol *iface, HRESULT hrReason,
00108         DWORD dwOptions)
00109 {
00110     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00111     FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
00112     return E_NOTIMPL;
00113 }
00114 
00115 static HRESULT WINAPI ProtocolProxy_Terminate(IInternetProtocol *iface, DWORD dwOptions)
00116 {
00117     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00118 
00119     TRACE("(%p)->(%08x)\n", This, dwOptions);
00120 
00121     return IInternetProtocol_Terminate(This->protocol, dwOptions);
00122 }
00123 
00124 static HRESULT WINAPI ProtocolProxy_Suspend(IInternetProtocol *iface)
00125 {
00126     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00127     FIXME("(%p)\n", This);
00128     return E_NOTIMPL;
00129 }
00130 
00131 static HRESULT WINAPI ProtocolProxy_Resume(IInternetProtocol *iface)
00132 {
00133     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00134     FIXME("(%p)\n", This);
00135     return E_NOTIMPL;
00136 }
00137 
00138 static HRESULT WINAPI ProtocolProxy_Read(IInternetProtocol *iface, void *pv,
00139         ULONG cb, ULONG *pcbRead)
00140 {
00141     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00142 
00143     TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
00144 
00145     return IInternetProtocol_Read(This->protocol, pv, cb, pcbRead);
00146 }
00147 
00148 static HRESULT WINAPI ProtocolProxy_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
00149         DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
00150 {
00151     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00152     FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
00153     return E_NOTIMPL;
00154 }
00155 
00156 static HRESULT WINAPI ProtocolProxy_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
00157 {
00158     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00159 
00160     TRACE("(%p)->(%08x)\n", This, dwOptions);
00161 
00162     return IInternetProtocol_LockRequest(This->protocol, dwOptions);
00163 }
00164 
00165 static HRESULT WINAPI ProtocolProxy_UnlockRequest(IInternetProtocol *iface)
00166 {
00167     ProtocolProxy *This = impl_from_IInternetProtocol(iface);
00168 
00169     TRACE("(%p)\n", This);
00170 
00171     return IInternetProtocol_UnlockRequest(This->protocol);
00172 }
00173 
00174 static const IInternetProtocolVtbl ProtocolProxyVtbl = {
00175     ProtocolProxy_QueryInterface,
00176     ProtocolProxy_AddRef,
00177     ProtocolProxy_Release,
00178     ProtocolProxy_Start,
00179     ProtocolProxy_Continue,
00180     ProtocolProxy_Abort,
00181     ProtocolProxy_Terminate,
00182     ProtocolProxy_Suspend,
00183     ProtocolProxy_Resume,
00184     ProtocolProxy_Read,
00185     ProtocolProxy_Seek,
00186     ProtocolProxy_LockRequest,
00187     ProtocolProxy_UnlockRequest
00188 };
00189 
00190 static inline ProtocolProxy *impl_from_IInternetProtocolSink(IInternetProtocolSink *iface)
00191 {
00192     return CONTAINING_RECORD(iface, ProtocolProxy, IInternetProtocolSink_iface);
00193 }
00194 
00195 static HRESULT WINAPI ProtocolProxySink_QueryInterface(IInternetProtocolSink *iface,
00196         REFIID riid, void **ppv)
00197 {
00198     ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
00199     return IInternetProtocol_QueryInterface(&This->IInternetProtocol_iface, riid, ppv);
00200 }
00201 
00202 static ULONG WINAPI ProtocolProxySink_AddRef(IInternetProtocolSink *iface)
00203 {
00204     ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
00205     return IInternetProtocol_AddRef(&This->IInternetProtocol_iface);
00206 }
00207 
00208 static ULONG WINAPI ProtocolProxySink_Release(IInternetProtocolSink *iface)
00209 {
00210     ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
00211     return IInternetProtocol_Release(&This->IInternetProtocol_iface);
00212 }
00213 
00214 static HRESULT WINAPI ProtocolProxySink_Switch(IInternetProtocolSink *iface,
00215         PROTOCOLDATA *pProtocolData)
00216 {
00217     ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
00218 
00219     TRACE("(%p)->(%p)\n", This, pProtocolData);
00220 
00221     return IInternetProtocolSink_Switch(This->protocol_sink, pProtocolData);
00222 }
00223 
00224 static HRESULT WINAPI ProtocolProxySink_ReportProgress(IInternetProtocolSink *iface,
00225         ULONG ulStatusCode, LPCWSTR szStatusText)
00226 {
00227     ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
00228 
00229     TRACE("(%p)->(%u %s)\n", This, ulStatusCode, debugstr_w(szStatusText));
00230 
00231     switch(ulStatusCode) {
00232     case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE:
00233         IInternetProtocolSink_ReportProgress(This->protocol_sink, BINDSTATUS_MIMETYPEAVAILABLE, szStatusText);
00234         break;
00235     default:
00236         IInternetProtocolSink_ReportProgress(This->protocol_sink, ulStatusCode, szStatusText);
00237     }
00238 
00239     return S_OK;
00240 }
00241 
00242 static HRESULT WINAPI ProtocolProxySink_ReportData(IInternetProtocolSink *iface,
00243         DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax)
00244 {
00245     ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
00246 
00247     TRACE("(%p)->(%d %u %u)\n", This, grfBSCF, ulProgress, ulProgressMax);
00248 
00249     return IInternetProtocolSink_ReportData(This->protocol_sink, grfBSCF, ulProgress, ulProgressMax);
00250 }
00251 
00252 static HRESULT WINAPI ProtocolProxySink_ReportResult(IInternetProtocolSink *iface,
00253         HRESULT hrResult, DWORD dwError, LPCWSTR szResult)
00254 {
00255     ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
00256 
00257     TRACE("(%p)->(%08x %d %s)\n", This, hrResult, dwError, debugstr_w(szResult));
00258 
00259     return IInternetProtocolSink_ReportResult(This->protocol_sink, hrResult, dwError, szResult);
00260 }
00261 
00262 static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl = {
00263     ProtocolProxySink_QueryInterface,
00264     ProtocolProxySink_AddRef,
00265     ProtocolProxySink_Release,
00266     ProtocolProxySink_Switch,
00267     ProtocolProxySink_ReportProgress,
00268     ProtocolProxySink_ReportData,
00269     ProtocolProxySink_ReportResult
00270 };
00271 
00272 HRESULT create_protocol_proxy(IInternetProtocol *protocol, IInternetProtocolSink *protocol_sink, ProtocolProxy **ret)
00273 {
00274     ProtocolProxy *sink;
00275 
00276     sink = heap_alloc(sizeof(ProtocolProxy));
00277     if(!sink)
00278         return E_OUTOFMEMORY;
00279 
00280     sink->IInternetProtocol_iface.lpVtbl = &ProtocolProxyVtbl;
00281     sink->IInternetProtocolSink_iface.lpVtbl = &InternetProtocolSinkVtbl;
00282     sink->ref = 1;
00283 
00284     IInternetProtocol_AddRef(protocol);
00285     sink->protocol = protocol;
00286 
00287     IInternetProtocolSink_AddRef(protocol_sink);
00288     sink->protocol_sink = protocol_sink;
00289 
00290     *ret = sink;
00291     return S_OK;
00292 }

Generated on Fri May 25 2012 04:24:47 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.