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