Changeset 94704 in vbox
- Timestamp:
- Apr 25, 2022 10:28:46 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151077
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r94700 r94704 11345 11345 <interface 11346 11346 name="IUpdateAgent" extends="$unknown" 11347 uuid=" d6c683f2-489e-4701-aa6a-d490f7bc0d7e"11347 uuid="4cef7347-ed89-470b-9ac2-524ae889e17c" 11348 11348 wsmap="managed" 11349 11349 reservedMethods="2" reservedAttributes="4" … … 11401 11401 <desc> 11402 11402 Name of the update component. 11403 </desc> 11404 </attribute> 11405 11406 <attribute name="eventSource" type="IEventSource" readonly="yes"> 11407 <desc> 11408 Event source for update agent events. 11403 11409 </desc> 11404 11410 </attribute> … … 11551 11557 </desc> 11552 11558 <attribute name="midlDoesNotLikeEmptyInterfaces" readonly="yes" type="boolean"/> 11553 </interface>11554 11555 <interface11556 name="IUpdateAgentEvent" extends="$unknown"11557 uuid="aa1987dc-6402-4e3c-a0e9-68e87d301a83"11558 wsmap="managed"11559 reservedAttributes="4"11560 >11561 <desc>11562 Abstract base interface for update agent events.11563 </desc>11564 11565 <attribute name="eventSource" type="IEventSource" readonly="yes">11566 <desc>11567 Event source for update agent events.11568 </desc>11569 </attribute>11570 11571 </interface>11572 11573 <interface11574 name="IUpdateAgentSettingsChangedEvent" extends="IUpdateAgentEvent"11575 uuid="a3537480-a15f-404c-b540-abae5f6b25a0"11576 wsmap="managed"11577 reservedAttributes="4"11578 >11579 <desc>11580 Notification when update agent settings have been changed.11581 </desc>11582 </interface>11583 11584 <interface11585 name="IUpdateAgentErrorEvent" extends="IUpdateAgentEvent"11586 uuid="2dad1ad8-78be-441d-b4fa-9cff25ee16b2"11587 wsmap="managed"11588 reservedAttributes="4"11589 >11590 <desc>11591 Notification when an update agent error occurred.11592 </desc>11593 11594 <attribute name="msg" type="wstring" readonly="yes">11595 <desc>11596 Error message in human readable format.11597 </desc>11598 </attribute>11599 11600 <attribute name="rcError" type="long" readonly="yes">11601 <desc>11602 IPRT-style error code.11603 </desc>11604 </attribute>11605 11606 </interface>11607 11608 <interface11609 name="IUpdateAgentAvailableEvent" extends="IUpdateAgentEvent"11610 uuid="7b931bfa-3b2b-4220-87ce-86cb0dee7ed1"11611 wsmap="managed"11612 reservedAttributes="4"11613 >11614 <desc>11615 Notification when an update is available.11616 </desc>11617 11618 <attribute name="version" type="wstring" readonly="yes">11619 <desc>11620 Version of the update.11621 </desc>11622 </attribute>11623 11624 <attribute name="channel" type="UpdateChannel" readonly="yes">11625 <desc>11626 Channel containing the update.11627 </desc>11628 </attribute>11629 11630 <attribute name="severity" type="UpdateSeverity" readonly="yes">11631 <desc>11632 Severity of the update.11633 </desc>11634 </attribute>11635 11636 <attribute name="downloadURL" type="wstring" readonly="yes">11637 <desc>11638 Download URL of the update.11639 </desc>11640 </attribute>11641 11642 <attribute name="webURL" type="wstring" readonly="yes">11643 <desc>11644 Web URL of the update.11645 </desc>11646 </attribute>11647 11648 <attribute name="releaseNotes" type="wstring" readonly="yes">11649 <desc>11650 Release notes of the update.11651 </desc>11652 </attribute>11653 11654 </interface>11655 11656 <interface11657 name="IUpdateAgentStateChangedEvent" extends="IUpdateAgentEvent"11658 uuid="7da1b997-10ea-4690-99ff-df78bf309164"11659 wsmap="managed"11660 reservedAttributes="4"11661 >11662 <desc>11663 Notification when an update agent state has been changed.11664 </desc>11665 11666 <attribute name="state" type="UpdateState" readonly="yes">11667 <desc>11668 New update agent state.11669 </desc>11670 </attribute>11671 11672 11559 </interface> 11673 11560 … … 25737 25624 <enum 25738 25625 name="VBoxEventType" 25739 uuid=" c88a66ed-fbce-4c21-9196-12354bd96b89"25626 uuid="08cc6ebb-1e55-4b78-8fb1-1e06f5b4dbe9" 25740 25627 > 25741 25628 … … 26201 26088 </desc> 26202 26089 </const> 26090 <const name="OnUpdateAgentAvailable" value="112"> 26091 <desc> 26092 See <link to="IUpdateAgentAvailableEvent">IUpdateAgentAvailableEvent</link>. 26093 </desc> 26094 </const> 26095 <const name="OnUpdateAgentError" value="113"> 26096 <desc> 26097 See <link to="IUpdateAgentErrorEvent">IUpdateAgentErrorEvent</link>. 26098 </desc> 26099 </const> 26100 <const name="OnUpdateAgentSettingsChanged" value="114"> 26101 <desc> 26102 See <link to="IUpdateAgentSettingsChangedEvent">IUpdateAgentSettingsChangedEvent</link>. 26103 </desc> 26104 </const> 26105 <const name="OnUpdateAgentStateChanged" value="115"> 26106 <desc> 26107 See <link to="IUpdateAgentStateChangedEvent">IUpdateAgentStateChangedEvent</link>. 26108 </desc> 26109 </const> 26203 26110 <!-- End event marker --> 26204 26111 <!-- @todo rename to 'End' as it is exclusive (we use 'last' to be inclusive). --> 26205 <const name="Last" value="11 2">26112 <const name="Last" value="116"> 26206 26113 <desc> 26207 26114 Must be last event, used for iterations and structures relying on numerical event values. … … 28381 28288 <desc>The virtual display output on which the monitor has changed.</desc> 28382 28289 </attribute> 28290 </interface> 28291 28292 <interface 28293 name="IUpdateAgentEvent" extends="IEvent" 28294 uuid="0e33366a-670e-4e1f-9ddc-41c8a346cafd" 28295 wsmap="managed"> 28296 <desc> 28297 Abstract base interface for update agent events. 28298 </desc> 28299 <attribute name="midlDoesNotLikeEmptyInterfaces" readonly="yes" type="boolean"/> 28300 </interface> 28301 28302 <interface 28303 name="IUpdateAgentSettingsChangedEvent" extends="IUpdateAgentEvent" 28304 uuid="abef51ae-1493-49f4-aa03-efaf106bf086" 28305 wsmap="managed" autogen="VBoxEvent" id="OnUpdateAgentSettingsChanged" 28306 > 28307 <desc> 28308 Notification when update agent settings have been changed. 28309 </desc> 28310 <attribute name="attributeHint" readonly="yes" type="wstring"/> 28311 </interface> 28312 28313 <interface 28314 name="IUpdateAgentErrorEvent" extends="IUpdateAgentEvent" 28315 uuid="2a88033d-82db-4ac2-97b5-e786c839420e" 28316 wsmap="managed" autogen="VBoxEvent" id="OnUpdateAgentError" 28317 > 28318 <desc> 28319 Notification when an update agent error occurred. 28320 </desc> 28321 28322 <attribute name="msg" type="wstring" readonly="yes"> 28323 <desc> 28324 Error message in human readable format. 28325 </desc> 28326 </attribute> 28327 28328 <attribute name="rcError" type="long" readonly="yes"> 28329 <desc> 28330 IPRT-style error code. 28331 </desc> 28332 </attribute> 28333 28334 </interface> 28335 28336 <interface 28337 name="IUpdateAgentAvailableEvent" extends="IUpdateAgentEvent" 28338 uuid="243829cb-15b7-42a4-8664-7aa4e34993da" 28339 wsmap="managed" autogen="VBoxEvent" id="OnUpdateAgentAvailable" 28340 > 28341 <desc> 28342 Notification when an update is available. 28343 </desc> 28344 28345 <attribute name="version" type="wstring" readonly="yes"> 28346 <desc> 28347 Version of the update. 28348 </desc> 28349 </attribute> 28350 28351 <attribute name="channel" type="UpdateChannel" readonly="yes"> 28352 <desc> 28353 Channel containing the update. 28354 </desc> 28355 </attribute> 28356 28357 <attribute name="severity" type="UpdateSeverity" readonly="yes"> 28358 <desc> 28359 Severity of the update. 28360 </desc> 28361 </attribute> 28362 28363 <attribute name="downloadURL" type="wstring" readonly="yes"> 28364 <desc> 28365 Download URL of the update. 28366 </desc> 28367 </attribute> 28368 28369 <attribute name="webURL" type="wstring" readonly="yes"> 28370 <desc> 28371 Web URL of the update. 28372 </desc> 28373 </attribute> 28374 28375 <attribute name="releaseNotes" type="wstring" readonly="yes"> 28376 <desc> 28377 Release notes of the update. 28378 </desc> 28379 </attribute> 28380 28381 </interface> 28382 28383 <interface 28384 name="IUpdateAgentStateChangedEvent" extends="IUpdateAgentEvent" 28385 uuid="eb000a0e-2079-4f47-bbcc-c6b28a4e50df" 28386 wsmap="managed" autogen="VBoxEvent" id="OnUpdateAgentStateChanged" 28387 > 28388 <desc> 28389 Notification when an update agent state has been changed. 28390 </desc> 28391 28392 <attribute name="state" type="UpdateState" readonly="yes"> 28393 <desc> 28394 New update agent state. 28395 </desc> 28396 </attribute> 28397 28383 28398 </interface> 28384 28399 -
trunk/src/VBox/Main/include/UpdateAgentImpl.h
r94702 r94704 26 26 #include <VBox/settings.h> 27 27 28 #include "EventImpl.h" 28 29 #include "UpdateAgentWrap.h" 29 30 #include "HostUpdateAgentWrap.h" … … 49 50 , m(new settings::UpdateAgent) { } 50 51 51 virtual ~UpdateAgentBase() { }52 virtual ~UpdateAgentBase() { delete m; } 52 53 53 54 public: … … 77 78 78 79 protected: 79 VirtualBox * const m_VirtualBox; 80 /** The update agent's event source. */ 81 const ComObjPtr<EventSource> m_EventSource; 82 VirtualBox * const m_VirtualBox; 80 83 81 84 /** @name Data members. … … 132 135 * @{ */ 133 136 HRESULT i_commitSettings(AutoWriteLock &aLock); 137 HRESULT i_reportError(int vrc, const char *pcszMsgFmt, ...); 134 138 /** @} */ 135 139 … … 143 147 144 148 HRESULT getName(com::Utf8Str &aName); 149 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource); 145 150 HRESULT getOrder(ULONG *aOrder); 146 151 HRESULT getDependsOn(std::vector<com::Utf8Str> &aDeps); -
trunk/src/VBox/Main/src-server/UpdateAgentImpl.cpp
r94702 r94704 41 41 #include "LoggingNew.h" 42 42 #include "VirtualBoxImpl.h" 43 #include "VBoxEvents.h" 43 44 #include "ThreadTask.h" 44 #include "SystemPropertiesImpl.h"45 45 #include "VirtualBoxBase.h" 46 46 … … 275 275 UpdateAgent::~UpdateAgent() 276 276 { 277 delete m; 278 } 279 280 HRESULT UpdateAgent::FinalConstruct() 277 } 278 279 HRESULT UpdateAgent::FinalConstruct(void) 281 280 { 282 281 return BaseFinalConstruct(); 283 282 } 284 283 285 void UpdateAgent::FinalRelease( )284 void UpdateAgent::FinalRelease(void) 286 285 { 287 286 uninit(); … … 299 298 unconst(m_VirtualBox) = aVirtualBox; 300 299 301 autoInitSpan.setSucceeded(); 302 return S_OK; 303 } 304 305 void UpdateAgent::uninit() 300 HRESULT hr = unconst(m_EventSource).createObject(); 301 if (SUCCEEDED(hr)) 302 { 303 hr = m_EventSource->init(); 304 if (SUCCEEDED(hr)) 305 autoInitSpan.setSucceeded(); 306 } 307 308 return hr; 309 } 310 311 void UpdateAgent::uninit(void) 306 312 { 307 313 // Enclose the state transition Ready->InUninit->NotReady. … … 309 315 if (autoUninitSpan.uninitDone()) 310 316 return; 317 318 unconst(m_EventSource).setNull(); 311 319 } 312 320 … … 343 351 aName = mData.m_strName; 344 352 353 return S_OK; 354 } 355 356 HRESULT UpdateAgent::getEventSource(ComPtr<IEventSource> &aEventSource) 357 { 358 LogFlowThisFuncEnter(); 359 360 /* No need to lock - lifetime constant. */ 361 m_EventSource.queryInterfaceTo(aEventSource.asOutParam()); 362 363 LogFlowFuncLeaveRC(S_OK); 345 364 return S_OK; 346 365 } … … 706 725 aLock.release(); 707 726 727 ::FireUpdateAgentSettingsChangedEvent(m_EventSource, "" /** @todo Include attribute hints */); 728 708 729 AutoWriteLock vboxLock(m_VirtualBox COMMA_LOCKVAL_SRC_POS); 709 730 return m_VirtualBox->i_saveSettings(); 731 } 732 733 /** 734 * Reports an error by setting the error info and also information subscribed listeners. 735 * 736 * @returns HRESULT 737 * @param vrc Result code (IPRT-style) to report. 738 * @param pcszMsgFmt Error message to report. 739 * @param ... Format string for \a pcszMsgFmt. 740 */ 741 HRESULT UpdateAgent::i_reportError(int vrc, const char *pcszMsgFmt, ...) 742 { 743 va_list va; 744 va_start(va, pcszMsgFmt); 745 746 char *psz = NULL; 747 if (RTStrAPrintfV(&psz, pcszMsgFmt, va) <= 0) 748 return E_OUTOFMEMORY; 749 750 LogRel(("Update agent (%s): %s\n", mData.m_strName.c_str(), psz)); 751 752 ::FireUpdateAgentErrorEvent(m_EventSource, psz, vrc); 753 754 HRESULT const rc = setErrorVrc(vrc, pcszMsgFmt, va); 755 756 va_end(va); 757 RTStrFree(psz); 758 759 return rc; 710 760 } 711 761 … … 897 947 } 898 948 else 899 rc = setErrorVrc(vrc, tr("Update agent (%s): RTHttpCreate() failed: %Rrc"), mData.m_strName.c_str(), vrc);949 rc = i_reportError(vrc, tr("RTHttpCreate() failed: %Rrc"), vrc); 900 950 901 951 return rc; … … 915 965 int vrc = RTHttpAddHeader(hHttp, "User-Agent", strUserAgent.c_str(), strUserAgent.length(), RTHTTPADDHDR_F_BACK); 916 966 if (RT_FAILURE(vrc)) 917 return setErrorVrc(vrc, tr("Update agent (%s): RTHttpAddHeader() failed: %Rrc (on User-Agent)"), 918 mData.m_strName.c_str(), vrc); 967 return i_reportError(vrc, tr("RTHttpAddHeader() failed: %Rrc (user agent)"), vrc); 919 968 920 969 /* … … 925 974 vrc = RTHttpSetProxyByUrl(hHttp, m->strProxyUrl.c_str()); 926 975 if (RT_FAILURE(vrc)) 927 return setErrorVrc(vrc, tr("Update agent (%s): RTHttpSetProxyByUrl() failed: %Rrc"), mData.m_strName.c_str(), vrc);976 return i_reportError(vrc, tr("RTHttpSetProxyByUrl() failed: %Rrc"), vrc); 928 977 } 929 978 else if (m->enmProxyMode == ProxyMode_System) … … 931 980 vrc = RTHttpUseSystemProxySettings(hHttp); 932 981 if (RT_FAILURE(vrc)) 933 return setErrorVrc(vrc, tr("Update agent (%s): RTHttpUseSystemProxySettings() failed: %Rrc"), 934 mData.m_strName.c_str(), vrc); 982 return i_reportError(vrc, tr("RTHttpUseSystemProxySettings() failed: %Rrc"), vrc); 935 983 } 936 984 else … … 944 992 vrc = RTHttpGetBinary(hHttp, strUrl.c_str(), &pvResponse, &cbResponse); 945 993 if (RT_FAILURE(vrc)) 946 return setErrorVrc(vrc, tr("Update agent (%s): RTHttpGetBinary() failed: %Rrc"), mData.m_strName.c_str(), vrc);994 return i_reportError(vrc, tr("RTHttpGetBinary() failed: %Rrc"), vrc); 947 995 948 996 /* Note! We can do nothing that might throw exceptions till we call RTHttpFreeResponse! */ … … 973 1021 HRESULT rc; 974 1022 975 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);976 977 1023 /* Decode the two word: */ 978 1024 static char const s_szUpToDate[] = "UPTODATE"; … … 980 1026 && memcmp(pchWord0, s_szUpToDate, sizeof(s_szUpToDate) - 1) == 0) 981 1027 { 1028 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1029 982 1030 mData.m_enmState = UpdateState_NotAvailable; 983 1031 rc = S_OK; 1032 1033 alock.release(); /* Release lock before firing off event. */ 1034 1035 ::FireUpdateAgentStateChangedEvent(m_EventSource, UpdateState_NotAvailable); 984 1036 } 985 1037 else … … 997 1049 rc = mData.m_lastResult.strDownloadUrl.assignEx(pchWord1, cchWord1); 998 1050 999 if ( RT_SUCCESS(vrc))1051 if (SUCCEEDED(rc)) 1000 1052 { 1053 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1054 1001 1055 /** @todo Implement this on the backend first. 1002 1056 * We also could do some guessing based on the installed version vs. reported update version? */ 1003 1057 mData.m_lastResult.enmSeverity = UpdateSeverity_Invalid; 1004 1058 mData.m_enmState = UpdateState_Available; 1059 1060 alock.release(); /* Release lock before firing off events. */ 1061 1062 ::FireUpdateAgentStateChangedEvent(m_EventSource, UpdateState_Available); 1063 ::FireUpdateAgentAvailableEvent(m_EventSource, mData.m_lastResult.strVer, m->enmChannel, 1064 mData.m_lastResult.enmSeverity, mData.m_lastResult.strDownloadUrl, 1065 mData.m_lastResult.strWebUrl, mData.m_lastResult.strReleaseNotes); 1005 1066 } 1067 else 1068 rc = i_reportError(VERR_GENERAL_FAILURE /** @todo Use a better rc */, 1069 tr("Invalid server response [1]: %Rhrc (%.*Rhxs -- %.*Rhxs)"), 1070 rc, cchWord0, pchWord0, cchWord1, pchWord1); 1006 1071 1007 1072 LogRel(("Update agent (%s): HTTP server replied: %.*s %.*s\n", … … 1009 1074 } 1010 1075 else 1011 rc = setErrorVrc(vrc, tr("Update agent (%s): Invalid server response: %Rrc (%.*Rhxs -- %.*Rhxs)"),1012 mData.m_strName.c_str(),vrc, cchWord0, pchWord0, cchWord1, pchWord1);1076 rc = i_reportError(vrc, tr("Invalid server response [2]: %Rrc (%.*Rhxs -- %.*Rhxs)"), 1077 vrc, cchWord0, pchWord0, cchWord1, pchWord1); 1013 1078 } 1014 1079
Note:
See TracChangeset
for help on using the changeset viewer.