Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenconpoint.c
Go to the documentation of this file.
00001 /* 00002 * Copyright 2006 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 <stdarg.h> 00020 00021 #define COBJMACROS 00022 00023 #include "windef.h" 00024 #include "winbase.h" 00025 #include "winuser.h" 00026 #include "ole2.h" 00027 00028 #include "wine/debug.h" 00029 00030 #include "mshtml_private.h" 00031 00032 WINE_DEFAULT_DEBUG_CHANNEL(mshtml); 00033 00034 #define CONPOINT(x) ((IConnectionPoint*) &(x)->lpConnectionPointVtbl); 00035 00036 static const char *debugstr_cp_guid(REFIID riid) 00037 { 00038 #define X(x) \ 00039 if(IsEqualGUID(riid, &x)) \ 00040 return #x 00041 00042 X(IID_IPropertyNotifySink); 00043 X(DIID_HTMLDocumentEvents); 00044 X(DIID_HTMLDocumentEvents2); 00045 X(DIID_HTMLTableEvents); 00046 X(DIID_HTMLTextContainerEvents); 00047 00048 #undef X 00049 00050 return debugstr_guid(riid); 00051 } 00052 00053 void call_property_onchanged(ConnectionPoint *This, DISPID dispid) 00054 { 00055 DWORD i; 00056 00057 for(i=0; i<This->sinks_size; i++) { 00058 if(This->sinks[i].propnotif) 00059 IPropertyNotifySink_OnChanged(This->sinks[i].propnotif, dispid); 00060 } 00061 } 00062 00063 #define CONPOINT_THIS(iface) DEFINE_THIS(ConnectionPoint, ConnectionPoint, iface) 00064 00065 static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, 00066 REFIID riid, LPVOID *ppv) 00067 { 00068 ConnectionPoint *This = CONPOINT_THIS(iface); 00069 00070 *ppv = NULL; 00071 00072 if(IsEqualGUID(&IID_IUnknown, riid)) { 00073 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); 00074 *ppv = CONPOINT(This); 00075 }else if(IsEqualGUID(&IID_IConnectionPoint, riid)) { 00076 TRACE("(%p)->(IID_IConnectionPoint %p)\n", This, ppv); 00077 *ppv = CONPOINT(This); 00078 } 00079 00080 if(*ppv) { 00081 IUnknown_AddRef((IUnknown*)*ppv); 00082 return S_OK; 00083 } 00084 00085 WARN("Unsupported interface %s\n", debugstr_guid(riid)); 00086 return E_NOINTERFACE; 00087 } 00088 00089 static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface) 00090 { 00091 ConnectionPoint *This = CONPOINT_THIS(iface); 00092 return IConnectionPointContainer_AddRef(CONPTCONT(This->container)); 00093 } 00094 00095 static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface) 00096 { 00097 ConnectionPoint *This = CONPOINT_THIS(iface); 00098 return IConnectionPointContainer_Release(CONPTCONT(This->container)); 00099 } 00100 00101 static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID) 00102 { 00103 ConnectionPoint *This = CONPOINT_THIS(iface); 00104 00105 TRACE("(%p)->(%p)\n", This, pIID); 00106 00107 if(!pIID) 00108 return E_POINTER; 00109 00110 *pIID = *This->iid; 00111 return S_OK; 00112 } 00113 00114 static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface, 00115 IConnectionPointContainer **ppCPC) 00116 { 00117 ConnectionPoint *This = CONPOINT_THIS(iface); 00118 00119 TRACE("(%p)->(%p)\n", This, ppCPC); 00120 00121 if(!ppCPC) 00122 return E_POINTER; 00123 00124 *ppCPC = CONPTCONT(This->container); 00125 IConnectionPointContainer_AddRef(*ppCPC); 00126 return S_OK; 00127 } 00128 00129 static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink, 00130 DWORD *pdwCookie) 00131 { 00132 ConnectionPoint *This = CONPOINT_THIS(iface); 00133 IUnknown *sink; 00134 DWORD i; 00135 HRESULT hres; 00136 00137 TRACE("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie); 00138 00139 hres = IUnknown_QueryInterface(pUnkSink, This->iid, (void**)&sink); 00140 if(FAILED(hres) && !IsEqualGUID(&IID_IPropertyNotifySink, This->iid)) 00141 hres = IUnknown_QueryInterface(pUnkSink, &IID_IDispatch, (void**)&sink); 00142 if(FAILED(hres)) 00143 return CONNECT_E_CANNOTCONNECT; 00144 00145 if(This->sinks) { 00146 for(i=0; i<This->sinks_size; i++) { 00147 if(!This->sinks[i].unk) 00148 break; 00149 } 00150 00151 if(i == This->sinks_size) 00152 This->sinks = heap_realloc(This->sinks,(++This->sinks_size)*sizeof(*This->sinks)); 00153 }else { 00154 This->sinks = heap_alloc(sizeof(*This->sinks)); 00155 This->sinks_size = 1; 00156 i = 0; 00157 } 00158 00159 This->sinks[i].unk = sink; 00160 *pdwCookie = i+1; 00161 00162 if(!i && This->data && This->data->on_advise) 00163 This->data->on_advise(This->container->outer, This->data); 00164 00165 return S_OK; 00166 } 00167 00168 static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie) 00169 { 00170 ConnectionPoint *This = CONPOINT_THIS(iface); 00171 TRACE("(%p)->(%d)\n", This, dwCookie); 00172 00173 if(!dwCookie || dwCookie > This->sinks_size || !This->sinks[dwCookie-1].unk) 00174 return CONNECT_E_NOCONNECTION; 00175 00176 IUnknown_Release(This->sinks[dwCookie-1].unk); 00177 This->sinks[dwCookie-1].unk = NULL; 00178 00179 return S_OK; 00180 } 00181 00182 static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface, 00183 IEnumConnections **ppEnum) 00184 { 00185 ConnectionPoint *This = CONPOINT_THIS(iface); 00186 FIXME("(%p)->(%p)\n", This, ppEnum); 00187 return E_NOTIMPL; 00188 } 00189 00190 #undef CONPOINT_THIS 00191 00192 static const IConnectionPointVtbl ConnectionPointVtbl = 00193 { 00194 ConnectionPoint_QueryInterface, 00195 ConnectionPoint_AddRef, 00196 ConnectionPoint_Release, 00197 ConnectionPoint_GetConnectionInterface, 00198 ConnectionPoint_GetConnectionPointContainer, 00199 ConnectionPoint_Advise, 00200 ConnectionPoint_Unadvise, 00201 ConnectionPoint_EnumConnections 00202 }; 00203 00204 void ConnectionPoint_Init(ConnectionPoint *cp, ConnectionPointContainer *container, REFIID riid, cp_static_data_t *data) 00205 { 00206 cp->lpConnectionPointVtbl = &ConnectionPointVtbl; 00207 cp->container = container; 00208 cp->sinks = NULL; 00209 cp->sinks_size = 0; 00210 cp->iid = riid; 00211 cp->next = NULL; 00212 cp->data = data; 00213 00214 cp->next = container->cp_list; 00215 container->cp_list = cp; 00216 } 00217 00218 static void ConnectionPoint_Destroy(ConnectionPoint *This) 00219 { 00220 DWORD i; 00221 00222 for(i=0; i<This->sinks_size; i++) { 00223 if(This->sinks[i].unk) 00224 IUnknown_Release(This->sinks[i].unk); 00225 } 00226 00227 heap_free(This->sinks); 00228 } 00229 00230 #define CONPTCONT_THIS(iface) DEFINE_THIS(ConnectionPointContainer, ConnectionPointContainer, iface) 00231 00232 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface, 00233 REFIID riid, void **ppv) 00234 { 00235 ConnectionPointContainer *This = CONPTCONT_THIS(iface); 00236 return IUnknown_QueryInterface(This->outer, riid, ppv); 00237 } 00238 00239 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface) 00240 { 00241 ConnectionPointContainer *This = CONPTCONT_THIS(iface); 00242 return IUnknown_AddRef(This->outer); 00243 } 00244 00245 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface) 00246 { 00247 ConnectionPointContainer *This = CONPTCONT_THIS(iface); 00248 return IUnknown_Release(This->outer); 00249 } 00250 00251 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface, 00252 IEnumConnectionPoints **ppEnum) 00253 { 00254 ConnectionPointContainer *This = CONPTCONT_THIS(iface); 00255 FIXME("(%p)->(%p)\n", This, ppEnum); 00256 return E_NOTIMPL; 00257 } 00258 00259 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface, 00260 REFIID riid, IConnectionPoint **ppCP) 00261 { 00262 ConnectionPointContainer *This = CONPTCONT_THIS(iface); 00263 ConnectionPoint *iter; 00264 00265 TRACE("(%p)->(%s %p)\n", This, debugstr_cp_guid(riid), ppCP); 00266 00267 if(This->forward_container) 00268 return IConnectionPointContainer_FindConnectionPoint(CONPTCONT(This), riid, ppCP); 00269 00270 *ppCP = NULL; 00271 00272 for(iter = This->cp_list; iter; iter = iter->next) { 00273 if(IsEqualGUID(iter->iid, riid)) 00274 *ppCP = CONPOINT(iter); 00275 } 00276 00277 if(*ppCP) { 00278 IConnectionPoint_AddRef(*ppCP); 00279 return S_OK; 00280 } 00281 00282 FIXME("unsupported riid %s\n", debugstr_cp_guid(riid)); 00283 return CONNECT_E_NOCONNECTION; 00284 } 00285 00286 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = { 00287 ConnectionPointContainer_QueryInterface, 00288 ConnectionPointContainer_AddRef, 00289 ConnectionPointContainer_Release, 00290 ConnectionPointContainer_EnumConnectionPoints, 00291 ConnectionPointContainer_FindConnectionPoint 00292 }; 00293 00294 #undef CONPTCONT_THIS 00295 00296 void ConnectionPointContainer_Init(ConnectionPointContainer *This, IUnknown *outer) 00297 { 00298 This->lpConnectionPointContainerVtbl = &ConnectionPointContainerVtbl; 00299 This->cp_list = NULL; 00300 This->outer = outer; 00301 } 00302 00303 void ConnectionPointContainer_Destroy(ConnectionPointContainer *This) 00304 { 00305 ConnectionPoint *iter = This->cp_list; 00306 00307 while(iter) { 00308 ConnectionPoint_Destroy(iter); 00309 iter = iter->next; 00310 } 00311 } Generated on Sat May 26 2012 04:23:23 for ReactOS by
1.7.6.1
|