void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink) { BindProtocol *This = PROTOCOL_THIS(bind_protocol); IInternetProtocolSink *prev_sink; IServiceProvider *service_provider = NULL; if(sink) IInternetProtocolSink_AddRef(sink); prev_sink = InterlockedExchangePointer((void**)&This->protocol_sink, sink); if(prev_sink) IInternetProtocolSink_Release(prev_sink); if(sink) IInternetProtocolSink_QueryInterface(sink, &IID_IServiceProvider, (void**)&service_provider); service_provider = InterlockedExchangePointer((void**)&This->service_provider, service_provider); if(service_provider) IServiceProvider_Release(service_provider); }
HRESULT create_protocol_proxy(IInternetProtocol *protocol, IInternetProtocolSink *protocol_sink, ProtocolProxy **ret) { ProtocolProxy *sink; sink = heap_alloc(sizeof(ProtocolProxy)); if(!sink) return E_OUTOFMEMORY; sink->lpIInternetProtocolVtbl = &ProtocolProxyVtbl; sink->lpIInternetProtocolSinkVtbl = &InternetProtocolSinkVtbl; sink->ref = 1; IInternetProtocol_AddRef(protocol); sink->protocol = protocol; IInternetProtocolSink_AddRef(protocol_sink); sink->protocol_sink = protocol_sink; *ret = sink; return S_OK; }
HRESULT protocol_start(Protocol *protocol, IInternetProtocol *prot, IUri *uri, IInternetProtocolSink *protocol_sink, IInternetBindInfo *bind_info) { DWORD request_flags; HRESULT hres; protocol->protocol = prot; IInternetProtocolSink_AddRef(protocol_sink); protocol->protocol_sink = protocol_sink; memset(&protocol->bind_info, 0, sizeof(protocol->bind_info)); protocol->bind_info.cbSize = sizeof(BINDINFO); hres = IInternetBindInfo_GetBindInfo(bind_info, &protocol->bindf, &protocol->bind_info); if(hres != S_OK) { WARN("GetBindInfo failed: %08x\n", hres); return report_result(protocol, hres); } if(!(protocol->bindf & BINDF_FROMURLMON)) report_progress(protocol, BINDSTATUS_DIRECTBIND, NULL); if(!get_internet_session(bind_info)) return report_result(protocol, INET_E_NO_SESSION); request_flags = INTERNET_FLAG_KEEP_CONNECTION; if(protocol->bindf & BINDF_NOWRITECACHE) request_flags |= INTERNET_FLAG_NO_CACHE_WRITE; if(protocol->bindf & BINDF_NEEDFILE) request_flags |= INTERNET_FLAG_NEED_FILE; hres = protocol->vtbl->open_request(protocol, uri, request_flags, internet_session, bind_info); if(FAILED(hres)) { protocol_close_connection(protocol); return report_result(protocol, hres); } return S_OK; }
void set_binding_sink(BindProtocol *This, IInternetProtocolSink *sink, IInternetBindInfo *bind_info) { IInternetProtocolSink *prev_sink; IServiceProvider *service_provider = NULL; if(sink) IInternetProtocolSink_AddRef(sink); prev_sink = InterlockedExchangePointer((void**)&This->protocol_sink, sink); if(prev_sink) IInternetProtocolSink_Release(prev_sink); if(sink) IInternetProtocolSink_QueryInterface(sink, &IID_IServiceProvider, (void**)&service_provider); service_provider = InterlockedExchangePointer((void**)&This->service_provider, service_provider); if(service_provider) IServiceProvider_Release(service_provider); if(bind_info) IInternetBindInfo_AddRef(bind_info); bind_info = InterlockedExchangePointer((void**)&This->bind_info, bind_info); if(bind_info) IInternetBindInfo_Release(bind_info); }