Changeset 94756 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Apr 29, 2022 8:55:44 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151138
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.