VirtualBox

Ignore:
Timestamp:
Nov 12, 2020 4:38:00 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141332
Message:

Guest Additions/VbglR3: Condensed / removed duplicate guest property code by adding VbglR3GuestPropExist() + VbglR3GuestPropReadEx().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp

    r86873 r86876  
    681681
    682682/**
    683  * An abbreviated copy of the VGSvcReadProp from VBoxServiceUtils.cpp
    684  */
    685 static int readGuestProperty(uint32_t u32ClientId, const char *pszPropName)
    686 {
    687     AssertPtrReturn(pszPropName, VERR_INVALID_POINTER);
    688 
    689     uint32_t    cbBuf = _1K;
    690     void       *pvBuf = NULL;
    691     int         rc    = VINF_SUCCESS;  /* MSC can't figure out the loop */
    692 
    693     for (unsigned cTries = 0; cTries < 10; cTries++)
    694     {
    695         /*
    696          * (Re-)Allocate the buffer and try read the property.
    697          */
    698         RTMemFree(pvBuf);
    699         pvBuf = RTMemAlloc(cbBuf);
    700         if (!pvBuf)
    701         {
    702             VBClLogError("Guest Property: Failed to allocate %zu bytes\n", cbBuf);
    703             rc = VERR_NO_MEMORY;
    704             break;
    705         }
    706         char    *pszValue;
    707         char    *pszFlags;
    708         uint64_t uTimestamp;
    709         rc = VbglR3GuestPropRead(u32ClientId, pszPropName, pvBuf, cbBuf, &pszValue, &uTimestamp, &pszFlags, NULL);
    710         if (RT_FAILURE(rc))
    711         {
    712             if (rc == VERR_BUFFER_OVERFLOW)
    713             {
    714                 /* try again with a bigger buffer. */
    715                 cbBuf *= 2;
    716                 continue;
    717             }
    718             else
    719                 break;
    720         }
    721         else
    722             break;
    723     }
    724 
    725     if (pvBuf)
    726         RTMemFree(pvBuf);
    727     return rc;
    728 }
    729 
    730 /**
    731683 * We start VBoxDRMClient from VBoxService in case  some guest property is set.
    732684 * We check the same guest property here and dont start this service in case
     
    735687static bool checkDRMClient(void)
    736688{
    737    uint32_t uGuestPropSvcClientID;
    738    int rc = VbglR3GuestPropConnect(&uGuestPropSvcClientID);
    739    if (RT_FAILURE(rc))
    740        return false;
    741    rc = readGuestProperty(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/DRMResize" /*pszPropName*/);
    742    if (RT_FAILURE(rc))
    743        return false;
    744    return true;
     689    bool fStartClient = false;
     690
     691    uint32_t idClient;
     692    int rc = VbglR3GuestPropConnect(&idClient);
     693    if (RT_SUCCESS(rc))
     694    {
     695        fStartClient = VbglR3GuestPropExist(idClient, "/VirtualBox/GuestAdd/DRMResize" /*pszPropName*/);
     696        VbglR3GuestPropDisconnect(idClient);
     697    }
     698
     699    return fStartClient;
    745700}
    746701
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