| 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" |
| 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> |
| 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" | |
| 19 #include "remoting/jingle_glue/jingle_channel.h" | 18 #include "remoting/jingle_glue/jingle_channel.h" |
| 20 #include "remoting/jingle_glue/jingle_client.h" | 19 #include "remoting/jingle_glue/jingle_client.h" |
| 21 | 20 |
| 22 using remoting::JingleClient; | 21 using remoting::JingleClient; |
| 23 using remoting::JingleChannel; | 22 using remoting::JingleChannel; |
| 24 using remoting::kChromotingTokenServiceName; | |
| 25 | 23 |
| 26 void SetConsoleEcho(bool on) { | 24 void SetConsoleEcho(bool on) { |
| 27 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 28 HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE); | 26 HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE); |
| 29 if ((hIn == INVALID_HANDLE_VALUE) || (hIn == NULL)) | 27 if ((hIn == INVALID_HANDLE_VALUE) || (hIn == NULL)) |
| 30 return; | 28 return; |
| 31 | 29 |
| 32 DWORD mode; | 30 DWORD mode; |
| 33 if (!GetConsoleMode(hIn, &mode)) | 31 if (!GetConsoleMode(hIn, &mode)) |
| 34 return; | 32 return; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 else | 44 else |
| 47 system("stty -echo"); | 45 system("stty -echo"); |
| 48 #endif // !defined(OS_WIN) | 46 #endif // !defined(OS_WIN) |
| 49 } | 47 } |
| 50 | 48 |
| 51 class JingleTestClient : public JingleChannel::Callback, | 49 class JingleTestClient : public JingleChannel::Callback, |
| 52 public JingleClient::Callback { | 50 public JingleClient::Callback { |
| 53 public: | 51 public: |
| 54 virtual ~JingleTestClient() {} | 52 virtual ~JingleTestClient() {} |
| 55 | 53 |
| 56 void Run(const std::string& username, const std::string& auth_token, | 54 void Run(const std::string& username, const std::string& password, |
| 57 const std::string& host_jid) { | 55 const std::string& host_jid) { |
| 58 client_ = new JingleClient(); | 56 client_ = new JingleClient(); |
| 59 client_->Init(username, auth_token, kChromotingTokenServiceName, this); | 57 client_->Init(username, password, this); |
| 60 | 58 |
| 61 if (host_jid != "") { | 59 if (host_jid != "") { |
| 62 scoped_refptr<JingleChannel> channel = client_->Connect(host_jid, this); | 60 scoped_refptr<JingleChannel> channel = client_->Connect(host_jid, this); |
| 63 channels_.push_back(channel); | 61 channels_.push_back(channel); |
| 64 } | 62 } |
| 65 | 63 |
| 66 while (true) { | 64 while (true) { |
| 67 std::string line; | 65 std::string line; |
| 68 std::getline(std::cin, line); | 66 std::getline(std::cin, line); |
| 69 | 67 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 std::cerr << "Usage: " << argv[0] << " [<host_jid>]" << std::endl; | 137 std::cerr << "Usage: " << argv[0] << " [<host_jid>]" << std::endl; |
| 140 | 138 |
| 141 base::AtExitManager exit_manager; | 139 base::AtExitManager exit_manager; |
| 142 | 140 |
| 143 std::string host_jid = argc == 2 ? argv[1] : ""; | 141 std::string host_jid = argc == 2 ? argv[1] : ""; |
| 144 | 142 |
| 145 std::string username; | 143 std::string username; |
| 146 std::cout << "JID: "; | 144 std::cout << "JID: "; |
| 147 std::cin >> username; | 145 std::cin >> username; |
| 148 | 146 |
| 149 std::string auth_token; | 147 std::string password; |
| 150 std::cout << "Auth token: "; | 148 SetConsoleEcho(false); |
| 151 std::cin >> auth_token; | 149 std::cout << "Password: "; |
| 150 std::cin >> password; |
| 151 SetConsoleEcho(true); |
| 152 std::cout << std::endl; |
| 152 | 153 |
| 153 JingleTestClient client; | 154 JingleTestClient client; |
| 154 | 155 |
| 155 client.Run(username, auth_token, host_jid); | 156 client.Run(username, password, host_jid); |
| 156 | 157 |
| 157 return 0; | 158 return 0; |
| 158 } | 159 } |
| OLD | NEW |