VirtualBox

Ignore:
Timestamp:
Feb 13, 2009 1:43:01 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
42760
Message:

VBoxManageGuestProp.cpp: Fixed warning. Unified the style a bit and added a @todo escalation :-).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp

    r16530 r16724  
    2424*   Header Files                                                               *
    2525*******************************************************************************/
    26 
    27 #if defined(VBOX_WITH_XPCOM) && !defined(RT_OS_DARWIN) && !defined(RT_OS_OS2)
    28 # define USE_XPCOM_QUEUE
    29 #endif
    30 
    3126#include "VBoxManage.h"
    3227
     
    5045using namespace com;
    5146
     47/**
     48 * IVirtualBoxCallback implementation for handling the GuestPropertyCallback in
     49 * relation to the "guestproperty wait" command.
     50 */
    5251class GuestPropertyCallback : public IVirtualBoxCallback
    5352{
     
    5655        : mSignalled(false), mPatterns(pszPatterns), mUuid(aUuid)
    5756    {
    58 #if defined (RT_OS_WINDOWS)
     57#ifndef VBOX_WITH_XPCOM
    5958        refcnt = 0;
    6059#endif
     
    6362    virtual ~GuestPropertyCallback() {}
    6463
    65 #ifdef RT_OS_WINDOWS
     64#ifndef VBOX_WITH_XPCOM
    6665    STDMETHOD_(ULONG, AddRef)()
    6766    {
     
    9291        return E_NOINTERFACE;
    9392    }
    94 #endif
     93#endif /* !VBOX_WITH_XPCOM */
    9594
    9695    NS_DECL_ISUPPORTS
     
    124123    }
    125124
    126     STDMETHOD(OnMediaRegistered) (IN_GUID mediaId,
    127                                   DeviceType_T mediaType, BOOL registered)
    128     {
    129         NOREF (mediaId);
    130         NOREF (mediaType);
    131         NOREF (registered);
     125    STDMETHOD(OnMediaRegistered)(IN_GUID mediaId,
     126                                 DeviceType_T mediaType, BOOL registered)
     127    {
     128        NOREF(mediaId);
     129        NOREF(mediaType);
     130        NOREF(registered);
    132131        return S_OK;
    133132    }
     
    144143    }
    145144
    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,
    147158                                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)
    160159    {
    161160        return S_OK;
     
    166165                                     IN_BSTR flags)
    167166    {
    168         int rc = S_OK;
     167        HRESULT rc = S_OK;
    169168        Utf8Str utf8Name (name);
    170169        Guid uuid(machineId);
     
    173172        if (   SUCCEEDED (rc)
    174173            && uuid == mUuid
    175             && RTStrSimplePatternMultiMatch (mPatterns, RTSTR_MAX,
    176                                              utf8Name.raw(), RTSTR_MAX, NULL))
    177         {
    178             RTPrintf ("Name: %lS, value: %lS, flags: %lS\n", name, value,
    179                       flags);
     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);
    180179            mSignalled = true;
    181180        }
     
    189188    const char *mPatterns;
    190189    Guid mUuid;
    191 #ifdef RT_OS_WINDOWS
     190#ifndef VBOX_WITH_XPCOM
    192191    long refcnt;
    193192#endif
     
    221220
    222221    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)
    224224        verbose = true;
    225225    else if (a->argc != 2)
     
    241241        /* open a session for the VM - new or existing */
    242242        if (FAILED (a->virtualBox->OpenSession(a->session, uuid)))
    243             CHECK_ERROR_RET (a->virtualBox, OpenExistingSession(a->session, uuid), 1);
     243            CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, uuid), 1);
    244244
    245245        /* get the mutable session machine */
     
    247247
    248248        Bstr value;
    249         uint64_t u64Timestamp;
     249        ULONG64 u64Timestamp;
    250250        Bstr flags;
    251251        CHECK_ERROR(machine, GetGuestProperty(Bstr(a->argv[1]), value.asOutParam(),
    252                     &u64Timestamp, flags.asOutParam()));
     252                                              &u64Timestamp, flags.asOutParam()));
    253253        if (!value)
    254254            RTPrintf("No value set!\n");
     
    268268    HRESULT rc = S_OK;
    269269
    270 /*
    271  * Check the syntax.  We can deduce the correct syntax from the number of
    272  * arguments.
    273  */
     270    /*
     271     * Check the syntax.  We can deduce the correct syntax from the number of
     272     * arguments.
     273     */
    274274    bool usageOK = true;
    275275    const char *pszName = NULL;
    276276    const char *pszValue = NULL;
    277277    const char *pszFlags = NULL;
    278     if (3 == a->argc)
    279     {
     278    if (a->argc == 3)
    280279        pszValue = a->argv[2];
    281     }
    282     else if (4 == a->argc)
     280    else if (a->argc == 4)
    283281        usageOK = false;
    284     else if (5 == a->argc)
     282    else if (a->argc == 5)
    285283    {
    286284        pszValue = a->argv[2];
     
    316314        a->session->COMGETTER(Machine)(machine.asOutParam());
    317315
    318         if ((NULL == pszValue) && (NULL == pszFlags))
     316        if (!pszValue && !pszFlags)
    319317            CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(pszName), NULL));
    320         else if (NULL == pszFlags)
     318        else if (!pszFlags)
    321319            CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(pszName), Bstr(pszValue)));
    322320        else
     
    339337static int handleEnumGuestProperty(HandlerArg *a)
    340338{
    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))
    347347        return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
    348348
    349 /*
    350  * Pack the patterns
    351  */
     349    /*
     350     * Pack the patterns
     351     */
    352352    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)
    354354        Utf8Patterns = Utf8StrFmt ("%s,%s", Utf8Patterns.raw(), a->argv[i]);
    355355
    356 /*
    357  * Make the actual call to Main.
    358  */
     356    /*
     357     * Make the actual call to Main.
     358     */
    359359    ComPtr<IMachine> machine;
    360360    /* assume it's a UUID */
     
    371371
    372372        /* open a session for the VM - new or existing */
    373         if (FAILED (a->virtualBox->OpenSession(a->session, uuid)))
     373        if (FAILED(a->virtualBox->OpenSession(a->session, uuid)))
    374374            CHECK_ERROR_RET (a->virtualBox, OpenExistingSession(a->session, uuid), 1);
    375375
     
    406406static int handleWaitGuestProperty(HandlerArg *a)
    407407{
    408 
    409 /*
    410  * Handle arguments
    411  */
     408    /*
     409     * Handle arguments
     410     */
    412411    const char *pszPatterns = NULL;
    413412    uint32_t u32Timeout = RT_INDEFINITE_WAIT;
     
    445444        return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
    446445
    447 /*
    448  * Set up the callback and wait.
    449  */
     446    /*
     447     * Set up the callback and wait.
     448     */
    450449    Guid uuid;
    451450    machine->COMGETTER(Id)(uuid.asOutParam());
     
    483482                stop = true;
    484483        }
    485 #else
     484#else  /* !USE_XPCOM_QUEUE */
    486485        /** @todo Use a semaphore.  But I currently don't have a Windows system
    487486         * running to test on. */
     487        /**@todo r=bird: get to it!*/
    488488        RTThreadSleep(RT_MIN(1000, u32Timeout));
    489489        if (callback->Signalled())
    490490            stop = true;
    491 #endif /* USE_XPCOM_QUEUE */
    492     }
    493 
    494 /*
    495  * Clean up the callback.
    496  */
    497     a->virtualBox->UnregisterCallback (callback);
     491#endif /* !USE_XPCOM_QUEUE */
     492    }
     493
     494    /*
     495     * Clean up the callback.
     496     */
     497    a->virtualBox->UnregisterCallback(callback);
    498498    if (!callback->Signalled())
    499499        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     */
    505505    return 0;
    506506}
     
    518518    arg.argv = a->argv + 1;
    519519
    520     if (0 == a->argc)
     520    if (a->argc == 0)
    521521        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)
    523525        return handleGetGuestProperty(&arg);
    524     else if (0 == strcmp(a->argv[0], "set"))
     526    if (strcmp(a->argv[0], "set") == 0)
    525527        return handleSetGuestProperty(&arg);
    526     else if (0 == strcmp(a->argv[0], "enumerate"))
     528    if (strcmp(a->argv[0], "enumerate") == 0)
    527529        return handleEnumGuestProperty(&arg);
    528     else if (0 == strcmp(a->argv[0], "wait"))
     530    if (strcmp(a->argv[0], "wait") == 0)
    529531        return handleWaitGuestProperty(&arg);
    530     /* else */
     532
     533    /* default: */
    531534    return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
    532535}
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