Changeset 85286 in vbox
- Timestamp:
- Jul 12, 2020 11:08:50 PM (4 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/comimpl.xsl
r82972 r85286 127 127 <xsl:choose> 128 128 <xsl:when test="$mod='ptr'"> 129 <xsl:value-of select="'BYTE *'" />129 <xsl:value-of select="'BYTE *'" /> 130 130 </xsl:when> 131 131 <xsl:when test="(($type='wstring') or ($type='uuid'))"> … … 148 148 <xsl:choose> 149 149 <xsl:when test="$param"> 150 <xsl:value-of select="concat($type,' *')"/>150 <xsl:value-of select="concat($type,' *')"/> 151 151 </xsl:when> 152 152 <xsl:otherwise> … … 186 186 </xsl:choose> 187 187 <xsl:if test="$dir='out'"> 188 <xsl:value-of select="' *'"/>188 <xsl:value-of select="' *'"/> 189 189 </xsl:if> 190 190 <xsl:if test="$param and not($param='_')"> … … 258 258 <xsl:param name="name" /> 259 259 <xsl:param name="obj" /> 260 <xsl:param name="va" select="true" /> 260 261 <xsl:variable name="extends"> 261 262 <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" /> … … 271 272 <xsl:with-param name="name" select="$extends" /> 272 273 <xsl:with-param name="obj" select="$obj" /> 274 <xsl:with-param name="va" select="$va" /> 273 275 </xsl:call-template> 274 276 </xsl:when> … … 310 312 </xsl:call-template> 311 313 </xsl:variable> 312 <xsl:value-of select=" '#ifdef RT_OS_WINDOWS '"/> 313 <xsl:value-of select="concat(' SAFEARRAY *aPtr_', @name, ' = va_arg(args, SAFEARRAY *); ')"/> 314 <xsl:value-of select="concat(' com::SafeArray<', $elemtype,'> aArr_', @name, '(aPtr_', @name, '); ')"/> 315 <xsl:value-of select=" '#else '"/> 316 <xsl:value-of select="concat(' PRUint32 aArrSize_', @name, ' = va_arg(args, PRUint32); ')"/> 317 <xsl:value-of select="concat(' void* aPtr_', @name, ' = va_arg(args, void*); ')"/> 318 <xsl:value-of select="concat(' com::SafeArray<', $elemtype,'> aArr_', @name, '(aArrSize_', @name, ', (', $elemtype,'*)aPtr_', @name, '); ')"/> 319 <xsl:value-of select=" '#endif '"/> 320 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(ComSafeArrayAsInParam(aArr_', @name, ')); ')"/> 314 <xsl:if test="$va"> 315 <xsl:value-of select=" '#ifdef RT_OS_WINDOWS '"/> 316 <xsl:value-of select="concat(' SAFEARRAY *aPtr_', @name, ' = va_arg(args, SAFEARRAY *); ')"/> 317 <xsl:value-of select="concat(' com::SafeArray<', $elemtype,'> aArr_', @name, '(aPtr_', @name, '); ')"/> 318 <xsl:value-of select=" '#else '"/> 319 <xsl:value-of select="concat(' PRUint32 aArrSize_', @name, ' = va_arg(args, PRUint32); ')"/> 320 <xsl:value-of select="concat(' void* aPtr_', @name, ' = va_arg(args, void*); ')"/> 321 <xsl:value-of select="concat(' com::SafeArray<', $elemtype,'> aArr_', @name, '(aArrSize_', @name, ', (', $elemtype,'*)aPtr_', @name, '); ')"/> 322 <xsl:value-of select=" '#endif '"/> 323 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(ComSafeArrayAsInParam(aArr_', @name, ')); ')"/> 324 </xsl:if> 325 <xsl:if test="not($va)"> 326 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(ComSafeArrayInArg(a_', @name, ')); ')"/> 327 </xsl:if> 321 328 </xsl:when> 322 329 <xsl:when test="substring($aType, string-length($aType) - 1) = '_T'"> <!-- To avoid pedantic gcc warnings/errors. --> 323 <xsl:value-of select=" '#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK '"/> 324 <xsl:value-of select="concat(' ',$aTypeName, ' = (',$aType,')va_arg(args, int); ')"/> 325 <xsl:value-of select=" '#else '"/> 326 <xsl:value-of select="concat(' ',$aTypeName, ' = va_arg(args, ',$aType,'); ')"/> 327 <xsl:value-of select=" '#endif '"/> 328 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(',$aName, '); ')"/> 330 <xsl:if test="$va"> 331 <xsl:value-of select=" '#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK '"/> 332 <xsl:value-of select="concat(' ',$aTypeName, ' = (',$aType,')va_arg(args, int); ')"/> 333 <xsl:value-of select=" '#else '"/> 334 <xsl:value-of select="concat(' ',$aTypeName, ' = va_arg(args, ',$aType,'); ')"/> 335 <xsl:value-of select=" '#endif '"/> 336 </xsl:if> 337 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(',$aName, '); ')"/> 329 338 </xsl:when> 330 339 <xsl:otherwise> 331 <xsl:value-of select="concat(' ',$aTypeName, ' = va_arg(args, ',$aType,'); ')"/> 332 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(',$aName, '); ')"/> 340 <xsl:if test="$va"> 341 <xsl:value-of select="concat(' ',$aTypeName, ' = va_arg(args, ',$aType,'); ')"/> 342 </xsl:if> 343 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(',$aName, '); ')"/> 333 344 </xsl:otherwise> 334 345 </xsl:choose> … … 489 500 490 501 <xsl:value-of select="concat('class ATL_NO_VTABLE ',$implName, 491 ' : public VirtualBoxBase , VBOX_SCRIPTABLE_IMPL(',502 ' : public VirtualBoxBase , VBOX_SCRIPTABLE_IMPL(', 492 503 @name, ') { ')" /> 493 504 <xsl:value-of select="'public: '" /> … … 550 561 <xsl:when test="$isVeto='yes'"> 551 562 <xsl:text><![CDATA[ 552 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable = TRUE)563 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable = TRUE) 553 564 { 554 565 NOREF(aWaitable); … … 586 597 <xsl:text> 587 598 <![CDATA[ 588 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable = FALSE)599 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable = FALSE) 589 600 { 590 601 mGeneration = 1; … … 593 604 STDMETHOD(COMGETTER(Generation))(ULONG *aGeneration) 594 605 { 595 *aGeneration = mGeneration;596 return S_OK;606 *aGeneration = mGeneration; 607 return S_OK; 597 608 } 598 609 STDMETHOD(Reuse)() 599 610 { 600 ASMAtomicIncU32((volatile uint32_t*)&mGeneration);601 return S_OK;611 ASMAtomicIncU32((volatile uint32_t *)&mGeneration); 612 return S_OK; 602 613 } 603 614 private: … … 608 619 <xsl:otherwise> 609 620 <xsl:text><![CDATA[ 610 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable)621 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable) 611 622 { 612 623 return mEvent->init(aSource, aType, aWaitable); … … 637 648 <xsl:with-param name="parents" select="''" /> 638 649 </xsl:call-template> 650 651 <!-- Split off the remainer into separate template? --> 652 <xsl:variable name="evname"> 653 <xsl:value-of select="substring(@name, 2)" /> 654 </xsl:variable> 655 <xsl:variable name="evid"> 656 <xsl:value-of select="concat('On', substring(@name, 2, string-length(@name)-6))" /> 657 </xsl:variable> 658 <xsl:variable name="ifname"> 659 <xsl:value-of select="@name" /> 660 </xsl:variable> 661 <xsl:variable name="waitable"> 662 <xsl:choose> 663 <xsl:when test="@waitable='yes'"> 664 <xsl:value-of select="'TRUE'"/> 665 </xsl:when> 666 <xsl:otherwise> 667 <xsl:value-of select="'FALSE'"/> 668 </xsl:otherwise> 669 </xsl:choose> 670 </xsl:variable> 671 672 <!-- Generate ReinitXxxxEvent functions if reusable. --> 673 <xsl:if test="$isReusable='yes'"> 674 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Reinit', $evname, '(IEvent *aEvent')"/> 675 <xsl:call-template name="genFormalParams"> 676 <xsl:with-param name="name" select="$ifname" /> 677 </xsl:call-template> 678 <xsl:text>) </xsl:text> 679 <xsl:text>{ </xsl:text> 680 <xsl:text> </xsl:text><xsl:value-of select="$implName"/><xsl:text> *pEvtImpl = dynamic_cast<</xsl:text> 681 <xsl:value-of select="$implName"/><xsl:text> *>(aEvent); </xsl:text> 682 <xsl:text> if (pEvtImpl) </xsl:text> 683 <xsl:text> { </xsl:text> 684 <xsl:text> pEvtImpl->Reuse(); </xsl:text> 685 <xsl:text> { </xsl:text> 686 <xsl:call-template name="genAttrInitCode"> 687 <xsl:with-param name="name" select="@name" /> 688 <xsl:with-param name="obj" select="'pEvtImpl'" /> 689 <xsl:with-param name="va" select="false" /> 690 </xsl:call-template> 691 <xsl:text> } </xsl:text> 692 <xsl:text> return S_OK; </xsl:text> 693 <xsl:text> } </xsl:text> 694 <xsl:text> return E_INVALIDARG; </xsl:text> 695 <xsl:text>} </xsl:text> 696 <xsl:text> </xsl:text> 697 </xsl:if> 698 699 <!-- Generate the CreateXxxxEvent function. --> 700 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Create', $evname, '(IEvent **aEvent, IEventSource *aSource')"/> 701 <xsl:call-template name="genFormalParams"> 702 <xsl:with-param name="name" select="$ifname" /> 703 </xsl:call-template> 704 <xsl:text>) </xsl:text> 705 <xsl:text>{ </xsl:text> 706 <xsl:text> ComObjPtr<</xsl:text><xsl:value-of select="$implName"/><xsl:text>> EvtObj; </xsl:text> 707 <xsl:text> HRESULT hrc = EvtObj.createObject(); </xsl:text> 708 <xsl:text> if (SUCCEEDED(hrc)) </xsl:text> 709 <xsl:text> { </xsl:text> 710 <xsl:text> hrc = EvtObj->init(aSource, VBoxEventType_</xsl:text><xsl:value-of select="$evid"/> 711 <xsl:text>, </xsl:text><xsl:value-of select="$waitable" /><xsl:text> /*waitable*/); </xsl:text> 712 <xsl:text> if (SUCCEEDED(hrc)) </xsl:text> 713 <xsl:text> { </xsl:text> 714 <xsl:call-template name="genAttrInitCode"> 715 <xsl:with-param name="name" select="@name" /> 716 <xsl:with-param name="obj" select="'EvtObj'" /> 717 <xsl:with-param name="va" select="false" /> 718 </xsl:call-template> 719 <xsl:text> hrc = EvtObj.queryInterfaceTo(aEvent); </xsl:text> 720 <xsl:text> } </xsl:text> 721 <xsl:text> } </xsl:text> 722 <xsl:text> return hrc; </xsl:text> 723 <xsl:text>} </xsl:text> 724 <xsl:text> </xsl:text> 725 726 <!-- Generate the fireXxxxEvent function. --> 727 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) fire', $evname, '(IEventSource *aSource')"/> 728 <xsl:call-template name="genFormalParams"> 729 <xsl:with-param name="name" select="$ifname" /> 730 </xsl:call-template> 731 <xsl:text>) </xsl:text> 732 <xsl:text>{ </xsl:text> 733 <xsl:text> ComPtr<IEvent> ptrEvent; </xsl:text> 734 <xsl:text> HRESULT hrc = </xsl:text> 735 <xsl:value-of select="concat('Create', $evname, '(ptrEvent.asOutParam(), aSource')"/> 736 <xsl:call-template name="genFactParams"> 737 <xsl:with-param name="name" select="$ifname" /> 738 </xsl:call-template> 739 <xsl:text>); </xsl:text> 740 <xsl:text> if (SUCCEEDED(hrc)) </xsl:text> 741 <xsl:text> { </xsl:text> 742 <xsl:text> VBoxEventDesc EvtDesc(ptrEvent, aSource); </xsl:text> 743 <xsl:text> EvtDesc.fire(/* do not wait for delivery */ 0); </xsl:text> 744 <xsl:text> } </xsl:text> 745 <xsl:text> return hrc; </xsl:text> 746 <xsl:text>} </xsl:text> 747 <xsl:text> </xsl:text> 639 748 640 749 </xsl:template> … … 691 800 #include <iprt/asm.h> 692 801 #include "EventImpl.h" 802 #include "VBoxEvents.h" 693 803 ]]></xsl:text> 694 804 … … 723 833 724 834 <xsl:text><![CDATA[ 835 #if 0 725 836 HRESULT VBoxEventDesc::init(IEventSource *aSource, VBoxEventType_T aType, ...) 726 837 { … … 752 863 return S_OK; 753 864 } 865 #endif 754 866 ]]></xsl:text> 755 867 756 868 <xsl:text><![CDATA[ 869 #if 0 757 870 HRESULT VBoxEventDesc::reinit(VBoxEventType_T aType, ...) 758 871 { … … 783 896 return S_OK; 784 897 } 898 #endif 785 899 ]]></xsl:text> 786 900 … … 868 982 <xsl:text><![CDATA[ 869 983 #include "EventImpl.h" 984 870 985 ]]></xsl:text> 871 986 872 <!-- Interfaces --> 987 <!-- Simple methods for firing off events. --> 988 <xsl:text>/** @name Fire off events </xsl:text> 989 <xsl:text> * @{ */ </xsl:text> 873 990 <xsl:for-each select="//interface[@autogen='VBoxEvent']"> 874 <xsl:value-of select="concat('/ / ', @name, ' generation routine ')" />991 <xsl:value-of select="concat('/** Fire an ', @name, ' event. */ ')" /> 875 992 <xsl:variable name="evname"> 876 993 <xsl:value-of select="substring(@name, 2)" /> … … 884 1001 </xsl:variable> 885 1002 886 <xsl:value-of select="concat('DECLINLINE(void) fire', $evname, '(IEventSource* aSource')"/> 1003 <!-- 1004 OLD: 1005 <xsl:value-of select="concat('DECLINLINE(void) fire', $evname, '(IEventSource *aSource')"/> 887 1006 <xsl:call-template name="genFormalParams"> 888 1007 <xsl:with-param name="name" select="$ifname" /> … … 898 1017 <xsl:value-of select=" ' evDesc.fire(/* do not wait for delivery */ 0); '"/> 899 1018 <xsl:value-of select=" '} '"/> 1019 1020 NEW: 1021 --> 1022 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) fire', $evname, '(IEventSource *aSource')"/> 1023 <xsl:call-template name="genFormalParams"> 1024 <xsl:with-param name="name" select="$ifname" /> 1025 </xsl:call-template> 1026 <xsl:text>); </xsl:text> 900 1027 </xsl:for-each> 1028 <xsl:text>/** @} */ </xsl:text> 1029 1030 <!-- Event instantiation methods. --> 1031 <xsl:text>/** @name Instantiate events </xsl:text> 1032 <xsl:text> * @{ */ </xsl:text> 1033 <xsl:for-each select="//interface[@autogen='VBoxEvent']"> 1034 <xsl:value-of select="concat('/** Create an ', @name, ' event. */ ')" /> 1035 <xsl:variable name="evname"> 1036 <xsl:value-of select="substring(@name, 2)" /> 1037 </xsl:variable> 1038 <xsl:variable name="evid"> 1039 <xsl:value-of select="concat('On', substring(@name, 2, string-length(@name)-6))" /> 1040 </xsl:variable> 1041 <xsl:variable name="ifname"> 1042 <xsl:value-of select="@name" /> 1043 </xsl:variable> 1044 1045 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Create', $evname, '(IEvent **aEvent, IEventSource *aSource')"/> 1046 <xsl:call-template name="genFormalParams"> 1047 <xsl:with-param name="name" select="$ifname" /> 1048 </xsl:call-template> 1049 <xsl:text>); </xsl:text> 1050 </xsl:for-each> 1051 <xsl:text>/** @} */ </xsl:text> 1052 <xsl:text> </xsl:text> 1053 1054 <!-- Reinitialization methods for reusable events. --> 1055 <xsl:text>/** @name Re-init reusable events </xsl:text> 1056 <xsl:text> * @{ */ </xsl:text> 1057 <xsl:for-each select="//interface[@autogen='VBoxEvent']"> 1058 <xsl:if test="@extends='IReusableEvent'"> 1059 <xsl:value-of select="concat('/** Re-init an ', @name, ' event. */ ')" /> 1060 <xsl:variable name="evname"> 1061 <xsl:value-of select="substring(@name, 2)" /> 1062 </xsl:variable> 1063 <xsl:variable name="ifname"> 1064 <xsl:value-of select="@name" /> 1065 </xsl:variable> 1066 1067 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Reinit', $evname, '(IEvent *aEvent')"/> 1068 <xsl:call-template name="genFormalParams"> 1069 <xsl:with-param name="name" select="$ifname" /> 1070 </xsl:call-template> 1071 <xsl:text>); </xsl:text> 1072 </xsl:if> 1073 </xsl:for-each> 1074 <xsl:text>/** @} */ </xsl:text> 1075 901 1076 </xsl:template> 902 1077 -
trunk/src/VBox/Main/include/EventImpl.h
r85240 r85286 27 27 28 28 29 class ATL_NO_VTABLE VBoxEvent :30 public EventWrap29 class ATL_NO_VTABLE VBoxEvent 30 : public EventWrap 31 31 { 32 32 public: … … 55 55 56 56 57 class ATL_NO_VTABLE VBoxVetoEvent :58 public VetoEventWrap57 class ATL_NO_VTABLE VBoxVetoEvent 58 : public VetoEventWrap 59 59 { 60 60 public: … … 123 123 124 124 struct Data; 125 Data *m;125 Data *m; 126 126 127 127 friend class ListenerRecord; … … 134 134 {} 135 135 136 VBoxEventDesc(IEvent *aEvent, IEventSource *aSource) 137 : mEvent(aEvent), mEventSource(aSource) 138 {} 139 136 140 ~VBoxEventDesc() 137 141 {} 138 142 143 144 #if 0 139 145 /** 140 146 * This function to be used with some care, as arguments order must match … … 150 156 */ 151 157 HRESULT reinit(VBoxEventType_T aType, ...); 158 #endif 159 160 void init(IEvent *aEvent, IEventSource *aSource) 161 { 162 mEvent = aEvent; 163 mEventSource = aSource; 164 } 152 165 153 166 void uninit() -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r85121 r85286 91 91 typedef ObjectsList<Machine> MachinesOList; 92 92 93 #if 0 /* obsoleted by AsyncEvent */ 93 94 class CallbackEvent; 94 95 friend class CallbackEvent; 96 #endif 97 class AsyncEvent; 98 friend class AsyncEvent; 95 99 96 100 #ifndef VBOX_WITH_XPCOM -
trunk/src/VBox/Main/src-all/EventImpl.cpp
r85239 r85286 58 58 #include "AutoCaller.h" 59 59 #include "LoggingNew.h" 60 #include "VBoxEvents.h" 60 61 61 62 #include <iprt/asm.h> … … 1073 1074 m->mListeners.insert(Listeners::value_type((IEventListener *)aListener, lrh)); 1074 1075 1075 VBoxEventDesc evDesc; 1076 evDesc.init(this, VBoxEventType_OnEventSourceChanged, (IEventListener *)aListener, TRUE); 1077 evDesc.fire(0); 1076 fireEventSourceChangedEvent(this, (IEventListener *)aListener, TRUE /*add*/); 1078 1077 1079 1078 return S_OK; … … 1093 1092 m->mListeners.erase(it); 1094 1093 // destructor removes refs from the event map 1094 fireEventSourceChangedEvent(this, (IEventListener *)aListener, FALSE /*add*/); 1095 1095 rc = S_OK; 1096 1096 } 1097 1097 else 1098 {1099 1098 rc = setError(VBOX_E_OBJECT_NOT_FOUND, 1100 1099 tr("Listener was never registered")); 1101 }1102 1103 if (SUCCEEDED(rc))1104 {1105 VBoxEventDesc evDesc;1106 evDesc.init(this, VBoxEventType_OnEventSourceChanged, (IEventListener *)aListener, FALSE);1107 evDesc.fire(0);1108 }1109 1100 1110 1101 return rc; -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r84618 r85286 7358 7358 AssertComRCReturnRC(autoCaller.rc()); 7359 7359 7360 VBoxEventDesc evDesc;7360 ComPtr<IEvent> ptrEvent; 7361 7361 if (aCheck) 7362 7362 { 7363 evDesc.init(mEventSource, VBoxEventType_OnCanShowWindow); 7364 BOOL fDelivered = evDesc.fire(5000); /* Wait up to 5 secs for delivery */ 7365 //Assert(fDelivered); 7366 if (fDelivered) 7367 { 7368 ComPtr<IEvent> pEvent; 7369 evDesc.getEvent(pEvent.asOutParam()); 7370 // bit clumsy 7371 ComPtr<ICanShowWindowEvent> pCanShowEvent = pEvent; 7372 if (pCanShowEvent) 7363 *aCanShow = TRUE; 7364 HRESULT hrc = CreateCanShowWindowEvent(ptrEvent.asOutParam(), mEventSource); 7365 if (SUCCEEDED(hrc)) 7366 { 7367 VBoxEventDesc EvtDesc(ptrEvent, mEventSource); 7368 BOOL fDelivered = EvtDesc.fire(5000); /* Wait up to 5 secs for delivery */ 7369 //Assert(fDelivered); 7370 if (fDelivered) 7373 7371 { 7374 BOOL fVetoed = FALSE; 7375 BOOL fApproved = FALSE; 7376 pCanShowEvent->IsVetoed(&fVetoed); 7377 pCanShowEvent->IsApproved(&fApproved); 7378 *aCanShow = fApproved || !fVetoed; 7372 // bit clumsy 7373 ComPtr<ICanShowWindowEvent> ptrCanShowEvent = ptrEvent; 7374 if (ptrCanShowEvent) 7375 { 7376 BOOL fVetoed = FALSE; 7377 BOOL fApproved = FALSE; 7378 ptrCanShowEvent->IsVetoed(&fVetoed); 7379 ptrCanShowEvent->IsApproved(&fApproved); 7380 *aCanShow = fApproved || !fVetoed; 7381 } 7382 else 7383 AssertFailed(); 7379 7384 } 7380 else 7385 } 7386 } 7387 else 7388 { 7389 HRESULT hrc = CreateShowWindowEvent(ptrEvent.asOutParam(), mEventSource, 0); 7390 if (SUCCEEDED(hrc)) 7391 { 7392 VBoxEventDesc EvtDesc(ptrEvent, mEventSource); 7393 BOOL fDelivered = EvtDesc.fire(5000); /* Wait up to 5 secs for delivery */ 7394 //Assert(fDelivered); 7395 if (fDelivered) 7381 7396 { 7382 AssertFailed(); 7383 *aCanShow = TRUE; 7397 ComPtr<IShowWindowEvent> ptrShowEvent = ptrEvent; 7398 if (ptrShowEvent) 7399 { 7400 LONG64 idWindow = 0; 7401 ptrShowEvent->COMGETTER(WinId)(&idWindow); 7402 if (idWindow != 0 && *aWinId == 0) 7403 *aWinId = idWindow; 7404 } 7405 else 7406 AssertFailed(); 7384 7407 } 7385 }7386 else7387 *aCanShow = TRUE;7388 }7389 else7390 {7391 evDesc.init(mEventSource, VBoxEventType_OnShowWindow, INT64_C(0));7392 BOOL fDelivered = evDesc.fire(5000); /* Wait up to 5 secs for delivery */7393 //Assert(fDelivered);7394 if (fDelivered)7395 {7396 ComPtr<IEvent> pEvent;7397 evDesc.getEvent(pEvent.asOutParam());7398 ComPtr<IShowWindowEvent> pShowEvent = pEvent;7399 if (pShowEvent)7400 {7401 LONG64 iEvWinId = 0;7402 pShowEvent->COMGETTER(WinId)(&iEvWinId);7403 if (iEvWinId != 0 && *aWinId == 0)7404 *aWinId = iEvWinId;7405 }7406 else7407 AssertFailed();7408 7408 } 7409 7409 } -
trunk/src/VBox/Main/src-client/KeyboardImpl.cpp
r82968 r85286 23 23 24 24 #include "AutoCaller.h" 25 #include "VBoxEvents.h" 25 26 26 27 #include <VBox/com/array.h> … … 212 213 keys[i] = aScancodes[i]; 213 214 214 VBoxEventDesc evDesc; 215 evDesc.init(mEventSource, VBoxEventType_OnGuestKeyboard, ComSafeArrayAsInParam(keys)); 216 evDesc.fire(0); 215 fireGuestKeyboardEvent(mEventSource, ComSafeArrayAsInParam(keys)); 217 216 218 217 if (RT_FAILURE(vrc)) -
trunk/src/VBox/Main/src-client/MouseImpl.cpp
r82968 r85286 25 25 #include "VMMDev.h" 26 26 #include "MousePointerShapeWrap.h" 27 #include "VBoxEvents.h" 27 28 28 29 #include <VBox/vmm/pdmdrv.h> … … 266 267 HRESULT rc = mEventSource->init(); 267 268 AssertComRCReturnRC(rc); 268 mMouseEvent.init(mEventSource, VBoxEventType_OnGuestMouse, 269 0, 0, 0, 0, 0, 0); 269 270 ComPtr<IEvent> ptrEvent; 271 rc = CreateGuestMouseEvent(ptrEvent.asOutParam(), mEventSource, 272 (GuestMouseEventMode_T)0, 0 /*x*/, 0 /*y*/, 0 /*z*/, 0 /*w*/, 0 /*buttons*/); 273 AssertComRCReturnRC(rc); 274 mMouseEvent.init(ptrEvent, mEventSource); 270 275 271 276 /* Confirm a successful initialization */ … … 688 693 689 694 if (fButtons != 0) 690 { 691 VBoxEventDesc evDesc; 692 evDesc.init(mEventSource, VBoxEventType_OnGuestMouse, mode, x, y, 693 dz, dw, fButtons); 694 evDesc.fire(0); 695 } 695 fireGuestMouseEvent(mEventSource, mode, x, y, dz, dw, fButtons); 696 696 else 697 697 { 698 mMouseEvent.reinit(VBoxEventType_OnGuestMouse, mode, x, y, dz, dw, 699 fButtons); 698 ComPtr<IEvent> ptrEvent; 699 mMouseEvent.getEvent(ptrEvent.asOutParam()); 700 ReinitGuestMouseEvent(ptrEvent, mode, x, y, dz, dw, fButtons); 700 701 mMouseEvent.fire(0); 701 702 } … … 722 723 } 723 724 724 VBoxEventDesc evDesc; 725 evDesc.init(mEventSource, VBoxEventType_OnGuestMultiTouch, 726 cContacts, ComSafeArrayAsInParam(xPositions), ComSafeArrayAsInParam(yPositions), 727 ComSafeArrayAsInParam(contactIds), ComSafeArrayAsInParam(contactFlags), u32ScanTime); 728 evDesc.fire(0); 725 fireGuestMultiTouchEvent(mEventSource, cContacts, ComSafeArrayAsInParam(xPositions), ComSafeArrayAsInParam(yPositions), 726 ComSafeArrayAsInParam(contactIds), ComSafeArrayAsInParam(contactFlags), u32ScanTime); 729 727 } 730 728 -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r85262 r85286 90 90 #include "CloudProviderManagerImpl.h" 91 91 #include "ThreadTask.h" 92 #include "VBoxEvents.h" 92 93 93 94 #include <QMTranslator.h> … … 135 136 136 137 138 #if 0 /* obsoleted by AsyncEvent */ 137 139 //////////////////////////////////////////////////////////////////////////////// 138 140 // … … 173 175 protected: 174 176 VBoxEventType_T mWhat; 177 }; 178 #endif 179 180 //////////////////////////////////////////////////////////////////////////////// 181 // 182 // AsyncEvent class 183 // 184 //////////////////////////////////////////////////////////////////////////////// 185 186 /** 187 * For firing off an event on asynchronously on an event thread. 188 */ 189 class VirtualBox::AsyncEvent : public Event 190 { 191 public: 192 AsyncEvent(VirtualBox *a_pVirtualBox, ComPtr<IEvent> const &a_rEvent) 193 : mVirtualBox(a_pVirtualBox), mEvent(a_rEvent) 194 { 195 Assert(a_pVirtualBox); 196 } 197 198 void *handler() RT_OVERRIDE; 199 200 private: 201 /** 202 * @note This is a weak ref -- the CallbackEvent handler thread is bound to the 203 * lifetime of the VirtualBox instance, so it's safe. 204 */ 205 VirtualBox *mVirtualBox; 206 /** The event. */ 207 ComPtr<IEvent> mEvent; 175 208 }; 176 209 … … 556 589 try 557 590 { 591 /* Create the event source early as we may fire async event during settings loading (media). */ 592 rc = unconst(m->pEventSource).createObject(); 593 if (FAILED(rc)) throw rc; 594 rc = m->pEventSource->init(); 595 if (FAILED(rc)) throw rc; 596 597 558 598 /* Get the VirtualBox home directory. */ 559 599 { … … 718 758 } 719 759 #endif /* VBOX_WITH_CLOUD_NET */ 720 721 /* events */722 if (SUCCEEDED(rc = unconst(m->pEventSource).createObject()))723 rc = m->pEventSource->init();724 if (FAILED(rc)) throw rc;725 760 726 761 /* cloud provider manager */ … … 3188 3223 } 3189 3224 3190 /** Event for onMachineStateChange(), onMachineDataChange(), onMachineRegistered() */3191 struct MachineEvent : public VirtualBox::CallbackEvent3192 {3193 MachineEvent(VirtualBox *aVB, VBoxEventType_T aWhat, const Guid &aId, BOOL aBool)3194 : CallbackEvent(aVB, aWhat), id(aId.toUtf16())3195 , mBool(aBool)3196 { }3197 3198 MachineEvent(VirtualBox *aVB, VBoxEventType_T aWhat, const Guid &aId, MachineState_T aState)3199 : CallbackEvent(aVB, aWhat), id(aId.toUtf16())3200 , mState(aState)3201 {}3202 3203 virtual HRESULT prepareEventDesc(IEventSource* aSource, VBoxEventDesc& aEvDesc)3204 {3205 switch (mWhat)3206 {3207 case VBoxEventType_OnMachineDataChanged:3208 aEvDesc.init(aSource, mWhat, id.raw(), mBool);3209 break;3210 3211 case VBoxEventType_OnMachineStateChanged:3212 aEvDesc.init(aSource, mWhat, id.raw(), mState);3213 break;3214 3215 case VBoxEventType_OnMachineRegistered:3216 aEvDesc.init(aSource, mWhat, id.raw(), mBool);3217 break;3218 3219 default:3220 AssertFailedReturn(S_OK);3221 }3222 return S_OK;3223 }3224 3225 Bstr id;3226 MachineState_T mState;3227 BOOL mBool;3228 };3229 3230 3231 3225 /** 3232 3226 * VD plugin load … … 3245 3239 } 3246 3240 3247 3248 /** Event for onMediumRegistered() */3249 struct MediumRegisteredEventStruct : public VirtualBox::CallbackEvent3250 {3251 MediumRegisteredEventStruct(VirtualBox *aVB, const Guid &aMediumId,3252 const DeviceType_T aDevType, const BOOL aRegistered)3253 : CallbackEvent(aVB, VBoxEventType_OnMediumRegistered)3254 , mMediumId(aMediumId.toUtf16()), mDevType(aDevType), mRegistered(aRegistered)3255 {}3256 3257 virtual HRESULT prepareEventDesc(IEventSource *aSource, VBoxEventDesc &aEvDesc)3258 {3259 return aEvDesc.init(aSource, VBoxEventType_OnMediumRegistered, mMediumId.raw(), mDevType, mRegistered);3260 }3261 3262 Bstr mMediumId;3263 DeviceType_T mDevType;3264 BOOL mRegistered;3265 };3266 3267 3241 /** 3268 3242 * @note Doesn't lock any object. … … 3270 3244 void VirtualBox::i_onMediumRegistered(const Guid &aMediumId, const DeviceType_T aDevType, const BOOL aRegistered) 3271 3245 { 3272 i_postEvent(new MediumRegisteredEventStruct(this, aMediumId, aDevType, aRegistered)); 3273 } 3274 3275 /** Event for onMediumConfigChanged() */ 3276 struct MediumConfigChangedEventStruct : public VirtualBox::CallbackEvent 3277 { 3278 MediumConfigChangedEventStruct(VirtualBox *aVB, IMedium *aMedium) 3279 : CallbackEvent(aVB, VBoxEventType_OnMediumConfigChanged) 3280 , mMedium(aMedium) 3281 {} 3282 3283 virtual HRESULT prepareEventDesc(IEventSource *aSource, VBoxEventDesc &aEvDesc) 3284 { 3285 return aEvDesc.init(aSource, VBoxEventType_OnMediumConfigChanged, mMedium); 3286 } 3287 3288 IMedium* mMedium; 3289 }; 3246 ComPtr<IEvent> ptrEvent; 3247 HRESULT hrc = CreateMediumRegisteredEvent(ptrEvent.asOutParam(), m->pEventSource, 3248 aMediumId.toUtf16().raw(), aDevType, aRegistered); 3249 AssertComRCReturnVoid(hrc); 3250 i_postEvent(new AsyncEvent(this, ptrEvent)); 3251 } 3290 3252 3291 3253 void VirtualBox::i_onMediumConfigChanged(IMedium *aMedium) 3292 3254 { 3293 i_postEvent(new MediumConfigChangedEventStruct(this, aMedium)); 3294 } 3295 3296 /** Event for onMediumChanged() */ 3297 struct MediumChangedEventStruct : public VirtualBox::CallbackEvent 3298 { 3299 MediumChangedEventStruct(VirtualBox *aVB, IMediumAttachment *aMediumAttachment) 3300 : CallbackEvent(aVB, VBoxEventType_OnMediumChanged) 3301 , mMediumAttachment(aMediumAttachment) 3302 {} 3303 3304 virtual HRESULT prepareEventDesc(IEventSource *aSource, VBoxEventDesc &aEvDesc) 3305 { 3306 return aEvDesc.init(aSource, VBoxEventType_OnMediumChanged, mMediumAttachment); 3307 } 3308 3309 IMediumAttachment* mMediumAttachment; 3310 }; 3255 ComPtr<IEvent> ptrEvent; 3256 HRESULT hrc = CreateMediumConfigChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aMedium); 3257 AssertComRCReturnVoid(hrc); 3258 i_postEvent(new AsyncEvent(this, ptrEvent)); 3259 } 3311 3260 3312 3261 void VirtualBox::i_onMediumChanged(IMediumAttachment *aMediumAttachment) 3313 3262 { 3314 i_postEvent(new MediumChangedEventStruct(this, aMediumAttachment)); 3315 } 3316 3317 /** Event for onStorageControllerChanged() */ 3318 struct StorageControllerChangedEventStruct : public VirtualBox::CallbackEvent 3319 { 3320 StorageControllerChangedEventStruct(VirtualBox *aVB, const Guid &aMachineId, 3321 const com::Utf8Str &aControllerName) 3322 : CallbackEvent(aVB, VBoxEventType_OnStorageControllerChanged) 3323 , mMachineId(aMachineId.toUtf16()), mControllerName(aControllerName) 3324 {} 3325 3326 virtual HRESULT prepareEventDesc(IEventSource *aSource, VBoxEventDesc &aEvDesc) 3327 { 3328 return aEvDesc.init(aSource, VBoxEventType_OnStorageControllerChanged, mMachineId.raw(), mControllerName.raw()); 3329 } 3330 3331 Bstr mMachineId; 3332 Bstr mControllerName; 3333 }; 3263 ComPtr<IEvent> ptrEvent; 3264 HRESULT hrc = CreateMediumChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aMediumAttachment); 3265 AssertComRCReturnVoid(hrc); 3266 i_postEvent(new AsyncEvent(this, ptrEvent)); 3267 } 3334 3268 3335 3269 /** … … 3338 3272 void VirtualBox::i_onStorageControllerChanged(const Guid &aMachineId, const com::Utf8Str &aControllerName) 3339 3273 { 3340 i_postEvent(new StorageControllerChangedEventStruct(this, aMachineId, aControllerName)); 3341 } 3342 3343 /** Event for onStorageDeviceChanged() */ 3344 struct StorageDeviceChangedEventStruct : public VirtualBox::CallbackEvent 3345 { 3346 StorageDeviceChangedEventStruct(VirtualBox *aVB, IMediumAttachment *aStorageDevice, BOOL fRemoved, BOOL fSilent) 3347 : CallbackEvent(aVB, VBoxEventType_OnStorageDeviceChanged) 3348 , mStorageDevice(aStorageDevice) 3349 , mRemoved(fRemoved) 3350 , mSilent(fSilent) 3351 {} 3352 3353 virtual HRESULT prepareEventDesc(IEventSource *aSource, VBoxEventDesc &aEvDesc) 3354 { 3355 return aEvDesc.init(aSource, VBoxEventType_OnStorageDeviceChanged, mStorageDevice, mRemoved, mSilent); 3356 } 3357 3358 IMediumAttachment* mStorageDevice; 3359 BOOL mRemoved; 3360 BOOL mSilent; 3361 }; 3274 ComPtr<IEvent> ptrEvent; 3275 HRESULT hrc = CreateStorageControllerChangedEvent(ptrEvent.asOutParam(), m->pEventSource, 3276 aMachineId.toUtf16().raw(), Bstr(aControllerName).raw()); 3277 AssertComRCReturnVoid(hrc); 3278 i_postEvent(new AsyncEvent(this, ptrEvent)); 3279 } 3362 3280 3363 3281 void VirtualBox::i_onStorageDeviceChanged(IMediumAttachment *aStorageDevice, const BOOL fRemoved, const BOOL fSilent) 3364 3282 { 3365 i_postEvent(new StorageDeviceChangedEventStruct(this, aStorageDevice, fRemoved, fSilent)); 3283 ComPtr<IEvent> ptrEvent; 3284 HRESULT hrc = CreateStorageDeviceChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aStorageDevice, fRemoved, fSilent); 3285 AssertComRCReturnVoid(hrc); 3286 i_postEvent(new AsyncEvent(this, ptrEvent)); 3366 3287 } 3367 3288 … … 3371 3292 void VirtualBox::i_onMachineStateChange(const Guid &aId, MachineState_T aState) 3372 3293 { 3373 i_postEvent(new MachineEvent(this, VBoxEventType_OnMachineStateChanged, aId, aState)); 3294 ComPtr<IEvent> ptrEvent; 3295 HRESULT hrc = CreateMachineStateChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aState); 3296 AssertComRCReturnVoid(hrc); 3297 i_postEvent(new AsyncEvent(this, ptrEvent)); 3374 3298 } 3375 3299 … … 3379 3303 void VirtualBox::i_onMachineDataChange(const Guid &aId, BOOL aTemporary) 3380 3304 { 3381 i_postEvent(new MachineEvent(this, VBoxEventType_OnMachineDataChanged, aId, aTemporary)); 3305 ComPtr<IEvent> ptrEvent; 3306 HRESULT hrc = CreateMachineDataChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aTemporary); 3307 AssertComRCReturnVoid(hrc); 3308 i_postEvent(new AsyncEvent(this, ptrEvent)); 3382 3309 } 3383 3310 … … 3388 3315 Bstr &aError) 3389 3316 { 3390 LogFlowThisFunc(("machine={%s} aKey={%ls} aValue={%ls}\n", 3391 aId.toString().c_str(), aKey, aValue)); 3317 LogFlowThisFunc(("machine={%RTuuid} aKey={%ls} aValue={%ls}\n", aId.raw(), aKey, aValue)); 3392 3318 3393 3319 AutoCaller autoCaller(this); 3394 3320 AssertComRCReturn(autoCaller.rc(), FALSE); 3395 3321 3396 BOOL allowChange = TRUE; 3397 Bstr id = aId.toUtf16(); 3398 3399 VBoxEventDesc evDesc; 3400 evDesc.init(m->pEventSource, VBoxEventType_OnExtraDataCanChange, id.raw(), aKey, aValue); 3401 BOOL fDelivered = evDesc.fire(3000); /* Wait up to 3 secs for delivery */ 3322 ComPtr<IEvent> ptrEvent; 3323 HRESULT hrc = CreateExtraDataCanChangeEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aKey, aValue); 3324 AssertComRCReturn(hrc, TRUE); 3325 i_postEvent(new AsyncEvent(this, ptrEvent)); 3326 3327 VBoxEventDesc EvtDesc(ptrEvent, m->pEventSource); 3328 BOOL fDelivered = EvtDesc.fire(3000); /* Wait up to 3 secs for delivery */ 3402 3329 //Assert(fDelivered); 3330 BOOL fAllowChange = TRUE; 3403 3331 if (fDelivered) 3404 3332 { 3405 ComPtr<IEvent> aEvent; 3406 evDesc.getEvent(aEvent.asOutParam()); 3407 ComPtr<IExtraDataCanChangeEvent> aCanChangeEvent = aEvent; 3408 Assert(aCanChangeEvent); 3333 ComPtr<IExtraDataCanChangeEvent> ptrCanChangeEvent = ptrEvent; 3334 Assert(ptrCanChangeEvent); 3335 3409 3336 BOOL fVetoed = FALSE; 3410 aCanChangeEvent->IsVetoed(&fVetoed);3411 allowChange = !fVetoed;3412 3413 if (! allowChange)3337 ptrCanChangeEvent->IsVetoed(&fVetoed); 3338 fAllowChange = !fVetoed; 3339 3340 if (!fAllowChange) 3414 3341 { 3415 3342 SafeArray<BSTR> aVetos; 3416 aCanChangeEvent->GetVetos(ComSafeArrayAsOutParam(aVetos));3343 ptrCanChangeEvent->GetVetos(ComSafeArrayAsOutParam(aVetos)); 3417 3344 if (aVetos.size() > 0) 3418 3345 aError = aVetos[0]; 3419 3346 } 3420 3347 } 3421 else 3422 allowChange = TRUE; 3423 3424 LogFlowThisFunc(("allowChange=%RTbool\n", allowChange)); 3425 return allowChange; 3426 } 3427 3428 /** Event for onExtraDataChange() */ 3429 struct ExtraDataEvent : public VirtualBox::CallbackEvent 3430 { 3431 ExtraDataEvent(VirtualBox *aVB, const Guid &aMachineId, 3432 IN_BSTR aKey, IN_BSTR aVal) 3433 : CallbackEvent(aVB, VBoxEventType_OnExtraDataChanged) 3434 , machineId(aMachineId.toUtf16()), key(aKey), val(aVal) 3435 {} 3436 3437 virtual HRESULT prepareEventDesc(IEventSource* aSource, VBoxEventDesc& aEvDesc) 3438 { 3439 return aEvDesc.init(aSource, VBoxEventType_OnExtraDataChanged, machineId.raw(), key.raw(), val.raw()); 3440 } 3441 3442 Bstr machineId, key, val; 3443 }; 3348 3349 LogFlowThisFunc(("fAllowChange=%RTbool\n", fAllowChange)); 3350 return fAllowChange; 3351 } 3444 3352 3445 3353 /** 3446 3354 * @note Doesn't lock any object. 3355 * @todo +d 3447 3356 */ 3448 3357 void VirtualBox::i_onExtraDataChange(const Guid &aId, IN_BSTR aKey, IN_BSTR aValue) 3449 3358 { 3450 i_postEvent(new ExtraDataEvent(this, aId, aKey, aValue)); 3359 ComPtr<IEvent> ptrEvent; 3360 HRESULT hrc = CreateExtraDataChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aKey, aValue); 3361 AssertComRCReturnVoid(hrc); 3362 i_postEvent(new AsyncEvent(this, ptrEvent)); 3451 3363 } 3452 3364 … … 3456 3368 void VirtualBox::i_onMachineRegistered(const Guid &aId, BOOL aRegistered) 3457 3369 { 3458 i_postEvent(new MachineEvent(this, VBoxEventType_OnMachineRegistered, aId, aRegistered)); 3459 } 3460 3461 /** Event for onSessionStateChange() */ 3462 struct SessionEvent : public VirtualBox::CallbackEvent 3463 { 3464 SessionEvent(VirtualBox *aVB, const Guid &aMachineId, SessionState_T aState) 3465 : CallbackEvent(aVB, VBoxEventType_OnSessionStateChanged) 3466 , machineId(aMachineId.toUtf16()), sessionState(aState) 3467 {} 3468 3469 virtual HRESULT prepareEventDesc(IEventSource* aSource, VBoxEventDesc& aEvDesc) 3470 { 3471 return aEvDesc.init(aSource, VBoxEventType_OnSessionStateChanged, machineId.raw(), sessionState); 3472 } 3473 Bstr machineId; 3474 SessionState_T sessionState; 3475 }; 3370 ComPtr<IEvent> ptrEvent; 3371 HRESULT hrc = CreateMachineRegisteredEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aRegistered); 3372 AssertComRCReturnVoid(hrc); 3373 i_postEvent(new AsyncEvent(this, ptrEvent)); 3374 } 3476 3375 3477 3376 /** 3478 3377 * @note Doesn't lock any object. 3378 * @todo +d 3479 3379 */ 3480 3380 void VirtualBox::i_onSessionStateChange(const Guid &aId, SessionState_T aState) 3481 3381 { 3482 i_postEvent(new SessionEvent(this, aId, aState)); 3483 } 3484 3485 /** Event for i_onSnapshotTaken(), i_onSnapshotDeleted(), i_onSnapshotRestored() and i_onSnapshotChange() */ 3486 struct SnapshotEvent : public VirtualBox::CallbackEvent 3487 { 3488 SnapshotEvent(VirtualBox *aVB, const Guid &aMachineId, const Guid &aSnapshotId, 3489 VBoxEventType_T aWhat) 3490 : CallbackEvent(aVB, aWhat) 3491 , machineId(aMachineId), snapshotId(aSnapshotId) 3492 {} 3493 3494 virtual HRESULT prepareEventDesc(IEventSource* aSource, VBoxEventDesc& aEvDesc) 3495 { 3496 return aEvDesc.init(aSource, mWhat, machineId.toUtf16().raw(), 3497 snapshotId.toUtf16().raw()); 3498 } 3499 3500 Guid machineId; 3501 Guid snapshotId; 3502 }; 3382 ComPtr<IEvent> ptrEvent; 3383 HRESULT hrc = CreateSessionStateChangedEvent(ptrEvent.asOutParam(), m->pEventSource, aId.toUtf16().raw(), aState); 3384 AssertComRCReturnVoid(hrc); 3385 i_postEvent(new AsyncEvent(this, ptrEvent)); 3386 } 3503 3387 3504 3388 /** … … 3507 3391 void VirtualBox::i_onSnapshotTaken(const Guid &aMachineId, const Guid &aSnapshotId) 3508 3392 { 3509 i_postEvent(new SnapshotEvent(this, aMachineId, aSnapshotId, 3510 VBoxEventType_OnSnapshotTaken)); 3393 ComPtr<IEvent> ptrEvent; 3394 HRESULT hrc = CreateSnapshotTakenEvent(ptrEvent.asOutParam(), m->pEventSource, 3395 aMachineId.toUtf16().raw(), aSnapshotId.toUtf16().raw()); 3396 AssertComRCReturnVoid(hrc); 3397 i_postEvent(new AsyncEvent(this, ptrEvent)); 3511 3398 } 3512 3399 … … 3516 3403 void VirtualBox::i_onSnapshotDeleted(const Guid &aMachineId, const Guid &aSnapshotId) 3517 3404 { 3518 i_postEvent(new SnapshotEvent(this, aMachineId, aSnapshotId, 3519 VBoxEventType_OnSnapshotDeleted)); 3405 ComPtr<IEvent> ptrEvent; 3406 HRESULT hrc = CreateSnapshotDeletedEvent(ptrEvent.asOutParam(), m->pEventSource, 3407 aMachineId.toUtf16().raw(), aSnapshotId.toUtf16().raw()); 3408 AssertComRCReturnVoid(hrc); 3409 i_postEvent(new AsyncEvent(this, ptrEvent)); 3520 3410 } 3521 3411 … … 3525 3415 void VirtualBox::i_onSnapshotRestored(const Guid &aMachineId, const Guid &aSnapshotId) 3526 3416 { 3527 i_postEvent(new SnapshotEvent(this, aMachineId, aSnapshotId, 3528 VBoxEventType_OnSnapshotRestored)); 3417 ComPtr<IEvent> ptrEvent; 3418 HRESULT hrc = CreateSnapshotRestoredEvent(ptrEvent.asOutParam(), m->pEventSource, 3419 aMachineId.toUtf16().raw(), aSnapshotId.toUtf16().raw()); 3420 AssertComRCReturnVoid(hrc); 3421 i_postEvent(new AsyncEvent(this, ptrEvent)); 3529 3422 } 3530 3423 3531 3424 /** 3532 3425 * @note Doesn't lock any object. 3426 * @todo +d 3533 3427 */ 3534 3428 void VirtualBox::i_onSnapshotChange(const Guid &aMachineId, const Guid &aSnapshotId) 3535 3429 { 3536 i_postEvent(new SnapshotEvent(this, aMachineId, aSnapshotId, 3537 VBoxEventType_OnSnapshotChanged)); 3538 } 3539 3540 /** Event for onGuestPropertyChange() */ 3541 struct GuestPropertyEvent : public VirtualBox::CallbackEvent 3542 { 3543 GuestPropertyEvent(VirtualBox *aVBox, const Guid &aMachineId, 3544 IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags) 3545 : CallbackEvent(aVBox, VBoxEventType_OnGuestPropertyChanged), 3546 machineId(aMachineId), 3547 name(aName), 3548 value(aValue), 3549 flags(aFlags) 3550 {} 3551 3552 virtual HRESULT prepareEventDesc(IEventSource* aSource, VBoxEventDesc& aEvDesc) 3553 { 3554 return aEvDesc.init(aSource, VBoxEventType_OnGuestPropertyChanged, 3555 machineId.toUtf16().raw(), name.raw(), value.raw(), flags.raw()); 3556 } 3557 3558 Guid machineId; 3559 Bstr name, value, flags; 3560 }; 3561 3562 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 3430 ComPtr<IEvent> ptrEvent; 3431 HRESULT hrc = CreateSnapshotChangedEvent(ptrEvent.asOutParam(), m->pEventSource, 3432 aMachineId.toUtf16().raw(), aSnapshotId.toUtf16().raw()); 3433 AssertComRCReturnVoid(hrc); 3434 i_postEvent(new AsyncEvent(this, ptrEvent)); 3435 } 3436 3437 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS /** @todo r=bird: Why is this still here? */ 3438 3563 3439 /** 3564 3440 * Generates a new clipboard area on the host by opening (and locking) a new, temporary directory. … … 3833 3709 return cRefCount; 3834 3710 } 3711 3835 3712 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */ 3836 3713 3837 3714 /** 3838 3715 * @note Doesn't lock any object. 3716 * @todo +d 3839 3717 */ 3840 3718 void VirtualBox::i_onGuestPropertyChange(const Guid &aMachineId, IN_BSTR aName, 3841 3719 IN_BSTR aValue, IN_BSTR aFlags) 3842 3720 { 3843 i_postEvent(new GuestPropertyEvent(this, aMachineId, aName, aValue, aFlags)); 3721 ComPtr<IEvent> ptrEvent; 3722 HRESULT hrc = CreateGuestPropertyChangedEvent(ptrEvent.asOutParam(), m->pEventSource, 3723 aMachineId.toUtf16().raw(), aName, aValue, aFlags); 3724 AssertComRCReturnVoid(hrc); 3725 i_postEvent(new AsyncEvent(this, ptrEvent)); 3844 3726 } 3845 3727 3846 3728 /** 3847 3729 * @note Doesn't lock any object. 3730 * @todo +d 3848 3731 */ 3849 3732 void VirtualBox::i_onNatRedirectChange(const Guid &aMachineId, ULONG ulSlot, bool fRemove, IN_BSTR aName, … … 3855 3738 } 3856 3739 3740 /** @todo +d */ 3857 3741 void VirtualBox::i_onNATNetworkChange(IN_BSTR aName) 3858 3742 { … … 5802 5686 //////////////////////////////////////////////////////////////////////////////// 5803 5687 5688 #if 0 /* obsoleted by AsyncEvent */ 5804 5689 /** 5805 5690 * Prepare the event using the overwritten #prepareEventDesc method and fire. … … 5831 5716 5832 5717 mVirtualBox = NULL; /* Not needed any longer. Still make sense to do this? */ 5718 return NULL; 5719 } 5720 #endif 5721 5722 /** 5723 * Called on the event handler thread. 5724 * 5725 * @note Locks the managed VirtualBox object for reading but leaves the lock 5726 * before iterating over callbacks and calling their methods. 5727 */ 5728 void *VirtualBox::AsyncEvent::handler() 5729 { 5730 if (mVirtualBox) 5731 { 5732 AutoCaller autoCaller(mVirtualBox); 5733 if (autoCaller.isOk()) 5734 { 5735 VBoxEventDesc EvtDesc(mEvent, mVirtualBox->m->pEventSource); 5736 EvtDesc.fire(/* don't wait for delivery */0); 5737 } 5738 else 5739 Log1WarningFunc(("VirtualBox has been uninitialized (state=%d), the callback event is discarded!\n", 5740 mVirtualBox->getObjectState().getState())); 5741 mVirtualBox = NULL; /* Old code did this, not really necessary, but whatever. */ 5742 } 5743 mEvent.setNull(); 5833 5744 return NULL; 5834 5745 }
Note:
See TracChangeset
for help on using the changeset viewer.