summaryrefslogtreecommitdiffstats
path: root/remoting/client/client_util.cc
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 21:56:39 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 21:56:39 +0000
commitef0a59a6fd722a0910196c951dc676c19127a28b (patch)
tree9d90ab9227e4222fa312dadae114c8d2247028bf /remoting/client/client_util.cc
parente9fdd159ffd94e3e097bd6905d84e6b564b04c2c (diff)
downloadchromium_src-ef0a59a6fd722a0910196c951dc676c19127a28b.zip
chromium_src-ef0a59a6fd722a0910196c951dc676c19127a28b.tar.gz
chromium_src-ef0a59a6fd722a0910196c951dc676c19127a28b.tar.bz2
Implement a chromoting client using X11
Using XRender to render the chromoting client. This patch has done several things: 1. Rename chromotocol_pb to remoting 2. Defined ChromotingView as the display area of the remote view 3. Implemented X11Client as the client that uses X11 for display 4. Implemented X11View that uses XRender for drawing 5. Fixed several problems in host capturer and encoder Review URL: http://codereview.chromium.org/2745006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49329 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client/client_util.cc')
-rw-r--r--remoting/client/client_util.cc76
1 files changed, 76 insertions, 0 deletions
diff --git a/remoting/client/client_util.cc b/remoting/client/client_util.cc
new file mode 100644
index 0000000..66906f8
--- /dev/null
+++ b/remoting/client/client_util.cc
@@ -0,0 +1,76 @@
+// 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/client_util.h"
+
+#include <iostream>
+
+static void SetConsoleEcho(bool on) {
+#ifdef WIN32
+ HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
+ if ((hIn == INVALID_HANDLE_VALUE) || (hIn == NULL))
+ return;
+
+ DWORD mode;
+ if (!GetConsoleMode(hIn, &mode))
+ return;
+
+ if (on) {
+ mode = mode | ENABLE_ECHO_INPUT;
+ } else {
+ mode = mode & ~ENABLE_ECHO_INPUT;
+ }
+
+ SetConsoleMode(hIn, mode);
+#else
+ if (on)
+ system("stty echo");
+ else
+ system("stty -echo");
+#endif
+}
+
+namespace remoting {
+
+// Get host JID from command line arguments, or stdin if not specified.
+bool GetLoginInfo(std::string& host_jid,
+ std::string& username,
+ std::string& password) {
+ std::cout << "Host JID: ";
+ std::cin >> host_jid;
+ std::cin.ignore(); // Consume the leftover '\n'
+
+ if (host_jid.find("/chromoting") == std::string::npos) {
+ std::cerr << "Error: Expected Host JID in format: <jid>/chromoting<id>"
+ << std::endl;
+ return false;
+ }
+
+ // Get username (JID).
+ // Extract default JID from host_jid.
+ std::string default_username;
+ size_t jid_end = host_jid.find('/');
+ if (jid_end != std::string::npos) {
+ default_username = host_jid.substr(0, jid_end);
+ }
+ std::cout << "JID [" << default_username << "]: ";
+ getline(std::cin, username);
+ if (username.length() == 0) {
+ username = default_username;
+ }
+ if (username.length() == 0) {
+ std::cerr << "Error: Expected valid JID username" << std::endl;
+ return 1;
+ }
+
+ // Get password (with console echo turned off).
+ SetConsoleEcho(false);
+ std::cout << "Password: ";
+ getline(std::cin, password);
+ SetConsoleEcho(true);
+ std::cout << std::endl;
+ return true;
+}
+
+} // namespace remoting