VirtualBox

Changeset 24618 in vbox


Ignore:
Timestamp:
Nov 12, 2009 5:52:33 PM (15 years ago)
Author:
vboxsync
Message:

Added Global::vboxStatusCodeFromCOM (and Global::vboxStatusCodeToCOM), made Console::doGuestPropNotification make use of it.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/err.h

    r24282 r24618  
    14501450 */
    14511451/** Switch back to host */
    1452 #define VINF_PARAV_SWITCH_TO_HOST                     4400
     1452#define VINF_PARAV_SWITCH_TO_HOST                   4400
    14531453
    14541454/** @} */
     
    14581458 */
    14591459/** command processing is pending, a completion handler will be called */
    1460 #define VINF_VHWA_CMD_PENDING                        4500
    1461 
     1460#define VINF_VHWA_CMD_PENDING                       4500
     1461
     1462/** @} */
     1463
     1464
     1465/** @name VBox Webservice Status Codes
     1466 * @{
     1467 */
     1468/** Object not found. */
     1469#define VERR_COM_OBJECT_NOT_FOUND                  (-4601)
     1470/** Invalid machine state. */
     1471#define VERR_COM_INVALID_VM_STATE                  (-4602)
     1472/** VM error. */
     1473#define VERR_COM_VM_ERROR                          (-4603)
     1474/** File error. */
     1475#define VERR_COM_FILE_ERROR                        (-4604)
     1476/** IPRT error. */
     1477#define VERR_COM_IPRT_ERROR                        (-4605)
     1478/** PDM error. */
     1479#define VERR_COM_PDM_ERROR                         (-4606)
     1480/** Invalid object state. */
     1481#define VERR_COM_INVALID_OBJECT_STATE              (-4607)
     1482/** Host error. */
     1483#define VERR_COM_HOST_ERROR                        (-4608)
     1484/** Not supported. */
     1485#define VERR_COM_NOT_SUPPORTED                     (-4609)
     1486/** XML error. */
     1487#define VERR_COM_XML_ERROR                         (-4610)
     1488/** Invalid session state. */
     1489#define VERR_COM_INVALID_SESSION_STATE             (-4611)
     1490/** Invalid session state. */
     1491#define VERR_COM_OBJECT_IN_USE                     (-4612)
    14621492/** @} */
    14631493
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r24579 r24618  
    11971197//             LogFunc(("pCBData->pcszValue=%s\n", pCBData->pcszValue));
    11981198//             LogFunc(("pCBData->pcszFlags=%s\n", pCBData->pcszFlags));
    1199             rc = VERR_UNRESOLVED_ERROR;  /** @todo translate error code */
     1199            rc = Global::vboxStatusCodeFromCOM(hrc);
    12001200        }
    12011201    }
  • trunk/src/VBox/Main/Global.cpp

    r24301 r24618  
    2828#include <iprt/assert.h>
    2929#include <iprt/string.h>
     30#include <VBox/err.h>
    3031
    3132/* static */
     
    237238}
    238239
     240/*static*/ int
     241Global::vboxStatusCodeFromCOM(HRESULT aComStatus)
     242{
     243    switch (aComStatus)
     244    {
     245        case S_OK:                              return VINF_SUCCESS;
     246        case E_FAIL:                            return VERR_GENERAL_FAILURE;
     247        case E_INVALIDARG:                      return VERR_INVALID_PARAMETER;
     248        case E_POINTER:                         return VERR_INVALID_POINTER;
     249
     250        case VBOX_E_OBJECT_NOT_FOUND:           return VERR_COM_OBJECT_NOT_FOUND;
     251        case VBOX_E_INVALID_VM_STATE:           return VERR_COM_INVALID_VM_STATE;
     252        case VBOX_E_VM_ERROR:                   return VERR_COM_VM_ERROR;
     253        case VBOX_E_FILE_ERROR:                 return VERR_COM_FILE_ERROR;
     254        case VBOX_E_IPRT_ERROR:                 return VERR_COM_IPRT_ERROR;
     255        case VBOX_E_PDM_ERROR:                  return VERR_COM_PDM_ERROR;
     256        case VBOX_E_INVALID_OBJECT_STATE:       return VERR_COM_INVALID_OBJECT_STATE;
     257        case VBOX_E_HOST_ERROR:                 return VERR_COM_HOST_ERROR;
     258        case VBOX_E_NOT_SUPPORTED:              return VERR_COM_NOT_SUPPORTED;
     259        case VBOX_E_XML_ERROR:                  return VERR_COM_XML_ERROR;
     260        case VBOX_E_INVALID_SESSION_STATE:      return VERR_COM_INVALID_SESSION_STATE;
     261        case VBOX_E_OBJECT_IN_USE:              return VERR_COM_OBJECT_IN_USE;
     262
     263        default:
     264            if (SUCCEEDED(aComStatus))
     265                return VINF_SUCCESS;
     266            return VERR_UNRESOLVED_ERROR;
     267    }
     268}
     269
     270
     271/*static*/ HRESULT
     272Global::vboxStatusCodeToCOM(int aVBoxStatus)
     273{
     274    switch (aVBoxStatus)
     275    {
     276        case VINF_SUCCESS:                      return S_OK;
     277        case VERR_GENERAL_FAILURE:              return E_FAIL;
     278        case VERR_UNRESOLVED_ERROR:             return E_FAIL;
     279        case VERR_INVALID_PARAMETER:            return E_INVALIDARG;
     280        case VERR_INVALID_POINTER:              return E_POINTER;
     281
     282        case VERR_COM_OBJECT_NOT_FOUND:         return VBOX_E_OBJECT_NOT_FOUND;
     283        case VERR_COM_INVALID_VM_STATE:         return VBOX_E_INVALID_VM_STATE;
     284        case VERR_COM_VM_ERROR:                 return VBOX_E_VM_ERROR;
     285        case VERR_COM_FILE_ERROR:               return VBOX_E_FILE_ERROR;
     286        case VERR_COM_IPRT_ERROR:               return VBOX_E_IPRT_ERROR;
     287        case VERR_COM_PDM_ERROR:                return VBOX_E_PDM_ERROR;
     288        case VERR_COM_INVALID_OBJECT_STATE:     return VBOX_E_INVALID_OBJECT_STATE;
     289        case VERR_COM_HOST_ERROR:               return VBOX_E_HOST_ERROR;
     290        case VERR_COM_NOT_SUPPORTED:            return VBOX_E_NOT_SUPPORTED;
     291        case VERR_COM_XML_ERROR:                return VBOX_E_XML_ERROR;
     292        case VERR_COM_INVALID_SESSION_STATE:    return VBOX_E_INVALID_SESSION_STATE;
     293        case VERR_COM_OBJECT_IN_USE:            return VBOX_E_OBJECT_IN_USE;
     294
     295        default:
     296            AssertMsgFailed(("%Rrc\n", aVBoxStatus));
     297            if (RT_SUCCESS(aVBoxStatus))
     298                return S_OK;
     299
     300            /* try categorize it */
     301            if (aVBoxStatus < 0 && aVBoxStatus > -1000)
     302                return VBOX_E_IPRT_ERROR;
     303            if (    aVBoxStatus <  VERR_PDM_NO_SUCH_LUN / 100 * 10
     304                &&  aVBoxStatus >  VERR_PDM_NO_SUCH_LUN / 100 * 10 - 100)
     305                return VBOX_E_PDM_ERROR;
     306            if (    aVBoxStatus <= -1000
     307                &&  aVBoxStatus >  -5000 /* wrong, but so what... */)
     308                return VBOX_E_VM_ERROR;
     309
     310            return E_FAIL;
     311    }
     312}
     313
     314
    239315/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/include/Global.h

    r24301 r24618  
    161161     */
    162162    static const char *stringifySessionState(SessionState_T aState);
     163
     164    /**
     165     * Try convert a COM status code to a VirtualBox status code (VBox/err.h).
     166     *
     167     * @returns VBox status code.
     168     * @param   aComStatus      COM status code.
     169     */
     170    static int vboxStatusCodeFromCOM(HRESULT aComStatus);
     171
     172    /**
     173     * Try convert a VirtualBox status code (VBox/err.h) to a COM status code.
     174     *
     175     * This is mainly inteded for dealing with vboxStatusCodeFromCOM() return
     176     * values.  If used on anything else, it won't be able to cope with most of the
     177     * input!
     178     *
     179     * @returns COM status code.
     180     * @param   aVBoxStatus      VBox status code.
     181     */
     182    static HRESULT vboxStatusCodeToCOM(int aVBoxStatus);
    163183};
    164184
Note: See TracChangeset for help on using the changeset viewer.

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