VirtualBox

Ignore:
Timestamp:
Nov 12, 2020 6:32:51 PM (4 years ago)
Author:
vboxsync
Message:

Additions/VBoxDRMClient: Removed code duplication between VBoxClient / VBoxService by refactoring the VBoxDRMClient routines into VbglR3. Also improved error checking here and there, added @todos. bugref:9637

File:
1 edited

Legend:

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

    r86876 r86877  
    670670    const char *pSessionType;
    671671
    672     if (pDisplayType != NULL) {
     672    if (pDisplayType != NULL)
    673673        return true;
    674     }
    675     pSessionType = getenv("XDG_SESSION_TYPE");
    676     if ((pSessionType != NULL) && (RTStrIStartsWith(pSessionType, "wayland"))) {
     674
     675    pSessionType = getenv("XDG_SESSION_TYPE"); /** @todo r=andy Use RTEnv API. */
     676    if ((pSessionType != NULL) && (RTStrIStartsWith(pSessionType, "wayland")))
    677677        return true;
    678     }
    679     return false;
    680 }
    681 
    682 /**
    683  * We start VBoxDRMClient from VBoxService in case  some guest property is set.
    684  * We check the same guest property here and dont start this service in case
    685  * it (guest property) is set.
    686  */
    687 static bool checkDRMClient(void)
    688 {
    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;
    700 }
    701 
    702 static bool startDRMClient(void)
    703 {
    704     char* argv[] = {NULL};
    705     char* env[] = {NULL};
    706     char szDRMClientPath[RTPATH_MAX];
    707     RTPathExecDir(szDRMClientPath, RTPATH_MAX);
    708     RTPathAppend(szDRMClientPath, RTPATH_MAX, "VBoxDRMClient");
    709     VBClLogInfo("Starting DRM client.\n");
    710     int rc = execve(szDRMClientPath, argv, env);
    711     if (rc == -1)
    712         VBClLogFatalError("execve for '%s' returns the following error %d: %s\n", szDRMClientPath, errno, strerror(errno));
    713     /* This is reached only when execve fails. */
     678
    714679    return false;
    715680}
     
    723688     * So for 32-bit GAs we use our DRM client. */
    724689#if ARCH_BITS == 32
    725     /* igore rc */ startDRMClient();
    726     return VERR_NOT_AVAILABLE;
     690    int rc = VbglR3DRMClientStart();
     691    if (RT_FAILURE(rc))
     692        VBClLogError("Starting DRM resizing client (32-bit) failed with %Rrc\n", rc);
     693    return VERR_NOT_AVAILABLE; /** @todo r=andy Why ignoring rc here? */
    727694#endif
    728695
    729696    /* If DRM client is already running don't start this service. */
    730     if (checkDRMClient())
    731     {
    732         VBClLogFatalError("DRM resizing is already running. Exiting this service\n");
     697    if (VbglR3DRMClientIsRunning())
     698    {
     699        VBClLogInfo("DRM resizing is already running. Exiting this service\n");
    733700        return VERR_NOT_AVAILABLE;
    734701    }
     702
    735703    if (isXwayland())
    736         return startDRMClient();
     704    {
     705        int rc = VbglR3DRMClientStart();
     706        if (RT_FAILURE(rc))
     707            VBClLogError("Starting DRM resizing client failed with %Rrc\n", rc);
     708        return rc;
     709    }
    737710
    738711    x11Connect();
     712
    739713    if (x11Context.pDisplay == NULL)
    740         return false;
     714        return VERR_NOT_AVAILABLE;
     715
    741716    /* don't start the monitoring thread if related randr functionality is not available. */
    742717    if (x11Context.fMonitorInfoAvailable)
     718    {
    743719        if (RT_FAILURE(startX11MonitorThread()))
    744             return false;
    745     return true;
     720            return VERR_NOT_AVAILABLE;
     721    }
     722
     723    return VINF_SUCCESS;
    746724}
    747725
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