libdndcp_la_CPPFLAGS += @PLUGIN_CPPFLAGS@
libdndcp_la_CPPFLAGS += -I$(top_srcdir)/services/plugins/dndcp/dnd
libdndcp_la_CPPFLAGS += -I$(top_srcdir)/services/plugins/dndcp/dndGuest
+libdndcp_la_CPPFLAGS += -I$(top_srcdir)/services/plugins/dndcp/dndGuestBase
libdndcp_la_CPPFLAGS += -I$(top_srcdir)/services/plugins/dndcp/stringxx
libdndcp_la_CPPFLAGS += -I$(top_srcdir)/services/plugins/dndcp/xutils
libdndcp_la_CPPFLAGS += -I$(top_srcdir)/include
libdndcp_la_SOURCES += dnd/dndLinux.c
libdndcp_la_SOURCES += dnd/dndMsg.c
+libdndcp_la_SOURCES += dndGuestBase/copyPasteDnDWrapper.cpp
+libdndcp_la_SOURCES += dndGuestBase/dndFileList.cc
+libdndcp_la_SOURCES += dndGuestBase/dndRpcV3.cc
+libdndcp_la_SOURCES += dndGuestBase/guestDnDCPMgr.cc
+libdndcp_la_SOURCES += dndGuestBase/guestDnDDest.cc
+libdndcp_la_SOURCES += dndGuestBase/guestDnDSrc.cc
+libdndcp_la_SOURCES += dndGuestBase/guestDnDMgr.cc
+libdndcp_la_SOURCES += dndGuestBase/guestFileTransfer.cc
+
libdndcp_la_SOURCES += dndGuest/copyPasteRpcV3.cc
-libdndcp_la_SOURCES += dndGuest/dndFileList.cc
-libdndcp_la_SOURCES += dndGuest/dndRpcV3.cc
libdndcp_la_SOURCES += dndGuest/guestCopyPasteDest.cc
libdndcp_la_SOURCES += dndGuest/guestCopyPasteMgr.cc
libdndcp_la_SOURCES += dndGuest/guestCopyPasteSrc.cc
-libdndcp_la_SOURCES += dndGuest/guestDnDCPMgr.cc
-libdndcp_la_SOURCES += dndGuest/guestDnDDest.cc
-libdndcp_la_SOURCES += dndGuest/guestDnDMgr.cc
-libdndcp_la_SOURCES += dndGuest/guestDnDSrc.cc
-libdndcp_la_SOURCES += dndGuest/guestFileTransfer.cc
+libdndcp_la_SOURCES += dndGuest/vmGuestDnDCPMgr.cc
+libdndcp_la_SOURCES += dndGuest/vmGuestFileTransfer.cc
+libdndcp_la_SOURCES += dndGuest/vmGuestDnDSrc.cc
libdndcp_la_SOURCES += dndGuest/copyPasteRpcV4.cc
+libdndcp_la_SOURCES += dndGuest/vmGuestDnDMgr.cc
libdndcp_la_SOURCES += dndGuest/dndRpcV4.cc
libdndcp_la_SOURCES += dndGuest/fileTransferRpcV4.cc
libdndcp_la_SOURCES += dndGuest/rpcV3Util.cpp
libdndcp_la_SOURCES += copyPasteCompat.c
libdndcp_la_SOURCES += copyPasteCompatX11.c
-libdndcp_la_SOURCES += copyPasteDnDWrapper.cpp
+libdndcp_la_SOURCES += vmCopyPasteDnDWrapper.cpp
libdndcp_la_SOURCES += copyPasteDnDX11.cpp
libdndcp_la_SOURCES += copyPasteUIX11.cpp
libdndcp_la_SOURCES += dndUIX11.cpp
libdndcp_la_SOURCES += dnd/dndXdg.c
endif
+# DND_VM is used to distinguish the dnd feature between WS/FS and View
+libdndcp_la_CPPFLAGS += -DDND_VM
+
BUILT_SOURCES =
BUILT_SOURCES += cpFileContents.h
BUILT_SOURCES += cpFileContents_xdr.c
#include "copyPasteDnDWrapper.h"
#include "copyPasteDnDX11.h"
+#include "copyPasteUIX11.h"
#include "dndPluginIntX11.h"
#include "tracer.hh"
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @vmGuestDnDCPMgr.cc --
+ *
+ * The inherited implementation of common class GuestDnDCPMgr in VM side.
+ */
+
+#include "dndCPTransportGuestRpc.hpp"
+#include "vmGuestDnDCPMgr.hh"
+#include "vmGuestDnDMgr.hh"
+#include "vmGuestFileTransfer.hh"
+
+
+/**
+ *
+ * Destructor.
+ */
+
+VMGuestDnDCPMgr::~VMGuestDnDCPMgr()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ delete mDnDMgr;
+ mDnDMgr = NULL;
+ delete mFileTransfer;
+ mFileTransfer = NULL;
+ delete mTransport;
+ mTransport = NULL;
+}
+
+
+/**
+ * Initialize the VMGuestDnDCPMgr object. All owner should call this first before
+ * calling any other function.
+ *
+ * @param[in] ctx ToolsAppCtx
+ */
+
+void
+VMGuestDnDCPMgr::Init(ToolsAppCtx *ctx)
+{
+ mToolsAppCtx = ctx;
+
+ ASSERT(mToolsAppCtx);
+
+ if (mFileTransfer) {
+ delete mFileTransfer;
+ }
+ mFileTransfer = new VMGuestFileTransfer(GetTransport());
+}
+
+
+/**
+ * Get the DnDCPTransport object.
+ *
+ * XXX Implementation here is temporary and should be replaced with rpcChannel.
+ *
+ * @return a pointer to the manager's DnDCPTransport instance.
+ */
+
+DnDCPTransport *
+VMGuestDnDCPMgr::GetTransport(void)
+{
+ if (!mTransport) {
+ ASSERT(mToolsAppCtx);
+ mTransport = new DnDCPTransportGuestRpc(mToolsAppCtx->rpc);
+ }
+ return mTransport;
+}
+
+
+/**
+ * Get the GuestDnDMgr object.
+ *
+ * @return a pointer to the GuestDnDMgr instance.
+ */
+
+GuestDnDMgr *
+VMGuestDnDCPMgr::GetDnDMgr(void)
+{
+ if (!mDnDMgr) {
+ /* mEventQueue must be set before this call. */
+ mDnDMgr = new VMGuestDnDMgr(GetTransport(), mToolsAppCtx);
+ }
+ return mDnDMgr;
+}
+
+
+/**
+ * Create an instance of class VMGuestDnDCPMgr.
+ *
+ * @return a pointer to the VMGuestDnDCPMgr instance.
+ */
+
+VMGuestDnDCPMgr *
+VMGuestDnDCPMgr::CreateInstance(void)
+{
+ return new VMGuestDnDCPMgr();
+}
+
+
+/**
+ * Get the GuestCopyPasteMgr object.
+ *
+ * @return a pointer to the GuestCopyPasteMgr instance.
+ */
+
+GuestCopyPasteMgr *
+VMGuestDnDCPMgr::GetCopyPasteMgr(void)
+{
+ if (!mCPMgr) {
+ mCPMgr = new GuestCopyPasteMgr(GetTransport());
+ }
+ return mCPMgr;
+}
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @vmGuestDnDCPMgr.hh --
+ *
+ * The inherited implementation of common class GuestDnDCPMgr in VM side.
+ */
+
+#ifndef VM_GUEST_DND_CP_MGR_HH
+#define VM_GUEST_DND_CP_MGR_HH
+
+#include "guestDnDCPMgr.hh"
+
+extern "C" {
+ #include "vmware/tools/guestrpc.h"
+ #include "vmware/tools/plugin.h"
+}
+
+class VMGuestDnDCPMgr
+ : public GuestDnDCPMgr
+{
+public:
+ virtual ~VMGuestDnDCPMgr();
+ void Init(ToolsAppCtx *ctx);
+ virtual GuestDnDMgr *GetDnDMgr(void);
+ virtual DnDCPTransport *GetTransport(void);
+ virtual GuestCopyPasteMgr *GetCopyPasteMgr(void);
+
+ static VMGuestDnDCPMgr *CreateInstance(void);
+
+private:
+ VMGuestDnDCPMgr(void) : GuestDnDCPMgr() { }
+ VMGuestDnDCPMgr(const VMGuestDnDCPMgr &mgr);
+ VMGuestDnDCPMgr& operator=(const VMGuestDnDCPMgr &mgr);
+
+private:
+ ToolsAppCtx *mToolsAppCtx;
+};
+
+#endif // VM_GUEST_DND_CP_MGR_HH
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @vmGuestDnDMgr.cc --
+ *
+ * The inherited implementation of common class GuestDnDMgr in VM side.
+ */
+
+#include "dndRpcV3.hh"
+#include "dndRpcV4.hh"
+#include "tracer.hh"
+#include "vmGuestDnDMgr.hh"
+
+extern "C" {
+#include "debug.h"
+}
+
+
+/**
+ * Constructor.
+ *
+ * @param[in] transport for sending/receiving packets.
+ * @param[in] ctx ToolsAppCtx
+ */
+
+VMGuestDnDMgr::VMGuestDnDMgr(DnDCPTransport *transport,
+ ToolsAppCtx *ctx)
+ : GuestDnDMgr(transport, ctx),
+ mToolsAppCtx(ctx)
+{
+ ASSERT(mToolsAppCtx);
+}
+
+
+/**
+ * Add DnD un-grab timeout event.
+ */
+
+void
+VMGuestDnDMgr::AddDnDUngrabTimeoutEvent()
+{
+ if (NULL == mUngrabTimeout) {
+ g_debug("%s: adding UngrabTimeout\n", __FUNCTION__);
+ mUngrabTimeout = g_timeout_source_new(UNGRAB_TIMEOUT);
+ VMTOOLSAPP_ATTACH_SOURCE(mToolsAppCtx, mUngrabTimeout,
+ GuestDnDMgr::DnDUngrabTimeout, this, NULL);
+ g_source_unref(mUngrabTimeout);
+ }
+}
+
+
+/**
+ * Add Unity DnD detect timeout event.
+ */
+
+void
+VMGuestDnDMgr::AddUnityDnDDetTimeoutEvent()
+{
+ mUnityDnDDetTimeout = g_timeout_source_new(UNITY_DND_DET_TIMEOUT);
+ VMTOOLSAPP_ATTACH_SOURCE(mToolsAppCtx,
+ mUnityDnDDetTimeout,
+ GuestDnDMgr::DnDUnityDetTimeout,
+ this,
+ NULL);
+ g_source_unref(mUnityDnDDetTimeout);
+}
+
+
+/**
+ * Add hide detect window timer.
+ */
+
+void
+VMGuestDnDMgr::AddHideDetWndTimerEvent()
+{
+ if (NULL == mHideDetWndTimer) {
+ g_debug("%s: add timer to hide detection window.\n", __FUNCTION__);
+ mHideDetWndTimer = g_timeout_source_new(HIDE_DET_WND_TIMER);
+ VMTOOLSAPP_ATTACH_SOURCE(mToolsAppCtx, mHideDetWndTimer,
+ GuestDnDMgr::DnDHideDetWndTimer, this, NULL);
+ g_source_unref(mHideDetWndTimer);
+ } else {
+ g_debug("%s: mHideDetWndTimer is not NULL, quit.\n", __FUNCTION__);
+ }
+}
+
+
+/**
+ * Create DnD rpc with input version.
+ *
+ * @param[in] version input version number
+ */
+
+void
+VMGuestDnDMgr::CreateDnDRpcWithVersion(uint32 version)
+{
+ switch(version) {
+ case 4:
+ mRpc = new DnDRpcV4(mDnDTransport);
+ break;
+ case 3:
+ mRpc = new DnDRpcV3(mDnDTransport);
+ break;
+ default:
+ g_debug("%s: unsupported DnD version\n", __FUNCTION__);
+ break;
+ }
+}
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @vmGuestDnDMgr.hh --
+ *
+ * The inherited implementation of common class GuestDnDMgr in VM side.
+ */
+
+#ifndef VM_GUEST_DND_MGR_HH
+#define VM_GUEST_DND_MGR_HH
+
+#include "guestDnD.hh"
+
+extern "C" {
+ #include "vmware/tools/plugin.h"
+}
+
+class VMGuestDnDMgr
+ : public GuestDnDMgr
+{
+public:
+ VMGuestDnDMgr(DnDCPTransport *transport,
+ ToolsAppCtx *ctx);
+
+protected:
+ virtual void AddDnDUngrabTimeoutEvent();
+ virtual void AddUnityDnDDetTimeoutEvent();
+ virtual void AddHideDetWndTimerEvent();
+ virtual void CreateDnDRpcWithVersion(uint32 version);
+
+private:
+ ToolsAppCtx *mToolsAppCtx;
+};
+
+#endif // VM_GUEST_DND_MGR_HH
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @vmGuestDnDSrc.cc --
+ *
+ * The inherited implementation of common class GuestDnDSrc in VM side.
+ */
+
+#include "util.h"
+#include "vmGuestDnDSrc.hh"
+
+#include "file.h"
+#include "str.h"
+
+
+/**
+ * Constructor.
+ *
+ * @param[in] mgr guest DnD manager
+ */
+
+VMGuestDnDSrc::VMGuestDnDSrc(GuestDnDMgr *mgr)
+ : GuestDnDSrc(mgr)
+{
+}
+
+
+/**
+ * Creates a directory for file transfer. If the destination dir is provided,
+ * we will attempt to copy files to that directory.
+ *
+ * @param[in] destDir the preferred destination directory
+ *
+ * @return the destination directory on success, an empty string on failure.
+ */
+
+const std::string&
+VMGuestDnDSrc::SetupDestDir(const std::string &destDir)
+{
+ mStagingDir = "";
+
+ if (!destDir.empty() && File_Exists(destDir.c_str())) {
+ mStagingDir = destDir;
+ const char *lastSep = Str_Strrchr(mStagingDir.c_str(), DIRSEPC);
+ if (lastSep && lastSep[1] != '\0') {
+ mStagingDir += DIRSEPS;
+ }
+
+ return mStagingDir;
+ } else {
+ char *newDir;
+
+ newDir = DnD_CreateStagingDirectory();
+ if (newDir != NULL) {
+ mStagingDir = newDir;
+
+ char *lastSep = Str_Strrchr(newDir, DIRSEPC);
+ if (lastSep && lastSep[1] != '\0') {
+ mStagingDir += DIRSEPS;
+ }
+ free(newDir);
+ g_debug("%s: destination dir is: %s", __FUNCTION__, mStagingDir.c_str());
+
+ return mStagingDir;
+ } else {
+ g_debug("%s: destination dir is not created", __FUNCTION__);
+ return mStagingDir;
+ }
+ }
+}
+
+
+/**
+ * Clean the staging files.
+ *
+ * @param[in] fileTransferResult the file transfer result
+ */
+
+void
+VMGuestDnDSrc::CleanStagingFiles(bool fileTransferResult)
+{
+ if (!fileTransferResult && !mStagingDir.empty()) {
+ /* Delete all files if host canceled the file transfer. */
+ DnD_DeleteStagingFiles(mStagingDir.c_str(), FALSE);
+ mStagingDir.clear();
+ }
+}
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @vmGuestDnDSrc.hh --
+ *
+ * The inherited implementation of common class GuestDnDSrc in VM side.
+ */
+
+#ifndef VM_GUEST_DND_SRC_HH
+#define VM_GUEST_DND_SRC_HH
+
+#include "guestDnD.hh"
+
+class VMGuestDnDSrc
+ : public GuestDnDSrc
+{
+public:
+ VMGuestDnDSrc(GuestDnDMgr *mgr);
+
+protected:
+ virtual const std::string& SetupDestDir(const std::string &destDir);
+ virtual void CleanStagingFiles(bool fileTransferResult);
+};
+
+#endif // VM_GUEST_DND_SRC_HH
/*********************************************************
- * Copyright (C) 2010-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
*********************************************************/
/**
- * @guestFileTransfer.cc --
+ * @vmGuestFileTransfer.cc --
*
- * Implementation of common layer file transfer object for guest.
+ * VM side implementation of file transfer object for guest.
*/
-#include "guestFileTransfer.hh"
#include "fileTransferRpcV4.hh"
+#include "vmGuestFileTransfer.hh"
extern "C" {
#include "debug.h"
* @param[in] transport pointer to a transport object.
*/
-GuestFileTransfer::GuestFileTransfer(DnDCPTransport *transport)
+VMGuestFileTransfer::VMGuestFileTransfer(DnDCPTransport *transport)
+ : GuestFileTransfer(transport)
{
ASSERT(transport);
mRpc = new FileTransferRpcV4(transport);
mRpc->Init();
mRpc->HgfsPacketReceived.connect(
- sigc::mem_fun(this, &GuestFileTransfer::OnRpcRecvHgfsPacket));
+ sigc::mem_fun(this, &VMGuestFileTransfer::OnRpcRecvHgfsPacket));
HgfsServerManager_DataInit(&mHgfsServerMgrData,
"DnDGuestHgfsMgr",
NULL,
/**
* Destructor.
*/
-GuestFileTransfer::~GuestFileTransfer(void)
+VMGuestFileTransfer::~VMGuestFileTransfer(void)
{
- delete mRpc;
- mRpc = NULL;
HgfsServerManager_Unregister(&mHgfsServerMgrData);
+
+ if (NULL != mRpc) {
+ delete mRpc;
+ mRpc = NULL;
+ }
}
*/
void
-GuestFileTransfer::OnRpcRecvHgfsPacket(uint32 sessionId,
- const uint8 *packet,
- size_t packetSize)
+VMGuestFileTransfer::OnRpcRecvHgfsPacket(uint32 sessionId,
+ const uint8 *packet,
+ size_t packetSize)
{
char replyPacket[HGFS_LARGE_PACKET_MAX];
size_t replyPacketSize;
&replyPacketSize);
mRpc->SendHgfsReply(sessionId, (const uint8 *)replyPacket, replyPacketSize);
}
-
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @vmGuestFileTransfer.hh --
+ *
+ * VM side implementation of file transfer object for guest.
+ */
+
+#ifndef VM_GUEST_FILE_TRANSFER_HH
+#define VM_GUEST_FILE_TRANSFER_HH
+
+#include <sigc++/trackable.h>
+#include "fileTransferRpc.hh"
+#include "dndCPTransport.h"
+#include "guestFileTransfer.hh"
+extern "C" {
+#include "hgfsServerManager.h"
+}
+
+class VMGuestFileTransfer
+ : public GuestFileTransfer
+{
+public:
+ VMGuestFileTransfer(DnDCPTransport *transport);
+ ~VMGuestFileTransfer(void);
+
+private:
+ void OnRpcRecvHgfsPacket(uint32 sessionId,
+ const uint8 *packet,
+ size_t packetSize);
+
+ HgfsServerMgrData mHgfsServerMgrData;
+};
+
+#endif // VM_GUEST_FILE_TRANSFER_HH
/*********************************************************
- * Copyright (C) 2010-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#define __COPYPASTEDNDIMPL_H__
#include "vmware.h"
+#include "vm_basic_types.h"
extern "C" {
#include "vmware/tools/plugin.h"
}
+typedef struct ToolsAppCtx ToolsAppCtx;
class CopyPasteDnDImpl
{
public:
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @file copyPasteDnDWrapper.cpp
+ *
+ * This singleton class implements a wrapper around various versions of
+ * copy and paste and dnd protocols, and provides some convenience functions
+ * that help to make VMwareUser a bit cleaner.
+ */
+
+#define G_LOG_DOMAIN "dndcp"
+
+#if defined(HAVE_GTKMM)
+#include "copyPasteDnDX11.h"
+#endif
+
+#if defined(WIN32)
+#include "copyPasteDnDWin32.h"
+#ifdef DND_VM
+#include "vmCopyPasteDnDWin32.h"
+#else
+#include "crtCopyPasteDnDWin32.h"
+#endif
+#endif
+
+#if defined(__APPLE__)
+#include "copyPasteDnDMac.h"
+#endif
+
+#ifdef DND_VM
+#include "vmCopyPasteDnDWrapper.h"
+#else
+#include "crtCopyPasteDnDWrapper.h"
+#endif
+
+#include "copyPasteDnDWrapper.h"
+#include "guestDnDCPMgr.hh"
+#include "vmware.h"
+
+
+/**
+ * CopyPasteDnDWrapper is a singleton, here is a pointer to its only instance.
+ */
+
+CopyPasteDnDWrapper *CopyPasteDnDWrapper::m_instance = NULL;
+
+/**
+ *
+ * Get an instance of CopyPasteDnDWrapper, which is an application singleton.
+ *
+ * @return a pointer to the singleton CopyPasteDnDWrapper object, or NULL if
+ * for some reason it could not be allocated.
+ */
+
+CopyPasteDnDWrapper *
+CopyPasteDnDWrapper::GetInstance()
+{
+ if (!m_instance) {
+#ifdef DND_VM
+ m_instance = VMCopyPasteDnDWrapper::CreateInstance();
+#else
+ m_instance = CRTCopyPasteDnDWrapper::CreateInstance();
+#endif
+ }
+ ASSERT(m_instance);
+ return m_instance;
+}
+
+
+/**
+ *
+ * Destroy the singleton object.
+ */
+
+void
+CopyPasteDnDWrapper::Destroy()
+{
+ if (m_instance) {
+ g_debug("%s: destroying self\n", __FUNCTION__);
+ delete m_instance;
+ m_instance = NULL;
+ }
+}
+
+
+/**
+ *
+ * Constructor.
+ */
+
+CopyPasteDnDWrapper::CopyPasteDnDWrapper() :
+ m_isCPEnabled(FALSE),
+ m_isDnDEnabled(FALSE),
+ m_isCPRegistered(FALSE),
+ m_isDnDRegistered(FALSE),
+ m_cpVersion(0),
+ m_dndVersion(0),
+ m_pimpl(NULL)
+{
+}
+
+
+/**
+ *
+ * Call the implementation class pointer/grab initialization code. See
+ * the implementation code for further details.
+ */
+
+void
+CopyPasteDnDWrapper::PointerInit()
+{
+ ASSERT(m_pimpl);
+
+ m_pimpl->PointerInit();
+}
+
+
+/**
+ *
+ * Initialize the wrapper by instantiating the platform specific impl
+ * class. Effectively, this function is a factory that produces a
+ * platform implementation of the DnD/Copy Paste UI layer.
+ *
+ * @param[in] ctx tools app context.
+ */
+
+void
+CopyPasteDnDWrapper::Init(ToolsAppCtx *ctx)
+{
+ GuestDnDCPMgr *p = GuestDnDCPMgr::GetInstance();
+ ASSERT(p);
+ p->Init(ctx);
+
+ if (!m_pimpl) {
+#if defined(HAVE_GTKMM)
+ m_pimpl = new CopyPasteDnDX11();
+#endif
+#if defined(WIN32)
+#ifdef DND_VM
+ m_pimpl = new VMCopyPasteDnDWin32();
+#else
+ m_pimpl = new CRTCopyPasteDnDWin32();
+#endif
+#endif
+#if defined(__APPLE__)
+ m_pimpl = new CopyPasteDnDMac();
+#endif
+
+ if (m_pimpl) {
+ m_pimpl->Init(ctx);
+ /*
+ * Tell the Guest DnD Manager what capabilities we support.
+ */
+ p->SetCaps(m_pimpl->GetCaps());
+ }
+ }
+}
+
+
+/**
+ *
+ * Destructor.
+ */
+
+CopyPasteDnDWrapper::~CopyPasteDnDWrapper()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ if (m_pimpl) {
+ if (IsCPRegistered()) {
+ m_pimpl->UnregisterCP();
+ }
+ if (IsDnDRegistered()) {
+ m_pimpl->UnregisterDnD();
+ }
+ delete m_pimpl;
+ }
+ GuestDnDCPMgr::Destroy();
+}
+
+
+/**
+ *
+ * Register copy and paste capabilities with the VMX. Try newest version
+ * first, then fall back to the legacy implementation.
+ *
+ * @return TRUE on success, FALSE on failure
+ */
+
+gboolean
+CopyPasteDnDWrapper::RegisterCP()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ ASSERT(m_pimpl);
+ if (IsCPEnabled()) {
+ return m_pimpl->RegisterCP();
+ }
+ return false;
+}
+
+
+/**
+ *
+ * Register DnD capabilities with the VMX. Handled by the platform layer.
+ *
+ * @return TRUE on success, FALSE on failure
+ */
+
+gboolean
+CopyPasteDnDWrapper::RegisterDnD()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ ASSERT(m_pimpl);
+ if (IsDnDEnabled()) {
+ return m_pimpl->RegisterDnD();
+ }
+ return false;
+}
+
+
+/**
+ *
+ * Unregister copy paste capabilities. Handled by platform layer.
+ */
+
+void
+CopyPasteDnDWrapper::UnregisterCP()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ ASSERT(m_pimpl);
+ return m_pimpl->UnregisterCP();
+}
+
+
+/**
+ *
+ * Unregister DnD capabilities. Handled by platform layer.
+ */
+
+void
+CopyPasteDnDWrapper::UnregisterDnD()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ ASSERT(m_pimpl);
+ return m_pimpl->UnregisterDnD();
+}
+
+
+/**
+ *
+ * Get the version of the copy paste protocol being wrapped.
+ *
+ * @return copy paste protocol version.
+ */
+
+int
+CopyPasteDnDWrapper::GetCPVersion()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ return m_cpVersion;
+}
+
+
+/**
+ *
+ * Get the version of the DnD protocol being wrapped.
+ *
+ * @return DnD protocol version.
+ */
+
+int
+CopyPasteDnDWrapper::GetDnDVersion()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ return m_dndVersion;
+}
+
+
+/**
+ *
+ * Set a flag indicating that we are wrapping an initialized and registered
+ * copy paste implementation, or not.
+ *
+ * @param[in] isRegistered If TRUE, protocol is registered, otherwise FALSE.
+ */
+
+void
+CopyPasteDnDWrapper::SetCPIsRegistered(gboolean isRegistered)
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ m_isCPRegistered = isRegistered;
+}
+
+
+/**
+ *
+ * Get the flag indicating that we are wrapping an initialized and registered
+ * copy paste implementation, or not.
+ *
+ * @return TRUE if copy paste is initialized, otherwise FALSE.
+ */
+
+gboolean
+CopyPasteDnDWrapper::IsCPRegistered()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ return m_isCPRegistered;
+}
+
+
+/**
+ *
+ * Set a flag indicating that we are wrapping an initialized and registered
+ * DnD implementation, or not.
+ *
+ * @param[in] isRegistered If TRUE, protocol is registered, otherwise FALSE.
+ */
+
+void
+CopyPasteDnDWrapper::SetDnDIsRegistered(gboolean isRegistered)
+{
+ m_isDnDRegistered = isRegistered;
+}
+
+
+/**
+ *
+ * Get the flag indicating that we are wrapping an initialized and registered
+ * DnD implementation, or not.
+ *
+ * @return TRUE if DnD is initialized, otherwise FALSE.
+ */
+
+gboolean
+CopyPasteDnDWrapper::IsDnDRegistered()
+{
+ return m_isDnDRegistered;
+}
+
+
+/**
+ *
+ * Set a flag indicating that copy paste is enabled, or not. This is called
+ * in response to SetOption RPC being received.
+ *
+ * @param[in] isEnabled If TRUE, copy paste is enabled, otherwise FALSE.
+ */
+
+void
+CopyPasteDnDWrapper::SetCPIsEnabled(gboolean isEnabled)
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ m_isCPEnabled = isEnabled;
+ if (!isEnabled && IsCPRegistered()) {
+ UnregisterCP();
+ } else if (isEnabled && !IsCPRegistered()) {
+ RegisterCP();
+ }
+}
+
+
+/**
+ *
+ * Get the flag indicating that copy paste was enabled (via SetOption RPC).
+ *
+ * @return TRUE if copy paste is enabled, otherwise FALSE.
+ */
+
+gboolean
+CopyPasteDnDWrapper::IsCPEnabled()
+{
+ return m_isCPEnabled;
+}
+
+
+/**
+ *
+ * Set a flag indicating that DnD is enabled, or not. This is called
+ * in response to SetOption RPC being received.
+ *
+ * @param[in] isEnabled If TRUE, DnD is enabled, otherwise FALSE.
+ */
+
+void
+CopyPasteDnDWrapper::SetDnDIsEnabled(gboolean isEnabled)
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ m_isDnDEnabled = isEnabled;
+ if (!isEnabled && IsDnDRegistered()) {
+ UnregisterDnD();
+ } else if (isEnabled && !IsDnDRegistered()) {
+ RegisterDnD();
+ }
+}
+
+
+/**
+ *
+ * Get the flag indicating that DnD was enabled (via SetOption) or not.
+ *
+ * @return TRUE if DnD is enabled, otherwise FALSE.
+ */
+
+gboolean
+CopyPasteDnDWrapper::IsDnDEnabled()
+{
+ return m_isDnDEnabled;
+}
+
+
+/**
+ *
+ * Handle reset.
+ */
+
+void
+CopyPasteDnDWrapper::OnResetInternal()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+}
+
+
+/**
+ *
+ * Handle reset.
+ *
+ * Schedule the post-reset actions to happen a little after one cycle of the
+ * RpcIn loop. This will give vmware a chance to receive the ATR
+ * reinitialize the channel if appropriate.
+ */
+
+void
+CopyPasteDnDWrapper::OnReset()
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ AddDnDPluginResetTimer();
+}
+
+
+/**
+ *
+ * Handle cap reg. This is cross-platform so handle here instead of the
+ * platform implementation.
+ */
+
+void
+CopyPasteDnDWrapper::OnCapReg(gboolean set)
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+}
+
+
+/**
+ *
+ * Handle SetOption
+ */
+
+gboolean
+CopyPasteDnDWrapper::OnSetOption(const char *option, const char *value)
+{
+ g_debug("%s: enter.\n", __FUNCTION__);
+ return TRUE;
+}
+
+
+/**
+ * Get capabilities by calling platform implementation.
+ *
+ * @return 32-bit mask of DnD/CP capabilities.
+ */
+
+uint32
+CopyPasteDnDWrapper::GetCaps()
+{
+ ASSERT(m_pimpl);
+
+ g_debug("%s: enter.\n", __FUNCTION__);
+ return m_pimpl->GetCaps();
+}
/*********************************************************
- * Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
class CopyPasteDnDWrapper
{
public:
- ~CopyPasteDnDWrapper();
+ virtual ~CopyPasteDnDWrapper();
static CopyPasteDnDWrapper *GetInstance();
static void Destroy();
gboolean RegisterCP();
gboolean RegisterDnD();
void UnregisterDnD();
void SetDnDVersion(int version) {m_dndVersion = version;};
- int GetDnDVersion();
+ virtual int GetDnDVersion();
void SetCPVersion(int version) {m_cpVersion = version;};
- int GetCPVersion();
+ virtual int GetCPVersion();
void SetCPIsRegistered(gboolean isRegistered);
gboolean IsCPRegistered();
void SetDnDIsRegistered(gboolean isRegistered);
void SetCPIsEnabled(gboolean isEnabled);
gboolean IsCPEnabled();
void OnReset();
- void OnResetInternal();
- void OnCapReg(gboolean set);
- gboolean OnSetOption(const char *option, const char *value);
- void Init(ToolsAppCtx *ctx);
+ virtual void OnResetInternal();
+ virtual void OnCapReg(gboolean set);
+ virtual gboolean OnSetOption(const char *option, const char *value);
+ virtual void Init(ToolsAppCtx *ctx);
void PointerInit(void);
- ToolsAppCtx *GetToolsAppCtx() {return m_ctx;};
+ virtual ToolsAppCtx *GetToolsAppCtx() {return NULL;};
uint32 GetCaps();
-private:
+
+protected:
/*
* We're a singleton, so it is a compile time error to call these.
*/
CopyPasteDnDWrapper();
CopyPasteDnDWrapper(const CopyPasteDnDWrapper &wrapper);
CopyPasteDnDWrapper& operator=(const CopyPasteDnDWrapper &wrapper);
-private:
+
+protected:
+ virtual void AddDnDPluginResetTimer(void) { }
+
+protected:
gboolean m_isCPEnabled;
gboolean m_isDnDEnabled;
gboolean m_isCPRegistered;
int m_cpVersion;
int m_dndVersion;
static CopyPasteDnDWrapper *m_instance;
- ToolsAppCtx *m_ctx;
CopyPasteDnDImpl *m_pimpl;
};
/*********************************************************
- * Copyright (C) 2010-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#define __COPYPASTEDNDX11_H__
#include "dnd.h" /* for DnDBlockControl */
-#include "copyPasteUIX11.h"
#include "dndUIX11.h"
#include <gtk/gtk.h>
#include "vm_basic_types.h"
void CopyPasteDnDWrapper_SetUnityMode(Bool mode);
}
+class CopyPasteUIX11;
+
class CopyPasteDnDX11 : public CopyPasteDnDImpl
{
public:
/*********************************************************
- * Copyright (C) 2010-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#include "vmware/tools/plugin.h"
}
+#define UNGRAB_TIMEOUT 500 // 0.5s
+#define HIDE_DET_WND_TIMER 500 // 0.5s
+#define UNITY_DND_DET_TIMEOUT 500 // 0.5s
+
enum GUEST_DND_STATE {
GUEST_DND_INVALID = 0,
GUEST_DND_READY,
public:
GuestDnDMgr(DnDCPTransport *transport,
ToolsAppCtx *ctx);
- ~GuestDnDMgr(void);
+ virtual ~GuestDnDMgr(void);
sigc::signal<void, int, int> moveMouseChanged;
sigc::signal<void, bool, int, int> updateDetWndChanged;
void VmxDnDVersionChanged(uint32 version);
bool IsDragEnterAllowed(void);
Bool CheckCapability(uint32 capsRequest);
-private:
+
+ static gboolean DnDUngrabTimeout(void *clientData);
+ static gboolean DnDHideDetWndTimer(void *clientData);
+ static gboolean DnDUnityDetTimeout(void *clientData);
+
+protected:
void OnRpcSrcDragBegin(uint32 sessionId,
const CPClipboard *clip);
void OnRpcQueryExiting(uint32 sessionId, int32 x, int32 y);
int32 y);
void OnPingReply(uint32 capabilities);
+ virtual void AddDnDUngrabTimeoutEvent() = 0;
+ virtual void AddUnityDnDDetTimeoutEvent() = 0;
+ virtual void AddHideDetWndTimerEvent() = 0;
+ virtual void CreateDnDRpcWithVersion(uint32 version) = 0;
+
GuestDnDSrc *mSrc;
GuestDnDDest *mDest;
DnDRpc *mRpc;
GSource *mHideDetWndTimer;
GSource *mUnityDnDDetTimeout;
GSource *mUngrabTimeout;
- ToolsAppCtx *mToolsAppCtx;
bool mDnDAllowed;
DnDCPTransport *mDnDTransport;
uint32 mCapabilities;
{
public:
GuestDnDSrc(GuestDnDMgr *mgr);
- ~GuestDnDSrc(void);
+ virtual ~GuestDnDSrc(void);
/* Common DnD layer API exposed to UI (all platforms) for DnD source. */
void UIDragBeginDone(void);
void UIUpdateFeedback(DND_DROPEFFECT feedback);
void OnRpcDragBegin(const CPClipboard *clip);
-private:
+protected:
/* Callbacks from rpc for DnD source. */
void OnRpcUpdateMouse(uint32 sessionId, int32 x, int32 y);
void OnRpcDrop(uint32 sessionId, int32 x, int32 y);
bool success,
const uint8 *stagingDirCP,
uint32 sz);
- const std::string& SetupDestDir(const std::string &destDir);
+ virtual const std::string& SetupDestDir(const std::string &destDir);
+ virtual void CleanStagingFiles(bool fileTransferResult) { }
GuestDnDMgr *mMgr;
DnDRpc *mRpc;
/*********************************************************
- * Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
*/
#include "guestDnDCPMgr.hh"
-#include "dndCPTransportGuestRpc.hpp"
+
+// The MACRO DND_VM is only used for WS/FS
+#ifdef DND_VM
+#include "vmGuestDnDCPMgr.hh"
+#else
+#include "crtGuestDnDCPMgr.hh"
+#endif
extern "C" {
#include "debug.h"
mCPMgr(NULL),
mFileTransfer(NULL),
mTransport(NULL),
- mToolsAppCtx(NULL),
mLocalCaps(0xffffffff)
{
}
GuestDnDCPMgr::~GuestDnDCPMgr(void)
{
g_debug("%s: enter\n", __FUNCTION__);
- delete mDnDMgr;
- mDnDMgr = NULL;
- delete mFileTransfer;
- mFileTransfer = NULL;
- delete mTransport;
- mTransport = NULL;
}
GuestDnDCPMgr::GetInstance(void)
{
if (!m_instance) {
- m_instance = new GuestDnDCPMgr;
+#ifdef DND_VM
+ m_instance = VMGuestDnDCPMgr::CreateInstance();
+#else
+ m_instance = CRTGuestDnDCPMgr::CreateInstance();
+#endif
}
return m_instance;
}
}
-/**
- * Initialize the GuestDnDCPMgr object. All owner should call this first before
- * calling any other function.
- *
- * @param[in] ctx ToolsAppCtx
- */
-
-void
-GuestDnDCPMgr::Init(ToolsAppCtx *ctx)
-{
- mToolsAppCtx = ctx;
-
- ASSERT(mToolsAppCtx);
-
- if (mFileTransfer) {
- delete mFileTransfer;
- }
- mFileTransfer = new GuestFileTransfer(GetTransport());
-}
-
-
-/**
- * Get the GuestDnDCPMgr object.
- *
- * @return a pointer to the GuestDnDCPMgr instance.
- */
-
-GuestDnDMgr *
-GuestDnDCPMgr::GetDnDMgr(void)
-{
- if (!mDnDMgr) {
- /* mEventQueue must be set before this call. */
- mDnDMgr = new GuestDnDMgr(GetTransport(), mToolsAppCtx);
- }
- return mDnDMgr;
-}
-
-
-/**
- * Get the GuestCopyPasteMgr object.
- *
- * @return a pointer to the GuestCopyPasteMgr instance.
- */
-
-GuestCopyPasteMgr *
-GuestDnDCPMgr::GetCopyPasteMgr(void)
-{
- if (!mCPMgr) {
- mCPMgr = new GuestCopyPasteMgr(GetTransport());
- }
- return mCPMgr;
-}
-
-
-/**
- * Get the DnDCPTransport object.
- *
- * XXX Implementation here is temporary and should be replaced with rpcChannel.
- *
- * @return a pointer to the manager's DnDCPTransport instance.
- */
-
-DnDCPTransport *
-GuestDnDCPMgr::GetTransport(void)
-{
- if (!mTransport) {
- ASSERT(mToolsAppCtx);
- mTransport = new DnDCPTransportGuestRpc(mToolsAppCtx->rpc);
- }
- return mTransport;
-}
-
-
/**
* API for starting the transport main loop from python.
*/
/*********************************************************
- * Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#include "guestCopyPaste.hh"
#include "guestFileTransfer.hh"
-extern "C" {
- #include "vmware/tools/guestrpc.h"
- #include "vmware/tools/plugin.h"
-}
-
struct DblLnkLst_Links;
+struct ToolsAppCtx;
class GuestDnDCPMgr
{
public:
- ~GuestDnDCPMgr();
- static GuestDnDCPMgr *GetInstance();
+ virtual ~GuestDnDCPMgr();
+ static GuestDnDCPMgr *GetInstance(void);
static void Destroy();
- GuestDnDMgr *GetDnDMgr(void);
- GuestCopyPasteMgr *GetCopyPasteMgr(void);
- DnDCPTransport *GetTransport(void);
+ virtual GuestDnDMgr *GetDnDMgr(void) { return NULL; }
+ virtual GuestCopyPasteMgr *GetCopyPasteMgr(void) { return NULL; }
+ virtual DnDCPTransport *GetTransport(void) { return NULL; }
void StartLoop();
void EndLoop();
void IterateLoop();
- void Init(ToolsAppCtx *ctx);
+ virtual void Init(ToolsAppCtx *ctx) { }
void SetCaps(uint32 caps) {mLocalCaps = caps;};
uint32 GetCaps() {return mLocalCaps;};
-private:
+
+protected:
/* We're a singleton, so it is a compile time error to call these. */
GuestDnDCPMgr(void);
GuestDnDCPMgr(const GuestDnDCPMgr &mgr);
GuestCopyPasteMgr *mCPMgr;
GuestFileTransfer *mFileTransfer;
DnDCPTransport *mTransport;
- ToolsAppCtx *mToolsAppCtx;
uint32 mLocalCaps;
};
/*********************************************************
- * Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#include "tracer.hh"
#include "guestDnD.hh"
-#include "dndRpcV4.hh"
-#include "dndRpcV3.hh"
#include "guestDnDCPMgr.hh"
+#ifdef DND_VM
+#include "vmGuestDnDSrc.hh"
+#else
+#include "crtGuestDnDSrc.hh"
+#endif
+
extern "C" {
#include "debug.h"
}
-#define UNGRAB_TIMEOUT 500 // 0.5s
-#define HIDE_DET_WND_TIMER 500 // 0.5s
-#define UNITY_DND_DET_TIMEOUT 500 // 0.5s
-
-
-/**
- * Callback for DnDUngrab timeout. This will be called if there is no pending
- * GH DnD when user dragged leaving the guest.
- *
- * @param[in] clientData
- *
- * @return FALSE always
- */
-
-static gboolean
-DnDUngrabTimeout(void *clientData)
-{
- TRACE_CALL();
-
- ASSERT(clientData);
- GuestDnDMgr *dnd = (GuestDnDMgr *)clientData;
- /* Call actual callback. */
- dnd->UngrabTimeout();
- return FALSE;
-}
-
-
-/**
- * Callback for HideDetWndTimer.
- *
- * @param[in] clientData
- *
- * @return FALSE always
- */
-
-
-static gboolean
-DnDHideDetWndTimer(void *clientData)
-{
- TRACE_CALL();
-
- ASSERT(clientData);
- GuestDnDMgr *dnd = (GuestDnDMgr *)clientData;
- dnd->SetHideDetWndTimer(NULL);
- dnd->HideDetWnd();
- return FALSE;
-}
-
-
-/**
- * Callback for UnityDnDDetTimeout.
- *
- * @param[in] clientData
- *
- * @return FALSE always
- */
-
-
-static gboolean
-DnDUnityDetTimeout(void *clientData)
-{
- TRACE_CALL();
-
- ASSERT(clientData);
- GuestDnDMgr *dnd = (GuestDnDMgr *)clientData;
- dnd->UnityDnDDetTimeout();
- return FALSE;
-}
-
-
/**
* Constructor.
*
mHideDetWndTimer(NULL),
mUnityDnDDetTimeout(NULL),
mUngrabTimeout(NULL),
- mToolsAppCtx(ctx),
mDnDAllowed(false),
mDnDTransport(transport),
mCapabilities(0xffffffff)
{
ASSERT(transport);
- ASSERT(mToolsAppCtx);
}
SetSessionId(sessionId);
ASSERT(clip);
- mSrc = new GuestDnDSrc(this);
+
+#ifdef DND_VM
+ mSrc = new VMGuestDnDSrc(this);
+#else
+ mSrc = new CRTGuestDnDSrc(this);
+#endif
mSrc->OnRpcDragBegin(clip);
}
* this is here in case the drag isn't picked up by our drag detection window
* for some reason.
*/
- if (NULL == mUngrabTimeout) {
- g_debug("%s: adding UngrabTimeout\n", __FUNCTION__);
- mUngrabTimeout = g_timeout_source_new(UNGRAB_TIMEOUT);
- VMTOOLSAPP_ATTACH_SOURCE(mToolsAppCtx, mUngrabTimeout, DnDUngrabTimeout, this, NULL);
- g_source_unref(mUngrabTimeout);
- }
+ AddDnDUngrabTimeoutEvent();
}
* this window to accept drop in cancel case.
*/
UpdateDetWnd(show, 1, 1);
- mUnityDnDDetTimeout = g_timeout_source_new(UNITY_DND_DET_TIMEOUT);
- VMTOOLSAPP_ATTACH_SOURCE(mToolsAppCtx,
- mUnityDnDDetTimeout,
- DnDUnityDetTimeout,
- this,
- NULL);
- g_source_unref(mUnityDnDDetTimeout);
+ AddUnityDnDDetTimeoutEvent();
SetSessionId(sessionId);
} else {
/*
{
TRACE_CALL();
- if (NULL == mHideDetWndTimer) {
- g_debug("%s: add timer to hide detection window.\n", __FUNCTION__);
- mHideDetWndTimer = g_timeout_source_new(HIDE_DET_WND_TIMER);
- VMTOOLSAPP_ATTACH_SOURCE(mToolsAppCtx, mHideDetWndTimer,
- DnDHideDetWndTimer, this, NULL);
- g_source_unref(mHideDetWndTimer);
- } else {
- g_debug("%s: mHideDetWndTimer is not NULL, quit.\n", __FUNCTION__);
- }
+ AddHideDetWndTimerEvent();
}
mRpc = NULL;
}
- switch(version) {
- case 4:
- mRpc = new DnDRpcV4(mDnDTransport);
- break;
- case 3:
- mRpc = new DnDRpcV3(mDnDTransport);
- break;
- default:
- g_debug("%s: unsupported DnD version\n", __FUNCTION__);
- break;
- }
+ CreateDnDRpcWithVersion(version);
+
if (mRpc) {
mRpc->pingReplyChanged.connect(
sigc::mem_fun(this, &GuestDnDMgr::OnPingReply));
mCapabilities = capabilities;
}
+
+/**
+ * Callback for DnDUngrab timeout. This will be called if there is no pending
+ * GH DnD when user dragged leaving the guest.
+ *
+ * @param[in] clientData
+ *
+ * @return FALSE always
+ */
+
+gboolean
+GuestDnDMgr::DnDUngrabTimeout(void *clientData)
+{
+ TRACE_CALL();
+
+ ASSERT(clientData);
+ GuestDnDMgr *dnd = (GuestDnDMgr *)clientData;
+ /* Call actual callback. */
+ dnd->UngrabTimeout();
+ return FALSE;
+}
+
+
+/**
+ * Callback for HideDetWndTimer.
+ *
+ * @param[in] clientData
+ *
+ * @return FALSE always
+ */
+
+gboolean
+GuestDnDMgr::DnDHideDetWndTimer(void *clientData)
+{
+ TRACE_CALL();
+
+ ASSERT(clientData);
+ GuestDnDMgr *dnd = (GuestDnDMgr *)clientData;
+ dnd->SetHideDetWndTimer(NULL);
+ dnd->HideDetWnd();
+ return FALSE;
+}
+
+
+/**
+ * Callback for UnityDnDDetTimeout.
+ *
+ * @param[in] clientData
+ *
+ * @return FALSE always
+ */
+
+gboolean
+GuestDnDMgr::DnDUnityDetTimeout(void *clientData)
+{
+ TRACE_CALL();
+
+ ASSERT(clientData);
+ GuestDnDMgr *dnd = (GuestDnDMgr *)clientData;
+ dnd->UnityDnDDetTimeout();
+ return FALSE;
+}
+
/*********************************************************
- * Copyright (C) 2010-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
const uint8 *stagingDirCP,
uint32 sz)
{
- if (!success && !mStagingDir.empty()) {
- /* Delete all files if host canceled the file transfer. */
- DnD_DeleteStagingFiles(mStagingDir.c_str(), FALSE);
- mStagingDir.clear();
- }
+ CleanStagingFiles(success);
+
/* UI should remove block with this signal. */
mMgr->getFilesDoneChanged.emit(success);
mMgr->HideDetWnd();
const std::string &
GuestDnDSrc::SetupDestDir(const std::string &destDir)
{
- mStagingDir = "";
-
- if (!destDir.empty() && File_Exists(destDir.c_str())) {
- mStagingDir = destDir;
- const char *lastSep = Str_Strrchr(mStagingDir.c_str(), DIRSEPC);
- if (lastSep && lastSep[1] != '\0') {
- mStagingDir += DIRSEPS;
- }
-
- return mStagingDir;
- } else {
- char *newDir;
-
- newDir = DnD_CreateStagingDirectory();
- if (newDir != NULL) {
- mStagingDir = newDir;
-
- char *lastSep = Str_Strrchr(newDir, DIRSEPC);
- if (lastSep && lastSep[1] != '\0') {
- mStagingDir += DIRSEPS;
- }
- free(newDir);
- g_debug("%s: destdir: %s", __FUNCTION__, mStagingDir.c_str());
-
- return mStagingDir;
- } else {
- g_debug("%s: destdir not created", __FUNCTION__);
- return mStagingDir;
- }
- }
+ return mStagingDir;
}
-
-
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @guestFileTransfer.cc --
+ *
+ * Implementation of common layer file transfer object for guest.
+ */
+
+#include "guestFileTransfer.hh"
+
+extern "C" {
+ #include "debug.h"
+}
+
+#include "hgfsServer.h"
+
+
+/**
+ * Create transport object and register callback.
+ *
+ * @param[in] transport pointer to a transport object.
+ */
+
+GuestFileTransfer::GuestFileTransfer(DnDCPTransport *transport)
+ : mRpc(NULL)
+{
+ ASSERT(transport);
+}
+
+
+/**
+ * Destructor.
+ */
+GuestFileTransfer::~GuestFileTransfer(void)
+{
+}
/*********************************************************
- * Copyright (C) 2010-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#include <sigc++/trackable.h>
#include "fileTransferRpc.hh"
#include "dndCPTransport.h"
-extern "C" {
-#include "hgfsServerManager.h"
-}
class GuestFileTransfer
: public sigc::trackable
{
public:
GuestFileTransfer(DnDCPTransport *transport);
- ~GuestFileTransfer(void);
-
-private:
- void OnRpcRecvHgfsPacket(uint32 sessionId,
- const uint8 *packet,
- size_t packetSize);
+ virtual ~GuestFileTransfer(void);
+protected:
FileTransferRpc *mRpc;
- HgfsServerMgrData mHgfsServerMgrData;
};
#endif // GUEST_FILE_TRANSFER_HH
/*********************************************************
- * Copyright (C) 2010-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
*********************************************************/
/**
- * @file copyPasteDnDWrapper.cpp
+ * @file vmCopyPasteDnDWrapper.cpp
*
- * This singleton class implements a wrapper around various versions of
- * copy and paste and dnd protocols, and provides some convenience functions
- * that help to make VMwareUser a bit cleaner.
+ * The inherited implementation of common class CopyPasteDnDWrapper in VM side.
*/
-#define G_LOG_DOMAIN "dndcp"
-
-#if defined(HAVE_GTKMM)
-#include "copyPasteDnDX11.h"
-#endif
-
-#if defined(WIN32)
-#include "copyPasteDnDWin32.h"
-#endif
-
-#if defined(__APPLE__)
-#include "copyPasteDnDMac.h"
-#endif
-
-#include "copyPasteDnDWrapper.h"
#include "guestDnDCPMgr.hh"
+#include "vmCopyPasteDnDWrapper.h"
#include "vmware.h"
extern "C" {
-#include "rpcout.h"
-#include "vmware/guestrpc/tclodefs.h"
-#include "vmware/tools/plugin.h"
-#include "vmware/tools/utils.h"
-#include <string.h>
+ #include "rpcout.h"
+ #include "vmware/guestrpc/tclodefs.h"
+ #include "vmware/tools/plugin.h"
+ #include "vmware/tools/utils.h"
+ #include <string.h>
}
-/**
- * CopyPasteDnDWrapper is a singleton, here is a pointer to its only instance.
- */
-
-CopyPasteDnDWrapper *CopyPasteDnDWrapper::m_instance = NULL;
/**
*
- * Get an instance of CopyPasteDnDWrapper, which is an application singleton.
+ * Timer callback for reset. Handle it by calling the member function
+ * that handles reset.
*
- * @return a pointer to the singleton CopyPasteDnDWrapper object, or NULL if
- * for some reason it could not be allocated.
- */
-
-CopyPasteDnDWrapper *
-CopyPasteDnDWrapper::GetInstance()
-{
- if (!m_instance) {
- m_instance = new CopyPasteDnDWrapper;
- }
- ASSERT(m_instance);
- return m_instance;
-}
-
-
-/**
+ * @param[in] clientData pointer to the CopyPasteDnDWrapper instance that
+ * issued the timer.
*
- * Destroy the singleton object.
+ * @return FALSE always.
*/
-void
-CopyPasteDnDWrapper::Destroy()
+static gboolean
+DnDPluginResetSent(void *clientData)
{
- if (m_instance) {
- g_debug("%s: destroying self\n", __FUNCTION__);
- delete m_instance;
- m_instance = NULL;
- }
-}
-
-
-/**
- *
- * Constructor.
- */
+ CopyPasteDnDWrapper *p = reinterpret_cast<CopyPasteDnDWrapper *>(clientData);
-CopyPasteDnDWrapper::CopyPasteDnDWrapper() :
- m_isCPEnabled(FALSE),
- m_isDnDEnabled(FALSE),
- m_isCPRegistered(FALSE),
- m_isDnDRegistered(FALSE),
- m_cpVersion(0),
- m_dndVersion(0),
- m_ctx(NULL),
- m_pimpl(NULL)
-{
+ ASSERT(p);
+ p->OnResetInternal();
+ return FALSE;
}
/**
*
- * Call the implementation class pointer/grab initialization code. See
- * the implementation code for further details.
+ * Create an instance for class VMCopyPasteDnDWrapper.
+ *
+ * @return a pointer to the VMCopyPasteDnDWrapper instance.
*/
-void
-CopyPasteDnDWrapper::PointerInit()
+VMCopyPasteDnDWrapper *
+VMCopyPasteDnDWrapper::CreateInstance(void)
{
- ASSERT(m_pimpl);
-
- m_pimpl->PointerInit();
+ return new VMCopyPasteDnDWrapper();
}
*/
void
-CopyPasteDnDWrapper::Init(ToolsAppCtx *ctx)
+VMCopyPasteDnDWrapper::Init(ToolsAppCtx *ctx)
{
m_ctx = ctx;
-
- GuestDnDCPMgr *p = GuestDnDCPMgr::GetInstance();
- ASSERT(p);
- p->Init(ctx);
-
- if (!m_pimpl) {
-#if defined(HAVE_GTKMM)
- m_pimpl = new CopyPasteDnDX11();
-#endif
-#if defined(WIN32)
- m_pimpl = new CopyPasteDnDWin32();
-#endif
-#if defined(__APPLE__)
- m_pimpl = new CopyPasteDnDMac();
-#endif
- if (m_pimpl) {
- m_pimpl->Init(ctx);
- /*
- * Tell the Guest DnD Manager what capabilities we support.
- */
- p->SetCaps(m_pimpl->GetCaps());
- }
- }
-}
-
-
-/**
- *
- * Destructor.
- */
-
-CopyPasteDnDWrapper::~CopyPasteDnDWrapper()
-{
- g_debug("%s: enter\n", __FUNCTION__);
- if (m_pimpl) {
- if (IsCPRegistered()) {
- m_pimpl->UnregisterCP();
- }
- if (IsDnDRegistered()) {
- m_pimpl->UnregisterDnD();
- }
- delete m_pimpl;
- }
- GuestDnDCPMgr::Destroy();
-}
-
-
-/**
- *
- * Register copy and paste capabilities with the VMX. Try newest version
- * first, then fall back to the legacy implementation.
- *
- * @return TRUE on success, FALSE on failure
- */
-
-gboolean
-CopyPasteDnDWrapper::RegisterCP()
-{
- g_debug("%s: enter\n", __FUNCTION__);
- ASSERT(m_pimpl);
- if (IsCPEnabled()) {
- return m_pimpl->RegisterCP();
- }
- return false;
-}
-
-
-/**
- *
- * Register DnD capabilities with the VMX. Handled by the platform layer.
- *
- * @return TRUE on success, FALSE on failure
- */
-
-gboolean
-CopyPasteDnDWrapper::RegisterDnD()
-{
- g_debug("%s: enter\n", __FUNCTION__);
- ASSERT(m_pimpl);
- if (IsDnDEnabled()) {
- return m_pimpl->RegisterDnD();
- }
- return false;
-}
-
-
-/**
- *
- * Unregister copy paste capabilities. Handled by platform layer.
- */
-
-void
-CopyPasteDnDWrapper::UnregisterCP()
-{
- g_debug("%s: enter\n", __FUNCTION__);
- ASSERT(m_pimpl);
- return m_pimpl->UnregisterCP();
-}
-
-
-/**
- *
- * Unregister DnD capabilities. Handled by platform layer.
- */
-
-void
-CopyPasteDnDWrapper::UnregisterDnD()
-{
- g_debug("%s: enter\n", __FUNCTION__);
- ASSERT(m_pimpl);
- return m_pimpl->UnregisterDnD();
-}
-
-
-/**
- *
- * Get the version of the copy paste protocol being wrapped.
- *
- * @return copy paste protocol version.
- */
-
-int
-CopyPasteDnDWrapper::GetCPVersion()
-{
- g_debug("%s: enter\n", __FUNCTION__);
- if (IsCPRegistered()) {
- char *reply = NULL;
- size_t replyLen;
-
- ToolsAppCtx *ctx = GetToolsAppCtx();
- if (!RpcChannel_Send(ctx->rpc, QUERY_VMX_COPYPASTE_VERSION,
- strlen(QUERY_VMX_COPYPASTE_VERSION), &reply, &replyLen)) {
- g_debug("%s: could not get VMX copyPaste "
- "version capability: %s\n", __FUNCTION__, reply ? reply : "NULL");
- m_cpVersion = 1;
- } else {
- m_cpVersion = atoi(reply);
- }
- free(reply);
- }
- g_debug("%s: got version %d\n", __FUNCTION__, m_cpVersion);
- return m_cpVersion;
-}
-
-
-/**
- *
- * Get the version of the DnD protocol being wrapped.
- *
- * @return DnD protocol version.
- */
-
-int
-CopyPasteDnDWrapper::GetDnDVersion()
-{
- g_debug("%s: enter\n", __FUNCTION__);
- if (IsDnDRegistered()) {
- char *reply = NULL;
- size_t replyLen;
-
- ToolsAppCtx *ctx = GetToolsAppCtx();
- if (!RpcChannel_Send(ctx->rpc, QUERY_VMX_DND_VERSION,
- strlen(QUERY_VMX_DND_VERSION), &reply, &replyLen)) {
- g_debug("%s: could not get VMX dnd "
- "version capability: %s\n", __FUNCTION__, reply ? reply : "NULL");
- m_dndVersion = 1;
- } else {
- m_dndVersion = atoi(reply);
- }
- free(reply);
- }
- g_debug("%s: got version %d\n", __FUNCTION__, m_dndVersion);
- return m_dndVersion;
-}
-
-
-/**
- *
- * Set a flag indicating that we are wrapping an initialized and registered
- * copy paste implementation, or not.
- *
- * @param[in] isRegistered If TRUE, protocol is registered, otherwise FALSE.
- */
-
-void
-CopyPasteDnDWrapper::SetCPIsRegistered(gboolean isRegistered)
-{
- g_debug("%s: enter\n", __FUNCTION__);
- m_isCPRegistered = isRegistered;
-}
-
-
-/**
- *
- * Get the flag indicating that we are wrapping an initialized and registered
- * copy paste implementation, or not.
- *
- * @return TRUE if copy paste is initialized, otherwise FALSE.
- */
-
-gboolean
-CopyPasteDnDWrapper::IsCPRegistered()
-{
- g_debug("%s: enter\n", __FUNCTION__);
- return m_isCPRegistered;
-}
-
-
-/**
- *
- * Set a flag indicating that we are wrapping an initialized and registered
- * DnD implementation, or not.
- *
- * @param[in] isRegistered If TRUE, protocol is registered, otherwise FALSE.
- */
-
-void
-CopyPasteDnDWrapper::SetDnDIsRegistered(gboolean isRegistered)
-{
- m_isDnDRegistered = isRegistered;
-}
-
-
-/**
- *
- * Get the flag indicating that we are wrapping an initialized and registered
- * DnD implementation, or not.
- *
- * @return TRUE if DnD is initialized, otherwise FALSE.
- */
-
-gboolean
-CopyPasteDnDWrapper::IsDnDRegistered()
-{
- return m_isDnDRegistered;
-}
-
-
-/**
- *
- * Set a flag indicating that copy paste is enabled, or not. This is called
- * in response to SetOption RPC being received.
- *
- * @param[in] isEnabled If TRUE, copy paste is enabled, otherwise FALSE.
- */
-
-void
-CopyPasteDnDWrapper::SetCPIsEnabled(gboolean isEnabled)
-{
- g_debug("%s: enter\n", __FUNCTION__);
- m_isCPEnabled = isEnabled;
- if (!isEnabled && IsCPRegistered()) {
- UnregisterCP();
- } else if (isEnabled && !IsCPRegistered()) {
- RegisterCP();
- }
-}
-
-
-/**
- *
- * Get the flag indicating that copy paste was enabled (via SetOption RPC).
- *
- * @return TRUE if copy paste is enabled, otherwise FALSE.
- */
-
-gboolean
-CopyPasteDnDWrapper::IsCPEnabled()
-{
- return m_isCPEnabled;
+ CopyPasteDnDWrapper::Init(ctx);
}
/**
*
- * Set a flag indicating that DnD is enabled, or not. This is called
- * in response to SetOption RPC being received.
- *
- * @param[in] isEnabled If TRUE, DnD is enabled, otherwise FALSE.
+ * Add the DnD plugin reset timer.
*/
void
-CopyPasteDnDWrapper::SetDnDIsEnabled(gboolean isEnabled)
-{
- m_isDnDEnabled = isEnabled;
- if (!isEnabled && IsDnDRegistered()) {
- UnregisterDnD();
- } else if (isEnabled && !IsDnDRegistered()) {
- RegisterDnD();
- }
-}
-
-
-/**
- *
- * Get the flag indicating that DnD was enabled (via SetOption) or not.
- *
- * @return TRUE if DnD is enabled, otherwise FALSE.
- */
-
-gboolean
-CopyPasteDnDWrapper::IsDnDEnabled()
-{
- return m_isDnDEnabled;
-}
-
-
-/**
- *
- * Timer callback for reset. Handle it by calling the member function
- * that handles reset.
- *
- * @param[in] clientData pointer to the CopyPasteDnDWrapper instance that
- * issued the timer.
- *
- * @return FALSE always.
- */
-
-static gboolean
-DnDPluginResetSent(void *clientData)
-{
- CopyPasteDnDWrapper *p = reinterpret_cast<CopyPasteDnDWrapper *>(clientData);
-
- ASSERT(p);
- p->OnResetInternal();
- return FALSE;
-}
-
-
-/**
- *
- * Handle reset.
- */
-
-void
-CopyPasteDnDWrapper::OnResetInternal()
-{
- g_debug("%s: enter\n", __FUNCTION__);
-
- /*
- * Reset DnD/Copy/Paste only if vmx said we can. The reason is that
- * we may also get reset request from vmx when user is taking snapshot
- * or recording. If there is an ongoing DnD/copy/paste, we should not
- * reset here. For details please refer to bug 375928.
- */
- char *reply = NULL;
- size_t replyLen;
- ToolsAppCtx *ctx = GetToolsAppCtx();
- if (RpcChannel_Send(ctx->rpc, "dnd.is.active",
- strlen("dnd.is.active"), &reply, &replyLen) &&
- (1 == atoi(reply))) {
- g_debug("%s: ignore reset while file transfer is busy.\n", __FUNCTION__);
- goto exit;
- }
-
- if (IsDnDRegistered()) {
- UnregisterDnD();
- }
- if (IsCPRegistered()) {
- UnregisterCP();
- }
- if (IsCPEnabled() && !IsCPRegistered()) {
- RegisterCP();
- }
- if (IsDnDEnabled() && !IsDnDRegistered()) {
- RegisterDnD();
- }
- if (!IsDnDRegistered() || !IsCPRegistered()) {
- g_debug("%s: unable to reset fully DnD %d CP %d!\n",
- __FUNCTION__, IsDnDRegistered(), IsCPRegistered());
- }
-
-exit:
- free(reply);
-}
-
-
-/**
- *
- * Handle reset.
- *
- * Schedule the post-reset actions to happen a little after one cycle of the
- * RpcIn loop. This will give vmware a chance to receive the ATR
- * reinitialize the channel if appropriate.
- */
-
-void
-CopyPasteDnDWrapper::OnReset()
+VMCopyPasteDnDWrapper::AddDnDPluginResetTimer(void)
{
GSource *src;
*/
void
-CopyPasteDnDWrapper::OnCapReg(gboolean set)
+VMCopyPasteDnDWrapper::OnCapReg(gboolean set)
{
g_debug("%s: enter\n", __FUNCTION__);
char *reply = NULL;
ASSERT(version >= 1);
SetCPVersion(version);
g_debug("%s: VMX is copypaste version %d\n", __FUNCTION__,
- GetCPVersion());
+ GetCPVersion());
if (version == 3) {
/*
* VMDB still has version 4 in it, which will cause a V3
/**
*
- * Handle SetOption
+ * Get the version of the copy paste protocol being wrapped.
+ *
+ * @return copy paste protocol version.
+ */
+
+int
+VMCopyPasteDnDWrapper::GetCPVersion()
+{
+ g_debug("%s: enter\n", __FUNCTION__);
+ if (IsCPRegistered()) {
+ char *reply = NULL;
+ size_t replyLen;
+
+ ToolsAppCtx *ctx = GetToolsAppCtx();
+ if (!RpcChannel_Send(ctx->rpc, QUERY_VMX_COPYPASTE_VERSION,
+ strlen(QUERY_VMX_COPYPASTE_VERSION), &reply, &replyLen)) {
+ g_debug("%s: could not get VMX copyPaste "
+ "version capability: %s\n", __FUNCTION__,
+ reply ? reply : "NULL");
+ m_cpVersion = 1;
+ } else {
+ m_cpVersion = atoi(reply);
+ }
+ free(reply);
+ }
+ g_debug("%s: got version %d\n", __FUNCTION__, m_cpVersion);
+ return m_cpVersion;
+}
+
+
+/**
+ *
+ * Get the version of the DnD protocol being wrapped.
+ *
+ * @return DnD protocol version.
+ */
+
+int
+VMCopyPasteDnDWrapper::GetDnDVersion()
+{
+ g_debug("%s: enter\n", __FUNCTION__);
+ if (IsDnDRegistered()) {
+ char *reply = NULL;
+ size_t replyLen;
+
+ ToolsAppCtx *ctx = GetToolsAppCtx();
+ if (!RpcChannel_Send(ctx->rpc, QUERY_VMX_DND_VERSION,
+ strlen(QUERY_VMX_DND_VERSION), &reply, &replyLen)) {
+ g_debug("%s: could not get VMX dnd "
+ "version capability: %s\n", __FUNCTION__,
+ reply ? reply : "NULL");
+ m_dndVersion = 1;
+ } else {
+ m_dndVersion = atoi(reply);
+ }
+ free(reply);
+ }
+ g_debug("%s: got version %d\n", __FUNCTION__, m_dndVersion);
+ return m_dndVersion;
+}
+
+
+/**
+ *
+ * Handle reset.
+ */
+
+void
+VMCopyPasteDnDWrapper::OnResetInternal()
+{
+ g_debug("%s: enter\n", __FUNCTION__);
+
+ /*
+ * Reset DnD/Copy/Paste only if vmx said we can. The reason is that
+ * we may also get reset request from vmx when user is taking snapshot
+ * or recording. If there is an ongoing DnD/copy/paste, we should not
+ * reset here. For details please refer to bug 375928.
+ */
+ char *reply = NULL;
+ size_t replyLen;
+ ToolsAppCtx *ctx = GetToolsAppCtx();
+ if (RpcChannel_Send(ctx->rpc, "dnd.is.active",
+ strlen("dnd.is.active"), &reply, &replyLen) &&
+ (1 == atoi(reply))) {
+ g_debug("%s: ignore reset while file transfer is busy.\n", __FUNCTION__);
+ goto exit;
+ }
+
+ if (IsDnDRegistered()) {
+ UnregisterDnD();
+ }
+ if (IsCPRegistered()) {
+ UnregisterCP();
+ }
+ if (IsCPEnabled() && !IsCPRegistered()) {
+ RegisterCP();
+ }
+ if (IsDnDEnabled() && !IsDnDRegistered()) {
+ RegisterDnD();
+ }
+ if (!IsDnDRegistered() || !IsCPRegistered()) {
+ g_debug("%s: unable to reset fully DnD %d CP %d!\n",
+ __FUNCTION__, IsDnDRegistered(), IsCPRegistered());
+ }
+
+exit:
+ free(reply);
+}
+
+
+/**
+ *
+ * Handle SetOption.
+ *
+ * @param[in] option option name
+ * @param[in] option option value
+ * @return TRUE on success, FALSE on failure
*/
gboolean
-CopyPasteDnDWrapper::OnSetOption(const char *option, const char *value)
+VMCopyPasteDnDWrapper::OnSetOption(const char *option,
+ const char *value)
{
gboolean ret = false;
bool bEnable;
return ret;
}
-
-
-/**
- * Get capabilities by calling platform implementation.
- *
- * @return 32-bit mask of DnD/CP capabilities.
- */
-
-uint32
-CopyPasteDnDWrapper::GetCaps()
-{
- ASSERT(m_pimpl);
-
- return m_pimpl->GetCaps();
-}
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2018 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @file vmCopyPasteDnDWrapper.h
+ *
+ * The inherited implementation of common class CopyPasteDnDWrapper in VM side.
+ */
+
+#ifndef __VM_COPYPASTEDNDWRAPPER_H__
+#define __VM_COPYPASTEDNDWRAPPER_H__
+
+#include "copyPasteDnDWrapper.h"
+
+class VMCopyPasteDnDWrapper
+ : public CopyPasteDnDWrapper
+{
+public:
+ ~VMCopyPasteDnDWrapper() { }
+
+ static VMCopyPasteDnDWrapper *CreateInstance(void);
+ virtual void Init(ToolsAppCtx *ctx);
+ virtual ToolsAppCtx *GetToolsAppCtx() { return m_ctx; }
+ virtual void OnCapReg(gboolean set);
+ virtual int GetCPVersion();
+ virtual int GetDnDVersion();
+ virtual void OnResetInternal();
+ virtual gboolean OnSetOption(const char *option, const char *value);
+
+protected:
+ void AddDnDPluginResetTimer(void);
+
+private:
+ VMCopyPasteDnDWrapper() : m_ctx(NULL) { }
+ VMCopyPasteDnDWrapper(const VMCopyPasteDnDWrapper &wrapper);
+ VMCopyPasteDnDWrapper& operator=(const VMCopyPasteDnDWrapper &wrapper);
+
+private:
+ ToolsAppCtx *m_ctx;
+};
+
+#endif // __VM_COPYPASTEDNDWRAPPER_H__