Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
|
Sergey Ulanov
2010/06/16 01:26:25
Please also remove this include.
| |
| 6 | 6 |
| 7 #if !defined(OS_WIN) | 7 #if !defined(OS_WIN) |
| 8 extern "C" { | 8 extern "C" { |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
|
Sergey Ulanov
2010/06/16 01:26:25
and this.
| |
| 10 } | 10 } |
| 11 #endif // !defined(OS_WIN) | 11 #endif // !defined(OS_WIN) |
| 12 | 12 |
| 13 #include <iostream> | 13 #include <iostream> |
| 14 #include <list> | 14 #include <list> |
| 15 | 15 |
| 16 #include "base/at_exit.h" | 16 #include "base/at_exit.h" |
| 17 #include "media/base/data_buffer.h" | 17 #include "media/base/data_buffer.h" |
| 18 #include "remoting/base/constants.h" | 18 #include "remoting/base/constants.h" |
| 19 #include "remoting/jingle_glue/jingle_channel.h" | 19 #include "remoting/jingle_glue/jingle_channel.h" |
| 20 #include "remoting/jingle_glue/jingle_client.h" | 20 #include "remoting/jingle_glue/jingle_client.h" |
| 21 #include "remoting/jingle_glue/jingle_thread.h" | 21 #include "remoting/jingle_glue/jingle_thread.h" |
| 22 | 22 |
| 23 using remoting::JingleClient; | 23 using remoting::JingleClient; |
| 24 using remoting::JingleChannel; | 24 using remoting::JingleChannel; |
| 25 using remoting::kChromotingTokenServiceName; | 25 using remoting::kChromotingTokenServiceName; |
| 26 | 26 |
| 27 void SetConsoleEcho(bool on) { | |
| 28 #if defined(OS_WIN) | |
| 29 HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE); | |
| 30 if ((hIn == INVALID_HANDLE_VALUE) || (hIn == NULL)) | |
| 31 return; | |
| 32 | |
| 33 DWORD mode; | |
| 34 if (!GetConsoleMode(hIn, &mode)) | |
| 35 return; | |
| 36 | |
| 37 if (on) { | |
| 38 mode = mode | ENABLE_ECHO_INPUT; | |
| 39 } else { | |
| 40 mode = mode & ~ENABLE_ECHO_INPUT; | |
| 41 } | |
| 42 | |
| 43 SetConsoleMode(hIn, mode); | |
| 44 #else // defined(OS_WIN) | |
| 45 if (on) | |
| 46 system("stty echo"); | |
| 47 else | |
| 48 system("stty -echo"); | |
| 49 #endif // !defined(OS_WIN) | |
| 50 } | |
| 51 | |
| 52 class JingleTestClient : public JingleChannel::Callback, | 27 class JingleTestClient : public JingleChannel::Callback, |
| 53 public JingleClient::Callback { | 28 public JingleClient::Callback { |
| 54 public: | 29 public: |
| 55 virtual ~JingleTestClient() {} | 30 virtual ~JingleTestClient() {} |
| 56 | 31 |
| 57 void Run(const std::string& username, const std::string& auth_token, | 32 void Run(const std::string& username, const std::string& auth_token, |
| 58 const std::string& host_jid) { | 33 const std::string& host_jid) { |
| 59 // TODO(hclam): Fix the threading problem. | 34 // TODO(hclam): Fix the threading problem. |
| 60 remoting::JingleThread jingle_thread; | 35 remoting::JingleThread jingle_thread; |
| 61 jingle_thread.Start(); | 36 jingle_thread.Start(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 std::string auth_token; | 129 std::string auth_token; |
| 155 std::cout << "Auth token: "; | 130 std::cout << "Auth token: "; |
| 156 std::cin >> auth_token; | 131 std::cin >> auth_token; |
| 157 | 132 |
| 158 JingleTestClient client; | 133 JingleTestClient client; |
| 159 | 134 |
| 160 client.Run(username, auth_token, host_jid); | 135 client.Run(username, auth_token, host_jid); |
| 161 | 136 |
| 162 return 0; | 137 return 0; |
| 163 } | 138 } |
| OLD | NEW |