]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Internal branch sync. Included in this change:
authorVMware, Inc <>
Wed, 26 Jan 2011 01:46:03 +0000 (17:46 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Wed, 26 Jan 2011 01:46:03 +0000 (17:46 -0800)
. dnd: implement SrcCancel/DestCancel for DnD V4 (fixes issue with copying
  files when not needed).

. changes in shared code that don't affect open-vm-tools functionality.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/include/vm_legal.h
open-vm-tools/services/plugins/dndcp/dnd/dndCPMsgV4.h
open-vm-tools/services/plugins/dndcp/dnd/dndRpc.hh
open-vm-tools/services/plugins/dndcp/dnd/dndRpcV4.hh
open-vm-tools/services/plugins/dndcp/dndGuest/dndRpcV3.hh
open-vm-tools/services/plugins/dndcp/dndGuest/dndRpcV4.cc
open-vm-tools/services/plugins/dndcp/dndUIX11.cpp
open-vm-tools/services/plugins/dndcp/dndUIX11.h

index a845f8cb2f62561926c910d7e05620dcd85c3085..6e6debf99e4085b79fdf78dd2e7cb6b090e1914f 100644 (file)
@@ -30,7 +30,7 @@
 #include "vm_version.h"
 
 
-#define COPYRIGHT_YEARS    "1998-2010"
+#define COPYRIGHT_YEARS    "1998-2011"
 #define COPYRIGHT_STRING   "Copyright \251 " COPYRIGHT_YEARS " " COMPANY_NAME
 #define UTF8_COPYRIGHT_STRING   "Copyright \302\251 " COPYRIGHT_YEARS " " COMPANY_NAME
 #define GENERIC_COPYRIGHT_STRING   "Copyright (C) " COPYRIGHT_YEARS " " COMPANY_NAME
index 6b3fe3c3b81ab655c1c38d419b27a8e80fbe2817..bea29dcd09a625c9c05b151ada167c256ad33b7c 100644 (file)
@@ -94,7 +94,8 @@ typedef enum {
    DND_CMD_SEND_FILES_DONE,
    DND_CMD_QUERY_EXITING,
    DND_CMD_DRAG_NOT_PENDING,
-   DND_CMD_UPDATE_UNITY_DET_WND
+   DND_CMD_UPDATE_UNITY_DET_WND,
+   DND_CMD_DEST_CANCEL
 } DnDCmdV4;
 
 /* Copy/Paste commands. */
index 0b7d5ceba182b63c5d6747d398f0f7276bc1814b..9747ddc58fc452df4ee9ca33d091465351993f47 100644 (file)
@@ -70,6 +70,7 @@ public:
    virtual bool SrcPrivDragEnter(uint32 sessionId) = 0;
    virtual bool SrcPrivDragLeave(uint32 sessionId, int32 x, int32 y) = 0;
    virtual bool SrcPrivDrop(uint32 sessionId, int32 x, int32 y) = 0;
+   virtual bool SrcCancel(uint32 sessionId) = 0;
 
    /* DnD destination. */
    virtual bool DestDragEnter(uint32 sessionId,
@@ -78,6 +79,7 @@ public:
                              const CPClipboard *clip) = 0;
    virtual bool DestDragLeave(uint32 sessionId, int32 x, int32 y) = 0;
    virtual bool DestDrop(uint32 sessionId, int32 x, int32 y) = 0;
+   virtual bool DestCancel(uint32 sessionId) = 0;
 
    /* Common. */
    virtual void Init(void) = 0;
index ac948cb7b5f6d9c2f5b37705a6b9385b232f94d7..b5e5594297e02bbc97a456b983d98beb8247b7f4 100644 (file)
@@ -53,6 +53,7 @@ public:
    virtual bool SrcPrivDragEnter(uint32 sessionId);
    virtual bool SrcPrivDragLeave(uint32 sessionId, int32 x, int32 y);
    virtual bool SrcPrivDrop(uint32 sessionId, int32 x, int32 y);
+   virtual bool SrcCancel(uint32 sessionId);
 
    /* DnD destination. */
    virtual bool DestDragEnter(uint32 sessionId,
@@ -65,6 +66,7 @@ public:
    virtual bool DestDrop(uint32 sessionId,
                          int32 x,
                          int32 y);
+   virtual bool DestCancel(uint32 sessionId);
 
    /* Common. */
    virtual bool UpdateFeedback(uint32 sessionId, DND_DROPEFFECT feedback);
index cade10610cf1eacb39e7fe6adeff01d7b416dc97..3f76985e74df8865289be557a7d34f93bf80936d 100644 (file)
@@ -54,6 +54,7 @@ public:
    virtual bool SrcPrivDragEnter(uint32 sessionId);
    virtual bool SrcPrivDragLeave(uint32 sessionId, int32 x, int32 y);
    virtual bool SrcPrivDrop(uint32 sessionId, int32 x, int32 y);
+   virtual bool SrcCancel(uint32 sessionId) { return true; };
 
    /* DnD destination. */
    virtual bool DestDragEnter(uint32 sessionId,
@@ -66,6 +67,7 @@ public:
    virtual bool DestDrop(uint32 sessionId,
                          int32 x,
                          int32 y);
+   virtual bool DestCancel(uint32 sessionId) { return true; };
 
    /* Common. */
    virtual bool UpdateFeedback(uint32 sessionId, DND_DROPEFFECT feedback);
index 58cc631d1f0140f79a54233d3b18bf2067358107..c8ecc93a60c79b9235ef0a38f5db63a360c78b90 100644 (file)
@@ -257,6 +257,28 @@ DnDRpcV4::SrcDropDone(uint32 sessionId,
 }
 
 
+/**
+ * Send cmd DND_CMD_SRC_CANCEL to controller.
+ *
+ * @param[in] sessionId active session id the controller assigned earlier.
+ *
+ * @return true on success, false otherwise.
+ */
+
+bool
+DnDRpcV4::SrcCancel(uint32 sessionId)
+{
+   RpcParams params;
+
+   memset(&params, 0, sizeof params);
+   params.addrId = DEFAULT_CONNECTION_ID;
+   params.cmd = DND_CMD_SRC_CANCEL;
+   params.sessionId = sessionId;
+
+   return mUtil.SendMsg(&params);
+}
+
+
 /**
  * Send cmd DND_CMD_DEST_DRAG_ENTER to controller.
  *
@@ -389,6 +411,28 @@ DnDRpcV4::DestDrop(uint32 sessionId,
 }
 
 
+/**
+ * Send cmd DND_CMD_DEST_CANCEL to controller.
+ *
+ * @param[in] sessionId active session id the controller assigned earlier.
+ *
+ * @return true on success, false otherwise.
+ */
+
+bool
+DnDRpcV4::DestCancel(uint32 sessionId)
+{
+   RpcParams params;
+
+   memset(&params, 0, sizeof params);
+   params.addrId = DEFAULT_CONNECTION_ID;
+   params.cmd = DND_CMD_DEST_CANCEL;
+   params.sessionId = sessionId;
+
+   return mUtil.SendMsg(&params);
+}
+
+
 /**
  * Send cmd DND_CMD_QUERY_EXITING to controller.
  *
@@ -626,6 +670,9 @@ DnDRpcV4::HandleMsg(RpcParams *params,
                            params->optional.mouseInfo.x,
                            params->optional.mouseInfo.y);
       break;
+   case DND_CMD_DEST_CANCEL:
+      destCancelChanged.emit(params->sessionId);
+      break;
    case DND_CMD_PRIV_DRAG_ENTER:
       destPrivDragEnterChanged.emit(params->sessionId);
       break;
index ce43ca51620c7108a3f03ab57420fc93a5f1cc9e..de86b90ce6b8a806d666c5ef30f93af95b14f1c3 100644 (file)
@@ -71,7 +71,7 @@ DnDUIX11::DnDUIX11(ToolsAppCtx *ctx)
       m_unityMode(false),
       m_inHGDrag(false),
       m_effect(DROP_NONE),
-      m_isFileDnD(false),
+      m_fileTransferStarted(false),
       m_mousePosX(0),
       m_mousePosY(0),
       m_dc(NULL),
@@ -271,7 +271,7 @@ DnDUIX11::CommonResetCB(void)
    m_effect = DROP_NONE;
    m_inHGDrag = false;
    m_dc = NULL;
-   m_isFileDnD = false;
+   m_fileTransferStarted = false;
    RemoveBlock();
 }
 
@@ -364,7 +364,7 @@ DnDUIX11::CommonDragStartCB(const CPClipboard *clip, std::string stagingDir)
    /* Tell Gtk that a drag should be started from this widget. */
    m_detWnd->drag_begin(targets, actions, 1, (GdkEvent *)&event);
    m_blockAdded = false;
-   m_isFileDnD = false;
+   m_fileTransferStarted = false;
    SourceDragStartDone();
    /* Initialize host hide feedback to DROP_NONE. */
    m_effect = DROP_NONE;
@@ -487,12 +487,14 @@ DnDUIX11::CommonSourceFileCopyDoneCB(bool success)
     * call CommonResetCB(). Otherwise destination may miss the data because
      * we are already reset.
     */
+
+   m_HGGetDataInProgress = false;
+
    if (!m_inHGDrag) {
       CommonResetCB();
    } else {
       RemoveBlock();
    }
-   m_HGGetDataInProgress = false;
 }
 
 
@@ -924,9 +926,9 @@ DnDUIX11::GtkSourceDragDataGetCB(const Glib::RefPtr<Gdk::DragContext> &dc,
        * Doing both of these addresses bug
        * http://bugzilla.eng.vmware.com/show_bug.cgi?id=391661.
        */
-      if (!m_blockAdded && m_inHGDrag) {
+      if (!m_blockAdded && m_inHGDrag && !m_fileTransferStarted) {
          m_HGGetDataInProgress = true;
-         m_isFileDnD = true;
+         m_fileTransferStarted = true;
          AddBlock();
       } else {
          g_debug("%s: not calling AddBlock\n", __FUNCTION__);
@@ -997,7 +999,7 @@ DnDUIX11::GtkSourceDragEndCB(const Glib::RefPtr<Gdk::DragContext> &dc)
     * CommonResetCB() here, since we will do so in the fileCopyDoneChanged
     * callback.
     */
-   if (!m_isFileDnD || !m_HGGetDataInProgress) {
+   if (!m_fileTransferStarted || !m_HGGetDataInProgress) {
       CommonResetCB();
    }
    m_inHGDrag = false;
index 63092cf11a27a6b6f2910268b58d63266876bbc1..e532ef6e41da2cbf7c93b7344e9d4230344f32f7 100644 (file)
@@ -200,7 +200,7 @@ private:
    bool m_unityMode;
    bool m_inHGDrag;
    DND_DROPEFFECT m_effect;
-   bool m_isFileDnD;
+   bool m_fileTransferStarted;
    int32 m_mousePosX;
    int32 m_mousePosY;
    GdkDragContext *m_dc;