Changeset 16724 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Feb 13, 2009 1:43:01 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 42760
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
r16530 r16724 24 24 * Header Files * 25 25 *******************************************************************************/ 26 27 #if defined(VBOX_WITH_XPCOM) && !defined(RT_OS_DARWIN) && !defined(RT_OS_OS2)28 # define USE_XPCOM_QUEUE29 #endif30 31 26 #include "VBoxManage.h" 32 27 … … 50 45 using namespace com; 51 46 47 /** 48 * IVirtualBoxCallback implementation for handling the GuestPropertyCallback in 49 * relation to the "guestproperty wait" command. 50 */ 52 51 class GuestPropertyCallback : public IVirtualBoxCallback 53 52 { … … 56 55 : mSignalled(false), mPatterns(pszPatterns), mUuid(aUuid) 57 56 { 58 #if defined (RT_OS_WINDOWS)57 #ifndef VBOX_WITH_XPCOM 59 58 refcnt = 0; 60 59 #endif … … 63 62 virtual ~GuestPropertyCallback() {} 64 63 65 #if def RT_OS_WINDOWS64 #ifndef VBOX_WITH_XPCOM 66 65 STDMETHOD_(ULONG, AddRef)() 67 66 { … … 92 91 return E_NOINTERFACE; 93 92 } 94 #endif 93 #endif /* !VBOX_WITH_XPCOM */ 95 94 96 95 NS_DECL_ISUPPORTS … … 124 123 } 125 124 126 STDMETHOD(OnMediaRegistered) 127 128 { 129 NOREF 130 NOREF 131 NOREF 125 STDMETHOD(OnMediaRegistered)(IN_GUID mediaId, 126 DeviceType_T mediaType, BOOL registered) 127 { 128 NOREF(mediaId); 129 NOREF(mediaType); 130 NOREF(registered); 132 131 return S_OK; 133 132 } … … 144 143 } 145 144 146 STDMETHOD(OnSnapshotTaken) (IN_GUID aMachineId, 145 STDMETHOD(OnSnapshotTaken)(IN_GUID aMachineId, 146 IN_GUID aSnapshotId) 147 { 148 return S_OK; 149 } 150 151 STDMETHOD(OnSnapshotDiscarded)(IN_GUID aMachineId, 152 IN_GUID aSnapshotId) 153 { 154 return S_OK; 155 } 156 157 STDMETHOD(OnSnapshotChange)(IN_GUID aMachineId, 147 158 IN_GUID aSnapshotId) 148 {149 return S_OK;150 }151 152 STDMETHOD(OnSnapshotDiscarded) (IN_GUID aMachineId,153 IN_GUID aSnapshotId)154 {155 return S_OK;156 }157 158 STDMETHOD(OnSnapshotChange) (IN_GUID aMachineId,159 IN_GUID aSnapshotId)160 159 { 161 160 return S_OK; … … 166 165 IN_BSTR flags) 167 166 { 168 intrc = S_OK;167 HRESULT rc = S_OK; 169 168 Utf8Str utf8Name (name); 170 169 Guid uuid(machineId); … … 173 172 if ( SUCCEEDED (rc) 174 173 && uuid == mUuid 175 && RTStrSimplePatternMultiMatch 176 177 { 178 RTPrintf 179 174 && RTStrSimplePatternMultiMatch(mPatterns, RTSTR_MAX, 175 utf8Name.raw(), RTSTR_MAX, NULL)) 176 { 177 RTPrintf("Name: %lS, value: %lS, flags: %lS\n", name, value, 178 flags); 180 179 mSignalled = true; 181 180 } … … 189 188 const char *mPatterns; 190 189 Guid mUuid; 191 #if def RT_OS_WINDOWS190 #ifndef VBOX_WITH_XPCOM 192 191 long refcnt; 193 192 #endif … … 221 220 222 221 bool verbose = false; 223 if ((3 == a->argc) && (0 == strcmp(a->argv[2], "-verbose"))) 222 if ( a->argc == 3 223 && strcmp(a->argv[2], "-verbose") == 0) 224 224 verbose = true; 225 225 else if (a->argc != 2) … … 241 241 /* open a session for the VM - new or existing */ 242 242 if (FAILED (a->virtualBox->OpenSession(a->session, uuid))) 243 CHECK_ERROR_RET 243 CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, uuid), 1); 244 244 245 245 /* get the mutable session machine */ … … 247 247 248 248 Bstr value; 249 uint64_tu64Timestamp;249 ULONG64 u64Timestamp; 250 250 Bstr flags; 251 251 CHECK_ERROR(machine, GetGuestProperty(Bstr(a->argv[1]), value.asOutParam(), 252 &u64Timestamp, flags.asOutParam()));252 &u64Timestamp, flags.asOutParam())); 253 253 if (!value) 254 254 RTPrintf("No value set!\n"); … … 268 268 HRESULT rc = S_OK; 269 269 270 /*271 * Check the syntax. We can deduce the correct syntax from the number of272 * arguments.273 */270 /* 271 * Check the syntax. We can deduce the correct syntax from the number of 272 * arguments. 273 */ 274 274 bool usageOK = true; 275 275 const char *pszName = NULL; 276 276 const char *pszValue = NULL; 277 277 const char *pszFlags = NULL; 278 if (3 == a->argc) 279 { 278 if (a->argc == 3) 280 279 pszValue = a->argv[2]; 281 } 282 else if (4 == a->argc) 280 else if (a->argc == 4) 283 281 usageOK = false; 284 else if ( 5 == a->argc)282 else if (a->argc == 5) 285 283 { 286 284 pszValue = a->argv[2]; … … 316 314 a->session->COMGETTER(Machine)(machine.asOutParam()); 317 315 318 if ( (NULL == pszValue) && (NULL == pszFlags))316 if (!pszValue && !pszFlags) 319 317 CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(pszName), NULL)); 320 else if ( NULL ==pszFlags)318 else if (!pszFlags) 321 319 CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(pszName), Bstr(pszValue))); 322 320 else … … 339 337 static int handleEnumGuestProperty(HandlerArg *a) 340 338 { 341 /* 342 * Check the syntax. We can deduce the correct syntax from the number of 343 * arguments. 344 */ 345 if ((a->argc < 1) || (2 == a->argc) || 346 ((a->argc > 3) && strcmp(a->argv[1], "-patterns") != 0)) 339 /* 340 * Check the syntax. We can deduce the correct syntax from the number of 341 * arguments. 342 */ 343 if ( a->argc < 1 344 || a->argc == 2 345 || ( a->argc > 3 346 && strcmp(a->argv[1], "-patterns") != 0)) 347 347 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 348 348 349 /*350 * Pack the patterns351 */349 /* 350 * Pack the patterns 351 */ 352 352 Utf8Str Utf8Patterns(a->argc > 2 ? a->argv[2] : "*"); 353 for ( ssize_t i = 3; i < a->argc; ++i)353 for (int i = 3; i < a->argc; ++i) 354 354 Utf8Patterns = Utf8StrFmt ("%s,%s", Utf8Patterns.raw(), a->argv[i]); 355 355 356 /*357 * Make the actual call to Main.358 */356 /* 357 * Make the actual call to Main. 358 */ 359 359 ComPtr<IMachine> machine; 360 360 /* assume it's a UUID */ … … 371 371 372 372 /* open a session for the VM - new or existing */ 373 if (FAILED 373 if (FAILED(a->virtualBox->OpenSession(a->session, uuid))) 374 374 CHECK_ERROR_RET (a->virtualBox, OpenExistingSession(a->session, uuid), 1); 375 375 … … 406 406 static int handleWaitGuestProperty(HandlerArg *a) 407 407 { 408 409 /* 410 * Handle arguments 411 */ 408 /* 409 * Handle arguments 410 */ 412 411 const char *pszPatterns = NULL; 413 412 uint32_t u32Timeout = RT_INDEFINITE_WAIT; … … 445 444 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 446 445 447 /*448 * Set up the callback and wait.449 */446 /* 447 * Set up the callback and wait. 448 */ 450 449 Guid uuid; 451 450 machine->COMGETTER(Id)(uuid.asOutParam()); … … 483 482 stop = true; 484 483 } 485 #else 484 #else /* !USE_XPCOM_QUEUE */ 486 485 /** @todo Use a semaphore. But I currently don't have a Windows system 487 486 * running to test on. */ 487 /**@todo r=bird: get to it!*/ 488 488 RTThreadSleep(RT_MIN(1000, u32Timeout)); 489 489 if (callback->Signalled()) 490 490 stop = true; 491 #endif /* USE_XPCOM_QUEUE */492 } 493 494 /*495 * Clean up the callback.496 */497 a->virtualBox->UnregisterCallback 491 #endif /* !USE_XPCOM_QUEUE */ 492 } 493 494 /* 495 * Clean up the callback. 496 */ 497 a->virtualBox->UnregisterCallback(callback); 498 498 if (!callback->Signalled()) 499 499 RTPrintf("Time out or interruption while waiting for a notification.\n"); 500 callback->Release 501 502 /*503 * Done.504 */500 callback->Release(); 501 502 /* 503 * Done. 504 */ 505 505 return 0; 506 506 } … … 518 518 arg.argv = a->argv + 1; 519 519 520 if ( 0 == a->argc)520 if (a->argc == 0) 521 521 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 522 if (0 == strcmp(a->argv[0], "get")) 522 523 /* switch (cmd) */ 524 if (strcmp(a->argv[0], "get") == 0) 523 525 return handleGetGuestProperty(&arg); 524 else if (0 == strcmp(a->argv[0], "set"))526 if (strcmp(a->argv[0], "set") == 0) 525 527 return handleSetGuestProperty(&arg); 526 else if (0 == strcmp(a->argv[0], "enumerate"))528 if (strcmp(a->argv[0], "enumerate") == 0) 527 529 return handleEnumGuestProperty(&arg); 528 else if (0 == strcmp(a->argv[0], "wait"))530 if (strcmp(a->argv[0], "wait") == 0) 529 531 return handleWaitGuestProperty(&arg); 530 /* else */ 532 533 /* default: */ 531 534 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 532 535 }
Note:
See TracChangeset
for help on using the changeset viewer.