1
/*********************************************************
2
* Copyright (C) 2010 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation version 2.1 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11
* License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*********************************************************/
20
* @GuestDnDCPMgr.cc --
22
* Implementation of common layer GuestDnDCPMgr object.
25
#include "guestDnDCPMgr.hh"
27
# include "dndCPTransportVMCF.hh"
29
# include "dndCPTransportGuestRpc.hpp"
37
GuestDnDCPMgr *GuestDnDCPMgr::m_instance = NULL;
45
GuestDnDCPMgr::GuestDnDCPMgr()
51
mLocalCaps(0xffffffff)
60
GuestDnDCPMgr::~GuestDnDCPMgr(void)
62
g_debug("%s: enter\n", __FUNCTION__);
73
* Get an instance of GuestDnDCPMgr, which is an application singleton.
75
* @return a pointer to the singleton GuestDnDCPMgr object, or NULL if
76
* for some reason it could not be allocated.
80
GuestDnDCPMgr::GetInstance(void)
83
m_instance = new GuestDnDCPMgr;
90
* Destroy the GuestDnDCPMgr singleton.
94
GuestDnDCPMgr::Destroy(void)
104
* Initialize the GuestDnDCPMgr object. All owner should call this first before
105
* calling any other function.
107
* @param[in] ctx ToolsAppCtx
111
GuestDnDCPMgr::Init(ToolsAppCtx *ctx)
115
#if !defined(DND_USING_VMCF)
116
ASSERT(mToolsAppCtx);
120
delete mFileTransfer;
122
mFileTransfer = new GuestFileTransfer(GetTransport());
127
* Get the GuestDnDCPMgr object.
129
* @return a pointer to the GuestDnDCPMgr instance.
133
GuestDnDCPMgr::GetDnDMgr(void)
136
/* mEventQueue must be set before this call. */
137
mDnDMgr = new GuestDnDMgr(GetTransport(), mToolsAppCtx);
144
* Get the GuestCopyPasteMgr object.
146
* @return a pointer to the GuestCopyPasteMgr instance.
150
GuestDnDCPMgr::GetCopyPasteMgr(void)
153
mCPMgr = new GuestCopyPasteMgr(GetTransport());
160
* Get the DnDCPTransport object.
162
* XXX Implementation here is temporary and should be replaced with rpcChannel.
164
* @return a pointer to the manager's DnDCPTransport instance.
168
GuestDnDCPMgr::GetTransport(void)
171
ASSERT(mToolsAppCtx);
172
#ifdef DND_USING_VMCF
173
GKeyFile *confDictRef = NULL;
174
const char *brokerAddr = NULL;
176
confDictRef = mToolsAppCtx->config;
178
brokerAddr = g_key_file_get_string(confDictRef,
185
/* We are executing in the simulator, so hardcode the brokerAddr. */
186
brokerAddr = "tcp:host=127.0.0.1,port=8672,family=ipv4";
188
mTransport = new DnDCPTransportVMCF(brokerAddr, NULL, false);
190
mTransport = new DnDCPTransportGuestRpc(mToolsAppCtx->rpc);
198
* API for starting the transport main loop from python.
202
GuestDnDCPMgr::StartLoop()
204
(void) GetTransport();
206
mTransport->StartLoop();
212
* API for iterating the transport main loop from python.
216
GuestDnDCPMgr::IterateLoop()
218
(void) GetTransport();
220
mTransport->IterateLoop();
226
* API for ending the transport main loop from python.
230
GuestDnDCPMgr::EndLoop()
232
(void) GetTransport();
234
mTransport->EndLoop();