diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-23 23:19:38 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-23 23:19:38 +0000 |
commit | c594137d5eb27a988d98dede8ff9a920f25733de (patch) | |
tree | cb02597bdbe244ca5e0fd9b678360c3252bd32e8 | |
parent | 139d147a5b334e7693c26e37a1e039a110b2ee2d (diff) | |
download | chromium_src-c594137d5eb27a988d98dede8ff9a920f25733de.zip chromium_src-c594137d5eb27a988d98dede8ff9a920f25733de.tar.gz chromium_src-c594137d5eb27a988d98dede8ff9a920f25733de.tar.bz2 |
Remove remoting_x11_client
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/7243014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90289 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | remoting/client/client_util.cc | 81 | ||||
-rw-r--r-- | remoting/client/client_util.h | 21 | ||||
-rw-r--r-- | remoting/client/client_util_unittest.cc | 19 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 1 | ||||
-rw-r--r-- | remoting/client/x11_client.cc | 56 | ||||
-rw-r--r-- | remoting/client/x11_input_handler.cc | 108 | ||||
-rw-r--r-- | remoting/client/x11_input_handler.h | 44 | ||||
-rw-r--r-- | remoting/client/x11_view.cc | 218 | ||||
-rw-r--r-- | remoting/client/x11_view.h | 71 | ||||
-rw-r--r-- | remoting/remoting.gyp | 34 |
10 files changed, 0 insertions, 653 deletions
diff --git a/remoting/client/client_util.cc b/remoting/client/client_util.cc deleted file mode 100644 index 1a292be..0000000 --- a/remoting/client/client_util.cc +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2011 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/client/client_util.h" - -#include <string> -#include <vector> - -#include "base/logging.h" -#include "base/string_util.h" -#include "remoting/base/constants.h" -#include "remoting/client/client_config.h" - -using std::string; -using std::vector; - -namespace remoting { - -// Get host JID from command line arguments, or stdin if not specified. -bool GetLoginInfoFromArgs(int argc, char** argv, ClientConfig* config) { - bool found_host_jid = false; - bool found_jid = false; - bool found_auth_token = false; - string host_jid; - string username; - string auth_token; - string auth_service(kChromotingTokenDefaultServiceName); - - for (int i = 1; i < argc; i++) { - std::string arg = argv[i]; - if (arg == "--host_jid") { - if (++i >= argc) { - LOG(WARNING) << "Expected Host JID to follow --host_jid option"; - } else { - found_host_jid = true; - host_jid = argv[i]; - } - } else if (arg == "--jid") { - if (++i >= argc) { - LOG(WARNING) << "Expected JID to follow --jid option"; - } else { - found_jid = true; - username = argv[i]; - } - } else if (arg == "--token") { - if (++i >= argc) { - LOG(WARNING) << "Expected Auth token to follow --token option"; - } else { - found_auth_token = true; - auth_token = argv[i]; - } - } else if (arg == "--service") { - if (++i >= argc) { - LOG(WARNING) << "Expected service name to follow --service option"; - } else { - auth_service = argv[i]; - } - } else { - LOG(WARNING) << "Unrecognized option: " << arg; - } - } - - if (!found_host_jid) - return false; - - // Validate the chromoting host JID. - if ((host_jid.find("/chromoting") == std::string::npos) || !found_jid || - !found_auth_token) - return false; - - NOTIMPLEMENTED() << "Nonce ignored."; - - config->host_jid = host_jid; - config->xmpp_username = username; - config->xmpp_auth_token = auth_token; - config->xmpp_auth_service = auth_service; - return true; -} - -} // namespace remoting diff --git a/remoting/client/client_util.h b/remoting/client/client_util.h deleted file mode 100644 index 3660563..0000000 --- a/remoting/client/client_util.h +++ /dev/null @@ -1,21 +0,0 @@ -// 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. - -#ifndef REMOTING_CLIENT_CLIENT_UTIL_H_ -#define REMOTING_CLIENT_CLIENT_UTIL_H_ - -#include <string> - -namespace remoting { - -struct ClientConfig; - -// Get the login info from the cmdline args (or request from the console if -// not present) and write values into |config|. -// Return true if successful. -bool GetLoginInfoFromArgs(int argc, char** argv, ClientConfig* config); - -} // namespace remoting - -#endif // REMOTING_CLIENT_CLIENT_UTIL_H_ diff --git a/remoting/client/client_util_unittest.cc b/remoting/client/client_util_unittest.cc deleted file mode 100644 index cb1bba6..0000000 --- a/remoting/client/client_util_unittest.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2011 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 "base/memory/scoped_ptr.h" -#include "remoting/client/client_config.h" -#include "remoting/client/client_util.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace remoting { - -// TODO(ajwong): Fill this out. -class ClientUtilTest : public testing::Test { - protected: - virtual void SetUp() { - } -}; - -} // namespace remoting diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index c961a6b..22d37d4 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -23,7 +23,6 @@ // TODO(wez): Remove this when crbug.com/86353 is complete. #include "ppapi/cpp/private/var_private.h" #include "remoting/client/client_config.h" -#include "remoting/client/client_util.h" #include "remoting/client/chromoting_client.h" #include "remoting/client/rectangle_update_decoder.h" #include "remoting/client/plugin/chromoting_scriptable_object.h" diff --git a/remoting/client/x11_client.cc b/remoting/client/x11_client.cc deleted file mode 100644 index f56d2b1..0000000 --- a/remoting/client/x11_client.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2011 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. -// -// This file implements a simple X11 chromoting client. - -#include <iostream> - -#include "base/at_exit.h" -#include "base/message_loop.h" -#include "remoting/client/chromoting_client.h" -#include "remoting/client/client_config.h" -#include "remoting/client/client_context.h" -#include "remoting/client/client_logger.h" -#include "remoting/client/client_util.h" -#include "remoting/client/rectangle_update_decoder.h" -#include "remoting/client/x11_view.h" -#include "remoting/client/x11_input_handler.h" -#include "remoting/protocol/connection_to_host.h" - -void ClientQuit(MessageLoop* loop) { - loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); -} - -int main(int argc, char** argv) { - base::AtExitManager at_exit; - - remoting::ClientConfig config; - if (!remoting::GetLoginInfoFromArgs(argc, argv, &config)) { - std::cout << "Unable to obtain login info" << std::endl; - return 1; - } - - MessageLoop ui_loop; - remoting::ClientContext context; - remoting::protocol::ConnectionToHost connection(context.jingle_thread(), - NULL, NULL, NULL); - remoting::X11View view; - scoped_refptr<remoting::RectangleUpdateDecoder> rectangle_decoder = - new remoting::RectangleUpdateDecoder(context.decode_message_loop(), - &view); - remoting::X11InputHandler input_handler(&context, &connection, &view); - remoting::ChromotingClient client( - config, &context, &connection, &view, rectangle_decoder, &input_handler, - new remoting::ClientLogger(), NewRunnableFunction(&ClientQuit, &ui_loop)); - - // Run the client on a new MessageLoop until - context.Start(); - client.Start(); - ui_loop.Run(); - - client.Stop(); - context.Stop(); - - return 0; -} diff --git a/remoting/client/x11_input_handler.cc b/remoting/client/x11_input_handler.cc deleted file mode 100644 index b7ee8df..0000000 --- a/remoting/client/x11_input_handler.cc +++ /dev/null @@ -1,108 +0,0 @@ -// 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/client/x11_input_handler.h" - -#include "base/message_loop.h" -#include "remoting/client/client_context.h" -#include "remoting/client/x11_view.h" -#include "remoting/jingle_glue/jingle_thread.h" - -// Include Xlib at the end because it clashes with Status in -// base/tracked_objects.h. -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -namespace remoting { - -using protocol::KeyEvent; -using protocol::MouseEvent; - -X11InputHandler::X11InputHandler(ClientContext* context, - protocol::ConnectionToHost* connection, - ChromotingView* view) - : InputHandler(context, connection, view) { -} - -X11InputHandler::~X11InputHandler() { -} - -void X11InputHandler::Initialize() { - ScheduleX11EventHandler(); -} - -void X11InputHandler::DoProcessX11Events() { - DCHECK_EQ(context_->jingle_thread()->message_loop(), MessageLoop::current()); - - Display* display = static_cast<X11View*>(view_)->display(); - if (XPending(display)) { - XEvent e; - XNextEvent(display, &e); - switch (e.type) { - case Expose: - // Tell the view to paint again. - view_->Paint(); - break; - case KeyPress: - case KeyRelease: - HandleKeyEvent(&e); - break; - case ButtonPress: - HandleMouseButtonEvent(true, e.xbutton.button); - HandleMouseMoveEvent(e.xbutton.x, e.xbutton.y); - break; - case ButtonRelease: - HandleMouseButtonEvent(false, e.xbutton.button); - HandleMouseMoveEvent(e.xbutton.x, e.xbutton.y); - break; - case MotionNotify: - SendMouseMoveEvent(e.xmotion.x, e.xmotion.y); - break; - default: - LOG(WARNING) << "Unknown event type: " << e.type; - } - } - - // Schedule the next event handler. - ScheduleX11EventHandler(); -} - -void X11InputHandler::ScheduleX11EventHandler() { - // Schedule a delayed task to process X11 events in 10ms. - static const int kProcessEventsInterval = 10; - context_->jingle_thread()->message_loop()->PostDelayedTask( - FROM_HERE, - NewRunnableMethod(this, &X11InputHandler::DoProcessX11Events), - kProcessEventsInterval); -} - -void X11InputHandler::HandleKeyEvent(void* event) { - XEvent* e = reinterpret_cast<XEvent*>(event); - char buffer[128]; - int buffsize = sizeof(buffer) - 1; - KeySym keysym; - XLookupString(&e->xkey, buffer, buffsize, &keysym, NULL); - SendKeyEvent(e->type == KeyPress, static_cast<int>(keysym)); -} - -void X11InputHandler::HandleMouseMoveEvent(int x, int y) { - SendMouseMoveEvent(x, y); -} - -void X11InputHandler::HandleMouseButtonEvent(bool button_down, int xbutton_id) { - MouseEvent::MouseButton button = MouseEvent::BUTTON_UNDEFINED; - if (xbutton_id == 1) { - button = MouseEvent::BUTTON_LEFT; - } else if (xbutton_id == 2) { - button = MouseEvent::BUTTON_MIDDLE; - } else if (xbutton_id == 3) { - button = MouseEvent::BUTTON_RIGHT; - } - - if (button != MouseEvent::BUTTON_UNDEFINED) { - SendMouseButtonEvent(button_down, button); - } -} - -} // namespace remoting diff --git a/remoting/client/x11_input_handler.h b/remoting/client/x11_input_handler.h deleted file mode 100644 index bd556ff..0000000 --- a/remoting/client/x11_input_handler.h +++ /dev/null @@ -1,44 +0,0 @@ -// 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. - -#ifndef REMOTING_CLIENT_X11_INPUT_HANDLER_H_ -#define REMOTING_CLIENT_X11_INPUT_HANDLER_H_ - -#include "remoting/client/input_handler.h" - -namespace remoting { - -class ClientContext; -class ChromotingView; - -class X11InputHandler : public InputHandler { - public: - X11InputHandler(ClientContext* context, - protocol::ConnectionToHost* connection, - ChromotingView* view); - virtual ~X11InputHandler(); - - virtual void Initialize(); - - private: - - void DoProcessX11Events(); - - void ScheduleX11EventHandler(); - - // This is really an XEvent, but if we include Xlib.h in this file, it will - // cause conflicts with other headers. See note at top of - // x11_input_handler.cc. - void HandleKeyEvent(void* event); - void HandleMouseMoveEvent(int x, int y); - void HandleMouseButtonEvent(bool button_down, int xbutton_id); - - DISALLOW_COPY_AND_ASSIGN(X11InputHandler); -}; - -} // namespace remoting - -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::X11InputHandler); - -#endif // REMOTING_CLIENT_X11_INPUT_HANDLER_H_ diff --git a/remoting/client/x11_view.cc b/remoting/client/x11_view.cc deleted file mode 100644 index a7501d8..0000000 --- a/remoting/client/x11_view.cc +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (c) 2011 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/client/x11_view.h" - -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/extensions/Xrender.h> -#include <X11/extensions/Xcomposite.h> - -#include "base/logging.h" -#include "base/task.h" - -namespace remoting { - -X11View::X11View() - : display_(NULL), - window_(0), - picture_(0) { -} - -X11View::~X11View() { - DCHECK(!display_); - DCHECK(!window_); -} - -bool X11View::Initialize() { - display_ = XOpenDisplay(NULL); - if (!display_) { - return false; - } - - // Get properties of the screen. - int screen = DefaultScreen(display_); - int root_window = RootWindow(display_, screen); - - // Creates the window. - window_ = XCreateSimpleWindow(display_, root_window, 1, 1, 640, 480, 0, - BlackPixel(display_, screen), - BlackPixel(display_, screen)); - DCHECK(window_); - XStoreName(display_, window_, "X11 Remoting"); - - // Specifies what kind of messages we want to receive. - XSelectInput(display_, - window_, - ExposureMask - | KeyPressMask | KeyReleaseMask - | ButtonPressMask | ButtonReleaseMask - | PointerMotionMask); - - XMapWindow(display_, window_); - return true; -} - -void X11View::TearDown() { - if (display_ && window_) { - // Shutdown the window system. - XDestroyWindow(display_, window_); - XCloseDisplay(display_); - } - display_ = NULL; - window_ = 0; -} - -void X11View::Paint() { - NOTIMPLEMENTED() << "Not sure if we need this call anymore."; -} - -void X11View::PaintRect(media::VideoFrame* frame, const gfx::Rect& clip) { - // Don't bother attempting to paint if the display hasn't been set up. - if (!display_ || !window_ || !frame) { - return; - } - - // If we have not initialized the render target then do it now. - if (!picture_) - InitPaintTarget(); - - // Upload the image to a pixmap. And then create a picture from the pixmap - // and composite the picture over the picture representing the window. - - // Creates a XImage. - XImage image; - memset(&image, 0, sizeof(image)); - image.width = frame->width(); - image.height = frame->height(); - image.depth = 32; - image.bits_per_pixel = 32; - image.format = ZPixmap; - image.byte_order = LSBFirst; - image.bitmap_unit = 8; - image.bitmap_bit_order = LSBFirst; - image.bytes_per_line = frame_->stride(media::VideoFrame::kRGBPlane); - image.red_mask = 0xff; - image.green_mask = 0xff00; - image.blue_mask = 0xff0000; - image.data = reinterpret_cast<char*>( - frame_->data(media::VideoFrame::kRGBPlane)); - - // Creates a pixmap and uploads from the XImage. - unsigned long pixmap = XCreatePixmap(display_, window_, - frame->width(), frame->height(), 32); - - GC gc = XCreateGC(display_, pixmap, 0, NULL); - XPutImage(display_, pixmap, gc, &image, clip.x(), clip.y(), - clip.x(), clip.y(), clip.width(), clip.height()); - XFreeGC(display_, gc); - - // Creates the picture representing the pixmap. - XID picture = XRenderCreatePicture( - display_, pixmap, - XRenderFindStandardFormat(display_, PictStandardARGB32), - 0, NULL); - - // Composite the picture over the picture representing the window. - XRenderComposite(display_, PictOpSrc, picture, 0, - picture_, 0, 0, 0, 0, clip.x(), clip.y(), - clip.width(), clip.height()); - - XRenderFreePicture(display_, picture); - XFreePixmap(display_, pixmap); -} - -void X11View::SetSolidFill(uint32 color) { - // TODO(garykac): Implement. - // NOTIMPLEMENTED(); -} - -void X11View::UnsetSolidFill() { - // TODO(garykac): Implement. - // NOTIMPLEMENTED(); -} - -void X11View::SetConnectionState(ConnectionState s) { - // TODO(garykac): Implement. -} - -void X11View::UpdateLoginStatus(bool success, const std::string& info) { - NOTIMPLEMENTED(); -} - -void X11View::SetViewport(int x, int y, int width, int height) { - // TODO(garykac): Implement. -} - -gfx::Point X11View::ConvertScreenToHost(const gfx::Point& p) const { - return p; -} - -void X11View::InitPaintTarget() { - // Testing XRender support. - int dummy; - bool xrender_support = XRenderQueryExtension(display_, &dummy, &dummy); - CHECK(xrender_support) << "XRender is not supported!"; - - XWindowAttributes attr; - XGetWindowAttributes(display_, window_, &attr); - - XRenderPictFormat* pictformat = XRenderFindVisualFormat( - display_, - attr.visual); - CHECK(pictformat) << "XRENDER does not support default visual"; - - picture_ = XRenderCreatePicture(display_, window_, pictformat, 0, NULL); - CHECK(picture_) << "Backing picture not created"; -} - -void X11View::AllocateFrame(media::VideoFrame::Format format, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, - scoped_refptr<media::VideoFrame>* frame_out, - Task* done) { - // TODO(ajwong): Implement this to use the native X window rather than - // just a generic frame buffer. - media::VideoFrame::CreateFrame(media::VideoFrame::RGB32, - width, height, - base::TimeDelta(), base::TimeDelta(), - frame_out); - if (*frame_out) { - (*frame_out)->AddRef(); - } - done->Run(); - delete done; -} - -void X11View::ReleaseFrame(media::VideoFrame* frame) { - if (frame) { - LOG(WARNING) << "Frame released."; - frame->Release(); - } -} - -void X11View::OnPartialFrameOutput(media::VideoFrame* frame, - UpdatedRects* rects, - Task* done) { - // TODO(hclam): Make sure we call this method on the right thread. Since - // decoder is single-threaded we don't have a problem but we better post - // a task to do the right thing. - - for (UpdatedRects::iterator it = rects->begin(); it != rects->end(); ++it) { - PaintRect(frame, *it); - } - - // TODO(ajwong): Shouldn't we only expose the part of the window that was - // damanged? - XEvent event; - event.type = Expose; - XSendEvent(display_, static_cast<int>(window_), true, ExposureMask, &event); - - done->Run(); - delete done; -} - -} // namespace remoting diff --git a/remoting/client/x11_view.h b/remoting/client/x11_view.h deleted file mode 100644 index 963e9b8..0000000 --- a/remoting/client/x11_view.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef REMOTING_CLIENT_X11_VIEW_H_ -#define REMOTING_CLIENT_X11_VIEW_H_ - -#include "base/memory/scoped_ptr.h" -#include "base/task.h" -#include "media/base/video_frame.h" -#include "remoting/base/decoder.h" // For UpdatedRects -#include "remoting/client/chromoting_view.h" -#include "remoting/client/frame_consumer.h" - -typedef unsigned long XID; -typedef struct _XDisplay Display; - -namespace remoting { - -// A ChromotingView implemented using X11 and XRender. -class X11View : public ChromotingView, public FrameConsumer { - public: - X11View(); - virtual ~X11View(); - - // ChromotingView implementations. - virtual bool Initialize() OVERRIDE; - virtual void TearDown() OVERRIDE; - virtual void Paint() OVERRIDE; - virtual void SetSolidFill(uint32 color) OVERRIDE; - virtual void UnsetSolidFill() OVERRIDE; - virtual void SetConnectionState(ConnectionState s) OVERRIDE; - virtual void UpdateLoginStatus(bool success, const std::string& info) - OVERRIDE; - virtual void SetViewport(int x, int y, int width, int height) OVERRIDE; - virtual gfx::Point ConvertScreenToHost(const gfx::Point& p) const OVERRIDE; - - // FrameConsumer implementation. - virtual void AllocateFrame(media::VideoFrame::Format format, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, - scoped_refptr<media::VideoFrame>* frame_out, - Task* done); - virtual void ReleaseFrame(media::VideoFrame* frame); - virtual void OnPartialFrameOutput(media::VideoFrame* frame, - UpdatedRects* rects, - Task* done); - - Display* display() { return display_; } - - private: - void InitPaintTarget(); - void PaintRect(media::VideoFrame* frame, const gfx::Rect& clip); - - Display* display_; - XID window_; - - // A picture created in the X server that represents drawing area of the - // window. - XID picture_; - - DISALLOW_COPY_AND_ASSIGN(X11View); -}; - -} // namespace remoting - -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::X11View); - -#endif // REMOTING_CLIENT_X11_VIEW_H_ diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index da649ef..0be1a37 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -77,38 +77,6 @@ } ], # end of target 'remoting_client_test_webserver' }], - - # TODO(hclam): Enable this target for mac. - ['use_x11 == 1', { - - 'targets': [ - { - 'target_name': 'remoting_x11_client', - 'type': 'executable', - 'dependencies': [ - 'remoting_base', - 'remoting_client', - 'remoting_jingle_glue', - '../media/media.gyp:media', - ], - 'link_settings': { - 'libraries': [ - '-ldl', - '-lX11', - '-lXrender', - '-lXext', - ], - }, - 'sources': [ - 'client/x11_client.cc', - 'client/x11_input_handler.cc', - 'client/x11_input_handler.h', - 'client/x11_view.cc', - 'client/x11_view.h', - ], - }, # end of target 'remoting_x11_client' - ], - }], # end of OS conditions for x11 client ], # end of 'conditions' 'targets': [ @@ -469,8 +437,6 @@ 'client/client_context.h', 'client/client_logger.cc', 'client/client_logger.h', - 'client/client_util.cc', - 'client/client_util.h', 'client/frame_consumer.h', 'client/input_handler.cc', 'client/input_handler.h', |