]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Tools/DnD X11: Logging improvements and cosmetic touchups.
authorVMware, Inc <>
Wed, 18 Sep 2013 03:27:07 +0000 (20:27 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:06:59 +0000 (22:06 -0700)
===== Logging =====

A large chunk of the Tools DND code included function call tracing via
log entries at the debug level.  However, it had some problems, such as
generating a lot of noise in all buildtypes.  (Remember that Tools only
has 3-4 log levels: debug, info, warning, and error.) There was also a
problem with inconsistency w/r/t logging when a function went out of
scope.

To address this, I whipped up a dummy tracing object and shove it in
bora-vmsoft/lib/public.  By including tracer.hh, one just inserts
TRACE_CALL(); at the beginning of a function to log entry/exit.
Additionally, it works only in developer builds; it's a ifdef'd out
everywhere else.

Another thing I did was centralize logging of GuestCopyPasteMgr's
session ID and state updates.  We now long old/new values upon update.

More of the DND code has been fixed to log to the dndcp GLib log domain,
making it easier for folks to isolate dndcp logs.  (This explains the
switch from Debug to g_debug.)

===== Readability ====

There was a list of some 10+ sigc signals that, due to indentation and
such, was kinda hard to read & easily skim.  I replaced this with a
macro which reduces each signal hookup to one line.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
13 files changed:
open-vm-tools/lib/include/tracer.hh [new file with mode: 0644]
open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp
open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp
open-vm-tools/services/plugins/dndcp/dndGuest/copyPasteRpcV3.cc
open-vm-tools/services/plugins/dndcp/dndGuest/dndRpcV3.cc
open-vm-tools/services/plugins/dndcp/dndGuest/guestCopyPaste.hh
open-vm-tools/services/plugins/dndcp/dndGuest/guestCopyPasteDest.cc
open-vm-tools/services/plugins/dndcp/dndGuest/guestCopyPasteMgr.cc
open-vm-tools/services/plugins/dndcp/dndGuest/guestCopyPasteSrc.cc
open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDDest.cc
open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDMgr.cc
open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDSrc.cc
open-vm-tools/services/plugins/dndcp/dndUIX11.cpp

diff --git a/open-vm-tools/lib/include/tracer.hh b/open-vm-tools/lib/include/tracer.hh
new file mode 100644 (file)
index 0000000..bb4d71b
--- /dev/null
@@ -0,0 +1,61 @@
+/*********************************************************
+ * Copyright (C) 2013 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.
+ *
+ *********************************************************/
+
+/*
+ * tracer.hh --
+ *
+ *    A dumb object to trace function enter/exit.  (Devel-only.)
+ */
+
+
+#ifndef TRACER_HH
+#define TRACER_HH
+
+
+extern "C" {
+#include "vm_basic_defs.h"
+#include "glib.h"
+}
+
+
+#ifdef VMX86_DEVEL
+#   define TRACE_CALL()    Tracer _fn_tracer (__FUNCTION__)
+class Tracer {
+public:
+   Tracer(const char* fnName)
+      : mFnName(fnName)
+   {
+      g_debug("> %s: enter\n", mFnName);
+   }
+
+   ~Tracer()
+   {
+      g_debug("< %s: exit\n", mFnName);
+   }
+
+private:
+   Tracer();                    // = delete
+   Tracer(const Tracer&);       // = delete
+
+   const char* mFnName;
+};
+#else
+#   define TRACE_CALL()
+#endif
+
+#endif // ifndef TRACER_HH
index 7096e7ab79a14ffc99e9f258e9e268f784740ed1..7c77f854cfccd1210c518d71aea3a74ae159df19 100644 (file)
@@ -27,6 +27,7 @@
 #include "copyPasteDnDWrapper.h"
 #include "copyPasteDnDX11.h"
 #include "dndPluginIntX11.h"
+#include "tracer.hh"
 
 Window gXRoot;
 Display *gXDisplay;
@@ -98,7 +99,7 @@ BlockService::BlockService() :
 BlockService *
 BlockService::GetInstance()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 
    if (!m_instance) {
       m_instance = new BlockService();
@@ -121,7 +122,7 @@ BlockService::GetInstance()
 void
 BlockService::Init(ToolsAppCtx *ctx)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 
    if (!m_initialized && ctx) {
       m_blockCtrl.fd = ctx->blockFD;
@@ -154,7 +155,7 @@ BlockService::ShutdownSignalHandler(const siginfo_t *siginfo,
                                     gpointer data)
 {
    ToolsAppCtx *ctx = (ToolsAppCtx *)data;
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 
    GetInstance()->Shutdown();
 
@@ -176,7 +177,7 @@ BlockService::ShutdownSignalHandler(const siginfo_t *siginfo,
 void
 BlockService::Shutdown()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 
    if (m_initialized) {
       g_source_destroy(m_shutdownSrc);
@@ -215,7 +216,7 @@ CopyPasteDnDX11::CopyPasteDnDX11() :
 gboolean
 CopyPasteDnDX11::Init(ToolsAppCtx *ctx)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
 
    ASSERT(ctx);
@@ -279,7 +280,7 @@ CopyPasteDnDX11::~CopyPasteDnDX11()
 gboolean
 CopyPasteDnDX11::RegisterCP()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
 
    if (wrapper->IsCPRegistered()) {
@@ -326,7 +327,7 @@ CopyPasteDnDX11::RegisterCP()
 gboolean
 CopyPasteDnDX11::RegisterDnD()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
 
    if (!wrapper->IsDnDEnabled()) {
@@ -366,7 +367,7 @@ CopyPasteDnDX11::RegisterDnD()
 void
 CopyPasteDnDX11::UnregisterCP()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
    if (wrapper->IsCPRegistered()) {
       if (m_copyPasteUI) {
@@ -387,7 +388,7 @@ CopyPasteDnDX11::UnregisterCP()
 void
 CopyPasteDnDX11::UnregisterDnD()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
    if (wrapper->IsDnDRegistered()) {
       if (m_dndUI) {
@@ -412,7 +413,7 @@ void
 CopyPasteDnDX11::SetDnDAllowed(bool allowed)
 {
    ASSERT(m_dndUI);
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    m_dndUI->SetDnDAllowed(allowed);
 }
 
@@ -428,7 +429,7 @@ void
 CopyPasteDnDX11::SetCopyPasteAllowed(bool allowed)
 {
    ASSERT(m_copyPasteUI);
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    m_copyPasteUI->SetCopyPasteAllowed(allowed);
 }
 
@@ -442,7 +443,7 @@ CopyPasteDnDX11::SetCopyPasteAllowed(bool allowed)
 void
 CopyPasteDnDX11::CopyPasteVersionChanged(int version)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
    ToolsAppCtx *ctx = wrapper->GetToolsAppCtx();
    g_debug("%s: calling VmxCopyPasteVersionChanged (version %d)\n",
@@ -462,7 +463,7 @@ CopyPasteDnDX11::CopyPasteVersionChanged(int version)
 void
 CopyPasteDnDX11::DnDVersionChanged(int version)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
    ToolsAppCtx *ctx = wrapper->GetToolsAppCtx();
    g_debug("%s: calling VmxDnDVersionChanged (version %d)\n",
@@ -481,7 +482,7 @@ CopyPasteDnDX11::DnDVersionChanged(int version)
 void
 CopyPasteDnDX11::PointerInit()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
 
    ASSERT(wrapper);
index bf55eb695667bada5f077353f9f975c215569735..32abe5d50356660365dbc7f794dac1ec65905fcf 100644 (file)
@@ -72,6 +72,7 @@
 #include "copyPasteUIX11.h"
 #include "dndFileList.hh"
 #include "guestDnDCPMgr.hh"
+#include "tracer.hh"
 
 extern "C" {
    #include "vmblock.h"
@@ -161,7 +162,7 @@ CopyPasteUIX11::CopyPasteUIX11()
 bool
 CopyPasteUIX11::Init()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    if (mInited) {
       return true;
    }
@@ -206,7 +207,7 @@ CopyPasteUIX11::Init()
 
 CopyPasteUIX11::~CopyPasteUIX11()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    CPClipboard_Destroy(&mClipboard);
    /* Any files from last unfinished file transfer should be deleted. */
    if (DND_FILE_TRANSFER_IN_PROGRESS == mHGGetFileStatus &&
@@ -1170,7 +1171,7 @@ CopyPasteUIX11::GetRemoteClipboardCB(const CPClipboard *clip) // IN
    void *buf;
    size_t sz;
 
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    if (!clip) {
       g_debug("%s: No clipboard contents.", __FUNCTION__);
       return;
@@ -1590,6 +1591,6 @@ CopyPasteUIX11::SendClipNotChanged(void)
 void
 CopyPasteUIX11::Reset(void)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    /* Cancel any pending file transfer. */
 }
index 268501ce2c4412acb1050e3bc29c9e3f8e31ba8c..b1dee0b67096ba2133413051cd1e7c970be8ba7a 100644 (file)
@@ -24,6 +24,7 @@
 
 
 #include "copyPasteRpcV3.hh"
+#include "tracer.hh"
 
 extern "C" {
    #include "dndMsg.h"
@@ -63,7 +64,7 @@ CopyPasteRpcV3::~CopyPasteRpcV3(void)
 void
 CopyPasteRpcV3::Init(void)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    ASSERT(mTransport);
    mTransport->RegisterRpc(this, mTransportInterface);
 }
@@ -78,7 +79,7 @@ CopyPasteRpcV3::Init(void)
 void
 CopyPasteRpcV3::SendPing(uint32 caps)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
 }
 
 
@@ -95,7 +96,7 @@ bool
 CopyPasteRpcV3::SrcRequestClip(uint32 sessionId,
                                bool isActive)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -115,7 +116,7 @@ CopyPasteRpcV3::DestSendClip(uint32 sessionId,
                              bool isActive,
                              const CPClipboard* clip)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return mUtil.SendMsg(CP_GH_GET_CLIPBOARD_DONE, clip);
 }
 
@@ -138,14 +139,14 @@ CopyPasteRpcV3::RequestFiles(uint32 sessionId,
    DnDMsg msg;
    bool ret = false;
 
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
 
    DnDMsg_Init(&msg);
 
    /* Construct msg with both cmd CP_HG_START_FILE_COPY and stagingDirCP. */
    DnDMsg_SetCmd(&msg, CP_HG_START_FILE_COPY);
    if (!DnDMsg_AppendArg(&msg, (void *)stagingDirCP, sz)) {
-      Debug("%s: DnDMsg_AppendData failed.\n", __FUNCTION__);
+      g_debug("%s: DnDMsg_AppendData failed.\n", __FUNCTION__);
       goto exit;
    }
 
@@ -174,7 +175,7 @@ CopyPasteRpcV3::SendFilesDone(uint32 sessionId,
                               const uint8 *stagingDirCP,
                               uint32 sz)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -192,7 +193,7 @@ bool
 CopyPasteRpcV3::GetFilesDone(uint32 sessionId,
                              bool success)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -212,7 +213,7 @@ CopyPasteRpcV3::SendPacket(uint32 destId,
                            const uint8 *packet,
                            size_t length)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return mTransport->SendPacket(destId,
                                  mTransportInterface,
                                  packet,
@@ -241,7 +242,7 @@ CopyPasteRpcV3::HandleMsg(RpcParams *params,
 
    ret = DnDMsg_UnserializeHeader(&msg, (void *)binary, binarySize);
    if (DNDMSG_SUCCESS != ret) {
-      Debug("%s: DnDMsg_UnserializeHeader failed %d\n", __FUNCTION__, ret);
+      g_debug("%s: DnDMsg_UnserializeHeader failed %d\n", __FUNCTION__, ret);
       goto exit;
    }
 
@@ -249,12 +250,12 @@ CopyPasteRpcV3::HandleMsg(RpcParams *params,
                                 (void *)(binary + DNDMSG_HEADERSIZE_V3),
                                 binarySize - DNDMSG_HEADERSIZE_V3);
    if (DNDMSG_SUCCESS != ret) {
-      Debug("%s: DnDMsg_UnserializeArgs failed with %d\n", __FUNCTION__, ret);
+      g_debug("%s: DnDMsg_UnserializeArgs failed with %d\n", __FUNCTION__, ret);
       goto exit;
    }
 
-   Debug("%s: Got %d, binary size %d.\n",
-         __FUNCTION__, DnDMsg_GetCmd(&msg), binarySize);
+   g_debug("%s: Got %d, binary size %d.\n", __FUNCTION__, DnDMsg_GetCmd(&msg),
+           binarySize);
 
    /*
     * Translate command and emit signal. Session Id 1 is used because version
@@ -268,7 +269,7 @@ CopyPasteRpcV3::HandleMsg(RpcParams *params,
       /* Unserialize clipboard data for the command. */
       buf = DnDMsg_GetArg(&msg, 0);
       if (!CPClipboard_Unserialize(&clip, DynBuf_Get(buf), DynBuf_GetSize(buf))) {
-         Debug("%s: CPClipboard_Unserialize failed.\n", __FUNCTION__);
+         g_debug("%s: CPClipboard_Unserialize failed.\n", __FUNCTION__);
          goto exit;
       }
       srcRecvClipChanged.emit(1, false, &clip);
@@ -291,8 +292,8 @@ CopyPasteRpcV3::HandleMsg(RpcParams *params,
       break;
    }
    default:
-      Debug("%s: got unsupported new command %d.\n",
-            __FUNCTION__, DnDMsg_GetCmd(&msg));
+      g_debug("%s: got unsupported new command %d.\n", __FUNCTION__,
+              DnDMsg_GetCmd(&msg));
    }
 exit:
    DnDMsg_Destroy(&msg);
@@ -312,6 +313,6 @@ CopyPasteRpcV3::OnRecvPacket(uint32 srcId,
                              const uint8 *packet,
                              size_t packetSize)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    mUtil.OnRecvPacket(srcId, packet, packetSize);
 }
index 07b932e92ec4ac153e144cecb5a201cf65ed23f1..75b268846857f13c7b8086b29d5576943ddaaf63 100644 (file)
@@ -36,6 +36,7 @@
 #endif
 
 #include "dndRpcV3.hh"
+#include "tracer.hh"
 
 extern "C" {
    #include "debug.h"
@@ -79,7 +80,7 @@ DnDRpcV3::~DnDRpcV3(void)
 void
 DnDRpcV3::Init(void)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    ASSERT(mTransport);
    mTransport->RegisterRpc(this, mTransportInterface);
 }
@@ -98,7 +99,7 @@ bool
 DnDRpcV3::SrcDragEnterDone(int32 x,
                            int32 y)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return mUtil.SendMsg(DND_HG_DRAG_ENTER_DONE, x, y);
 
 }
@@ -115,7 +116,7 @@ DnDRpcV3::SrcDragEnterDone(int32 x,
 bool
 DnDRpcV3::SrcDragBeginDone(uint32 sessionId)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return mUtil.SendMsg(DND_HG_DRAG_READY);
 }
 
@@ -141,7 +142,7 @@ DnDRpcV3::UpdateFeedback(uint32 sessionId,
    DnDMsg_SetCmd(&msg, DND_HG_UPDATE_FEEDBACK);
 
    if (!DnDMsg_AppendArg(&msg, &feedback, sizeof feedback)) {
-      Debug("%s: DnDMsg_AppendData failed.\n", __FUNCTION__);
+      g_debug("%s: DnDMsg_AppendData failed.\n", __FUNCTION__);
       goto exit;
    }
 
@@ -164,7 +165,7 @@ exit:
 bool
 DnDRpcV3::SrcPrivDragEnter(uint32 sessionId)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -184,7 +185,7 @@ DnDRpcV3::SrcPrivDragLeave(uint32 sessionId,
                            int32 x,
                            int32 y)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -204,7 +205,7 @@ DnDRpcV3::SrcPrivDrop(uint32 sessionId,
                       int32 x,
                       int32 y)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -224,7 +225,7 @@ DnDRpcV3::SrcDrop(uint32 sessionId,
                   int32 x,
                   int32 y)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -247,14 +248,14 @@ DnDRpcV3::SrcDropDone(uint32 sessionId,
    DnDMsg msg;
    bool ret = false;
 
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
 
    DnDMsg_Init(&msg);
 
    /* Construct msg with both cmd CP_HG_START_FILE_COPY and stagingDirCP. */
    DnDMsg_SetCmd(&msg, DND_HG_DROP_DONE);
    if (!DnDMsg_AppendArg(&msg, (void *)stagingDirCP, sz)) {
-      Debug("%s: DnDMsg_AppendData failed.\n", __FUNCTION__);
+      g_debug("%s: DnDMsg_AppendData failed.\n", __FUNCTION__);
       goto exit;
    }
 
@@ -279,7 +280,7 @@ bool
 DnDRpcV3::DestDragEnter(uint32 sessionId,
                         const CPClipboard *clip)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return mUtil.SendMsg(DND_GH_DRAG_ENTER, clip);
 }
 
@@ -297,7 +298,7 @@ bool
 DnDRpcV3::DestSendClip(uint32 sessionId,
                        const CPClipboard *clip)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -313,7 +314,7 @@ DnDRpcV3::DestSendClip(uint32 sessionId,
 bool
 DnDRpcV3::DragNotPending(uint32 sessionId)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return mUtil.SendMsg(DND_GH_NOT_PENDING);
 }
 
@@ -333,7 +334,7 @@ DnDRpcV3::DestDragLeave(uint32 sessionId,
                         int32 x,
                         int32 y)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -353,7 +354,7 @@ DnDRpcV3::DestDrop(uint32 sessionId,
                    int32 x,
                    int32 y)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -373,7 +374,7 @@ DnDRpcV3::QueryExiting(uint32 sessionId,
                        int32 x,
                        int32 y)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -393,7 +394,7 @@ DnDRpcV3::UpdateUnityDetWnd(uint32 sessionId,
                             bool show,
                             uint32 unityWndId)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -413,7 +414,7 @@ DnDRpcV3::MoveMouse(uint32 sessionId,
                     int32 x,
                     int32 y)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -429,7 +430,7 @@ DnDRpcV3::MoveMouse(uint32 sessionId,
 bool
 DnDRpcV3::RequestFiles(uint32 sessionId)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -451,7 +452,7 @@ DnDRpcV3::SendFilesDone(uint32 sessionId,
                         const uint8 *stagingDirCP,
                         uint32 sz)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -469,7 +470,7 @@ bool
 DnDRpcV3::GetFilesDone(uint32 sessionId,
                        bool success)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -489,7 +490,7 @@ DnDRpcV3::SendPacket(uint32 destId,
                      const uint8 *packet,
                      size_t length)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    return mTransport->SendPacket(destId, mTransportInterface, packet, length);
 }
 
@@ -515,7 +516,7 @@ DnDRpcV3::HandleMsg(RpcParams *params,
 
    ret = DnDMsg_UnserializeHeader(&msg, (void *)binary, binarySize);
    if (DNDMSG_SUCCESS != ret) {
-      Debug("%s: DnDMsg_UnserializeHeader failed %d\n", __FUNCTION__, ret);
+      g_debug("%s: DnDMsg_UnserializeHeader failed %d\n", __FUNCTION__, ret);
       goto exit;
    }
 
@@ -523,12 +524,12 @@ DnDRpcV3::HandleMsg(RpcParams *params,
                                 (void *)(binary + DNDMSG_HEADERSIZE_V3),
                                 binarySize - DNDMSG_HEADERSIZE_V3);
    if (DNDMSG_SUCCESS != ret) {
-      Debug("%s: DnDMsg_UnserializeArgs failed with %d\n", __FUNCTION__, ret);
+      g_debug("%s: DnDMsg_UnserializeArgs failed with %d\n", __FUNCTION__, ret);
       goto exit;
    }
 
-   Debug("%s: Got %d, binary size %d.\n",
-         __FUNCTION__, DnDMsg_GetCmd(&msg), binarySize);
+   g_debug("%s: Got %d, binary size %d.\n", __FUNCTION__, DnDMsg_GetCmd(&msg),
+           binarySize);
 
    /*
     * Translate command and emit signal. Session Id 1 is used because version
@@ -542,7 +543,7 @@ DnDRpcV3::HandleMsg(RpcParams *params,
       /* Unserialize clipboard data for the command. */
       buf = DnDMsg_GetArg(&msg, 0);
       if (!CPClipboard_Unserialize(&mClipboard, DynBuf_Get(buf), DynBuf_GetSize(buf))) {
-         Debug("%s: CPClipboard_Unserialize failed.\n", __FUNCTION__);
+         g_debug("%s: CPClipboard_Unserialize failed.\n", __FUNCTION__);
          break;
       }
       SrcDragEnterDone(DRAG_DET_WINDOW_WIDTH / 2,
@@ -665,8 +666,8 @@ DnDRpcV3::HandleMsg(RpcParams *params,
       break;
    }
    default:
-      Debug("%s: got unsupported new command %d.\n",
-            __FUNCTION__, DnDMsg_GetCmd(&msg));
+      g_debug("%s: got unsupported new command %d.\n", __FUNCTION__,
+              DnDMsg_GetCmd(&msg));
    }
 exit:
    DnDMsg_Destroy(&msg);
@@ -686,6 +687,6 @@ DnDRpcV3::OnRecvPacket(uint32 srcId,
                        const uint8 *packet,
                        size_t packetSize)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
    mUtil.OnRecvPacket(srcId, packet, packetSize);
 }
index 6eebdbf881cfd761a9c181d7e887d5080a2df717..2361315b53a073ec0242953a1f92f8e47c290272 100644 (file)
@@ -55,15 +55,16 @@ public:
    sigc::signal<void, bool> getFilesDoneChanged;
 
    GUEST_CP_STATE GetState(void) { return mCPState; }
-   void SetState(GUEST_CP_STATE state) { mCPState = state; }
+   void SetState(GUEST_CP_STATE state);
    CopyPasteRpc *GetRpc(void) { return mRpc; }
    GuestCopyPasteSrc *GetCopyPasteSrc(void)
       { return mSrc; }
    GuestCopyPasteDest *GetCopyPasteDest(void)
       { return mDest; }
    void ResetCopyPaste(void);
+
    uint32 GetSessionId(void) { return mSessionId; }
-   void SetSessionId(uint32 id) { mSessionId = id; }
+   void SetSessionId(uint32 id);
 
    void DestUISendClip(const CPClipboard *clip);
    const std::string SrcUIRequestFiles(const std::string &dir = "");
index df0eb76aa6ab7f2149854026245ecd129f3948af..0781c211069df318e3c9b0dcee13483347a1b1ed 100644 (file)
@@ -25,6 +25,8 @@
 #include "guestCopyPaste.hh"
 
 extern "C" {
+   #include <glib.h>
+
    #include "dndClipboard.h"
    #include "debug.h"
 }
@@ -54,15 +56,15 @@ GuestCopyPasteDest::UISendClip(const CPClipboard *clip)
 {
    ASSERT(clip);
 
-   Debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
+   g_debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
    if (mMgr->GetState() != GUEST_CP_READY) {
       /* Reset DnD for any wrong state. */
-      Debug("%s: Bad state: %d\n", __FUNCTION__, mMgr->GetState());
+      g_debug("%s: Bad state: %d\n", __FUNCTION__, mMgr->GetState());
       goto error;
    }
 
    if (!mMgr->GetRpc()->DestSendClip(mMgr->GetSessionId(), mIsActive, clip)) {
-      Debug("%s: DestSendClip failed\n", __FUNCTION__);
+      g_debug("%s: DestSendClip failed\n", __FUNCTION__);
       goto error;
    }
 
@@ -83,7 +85,7 @@ void
 GuestCopyPasteDest::OnRpcRequestClip(bool isActive)
 {
    mIsActive = isActive;
-   Debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
+   g_debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
    mMgr->destRequestClipChanged.emit();
 }
 
index 52a04c59baebeb51e94e06a35836fe62fb8b1d9c..04205e5db0c0eafb07238fa304e7484722231cd2 100644 (file)
@@ -22,6 +22,7 @@
  * Implementation of common layer GuestCopyPasteMgr object for guest.
  */
 
+#include "tracer.hh"
 #include "guestCopyPaste.hh"
 #include "copyPasteRpcV3.hh"
 #include "copyPasteRpcV4.hh"
@@ -70,8 +71,8 @@ GuestCopyPasteMgr::~GuestCopyPasteMgr(void)
 void
 GuestCopyPasteMgr::ResetCopyPaste(void)
 {
-   Debug("%s: state %d, session id %d before reset\n",
-         __FUNCTION__, mCPState, mSessionId);
+   TRACE_CALL();
+
    if (mSrc) {
       delete mSrc;
       mSrc = NULL;
@@ -82,8 +83,41 @@ GuestCopyPasteMgr::ResetCopyPaste(void)
    }
    SetState(GUEST_CP_READY);
    SetSessionId(0);
-   Debug("%s: change to state %d, session id %d\n",
-         __FUNCTION__, mCPState, mSessionId);
+}
+
+
+/**
+ * Session ID change and bookkeeping.
+ *
+ * @param[in] id Next session ID.
+ */
+void
+GuestCopyPasteMgr::SetSessionId(uint32 id)
+{
+   DEVEL_ONLY(g_debug("%s: %u => %u\n", __FUNCTION__, mSessionId, id));
+   mSessionId = id;
+}
+
+
+/**
+ * State change and bookkeeping.
+ *
+ * @param[in] state Next state.
+ */
+
+void
+GuestCopyPasteMgr::SetState(GUEST_CP_STATE state)
+{
+#ifdef VMX86_DEVEL
+   static const char* states[] = {
+      "GUEST_CP_INVALID",
+      "GUEST_CP_READY",
+      "GUEST_CP_HG_FILE_COPYING",
+   };
+   g_debug("%s: %s => %s\n", __FUNCTION__, states[mCPState], states[state]);
+#endif
+
+   mCPState = state;
 }
 
 
@@ -103,30 +137,28 @@ GuestCopyPasteMgr::OnRpcSrcRecvClip(uint32 sessionId,
 {
    ASSERT(clip);
 
-   Debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 
    if (!mCopyPasteAllowed) {
-      Debug("%s: CopyPaste is not allowed.\n", __FUNCTION__);
+      g_debug("%s: CopyPaste is not allowed.\n", __FUNCTION__);
       return;
    }
 
    if  (GUEST_CP_READY != mCPState) {
-      Debug("%s: Bad state: %d, reset\n", __FUNCTION__, mCPState);
+      g_debug("%s: Bad state: %d, reset\n", __FUNCTION__, mCPState);
       /* XXX Should reset DnD here. */
       return;
    }
 
    if (mSrc) {
-      Debug("%s: mSrc is not NULL\n", __FUNCTION__);
+      g_debug("%s: mSrc is not NULL\n", __FUNCTION__);
       delete mSrc;
       mSrc = NULL;
    }
 
-   mSessionId = sessionId;
-   Debug("%s: change sessionId to %d\n", __FUNCTION__, mSessionId);
+   SetSessionId(sessionId);
 
    mSrc = new GuestCopyPasteSrc(this);
-
    mSrc->OnRpcRecvClip(isActive, clip);
 }
 
@@ -145,7 +177,7 @@ GuestCopyPasteMgr::SrcUIRequestFiles(const std::string &dir)
    if (mSrc) {
       return mSrc->UIRequestFiles(dir);
    } else {
-      Debug("%s: mSrc is NULL\n", __FUNCTION__);
+      g_debug("%s: mSrc is NULL\n", __FUNCTION__);
       return std::string("");
    }
 }
@@ -163,30 +195,28 @@ void
 GuestCopyPasteMgr::OnRpcDestRequestClip(uint32 sessionId,
                                         bool isActive)
 {
-   Debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 
    if (!mCopyPasteAllowed) {
-      Debug("%s: CopyPaste is not allowed.\n", __FUNCTION__);
+      g_debug("%s: CopyPaste is not allowed.\n", __FUNCTION__);
       return;
    }
 
    if  (GUEST_CP_READY != mCPState) {
-      Debug("%s: Bad state: %d, reset\n", __FUNCTION__, mCPState);
+      g_debug("%s: Bad state: %d, reset\n", __FUNCTION__, mCPState);
       /* XXX Should reset CP here. */
       return;
    }
 
    if (mDest) {
-      Debug("%s: mDest is not NULL\n", __FUNCTION__);
+      g_debug("%s: mDest is not NULL\n", __FUNCTION__);
       delete mDest;
       mDest = NULL;
    }
 
-   mSessionId = sessionId;
-   Debug("%s: change sessionId to %d\n", __FUNCTION__, mSessionId);
+   SetSessionId(sessionId);
 
    mDest = new GuestCopyPasteDest(this);
-
    mDest->OnRpcRequestClip(isActive);
 }
 
@@ -203,7 +233,7 @@ GuestCopyPasteMgr::DestUISendClip(const CPClipboard *clip)
    if (mDest) {
       mDest->UISendClip(clip);
    } else {
-      Debug("%s: mDest is NULL\n", __FUNCTION__);
+      g_debug("%s: mDest is NULL\n", __FUNCTION__);
    }
 }
 
@@ -217,7 +247,7 @@ GuestCopyPasteMgr::DestUISendClip(const CPClipboard *clip)
 void
 GuestCopyPasteMgr::VmxCopyPasteVersionChanged(uint32 version)
 {
-   Debug("GuestCopyPasteMgr::%s: enter version %d\n", __FUNCTION__, version);
+   g_debug("GuestCopyPasteMgr::%s: enter version %d\n", __FUNCTION__, version);
    ASSERT(version >= 3);
    ASSERT(mTransport);
 
@@ -237,8 +267,8 @@ GuestCopyPasteMgr::VmxCopyPasteVersionChanged(uint32 version)
       break;
    }
    if (mRpc) {
-      Debug("GuestCopyPasteMgr::%s: register ping reply changed %d\n",
-            __FUNCTION__, version);
+      g_debug("GuestCopyPasteMgr::%s: register ping reply changed %d\n",
+              __FUNCTION__, version);
       mRpc->pingReplyChanged.connect(
          sigc::mem_fun(this, &GuestCopyPasteMgr::OnPingReply));
       mRpc->srcRecvClipChanged.connect(
@@ -283,7 +313,7 @@ GuestCopyPasteMgr::CheckCapability(uint32 capsRequest)
 void
 GuestCopyPasteMgr::OnPingReply(uint32 capabilities)
 {
-   Debug("%s: copypaste ping reply caps are %x\n", __FUNCTION__, capabilities);
+   g_debug("%s: copypaste ping reply caps are %x\n", __FUNCTION__, capabilities);
    mResolvedCaps = capabilities;
 }
 
index e3905bd8b311fb86e7b4530d35f28deda7b97c58..f3c2e855241e99afe2a4f4eaa0d867f532ae9a44 100644 (file)
@@ -25,6 +25,8 @@
 #include "guestCopyPaste.hh"
 
 extern "C" {
+   #include <glib.h>
+
    #include "dndClipboard.h"
    #include "debug.h"
    #include "file.h"
@@ -78,7 +80,7 @@ GuestCopyPasteSrc::OnRpcRecvClip(bool isActive,
    ASSERT(mMgr);
    ASSERT(clip);
 
-   Debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
+   g_debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
 
    CPClipboard_Clear(&mClipboard);
    CPClipboard_Copy(&mClipboard, clip);
@@ -104,7 +106,7 @@ GuestCopyPasteSrc::UIRequestFiles(const std::string &dir)
 
    if (mMgr->GetState() != GUEST_CP_READY) {
       /* Reset DnD for any wrong state. */
-      Debug("%s: Bad state: %d\n", __FUNCTION__, mMgr->GetState());
+      g_debug("%s: Bad state: %d\n", __FUNCTION__, mMgr->GetState());
       goto error;
    }
 
@@ -119,7 +121,7 @@ GuestCopyPasteSrc::UIRequestFiles(const std::string &dir)
                                          sizeof cpName,
                                          cpName);
    if (cpNameSize < 0) {
-      Debug("%s: Error, could not convert to CPName.\n", __FUNCTION__);
+      g_debug("%s: Error, could not convert to CPName.\n", __FUNCTION__);
       goto error;
    }
 
@@ -131,7 +133,7 @@ GuestCopyPasteSrc::UIRequestFiles(const std::string &dir)
 
    mStagingDir = destDir;
    mMgr->SetState(GUEST_CP_HG_FILE_COPYING);
-   Debug("%s: state changed to GUEST_CP_HG_FILE_COPYING\n", __FUNCTION__);
+   g_debug("%s: state changed to GUEST_CP_HG_FILE_COPYING\n", __FUNCTION__);
 
    return destDir;
 
@@ -165,7 +167,7 @@ GuestCopyPasteSrc::OnRpcGetFilesDone(uint32 sessionId,
    /* UI should remove block with this signal. */
    mMgr->getFilesDoneChanged.emit(success);
    mMgr->SetState(GUEST_CP_READY);
-   Debug("%s: state changed to READY\n", __FUNCTION__);
+   g_debug("%s: state changed to READY\n", __FUNCTION__);
 }
 
 
@@ -201,9 +203,9 @@ GuestCopyPasteSrc::SetupDestDir(const std::string &destDir)
             mStagingDir += DIRSEPS;
          }
          free(newDir);
-         Debug("%s: destdir: %s", __FUNCTION__, mStagingDir.c_str());
+         g_debug("%s: destdir: %s", __FUNCTION__, mStagingDir.c_str());
       } else {
-         Debug("%s: destdir not created", __FUNCTION__);
+         g_debug("%s: destdir not created", __FUNCTION__);
       }
    }
    return mStagingDir;
index 69293a6b36d4e56196104d89ae234b84c318fb22..b9eff21600d840facf88f7e50fd4e48fd0cab296 100644 (file)
@@ -24,6 +24,7 @@
 
 
 #include "guestDnD.hh"
+#include "tracer.hh"
 
 extern "C" {
    #include "dndClipboard.h"
@@ -76,11 +77,11 @@ void
 GuestDnDDest::UIDragEnter(const CPClipboard *clip)
 {
    if (!mMgr->IsDragEnterAllowed()) {
-      Debug("%s: not allowed.\n", __FUNCTION__);
+      g_debug("%s: not allowed.\n", __FUNCTION__);
       return;
    }
 
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
 
    if (GUEST_DND_DEST_DRAGGING == mMgr->GetState() ||
        GUEST_DND_PRIV_DRAGGING == mMgr->GetState()) {
@@ -89,8 +90,8 @@ GuestDnDDest::UIDragEnter(const CPClipboard *clip)
        * VM and drag into the detection window again, and trigger the
        * DragEnter. In this case, ignore the DragEnter.
        */
-      Debug("%s: already in state %d for GH DnD, ignoring.\n",
-            __FUNCTION__, mMgr->GetState());
+      g_debug("%s: already in state %d for GH DnD, ignoring.\n", __FUNCTION__,
+              mMgr->GetState());
       return;
    }
 
@@ -99,7 +100,7 @@ GuestDnDDest::UIDragEnter(const CPClipboard *clip)
        * In HG DnD case, if DnD already happened, user may also drag into the
        * detection window again. The DragEnter should also be ignored.
        */
-      Debug("%s: already in SRC_DRAGGING state, ignoring\n", __FUNCTION__);
+      g_debug("%s: already in SRC_DRAGGING state, ignoring\n", __FUNCTION__);
       return;
    }
 
@@ -109,7 +110,7 @@ GuestDnDDest::UIDragEnter(const CPClipboard *clip)
     */
    if (mMgr->GetState() != GUEST_DND_QUERY_EXITING &&
        mMgr->GetState() != GUEST_DND_READY) {
-      Debug("%s: Bad state: %d, reset\n", __FUNCTION__, mMgr->GetState());
+      g_debug("%s: Bad state: %d, reset\n", __FUNCTION__, mMgr->GetState());
       goto error;
    }
 
@@ -117,12 +118,12 @@ GuestDnDDest::UIDragEnter(const CPClipboard *clip)
    CPClipboard_Copy(&mClipboard, clip);
 
    if (!mMgr->GetRpc()->DestDragEnter(mMgr->GetSessionId(), clip)) {
-      Debug("%s: DestDragEnter failed\n", __FUNCTION__);
+      g_debug("%s: DestDragEnter failed\n", __FUNCTION__);
       goto error;
    }
 
    mMgr->SetState(GUEST_DND_DEST_DRAGGING);
-   Debug("%s: state changed to DEST_DRAGGING\n", __FUNCTION__);
+   g_debug("%s: state changed to DEST_DRAGGING\n", __FUNCTION__);
    return;
 
 error:
@@ -140,15 +141,15 @@ error:
 void
 GuestDnDDest::OnRpcPrivDragEnter(uint32 sessionId)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
 
    if (GUEST_DND_DEST_DRAGGING != mMgr->GetState()) {
-      Debug("%s: Bad state: %d, reset\n", __FUNCTION__, mMgr->GetState());
+      g_debug("%s: Bad state: %d, reset\n", __FUNCTION__, mMgr->GetState());
       goto error;
    }
 
    mMgr->SetState(GUEST_DND_PRIV_DRAGGING);
-   Debug("%s: state changed to PRIV_DRAGGING\n", __FUNCTION__);
+   g_debug("%s: state changed to PRIV_DRAGGING\n", __FUNCTION__);
    return;
 
 error:
@@ -170,16 +171,16 @@ GuestDnDDest::OnRpcPrivDragLeave(uint32 sessionId,
                                  int32 x,
                                  int32 y)
 {
-   Debug("%s: entering.\n", __FUNCTION__);
+   TRACE_CALL();
 
    if (GUEST_DND_PRIV_DRAGGING != mMgr->GetState()) {
-      Debug("%s: Bad state: %d, reset\n", __FUNCTION__, mMgr->GetState());
+      g_debug("%s: Bad state: %d, reset\n", __FUNCTION__, mMgr->GetState());
       goto error;
    }
 
    mMgr->SetState(GUEST_DND_DEST_DRAGGING);
    mMgr->destMoveDetWndToMousePosChanged.emit();
-   Debug("%s: state changed to DEST_DRAGGING\n", __FUNCTION__);
+   g_debug("%s: state changed to DEST_DRAGGING\n", __FUNCTION__);
    return;
 
 error:
@@ -204,8 +205,9 @@ GuestDnDDest::OnRpcPrivDrop(uint32 sessionId,
    mMgr->privDropChanged.emit(x, y);
    mMgr->HideDetWnd();
    mMgr->SetState(GUEST_DND_READY);
-   Debug("%s: state changed to GUEST_DND_READY, session id changed to 0\n",
-         __FUNCTION__);
+   // XXX Trace.
+   g_debug("%s: state changed to GUEST_DND_READY, session id changed to 0\n",
+           __FUNCTION__);
 }
 
 
@@ -239,7 +241,7 @@ GuestDnDDest::OnRpcCancel(uint32 sessionId)
    mMgr->RemoveUngrabTimeout();
    mMgr->destCancelChanged.emit();
    mMgr->SetState(GUEST_DND_READY);
-   Debug("%s: state changed to GUEST_DND_READY, session id changed to 0\n",
-         __FUNCTION__);
+   g_debug("%s: state changed to GUEST_DND_READY, session id changed to 0\n",
+           __FUNCTION__);
 }
 
index 5e98e6f5d608e141c0e0919ec45739114db7d127..ffe30612c86283200423ae831032f8cb2be7cddd 100644 (file)
@@ -22,6 +22,7 @@
  * Implementation of common layer GuestDnDMgr object for guest.
  */
 
+#include "tracer.hh"
 #include "guestDnD.hh"
 #include "dndRpcV4.hh"
 #include "dndRpcV3.hh"
@@ -49,6 +50,8 @@ extern "C" {
 static gboolean
 DnDUngrabTimeout(void *clientData)
 {
+   TRACE_CALL();
+
    ASSERT(clientData);
    GuestDnDMgr *dnd = (GuestDnDMgr *)clientData;
    /* Call actual callback. */
@@ -69,7 +72,8 @@ DnDUngrabTimeout(void *clientData)
 static gboolean
 DnDHideDetWndTimer(void *clientData)
 {
-   Debug("%s: entering\n", __FUNCTION__);
+   TRACE_CALL();
+
    ASSERT(clientData);
    GuestDnDMgr *dnd = (GuestDnDMgr *)clientData;
    dnd->SetHideDetWndTimer(NULL);
@@ -90,7 +94,8 @@ DnDHideDetWndTimer(void *clientData)
 static gboolean
 DnDUnityDetTimeout(void *clientData)
 {
-   Debug("%s: entering\n", __FUNCTION__);
+   TRACE_CALL();
+
    ASSERT(clientData);
    GuestDnDMgr *dnd = (GuestDnDMgr *)clientData;
    dnd->UnityDnDDetTimeout();
@@ -155,8 +160,8 @@ GuestDnDMgr::~GuestDnDMgr(void)
 void
 GuestDnDMgr::ResetDnD(void)
 {
-   Debug("%s: state %d, session id %d before reset\n",
-         __FUNCTION__, mDnDState, mSessionId);
+   TRACE_CALL();
+
    if (mSrc) {
       srcCancelChanged.emit();
       DelayHideDetWnd();
@@ -170,9 +175,11 @@ GuestDnDMgr::ResetDnD(void)
       delete mDest;
       mDest = NULL;
    }
+
    SetState(GUEST_DND_READY);
-   Debug("%s: change to state %d, session id %d\n",
-         __FUNCTION__, mDnDState, mSessionId);
+
+   g_debug("%s: change to state %d, session id %d\n", __FUNCTION__, mDnDState,
+           mSessionId);
 }
 
 
@@ -183,10 +190,12 @@ GuestDnDMgr::ResetDnD(void)
 void
 GuestDnDMgr::SrcUIDragBeginDone(void)
 {
+   TRACE_CALL();
+
    if (mSrc) {
       mSrc->UIDragBeginDone();
    } else {
-      Debug("%s: mSrc is NULL\n", __FUNCTION__);
+      g_debug("%s: mSrc is NULL\n", __FUNCTION__);
    }
 }
 
@@ -200,10 +209,12 @@ GuestDnDMgr::SrcUIDragBeginDone(void)
 void
 GuestDnDMgr::SrcUIUpdateFeedback(DND_DROPEFFECT feedback)
 {
+   TRACE_CALL();
+
    if (mSrc) {
       mSrc->UIUpdateFeedback(feedback);
    } else {
-      Debug("%s: mSrc is NULL\n", __FUNCTION__);
+      g_debug("%s: mSrc is NULL\n", __FUNCTION__);
    }
 }
 
@@ -218,7 +229,7 @@ GuestDnDMgr::SrcUIUpdateFeedback(DND_DROPEFFECT feedback)
 void
 GuestDnDMgr::DestUIDragEnter(const CPClipboard *clip)
 {
-   Debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 
    /* Remove untriggered ungrab timer. */
    RemoveUngrabTimeout();
@@ -242,7 +253,7 @@ GuestDnDMgr::DestUIDragEnter(const CPClipboard *clip)
     */
    if (mDnDState != GUEST_DND_QUERY_EXITING &&
        mDnDState != GUEST_DND_READY) {
-      Debug("%s: Bad state: %d, reset\n", __FUNCTION__, mDnDState);
+      g_debug("%s: Bad state: %d, reset\n", __FUNCTION__, mDnDState);
       ResetDnD();
       return;
    }
@@ -254,7 +265,7 @@ GuestDnDMgr::DestUIDragEnter(const CPClipboard *clip)
    }
 
    if (mDest) {
-      Debug("%s: mDest is not NULL\n", __FUNCTION__);
+      g_debug("%s: mDest is not NULL\n", __FUNCTION__);
       delete mDest;
       mDest = NULL;
    }
@@ -278,27 +289,26 @@ void
 GuestDnDMgr::OnRpcSrcDragBegin(uint32 sessionId,
                                const CPClipboard *clip)
 {
-   Debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 
    if (!mDnDAllowed) {
-      Debug("%s: DnD is not allowed.\n", __FUNCTION__);
+      g_debug("%s: DnD is not allowed.\n", __FUNCTION__);
       return;
    }
 
    if  (GUEST_DND_READY != mDnDState) {
-      Debug("%s: Bad state: %d, reset\n", __FUNCTION__, mDnDState);
+      g_debug("%s: Bad state: %d, reset\n", __FUNCTION__, mDnDState);
       ResetDnD();
       return;
    }
 
    if (mSrc) {
-      Debug("%s: mSrc is not NULL\n", __FUNCTION__);
+      g_debug("%s: mSrc is not NULL\n", __FUNCTION__);
       delete mSrc;
       mSrc = NULL;
    }
 
-   mSessionId = sessionId;
-   Debug("%s: change sessionId to %d\n", __FUNCTION__, mSessionId);
+   SetSessionId(sessionId);
 
    ASSERT(clip);
    mSrc = new GuestDnDSrc(this);
@@ -321,24 +331,24 @@ GuestDnDMgr::OnRpcQueryExiting(uint32 sessionId,
                                int32 x,
                                int32 y)
 {
+   TRACE_CALL();
+
    if (!mDnDAllowed) {
-      Debug("%s: DnD is not allowed.\n", __FUNCTION__);
+      g_debug("%s: DnD is not allowed.\n", __FUNCTION__);
       return;
    }
 
    if (GUEST_DND_READY != mDnDState) {
       /* Reset DnD for any wrong state. */
-      Debug("%s: Bad state: %d\n", __FUNCTION__, mDnDState);
+      g_debug("%s: Bad state: %d\n", __FUNCTION__, mDnDState);
       ResetDnD();
       return;
    }
 
    /* Show detection window to detect pending GH DnD. */
    ShowDetWnd(x, y);
-   mSessionId = sessionId;
+   SetSessionId(sessionId);
    SetState(GUEST_DND_QUERY_EXITING);
-   Debug("%s: state changed to QUERY_EXITING, session id changed to %d\n",
-         __FUNCTION__, mSessionId);
 
    /*
     * Add event to fire and hide our window if a DnD is not pending.  Note that
@@ -346,7 +356,7 @@ GuestDnDMgr::OnRpcQueryExiting(uint32 sessionId,
     * for some reason.
     */
    if (NULL == mUngrabTimeout) {
-      Debug("%s: adding UngrabTimeout\n", __FUNCTION__);
+      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);
@@ -363,11 +373,13 @@ GuestDnDMgr::OnRpcQueryExiting(uint32 sessionId,
 void
 GuestDnDMgr::UngrabTimeout(void)
 {
+   TRACE_CALL();
+
    mUngrabTimeout = NULL;
 
    if (mDnDState != GUEST_DND_QUERY_EXITING) {
       /* Reset DnD for any wrong state. */
-      Debug("%s: Bad state: %d\n", __FUNCTION__, mDnDState);
+      g_debug("%s: Bad state: %d\n", __FUNCTION__, mDnDState);
       ResetDnD();
       return;
    }
@@ -377,8 +389,6 @@ GuestDnDMgr::UngrabTimeout(void)
 
    HideDetWnd();
    SetState(GUEST_DND_READY);
-   Debug("%s: state changed to GUEST_DND_READY, session id changed to %d\n",
-         __FUNCTION__, mSessionId);
 }
 
 
@@ -397,12 +407,14 @@ GuestDnDMgr::OnRpcUpdateUnityDetWnd(uint32 sessionId,
                                     bool show,
                                     uint32 unityWndId)
 {
+   TRACE_CALL();
+
    if (show && mDnDState != GUEST_DND_READY) {
       /*
        * Reset DnD for any wrong state. Only do this when host asked to
        * show the window.
        */
-      Debug("%s: Bad state: %d\n", __FUNCTION__, mDnDState);
+      g_debug("%s: Bad state: %d\n", __FUNCTION__, mDnDState);
       ResetDnD();
       return;
    }
@@ -427,8 +439,7 @@ GuestDnDMgr::OnRpcUpdateUnityDetWnd(uint32 sessionId,
                                this,
                                NULL);
       g_source_unref(mUnityDnDDetTimeout);
-      mSessionId = sessionId;
-      Debug("%s: change sessionId to %d\n", __FUNCTION__, mSessionId);
+      SetSessionId(sessionId);
    } else {
       /*
        * If there is active DnD, the regular detection window will be hidden
@@ -441,8 +452,8 @@ GuestDnDMgr::OnRpcUpdateUnityDetWnd(uint32 sessionId,
 
    /* Show/hide the full screen detection window. */
    updateUnityDetWndChanged.emit(show, unityWndId, false);
-   Debug("%s: updating Unity detection window, show %d, id %u\n",
-         __FUNCTION__, show, unityWndId);
+   g_debug("%s: updating Unity detection window, show %d, id %u\n",
+           __FUNCTION__, show, unityWndId);
 }
 
 
@@ -454,6 +465,8 @@ GuestDnDMgr::OnRpcUpdateUnityDetWnd(uint32 sessionId,
 void
 GuestDnDMgr::UnityDnDDetTimeout(void)
 {
+   TRACE_CALL();
+
    mUnityDnDDetTimeout = NULL;
    updateUnityDetWndChanged.emit(true, 0, true);
 }
@@ -473,12 +486,14 @@ GuestDnDMgr::OnRpcMoveMouse(uint32 sessionId,
                             int32 x,
                             int32 y)
 {
+   TRACE_CALL();
+
    if (GUEST_DND_SRC_DRAGGING != mDnDState &&
        GUEST_DND_PRIV_DRAGGING != mDnDState) {
-      Debug("%s: not in valid state %d, ignoring\n", __FUNCTION__, mDnDState);
+      g_debug("%s: not in valid state %d, ignoring\n", __FUNCTION__, mDnDState);
       return;
    }
-   Debug("%s: move to %d, %d\n", __FUNCTION__, x, y);
+   g_debug("%s: move to %d, %d\n", __FUNCTION__, x, y);
    moveMouseChanged.emit(x, y);
 }
 
@@ -496,13 +511,15 @@ GuestDnDMgr::UpdateDetWnd(bool show,
                           int32 x,
                           int32 y)
 {
+   TRACE_CALL();
+
    if (mHideDetWndTimer) {
       g_source_destroy(mHideDetWndTimer);
       mHideDetWndTimer = NULL;
    }
 
-   Debug("%s: %s window at %d, %d\n",
-         __FUNCTION__, show ? "show" : "hide", x, y);
+   g_debug("%s: %s window at %d, %d\n", __FUNCTION__, show ? "show" : "hide",
+           x, y);
    updateDetWndChanged.emit(show, x, y);
 }
 
@@ -518,14 +535,16 @@ GuestDnDMgr::UpdateDetWnd(bool show,
 void
 GuestDnDMgr::DelayHideDetWnd(void)
 {
+   TRACE_CALL();
+
    if (NULL == mHideDetWndTimer) {
-      Debug("%s: add timer to hide detection window.\n", __FUNCTION__);
+      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 {
-      Debug("%s: mHideDetWndTimer is not NULL, quit.\n", __FUNCTION__);
+      g_debug("%s: mHideDetWndTimer is not NULL, quit.\n", __FUNCTION__);
    }
 }
 
@@ -537,6 +556,8 @@ GuestDnDMgr::DelayHideDetWnd(void)
 void
 GuestDnDMgr::RemoveUngrabTimeout(void)
 {
+   TRACE_CALL();
+
    if (mUngrabTimeout) {
       g_source_destroy(mUngrabTimeout);
       mUngrabTimeout = NULL;
@@ -553,6 +574,23 @@ GuestDnDMgr::RemoveUngrabTimeout(void)
 void
 GuestDnDMgr::SetState(GUEST_DND_STATE state)
 {
+#ifdef VMX86_DEVEL
+   static const char* states[] = {
+      "GUEST_DND_INVALID",
+      "GUEST_DND_READY",
+      /* As destination. */
+      "GUEST_DND_QUERY_EXITING",
+      "GUEST_DND_DEST_DRAGGING",
+      /* In private dragging mode. */
+      "GUEST_DND_PRIV_DRAGGING",
+      /* As source. */
+      "GUEST_DND_SRC_DRAGBEGIN_PENDING",
+      "GUEST_DND_SRC_CANCEL_PENDING",
+      "GUEST_DND_SRC_DRAGGING",
+   };
+   g_debug("%s: %s => %s\n", __FUNCTION__, states[mDnDState], states[state]);
+#endif
+
    mDnDState = state;
    stateChanged.emit(state);
    if (GUEST_DND_READY == state) {
@@ -590,6 +628,8 @@ GuestDnDMgr::IsDragEnterAllowed(void)
 void
 GuestDnDMgr::VmxDnDVersionChanged(uint32 version)
 {
+   TRACE_CALL();
+
    g_debug("GuestDnDMgr::%s: enter version %d\n", __FUNCTION__, version);
    ASSERT(version >= 3);
 
@@ -663,7 +703,9 @@ GuestDnDMgr::CheckCapability(uint32 capsRequest)
 void
 GuestDnDMgr::OnPingReply(uint32 capabilities)
 {
-   Debug("%s: dnd ping reply caps are %x\n", __FUNCTION__, capabilities);
+   TRACE_CALL();
+
+   g_debug("%s: dnd ping reply caps are %x\n", __FUNCTION__, capabilities);
    mCapabilities = capabilities;
 }
 
index 7c7e336d29b42ae4d3883a82554841dc6737dbd5..96188b2bc65cb840728f3020ce6636b7d681f1f6 100644 (file)
@@ -81,11 +81,11 @@ GuestDnDSrc::OnRpcDragBegin(const CPClipboard *clip)
    ASSERT(mMgr);
    ASSERT(clip);
 
-   Debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
+   g_debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
    /* Setup staging directory. */
    mStagingDir = SetupDestDir("");
    if (mStagingDir.empty()) {
-      Debug("%s: SetupDestDir failed.\n", __FUNCTION__);
+      g_debug("%s: SetupDestDir failed.\n", __FUNCTION__);
       return;
    }
 
@@ -96,7 +96,7 @@ GuestDnDSrc::OnRpcDragBegin(const CPClipboard *clip)
    CPClipboard_Copy(&mClipboard, clip);
 
    mMgr->SetState(GUEST_DND_SRC_DRAGBEGIN_PENDING);
-   Debug("%s: state changed to DRAGBEGIN_PENDING\n", __FUNCTION__);
+   g_debug("%s: state changed to DRAGBEGIN_PENDING\n", __FUNCTION__);
 
    mMgr->srcDragBeginChanged.emit(&mClipboard, mStagingDir);
 }
@@ -111,20 +111,20 @@ GuestDnDSrc::UIDragBeginDone(void)
 {
    ASSERT(mMgr);
 
-   Debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
+   g_debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
    if (mMgr->GetState() != GUEST_DND_SRC_DRAGBEGIN_PENDING) {
       /* Reset DnD for any wrong state. */
-      Debug("%s: Bad state: %d\n", __FUNCTION__, mMgr->GetState());
+      g_debug("%s: Bad state: %d\n", __FUNCTION__, mMgr->GetState());
       goto error;
    }
 
    if (!mMgr->GetRpc()->SrcDragBeginDone(mMgr->GetSessionId())) {
-      Debug("%s: SrcDragBeginDone failed\n", __FUNCTION__);
+      g_debug("%s: SrcDragBeginDone failed\n", __FUNCTION__);
       goto error;
    }
 
    mMgr->SetState(GUEST_DND_SRC_DRAGGING);
-   Debug("%s: state changed to DRAGGING\n", __FUNCTION__);
+   g_debug("%s: state changed to DRAGGING\n", __FUNCTION__);
    return;
 
 error:
@@ -143,16 +143,16 @@ GuestDnDSrc::UIUpdateFeedback(DND_DROPEFFECT feedback)
 {
    ASSERT(mMgr);
 
-   Debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
+   g_debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
 
    /* This operation needs a valid session id from controller. */
    if (0 == mMgr->GetSessionId()) {
-      Debug("%s: can not get a valid session id from controller.\n",
-            __FUNCTION__);
+      g_debug("%s: can not get a valid session id from controller.\n",
+              __FUNCTION__);
       return;
    }
    if (!mMgr->GetRpc()->UpdateFeedback(mMgr->GetSessionId(), feedback)) {
-      Debug("%s: UpdateFeedback failed\n", __FUNCTION__);
+      g_debug("%s: UpdateFeedback failed\n", __FUNCTION__);
       mMgr->ResetDnD();
    }
 }
@@ -176,10 +176,10 @@ GuestDnDSrc::OnRpcDrop(uint32 sessionId,
 
    ASSERT(mMgr);
 
-   Debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
+   g_debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
    if (mMgr->GetState() != GUEST_DND_SRC_DRAGGING) {
       /* Reset DnD for any wrong state. */
-      Debug("%s: Bad state: %d\n", __FUNCTION__, mMgr->GetState());
+      g_debug("%s: Bad state: %d\n", __FUNCTION__, mMgr->GetState());
       goto error;
    }
    mMgr->srcDropChanged.emit();
@@ -190,21 +190,21 @@ GuestDnDSrc::OnRpcDrop(uint32 sessionId,
                                             sizeof cpName,
                                             cpName);
       if (cpNameSize < 0) {
-         Debug("%s: Error, could not convert to CPName.\n", __FUNCTION__);
+         g_debug("%s: Error, could not convert to CPName.\n", __FUNCTION__);
          goto error;
       }
 
       if (!mMgr->GetRpc()->SrcDropDone(sessionId,
                                        (const uint8 *)cpName,
                                        cpNameSize)) {
-         Debug("%s: SrcDropDone failed\n", __FUNCTION__);
+         g_debug("%s: SrcDropDone failed\n", __FUNCTION__);
          goto error;
       }
    } else {
       /* For non-file formats, the DnD is done. Hide detection window. */
       mMgr->HideDetWnd();
       mMgr->SetState(GUEST_DND_READY);
-      Debug("%s: state changed to READY\n", __FUNCTION__);
+      g_debug("%s: state changed to READY\n", __FUNCTION__);
    }
    return;
 
@@ -224,11 +224,11 @@ GuestDnDSrc::OnRpcCancel(uint32 sessionId)
 {
    ASSERT(mMgr);
 
-   Debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
+   g_debug("%s: state is %d\n", __FUNCTION__, mMgr->GetState());
    mMgr->srcCancelChanged.emit();
    mMgr->DelayHideDetWnd();
    mMgr->SetState(GUEST_DND_READY);
-   Debug("%s: state changed to READY\n", __FUNCTION__);
+   g_debug("%s: state changed to READY\n", __FUNCTION__);
 }
 
 
@@ -256,7 +256,7 @@ GuestDnDSrc::OnRpcGetFilesDone(uint32 sessionId,
    mMgr->getFilesDoneChanged.emit(success);
    mMgr->HideDetWnd();
    mMgr->SetState(GUEST_DND_READY);
-   Debug("%s: state changed to READY\n", __FUNCTION__);
+   g_debug("%s: state changed to READY\n", __FUNCTION__);
 }
 
 
@@ -294,11 +294,11 @@ GuestDnDSrc::SetupDestDir(const std::string &destDir)
             mStagingDir += DIRSEPS;
          }
          free(newDir);
-         Debug("%s: destdir: %s", __FUNCTION__, mStagingDir.c_str());
+         g_debug("%s: destdir: %s", __FUNCTION__, mStagingDir.c_str());
 
          return mStagingDir;
       } else {
-         Debug("%s: destdir not created", __FUNCTION__);
+         g_debug("%s: destdir not created", __FUNCTION__);
          return mStagingDir;
       }
    }
index 28eb95820682344840fb00c31fdd497b9ddc2bc0..4548a502559c42bd3f8f8a4256b84feec375226d 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2009 VMware, Inc. All rights reserved.
+ * Copyright (C) 2009-2013 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
@@ -27,6 +27,7 @@
 
 #include "dndUIX11.h"
 #include "guestDnDCPMgr.hh"
+#include "tracer.hh"
 
 extern "C" {
 #include "vmblock.h"
@@ -76,7 +77,7 @@ DnDUIX11::DnDUIX11(ToolsAppCtx *ctx)
       m_destDropTime(0),
       mTotalFileSize(0)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 }
 
 
@@ -87,7 +88,7 @@ DnDUIX11::DnDUIX11(ToolsAppCtx *ctx)
 
 DnDUIX11::~DnDUIX11()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    if (m_detWnd) {
       delete m_detWnd;
    }
@@ -118,7 +119,7 @@ DnDUIX11::~DnDUIX11()
 bool
 DnDUIX11::Init()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    bool ret = true;
 
    CPClipboard_Init(&m_clipboard);
@@ -135,71 +136,48 @@ DnDUIX11::Init()
    }
 
 #if defined(DETWNDDEBUG)
-
    /*
     * This code can only be called when DragDetWnd is derived from
     * Gtk::Window. The normal case is that DragDetWnd is an instance of
     * Gtk::Invisible, which doesn't implement the methods that SetAttributes
     * relies upon.
     */
-
    m_detWnd->SetAttributes();
 #endif
 
    SetTargetsAndCallbacks();
 
+#define CONNECT_SIGNAL(_obj, _sig, _cb) \
+   _obj->_sig.connect(sigc::mem_fun(this, &DnDUIX11::_cb))
+
    /* Set common layer callbacks. */
-   m_DnD->srcDragBeginChanged.connect(
-      sigc::mem_fun(this, &DnDUIX11::CommonDragStartCB));
-   m_DnD->srcDropChanged.connect(
-      sigc::mem_fun(this, &DnDUIX11::CommonSourceDropCB));
-   m_DnD->srcCancelChanged.connect(
-      sigc::mem_fun(this, &DnDUIX11::CommonSourceCancelCB));
-   m_DnD->getFilesDoneChanged.connect(
-      sigc::mem_fun(this, &DnDUIX11::CommonSourceFileCopyDoneCB));
-
-   m_DnD->destCancelChanged.connect(
-      sigc::mem_fun(this, &DnDUIX11::CommonDestCancelCB));
-   m_DnD->privDropChanged.connect(
-      sigc::mem_fun(this, &DnDUIX11::CommonDestPrivateDropCB));
-
-   m_DnD->updateDetWndChanged.connect(
-      sigc::mem_fun(this, &DnDUIX11::CommonUpdateDetWndCB));
-   m_DnD->moveMouseChanged.connect(
-      sigc::mem_fun(this, &DnDUIX11::CommonUpdateMouseCB));
-
-   m_DnD->updateUnityDetWndChanged.connect(
-      sigc::mem_fun(this, &DnDUIX11::CommonUpdateUnityDetWndCB));
-   m_DnD->destMoveDetWndToMousePosChanged.connect(
-      sigc::mem_fun(this, &DnDUIX11::CommonMoveDetWndToMousePos));
+   CONNECT_SIGNAL(m_DnD, srcDragBeginChanged,   CommonDragStartCB);
+   CONNECT_SIGNAL(m_DnD, srcDropChanged,        CommonSourceDropCB);
+   CONNECT_SIGNAL(m_DnD, srcCancelChanged,      CommonSourceCancelCB);
+   CONNECT_SIGNAL(m_DnD, destCancelChanged,     CommonDestCancelCB);
+   CONNECT_SIGNAL(m_DnD, destMoveDetWndToMousePosChanged, CommonMoveDetWndToMousePos);
+   CONNECT_SIGNAL(m_DnD, getFilesDoneChanged,   CommonSourceFileCopyDoneCB);
+   CONNECT_SIGNAL(m_DnD, moveMouseChanged,      CommonUpdateMouseCB);
+   CONNECT_SIGNAL(m_DnD, privDropChanged,       CommonDestPrivateDropCB);
+   CONNECT_SIGNAL(m_DnD, updateDetWndChanged,   CommonUpdateDetWndCB);
+   CONNECT_SIGNAL(m_DnD, updateUnityDetWndChanged, CommonUpdateUnityDetWndCB);
+
    /* Set Gtk+ callbacks for source. */
-   m_detWnd->signal_drag_begin().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkSourceDragBeginCB));
-   m_detWnd->signal_drag_data_get().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkSourceDragDataGetCB));
-   m_detWnd->signal_drag_end().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkSourceDragEndCB));
-
-   m_detWnd->signal_enter_notify_event().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkEnterEventCB));
-   m_detWnd->signal_leave_notify_event().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkLeaveEventCB));
-   m_detWnd->signal_map_event().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkMapEventCB));
-   m_detWnd->signal_unmap_event().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkUnmapEventCB));
-   m_detWnd->signal_realize().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkRealizeEventCB));
-   m_detWnd->signal_unrealize().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkUnrealizeEventCB));
-   m_detWnd->signal_motion_notify_event().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkMotionNotifyEventCB));
-   m_detWnd->signal_configure_event().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkConfigureEventCB));
-   m_detWnd->signal_button_press_event().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkButtonPressEventCB));
-   m_detWnd->signal_button_release_event().connect(
-      sigc::mem_fun(this, &DnDUIX11::GtkButtonReleaseEventCB));
+   CONNECT_SIGNAL(m_detWnd, signal_drag_begin(),        GtkSourceDragBeginCB);
+   CONNECT_SIGNAL(m_detWnd, signal_drag_data_get(),     GtkSourceDragDataGetCB);
+   CONNECT_SIGNAL(m_detWnd, signal_drag_end(),          GtkSourceDragEndCB);
+   CONNECT_SIGNAL(m_detWnd, signal_enter_notify_event(), GtkEnterEventCB);
+   CONNECT_SIGNAL(m_detWnd, signal_leave_notify_event(), GtkLeaveEventCB);
+   CONNECT_SIGNAL(m_detWnd, signal_map_event(),         GtkMapEventCB);
+   CONNECT_SIGNAL(m_detWnd, signal_unmap_event(),       GtkUnmapEventCB);
+   CONNECT_SIGNAL(m_detWnd, signal_realize(),           GtkRealizeEventCB);
+   CONNECT_SIGNAL(m_detWnd, signal_unrealize(),         GtkUnrealizeEventCB);
+   CONNECT_SIGNAL(m_detWnd, signal_motion_notify_event(), GtkMotionNotifyEventCB);
+   CONNECT_SIGNAL(m_detWnd, signal_configure_event(),   GtkConfigureEventCB);
+   CONNECT_SIGNAL(m_detWnd, signal_button_press_event(), GtkButtonPressEventCB);
+   CONNECT_SIGNAL(m_detWnd, signal_button_release_event(), GtkButtonReleaseEventCB);
+
+#undef CONNECT_SIGNAL
 
    CommonUpdateDetWndCB(false, 0, 0);
    CommonUpdateUnityDetWndCB(false, 0, false);
@@ -229,7 +207,7 @@ out:
 void
 DnDUIX11::SetTargetsAndCallbacks()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 
    /* Construct supported target list for HG DnD. */
    std::list<Gtk::TargetEntry> targets;
@@ -278,7 +256,7 @@ DnDUIX11::SetTargetsAndCallbacks()
 void
 DnDUIX11::CommonResetCB(void)
 {
-   g_debug("%s: entering\n", __FUNCTION__);
+   TRACE_CALL();
    m_GHDnDDataReceived = false;
    m_HGGetFileStatus = DND_FILE_TRANSFER_NOT_STARTED;
    m_GHDnDInProgress = false;
@@ -309,7 +287,7 @@ DnDUIX11::CommonDragStartCB(const CPClipboard *clip, std::string stagingDir)
    CPClipboard_Clear(&m_clipboard);
    CPClipboard_Copy(&m_clipboard, clip);
 
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 
    /*
     * Before the DnD, we should make sure that the mouse is released
@@ -393,7 +371,7 @@ DnDUIX11::CommonDragStartCB(const CPClipboard *clip, std::string stagingDir)
 void
 DnDUIX11::CommonSourceCancelCB(void)
 {
-   g_debug("%s: entering\n", __FUNCTION__);
+   TRACE_CALL();
 
    /*
     * Force the window to show, position the mouse over it, and release.
@@ -426,7 +404,7 @@ void
 DnDUIX11::CommonDestPrivateDropCB(int32 x,
                                   int32 y)
 {
-   g_debug("%s: entering\n", __FUNCTION__);
+   TRACE_CALL();
    /* Unity manager in host side may already send the drop into guest. */
    if (m_GHDnDInProgress) {
 
@@ -447,7 +425,7 @@ DnDUIX11::CommonDestPrivateDropCB(int32 x,
 void
 DnDUIX11::CommonDestCancelCB(void)
 {
-   g_debug("%s: entering\n", __FUNCTION__);
+   TRACE_CALL();
    /* Unity manager in host side may already send the drop into guest. */
    if (m_GHDnDInProgress) {
       CommonUpdateDetWndCB(true, 0, 0);
@@ -471,7 +449,7 @@ DnDUIX11::CommonDestCancelCB(void)
 void
 DnDUIX11::CommonSourceDropCB(void)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    CommonUpdateDetWndCB(true, 0, 0);
 
    /*
@@ -1504,6 +1482,8 @@ DnDUIX11::SendFakeXEvents(const bool showWidget,
    int winYReturn;
    unsigned int maskReturn;
 
+   TRACE_CALL();
+
    x = xCoord;
    y = yCoord;
 
@@ -1767,7 +1747,7 @@ DnDUIX11::GetDetWndAsWidget()
 void
 DnDUIX11::AddBlock()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    if (m_blockAdded) {
       g_debug("%s: block already added\n", __FUNCTION__);
       return;
@@ -1793,7 +1773,7 @@ DnDUIX11::AddBlock()
 void
 DnDUIX11::RemoveBlock()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    if (m_blockAdded && (DND_FILE_TRANSFER_IN_PROGRESS != m_HGGetFileStatus)) {
       g_debug("%s: removing block for %s\n", __FUNCTION__, m_HGStagingDir.c_str());
       /* We need to make sure block subsystem has not been shut off. */
@@ -2042,7 +2022,7 @@ exit:
 void
 DnDUIX11::SourceDragStartDone(void)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    m_inHGDrag = true;
    m_DnD->SrcUIDragBeginDone();
 }
@@ -2071,7 +2051,7 @@ DnDUIX11::SetBlockControl(DnDBlockControl *blockCtrl)
 void
 DnDUIX11::SourceUpdateFeedback(DND_DROPEFFECT effect)
 {
-   g_debug("%s: entering\n", __FUNCTION__);
+   TRACE_CALL();
    m_DnD->SrcUIUpdateFeedback(effect);
 }
 
@@ -2084,7 +2064,7 @@ DnDUIX11::SourceUpdateFeedback(DND_DROPEFFECT effect)
 void
 DnDUIX11::TargetDragEnter(void)
 {
-   g_debug("%s: entering\n", __FUNCTION__);
+   TRACE_CALL();
 
    /* Check if there is valid data with current detection window. */
    if (!CPClipboard_IsEmpty(&m_clipboard)) {
@@ -2142,7 +2122,7 @@ DnDUIX11::VmxDnDVersionChanged(RpcChannel *chan, uint32 version)
 bool
 DnDUIX11::GtkEnterEventCB(GdkEventCrossing *ignored)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -2157,7 +2137,7 @@ DnDUIX11::GtkEnterEventCB(GdkEventCrossing *ignored)
 bool
 DnDUIX11::GtkLeaveEventCB(GdkEventCrossing *ignored)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -2172,7 +2152,7 @@ DnDUIX11::GtkLeaveEventCB(GdkEventCrossing *ignored)
 bool
 DnDUIX11::GtkMapEventCB(GdkEventAny *event)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -2188,7 +2168,7 @@ DnDUIX11::GtkMapEventCB(GdkEventAny *event)
 bool
 DnDUIX11::GtkUnmapEventCB(GdkEventAny *event)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -2200,7 +2180,7 @@ DnDUIX11::GtkUnmapEventCB(GdkEventAny *event)
 void
 DnDUIX11::GtkRealizeEventCB()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 }
 
 
@@ -2211,7 +2191,7 @@ DnDUIX11::GtkRealizeEventCB()
 void
 DnDUIX11::GtkUnrealizeEventCB()
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
 }
 
 /**
@@ -2259,7 +2239,7 @@ DnDUIX11::GtkConfigureEventCB(GdkEventConfigure *event)
 bool
 DnDUIX11::GtkButtonPressEventCB(GdkEventButton *event)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }
 
@@ -2275,7 +2255,7 @@ DnDUIX11::GtkButtonPressEventCB(GdkEventButton *event)
 bool
 DnDUIX11::GtkButtonReleaseEventCB(GdkEventButton *event)
 {
-   g_debug("%s: enter\n", __FUNCTION__);
+   TRACE_CALL();
    return true;
 }