Changeset 92536 in vbox
- Timestamp:
- Nov 21, 2021 9:36:45 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r92535 r92536 49 49 50 50 DECLARE_TRANSLATION_CONTEXT(Info); 51 52 53 /********************************************************************************************************************************* 54 * Defined Constants And Macros * 55 *********************************************************************************************************************************/ 56 #define SHOW_UTF8_STRING(a_pszMachine, a_pszHuman, a_szValue) \ 57 do \ 58 { \ 59 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 60 if (details == VMINFO_MACHINEREADABLE) \ 61 outputMachineReadableString(a_pszMachine, a_szValue); \ 62 else \ 63 RTPrintf("%-28s %s\n", a_pszHuman, a_szValue); \ 64 } while (0) 65 66 #define SHOW_BSTR_STRING(a_pszMachine, a_pszHuman, a_bstrValue) \ 67 do \ 68 { \ 69 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 70 if (details == VMINFO_MACHINEREADABLE) \ 71 outputMachineReadableString(a_pszMachine, &a_bstrValue); \ 72 else \ 73 RTPrintf("%-28s %ls\n", a_pszHuman, a_bstrValue.raw()); \ 74 } while (0) 75 76 #define SHOW_BOOL_VALUE_EX(a_pszMachine, a_pszHuman, a_fValue, a_szTrue, a_szFalse) \ 77 do \ 78 { \ 79 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 80 if (details == VMINFO_MACHINEREADABLE) \ 81 outputMachineReadableString(a_pszMachine, a_fValue ? "on" : "off"); \ 82 else \ 83 RTPrintf("%-28s %s\n", a_pszHuman, a_fValue ? a_szTrue: a_szFalse); \ 84 } while (0) 85 86 #define SHOW_BOOL_VALUE(a_pszMachine, a_pszHuman, a_fValue) \ 87 SHOW_BOOL_VALUE_EX(a_pszMachine, a_pszHuman, a_fValue, Info::tr("enabled"), Info::tr("disabled")) 88 89 #define SHOW_ULONG_VALUE(a_pszMachine, a_pszHuman, a_uValue, a_pszUnit) \ 90 do \ 91 { \ 92 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 93 if (details == VMINFO_MACHINEREADABLE) \ 94 RTPrintf("%s=%u\n", a_pszMachine, a_uValue); \ 95 else \ 96 RTPrintf("%-28s %u%s\n", a_pszHuman, a_uValue, a_pszUnit); \ 97 } while (0) 98 99 #define SHOW_LONG64_VALUE(a_pszMachine, a_pszHuman, a_llValue, a_pszUnit) \ 100 do \ 101 { \ 102 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 103 if (details == VMINFO_MACHINEREADABLE) \ 104 RTPrintf("%s=%lld\n", a_pszMachine, a_llValue); \ 105 else \ 106 RTPrintf("%-28s %lld%s\n", a_pszHuman, a_llValue, a_pszUnit); \ 107 } while (0) 108 109 #define SHOW_BOOLEAN_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman) \ 110 SHOW_BOOLEAN_PROP_EX(a_pObj, a_Prop, a_pszMachine, a_pszHuman, Info::tr("enabled"), Info::tr("disabled")) 111 112 #define SHOW_BOOLEAN_PROP_EX(a_pObj, a_Prop, a_pszMachine, a_pszHuman, a_szTrue, a_szFalse) \ 113 do \ 114 { \ 115 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 116 BOOL f; \ 117 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&f), hrcCheck); \ 118 if (details == VMINFO_MACHINEREADABLE) \ 119 outputMachineReadableString(a_pszMachine, f ? "on" : "off"); \ 120 else \ 121 RTPrintf("%-28s %s\n", a_pszHuman, f ? a_szTrue : a_szFalse); \ 122 } while (0) 123 124 #define SHOW_BOOLEAN_METHOD(a_pObj, a_Invocation, a_pszMachine, a_pszHuman) \ 125 do \ 126 { \ 127 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 128 BOOL f; \ 129 CHECK_ERROR2I_RET(a_pObj, a_Invocation, hrcCheck); \ 130 if (details == VMINFO_MACHINEREADABLE) \ 131 outputMachineReadableString(a_pszMachine, f ? "on" : "off"); \ 132 else \ 133 RTPrintf("%-28s %s\n", a_pszHuman, f ? Info::tr("enabled") : Info::tr("disabled")); \ 134 } while (0) 135 136 #define SHOW_STRING_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman) \ 137 do \ 138 { \ 139 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 140 Bstr bstr; \ 141 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(bstr.asOutParam()), hrcCheck); \ 142 if (details == VMINFO_MACHINEREADABLE) \ 143 outputMachineReadableString(a_pszMachine, &bstr); \ 144 else \ 145 RTPrintf("%-28s %ls\n", a_pszHuman, bstr.raw()); \ 146 } while (0) 147 148 #define SHOW_STRING_PROP_NOT_EMPTY(a_pObj, a_Prop, a_pszMachine, a_pszHuman) \ 149 do \ 150 { \ 151 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 152 Bstr bstr; \ 153 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(bstr.asOutParam()), hrcCheck); \ 154 if (bstr.isNotEmpty()) \ 155 { \ 156 if (details == VMINFO_MACHINEREADABLE) \ 157 outputMachineReadableString(a_pszMachine, &bstr); \ 158 else \ 159 RTPrintf("%-28s %ls\n", a_pszHuman, bstr.raw()); \ 160 } \ 161 } while (0) 162 163 /** @def SHOW_STRING_PROP_MAJ 164 * For not breaking the output in a dot release we don't show default values. */ 165 #define SHOW_STRING_PROP_MAJ(a_pObj, a_Prop, a_pszMachine, a_pszHuman, a_pszUnless, a_uMajorVer) \ 166 do \ 167 { \ 168 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 169 Bstr bstr; \ 170 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(bstr.asOutParam()), hrcCheck); \ 171 if ((a_uMajorVer) <= VBOX_VERSION_MAJOR || !bstr.equals(a_pszUnless)) \ 172 { \ 173 if (details == VMINFO_MACHINEREADABLE)\ 174 outputMachineReadableString(a_pszMachine, &bstr); \ 175 else \ 176 RTPrintf("%-28s %ls\n", a_pszHuman, bstr.raw()); \ 177 } \ 178 } while (0) 179 180 #define SHOW_STRINGARRAY_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman) \ 181 do \ 182 { \ 183 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 184 SafeArray<BSTR> array; \ 185 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(ComSafeArrayAsOutParam(array)), hrcCheck); \ 186 Utf8Str str; \ 187 for (size_t i = 0; i < array.size(); i++) \ 188 { \ 189 if (i != 0) \ 190 str.append(","); \ 191 str.append(Utf8Str(array[i]).c_str()); \ 192 } \ 193 Bstr bstr(str); \ 194 if (details == VMINFO_MACHINEREADABLE) \ 195 outputMachineReadableString(a_pszMachine, &bstr); \ 196 else \ 197 RTPrintf("%-28s %ls\n", a_pszHuman, bstr.raw()); \ 198 } while (0) 199 200 #define SHOW_UUID_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman) \ 201 SHOW_STRING_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman) 202 203 #define SHOW_USHORT_PROP_EX2(a_pObj, a_Prop, a_pszMachine, a_pszHuman, a_pszUnit, a_szFmtMachine, a_szFmtHuman) \ 204 do \ 205 { \ 206 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 207 USHORT u16 = 0; \ 208 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&u16), hrcCheck); \ 209 if (details == VMINFO_MACHINEREADABLE) \ 210 RTPrintf("%s=" a_szFmtMachine "\n", a_pszMachine, u16); \ 211 else \ 212 RTPrintf("%-28s " a_szFmtHuman "%s\n", a_pszHuman, u16, u16, a_pszUnit); \ 213 } while (0) 214 215 #define SHOW_ULONG_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman, a_pszUnit) \ 216 do \ 217 { \ 218 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 219 ULONG u32 = 0; \ 220 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&u32), hrcCheck); \ 221 if (details == VMINFO_MACHINEREADABLE) \ 222 RTPrintf("%s=%u\n", a_pszMachine, u32); \ 223 else \ 224 RTPrintf("%-28s %u%s\n", a_pszHuman, u32, a_pszUnit); \ 225 } while (0) 226 227 #define SHOW_LONG64_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman, a_pszUnit) \ 228 do \ 229 { \ 230 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \ 231 LONG64 i64 = 0; \ 232 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&i64), hrcCheck); \ 233 if (details == VMINFO_MACHINEREADABLE) \ 234 RTPrintf("%s=%lld\n", a_pszMachine, i64); \ 235 else \ 236 RTPrintf("%-28s %'lld%s\n", a_pszHuman, i64, a_pszUnit); \ 237 } while (0) 238 51 239 52 240 // funcs … … 452 640 } 453 641 642 /** Displays a list of IUSBDevices or IHostUSBDevices. */ 643 template <class IUSBDeviceType> 644 static HRESULT showUsbDevices(SafeIfaceArray<IUSBDeviceType> &coll, const char *pszPfx, 645 const char *pszName, VMINFO_DETAILS details) 646 { 647 if (coll.size() > 0) 648 { 649 if (details != VMINFO_MACHINEREADABLE) 650 RTPrintf("%-28s\n\n", pszName); 651 for (size_t i = 0; i < coll.size(); ++i) 652 { 653 ComPtr<IUSBDeviceType> dev = coll[i]; 654 char szValue[128]; 655 char szNm[80]; 656 657 SHOW_STRING_PROP(dev, Id, FmtNm(szNm, "%sActive%zu", pszPfx, i + 1), "UUID:"); 658 SHOW_USHORT_PROP_EX2(dev, VendorId, FmtNm(szNm, "%sVendorId%zu", pszPfx, i + 1), Info::tr("VendorId:"), "", "%#06x", "%#06x (%04X)"); 659 SHOW_USHORT_PROP_EX2(dev, ProductId, FmtNm(szNm, "%sProductId%zu", pszPfx, i + 1), Info::tr("ProductId:"), "", "%#06x", "%#06x (%04X)"); 660 661 USHORT bcdRevision; 662 CHECK_ERROR2I_RET(dev, COMGETTER(Revision)(&bcdRevision), hrcCheck); 663 if (details == VMINFO_MACHINEREADABLE) 664 RTStrPrintf(szValue, sizeof(szValue), "%#04x%02x", bcdRevision >> 8, bcdRevision & 0xff); 665 else 666 RTStrPrintf(szValue, sizeof(szValue), "%u.%u (%02u%02u)\n", 667 bcdRevision >> 8, bcdRevision & 0xff, bcdRevision >> 8, bcdRevision & 0xff); 668 SHOW_UTF8_STRING(FmtNm(szNm, "%sRevision%zu", pszPfx, i + 1), Info::tr("Revision:"), szValue); 669 670 SHOW_STRING_PROP_NOT_EMPTY(dev, Manufacturer, FmtNm(szNm, "%sManufacturer%zu", pszPfx, i + 1), Info::tr("Manufacturer:")); 671 SHOW_STRING_PROP_NOT_EMPTY(dev, Product, FmtNm(szNm, "%sProduct%zu", pszPfx, i + 1), Info::tr("Product:")); 672 SHOW_STRING_PROP_NOT_EMPTY(dev, SerialNumber, FmtNm(szNm, "%sSerialNumber%zu", pszPfx, i + 1), Info::tr("SerialNumber:")); 673 SHOW_STRING_PROP_NOT_EMPTY(dev, Address, FmtNm(szNm, "%sAddress%zu", pszPfx, i + 1), Info::tr("Address:")); 674 675 if (details != VMINFO_MACHINEREADABLE) 676 RTPrintf("\n"); 677 } 678 } 679 else if (details != VMINFO_MACHINEREADABLE) 680 RTPrintf("%-28s %s\n", pszName, Info::tr("<none>")); 681 return S_OK; 682 } 683 454 684 #ifdef VBOX_WITH_IOMMU_AMD 455 685 static const char *iommuTypeToString(IommuType_T iommuType, VMINFO_DETAILS details) … … 551 781 char szNm[80]; 552 782 char szValue[256]; 553 554 #define SHOW_UTF8_STRING(a_pszMachine, a_pszHuman, a_szValue) \555 do \556 { \557 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \558 if (details == VMINFO_MACHINEREADABLE) \559 outputMachineReadableString(a_pszMachine, a_szValue); \560 else \561 RTPrintf("%-28s %s\n", a_pszHuman, a_szValue); \562 } while (0)563 564 #define SHOW_BSTR_STRING(a_pszMachine, a_pszHuman, a_bstrValue) \565 do \566 { \567 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \568 if (details == VMINFO_MACHINEREADABLE) \569 outputMachineReadableString(a_pszMachine, &a_bstrValue); \570 else \571 RTPrintf("%-28s %ls\n", a_pszHuman, a_bstrValue.raw()); \572 } while (0)573 574 #define SHOW_BOOL_VALUE_EX(a_pszMachine, a_pszHuman, a_fValue, a_szTrue, a_szFalse) \575 do \576 { \577 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \578 if (details == VMINFO_MACHINEREADABLE) \579 outputMachineReadableString(a_pszMachine, a_fValue ? "on" : "off"); \580 else \581 RTPrintf("%-28s %s\n", a_pszHuman, a_fValue ? a_szTrue: a_szFalse); \582 } while (0)583 584 #define SHOW_BOOL_VALUE(a_pszMachine, a_pszHuman, a_fValue) \585 SHOW_BOOL_VALUE_EX(a_pszMachine, a_pszHuman, a_fValue, Info::tr("enabled"), Info::tr("disabled"))586 587 #define SHOW_ULONG_VALUE(a_pszMachine, a_pszHuman, a_uValue, a_pszUnit) \588 do \589 { \590 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \591 if (details == VMINFO_MACHINEREADABLE) \592 RTPrintf("%s=%u\n", a_pszMachine, a_uValue); \593 else \594 RTPrintf("%-28s %u%s\n", a_pszHuman, a_uValue, a_pszUnit); \595 } while (0)596 597 #define SHOW_LONG64_VALUE(a_pszMachine, a_pszHuman, a_llValue, a_pszUnit) \598 do \599 { \600 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \601 if (details == VMINFO_MACHINEREADABLE) \602 RTPrintf("%s=%lld\n", a_pszMachine, a_llValue); \603 else \604 RTPrintf("%-28s %lld%s\n", a_pszHuman, a_llValue, a_pszUnit); \605 } while (0)606 607 #define SHOW_BOOLEAN_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman) \608 SHOW_BOOLEAN_PROP_EX(a_pObj, a_Prop, a_pszMachine, a_pszHuman, Info::tr("enabled"), Info::tr("disabled"))609 610 #define SHOW_BOOLEAN_PROP_EX(a_pObj, a_Prop, a_pszMachine, a_pszHuman, a_szTrue, a_szFalse) \611 do \612 { \613 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \614 BOOL f; \615 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&f), hrcCheck); \616 if (details == VMINFO_MACHINEREADABLE) \617 outputMachineReadableString(a_pszMachine, f ? "on" : "off"); \618 else \619 RTPrintf("%-28s %s\n", a_pszHuman, f ? a_szTrue : a_szFalse); \620 } while (0)621 622 #define SHOW_BOOLEAN_METHOD(a_pObj, a_Invocation, a_pszMachine, a_pszHuman) \623 do \624 { \625 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \626 BOOL f; \627 CHECK_ERROR2I_RET(a_pObj, a_Invocation, hrcCheck); \628 if (details == VMINFO_MACHINEREADABLE) \629 outputMachineReadableString(a_pszMachine, f ? "on" : "off"); \630 else \631 RTPrintf("%-28s %s\n", a_pszHuman, f ? Info::tr("enabled") : Info::tr("disabled")); \632 } while (0)633 634 #define SHOW_STRING_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman) \635 do \636 { \637 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \638 Bstr bstr; \639 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(bstr.asOutParam()), hrcCheck); \640 if (details == VMINFO_MACHINEREADABLE) \641 outputMachineReadableString(a_pszMachine, &bstr); \642 else \643 RTPrintf("%-28s %ls\n", a_pszHuman, bstr.raw()); \644 } while (0)645 646 #define SHOW_STRING_PROP_NOT_EMPTY(a_pObj, a_Prop, a_pszMachine, a_pszHuman) \647 do \648 { \649 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \650 Bstr bstr; \651 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(bstr.asOutParam()), hrcCheck); \652 if (bstr.isNotEmpty()) \653 { \654 if (details == VMINFO_MACHINEREADABLE) \655 outputMachineReadableString(a_pszMachine, &bstr); \656 else \657 RTPrintf("%-28s %ls\n", a_pszHuman, bstr.raw()); \658 } \659 } while (0)660 661 /** @def SHOW_STRING_PROP_MAJ662 * For not breaking the output in a dot release we don't show default values. */663 #define SHOW_STRING_PROP_MAJ(a_pObj, a_Prop, a_pszMachine, a_pszHuman, a_pszUnless, a_uMajorVer) \664 do \665 { \666 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \667 Bstr bstr; \668 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(bstr.asOutParam()), hrcCheck); \669 if ((a_uMajorVer) <= VBOX_VERSION_MAJOR || !bstr.equals(a_pszUnless)) \670 { \671 if (details == VMINFO_MACHINEREADABLE)\672 outputMachineReadableString(a_pszMachine, &bstr); \673 else \674 RTPrintf("%-28s %ls\n", a_pszHuman, bstr.raw()); \675 } \676 } while (0)677 678 #define SHOW_STRINGARRAY_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman) \679 do \680 { \681 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \682 SafeArray<BSTR> array; \683 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(ComSafeArrayAsOutParam(array)), hrcCheck); \684 Utf8Str str; \685 for (size_t i = 0; i < array.size(); i++) \686 { \687 if (i != 0) \688 str.append(","); \689 str.append(Utf8Str(array[i]).c_str()); \690 } \691 Bstr bstr(str); \692 if (details == VMINFO_MACHINEREADABLE) \693 outputMachineReadableString(a_pszMachine, &bstr); \694 else \695 RTPrintf("%-28s %ls\n", a_pszHuman, bstr.raw()); \696 } while (0)697 698 #define SHOW_UUID_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman) \699 SHOW_STRING_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman)700 701 #define SHOW_USHORT_PROP_EX2(a_pObj, a_Prop, a_pszMachine, a_pszHuman, a_pszUnit, a_szFmtMachine, a_szFmtHuman) \702 do \703 { \704 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \705 USHORT u16 = 0; \706 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&u16), hrcCheck); \707 if (details == VMINFO_MACHINEREADABLE) \708 RTPrintf("%s=" a_szFmtMachine "\n", a_pszMachine, u16); \709 else \710 RTPrintf("%-28s " a_szFmtHuman "%s\n", a_pszHuman, u16, u16, a_pszUnit); \711 } while (0)712 713 #define SHOW_ULONG_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman, a_pszUnit) \714 do \715 { \716 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \717 ULONG u32 = 0; \718 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&u32), hrcCheck); \719 if (details == VMINFO_MACHINEREADABLE) \720 RTPrintf("%s=%u\n", a_pszMachine, u32); \721 else \722 RTPrintf("%-28s %u%s\n", a_pszHuman, u32, a_pszUnit); \723 } while (0)724 725 #define SHOW_LONG64_PROP(a_pObj, a_Prop, a_pszMachine, a_pszHuman, a_pszUnit) \726 do \727 { \728 Assert(a_pszHuman[strlen(a_pszHuman) - 1] == ':'); \729 LONG64 i64 = 0; \730 CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&i64), hrcCheck); \731 if (details == VMINFO_MACHINEREADABLE) \732 RTPrintf("%s=%lld\n", a_pszMachine, i64); \733 else \734 RTPrintf("%-28s %'lld%s\n", a_pszHuman, i64, a_pszUnit); \735 } while (0)736 783 737 784 /* … … 2361 2408 if (pConsole) 2362 2409 { 2363 /* scope */ 2364 { 2365 if (details != VMINFO_MACHINEREADABLE) 2366 RTPrintf(Info::tr("Available remote USB devices:\n\n")); 2367 2368 SafeIfaceArray <IHostUSBDevice> coll; 2410 { 2411 SafeIfaceArray<IHostUSBDevice> coll; 2369 2412 CHECK_ERROR_RET(pConsole, COMGETTER(RemoteUSBDevices)(ComSafeArrayAsOutParam(coll)), rc); 2370 2371 if (coll.size() == 0) 2372 { 2373 if (details != VMINFO_MACHINEREADABLE) 2374 RTPrintf(Info::tr("<none>\n\n")); 2375 } 2376 else 2377 { 2378 /* This code is duplicated below, with USBAttach as prefix. */ 2379 const char *pszPfx = "USBRemote"; 2380 for (size_t i = 0; i < coll.size(); ++i) 2381 { 2382 ComPtr<IHostUSBDevice> dev = coll[i]; 2383 2384 SHOW_STRING_PROP(dev, Id, FmtNm(szNm, "%sActive%zu", pszPfx, i + 1), "UUID:"); 2385 SHOW_USHORT_PROP_EX2(dev, VendorId, FmtNm(szNm, "%sVendorId%zu", pszPfx, i + 1), Info::tr("VendorId:"), "", "%#06x", "%#06x (%04X)"); 2386 SHOW_USHORT_PROP_EX2(dev, ProductId, FmtNm(szNm, "%sProductId%zu", pszPfx, i + 1), Info::tr("ProductId:"), "", "%#06x", "%#06x (%04X)"); 2387 2388 USHORT bcdRevision; 2389 CHECK_ERROR_RET(dev, COMGETTER(Revision)(&bcdRevision), rc); 2390 if (details == VMINFO_MACHINEREADABLE) 2391 RTStrPrintf(szValue, sizeof(szValue), "%#04x%02x", bcdRevision >> 8, bcdRevision & 0xff); 2392 else 2393 RTStrPrintf(szValue, sizeof(szValue), "%u.%u (%02u%02u)\n", 2394 bcdRevision >> 8, bcdRevision & 0xff, bcdRevision >> 8, bcdRevision & 0xff); 2395 SHOW_UTF8_STRING(FmtNm(szNm, "%sRevision%zu", pszPfx, i + 1), Info::tr("Revision:"), szValue); 2396 2397 SHOW_STRING_PROP_NOT_EMPTY(dev, Manufacturer, FmtNm(szNm, "%sManufacturer%zu", pszPfx, i + 1), Info::tr("Manufacturer:")); 2398 SHOW_STRING_PROP_NOT_EMPTY(dev, Product, FmtNm(szNm, "%sProduct%zu", pszPfx, i + 1), Info::tr("Product:")); 2399 SHOW_STRING_PROP_NOT_EMPTY(dev, SerialNumber, FmtNm(szNm, "%sSerialNumber%zu", pszPfx, i + 1), Info::tr("SerialNumber:")); 2400 SHOW_STRING_PROP_NOT_EMPTY(dev, Address, FmtNm(szNm, "%sAddress%zu", pszPfx, i + 1), Info::tr("Address:")); 2401 2402 if (details != VMINFO_MACHINEREADABLE) 2403 RTPrintf("\n"); 2404 } 2405 } 2406 } 2407 2408 /* scope */ 2409 { 2410 if (details != VMINFO_MACHINEREADABLE) 2411 RTPrintf(Info::tr("Currently Attached USB Devices:\n\n")); 2412 2413 SafeIfaceArray <IUSBDevice> coll; 2413 rc = showUsbDevices(coll, "USBRemote", Info::tr("Available remote USB devices:"), details); 2414 if (FAILED(rc)) 2415 return rc; 2416 } 2417 2418 { 2419 SafeIfaceArray<IUSBDevice> coll; 2414 2420 CHECK_ERROR_RET(pConsole, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(coll)), rc); 2415 2416 if (coll.size() == 0) 2417 { 2418 if (details != VMINFO_MACHINEREADABLE) 2419 RTPrintf(Info::tr("<none>\n\n")); 2420 } 2421 else 2422 { 2423 /* This code is duplicated below, with USBAttach as prefix. */ 2424 const char *pszPfx = "USBAttach"; 2425 for (size_t i = 0; i < coll.size(); ++i) 2426 { 2427 ComPtr<IUSBDevice> dev = coll[i]; 2428 2429 SHOW_STRING_PROP(dev, Id, FmtNm(szNm, "%sActive%zu", pszPfx, i + 1), "UUID:"); 2430 SHOW_USHORT_PROP_EX2(dev, VendorId, FmtNm(szNm, "%sVendorId%zu", pszPfx, i + 1), Info::tr("VendorId:"), "", "%#06x", "%#06x (%04X)"); 2431 SHOW_USHORT_PROP_EX2(dev, ProductId, FmtNm(szNm, "%sProductId%zu", pszPfx, i + 1), Info::tr("ProductId:"), "", "%#06x", "%#06x (%04X)"); 2432 2433 USHORT bcdRevision; 2434 CHECK_ERROR_RET(dev, COMGETTER(Revision)(&bcdRevision), rc); 2435 if (details == VMINFO_MACHINEREADABLE) 2436 RTStrPrintf(szValue, sizeof(szValue), "%#04x%02x", bcdRevision >> 8, bcdRevision & 0xff); 2437 else 2438 RTStrPrintf(szValue, sizeof(szValue), "%u.%u (%02u%02u)\n", 2439 bcdRevision >> 8, bcdRevision & 0xff, bcdRevision >> 8, bcdRevision & 0xff); 2440 SHOW_UTF8_STRING(FmtNm(szNm, "%sRevision%zu", pszPfx, i + 1), Info::tr("Revision:"), szValue); 2441 2442 SHOW_STRING_PROP_NOT_EMPTY(dev, Manufacturer, FmtNm(szNm, "%sManufacturer%zu", pszPfx, i + 1), Info::tr("Manufacturer:")); 2443 SHOW_STRING_PROP_NOT_EMPTY(dev, Product, FmtNm(szNm, "%sProduct%zu", pszPfx, i + 1), Info::tr("Product:")); 2444 SHOW_STRING_PROP_NOT_EMPTY(dev, SerialNumber, FmtNm(szNm, "%sSerialNumber%zu", pszPfx, i + 1), Info::tr("SerialNumber:")); 2445 SHOW_STRING_PROP_NOT_EMPTY(dev, Address, FmtNm(szNm, "%sAddress%zu", pszPfx, i + 1), Info::tr("Address:")); 2446 2447 if (details != VMINFO_MACHINEREADABLE) 2448 RTPrintf("\n"); 2449 } 2450 } 2421 showUsbDevices(coll, "USBAttach", Info::tr("Currently attached USB devices:"), details); 2422 if (FAILED(rc)) 2423 return rc; 2451 2424 } 2452 2425 } … … 2637 2610 } 2638 2611 } 2639 2640 if (details != VMINFO_MACHINEREADABLE)2641 RTPrintf("\n");2642 2612 } 2643 2613 … … 2730 2700 } 2731 2701 2702 /* 2703 * Snapshots. 2704 */ 2705 ComPtr<ISnapshot> snapshot; 2706 rc = machine->FindSnapshot(Bstr().raw(), snapshot.asOutParam()); 2707 if (SUCCEEDED(rc) && snapshot) 2708 { 2709 ComPtr<ISnapshot> currentSnapshot; 2710 rc = machine->COMGETTER(CurrentSnapshot)(currentSnapshot.asOutParam()); 2711 if (SUCCEEDED(rc)) 2712 { 2713 if (details != VMINFO_MACHINEREADABLE) 2714 RTPrintf(Info::tr("Snapshots:\n\n")); 2715 showSnapshots(snapshot, currentSnapshot, details); 2716 } 2717 } 2718 2719 /* 2720 * Guest stuff (mainly interesting when running). 2721 */ 2732 2722 if (details != VMINFO_MACHINEREADABLE) 2733 RTPrintf(Info::tr("Guest:\n\n")); 2734 2735 SHOW_ULONG_PROP(machine, MemoryBalloonSize, "GuestMemoryBalloon", Info::tr("Configured memory balloon size:"), Info::tr("MB")); 2723 RTPrintf(Info::tr("* Guest:\n")); 2724 2725 SHOW_ULONG_PROP(machine, MemoryBalloonSize, "GuestMemoryBalloon", 2726 Info::tr("Configured memory balloon:"), Info::tr("MB")); 2736 2727 2737 2728 if (pConsole) … … 2761 2752 } 2762 2753 2763 if (details != VMINFO_MACHINEREADABLE)2764 RTPrintf(Info::tr("\nGuest Facilities:\n\n"));2765 2766 2754 /* Print information about known Guest Additions facilities: */ 2767 2755 SafeIfaceArray <IAdditionsFacility> collFac; 2768 2756 CHECK_ERROR_RET(guest, COMGETTER(Facilities)(ComSafeArrayAsOutParam(collFac)), rc); 2769 LONG64 lLastUpdatedMS; 2770 char szLastUpdated[32]; 2771 AdditionsFacilityStatus_T curStatus; 2772 for (size_t index = 0; index < collFac.size(); ++index) 2773 { 2774 ComPtr<IAdditionsFacility> fac = collFac[index]; 2775 if (fac) 2757 if (collFac.size() > 0) 2758 { 2759 if (details != VMINFO_MACHINEREADABLE) 2760 RTPrintf("%s\n", Info::tr("Guest Facilities:")); 2761 LONG64 lLastUpdatedMS; 2762 char szLastUpdated[32]; 2763 AdditionsFacilityStatus_T curStatus; 2764 for (size_t index = 0; index < collFac.size(); ++index) 2776 2765 { 2777 C HECK_ERROR_RET(fac, COMGETTER(Name)(guestString.asOutParam()), rc);2778 if ( !guestString.isEmpty())2766 ComPtr<IAdditionsFacility> fac = collFac[index]; 2767 if (fac) 2779 2768 { 2780 CHECK_ERROR_RET(fac, COMGETTER(Status)(&curStatus), rc); 2781 CHECK_ERROR_RET(fac, COMGETTER(LastUpdated)(&lLastUpdatedMS), rc); 2782 if (details == VMINFO_MACHINEREADABLE) 2783 RTPrintf("GuestAdditionsFacility_%ls=%u,%lld\n", 2784 guestString.raw(), curStatus, lLastUpdatedMS); 2769 CHECK_ERROR_RET(fac, COMGETTER(Name)(guestString.asOutParam()), rc); 2770 if (!guestString.isEmpty()) 2771 { 2772 CHECK_ERROR_RET(fac, COMGETTER(Status)(&curStatus), rc); 2773 CHECK_ERROR_RET(fac, COMGETTER(LastUpdated)(&lLastUpdatedMS), rc); 2774 if (details == VMINFO_MACHINEREADABLE) 2775 RTPrintf("GuestAdditionsFacility_%ls=%u,%lld\n", 2776 guestString.raw(), curStatus, lLastUpdatedMS); 2777 else 2778 { 2779 makeTimeStr(szLastUpdated, sizeof(szLastUpdated), lLastUpdatedMS); 2780 RTPrintf(Info::tr("Facility \"%ls\": %s (last update: %s)\n"), 2781 guestString.raw(), facilityStateToName(curStatus, false /* No short naming */), szLastUpdated); 2782 } 2783 } 2785 2784 else 2786 { 2787 makeTimeStr(szLastUpdated, sizeof(szLastUpdated), lLastUpdatedMS); 2788 RTPrintf(Info::tr("Facility \"%ls\": %s (last update: %s)\n"), 2789 guestString.raw(), facilityStateToName(curStatus, false /* No short naming */), szLastUpdated); 2790 } 2785 AssertMsgFailed(("Facility with undefined name retrieved!\n")); 2791 2786 } 2792 2787 else 2793 AssertMsgFailed((" Facility with undefined name retrieved!\n"));2788 AssertMsgFailed(("Invalid facility returned!\n")); 2794 2789 } 2795 else 2796 AssertMsgFailed(("Invalid facility returned!\n")); 2797 } 2798 if (!collFac.size() && details != VMINFO_MACHINEREADABLE) 2799 RTPrintf(Info::tr("No active facilities.\n")); 2800 } 2801 } 2802 2803 if (details != VMINFO_MACHINEREADABLE) 2804 RTPrintf("\n"); 2805 2806 /* 2807 * snapshots 2808 */ 2809 ComPtr<ISnapshot> snapshot; 2810 rc = machine->FindSnapshot(Bstr().raw(), snapshot.asOutParam()); 2811 if (SUCCEEDED(rc) && snapshot) 2812 { 2813 ComPtr<ISnapshot> currentSnapshot; 2814 rc = machine->COMGETTER(CurrentSnapshot)(currentSnapshot.asOutParam()); 2815 if (SUCCEEDED(rc)) 2816 { 2817 if (details != VMINFO_MACHINEREADABLE) 2818 RTPrintf(Info::tr("Snapshots:\n\n")); 2819 showSnapshots(snapshot, currentSnapshot, details); 2790 } 2791 else if (details != VMINFO_MACHINEREADABLE) 2792 RTPrintf("%-28s %s\n", Info::tr("Guest Facilities:"), Info::tr("<none>")); 2820 2793 } 2821 2794 }
Note:
See TracChangeset
for help on using the changeset viewer.

