]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Internal branch sync. Included in this change:
authorVMware, Inc <>
Tue, 26 Apr 2011 20:33:02 +0000 (13:33 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 26 Apr 2011 20:33:02 +0000 (13:33 -0700)
. DnD: cache the file list so that we can provide a valid response after the
  DnD operation has finished. Also add "ftp" to the supported schemes.

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

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp
open-vm-tools/services/plugins/dndcp/dnd/dnd.h
open-vm-tools/services/plugins/dndcp/dndUIX11.cpp
open-vm-tools/services/plugins/dndcp/dndUIX11.h

index 9279da7e3d8b0221a39bce0004cf68ae08682c9e..67751e17a84a415ce7635369ece2edf036a84565 100644 (file)
@@ -309,7 +309,6 @@ CopyPasteUIX11::LocalGetFileRequestCB(Gtk::SelectionData& sd,        // IN:
                                       guint info)                    // IN:
 {
    g_debug("%s: enter.\n", __FUNCTION__);
-   mHGCopiedUriList = "";
    VmTimeType curTime;
 
    curTime = GetCurrentTime();
@@ -340,8 +339,8 @@ CopyPasteUIX11::LocalGetFileRequestCB(Gtk::SelectionData& sd,        // IN:
        * On KDE (at least), we can see this multiple times, so ignore if
        * we are already getting files.
        */
-      g_debug("%s: already processing a GetFile request, returning.\n",
-              __FUNCTION__);
+      g_debug("%s: GetFiles already started, returning uriList [%s]\n",
+              __FUNCTION__, mHGCopiedUriList.c_str());
       sd.set(sd.get_target().c_str(), mHGCopiedUriList.c_str());
       return;
    }
index 62069ac2788d51f456f008a4bd424f910ee34b93..6000fa35d3285187a1d095bd18b459bac0483388 100644 (file)
@@ -58,7 +58,7 @@
 /* Strings used for formatting various types of data */
 #define DND_URI_LIST_PRE     "file://"
 #define DND_URI_LIST_PRE_KDE "file:"
-#define DND_URI_NON_FILE_SCHEMES {"ssh", "sftp", "smb", "dav", "davs", NULL}
+#define DND_URI_NON_FILE_SCHEMES {"ssh", "sftp", "smb", "dav", "davs", "ftp",  NULL}
 #define DND_URI_LIST_POST    "\r\n"
 #define DND_TEXT_PLAIN_PRE   ""
 #define DND_TEXT_PLAIN_POST  ""
@@ -137,6 +137,12 @@ typedef struct {
 
 #if !defined(SWIG)
 
+typedef enum {
+   DND_FILE_TRANSFER_NOT_STARTED = 0,
+   DND_FILE_TRANSFER_IN_PROGRESS,
+   DND_FILE_TRANSFER_FINISHED,
+} DND_FILE_TRANSFER_STATUS;
+
 /*
  * Comment out the following for SWIG. We don't currently need to use any of
  * these data structures or call any of these functions from test scripts, and
index 03ca3eaee86fcf4a6e3169b0e5a581f062a9b4ad..570acf75b6b5b9c7612ce208b9fb9fafded75f03 100644 (file)
@@ -64,14 +64,13 @@ DnDUIX11::DnDUIX11(ToolsAppCtx *ctx)
       m_DnD(NULL),
       m_detWnd(NULL),
       m_blockCtrl(NULL),
-      m_HGGetDataInProgress(false),
+      m_HGGetFileStatus(DND_FILE_TRANSFER_NOT_STARTED),
       m_blockAdded(false),
       m_GHDnDInProgress(false),
       m_GHDnDDataReceived(false),
       m_unityMode(false),
       m_inHGDrag(false),
       m_effect(DROP_NONE),
-      m_fileTransferStarted(false),
       m_mousePosX(0),
       m_mousePosY(0),
       m_dc(NULL),
@@ -268,12 +267,11 @@ DnDUIX11::CommonResetCB(void)
 {
    g_debug("%s: entering\n", __FUNCTION__);
    m_GHDnDDataReceived = false;
-   m_HGGetDataInProgress = false;
+   m_HGGetFileStatus = DND_FILE_TRANSFER_NOT_STARTED;
    m_GHDnDInProgress = false;
    m_effect = DROP_NONE;
    m_inHGDrag = false;
    m_dc = NULL;
-   m_fileTransferStarted = false;
    RemoveBlock();
 }
 
@@ -366,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_fileTransferStarted = false;
+   m_HGGetFileStatus = DND_FILE_TRANSFER_NOT_STARTED;
    SourceDragStartDone();
    /* Initialize host hide feedback to DROP_NONE. */
    m_effect = DROP_NONE;
@@ -394,7 +392,7 @@ DnDUIX11::CommonSourceCancelCB(void)
    SendFakeXEvents(true, true, false, true, true, 0, 0);
    CommonUpdateDetWndCB(false, 0, 0);
    m_inHGDrag = false;
-   m_HGGetDataInProgress = false;
+   m_HGGetFileStatus = DND_FILE_TRANSFER_NOT_STARTED;
    m_effect = DROP_NONE;
    RemoveBlock();
 }
@@ -490,7 +488,7 @@ DnDUIX11::CommonSourceFileCopyDoneCB(bool success)
      * we are already reset.
     */
 
-   m_HGGetDataInProgress = false;
+   m_HGGetFileStatus = DND_FILE_TRANSFER_FINISHED;
 
    if (!m_inHGDrag) {
       CommonResetCB();
@@ -685,7 +683,7 @@ DnDUIX11::GtkDestDragMotionCB(const Glib::RefPtr<Gdk::DragContext> &dc,
    g_debug("%s: not ignored %ld %ld %ld\n", __FUNCTION__,
          curTime, m_destDropTime, curTime - m_destDropTime);
 
-   if (m_inHGDrag || m_HGGetDataInProgress) {
+   if (m_inHGDrag || (m_HGGetFileStatus != DND_FILE_TRANSFER_NOT_STARTED)) {
       g_debug("%s: ignored not in hg drag or not getting hg data\n", __FUNCTION__);
       return true;
    }
@@ -931,9 +929,10 @@ 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 && !m_fileTransferStarted) {
-         m_HGGetDataInProgress = true;
-         m_fileTransferStarted = true;
+      if (!m_blockAdded &&
+          m_inHGDrag &&
+          (m_HGGetFileStatus == DND_FILE_TRANSFER_NOT_STARTED)) {
+         m_HGGetFileStatus == DND_FILE_TRANSFER_IN_PROGRESS;
          AddBlock();
       } else {
          g_debug("%s: not calling AddBlock\n", __FUNCTION__);
@@ -1004,7 +1003,7 @@ DnDUIX11::GtkSourceDragEndCB(const Glib::RefPtr<Gdk::DragContext> &dc)
     * CommonResetCB() here, since we will do so in the fileCopyDoneChanged
     * callback.
     */
-   if (!m_fileTransferStarted || !m_HGGetDataInProgress) {
+   if (DND_FILE_TRANSFER_IN_PROGRESS != m_HGGetFileStatus) {
       CommonResetCB();
    }
    m_inHGDrag = false;
@@ -1780,7 +1779,7 @@ void
 DnDUIX11::RemoveBlock()
 {
    g_debug("%s: enter\n", __FUNCTION__);
-   if (m_blockAdded && !m_HGGetDataInProgress) {
+   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. */
       if (DnD_BlockIsReady(m_blockCtrl)) {
@@ -1788,10 +1787,10 @@ DnDUIX11::RemoveBlock()
       }
       m_blockAdded = false;
    } else {
-      g_debug("%s: not removing block m_blockAdded %d m_HGGetDataInProgress %d\n",
+      g_debug("%s: not removing block m_blockAdded %d m_HGGetFileStatus %d\n",
             __FUNCTION__,
             m_blockAdded,
-            m_HGGetDataInProgress);
+            m_HGGetFileStatus);
    }
 }
 
index 859ad89418cd819cd589be043b48f737b322459f..3341ff4eae92d3b088089b92d977163d1a278d13 100644 (file)
@@ -189,7 +189,7 @@ private:
    DragDetWnd *m_detWnd;
    CPClipboard m_clipboard;
    DnDBlockControl *m_blockCtrl;
-   bool m_HGGetDataInProgress;
+   DND_FILE_TRANSFER_STATUS m_HGGetFileStatus;
    int m_HGEffect;
    bool m_blockAdded;
 
@@ -202,7 +202,6 @@ private:
    bool m_unityMode;
    bool m_inHGDrag;
    DND_DROPEFFECT m_effect;
-   bool m_fileTransferStarted;
    int32 m_mousePosX;
    int32 m_mousePosY;
    GdkDragContext *m_dc;