Index: remoting/client/chromoting_client.cc |
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc |
index cf13d13e65c75cc1f654b13932b9ed5c5ca4d4a8..3c1b506859ddfaa08b4028f9b4db8e310f952513 100644 |
--- a/remoting/client/chromoting_client.cc |
+++ b/remoting/client/chromoting_client.cc |
@@ -5,6 +5,7 @@ |
#include "remoting/client/chromoting_client.h" |
#include "base/bind.h" |
+#include "remoting/base/capabilities.h" |
#include "remoting/client/audio_decode_scheduler.h" |
#include "remoting/client/audio_player.h" |
#include "remoting/client/client_context.h" |
@@ -14,6 +15,7 @@ |
#include "remoting/proto/video.pb.h" |
#include "remoting/protocol/authentication_method.h" |
#include "remoting/protocol/connection_to_host.h" |
+#include "remoting/protocol/host_stub.h" |
#include "remoting/protocol/negotiating_client_authenticator.h" |
#include "remoting/protocol/session_config.h" |
#include "remoting/protocol/transport.h" |
@@ -88,14 +90,40 @@ ChromotingStats* ChromotingClient::GetStats() { |
return rectangle_decoder_->GetStats(); |
} |
+void ChromotingClient::SetCapabilities( |
+ const protocol::Capabilities& capabilities) { |
+ DCHECK(task_runner_->BelongsToCurrentThread()); |
+ |
+ // Only accept the first |protocol::Capabilities| message. |
+ if (host_capabilities_) { |
+ LOG(WARNING) << "protocol::Capabilities has been received already."; |
+ return; |
+ } |
+ |
+ host_capabilities_ = make_scoped_ptr(new Capabilities()); |
+ if (host_capabilities_->FromProtocolMessage(capabilities)) { |
+ VLOG(1) << "Host capabilities: " << host_capabilities_->ToString(); |
+ } else { |
+ LOG(ERROR) << "Invalid protocol::Capabilities received."; |
+ } |
+ |
+ // Calculate the set of capabilities enabled by both client and host and pass |
+ // it to the webapp. |
+ user_interface_->SetCapabilities( |
+ host_capabilities_->Intersect(config_.capabilities).ToString()); |
+} |
+ |
void ChromotingClient::InjectClipboardEvent( |
const protocol::ClipboardEvent& event) { |
DCHECK(task_runner_->BelongsToCurrentThread()); |
+ |
user_interface_->GetClipboardStub()->InjectClipboardEvent(event); |
} |
void ChromotingClient::SetCursorShape( |
const protocol::CursorShapeInfo& cursor_shape) { |
+ DCHECK(task_runner_->BelongsToCurrentThread()); |
+ |
user_interface_->GetCursorShapeStub()->SetCursorShape(cursor_shape); |
} |
@@ -121,6 +149,17 @@ void ChromotingClient::Initialize() { |
rectangle_decoder_->Initialize(connection_->config()); |
if (connection_->config().is_audio_enabled()) |
audio_decode_scheduler_->Initialize(connection_->config()); |
+ |
+ // Negotiate capabilities with the host. |
+ if (connection_->config().supports_capabilities()) { |
+ VLOG(1) << "Client capabilities: " << config_.capabilities.ToString(); |
+ connection_->host_stub()->SetCapabilities( |
+ *config_.capabilities.ToProtocolMessage()); |
Sergey Ulanov
2013/04/16 08:38:53
Should we send intersection of capabilities suppor
alexeypa (please no reviews)
2013/04/16 22:06:11
We do. |config_.capabilities| is a combination of
|
+ } else { |
+ VLOG(1) << "The host does not support any capabilities."; |
+ host_capabilities_ = make_scoped_ptr(new Capabilities()); |
+ user_interface_->SetCapabilities(host_capabilities_->ToString()); |
+ } |
} |
} // namespace remoting |