| Index: remoting/client/simple_client.cc
|
| diff --git a/remoting/client/simple_client.cc b/remoting/client/simple_client.cc
|
| index ff74312982359d6818be9285304fd29781791659..9b0a8c5395e5560e62d069812941e42c3672101b 100644
|
| --- a/remoting/client/simple_client.cc
|
| +++ b/remoting/client/simple_client.cc
|
| @@ -11,47 +11,20 @@
|
| #include "base/at_exit.h"
|
| #include "base/message_loop.h"
|
| #include "base/stl_util-inl.h"
|
| -#include "media/base/data_buffer.h"
|
| #include "remoting/base/protocol_decoder.h"
|
| +#include "remoting/client/client_util.h"
|
| #include "remoting/client/host_connection.h"
|
| -#include "remoting/jingle_glue/jingle_channel.h"
|
| -#include "remoting/jingle_glue/jingle_client.h"
|
| -
|
| -using chromotocol_pb::HostMessage;
|
| -using chromotocol_pb::InitClientMessage;
|
| -using chromotocol_pb::BeginUpdateStreamMessage;
|
| -using chromotocol_pb::EndUpdateStreamMessage;
|
| -using chromotocol_pb::UpdateStreamPacketMessage;
|
| +
|
| +using remoting::BeginUpdateStreamMessage;
|
| +using remoting::EndUpdateStreamMessage;
|
| using remoting::HostConnection;
|
| +using remoting::HostMessage;
|
| using remoting::HostMessageList;
|
| +using remoting::InitClientMessage;
|
| using remoting::JingleClient;
|
| using remoting::JingleChannel;
|
| using remoting::ProtocolDecoder;
|
| -
|
| -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
|
| -}
|
| +using remoting::UpdateStreamPacketMessage;
|
|
|
| class SimpleHostEventHandler : public HostConnection::EventHandler {
|
| public:
|
| @@ -137,53 +110,13 @@ class SimpleHostEventHandler : public HostConnection::EventHandler {
|
|
|
| int main(int argc, char** argv) {
|
| base::AtExitManager exit_manager;
|
| + std::string host_jid, username, password;
|
|
|
| - if (argc > 2) {
|
| - std::cerr << "Usage: " << argv[0] << " [<host_jid>]" << std::endl;
|
| - return 1;
|
| - }
|
| -
|
| - // Get host JID from command line arguments, or stdin if not specified.
|
| - std::string host_jid;
|
| - if (argc == 2) {
|
| - host_jid = argv[1];
|
| - } else {
|
| - 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;
|
| + if (!remoting::GetLoginInfo(host_jid, username, password)) {
|
| + std::cerr << "Cannot get valid login info." << std::endl;
|
| return 1;
|
| }
|
|
|
| - // Get username (JID).
|
| - // Extract default JID from host_jid.
|
| - std::string username;
|
| - 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).
|
| - std::string password;
|
| - SetConsoleEcho(false);
|
| - std::cout << "Password: ";
|
| - getline(std::cin, password);
|
| - SetConsoleEcho(true);
|
| - std::cout << std::endl;
|
| -
|
| // The message loop that everything runs on.
|
| MessageLoop main_loop;
|
| SimpleHostEventHandler handler(&main_loop);
|
|
|