VirtualBox

Ignore:
Timestamp:
Jan 20, 2014 2:05:02 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
91661
Message:

Main+Frontends: clear out some cruft code, outdated EventQueue stuff and whitespace cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp

    r48244 r50117  
    66
    77/*
    8  * Copyright (C) 2006-2011 Oracle Corporation
     8 * Copyright (C) 2006-2014 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2222#include <VBox/com/ErrorInfo.h>
    2323#include <VBox/com/errorprint.h>
    24 #include <VBox/com/EventQueue.h>
    2524
    2625#include <VBox/com/VirtualBox.h>
     
    3837 *  Entry point.
    3938 */
    40 int main (int argc, char **argv)
     39int main(int argc, char **argv)
    4140{
    4241    // initialize VBox Runtime
     
    5655    if (!name || !operation)
    5756    {
    58         RTPrintf ("\nUsage:\n\n"
    59                   "%s <machine_name> [on|off|pause|resume]\n\n",
    60                   argv [0]);
     57        RTPrintf("\nUsage:\n\n"
     58                 "%s <machine_name> [on|off|pause|resume]\n\n",
     59                 argv [0]);
    6160        return 0;
    6261    }
    6362
    64     RTPrintf ("\n");
    65     RTPrintf ("tstHeadless STARTED.\n");
    66 
    67     RTPrintf ("VM name   : {%s}\n"
    68               "Operation : %s\n\n",
    69               name, operation);
     63    RTPrintf("\n");
     64    RTPrintf("tstHeadless STARTED.\n");
     65
     66    RTPrintf("VM name   : {%s}\n"
     67             "Operation : %s\n\n",
     68             name, operation);
    7069
    7170    HRESULT rc;
     
    8382        ComPtr <ISession> session;
    8483
    85         RTPrintf ("Creating VirtualBox object...\n");
    86         rc = virtualBox.createLocalObject (CLSID_VirtualBox);
     84        RTPrintf("Creating VirtualBox object...\n");
     85        rc = virtualBox.createLocalObject(CLSID_VirtualBox);
    8786        if (FAILED(rc))
    8887            RTPrintf("ERROR: failed to create the VirtualBox object!\n");
     
    9493        }
    9594
    96         if (FAILED (rc))
     95        if (FAILED(rc))
    9796        {
    9897            com::ErrorInfo info;
     
    106105            break;
    107106        }
    108 
    109         // create the event queue
    110         // (here it is necessary only to process remaining XPCOM/IPC events
    111         // after the session is closed)
    112         EventQueue eventQ;
    113107
    114108        ComPtr <IMachine> m;
     
    121115        {
    122116            ComPtr <IProgress> progress;
    123             RTPrintf ("Opening a new (remote) session...\n");
    124             CHECK_ERROR_BREAK (m,
    125                                LaunchVMProcess(session, Bstr("vrdp").raw(),
    126                                                NULL, progress.asOutParam()));
    127 
    128             RTPrintf ("Waiting for the remote session to open...\n");
    129             CHECK_ERROR_BREAK (progress, WaitForCompletion (-1));
     117            RTPrintf("Opening a new (remote) session...\n");
     118            CHECK_ERROR_BREAK(m,
     119                              LaunchVMProcess(session, Bstr("vrdp").raw(),
     120                                              NULL, progress.asOutParam()));
     121
     122            RTPrintf("Waiting for the remote session to open...\n");
     123            CHECK_ERROR_BREAK(progress, WaitForCompletion(-1));
    130124
    131125            BOOL completed;
    132             CHECK_ERROR_BREAK (progress, COMGETTER(Completed) (&completed));
    133             ASSERT (completed);
     126            CHECK_ERROR_BREAK(progress, COMGETTER(Completed)(&completed));
     127            ASSERT(completed);
    134128
    135129            LONG resultCode;
    136             CHECK_ERROR_BREAK (progress, COMGETTER(ResultCode) (&resultCode));
    137             if (FAILED (resultCode))
     130            CHECK_ERROR_BREAK(progress, COMGETTER(ResultCode)(&resultCode));
     131            if (FAILED(resultCode))
    138132            {
    139133                ProgressErrorInfo info(progress);
     
    142136            else
    143137            {
    144                 RTPrintf ("Remote session has been successfully opened.\n");
     138                RTPrintf("Remote session has been successfully opened.\n");
    145139            }
    146140        }
    147141        else
    148142        {
    149             RTPrintf ("Opening an existing session...\n");
     143            RTPrintf("Opening an existing session...\n");
    150144            CHECK_ERROR_BREAK(m, LockMachine(session, LockType_Shared));
    151145
     
    153147            CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam()));
    154148
    155             if (!strcmp (operation, "off"))
     149            if (!strcmp(operation, "off"))
    156150            {
    157151                ComPtr <IProgress> progress;
    158                 RTPrintf ("Powering the VM off...\n");
    159                 CHECK_ERROR_BREAK (console, PowerDown(progress.asOutParam()));
    160 
    161                 RTPrintf ("Waiting for the VM to power down...\n");
    162                 CHECK_ERROR_BREAK (progress, WaitForCompletion (-1));
     152                RTPrintf("Powering the VM off...\n");
     153                CHECK_ERROR_BREAK(console, PowerDown(progress.asOutParam()));
     154
     155                RTPrintf("Waiting for the VM to power down...\n");
     156                CHECK_ERROR_BREAK(progress, WaitForCompletion(-1));
    163157
    164158                BOOL completed;
    165                 CHECK_ERROR_BREAK (progress, COMGETTER(Completed) (&completed));
    166                 ASSERT (completed);
     159                CHECK_ERROR_BREAK(progress, COMGETTER(Completed)(&completed));
     160                ASSERT(completed);
    167161
    168162                LONG resultCode;
    169                 CHECK_ERROR_BREAK (progress, COMGETTER(ResultCode) (&resultCode));
    170                 if (FAILED (resultCode))
     163                CHECK_ERROR_BREAK(progress, COMGETTER(ResultCode)(&resultCode));
     164                if (FAILED(resultCode))
    171165                {
    172166                    ProgressErrorInfo info(progress);
     
    175169                else
    176170                {
    177                     RTPrintf ("VM is powered down.\n");
     171                    RTPrintf("VM is powered down.\n");
    178172                }
    179173            }
    180174            else
    181             if (!strcmp (operation, "pause"))
    182             {
    183                 RTPrintf ("Pausing the VM...\n");
    184                 CHECK_ERROR_BREAK (console, Pause());
    185             }
    186             else
    187             if (!strcmp (operation, "resume"))
    188             {
    189                 RTPrintf ("Resuming the VM...\n");
    190                 CHECK_ERROR_BREAK (console, Resume());
    191             }
    192             else
    193             {
    194                 RTPrintf ("Invalid operation!\n");
     175            if (!strcmp(operation, "pause"))
     176            {
     177                RTPrintf("Pausing the VM...\n");
     178                CHECK_ERROR_BREAK(console, Pause());
     179            }
     180            else
     181            if (!strcmp(operation, "resume"))
     182            {
     183                RTPrintf("Resuming the VM...\n");
     184                CHECK_ERROR_BREAK(console, Resume());
     185            }
     186            else
     187            {
     188                RTPrintf("Invalid operation!\n");
    195189            }
    196190        }
     
    200194    }
    201195    while (0);
    202     RTPrintf ("\n");
     196    RTPrintf("\n");
    203197
    204198    com::Shutdown();
    205199
    206     RTPrintf ("tstHeadless FINISHED.\n");
     200    RTPrintf("tstHeadless FINISHED.\n");
    207201
    208202    return rc;
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