VirtualBox

Changeset 44970 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Mar 11, 2013 9:59:05 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84190
Message:

Main/VirtualBoxClient: add method to perform VM error checking which simplifies client code
com/ErrorInfo: small bugfix (the object where the error information originated was always lost), added a way to inject whole error object structures which needed the bugfix
Frontends/VBoxSDL: sample code how to use the new method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/VirtualBoxClientImpl.cpp

    r44529 r44970  
    55
    66/*
    7  * Copyright (C) 2010-2011 Oracle Corporation
     7 * Copyright (C) 2010-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121#include "VBoxEvents.h"
    2222#include "Logging.h"
     23#include "VBox/com/ErrorInfo.h"
    2324
    2425#include <iprt/asm.h>
     
    199200
    200201    return mData.m_pEventSource.isNull() ? E_FAIL : S_OK;
     202}
     203
     204/**
     205 * Checks a Machine object for any pending errors.
     206 *
     207 * @returns COM status code
     208 * @param   aMachine    Machine object to check.
     209 */
     210STDMETHODIMP VirtualBoxClient::CheckMachineError(IMachine *aMachine)
     211{
     212    HRESULT rc;
     213    CheckComArgNotNull(aMachine);
     214
     215    BOOL fAccessible = FALSE;
     216    rc = aMachine->COMGETTER(Accessible)(&fAccessible);
     217    if (FAILED(rc))
     218        return setError(rc, tr("Could not check the accessibility status of the VM"));
     219    else if (!fAccessible)
     220    {
     221        ComPtr<IVirtualBoxErrorInfo> pAccessError;
     222        rc = aMachine->COMGETTER(AccessError)(pAccessError.asOutParam());
     223        if (FAILED(rc))
     224            return setError(rc, tr("Could not get the access error message of the VM"));
     225        else
     226        {
     227            ErrorInfo info(pAccessError);
     228            ErrorInfoKeeper eik(info);
     229            return info.getResultCode();
     230        }
     231    }
     232    return S_OK;
    201233}
    202234
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