[Spice-commits] vdagent/vdagent.cpp

Victor Toso de Carvalho victortoso at kemper.freedesktop.org
Mon May 9 10:41:08 UTC 2016


 vdagent/vdagent.cpp |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 5907b6cbb5c724f9729da59a644271b4258d122e
Author: Victor Toso <victortoso at redhat.com>
Date:   Fri May 6 13:50:31 2016 +0200

    vdagent-win: check for locked session
    
    >From WTSRegisterSessionNotification() we are aware of session changes
    (WM_WTSSESSION_CHANGE) such as Lock/Unlock events.
    
    We can use that to disable features such as drag-and-drop.
    Tested on: Windows 7, Windows XP
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1323628
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 595db85..959881d 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -146,6 +146,7 @@ private:
     uint32_t _in_msg_pos;
     bool _pending_input;
     bool _running;
+    bool _session_is_locked;
     bool _desktop_switch;
     DesktopLayout* _desktop_layout;
     bool _updating_display_config;
@@ -205,6 +206,7 @@ VDAgent::VDAgent()
     , _in_msg_pos (0)
     , _pending_input (false)
     , _running (false)
+    , _session_is_locked (false)
     , _desktop_switch (false)
     , _desktop_layout (NULL)
     , _display_setting (VD_AGENT_REGISTRY_KEY)
@@ -1284,7 +1286,19 @@ void VDAgent::dispatch_message(VDAgentMessage* msg, uint32_t port)
     case VD_AGENT_ANNOUNCE_CAPABILITIES:
         res = handle_announce_capabilities((VDAgentAnnounceCapabilities*)msg->data, msg->size);
         break;
-    case VD_AGENT_FILE_XFER_START:
+    case VD_AGENT_FILE_XFER_START: {
+        VDAgentFileXferStatusMessage status;
+        if (_session_is_locked) {
+            VDAgentFileXferStartMessage *s = (VDAgentFileXferStartMessage *)msg->data;
+            status.id = s->id;
+            status.result = VD_AGENT_FILE_XFER_STATUS_ERROR;
+            vd_printf("Fail to start file-xfer %u due: Locked session", status.id);
+            write_message(VD_AGENT_FILE_XFER_STATUS, sizeof(status), &status);
+        } else if (_file_xfer.dispatch(msg, &status)) {
+            write_message(VD_AGENT_FILE_XFER_STATUS, sizeof(status), &status);
+        }
+        break;
+    }
     case VD_AGENT_FILE_XFER_STATUS:
     case VD_AGENT_FILE_XFER_DATA: {
         VDAgentFileXferStatusMessage status;
@@ -1491,6 +1505,10 @@ LRESULT CALLBACK VDAgent::wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARA
     case WM_WTSSESSION_CHANGE:
         if (wparam == WTS_SESSION_LOGON) {
             a->set_control_event(CONTROL_LOGON);
+        } else if (wparam == WTS_SESSION_LOCK) {
+            a->_session_is_locked = true;
+        } else if (wparam == WTS_SESSION_UNLOCK) {
+            a->_session_is_locked = false;
         }
         break;
     default:


More information about the Spice-commits mailing list