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 "remoting/client/host_connection.h" | 5 #include "remoting/client/host_connection.h" |
6 | 6 |
7 #include "remoting/base/constants.h" | |
8 | |
9 namespace remoting { | 7 namespace remoting { |
10 | 8 |
11 HostConnection::HostConnection(ProtocolDecoder* decoder, | 9 HostConnection::HostConnection(ProtocolDecoder* decoder, |
12 EventHandler* handler) | 10 EventHandler* handler) |
13 : decoder_(decoder), handler_(handler) { | 11 : decoder_(decoder), handler_(handler) { |
14 } | 12 } |
15 | 13 |
16 HostConnection::~HostConnection() { | 14 HostConnection::~HostConnection() { |
17 Disconnect(); | 15 Disconnect(); |
18 } | 16 } |
19 | 17 |
20 void HostConnection::Connect(const std::string& username, | 18 void HostConnection::Connect(const std::string& username, |
21 const std::string& auth_token, | 19 const std::string& password, |
22 const std::string& host_jid) { | 20 const std::string& host_jid) { |
23 jingle_client_ = new JingleClient(); | 21 jingle_client_ = new JingleClient(); |
24 jingle_client_->Init(username, auth_token, kChromotingTokenServiceName, this); | 22 jingle_client_->Init(username, password, this); |
25 jingle_channel_ = jingle_client_->Connect(host_jid, this); | 23 jingle_channel_ = jingle_client_->Connect(host_jid, this); |
26 } | 24 } |
27 | 25 |
28 void HostConnection::Disconnect() { | 26 void HostConnection::Disconnect() { |
29 if (jingle_channel_.get()) | 27 if (jingle_channel_.get()) |
30 jingle_channel_->Close(); | 28 jingle_channel_->Close(); |
31 | 29 |
32 if (jingle_client_.get()) | 30 if (jingle_client_.get()) |
33 jingle_client_->Close(); | 31 jingle_client_->Close(); |
34 } | 32 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Client rejects all connection. | 69 // Client rejects all connection. |
72 return false; | 70 return false; |
73 } | 71 } |
74 | 72 |
75 void HostConnection::OnNewConnection(JingleClient* client, | 73 void HostConnection::OnNewConnection(JingleClient* client, |
76 scoped_refptr<JingleChannel> channel) { | 74 scoped_refptr<JingleChannel> channel) { |
77 NOTREACHED() << "SimpleClient can't accept connection."; | 75 NOTREACHED() << "SimpleClient can't accept connection."; |
78 } | 76 } |
79 | 77 |
80 } // namespace remoting | 78 } // namespace remoting |
OLD | NEW |