VirtualBox

Changeset 74205 in vbox for trunk/src


Ignore:
Timestamp:
Sep 12, 2018 9:22:06 AM (6 years ago)
Author:
vboxsync
Message:

DnD/HostService: Refactored out more code to the common client and message classes, added documentation (also about deferred client states).

Location:
trunk/src/VBox/HostServices
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/DragAndDrop/Makefile.kmk

    r69111 r74205  
    55
    66#
    7 # Copyright (C) 2011-2017 Oracle Corporation
     7# Copyright (C) 2011-2018 Oracle Corporation
    88#
    99# This file is part of VirtualBox Open Source Edition (OSE), as
     
    3939        dndmanager.cpp
    4040
     41VBoxDragAndDropSvc_SOURCES += \
     42    ../common/client.cpp \
     43    ../common/message.cpp
     44
    4145VBoxDragAndDropSvc_SOURCES.win = \
    4246        VBoxDragAndDropSvc.rc
  • trunk/src/VBox/HostServices/DragAndDrop/service.cpp

    r73939 r74205  
    55
    66/*
    7  * Copyright (C) 2011-2017 Oracle Corporation
     7 * Copyright (C) 2011-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5151public:
    5252
    53     DragAndDropClient(uint32_t uClientId, VBOXHGCMCALLHANDLE hHandle = NULL,
    54                       uint32_t uMsg = 0, uint32_t cParms = 0, VBOXHGCMSVCPARM aParms[] = NULL)
    55         : HGCM::Client(uClientId, hHandle, uMsg, cParms, aParms)
    56         , m_fDeferred(false)
     53    DragAndDropClient(uint32_t uClientID)
     54        : HGCM::Client(uClientID)
    5755    {
    5856        RT_ZERO(m_SvcCtx);
     
    6664public:
    6765
    68     void complete(VBOXHGCMCALLHANDLE hHandle, int rcOp);
    69     void completeDeferred(int rcOp);
    7066    void disconnect(void);
    71     bool isDeferred(void) const { return m_fDeferred; }
    72     void setDeferred(VBOXHGCMCALLHANDLE hHandle, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
    73     void setSvcContext(const HGCM::VBOXHGCMSVCTX &SvcCtx) { m_SvcCtx = SvcCtx; }
    74 
    75 protected:
    76 
    77     /** The HGCM service context this client is bound to. */
    78     HGCM::VBOXHGCMSVCTX m_SvcCtx;
    79     /** Flag indicating whether this client currently is deferred mode,
    80      *  meaning that it did not return to the caller yet. */
    81     bool                m_fDeferred;
    8267};
    8368
     
    137122
    138123/**
    139  * Completes the call by returning the control back to the guest
    140  * side code.
    141  */
    142 void DragAndDropClient::complete(VBOXHGCMCALLHANDLE hHandle, int rcOp)
    143 {
    144     LogFlowThisFunc(("uClientID=%RU32\n", m_uClientId));
    145 
    146     if (   m_SvcCtx.pHelpers
    147         && m_SvcCtx.pHelpers->pfnCallComplete)
    148     {
    149         m_SvcCtx.pHelpers->pfnCallComplete(hHandle, rcOp);
    150     }
    151 }
    152 
    153 /**
    154  * Completes a deferred call by returning the control back to the guest
    155  * side code.
    156  */
    157 void DragAndDropClient::completeDeferred(int rcOp)
    158 {
    159     AssertMsg(m_fDeferred, ("Client %RU32 is not in deferred mode\n", m_uClientId));
    160     Assert(m_hHandle != NULL);
    161 
    162     LogFlowThisFunc(("uClientID=%RU32\n", m_uClientId));
    163 
    164     complete(m_hHandle, rcOp);
    165     m_fDeferred = false;
    166 }
    167 
    168 /**
    169124 * Called when the HGCM client disconnected on the guest side.
    170125 * This function takes care of the client's data cleanup and also lets the host
     
    174129void DragAndDropClient::disconnect(void)
    175130{
    176     LogFlowThisFunc(("uClient=%RU32\n", m_uClientId));
    177 
    178     if (isDeferred())
    179         completeDeferred(VERR_INTERRUPTED);
     131    LogFlowThisFunc(("uClient=%RU32\n", m_uClientID));
     132
     133    if (IsDeferred())
     134        CompleteDeferred(VERR_INTERRUPTED);
    180135
    181136    /*
     
    191146        int rc2 = m_SvcCtx.pfnHostCallback(m_SvcCtx.pvHostData, GUEST_DND_DISCONNECT, &data, sizeof(data));
    192147        if (RT_FAILURE(rc2))
    193             LogFlowFunc(("Warning: Unable to notify host about client %RU32 disconnect, rc=%Rrc\n", m_uClientId, rc2));
     148            LogFlowFunc(("Warning: Unable to notify host about client %RU32 disconnect, rc=%Rrc\n", m_uClientID, rc2));
    194149        /* Not fatal. */
    195150    }
    196151}
    197 
    198 /**
    199  * Set the client's status to deferred, meaning that it does not return to the caller
    200  * on the guest side yet.
    201  */
    202 void DragAndDropClient::setDeferred(VBOXHGCMCALLHANDLE hHandle, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
    203 {
    204     LogFlowThisFunc(("uClient=%RU32\n", m_uClientId));
    205 
    206     AssertMsg(m_fDeferred == false, ("Client already in deferred mode\n"));
    207     m_fDeferred = true;
    208 
    209     m_hHandle = hHandle;
    210     m_uMsg    = u32Function;
    211     m_cParms  = cParms;
    212     m_paParms = paParms;
    213 }
    214 
    215152
    216153/*********************************************************************************************************************************
     
    288225        {
    289226            DragAndDropClient *pClient = new DragAndDropClient(u32ClientID);
    290             pClient->setSvcContext(m_SvcCtx);
     227            pClient->SetSvcContext(m_SvcCtx);
    291228            m_clientMap[u32ClientID] = pClient;
    292229        }
     
    553490                        rc = paParms[idxProto + 1].getUInt32(&data.uFlags);
    554491                    if (RT_SUCCESS(rc))
    555                         rc = pClient->SetProtocolVer(data.uProtocol);
     492                        pClient->SetProtocolVer(data.uProtocol);
    556493                    if (RT_SUCCESS(rc))
    557494                    {
     
    10881025        {
    10891026            AssertPtr(pClient);
    1090             pClient->setDeferred(callHandle, u32Function, cParms, paParms);
     1027            pClient->SetDeferred(callHandle, u32Function, cParms, paParms);
    10911028            m_clientQueue.push_back(u32ClientID);
    10921029        }
     
    10981035    }
    10991036    else if (pClient)
    1100         pClient->complete(callHandle, rc);
     1037        pClient->Complete(callHandle, rc);
    11011038    else
    11021039    {
     
    11631100                    AssertPtr(pClient);
    11641101
    1165                     int rc2 = pClient->addMessageInfo(HOST_DND_HG_EVT_CANCEL,
    1166                                                       /* Protocol v3+ also contains the context ID. */
    1167                                                       pClient->GetProtocolVer() >= 3 ? 1 : 0);
    1168                     pClient->completeDeferred(rc2);
     1102                    int rc2 = pClient->SetDeferredMsgInfo(HOST_DND_HG_EVT_CANCEL,
     1103                                                          /* Protocol v3+ also contains the context ID. */
     1104                                                          pClient->GetProtocolVer() >= 3 ? 1 : 0);
     1105                    pClient->CompleteDeferred(rc2);
    11691106
    11701107                    m_clientQueue.erase(itQueue);
     
    12461183                if (uMsgClient == GUEST_DND_GET_NEXT_HOST_MSG)
    12471184                {
    1248                     rc = pClient->addMessageInfo(uMsgNext, cParmsNext);
     1185                    rc = pClient->SetDeferredMsgInfo(uMsgNext, cParmsNext);
    12491186
    12501187                    /* Note: Report the current rc back to the guest. */
    1251                     pClient->completeDeferred(rc);
     1188                    pClient->CompleteDeferred(rc);
    12521189                }
    12531190                /*
     
    12601197
    12611198                    /* Note: Report the current rc back to the guest. */
    1262                     pClient->completeDeferred(rc);
     1199                    pClient->CompleteDeferred(rc);
    12631200                }
    12641201                else /* Should not happen; cancel the operation on the guest. */
     
    12671204                             pClient->GetClientID(), uMsgClient, uMsgNext));
    12681205
    1269                     pClient->completeDeferred(VERR_CANCELLED);
     1206                    pClient->CompleteDeferred(VERR_CANCELLED);
    12701207                }
    12711208
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