Changeset 94756 in vbox
- Timestamp:
- Apr 29, 2022 8:55:44 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/man_VBoxManage-updatecheck.xml
r94643 r94756 3 3 manpage, user manual, usage: VBoxManage updatecheck 4 4 5 Copyright (C) 2020 Oracle Corporation5 Copyright (C) 2020-2022 Oracle Corporation 6 6 7 7 This file is part of VirtualBox Open Source Edition (OSE), as … … 125 125 <listitem><para>Specifies how often in days to check for a newer version of VirtualBox.</para></listitem> 126 126 </varlistentry> 127 <varlistentry> 128 <term><option>--proxy-mode=system | manual | none</option></term> 129 <listitem><para>Specifies the proxy mode to use.</para></listitem> 130 </varlistentry> 131 <varlistentry> 132 <term><option>--proxy-url=<address></option></term> 133 <listitem><para>Specifies the proxy address to use. Set to empty string to clear proxy address.</para></listitem> 134 </varlistentry> 127 135 </variablelist> 128 136 </refsect2> -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageUpdateCheck.cpp
r94685 r94756 41 41 using namespace com; // SafeArray 42 42 43 44 /** 45 * Returns the proxy mode as a string. 46 * 47 * @returns Proxy mode as string. 48 * @param enmMode Proxy mode to return as string. 49 */ 50 static const char *proxyModeToStr(ProxyMode_T enmMode) 51 { 52 switch (enmMode) 53 { 54 case ProxyMode_System: return "System"; 55 case ProxyMode_Manual: return "Manual"; 56 case ProxyMode_NoProxy: return "None"; 57 default: break; 58 } 59 60 AssertFailed(); 61 return "<Invalid>"; 62 } 63 43 64 static RTEXITCODE doUpdateList(int argc, char **argv, ComPtr<IUpdateAgent> pUpdateAgent) 44 65 { … … 92 113 CHECK_ERROR2I_RET(pUpdateAgent, COMGETTER(CheckFrequency)(&uCheckFreqSeconds), RTEXITCODE_FAILURE); 93 114 94 ULONG constuCheckFreqDays = uCheckFreqSeconds / RT_SEC_1DAY;95 96 if (fMachineReadable) 97 outputMachineReadableULong("frequency ", &uCheckFreqSeconds);115 ULONG uCheckFreqDays = uCheckFreqSeconds / RT_SEC_1DAY; 116 117 if (fMachineReadable) 118 outputMachineReadableULong("frequency-days", &uCheckFreqDays); 98 119 else if (uCheckFreqDays == 0) 99 RTPrintf(UpdateCheck::tr("Frequency: never\n")); /** @todo r=bird: Two inconsistencies here. HostUpdateImpl.cpp code will indicate the need for updating if no last-check-date. modifysettings cannot set it to zero (I added the error message, you just skipped setting it originally). */120 RTPrintf(UpdateCheck::tr("Frequency: Never\n")); 100 121 else if (uCheckFreqDays == 1) 101 RTPrintf(UpdateCheck::tr("Frequency: every day\n"));102 else 103 RTPrintf(UpdateCheck::tr("Frequency: every %u days\n"), uCheckFreqDays);122 RTPrintf(UpdateCheck::tr("Frequency: Every day\n")); 123 else 124 RTPrintf(UpdateCheck::tr("Frequency: Every %u days\n"), uCheckFreqDays); 104 125 105 126 UpdateChannel_T enmUpdateChannel; … … 132 153 RTPrintf(UpdateCheck::tr("Channel: %s\n"), psz); 133 154 134 Bstr bstr LastCheckDate;135 CHECK_ERROR2I_RET(pUpdateAgent, COMGETTER(LastCheckDate)(bstr LastCheckDate.asOutParam()),155 Bstr bstrVal; 156 CHECK_ERROR2I_RET(pUpdateAgent, COMGETTER(LastCheckDate)(bstrVal.asOutParam()), 136 157 RTEXITCODE_FAILURE); 137 158 if (fMachineReadable) 138 outputMachineReadableString("last-check-date", &bstrLastCheckDate); 139 else if (bstrLastCheckDate.isNotEmpty()) 140 RTPrintf(UpdateCheck::tr("Last Check Date: %ls\n"), bstrLastCheckDate.raw()); 159 outputMachineReadableString("last-check-date", &bstrVal); 160 else if (bstrVal.isNotEmpty()) 161 RTPrintf(UpdateCheck::tr("Last Check Date: %ls\n"), bstrVal.raw()); 162 163 CHECK_ERROR2I_RET(pUpdateAgent, COMGETTER(RepositoryURL)(bstrVal.asOutParam()), RTEXITCODE_FAILURE); 164 if (fMachineReadable) 165 outputMachineReadableString("repo-url", &bstrVal); 166 else 167 RTPrintf(UpdateCheck::tr("Repository: %ls\n"), bstrVal.raw()); 168 169 ProxyMode_T enmProxyMode; 170 CHECK_ERROR2I_RET(pUpdateAgent, COMGETTER(ProxyMode)(&enmProxyMode), RTEXITCODE_FAILURE); 171 if (fMachineReadable) 172 outputMachineReadableString("proxy-mode", proxyModeToStr(enmProxyMode)); 173 else 174 RTPrintf(UpdateCheck::tr("Proxy mode: %s\n"), proxyModeToStr(enmProxyMode)); 175 CHECK_ERROR2I_RET(pUpdateAgent, COMGETTER(ProxyURL)(bstrVal.asOutParam()), RTEXITCODE_FAILURE); 176 if (fMachineReadable) 177 outputMachineReadableString("proxy-url", &bstrVal); 178 else 179 RTPrintf(UpdateCheck::tr("Proxy URL: %ls\n"), bstrVal.raw()); 141 180 142 181 return RTEXITCODE_SUCCESS; … … 148 187 * Parse options. 149 188 */ 189 enum GETOPTDEF_UPDATEMODIFY 190 { 191 GETOPTDEF_UPDATEMODIFY_PROXY_MODE = 2000, 192 GETOPTDEF_UPDATEMODIFY_PROXY_URL 193 }; 150 194 static const RTGETOPTDEF s_aOptions[] = 151 195 { 152 { "--enable", 'e', RTGETOPT_REQ_NOTHING }, 153 { "--disable", 'd', RTGETOPT_REQ_NOTHING }, 154 { "--channel", 'c', RTGETOPT_REQ_STRING }, 155 { "--frequency", 'f', RTGETOPT_REQ_UINT32 }, 196 { "--enable", 'e', RTGETOPT_REQ_NOTHING }, 197 { "--disable", 'd', RTGETOPT_REQ_NOTHING }, 198 { "--channel", 'c', RTGETOPT_REQ_STRING }, 199 { "--frequency", 'f', RTGETOPT_REQ_UINT32 }, 200 { "--proxy-mode", GETOPTDEF_UPDATEMODIFY_PROXY_MODE, RTGETOPT_REQ_STRING }, 201 { "--proxy-url", GETOPTDEF_UPDATEMODIFY_PROXY_URL, RTGETOPT_REQ_STRING } 156 202 }; 157 203 … … 160 206 AssertRCReturn(vrc, RTEXITCODE_INIT); 161 207 162 int fEnabled = -1; /* tristate: -1 (not modified), false, true */ 163 UpdateChannel_T const enmChannelNil = (UpdateChannel_T)-999; 164 UpdateChannel_T enmChannel = enmChannelNil; 208 int fEnabled = -1; /* Tristate: -1 (not modified), false, true. */ 209 UpdateChannel_T enmChannel = (UpdateChannel_T)-1; 165 210 uint32_t cFrequencyDays = 0; 211 ProxyMode_T enmProxyMode = (ProxyMode_T)-1; /* Default if not modified, or ProxyMode_T values. */ 212 Bstr strProxyURL = "unmodified"; /* Default if not modified, so that empty values also can be set (clears proxy). */ 166 213 167 214 int c; … … 188 235 enmChannel = UpdateChannel_All; 189 236 else 190 return errorArgument(UpdateCheck::tr(" Unknownchannel specified: '%s'"), ValueUnion.psz);237 return errorArgument(UpdateCheck::tr("Invalid channel specified: '%s'"), ValueUnion.psz); 191 238 break; 192 239 … … 197 244 break; 198 245 199 /** @todo Add more options like proxy + repo handling etc. */ 246 case GETOPTDEF_UPDATEMODIFY_PROXY_MODE: 247 if (!RTStrICmp(ValueUnion.psz, "system")) 248 enmProxyMode = ProxyMode_System; 249 else if ( !RTStrICmp(ValueUnion.psz, "none") 250 || !RTStrICmp(ValueUnion.psz, "disabled") 251 || !RTStrICmp(ValueUnion.psz, "off")) 252 enmProxyMode = ProxyMode_NoProxy; 253 else if (!RTStrICmp(ValueUnion.psz, "manual")) 254 enmProxyMode = ProxyMode_Manual; 255 else 256 return errorArgument(UpdateCheck::tr("Invalid proxy mode specified: '%s'"), ValueUnion.psz); 257 break; 258 259 case GETOPTDEF_UPDATEMODIFY_PROXY_URL: 260 strProxyURL = ValueUnion.psz; 261 break; 262 263 /** @todo Add more options like repo handling etc. */ 200 264 201 265 default: … … 205 269 206 270 if ( fEnabled == -1 207 && enmChannel == enmChannelNil 208 && cFrequencyDays == 0) 271 && enmChannel == (UpdateChannel_T)-1 272 && cFrequencyDays == 0 273 && enmProxyMode == (ProxyMode_T)-1 274 && strProxyURL == "unmodified") 209 275 return errorSyntax(UpdateCheck::tr("No change requested")); 210 276 … … 212 278 * Make the changes. 213 279 */ 214 if (enmChannel != enmChannelNil)280 if (enmChannel != (UpdateChannel_T)-1) 215 281 { 216 282 CHECK_ERROR2I_RET(pUpdateAgent, COMSETTER(Channel)(enmChannel), RTEXITCODE_FAILURE); … … 223 289 { 224 290 CHECK_ERROR2I_RET(pUpdateAgent, COMSETTER(CheckFrequency)(cFrequencyDays * RT_SEC_1DAY), RTEXITCODE_FAILURE); 291 } 292 if (enmProxyMode != (ProxyMode_T)-1) 293 { 294 CHECK_ERROR2I_RET(pUpdateAgent, COMSETTER(ProxyMode)(enmProxyMode), RTEXITCODE_FAILURE); 295 } 296 if (strProxyURL.compare("unmodified") != 0) 297 { 298 CHECK_ERROR2I_RET(pUpdateAgent, COMSETTER(ProxyURL)(strProxyURL.raw()), RTEXITCODE_FAILURE); 225 299 } 226 300 return RTEXITCODE_SUCCESS; -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r94715 r94756 4319 4319 connect(this, &UINotificationProgress::sigProgressFinished, 4320 4320 this, &UINotificationProgressNewVersionChecker::sltHandleProgressFinished); 4321 4322 #ifdef VBOX_WITH_UPDATE_AGENT4323 CHost comHost = uiCommon().host();4324 if (!comHost.isNull())4325 {4326 m_comUpdateHost = comHost.GetUpdateHost();4327 4328 /** @todo For now just grab the proxy settings from the system properties object.4329 * We might want to differentiate this later. */4330 const CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();4331 m_comUpdateHost.SetProxyMode(comProperties.GetProxyMode());4332 m_comUpdateHost.SetProxyURL(comProperties.GetProxyURL());4333 }4334 #endif /* VBOX_WITH_UPDATE_AGENT */4335 4321 } 4336 4322 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r94730 r94756 11562 11562 for VirtualBox host updates. 11563 11563 </desc> 11564 <note> 11565 If no proxy is explicitly set, the proxy settings from <link to="ISystemProperties" /> will be used. 11566 </note> 11564 11567 <attribute name="midlDoesNotLikeEmptyInterfaces" readonly="yes" type="boolean"/> 11565 11568 </interface> -
trunk/src/VBox/Main/include/UpdateAgentImpl.h
r94723 r94756 75 75 * @{ */ 76 76 static Utf8Str i_getPlatformInfo(void); 77 const char *i_proxyModeToStr(ProxyMode_T enmMode); 77 78 /** @} */ 78 79 … … 95 96 UpdateState_T m_enmState; 96 97 uint32_t m_uOrder; 98 /** Whether to use the own (dedicated) proxy settings or 99 * use the ones of ISystemProperties. */ 100 bool m_fUseOwnProxy; 97 101 98 102 Data(void) … … 135 139 /** @name Internal helper methods. 136 140 * @{ */ 141 HRESULT i_getProxyMode(ProxyMode_T *aMode); 142 HRESULT i_getProxyURL(com::Utf8Str &aAddress); 143 HRESULT i_configureProxy(RTHTTP hHttp); 137 144 HRESULT i_commitSettings(AutoWriteLock &aLock); 138 145 HRESULT i_reportError(int vrc, const char *pcszMsgFmt, ...); -
trunk/src/VBox/Main/src-server/UpdateAgentImpl.cpp
r94737 r94756 43 43 #include "VirtualBoxImpl.h" 44 44 #include "VBoxEvents.h" 45 #include "SystemPropertiesImpl.h" 45 46 #include "ThreadTask.h" 46 47 #include "VirtualBoxImpl.h" … … 265 266 } 266 267 268 /** 269 * Returns the proxy mode as a string. 270 * 271 * @returns Proxy mode as string. 272 * @param enmMode Proxy mode to return as string. 273 */ 274 /* static */ 275 const char *UpdateAgentBase::i_proxyModeToStr(ProxyMode_T enmMode) 276 { 277 switch (enmMode) 278 { 279 case ProxyMode_System: return "System"; 280 case ProxyMode_Manual: return "Manual"; 281 case ProxyMode_NoProxy: return "None"; 282 default: break; 283 } 284 285 AssertFailed(); 286 return "<Invalid>"; 287 } 288 267 289 268 290 /********************************************************************************************************************************* … … 296 318 HRESULT hr = unconst(m_EventSource).createObject(); 297 319 if (SUCCEEDED(hr)) 320 { 298 321 hr = m_EventSource->init(); 322 if (SUCCEEDED(hr)) 323 mData.m_fUseOwnProxy = false; 324 } 299 325 300 326 return hr; … … 522 548 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 523 549 524 *aMode = m->enmProxyMode; 525 526 return S_OK; 550 return i_getProxyMode(aMode); 527 551 } 528 552 … … 532 556 533 557 m->enmProxyMode = aMode; 558 mData.m_fUseOwnProxy = true; 534 559 535 560 return i_commitSettings(alock); … … 540 565 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 541 566 542 aAddress = m->strProxyUrl; 543 544 return S_OK; 567 return i_getProxyURL(aAddress); 545 568 } 546 569 … … 550 573 551 574 m->strProxyUrl = aAddress; 575 mData.m_fUseOwnProxy = true; 552 576 553 577 return i_commitSettings(alock); … … 677 701 data = *m; 678 702 703 /* Cancel out eventually set proxy settings if those were not explicitly set. 704 * This way the ISystemProperties proxy settings will be used then. */ 705 if (!mData.m_fUseOwnProxy) 706 { 707 data.strProxyUrl = ""; 708 data.enmProxyMode = ProxyMode_System; 709 } 710 679 711 return S_OK; 680 712 } … … 731 763 AutoWriteLock vboxLock(m_VirtualBox COMMA_LOCKVAL_SRC_POS); 732 764 return m_VirtualBox->i_saveSettings(); 765 } 766 767 /** 768 * Returns the proxy mode to use. 769 * 770 * @returns HRESULT 771 * @param aMode Where to return the proxy mode. 772 */ 773 HRESULT UpdateAgent::i_getProxyMode(ProxyMode_T *aMode) 774 { 775 HRESULT hrc; 776 777 if (!mData.m_fUseOwnProxy) /* If not explicitly set, use the ISystemProperties proxy settings. */ 778 { 779 ComPtr<ISystemProperties> pSystemProperties; 780 hrc = m_VirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam()); 781 if (SUCCEEDED(hrc)) 782 hrc = pSystemProperties->COMGETTER(ProxyMode)(aMode); 783 } 784 else 785 { 786 *aMode = m->enmProxyMode; 787 hrc = S_OK; 788 } 789 790 return hrc; 791 } 792 793 /** 794 * Returns the proxy URL to use. 795 * 796 * @returns HRESULT 797 * @param aUrl Where to return the proxy URL to use. 798 */ 799 HRESULT UpdateAgent::i_getProxyURL(com::Utf8Str &aUrl) 800 { 801 HRESULT hrc; 802 803 if (!mData.m_fUseOwnProxy) /* If not explicitly set, use the ISystemProperties proxy settings. */ 804 { 805 ComPtr<ISystemProperties> pSystemProperties; 806 hrc = m_VirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam()); 807 if (SUCCEEDED(hrc)) 808 { 809 com::Bstr bstrVal; 810 hrc = pSystemProperties->COMGETTER(ProxyURL)(bstrVal.asOutParam()); 811 if (SUCCEEDED(hrc)) 812 aUrl = bstrVal; 813 } 814 } 815 else 816 { 817 aUrl = m->strProxyUrl; 818 hrc = S_OK; 819 } 820 821 return hrc; 822 } 823 824 /** 825 * Configures a HTTP client's proxy. 826 * 827 * @returns HRESULT 828 * @param hHttp HTTP client to configure proxy for. 829 */ 830 HRESULT UpdateAgent::i_configureProxy(RTHTTP hHttp) 831 { 832 HRESULT rc; 833 834 ProxyMode_T enmProxyMode; 835 rc = i_getProxyMode(&enmProxyMode); 836 ComAssertComRCRetRC(rc); 837 Utf8Str strProxyUrl; 838 rc = i_getProxyURL(strProxyUrl); 839 ComAssertComRCRetRC(rc); 840 841 if (enmProxyMode == ProxyMode_Manual) 842 { 843 int vrc = RTHttpSetProxyByUrl(hHttp, strProxyUrl.c_str()); 844 if (RT_FAILURE(vrc)) 845 return i_reportError(vrc, tr("RTHttpSetProxyByUrl() failed: %Rrc"), vrc); 846 } 847 else if (enmProxyMode == ProxyMode_System) 848 { 849 int vrc = RTHttpUseSystemProxySettings(hHttp); 850 if (RT_FAILURE(vrc)) 851 return i_reportError(vrc, tr("RTHttpUseSystemProxySettings() failed: %Rrc"), vrc); 852 } 853 else 854 Assert(enmProxyMode == ProxyMode_NoProxy); 855 856 LogRel2(("Update agent (%s): Using proxy mode = '%s', URL = '%s'\n", 857 mData.m_strName.c_str(), UpdateAgentBase::i_proxyModeToStr(enmProxyMode), strProxyUrl.c_str())); 858 859 return S_OK; 733 860 } 734 861 … … 978 1105 HRESULT HostUpdateAgent::i_checkForUpdateInner(RTHTTP hHttp, Utf8Str const &strUrl, Utf8Str const &strUserAgent) 979 1106 { 1107 /* 1108 * Configure the proxy (if any). 1109 */ 1110 HRESULT rc = i_configureProxy(hHttp); 1111 if (FAILED(rc)) 1112 return rc; 1113 980 1114 /** @todo Are there any other headers needed to be added first via RTHttpSetHeaders()? */ 981 1115 int vrc = RTHttpAddHeader(hHttp, "User-Agent", strUserAgent.c_str(), strUserAgent.length(), RTHTTPADDHDR_F_BACK); 982 1116 if (RT_FAILURE(vrc)) 983 1117 return i_reportError(vrc, tr("RTHttpAddHeader() failed: %Rrc (user agent)"), vrc); 984 985 /*986 * Configure proxying.987 */988 if (m->enmProxyMode == ProxyMode_Manual)989 {990 vrc = RTHttpSetProxyByUrl(hHttp, m->strProxyUrl.c_str());991 if (RT_FAILURE(vrc))992 return i_reportError(vrc, tr("RTHttpSetProxyByUrl() failed: %Rrc"), vrc);993 }994 else if (m->enmProxyMode == ProxyMode_System)995 {996 vrc = RTHttpUseSystemProxySettings(hHttp);997 if (RT_FAILURE(vrc))998 return i_reportError(vrc, tr("RTHttpUseSystemProxySettings() failed: %Rrc"), vrc);999 }1000 else1001 Assert(m->enmProxyMode == ProxyMode_NoProxy);1002 1118 1003 1119 /* … … 1035 1151 size_t const cchWord1 = (size_t)(pchResponse - pchWord1); 1036 1152 1037 HRESULT rc;1038 1039 1153 /* Decode the two word: */ 1040 1154 static char const s_szUpToDate[] = "UPTODATE";
Note:
See TracChangeset
for help on using the changeset viewer.