[Spice-commits] 2 commits - client/application.cpp client/red_client.cpp client/red_client.h

Yonit Halperin yhalperi at kemper.freedesktop.org
Sun Aug 22 22:24:42 PDT 2010


 client/application.cpp |    2 ++
 client/red_client.cpp  |   23 +++++++++++++++++++----
 client/red_client.h    |    9 ++++++++-
 3 files changed, 29 insertions(+), 5 deletions(-)

New commits:
commit 7b7feaecdf9cf3f00f4dfa37cd7ade9ecbfa0633
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Sun Aug 15 14:39:53 2010 +0300

    client: Fix for clipboard sending; It wasn't thread safe.

diff --git a/client/red_client.cpp b/client/red_client.cpp
index 9a8078e..b6a412e 100644
--- a/client/red_client.cpp
+++ b/client/red_client.cpp
@@ -75,6 +75,11 @@ private:
     RedClient& _client;
 };
 
+void ClipboardEvent::response(AbstractProcessLoop& events_loop)
+{
+    static_cast<RedClient*>(events_loop.get_owner())->send_agent_clipboard();
+}
+
 Migrate::Migrate(RedClient& client)
     : _client (client)
     , _running (false)
@@ -747,7 +752,7 @@ uint32_t get_agent_clipboard_type(uint32_t type)
     }
 }
 
-void RedClient::post_agent_clipboard()
+void RedClient::do_send_agent_clipboard()
 {
     uint32_t size;
 
@@ -771,7 +776,7 @@ void RedClient::post_agent_clipboard()
 }
 
 //FIXME: currently supports text only; better name - poll_clipboard?
-void RedClient::on_clipboard_change()
+void RedClient::send_agent_clipboard()
 {
     //FIXME: check connected  - assert on disconnect
     uint32_t clip_type = Platform::CLIPBOARD_UTF8_TEXT;
@@ -799,11 +804,18 @@ void RedClient::on_clipboard_change()
         _agent_out_msg_size = 0;
         return;
     }
+
     if (_agent_tokens) {
-        post_agent_clipboard();
+        do_send_agent_clipboard();
     }
 }
 
+void RedClient::on_clipboard_change()
+{
+    AutoRef<ClipboardEvent> event(new ClipboardEvent());
+    get_process_loop().push_event(*event);
+}
+
 void RedClient::set_mouse_mode(uint32_t supported_modes, uint32_t current_mode)
 {
     if (current_mode != _mouse_mode) {
@@ -960,6 +972,8 @@ void RedClient::handle_agent_data(RedPeer::InMessage* message)
             msg_size -= n;
             msg_pos += n;
             if (_agent_msg_pos == sizeof(VDAgentMessage)) {
+                DBG(0, "agent msg start: msg_size=%d, protocol=%d, type=%d",
+                    _agent_msg->size, _agent_msg->protocol, _agent_msg->type);
                 if (_agent_msg->protocol != VD_AGENT_PROTOCOL) {
                     THROW("Invalid protocol %u", _agent_msg->protocol);
                 }
@@ -974,6 +988,7 @@ void RedClient::handle_agent_data(RedPeer::InMessage* message)
             msg_pos += n;
         }
         if (_agent_msg_pos == sizeof(VDAgentMessage) + _agent_msg->size) {
+            DBG(0, "agent msg end");
             switch (_agent_msg->type) {
             case VD_AGENT_REPLY: {
                 on_agent_reply((VDAgentReply*)_agent_msg_data);
@@ -999,7 +1014,7 @@ void RedClient::handle_agent_tokens(RedPeer::InMessage* message)
     SpiceMsgMainAgentTokens *token = (SpiceMsgMainAgentTokens *)message->data();
     _agent_tokens += token->num_tokens;
     if (_agent_out_msg_pos < _agent_out_msg_size) {
-        post_agent_clipboard();
+        do_send_agent_clipboard();
     }
 }
 
diff --git a/client/red_client.h b/client/red_client.h
index fd1a9b4..6b4d4ab 100644
--- a/client/red_client.h
+++ b/client/red_client.h
@@ -144,10 +144,16 @@ public:
     uint32_t _color_depth;
 };
 
+class ClipboardEvent : public Event {
+public:
+    virtual void response(AbstractProcessLoop& events_loop);
+};
+
 class RedClient: public RedChannel {
 public:
     friend class RedChannel;
     friend class Migrate;
+    friend class ClipboardEvent;
 
     RedClient(Application& application);
     ~RedClient();
@@ -224,7 +230,8 @@ private:
 
     void on_agent_reply(VDAgentReply* reply);
     void on_agent_clipboard(VDAgentClipboard* clipboard, uint32_t size);
-    void post_agent_clipboard();
+    void send_agent_clipboard();
+    void do_send_agent_clipboard();
 
     ChannelFactory* find_factory(uint32_t type);
     void create_channel(uint32_t type, uint32_t id);
commit a5194d37e978d0a065a82f931293fceaaf43dc19
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Sun Aug 8 13:16:38 2010 +0300

    client: fix - exit on bad display-effect argument

diff --git a/client/application.cpp b/client/application.cpp
index 3dafbc6..490cd8c 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -1926,6 +1926,8 @@ bool Application::set_disabled_display_effects(CmdLineParser& parser, char *val,
             disp_setting._disable_animation = true;
         } else {
             Platform::term_printf("%s: bad display effect type \"%s\"\n", arg0, val);
+            _exit_code = SPICEC_ERROR_CODE_INVALID_ARG;
+            return false;
         }
     } while ((val = parser.next_argument()));
 


More information about the Spice-commits mailing list