VirtualBox

Ignore:
Timestamp:
Sep 27, 2019 2:32:13 PM (5 years ago)
Author:
vboxsync
Message:

Shared Clipboard/VBoxClient: Cleaned up connecting to host service.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp

    r81052 r81060  
    181181 * @returns VBox status code
    182182 */
    183 int SharedClipboardSvcImplConnect(void)
    184 {
    185     int rc = VINF_SUCCESS;
    186     LogRelFlowFunc(("\n"));
     183static int vboxClipboardConnect(void)
     184{
     185    LogFlowFuncEnter();
    187186
    188187    /* Sanity */
    189     AssertReturn(g_ctx.client == 0, VERR_WRONG_ORDER);
     188    AssertReturn(g_ctx.client   == 0,    VERR_WRONG_ORDER);
     189    AssertReturn(g_ctx.pBackend == NULL, VERR_WRONG_ORDER);
     190
     191    int rc;
     192
    190193    g_ctx.pBackend = ClipConstructX11(&g_ctx, false);
    191     if (!g_ctx.pBackend)
     194    if (g_ctx.pBackend)
     195    {
     196        rc = ClipStartX11(g_ctx.pBackend, false /* grab */);
     197        if (RT_SUCCESS(rc))
     198        {
     199            rc = VbglR3ClipboardConnect(&g_ctx.client);
     200            if (RT_SUCCESS(rc))
     201            {
     202                Assert(g_ctx.client);
     203            }
     204            else
     205                VBClLogError("Error connecting to host, rc=%Rrc\n", rc);
     206        }
     207    }
     208    else
    192209        rc = VERR_NO_MEMORY;
    193     if (RT_SUCCESS(rc))
    194         rc = ClipStartX11(g_ctx.pBackend, false /* grab */);
    195     if (RT_SUCCESS(rc))
    196     {
    197         rc = VbglR3ClipboardConnect(&g_ctx.client);
    198         if (RT_FAILURE(rc))
    199             VBClLogError("Error connecting to host, rc=%Rrc\n", rc);
    200         else if (!g_ctx.client)
    201         {
    202             VBClLogError("Invalid client ID of 0\n");
    203             rc = VERR_NOT_SUPPORTED;
    204         }
    205     }
    206210
    207211    if (rc != VINF_SUCCESS && g_ctx.pBackend)
     
    300304
    301305    /* Initialise the guest library. */
    302     int rc = SharedClipboardSvcImplConnect();
    303     /* Not RT_SUCCESS: VINF_PERMISSION_DENIED is host service not present. */
    304     if (rc == VINF_SUCCESS)
     306    int rc = vboxClipboardConnect();
     307    if (RT_SUCCESS(rc))
     308    {
    305309        rc = vboxClipboardMain();
    306     if (rc == VERR_NOT_SUPPORTED)
    307         rc = VINF_SUCCESS;  /* Prevent automatic restart. */
     310    }
     311
    308312    if (RT_FAILURE(rc))
    309         LogRelFunc(("guest clipboard service terminated abnormally: return code %Rrc\n", rc));
     313        VBClLogError("Service terminated abnormally with %Rrc\n", rc);
     314
     315    if (rc == VERR_HGCM_SERVICE_NOT_FOUND)
     316        rc = VINF_SUCCESS; /* Prevent automatic restart by daemon script if host service not available. */
     317
    310318    return rc;
    311319}
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