summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-29 21:56:12 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-29 21:56:12 +0000
commit65f86878792c6e8bb5b78e98ed96dd99ce2c30bb (patch)
treeb0c3a97fd2250b3fdbd254a4dc82c02c08bb04f4
parentbfc031f0f5f833f293b489bf1a2d1c873341fdda (diff)
downloadchromium_src-65f86878792c6e8bb5b78e98ed96dd99ce2c30bb.zip
chromium_src-65f86878792c6e8bb5b78e98ed96dd99ce2c30bb.tar.gz
chromium_src-65f86878792c6e8bb5b78e98ed96dd99ce2c30bb.tar.bz2
Hook up client events to new protocol stubs.
Patch by garykac@chromium.com. Original review: http://codereview.chromium.org/5062001 BUG=none TEST=none Review URL: http://codereview.chromium.org/5345007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67594 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/client/chromoting_client.cc11
-rw-r--r--remoting/client/chromoting_client.h11
-rw-r--r--remoting/client/input_handler.cc62
-rw-r--r--remoting/client/input_handler.h9
-rw-r--r--remoting/host/event_executor_linux.cc111
-rw-r--r--remoting/host/event_executor_win.cc173
-rw-r--r--remoting/host/event_executor_win.h13
-rw-r--r--remoting/proto/event.proto55
-rw-r--r--remoting/proto/internal.proto9
-rw-r--r--remoting/protocol/buffered_socket_writer.cc2
-rw-r--r--remoting/protocol/connection_to_host.cc35
-rw-r--r--remoting/protocol/connection_to_host.h37
-rw-r--r--remoting/protocol/input_sender.cc2
-rw-r--r--remoting/protocol/jingle_connection_to_host.cc11
-rw-r--r--remoting/protocol/jingle_connection_to_host.h4
-rw-r--r--remoting/protocol/message_decoder.h7
-rw-r--r--remoting/protocol/message_reader.h2
-rw-r--r--remoting/protocol/stream_writer.cc2
-rw-r--r--remoting/protocol/stream_writer.h2
-rw-r--r--remoting/remoting.gyp1
20 files changed, 234 insertions, 325 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc
index cd358c4..4e4b9a3 100644
--- a/remoting/client/chromoting_client.cc
+++ b/remoting/client/chromoting_client.cc
@@ -10,7 +10,6 @@
#include "remoting/client/client_context.h"
#include "remoting/client/input_handler.h"
#include "remoting/client/rectangle_update_decoder.h"
-#include "remoting/proto/internal.pb.h"
#include "remoting/protocol/connection_to_host.h"
#include "remoting/protocol/session_config.h"
@@ -46,7 +45,7 @@ void ChromotingClient::Start() {
}
connection_->Connect(config_.username, config_.auth_token, config_.host_jid,
- this, this);
+ this, this, this);
if (!view_->Initialize()) {
ClientDone();
@@ -215,4 +214,12 @@ void ChromotingClient::Initialize() {
input_handler_->Initialize();
}
+////////////////////////////////////////////////////////////////////////////
+// ClientStub control channel interface.
+void ChromotingClient::NotifyResolution(
+ const protocol::NotifyResolutionRequest* msg,
+ Task* done) {
+ // TODO(garykac): Implement this.
+}
+
} // namespace remoting
diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h
index e6e7d7d..441c3b3 100644
--- a/remoting/client/chromoting_client.h
+++ b/remoting/client/chromoting_client.h
@@ -12,19 +12,26 @@
#include "base/task.h"
#include "remoting/client/client_config.h"
#include "remoting/client/chromoting_view.h"
+#include "remoting/protocol/client_stub.h"
#include "remoting/protocol/connection_to_host.h"
+#include "remoting/protocol/input_stub.h"
#include "remoting/protocol/video_stub.h"
class MessageLoop;
namespace remoting {
+namespace protocol {
+class NotifyResolutionRequest;
+} // namespace protocol
+
class ClientContext;
class InputHandler;
class RectangleUpdateDecoder;
// TODO(sergeyu): Move VideoStub implementation to RectangleUpdateDecoder.
class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
+ public protocol::ClientStub,
public protocol::VideoStub {
public:
// Objects passed in are not owned by this class.
@@ -57,6 +64,10 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
virtual void OnConnectionClosed(protocol::ConnectionToHost* conn);
virtual void OnConnectionFailed(protocol::ConnectionToHost* conn);
+ // ClientStub implementation.
+ virtual void NotifyResolution(const protocol::NotifyResolutionRequest* msg,
+ Task* done);
+
// VideoStub implementation.
virtual void ProcessVideoPacket(const VideoPacket* packet, Task* done);
virtual int GetPendingPackets();
diff --git a/remoting/client/input_handler.cc b/remoting/client/input_handler.cc
index d2a8f0d..87c3c89 100644
--- a/remoting/client/input_handler.cc
+++ b/remoting/client/input_handler.cc
@@ -5,8 +5,7 @@
#include "remoting/client/input_handler.h"
#include "remoting/client/chromoting_view.h"
-// TODO(hclam): Should not include internal.pb.h.
-#include "remoting/proto/internal.pb.h"
+#include "remoting/proto/event.pb.h"
#include "remoting/protocol/connection_to_host.h"
namespace remoting {
@@ -16,66 +15,35 @@ InputHandler::InputHandler(ClientContext* context,
ChromotingView* view)
: context_(context),
connection_(connection),
- view_(view),
- send_absolute_mouse_(true),
- mouse_x_(0),
- mouse_y_(0) {
+ view_(view) {
}
void InputHandler::SendKeyEvent(bool press, int keycode) {
- ChromotingClientMessage msg;
-
- KeyEvent *event = msg.mutable_key_event();
+ KeyEvent* event = new KeyEvent();
event->set_key(keycode);
event->set_pressed(press);
- connection_->SendEvent(msg);
+ protocol::InputStub* stub = connection_->input_stub();
+ stub->InjectKeyEvent(event, new DeleteTask<KeyEvent>(event));
}
void InputHandler::SendMouseMoveEvent(int x, int y) {
- ChromotingClientMessage msg;
-
- if (send_absolute_mouse_) {
- MouseSetPositionEvent *event = msg.mutable_mouse_set_position_event();
- event->set_x(x);
- event->set_y(y);
-
- int width, height;
- view_->GetScreenSize(&width, &height);
- event->set_width(width);
- event->set_height(height);
+ MouseEvent* event = new MouseEvent();
+ event->set_x(x);
+ event->set_y(y);
- // TODO(garykac): Fix drift problem with relative mouse events and
- // then re-add this line.
- //send_absolute_mouse_ = false;
- } else {
- MouseMoveEvent *event = msg.mutable_mouse_move_event();
- int dx = x - mouse_x_;
- int dy = y - mouse_y_;
- if (dx == 0 && dy == 0) {
- return;
- }
- event->set_offset_x(dx);
- event->set_offset_y(dy);
- }
- // Record current mouse position.
- mouse_x_ = x;
- mouse_y_ = y;
-
- connection_->SendEvent(msg);
+ protocol::InputStub* stub = connection_->input_stub();
+ stub->InjectMouseEvent(event, new DeleteTask<MouseEvent>(event));
}
void InputHandler::SendMouseButtonEvent(bool button_down,
MouseButton button) {
- ChromotingClientMessage msg;
-
- if (button_down) {
- msg.mutable_mouse_down_event()->set_button(button);
- } else {
- msg.mutable_mouse_up_event()->set_button(button);
- }
+ MouseEvent* event = new MouseEvent();
+ event->set_button(button);
+ event->set_button_down(button_down);
- connection_->SendEvent(msg);
+ protocol::InputStub* stub = connection_->input_stub();
+ stub->InjectMouseEvent(event, new DeleteTask<MouseEvent>(event));
}
} // namespace remoting
diff --git a/remoting/client/input_handler.h b/remoting/client/input_handler.h
index dd1f3ae..8d7c86d 100644
--- a/remoting/client/input_handler.h
+++ b/remoting/client/input_handler.h
@@ -37,15 +37,6 @@ class InputHandler {
ChromotingView* view_;
private:
- // True if we should send the next mouse position as an absolute value rather
- // than a relative value. After sending a single absolute mouse position,
- // it will automatically switch back to sending relative mouse deltas.
- bool send_absolute_mouse_;
-
- // Current (x,y) position of mouse pointer.
- // This is the last value that we sent to the host.
- int mouse_x_, mouse_y_;
-
DISALLOW_COPY_AND_ASSIGN(InputHandler);
};
diff --git a/remoting/host/event_executor_linux.cc b/remoting/host/event_executor_linux.cc
index dcc7dc0..f540d44 100644
--- a/remoting/host/event_executor_linux.cc
+++ b/remoting/host/event_executor_linux.cc
@@ -206,11 +206,6 @@ class EventExecutorLinuxPimpl {
void HandleKey(const KeyEvent* key_event);
private:
- void HandleMouseSetPosition(const MouseSetPositionEvent& position_event);
- void HandleMouseMove(const MouseMoveEvent& move_event);
- void HandleMouseWheel(const MouseWheelEvent& wheel_event);
- void HandleMouseButtonDown(const MouseDownEvent& mouse_down_event);
- void HandleMouseButtonUp(const MouseUpEvent& mouse_up_event);
void DeinitXlib();
// Reference to containing class so we can access friend functions.
@@ -290,75 +285,6 @@ bool EventExecutorLinuxPimpl::Init() {
return true;
}
-void EventExecutorLinuxPimpl::HandleMouse(
- const MouseEvent* mouse_event) {
- if (mouse_event->has_set_position()) {
- HandleMouseSetPosition(mouse_event->set_position());
- } else if (mouse_event->has_wheel()) {
- HandleMouseWheel(mouse_event->wheel());
- } else if (mouse_event->has_down()) {
- HandleMouseButtonDown(mouse_event->down());
- } else if (mouse_event->has_up()) {
- HandleMouseButtonUp(mouse_event->up());
- }
-}
-
-void EventExecutorLinuxPimpl::HandleMouseSetPosition(
- const MouseSetPositionEvent& position_event) {
- if (position_event.x() < 0 || position_event.y() < 0 ||
- position_event.x() > width_ || position_event.y() > height_) {
- // A misbehaving client may send these. Drop events that are out of range.
- // TODO(ajwong): How can we log this sanely? We don't want to DOS the server
- // with a misbehaving client by logging like crazy.
- return;
- }
-
- VLOG(3) << "Moving mouse to " << position_event.x()
- << "," << position_event.y();
- XTestFakeMotionEvent(display_, DefaultScreen(display_),
- position_event.x(), position_event.y(),
- CurrentTime);
-}
-void EventExecutorLinuxPimpl::HandleMouseMove(
- const MouseMoveEvent& move_event) {
- NOTIMPLEMENTED() << "We shouldn't be using relative moves.";
-}
-
-void EventExecutorLinuxPimpl::HandleMouseWheel(
- const MouseWheelEvent& wheel_event) {
- NOTIMPLEMENTED() << "No scroll wheel support yet.";
-}
-
-void EventExecutorLinuxPimpl::HandleMouseButtonDown(
- const MouseDownEvent& mouse_down_event) {
- int button_number = MouseButtonToX11ButtonNumber(mouse_down_event.button());
-
- if (button_number < 0) {
- LOG(WARNING) << "Ignoring unknown button type: "
- << mouse_down_event.button();
- return;
- }
-
- VLOG(3) << "Button " << mouse_down_event.button()
- << " received, sending down " << button_number;
- XTestFakeButtonEvent(display_, button_number, True, CurrentTime);
-}
-
-void EventExecutorLinuxPimpl::HandleMouseButtonUp(
- const MouseUpEvent& mouse_up_event) {
- int button_number = MouseButtonToX11ButtonNumber(mouse_up_event.button());
-
- if (button_number < 0) {
- LOG(WARNING) << "Ignoring unknown button type: "
- << mouse_up_event.button();
- return;
- }
-
- VLOG(3) << "Button " << mouse_up_event.button()
- << " received, sending up " << button_number;
- XTestFakeButtonEvent(display_, button_number, False, CurrentTime);
-}
-
void EventExecutorLinuxPimpl::HandleKey(const KeyEvent* key_event) {
// TODO(ajwong): This will only work for QWERTY keyboards.
int keysym = ChromotocolKeycodeToX11Keysym(key_event->key());
@@ -382,6 +308,43 @@ void EventExecutorLinuxPimpl::HandleKey(const KeyEvent* key_event) {
XTestFakeKeyEvent(display_, keycode, key_event->pressed(), CurrentTime);
}
+void EventExecutorLinuxPimpl::HandleMouse(const MouseEvent* event) {
+ if (event->has_x() && event->has_y()) {
+ if (event->x() < 0 || event->y() < 0 ||
+ event->x() > width_ || event->y() > height_) {
+ // A misbehaving client may send these. Drop events that are out of range.
+ // TODO(ajwong): How can we log this sanely? We don't want to DOS the
+ // server with a misbehaving client by logging like crazy.
+ return;
+ }
+
+ VLOG(3) << "Moving mouse to " << event->x()
+ << "," << event->y();
+ XTestFakeMotionEvent(display_, DefaultScreen(display_),
+ event->x(), event->y(),
+ CurrentTime);
+ }
+
+ if (event->has_button() && event->has_button_down()) {
+ int button_number = MouseButtonToX11ButtonNumber(event->button());
+
+ if (button_number < 0) {
+ LOG(WARNING) << "Ignoring unknown button type: "
+ << event->button();
+ return;
+ }
+
+ VLOG(3) << "Button " << event->button()
+ << " received, sending down " << button_number;
+ XTestFakeButtonEvent(display_, button_number, event->button_down(),
+ CurrentTime);
+ }
+
+ if (event->has_wheel_offset_x() && event->has_wheel_offset_y()) {
+ NOTIMPLEMENTED() << "No scroll wheel support yet.";
+ }
+}
+
void EventExecutorLinuxPimpl::DeinitXlib() {
// TODO(ajwong): We should expose a "close" or "shutdown" method.
if (gc_) {
diff --git a/remoting/host/event_executor_win.cc b/remoting/host/event_executor_win.cc
index 9cabeb1..f79d9eb 100644
--- a/remoting/host/event_executor_win.cc
+++ b/remoting/host/event_executor_win.cc
@@ -16,7 +16,8 @@ namespace remoting {
EventExecutorWin::EventExecutorWin(
MessageLoop* message_loop, Capturer* capturer)
- : message_loop_(message_loop), capturer_(capturer) {
+ : message_loop_(message_loop),
+ capturer_(capturer) {
}
EventExecutorWin::~EventExecutorWin() {
@@ -30,7 +31,7 @@ void EventExecutorWin::InjectKeyEvent(const KeyEvent* event, Task* done) {
event, done));
return;
}
- HandleKey(*event);
+ HandleKey(event);
done->Run();
delete done;
}
@@ -44,111 +45,14 @@ void EventExecutorWin::InjectMouseEvent(const MouseEvent* event,
event, done));
return;
}
- if (event->has_set_position()) {
- HandleMouseSetPosition(event->set_position());
- } else if (event->has_wheel()) {
- HandleMouseWheel(event->wheel());
- } else if (event->has_down()) {
- HandleMouseButtonDown(event->down());
- } else if (event->has_up()) {
- HandleMouseButtonUp(event->up());
- }
+ HandleMouse(event);
done->Run();
delete done;
}
-void EventExecutorWin::HandleMouseSetPosition(
- const MouseSetPositionEvent& event) {
- int x = event.x();
- int y = event.y();
- int width = event.width();
- int height = event.height();
-
- // Get width and height from the capturer if they are missing from the
- // message.
- if (width == 0 || height == 0) {
- width = capturer_->width();
- height = capturer_->height();
- }
- if (width == 0 || height == 0) {
- return;
- }
-
- INPUT input;
- input.type = INPUT_MOUSE;
- input.mi.time = 0;
- input.mi.dx = static_cast<int>((x * 65535) / width);
- input.mi.dy = static_cast<int>((y * 65535) / height);
- input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
- SendInput(1, &input, sizeof(INPUT));
-}
-
-void EventExecutorWin::HandleMouseWheel(
- const MouseWheelEvent& event) {
- INPUT input;
- input.type = INPUT_MOUSE;
- input.mi.time = 0;
-
- int dx = event.offset_x();
- int dy = event.offset_y();
-
- if (dx != 0) {
- input.mi.mouseData = dx;
- input.mi.dwFlags = MOUSEEVENTF_HWHEEL;
- SendInput(1, &input, sizeof(INPUT));
- }
- if (dy != 0) {
- input.mi.mouseData = dy;
- input.mi.dwFlags = MOUSEEVENTF_WHEEL;
- SendInput(1, &input, sizeof(INPUT));
- }
-}
-
-void EventExecutorWin::HandleMouseButtonDown(const MouseDownEvent& event) {
- INPUT input;
- input.type = INPUT_MOUSE;
- input.mi.time = 0;
- input.mi.dx = 0;
- input.mi.dy = 0;
-
- MouseButton button = event.button();
- if (button == MouseButtonLeft) {
- input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
- } else if (button == MouseButtonMiddle) {
- input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
- } else if (button == MouseButtonRight) {
- input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
- } else {
- input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
- }
-
- SendInput(1, &input, sizeof(INPUT));
-}
-
-void EventExecutorWin::HandleMouseButtonUp(const MouseUpEvent& event) {
- INPUT input;
- input.type = INPUT_MOUSE;
- input.mi.time = 0;
- input.mi.dx = 0;
- input.mi.dy = 0;
-
- MouseButton button = event.button();
- if (button == MouseButtonLeft) {
- input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
- } else if (button == MouseButtonMiddle) {
- input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
- } else if (button == MouseButtonRight) {
- input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
- } else {
- input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
- }
-
- SendInput(1, &input, sizeof(INPUT));
-}
-
-void EventExecutorWin::HandleKey(const KeyEvent& event) {
- int key = event.key();
- bool down = event.pressed();
+void EventExecutorWin::HandleKey(const KeyEvent* event) {
+ int key = event->key();
+ bool down = event->pressed();
// Calculate scan code from virtual key.
HKL hkl = GetKeyboardLayout(0);
@@ -179,4 +83,67 @@ protocol::InputStub* CreateEventExecutor(MessageLoop* message_loop,
return new EventExecutorWin(message_loop, capturer);
}
+void EventExecutorWin::HandleMouse(const MouseEvent* event) {
+ // TODO(garykac) Collapse mouse (x,y) and button events into a single
+ // input event when possible.
+ if (event->has_x() && event->has_y()) {
+ int x = event->x();
+ int y = event->y();
+
+ INPUT input;
+ input.type = INPUT_MOUSE;
+ input.mi.time = 0;
+ input.mi.dx = static_cast<int>((x * 65535) / capturer_->width());
+ input.mi.dy = static_cast<int>((y * 65535) / capturer_->height());
+ input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
+ SendInput(1, &input, sizeof(INPUT));
+ }
+
+ if (event->has_wheel_offset_x() && event->has_wheel_offset_y()) {
+ INPUT wheel;
+ wheel.type = INPUT_MOUSE;
+ wheel.mi.time = 0;
+
+ int dx = event->wheel_offset_x();
+ int dy = event->wheel_offset_y();
+
+ if (dx != 0) {
+ wheel.mi.mouseData = dx;
+ wheel.mi.dwFlags = MOUSEEVENTF_HWHEEL;
+ SendInput(1, &wheel, sizeof(INPUT));
+ }
+ if (dy != 0) {
+ wheel.mi.mouseData = dy;
+ wheel.mi.dwFlags = MOUSEEVENTF_WHEEL;
+ SendInput(1, &wheel, sizeof(INPUT));
+ }
+ }
+
+ if (event->has_button() && event->has_button_down()) {
+ INPUT button_event;
+ button_event.type = INPUT_MOUSE;
+ button_event.mi.time = 0;
+ button_event.mi.dx = 0;
+ button_event.mi.dy = 0;
+
+ MouseButton button = event->button();
+ bool down = event->button_down();
+ if (button == MouseButtonLeft) {
+ button_event.mi.dwFlags =
+ down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
+ } else if (button == MouseButtonMiddle) {
+ button_event.mi.dwFlags =
+ down ? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP;
+ } else if (button == MouseButtonRight) {
+ button_event.mi.dwFlags =
+ down ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
+ } else {
+ button_event.mi.dwFlags =
+ down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
+ }
+
+ SendInput(1, &button_event, sizeof(INPUT));
+ }
+}
+
} // namespace remoting
diff --git a/remoting/host/event_executor_win.h b/remoting/host/event_executor_win.h
index 3e2ddc6..b7be3c8 100644
--- a/remoting/host/event_executor_win.h
+++ b/remoting/host/event_executor_win.h
@@ -15,11 +15,7 @@
namespace remoting {
-class KeyEvent;
-class MouseDownEvent;
-class MouseSetPositionEvent;
-class MouseUpEvent;
-class MouseWheelEvent;
+class EventExecutorWinPimpl;
// A class to generate events on Windows.
class EventExecutorWin : public protocol::InputStub {
@@ -31,11 +27,8 @@ class EventExecutorWin : public protocol::InputStub {
virtual void InjectMouseEvent(const MouseEvent* event, Task* done);
private:
- void HandleMouseSetPosition(const MouseSetPositionEvent& event);
- void HandleMouseWheel(const MouseWheelEvent& event);
- void HandleMouseButtonDown(const MouseDownEvent& event);
- void HandleMouseButtonUp(const MouseUpEvent& event);
- void HandleKey(const KeyEvent& event);
+ void HandleKey(const KeyEvent* event);
+ void HandleMouse(const MouseEvent* event);
MessageLoop* message_loop_;
Capturer* capturer_;
diff --git a/remoting/proto/event.proto b/remoting/proto/event.proto
index f6ca3f9..887f77f 100644
--- a/remoting/proto/event.proto
+++ b/remoting/proto/event.proto
@@ -18,35 +18,6 @@ message KeyEvent {
required bool pressed = 2;
}
-// Sets the absolute position of the mouse cursor.
-// dimension of the screen area.
-// NEXT ID: 3
-message MouseSetPositionEvent {
- required int32 x = 1;
- required int32 y = 2;
-
- // Windows sets absolute mouse pointer positions as a relative value to
- // the screen size. So pass the screen size to make this calculation easier.
- optional int32 width = 3;
- optional int32 height = 4;
-}
-
-// Adjust the position of the mouse cursor by an offset.
-// NEXT ID: 3
-message MouseMoveEvent {
- required int32 offset_x = 1;
- required int32 offset_y = 2;
-}
-
-// Motion of the mouse wheel.
-// TODO(garykac): What are units here? How many units correspond to a single
-// wheel click? On Windows, one click (WHEEL_DELTA) is 120 wheel units.
-// NEXT ID: 3
-message MouseWheelEvent {
- required int32 offset_x = 1;
- required int32 offset_y = 2;
-}
-
enum MouseButton {
MouseButtonUndefined = 0;
MouseButtonLeft = 1;
@@ -54,31 +25,19 @@ enum MouseButton {
MouseButtonRight = 3;
}
-// Mouse button is pressed down.
-// NEXT ID: 2
-message MouseDownEvent {
- required MouseButton button = 1;
-}
-
-// Mouse button is released.
-// NEXT ID: 2
-message MouseUpEvent {
- required MouseButton button = 1;
-}
-
// Defines a mouse event message on the event channel.
message MouseEvent {
// Mouse position information.
- optional MouseSetPositionEvent set_position = 1;
+ optional int32 x = 1;
+ optional int32 y = 2;
// Mouse wheel information.
- optional MouseWheelEvent wheel = 2;
-
- // Mouse down event.
- optional MouseDownEvent down = 3;
+ optional int32 wheel_offset_x = 3;
+ optional int32 wheel_offset_y = 4;
- // Mouse up event.
- optional MouseUpEvent up = 4;
+ // Mouse button event.
+ optional MouseButton button = 5;
+ optional bool button_down = 6;
}
// Defines an event message on the event channel.
diff --git a/remoting/proto/internal.proto b/remoting/proto/internal.proto
index a22ab632..6949375 100644
--- a/remoting/proto/internal.proto
+++ b/remoting/proto/internal.proto
@@ -15,13 +15,8 @@ option optimize_for = LITE_RUNTIME;
package remoting;
-// Defines the message that is sent from the client to the host.
-// Only one of the optional messages should be present.
+// TODO(garykac) This is dead, remove remaining references and delete.
message ChromotingClientMessage {
optional KeyEvent key_event = 1;
- optional MouseSetPositionEvent mouse_set_position_event = 2;
- optional MouseMoveEvent mouse_move_event = 3;
- optional MouseWheelEvent mouse_wheel_event = 4;
- optional MouseDownEvent mouse_down_event = 5;
- optional MouseUpEvent mouse_up_event = 6;
+ optional MouseEvent mouse_event = 2;
}
diff --git a/remoting/protocol/buffered_socket_writer.cc b/remoting/protocol/buffered_socket_writer.cc
index 555d4e6..0cf39bc 100644
--- a/remoting/protocol/buffered_socket_writer.cc
+++ b/remoting/protocol/buffered_socket_writer.cc
@@ -24,9 +24,11 @@ BufferedSocketWriterBase::~BufferedSocketWriterBase() { }
void BufferedSocketWriterBase::Init(net::Socket* socket,
WriteFailedCallback* callback) {
+ // TODO(garykac) Save copy of WriteFailedCallback.
AutoLock auto_lock(lock_);
message_loop_ = MessageLoop::current();
socket_ = socket;
+ DCHECK(socket_);
}
bool BufferedSocketWriterBase::Write(
diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc
new file mode 100644
index 0000000..162dfdf
--- /dev/null
+++ b/remoting/protocol/connection_to_host.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/protocol/connection_to_host.h"
+
+#include "base/callback.h"
+#include "base/message_loop.h"
+#include "remoting/base/constants.h"
+#include "remoting/jingle_glue/jingle_thread.h"
+#include "remoting/protocol/client_stub.h"
+#include "remoting/protocol/jingle_session_manager.h"
+#include "remoting/protocol/video_reader.h"
+#include "remoting/protocol/video_stub.h"
+#include "remoting/protocol/util.h"
+
+namespace remoting {
+namespace protocol {
+
+ConnectionToHost::ConnectionToHost() {
+}
+
+ConnectionToHost::~ConnectionToHost() {
+}
+
+InputStub* ConnectionToHost::input_stub() {
+ return input_stub_.get();
+}
+
+HostStub* ConnectionToHost::host_stub() {
+ return host_stub_.get();
+}
+
+} // namespace protocol
+} // namespace remoting
diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h
index d34b9ee..0d1c602 100644
--- a/remoting/protocol/connection_to_host.h
+++ b/remoting/protocol/connection_to_host.h
@@ -10,10 +10,14 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "remoting/proto/internal.pb.h"
+#include "remoting/protocol/host_stub.h"
+#include "remoting/protocol/input_stub.h"
+#include "remoting/protocol/stream_writer.h"
namespace remoting {
namespace protocol {
+class ClientStub;
class SessionConfig;
class VideoStub;
@@ -33,23 +37,48 @@ class ConnectionToHost {
virtual void OnConnectionFailed(ConnectionToHost* conn) = 0;
};
- virtual ~ConnectionToHost() {}
+ virtual ~ConnectionToHost();
// TODO(ajwong): We need to generalize this API.
virtual void Connect(const std::string& username,
const std::string& auth_token,
const std::string& host_jid,
HostEventCallback* event_callback,
+ ClientStub* client_stub,
VideoStub* video_stub) = 0;
virtual void Disconnect() = 0;
virtual const SessionConfig* config() = 0;
- // Send an input event to the host.
- virtual void SendEvent(const ChromotingClientMessage& msg) = 0;
+ virtual InputStub* input_stub();
+
+ virtual HostStub* host_stub();
protected:
- ConnectionToHost() {}
+ ConnectionToHost();
+
+ //private: TODO(garykac). Merge jingle_connection_to_host up into this class
+ // and then make these private again.
+ ////////////////////////////////////////////////////////////////////////////
+ // User input event channel interface
+
+ // Stub for sending input event messages to the host.
+ scoped_ptr<InputStub> input_stub_;
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Protocol control channel interface
+
+ // Stub for sending control messages to the host.
+ scoped_ptr<HostStub> host_stub_;
+
+ // Stub for receiving control messages from the host.
+ ClientStub* client_stub_;
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Video channel interface
+
+ // Stub for receiving video packets from the host.
+ VideoStub* video_stub_;
private:
DISALLOW_COPY_AND_ASSIGN(ConnectionToHost);
diff --git a/remoting/protocol/input_sender.cc b/remoting/protocol/input_sender.cc
index d7d5236..e45149e 100644
--- a/remoting/protocol/input_sender.cc
+++ b/remoting/protocol/input_sender.cc
@@ -17,6 +17,8 @@ namespace protocol {
InputSender::InputSender(net::Socket* socket)
: buffered_writer_(new BufferedSocketWriter()) {
+ // TODO(garykac) Set write failed callback.
+ DCHECK(socket);
buffered_writer_->Init(socket, NULL);
}
diff --git a/remoting/protocol/jingle_connection_to_host.cc b/remoting/protocol/jingle_connection_to_host.cc
index a11a8fb..a551f17 100644
--- a/remoting/protocol/jingle_connection_to_host.cc
+++ b/remoting/protocol/jingle_connection_to_host.cc
@@ -9,6 +9,8 @@
#include "remoting/base/constants.h"
#include "remoting/jingle_glue/jingle_thread.h"
#include "remoting/proto/auth.pb.h"
+#include "remoting/protocol/client_stub.h"
+#include "remoting/protocol/input_sender.h"
#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/video_reader.h"
#include "remoting/protocol/video_stub.h"
@@ -29,6 +31,7 @@ void JingleConnectionToHost::Connect(const std::string& username,
const std::string& auth_token,
const std::string& host_jid,
HostEventCallback* event_callback,
+ ClientStub* client_stub,
VideoStub* video_stub) {
event_callback_ = event_callback;
video_stub_ = video_stub;
@@ -52,7 +55,6 @@ void JingleConnectionToHost::Disconnect() {
}
control_reader_.Close();
- event_writer_.Close();
video_reader_->Close();
if (session_) {
@@ -126,11 +128,6 @@ const SessionConfig* JingleConnectionToHost::config() {
return session_->config();
}
-void JingleConnectionToHost::SendEvent(const ChromotingClientMessage& msg) {
- // This drops the message if we are not connected yet.
- event_writer_.SendMessage(msg);
-}
-
// JingleClient::Callback interface.
void JingleConnectionToHost::OnStateChange(JingleClient* client,
JingleClient::State state) {
@@ -173,9 +170,9 @@ void JingleConnectionToHost::OnSessionStateChange(
control_reader_.Init<ControlMessage>(
session_->control_channel(),
NewCallback(this, &JingleConnectionToHost::OnControlMessage));
- event_writer_.Init(session_->event_channel());
video_reader_.reset(VideoReader::Create(session_->config()));
video_reader_->Init(session_, video_stub_);
+ input_stub_.reset(new InputSender(session_->event_channel()));
event_callback_->OnConnectionOpened(this);
break;
diff --git a/remoting/protocol/jingle_connection_to_host.h b/remoting/protocol/jingle_connection_to_host.h
index c25d872..b006022 100644
--- a/remoting/protocol/jingle_connection_to_host.h
+++ b/remoting/protocol/jingle_connection_to_host.h
@@ -52,13 +52,12 @@ class JingleConnectionToHost : public ConnectionToHost,
const std::string& auth_token,
const std::string& host_jid,
HostEventCallback* event_callback,
+ ClientStub* client_stub,
VideoStub* video_stub);
virtual void Disconnect();
virtual const SessionConfig* config();
- virtual void SendEvent(const ChromotingClientMessage& msg);
-
// JingleClient::Callback interface.
virtual void OnStateChange(JingleClient* client, JingleClient::State state);
@@ -96,7 +95,6 @@ class JingleConnectionToHost : public ConnectionToHost,
scoped_refptr<protocol::Session> session_;
MessageReader control_reader_;
- EventStreamWriter event_writer_;
scoped_ptr<VideoReader> video_reader_;
HostEventCallback* event_callback_;
diff --git a/remoting/protocol/message_decoder.h b/remoting/protocol/message_decoder.h
index 1978dc2..d2ba80a 100644
--- a/remoting/protocol/message_decoder.h
+++ b/remoting/protocol/message_decoder.h
@@ -16,13 +16,6 @@
namespace remoting {
-class ChromotingClientMessage;
-class ChromotingHostMessage;
-class ClientControlMessage;
-class ClientEventMessage;
-class HostControlMessage;
-class HostEventMessage;
-
// MessageDecoder uses CompoundBuffer to decode bytes into protocol
// buffer messages. This can be used to decode bytes received from the
// network.
diff --git a/remoting/protocol/message_reader.h b/remoting/protocol/message_reader.h
index 44e6a5c..93a7f92 100644
--- a/remoting/protocol/message_reader.h
+++ b/remoting/protocol/message_reader.h
@@ -20,8 +20,6 @@ class Socket;
namespace remoting {
class ChromotocolConnection;
-class ChromotingClientMessage;
-class ChromotingHostMessage;
class MessageReader;
namespace internal {
diff --git a/remoting/protocol/stream_writer.cc b/remoting/protocol/stream_writer.cc
index 9e1ddd4..4ceb1c4 100644
--- a/remoting/protocol/stream_writer.cc
+++ b/remoting/protocol/stream_writer.cc
@@ -35,7 +35,7 @@ void StreamWriterBase::Close() {
buffered_writer_->Close();
}
-bool EventStreamWriter::SendMessage(const ChromotingClientMessage& message) {
+bool EventStreamWriter::SendMessage(const EventMessage& message) {
return buffered_writer_->Write(SerializeAndFrameMessage(message));
}
diff --git a/remoting/protocol/stream_writer.h b/remoting/protocol/stream_writer.h
index 15b9bdd..dbf026c 100644
--- a/remoting/protocol/stream_writer.h
+++ b/remoting/protocol/stream_writer.h
@@ -43,7 +43,7 @@ class EventStreamWriter : public StreamWriterBase {
public:
// Sends the |message| or returns false if called before Init().
// Can be called on any thread.
- bool SendMessage(const ChromotingClientMessage& message);
+ bool SendMessage(const EventMessage& message);
};
class ControlStreamWriter : public StreamWriterBase {
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 91dd1c0..e46154b 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -365,6 +365,7 @@
'protocol/client_stub.h',
'protocol/connection_to_client.cc',
'protocol/connection_to_client.h',
+ 'protocol/connection_to_host.cc',
'protocol/connection_to_host.h',
'protocol/host_control_message_handler.h',
'protocol/host_event_message_handler.h',