| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/host/host_status_sender.h" | 5 #include "remoting/host/host_status_sender.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | |
| 8 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringize_macros.h" | 8 #include "base/strings/stringize_macros.h" |
| 10 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 11 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
| 11 #include "remoting/base/logging.h" |
| 12 #include "remoting/host/server_log_entry.h" | 12 #include "remoting/host/server_log_entry.h" |
| 13 #include "remoting/jingle_glue/iq_sender.h" | 13 #include "remoting/jingle_glue/iq_sender.h" |
| 14 #include "remoting/jingle_glue/signal_strategy.h" | 14 #include "remoting/jingle_glue/signal_strategy.h" |
| 15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| 16 #include "third_party/libjingle/source/talk/xmpp/constants.h" | 16 #include "third_party/libjingle/source/talk/xmpp/constants.h" |
| 17 | 17 |
| 18 using buzz::QName; | 18 using buzz::QName; |
| 19 using buzz::XmlElement; | 19 using buzz::XmlElement; |
| 20 | 20 |
| 21 namespace remoting { | 21 namespace remoting { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 void HostStatusSender::SendOnlineStatus() { | 74 void HostStatusSender::SendOnlineStatus() { |
| 75 SendHostStatus(ONLINE, kSuccessExitCode); | 75 SendHostStatus(ONLINE, kSuccessExitCode); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void HostStatusSender::SendHostStatus(HostStatus status, | 78 void HostStatusSender::SendHostStatus(HostStatus status, |
| 79 HostExitCodes exit_code) { | 79 HostExitCodes exit_code) { |
| 80 SignalStrategy::State state = signal_strategy_->GetState(); | 80 SignalStrategy::State state = signal_strategy_->GetState(); |
| 81 if (state == SignalStrategy::CONNECTED) { | 81 if (state == SignalStrategy::CONNECTED) { |
| 82 LOG(INFO) << "Sending host status '" | 82 HOST_LOG << "Sending host status '" |
| 83 << HostStatusToString(status) | 83 << HostStatusToString(status) |
| 84 << "' to " | 84 << "' to " |
| 85 << directory_bot_jid_; | 85 << directory_bot_jid_; |
| 86 | 86 |
| 87 iq_sender_->SendIq(buzz::STR_SET, | 87 iq_sender_->SendIq(buzz::STR_SET, |
| 88 directory_bot_jid_, | 88 directory_bot_jid_, |
| 89 CreateHostStatusMessage(status, exit_code), | 89 CreateHostStatusMessage(status, exit_code), |
| 90 IqSender::ReplyCallback()); | 90 IqSender::ReplyCallback()); |
| 91 } else { | 91 } else { |
| 92 LOG(INFO) << "Cannot send host status to '" | 92 HOST_LOG << "Cannot send host status to '" |
| 93 << directory_bot_jid_ | 93 << directory_bot_jid_ |
| 94 << " ' because the state of the SignalStrategy is " | 94 << " ' because the state of the SignalStrategy is " |
| 95 << state; | 95 << state; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 scoped_ptr<XmlElement> HostStatusSender::CreateHostStatusMessage( | 99 scoped_ptr<XmlElement> HostStatusSender::CreateHostStatusMessage( |
| 100 HostStatus status, HostExitCodes exit_code) { | 100 HostStatus status, HostExitCodes exit_code) { |
| 101 // Create host status stanza. | 101 // Create host status stanza. |
| 102 scoped_ptr<XmlElement> host_status(new XmlElement( | 102 scoped_ptr<XmlElement> host_status(new XmlElement( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (status == OFFLINE) | 153 if (status == OFFLINE) |
| 154 message += std::string(" ") + ExitCodeToString(exit_code); | 154 message += std::string(" ") + ExitCodeToString(exit_code); |
| 155 | 155 |
| 156 std::string signature(key_pair_->SignMessage(message)); | 156 std::string signature(key_pair_->SignMessage(message)); |
| 157 signature_tag->AddText(signature); | 157 signature_tag->AddText(signature); |
| 158 | 158 |
| 159 return signature_tag.Pass(); | 159 return signature_tag.Pass(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace remoting | 162 } // namespace remoting |
| OLD | NEW |