OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/jingle_glue/xmpp_signal_strategy.h" | 5 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "jingle/notifier/base/gaia_token_pre_xmpp_auth.h" | 8 #include "jingle/notifier/base/gaia_token_pre_xmpp_auth.h" |
9 #include "remoting/jingle_glue/jingle_thread.h" | 9 #include "remoting/jingle_glue/jingle_thread.h" |
10 #include "remoting/jingle_glue/xmpp_socket_adapter.h" | 10 #include "remoting/jingle_glue/xmpp_socket_adapter.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // Disconnect first if we are currently connected. | 48 // Disconnect first if we are currently connected. |
49 Disconnect(); | 49 Disconnect(); |
50 | 50 |
51 buzz::XmppClientSettings settings; | 51 buzz::XmppClientSettings settings; |
52 buzz::Jid login_jid(username_); | 52 buzz::Jid login_jid(username_); |
53 settings.set_user(login_jid.node()); | 53 settings.set_user(login_jid.node()); |
54 settings.set_host(login_jid.domain()); | 54 settings.set_host(login_jid.domain()); |
55 settings.set_resource(resource_name_); | 55 settings.set_resource(resource_name_); |
56 settings.set_use_tls(buzz::TLS_ENABLED); | 56 settings.set_use_tls(buzz::TLS_ENABLED); |
57 settings.set_token_service(auth_token_service_); | 57 settings.set_token_service(auth_token_service_); |
58 settings.set_auth_cookie(auth_token_); | 58 settings.set_auth_token(buzz::AUTH_MECHANISM_GOOGLE_TOKEN, auth_token_); |
59 settings.set_server(talk_base::SocketAddress("talk.google.com", 5222)); | 59 settings.set_server(talk_base::SocketAddress("talk.google.com", 5222)); |
60 | 60 |
61 buzz::AsyncSocket* socket = new XmppSocketAdapter(settings, false); | 61 buzz::AsyncSocket* socket = new XmppSocketAdapter(settings, false); |
62 | 62 |
63 xmpp_client_ = new buzz::XmppClient(thread_->task_pump()); | 63 xmpp_client_ = new buzz::XmppClient(thread_->task_pump()); |
64 xmpp_client_->Connect(settings, "", socket, CreatePreXmppAuth(settings)); | 64 xmpp_client_->Connect(settings, "", socket, CreatePreXmppAuth(settings)); |
65 xmpp_client_->SignalStateChange.connect( | 65 xmpp_client_->SignalStateChange.connect( |
66 this, &XmppSignalStrategy::OnConnectionStateChanged); | 66 this, &XmppSignalStrategy::OnConnectionStateChanged); |
67 xmpp_client_->engine()->AddStanzaHandler(this, buzz::XmppEngine::HL_TYPE); | 67 xmpp_client_->engine()->AddStanzaHandler(this, buzz::XmppEngine::HL_TYPE); |
68 xmpp_client_->Start(); | 68 xmpp_client_->Start(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // static | 190 // static |
191 buzz::PreXmppAuth* XmppSignalStrategy::CreatePreXmppAuth( | 191 buzz::PreXmppAuth* XmppSignalStrategy::CreatePreXmppAuth( |
192 const buzz::XmppClientSettings& settings) { | 192 const buzz::XmppClientSettings& settings) { |
193 buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); | 193 buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); |
194 std::string mechanism = notifier::GaiaTokenPreXmppAuth::kDefaultAuthMechanism; | 194 std::string mechanism = notifier::GaiaTokenPreXmppAuth::kDefaultAuthMechanism; |
195 if (settings.token_service() == "oauth2") { | 195 if (settings.token_service() == "oauth2") { |
196 mechanism = "X-OAUTH2"; | 196 mechanism = "X-OAUTH2"; |
197 } | 197 } |
198 | 198 |
199 return new notifier::GaiaTokenPreXmppAuth( | 199 return new notifier::GaiaTokenPreXmppAuth( |
200 jid.Str(), settings.auth_cookie(), settings.token_service(), mechanism); | 200 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); |
201 } | 201 } |
202 | 202 |
203 } // namespace remoting | 203 } // namespace remoting |
OLD | NEW |