VirtualBox

Ignore:
Timestamp:
Jul 31, 2008 3:10:06 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
33921
Message:

FE/VBoxManage: moved the guest properties parts to a new file

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/Makefile.kmk

    r10797 r11031  
    4141        VBoxManage.cpp \
    4242        VBoxInternalManage.cpp \
     43        $(if $(VBOX_WITH_GUEST_PROPS),VBoxManageGuestProps.cpp) \
    4344        VBoxManageSVN.cpp
    4445VBoxManage_LIBS       += $(LIB_DDU)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r10896 r11031  
    651651#ifdef VBOX_WITH_GUEST_PROPS
    652652    if (u64Cmd & USAGE_GUESTPROPERTY)
    653     {
    654         RTPrintf("VBoxManage guestproperty    get <vmname>|<uuid>\n"
    655                  "                            <property> [-verbose]\n"
    656                  "\n");
    657         RTPrintf("VBoxManage guestproperty    set <vmname>|<uuid>\n"
    658                  "                            <property> [<value>] [-flags <flags>]\n"
    659                  "\n");
    660     }
     653        usageGuestProperty();
    661654#endif /* VBOX_WITH_GUEST_PROPS defined */
    662655
     
    75837576}
    75847577
    7585 #ifdef VBOX_WITH_GUEST_PROPS
    7586 static int handleGetGuestProperty(int argc, char *argv[],
    7587                                   ComPtr<IVirtualBox> virtualBox,
    7588                                   ComPtr<ISession> session)
    7589 {
    7590     HRESULT rc = S_OK;
    7591 
    7592     bool verbose = false;
    7593     if ((3 == argc) && (0 == strcmp(argv[2], "-verbose")))
    7594         verbose = true;
    7595     else if (argc != 2)
    7596         return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
    7597 
    7598     ComPtr<IMachine> machine;
    7599     /* assume it's a UUID */
    7600     rc = virtualBox->GetMachine(Guid(argv[0]), machine.asOutParam());
    7601     if (FAILED(rc) || !machine)
    7602     {
    7603         /* must be a name */
    7604         CHECK_ERROR(virtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
    7605     }
    7606     if (machine)
    7607     {
    7608         Bstr value;
    7609         uint64_t u64Timestamp;
    7610         Bstr flags;
    7611         CHECK_ERROR(machine, GetGuestProperty(Bstr(argv[1]), value.asOutParam(),
    7612                     &u64Timestamp, flags.asOutParam()));
    7613         if (!value)
    7614             RTPrintf("No value set!\n");
    7615         if (value)
    7616             RTPrintf("Value: %lS\n", value.raw());
    7617         if (value && verbose)
    7618         {
    7619             RTPrintf("Timestamp: %lld\n", u64Timestamp);
    7620             RTPrintf("Flags: %lS\n", flags.raw());
    7621         }
    7622     }
    7623     return SUCCEEDED(rc) ? 0 : 1;
    7624 }
    7625 
    7626 static int handleSetGuestProperty(int argc, char *argv[],
    7627                                   ComPtr<IVirtualBox> virtualBox,
    7628                                   ComPtr<ISession> session)
    7629 {
    7630     HRESULT rc = S_OK;
    7631 
    7632 /*
    7633  * Check the syntax.  We can deduce the correct syntax from the number of
    7634  * arguments.
    7635  */
    7636     bool usageOK = true;
    7637     const char *pszName = NULL;
    7638     const char *pszValue = NULL;
    7639     const char *pszFlags = NULL;
    7640     if (3 == argc)
    7641     {
    7642         pszName = argv[1];
    7643         pszValue = argv[2];
    7644     }
    7645     else if (4 == argc)
    7646     {
    7647         pszName = argv[1];
    7648         if (strcmp(argv[2], "-flags") != 0)
    7649             usageOK = false;
    7650         pszFlags = argv[3];
    7651     }
    7652     else if (5 == argc)
    7653     {
    7654         pszName = argv[1];
    7655         pszValue = argv[2];
    7656         if (strcmp(argv[3], "-flags") != 0)
    7657             usageOK = false;
    7658         pszFlags = argv[4];
    7659     }
    7660     else if (argc != 2)
    7661         usageOK = false;
    7662     if (!usageOK)
    7663         return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
    7664 
    7665     ComPtr<IMachine> machine;
    7666     /* assume it's a UUID */
    7667     rc = virtualBox->GetMachine(Guid(argv[0]), machine.asOutParam());
    7668     if (FAILED(rc) || !machine)
    7669     {
    7670         /* must be a name */
    7671         CHECK_ERROR(virtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
    7672     }
    7673     if (machine)
    7674     {
    7675         if ((NULL == pszValue) && (NULL == pszFlags))
    7676             CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(pszName), NULL));
    7677         else if (NULL == pszFlags)
    7678             CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(pszName), Bstr(pszValue)));
    7679         else if (NULL == pszValue)
    7680             CHECK_ERROR(machine, SetGuestProperty(Bstr(pszName), NULL, Bstr(pszFlags)));
    7681         else
    7682             CHECK_ERROR(machine, SetGuestProperty(Bstr(pszName), Bstr(pszValue), Bstr(pszFlags)));
    7683     }
    7684     return SUCCEEDED(rc) ? 0 : 1;
    7685 }
    7686 
    7687 
    7688 /**
    7689  * Access the guest property store.
    7690  *
    7691  * @returns 0 on success, 1 on failure
    7692  * @note see the command line API description for parameters
    7693  */
    7694 static int handleGuestProperty(int argc, char *argv[],
    7695                                ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
    7696 {
    7697     if (0 == argc)
    7698         return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
    7699     if (0 == strcmp(argv[0], "get"))
    7700         return handleGetGuestProperty(argc - 1, argv + 1, aVirtualBox, aSession);
    7701     else if (0 == strcmp(argv[0], "set"))
    7702         return handleSetGuestProperty(argc - 1, argv + 1, aVirtualBox, aSession);
    7703     /* else */
    7704     return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
    7705 }
    7706 
    7707 #endif /* VBOX_WITH_GUEST_PROPS defined */
    7708 
    77097578enum ConvertSettings
    77107579{
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r10826 r11031  
    100100int handleInternalCommands(int argc, char *argv[],
    101101                           ComPtr <IVirtualBox> aVirtualBox, ComPtr<ISession> aSession);
     102extern void usageGuestProperty(void);
     103extern int handleGuestProperty(int argc, char *argv[],
     104                               ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession);
    102105unsigned long VBoxSVNRev();
    103106
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette