VirtualBox

Changeset 55800 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
May 11, 2015 2:09:09 PM (10 years ago)
Author:
vboxsync
Message:

Main/Session+Machine: small API cleanup, introducing explicit session names and eliminating some terminology confusion (it never was a session type, which is a totally different thing)

Location:
trunk/src/VBox/Main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r55674 r55800  
    41704170  <interface
    41714171    name="IMachine" extends="$unknown"
    4172     uuid="701464d0-7284-42e9-b7b3-894cf31536b7"
     4172    uuid="77a44043-a68a-4ef9-ac26-e9567b1e6bbc"
    41734173    wsmap="managed"
    41744174    wrap-hint-server-addinterfaces="IInternalMachineControl"
     
    46704670    </attribute>
    46714671
    4672     <attribute name="sessionType" type="wstring" readonly="yes">
    4673       <desc>
    4674         Type of the session. If <link to="#sessionState"/> is
     4672    <attribute name="sessionName" type="wstring" readonly="yes">
     4673      <desc>
     4674        Name of the session. If <link to="#sessionState"/> is
    46754675        Spawning or Locked, this attribute contains the
    46764676        same value as passed to the
    46774677        <link to="IMachine::launchVMProcess"/> method in the
    4678         @a type parameter. If the session was used with
    4679         <link to="IMachine::lockMachine" />, or if
     4678        @a name parameter. If the session was established with
     4679        <link to="IMachine::lockMachine" />, it is the name of the session
     4680        (if set, otherwise empty string). If
    46804681        <link to="#sessionState"/> is SessionClosed, the value of this
    46814682        attribute is an empty string.
     
    51915192        </desc>
    51925193      </param>
    5193       <param name="type" type="wstring" dir="in">
     5194      <param name="name" type="wstring" dir="in">
    51945195        <desc>
    51955196          Front-end to use for the new VM process. The following are currently supported:
     
    1926619267  <interface
    1926719268    name="ISession" extends="$unknown"
    19268     uuid="12F4DCDB-12B2-4EC1-B7CD-DDD9F6C5BF4D"
     19269    uuid="3d4f472c-aac8-4387-94be-54042bcd8901"
    1926919270    wsmap="managed"
    1927019271    wrap-hint-server-addinterfaces="IInternalSessionControl"
     
    1933919340    </attribute>
    1934019341
     19342    <attribute name="name" type="wstring">
     19343      <desc>
     19344        Name of this session. Important only for VM sessions, otherwise it
     19345        it will be remembered, but not used for anything significant (and can
     19346        be left at the empty string which is the default). The value can only
     19347        be changed when the session state is SessionState_Unlocked. Make sure
     19348        that you use a descriptive name which does not conflict with the VM
     19349        process session names: "GUI/Qt", "GUI/SDL" and "headless".
     19350      </desc>
     19351    </attribute>
     19352
    1934119353    <attribute name="machine" type="IMachine" readonly="yes">
    1934219354      <desc>Machine object associated with this session.</desc>
     
    1934419356
    1934519357    <attribute name="console" type="IConsole" readonly="yes">
    19346       <desc>Console object associated with this session.</desc>
     19358      <desc>Console object associated with this session. Only sessions
     19359      which locked the machine for a VM process have a non-null console.</desc>
    1934719360    </attribute>
    1934819361
  • trunk/src/VBox/Main/include/MachineImpl.h

    r55674 r55800  
    149149            SessionState_T mState;
    150150
    151             /** Session type string (for indirect sessions) */
    152             Utf8Str mType;
     151            /** Session name string (of the primary session) */
     152            Utf8Str mName;
    153153
    154154            /** Session machine object */
     
    928928    HRESULT getSettingsModified(BOOL *aSettingsModified);
    929929    HRESULT getSessionState(SessionState_T *aSessionState);
    930     HRESULT getSessionType(com::Utf8Str &aSessionType);
     930    HRESULT getSessionType(SessionType_T *aSessionType);
     931    HRESULT getSessionName(com::Utf8Str &aSessionType);
    931932    HRESULT getSessionPID(ULONG *aSessionPID);
    932933    HRESULT getState(MachineState_T *aState);
  • trunk/src/VBox/Main/include/SessionImpl.h

    r55401 r55800  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5757    HRESULT getState(SessionState_T *aState);
    5858    HRESULT getType(SessionType_T *aType);
     59    HRESULT getName(com::Utf8Str &aName);
     60    HRESULT setName(const com::Utf8Str &aName);
    5961    HRESULT getMachine(ComPtr<IMachine> &aMachine);
    6062    HRESULT getConsole(ComPtr<IConsole> &aConsole);
     
    143145    SessionState_T mState;
    144146    SessionType_T mType;
     147    Utf8Str mName;
    145148
    146149    ComPtr<IInternalMachineControl> mControl;
  • trunk/src/VBox/Main/src-client/SessionImpl.cpp

    r55214 r55800  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    149149
    150150    *aType = mType;
     151    return S_OK;
     152}
     153
     154HRESULT Session::getName(com::Utf8Str &aName)
     155{
     156    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     157
     158    aName = mName;
     159    return S_OK;
     160}
     161
     162HRESULT Session::setName(const com::Utf8Str &aName)
     163{
     164    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     165
     166    if (mState != SessionState_Unlocked)
     167        return setError(VBOX_E_INVALID_OBJECT_STATE, tr("Trying to set name for a session which is not in state \"unlocked\""));
     168
     169    mName = aName;
    151170    return S_OK;
    152171}
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r55769 r55800  
    26742674HRESULT Machine::getSessionState(SessionState_T *aSessionState)
    26752675{
    2676 
    26772676    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    26782677
     
    26822681}
    26832682
    2684 HRESULT Machine::getSessionType(com::Utf8Str &aSessionType)
     2683HRESULT Machine::getSessionName(com::Utf8Str &aSessionName)
    26852684{
    26862685    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    26872686
    2688     aSessionType = mData->mSession.mType;
     2687    aSessionName = mData->mSession.mName;
    26892688
    26902689    return S_OK;
     
    32233222                    E_INVALIDARG);
    32243223
     3224    // session name (only used in some code paths)
     3225    Utf8Str strSessionName;
     3226
    32253227    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    32263228
     
    34373439                         tr("Failed to assign the machine to the session (%Rhrc)"), rc);
    34383440
     3441            // get session name, either to remember or to compare against
     3442            // the already known session name.
     3443            {
     3444                Bstr bstrSessionName;
     3445                HRESULT rc2 = aSession->COMGETTER(Name)(bstrSessionName.asOutParam());
     3446                if (SUCCEEDED(rc2))
     3447                    strSessionName = bstrSessionName;
     3448            }
     3449
    34393450            if (    SUCCEEDED(rc)
    34403451                 && fLaunchingVMProcess
     
    34853496        if (fLaunchingVMProcess)
    34863497        {
     3498            Assert(mData->mSession.mName == strSessionName);
    34873499            /* Note that the progress object is finalized later */
    34883500            /** @todo Consider checking mData->mSession.mProgress for cancellation
     
    35223534            mData->mSession.mDirectControl = pSessionControl;
    35233535            mData->mSession.mState = SessionState_Locked;
     3536            if (!fLaunchingVMProcess)
     3537                mData->mSession.mName = strSessionName;
    35243538            /* associate the SessionMachine with this Machine */
    35253539            mData->mSession.mMachine = sessionMachine;
     
    35613575 */
    35623576HRESULT Machine::launchVMProcess(const ComPtr<ISession> &aSession,
    3563                                  const com::Utf8Str &aType,
     3577                                 const com::Utf8Str &aName,
    35643578                                 const com::Utf8Str &aEnvironment,
    35653579                                 ComPtr<IProgress> &aProgress)
    35663580{
    3567     Utf8Str strFrontend(aType);
     3581    Utf8Str strFrontend(aName);
    35683582    /* "emergencystop" doesn't need the session, so skip the checks/interface
    35693583     * retrieval. This code doesn't quite fit in here, but introducing a
     
    74307444    if (fSeparate)
    74317445    {
    7432         if (mData->mSession.mState != SessionState_Unlocked && mData->mSession.mType.compare("headless", Utf8Str::CaseInsensitive))
     7446        if (mData->mSession.mState != SessionState_Unlocked && mData->mSession.mName == "headless")
    74337447            return setError(VBOX_E_INVALID_OBJECT_STATE,
    74347448                            tr("The machine '%s' is in a state which is incompatible with launching a separate UI process"),
     
    75317545#endif
    75327546
     7547    Utf8Str strCanonicalName;
    75337548
    75347549#ifdef VBOX_WITH_QTGUI
     
    75397554        || !strFrontend.compare("GUI/Qt/separate", Utf8Str::CaseInsensitive))
    75407555    {
     7556        strCanonicalName = "GUI/Qt";
    75417557# ifdef RT_OS_DARWIN /* Avoid Launch Services confusing this with the selector by using a helper app. */
    75427558        /* Modify the base path so that we don't need to use ".." below. */
     
    76077623        || !strFrontend.compare("GUI/SDL/separate", Utf8Str::CaseInsensitive))
    76087624    {
     7625        strCanonicalName = "GUI/SDL";
    76097626        static const char s_szVBoxSDL_exe[] = "VBoxSDL" HOSTSUFF_EXE;
    76107627        Assert(cchBufLeft >= sizeof(s_szVBoxSDL_exe));
     
    76417658       )
    76427659    {
     7660        strCanonicalName = "headless";
    76437661        /* On pre-4.0 the "headless" type was used for passing "--vrdp off" to VBoxHeadless to let it work in OSE,
    76447662         * which did not contain VRDP server. In VBox 4.0 the remote desktop server (VRDE) is optional,
     
    77327750        mData->mSession.mPID = pid;
    77337751        mData->mSession.mState = SessionState_Spawning;
    7734         mData->mSession.mType = strFrontend;
     7752        Assert(strCanonicalName.isNotEmpty());
     7753        mData->mSession.mName = strCanonicalName;
    77357754    }
    77367755    else
     
    1265412673    mData->mSession.mMachine.setNull();
    1265512674    mData->mSession.mState = SessionState_Unlocked;
    12656     mData->mSession.mType.setNull();
     12675    mData->mSession.mName.setNull();
    1265712676
    1265812677    /* destroy the machine client token before leaving the exclusive lock */
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