VirtualBox

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


Ignore:
Timestamp:
Mar 7, 2011 9:45:24 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70380
Message:

Main/VBoxManage/Guest Additions: Added support for "TRANSIENT_RESET" guest properties which are only present until a VM reset.

File:
1 edited

Legend:

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

    r36074 r36178  
    673673#ifdef VBOX_WITH_GUEST_PROPS
    674674
    675 bool Console::enabledGuestPropertiesVRDP(void)
     675/**
     676 * Handles guest properties on a VM reset.
     677 * At the moment we only delete properties which have the flag
     678 * "TRARESET".
     679 */
     680void Console::guestPropertiesHandleVMReset(void)
     681{
     682    com::SafeArray<BSTR>   arrNames;
     683    com::SafeArray<BSTR>   arrValues;
     684    com::SafeArray<LONG64> arrTimestamps;
     685    com::SafeArray<BSTR>   arrFlags;
     686    HRESULT hrc = enumerateGuestProperties(Bstr("*").raw(),
     687                                           ComSafeArrayAsOutParam(arrNames),
     688                                           ComSafeArrayAsOutParam(arrValues),
     689                                           ComSafeArrayAsOutParam(arrTimestamps),
     690                                           ComSafeArrayAsOutParam(arrFlags));
     691    if (SUCCEEDED(hrc))
     692    {
     693        for (size_t i = 0; i < arrFlags.size(); i++)
     694        {
     695            /* Delete all properties which have the flag "TRARESET". */
     696            if (Utf8Str(arrFlags[i]).contains("TRANSIENT_RESET", Utf8Str::CaseInsensitive))
     697            {
     698                hrc = mMachine->SetGuestProperty(arrNames[i], Bstr("").raw() /* Value */,
     699                                                 Bstr("").raw() /* Flags */);
     700                if (FAILED(hrc))
     701                    LogRel(("RESET: Could not delete transient property \"%ls\", rc=%Rhrc\n",
     702                            arrNames[i], hrc));
     703            }
     704        }
     705    }
     706    else
     707        LogRel(("RESET: Unable to enumerate guest properties, rc=%Rhrc\n", hrc));
     708}
     709
     710bool Console::guestPropertiesVRDPEnabled(void)
    676711{
    677712    Bstr value;
    678713    HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/EnableGuestPropertiesVRDP").raw(),
    679714                                         value.asOutParam());
    680     if (hrc == S_OK)
    681     {
    682         if (value == "1")
    683         {
    684             return true;
    685         }
    686     }
     715    if (   hrc   == S_OK
     716        && value == "1")
     717        return true;
    687718    return false;
    688719}
    689720
    690 void Console::updateGuestPropertiesVRDPLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
    691 {
    692     if (!enabledGuestPropertiesVRDP())
    693     {
     721void Console::guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
     722{
     723    if (!guestPropertiesVRDPEnabled())
    694724        return;
    695     }
    696725
    697726    char szPropNm[256];
     
    725754}
    726755
    727 void Console::updateGuestPropertiesVRDPDisconnect(uint32_t u32ClientId)
    728 {
    729     if (!enabledGuestPropertiesVRDP())
     756void Console::guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId)
     757{
     758    if (!guestPropertiesVRDPEnabled())
    730759        return;
    731760
     
    961990
    962991#ifdef VBOX_WITH_GUEST_PROPS
    963     updateGuestPropertiesVRDPLogon(u32ClientId, pszUser, pszDomain);
     992    guestPropertiesVRDPUpdateLogon(u32ClientId, pszUser, pszDomain);
    964993#endif /* VBOX_WITH_GUEST_PROPS */
    965994
     
    10961125
    10971126#ifdef VBOX_WITH_GUEST_PROPS
    1098     updateGuestPropertiesVRDPDisconnect(u32ClientId);
     1127    guestPropertiesVRDPUpdateDisconnect(u32ClientId);
    10991128#endif /* VBOX_WITH_GUEST_PROPS */
    11001129
     
    67686797                    break;
    67696798            }
     6799            break;
     6800        }
     6801
     6802        case VMSTATE_RESETTING:
     6803        {
     6804    #ifdef VBOX_WITH_GUEST_PROPS
     6805            /* Do not take any read/write locks here! */
     6806            that->guestPropertiesHandleVMReset();
     6807    #endif
    67706808            break;
    67716809        }
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