- Timestamp:
- Sep 12, 2014 12:33:41 PM (10 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/comimpl.xsl
r50857 r52719 14 14 Further extension to other interfaces is possible and anticipated. 15 15 16 Copyright (C) 2010-201 3Oracle Corporation16 Copyright (C) 2010-2014 Oracle Corporation 17 17 18 18 This file is part of VirtualBox Open Source Edition (OSE), as … … 47 47 48 48 /* 49 * Copyright (C) 2010-201 3Oracle Corporation49 * Copyright (C) 2010-2014 Oracle Corporation 50 50 * 51 51 * This file is part of VirtualBox Open Source Edition (OSE), as … … 496 496 BaseFinalRelease(); 497 497 } 498 STDMETHOD(COMGETTER(Type)) 499 { 500 return ((VBoxEvent*)mEvent)->COMGETTER(Type)(aType);501 } 502 STDMETHOD(COMGETTER(Source)) 503 { 504 return ((VBoxEvent*)mEvent)->COMGETTER(Source)(aSource);505 } 506 STDMETHOD(COMGETTER(Waitable)) 507 { 508 return ((VBoxEvent*)mEvent)->COMGETTER(Waitable)(aWaitable);498 STDMETHOD(COMGETTER(Type))(VBoxEventType_T *aType) 499 { 500 return mEvent->COMGETTER(Type)(aType); 501 } 502 STDMETHOD(COMGETTER(Source))(IEventSource * *aSource) 503 { 504 return mEvent->COMGETTER(Source)(aSource); 505 } 506 STDMETHOD(COMGETTER(Waitable))(BOOL *aWaitable) 507 { 508 return mEvent->COMGETTER(Waitable)(aWaitable); 509 509 } 510 510 STDMETHOD(SetProcessed)() 511 511 { 512 return ((VBoxEvent*)mEvent)->SetProcessed();512 return mEvent->SetProcessed(); 513 513 } 514 514 STDMETHOD(WaitProcessed)(LONG aTimeout, BOOL *aResult) 515 515 { 516 return ((VBoxEvent*)mEvent)->WaitProcessed(aTimeout, aResult);516 return mEvent->WaitProcessed(aTimeout, aResult); 517 517 } 518 518 void uninit() … … 557 557 return mEvent->init(aSource, aType, aWaitable); 558 558 } 559 STDMETHOD(COMGETTER(Generation)) 559 STDMETHOD(COMGETTER(Generation))(ULONG *aGeneration) 560 560 { 561 561 *aGeneration = mGeneration; 562 562 return S_OK; 563 563 } 564 STDMETHOD(Reuse) 564 STDMETHOD(Reuse)() 565 565 { 566 566 ASMAtomicIncU32((volatile uint32_t*)&mGeneration); -
trunk/src/VBox/Main/include/EventImpl.h
r50544 r52719 5 5 6 6 /* 7 * Copyright (C) 2010-201 2Oracle Corporation7 * Copyright (C) 2010-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 #define ____H_EVENTIMPL 20 20 21 #include "VirtualBoxBase.h" 21 #include "EventWrap.h" 22 #include "EventSourceWrap.h" 23 #include "VetoEventWrap.h" 22 24 23 25 24 26 class ATL_NO_VTABLE VBoxEvent : 25 public VirtualBoxBase, 26 VBOX_SCRIPTABLE_IMPL(IEvent) 27 public EventWrap 27 28 { 28 29 public: 29 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxEvent, IEvent) 30 31 DECLARE_NOT_AGGREGATABLE(VBoxEvent) 32 33 DECLARE_PROTECT_FINAL_CONSTRUCT() 34 35 BEGIN_COM_MAP(VBoxEvent) 36 VBOX_DEFAULT_INTERFACE_ENTRIES(IEvent) 37 END_COM_MAP() 38 39 VBoxEvent() {} 40 virtual ~VBoxEvent() {} 30 DECLARE_EMPTY_CTOR_DTOR(VBoxEvent) 41 31 42 32 HRESULT FinalConstruct(); … … 47 37 void uninit(); 48 38 49 // IEvent properties 50 STDMETHOD(COMGETTER(Type))(VBoxEventType_T *aType); 51 STDMETHOD(COMGETTER(Source))(IEventSource * *aSource); 52 STDMETHOD(COMGETTER(Waitable))(BOOL *aWaitable); 39 private: 40 // wrapped IEvent properties 41 HRESULT getType(VBoxEventType_T *aType); 42 HRESULT getSource(ComPtr<IEventSource> &aSource); 43 HRESULT getWaitable(BOOL *aWaitable); 53 44 54 // IEvent methods55 STDMETHOD(SetProcessed)();56 STDMETHOD(WaitProcessed)(LONG aTimeout, BOOL *aResult);45 // wrapped IEvent methods 46 HRESULT setProcessed(); 47 HRESULT waitProcessed(LONG aTimeout, BOOL *aResult); 57 48 58 private:59 49 struct Data; 60 61 50 Data* m; 62 51 }; 63 52 53 64 54 class ATL_NO_VTABLE VBoxVetoEvent : 65 public VBoxEvent, 66 VBOX_SCRIPTABLE_IMPL(IVetoEvent) 55 public virtual VetoEventWrap 67 56 { 68 57 public: 69 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxVetoEvent, IVetoEvent) 70 71 DECLARE_NOT_AGGREGATABLE(VBoxVetoEvent) 72 73 DECLARE_PROTECT_FINAL_CONSTRUCT() 74 75 BEGIN_COM_MAP(VBoxVetoEvent) 76 COM_INTERFACE_ENTRY2(IEvent, IVetoEvent) 77 VBOX_DEFAULT_INTERFACE_ENTRIES(IVetoEvent) 78 END_COM_MAP() 79 80 VBoxVetoEvent() {} 81 virtual ~VBoxVetoEvent() {} 58 DECLARE_EMPTY_CTOR_DTOR(VBoxVetoEvent) 82 59 83 60 HRESULT FinalConstruct(); … … 88 65 void uninit(); 89 66 90 // IEvent properties 91 STDMETHOD(COMGETTER(Type))(VBoxEventType_T *aType) 92 { 93 return VBoxEvent::COMGETTER(Type)(aType); 94 } 95 STDMETHOD(COMGETTER(Source))(IEventSource * *aSource) 96 { 97 return VBoxEvent::COMGETTER(Source)(aSource); 98 } 99 STDMETHOD(COMGETTER(Waitable))(BOOL *aWaitable) 100 { 101 return VBoxEvent::COMGETTER(Waitable)(aWaitable); 102 } 67 private: 68 // wrapped IEvent properties 69 HRESULT getType(VBoxEventType_T *aType); 70 HRESULT getSource(ComPtr<IEventSource> &aSource); 71 HRESULT getWaitable(BOOL *aWaitable); 103 72 104 // IEvent methods 105 STDMETHOD(SetProcessed)() 106 { 107 return VBoxEvent::SetProcessed(); 108 } 109 STDMETHOD(WaitProcessed)(LONG aTimeout, BOOL *aResult) 110 { 111 return VBoxEvent::WaitProcessed(aTimeout, aResult); 112 } 73 // wrapped IEvent methods 74 HRESULT setProcessed(); 75 HRESULT waitProcessed(LONG aTimeout, BOOL *aResult); 113 76 114 //IVetoEvent methods115 STDMETHOD(AddVeto)(IN_BSTR aVeto);116 STDMETHOD(IsVetoed)(BOOL *aResult);117 STDMETHOD(GetVetos)(ComSafeArrayOut(BSTR, aVetos));77 // wrapped IVetoEvent methods 78 HRESULT addVeto(const com::Utf8Str &aReason); 79 HRESULT isVetoed(BOOL *aResult); 80 HRESULT getVetos(std::vector<com::Utf8Str> &aResult); 118 81 119 private:120 82 struct Data; 121 122 83 Data* m; 123 84 }; 124 85 125 86 class ATL_NO_VTABLE EventSource : 126 public VirtualBoxBase, 127 VBOX_SCRIPTABLE_IMPL(IEventSource) 87 public EventSourceWrap 128 88 { 129 89 public: 130 131 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(EventSource, IEventSource)132 133 DECLARE_NOT_AGGREGATABLE(EventSource)134 135 DECLARE_PROTECT_FINAL_CONSTRUCT()136 137 BEGIN_COM_MAP(EventSource)138 VBOX_DEFAULT_INTERFACE_ENTRIES(IEventSource)139 END_COM_MAP()140 141 90 DECLARE_EMPTY_CTOR_DTOR(EventSource) 142 91 … … 148 97 void uninit(); 149 98 150 // IEventSource methods 151 STDMETHOD(CreateListener)(IEventListener **aListener); 152 STDMETHOD(CreateAggregator)(ComSafeArrayIn(IEventSource *, aSubordinates), 153 IEventSource **aAggregator); 154 STDMETHOD(RegisterListener)(IEventListener *aListener, 155 ComSafeArrayIn(VBoxEventType_T, aInterested), 156 BOOL aActive); 157 STDMETHOD(UnregisterListener)(IEventListener *aListener); 158 STDMETHOD(FireEvent)(IEvent *aEvent, LONG aTimeout, BOOL *aProcessed); 159 STDMETHOD(GetEvent)(IEventListener *aListener, LONG aTimeout, 160 IEvent **aEvent); 161 STDMETHOD(EventProcessed)(IEventListener *aListener, IEvent *aEvent); 99 private: 100 // wrapped IEventSource methods 101 HRESULT createListener(ComPtr<IEventListener> &aListener); 102 HRESULT createAggregator(const std::vector<ComPtr<IEventSource> > &aSubordinates, 103 ComPtr<IEventSource> &aResult); 104 HRESULT registerListener(const ComPtr<IEventListener> &aListener, 105 const std::vector<VBoxEventType_T> &aInteresting, 106 BOOL aActive); 107 HRESULT unregisterListener(const ComPtr<IEventListener> &aListener); 108 HRESULT fireEvent(const ComPtr<IEvent> &aEvent, 109 LONG aTimeout, 110 BOOL *aResult); 111 HRESULT getEvent(const ComPtr<IEventListener> &aListener, 112 LONG aTimeout, 113 ComPtr<IEvent> &aEvent); 114 HRESULT eventProcessed(const ComPtr<IEventListener> &aListener, 115 const ComPtr<IEvent> &aEvent); 162 116 163 private: 117 164 118 struct Data; 165 166 119 Data* m; 167 120 … … 220 173 }; 221 174 175 222 176 #endif // ____H_EVENTIMPL -
trunk/src/VBox/Main/src-all/EventImpl.cpp
r52413 r52719 83 83 }; 84 84 85 DEFINE_EMPTY_CTOR_DTOR(VBoxEvent) 86 85 87 HRESULT VBoxEvent::FinalConstruct() 86 88 { … … 95 97 uninit(); 96 98 delete m; 97 m = 0;98 BaseFinalRelease();99 }99 m = NULL; 100 } 101 BaseFinalRelease(); 100 102 } 101 103 … … 151 153 } 152 154 153 STDMETHODIMP VBoxEvent::COMGETTER(Type)(VBoxEventType_T *aType) 154 { 155 CheckComArgNotNull(aType); 156 157 AutoCaller autoCaller(this); 158 if (FAILED(autoCaller.rc())) 159 return autoCaller.rc(); 160 155 HRESULT VBoxEvent::getType(VBoxEventType_T *aType) 156 { 161 157 // never changes while event alive, no locking 162 158 *aType = m->mType; … … 164 160 } 165 161 166 STDMETHODIMP VBoxEvent::COMGETTER(Source)(IEventSource **aSource) 167 { 168 CheckComArgOutPointerValid(aSource); 169 170 AutoCaller autoCaller(this); 171 if (FAILED(autoCaller.rc())) 172 return autoCaller.rc(); 173 174 m->mSource.queryInterfaceTo(aSource); 175 return S_OK; 176 } 177 178 STDMETHODIMP VBoxEvent::COMGETTER(Waitable)(BOOL *aWaitable) 179 { 180 CheckComArgNotNull(aWaitable); 181 182 AutoCaller autoCaller(this); 183 if (FAILED(autoCaller.rc())) 184 return autoCaller.rc(); 185 162 HRESULT VBoxEvent::getSource(ComPtr<IEventSource> &aSource) 163 { 164 m->mSource.queryInterfaceTo(aSource.asOutParam()); 165 return S_OK; 166 } 167 168 HRESULT VBoxEvent::getWaitable(BOOL *aWaitable) 169 { 186 170 // never changes while event alive, no locking 187 171 *aWaitable = m->mWaitable; … … 189 173 } 190 174 191 192 STDMETHODIMP VBoxEvent::SetProcessed() 193 { 194 AutoCaller autoCaller(this); 195 if (FAILED(autoCaller.rc())) 196 return autoCaller.rc(); 197 175 HRESULT VBoxEvent::setProcessed() 176 { 198 177 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 199 178 … … 209 188 } 210 189 211 STDMETHODIMP VBoxEvent::WaitProcessed(LONG aTimeout, BOOL *aResult) 212 { 213 CheckComArgNotNull(aResult); 214 215 AutoCaller autoCaller(this); 216 if (FAILED(autoCaller.rc())) 217 return autoCaller.rc(); 218 219 { 220 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 221 222 if (m->mProcessed) 223 { 224 *aResult = TRUE; 225 return S_OK; 226 } 227 228 if (aTimeout == 0) 229 { 230 *aResult = m->mProcessed; 231 return S_OK; 232 } 190 HRESULT VBoxEvent::waitProcessed(LONG aTimeout, BOOL *aResult) 191 { 192 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 193 194 if (m->mProcessed) 195 { 196 *aResult = TRUE; 197 return S_OK; 198 } 199 200 if (aTimeout == 0) 201 { 202 *aResult = m->mProcessed; 203 return S_OK; 233 204 } 234 205 … … 252 223 } 253 224 254 typedef std::list< Bstr> VetoList;225 typedef std::list<Utf8Str> VetoList; 255 226 struct VBoxVetoEvent::Data 256 227 { … … 258 229 mVetoed(FALSE) 259 230 {} 231 ComObjPtr<VBoxEvent> mEvent; 260 232 BOOL mVetoed; 261 233 VetoList mVetoList; … … 264 236 HRESULT VBoxVetoEvent::FinalConstruct() 265 237 { 266 VBoxEvent::FinalConstruct();267 238 m = new Data; 268 return S_OK; 239 HRESULT rc = m->mEvent.createObject(); 240 BaseFinalConstruct(); 241 return rc; 269 242 } 270 243 … … 275 248 uninit(); 276 249 delete m; 277 m = 0; 278 } 279 VBoxEvent::FinalRelease(); 280 } 281 250 m = NULL; 251 } 252 BaseFinalRelease(); 253 } 254 255 DEFINE_EMPTY_CTOR_DTOR(VBoxVetoEvent) 282 256 283 257 HRESULT VBoxVetoEvent::init(IEventSource *aSource, VBoxEventType_T aType) … … 285 259 HRESULT rc = S_OK; 286 260 // all veto events are waitable 287 rc = VBoxEvent::init(aSource, aType, TRUE);261 rc = m->mEvent->init(aSource, aType, TRUE); 288 262 if (FAILED(rc)) 289 263 return rc; … … 292 266 m->mVetoList.clear(); 293 267 294 return rc;268 return S_OK; 295 269 } 296 270 297 271 void VBoxVetoEvent::uninit() 298 272 { 299 VBoxEvent::uninit();300 273 if (!m) 301 274 return; 275 302 276 m->mVetoed = FALSE; 303 } 304 305 STDMETHODIMP VBoxVetoEvent::AddVeto(IN_BSTR aVeto) 306 { 307 AutoCaller autoCaller(this); 308 if (FAILED(autoCaller.rc())) 309 return autoCaller.rc(); 310 311 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 312 313 if (aVeto) 314 m->mVetoList.push_back(aVeto); 277 if (!m->mEvent.isNull()) 278 { 279 m->mEvent->uninit(); 280 m->mEvent.setNull(); 281 } 282 } 283 284 HRESULT VBoxVetoEvent::getType(VBoxEventType_T *aType) 285 { 286 return m->mEvent->COMGETTER(Type)(aType); 287 } 288 289 HRESULT VBoxVetoEvent::getSource(ComPtr<IEventSource> &aSource) 290 { 291 return m->mEvent->COMGETTER(Source)(aSource.asOutParam()); 292 } 293 294 HRESULT VBoxVetoEvent::getWaitable(BOOL *aWaitable) 295 { 296 return m->mEvent->COMGETTER(Waitable)(aWaitable); 297 } 298 299 HRESULT VBoxVetoEvent::setProcessed() 300 { 301 return m->mEvent->SetProcessed(); 302 } 303 304 HRESULT VBoxVetoEvent::waitProcessed(LONG aTimeout, BOOL *aResult) 305 { 306 return m->mEvent->WaitProcessed(aTimeout, aResult); 307 } 308 309 HRESULT VBoxVetoEvent::addVeto(const com::Utf8Str &aReason) 310 { 311 // AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 312 if (aReason.length()) 313 m->mVetoList.push_back(aReason); 315 314 316 315 m->mVetoed = TRUE; … … 319 318 } 320 319 321 STDMETHODIMP VBoxVetoEvent::IsVetoed(BOOL *aResult) 322 { 323 CheckComArgOutPointerValid(aResult); 324 325 AutoCaller autoCaller(this); 326 if (FAILED(autoCaller.rc())) 327 return autoCaller.rc(); 328 329 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 330 320 HRESULT VBoxVetoEvent::isVetoed(BOOL *aResult) 321 { 322 // AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 331 323 *aResult = m->mVetoed; 332 324 … … 334 326 } 335 327 336 STDMETHODIMP VBoxVetoEvent::GetVetos(ComSafeArrayOut(BSTR, aVetos)) 337 { 338 if (ComSafeArrayOutIsNull(aVetos)) 339 return E_POINTER; 340 341 AutoCaller autoCaller(this); 342 if (FAILED(autoCaller.rc())) 343 return autoCaller.rc(); 344 345 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 346 com::SafeArray<BSTR> vetos(m->mVetoList.size()); 347 int i = 0; 348 for (VetoList::const_iterator it = m->mVetoList.begin(); 349 it != m->mVetoList.end(); 350 ++it, ++i) 351 { 352 const Bstr &str = *it; 353 str.cloneTo(&vetos[i]); 354 } 355 vetos.detachTo(ComSafeArrayOutArg(aVetos)); 328 HRESULT VBoxVetoEvent::getVetos(std::vector<com::Utf8Str> &aResult) 329 { 330 // AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 331 aResult.resize(m->mVetoList.size()); 332 size_t i = 0; 333 for (VetoList::const_iterator it = m->mVetoList.begin(); it != m->mVetoList.end(); ++it, ++i) 334 aResult[i] = (*it); 356 335 357 336 return S_OK; … … 1006 985 } 1007 986 1008 STDMETHODIMP EventSource::RegisterListener(IEventListener *aListener, 1009 ComSafeArrayIn(VBoxEventType_T, aInterested), 1010 BOOL aActive) 1011 { 1012 CheckComArgNotNull(aListener); 1013 CheckComArgSafeArrayNotNull(aInterested); 1014 1015 AutoCaller autoCaller(this); 1016 if (FAILED(autoCaller.rc())) 1017 return autoCaller.rc(); 1018 1019 { 1020 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1021 1022 if (m->fShutdown) 1023 return setError(VBOX_E_INVALID_OBJECT_STATE, 1024 tr("This event source is already shut down")); 1025 1026 Listeners::const_iterator it = m->mListeners.find(aListener); 1027 if (it != m->mListeners.end()) 1028 return setError(E_INVALIDARG, 1029 tr("This listener already registered")); 1030 1031 com::SafeArray<VBoxEventType_T> interested(ComSafeArrayInArg(aInterested)); 1032 RecordHolder<ListenerRecord> lrh(new ListenerRecord(aListener, interested, aActive, this)); 1033 m->mListeners.insert(Listeners::value_type(aListener, lrh)); 1034 } 987 HRESULT EventSource::registerListener(const ComPtr<IEventListener> &aListener, 988 const std::vector<VBoxEventType_T> &aInteresting, 989 BOOL aActive) 990 { 991 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 992 993 if (m->fShutdown) 994 return setError(VBOX_E_INVALID_OBJECT_STATE, 995 tr("This event source is already shut down")); 996 997 Listeners::const_iterator it = m->mListeners.find(aListener); 998 if (it != m->mListeners.end()) 999 return setError(E_INVALIDARG, 1000 tr("This listener already registered")); 1001 1002 com::SafeArray<VBoxEventType_T> interested(aInteresting); 1003 RecordHolder<ListenerRecord> lrh(new ListenerRecord(aListener, interested, aActive, this)); 1004 m->mListeners.insert(Listeners::value_type((IEventListener *)aListener, lrh)); 1035 1005 1036 1006 VBoxEventDesc evDesc; 1037 evDesc.init(this, VBoxEventType_OnEventSourceChanged, aListener, TRUE);1007 evDesc.init(this, VBoxEventType_OnEventSourceChanged, (IEventListener *)aListener, TRUE); 1038 1008 evDesc.fire(0); 1039 1009 … … 1041 1011 } 1042 1012 1043 STDMETHODIMP EventSource::UnregisterListener(IEventListener *aListener) 1044 { 1045 CheckComArgNotNull(aListener); 1046 1047 AutoCaller autoCaller(this); 1048 if (FAILED(autoCaller.rc())) 1049 return autoCaller.rc(); 1050 1051 HRESULT rc; 1052 { 1053 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1054 1055 Listeners::iterator it = m->mListeners.find(aListener); 1056 1057 if (it != m->mListeners.end()) 1058 { 1059 it->second.obj()->shutdown(); 1060 m->mListeners.erase(it); 1061 // destructor removes refs from the event map 1062 rc = S_OK; 1063 } 1064 else 1065 { 1066 rc = setError(VBOX_E_OBJECT_NOT_FOUND, 1067 tr("Listener was never registered")); 1068 } 1013 HRESULT EventSource::unregisterListener(const ComPtr<IEventListener> &aListener) 1014 { 1015 HRESULT rc = S_OK;; 1016 1017 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1018 1019 Listeners::iterator it = m->mListeners.find(aListener); 1020 1021 if (it != m->mListeners.end()) 1022 { 1023 it->second.obj()->shutdown(); 1024 m->mListeners.erase(it); 1025 // destructor removes refs from the event map 1026 rc = S_OK; 1027 } 1028 else 1029 { 1030 rc = setError(VBOX_E_OBJECT_NOT_FOUND, 1031 tr("Listener was never registered")); 1069 1032 } 1070 1033 … … 1072 1035 { 1073 1036 VBoxEventDesc evDesc; 1074 evDesc.init(this, VBoxEventType_OnEventSourceChanged, aListener, FALSE);1037 evDesc.init(this, VBoxEventType_OnEventSourceChanged, (IEventListener *)aListener, FALSE); 1075 1038 evDesc.fire(0); 1076 1039 } … … 1079 1042 } 1080 1043 1081 STDMETHODIMP EventSource::FireEvent(IEvent *aEvent, 1082 LONG aTimeout, 1083 BOOL *aProcessed) 1084 { 1085 CheckComArgNotNull(aEvent); 1086 CheckComArgOutPointerValid(aProcessed); 1087 1088 AutoCaller autoCaller(this); 1089 if (FAILED(autoCaller.rc())) 1090 return autoCaller.rc(); 1091 1092 HRESULT hrc; 1044 HRESULT EventSource::fireEvent(const ComPtr<IEvent> &aEvent, 1045 LONG aTimeout, 1046 BOOL *aResult) 1047 { 1048 1049 HRESULT hrc = S_OK; 1093 1050 BOOL aWaitable = FALSE; 1094 1051 aEvent->COMGETTER(Waitable)(&aWaitable); … … 1158 1115 1159 1116 if (aWaitable) 1160 hrc = aEvent->WaitProcessed(aTimeout, a Processed);1117 hrc = aEvent->WaitProcessed(aTimeout, aResult); 1161 1118 else 1162 *a Processed= TRUE;1119 *aResult = TRUE; 1163 1120 1164 1121 return hrc; 1165 1122 } 1166 1123 1167 1168 STDMETHODIMP EventSource::GetEvent(IEventListener *aListener, 1169 LONG aTimeout, 1170 IEvent **aEvent) 1171 { 1172 1173 CheckComArgNotNull(aListener); 1174 1175 AutoCaller autoCaller(this); 1176 if (FAILED(autoCaller.rc())) 1177 return autoCaller.rc(); 1178 1124 HRESULT EventSource::getEvent(const ComPtr<IEventListener> &aListener, 1125 LONG aTimeout, 1126 ComPtr<IEvent> &aEvent) 1127 { 1179 1128 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1180 1129 … … 1184 1133 1185 1134 Listeners::iterator it = m->mListeners.find(aListener); 1186 HRESULT rc; 1135 HRESULT rc = S_OK; 1136 1137 IEvent *ae = aEvent; 1187 1138 1188 1139 if (it != m->mListeners.end()) 1189 rc = it->second.obj()->dequeue( aEvent, aTimeout, alock);1140 rc = it->second.obj()->dequeue(&ae, aTimeout, alock); 1190 1141 else 1191 1142 rc = setError(VBOX_E_OBJECT_NOT_FOUND, … … 1198 1149 } 1199 1150 1200 STDMETHODIMP EventSource::EventProcessed(IEventListener *aListener, 1201 IEvent *aEvent) 1202 { 1203 CheckComArgNotNull(aListener); 1204 CheckComArgNotNull(aEvent); 1205 1206 AutoCaller autoCaller(this); 1207 if (FAILED(autoCaller.rc())) 1208 return autoCaller.rc(); 1209 1151 HRESULT EventSource::eventProcessed(const ComPtr<IEventListener> &aListener, 1152 const ComPtr<IEvent> &aEvent) 1153 { 1210 1154 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1211 1155 … … 1391 1335 1392 1336 // internal public 1393 HRESULT init( ComSafeArrayIn(IEventSource *, aSources));1337 HRESULT init(const std::vector<ComPtr<IEventSource> > aSourcesIn); 1394 1338 1395 1339 // IEventSource methods … … 1423 1367 NS_DECL_CLASSINFO(PassiveEventListener) 1424 1368 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(PassiveEventListener, IEventListener) 1425 NS_DECL_CLASSINFO(VBoxEvent)1426 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VBoxEvent, IEvent)1427 NS_DECL_CLASSINFO(VBoxVetoEvent)1428 1369 NS_IMPL_ISUPPORTS_INHERITED1(VBoxVetoEvent, VBoxEvent, IVetoEvent) 1429 NS_DECL_CLASSINFO(EventSource)1430 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(EventSource, IEventSource)1431 1370 NS_DECL_CLASSINFO(EventSourceAggregator) 1432 1371 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(EventSourceAggregator, IEventSource) … … 1434 1373 1435 1374 1436 STDMETHODIMP EventSource::CreateListener(IEventListener **aListener) 1437 { 1438 CheckComArgOutPointerValid(aListener); 1439 1440 AutoCaller autoCaller(this); 1441 if (FAILED(autoCaller.rc())) 1442 return autoCaller.rc(); 1443 1375 HRESULT EventSource::createListener(ComPtr<IEventListener> &aListener) 1376 { 1444 1377 ComObjPtr<PassiveEventListener> listener; 1445 1378 … … 1447 1380 ComAssertMsgRet(SUCCEEDED(rc), ("Could not create wrapper object (%Rhrc)", rc), 1448 1381 E_FAIL); 1449 listener.queryInterfaceTo(aListener); 1450 return S_OK; 1451 } 1452 1453 1454 STDMETHODIMP EventSource::CreateAggregator(ComSafeArrayIn(IEventSource *, aSubordinates), 1455 IEventSource **aResult) 1456 { 1457 CheckComArgOutPointerValid(aResult); 1458 1459 AutoCaller autoCaller(this); 1460 if (FAILED(autoCaller.rc())) 1461 return autoCaller.rc(); 1462 1382 listener.queryInterfaceTo(aListener.asOutParam()); 1383 return S_OK; 1384 } 1385 1386 HRESULT EventSource::createAggregator(const std::vector<ComPtr<IEventSource> > &aSubordinates, 1387 ComPtr<IEventSource> &aResult) 1388 { 1463 1389 ComObjPtr<EventSourceAggregator> agg; 1464 1390 … … 1467 1393 E_FAIL); 1468 1394 1469 rc = agg->init( ComSafeArrayInArg(aSubordinates));1395 rc = agg->init(aSubordinates); 1470 1396 if (FAILED(rc)) 1471 1397 return rc; 1472 1398 1473 agg.queryInterfaceTo(aResult );1474 return S_OK; 1475 } 1476 1477 HRESULT EventSourceAggregator::init( ComSafeArrayIn(IEventSource *, aSourcesIn))1399 agg.queryInterfaceTo(aResult.asOutParam()); 1400 return S_OK; 1401 } 1402 1403 HRESULT EventSourceAggregator::init(const std::vector<ComPtr<IEventSource> > aSourcesIn) 1478 1404 { 1479 1405 HRESULT rc; … … 1489 1415 E_FAIL); 1490 1416 1491 com::SafeIfaceArray<IEventSource> aSources(ComSafeArrayInArg (aSourcesIn)); 1492 1493 size_t cSize = aSources.size(); 1494 1495 for (size_t i = 0; i < cSize; i++) 1496 { 1497 if (aSources[i] != NULL) 1498 mEventSources.push_back(aSources[i]); 1417 for (size_t i = 0; i < aSourcesIn.size(); i++) 1418 { 1419 if (aSourcesIn[i] != NULL) 1420 mEventSources.push_back(aSourcesIn[i]); 1499 1421 } 1500 1422
Note:
See TracChangeset
for help on using the changeset viewer.