Index: remoting/host/offline_status_sender.h |
diff --git a/remoting/host/offline_status_sender.h b/remoting/host/offline_status_sender.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7e7efcfe8d95a2fc84e76f64eb0dd010f39577e4 |
--- /dev/null |
+++ b/remoting/host/offline_status_sender.h |
@@ -0,0 +1,78 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef REMOTING_HOST_OFFLINE_STATUS_SENDER_H_ |
+#define REMOTING_HOST_OFFLINE_STATUS_SENDER_H_ |
+ |
+#include <string> |
+ |
+#include "base/compiler_specific.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "remoting/base/rsa_key_pair.h" |
+#include "remoting/jingle_glue/signal_strategy.h" |
+ |
+namespace base { |
+class MessageLoopProxy; |
+} // namespace base |
+ |
+namespace buzz { |
+class XmlElement; |
+} // namespace buzz |
+ |
+namespace remoting { |
+ |
+class RsaKeyPair; |
+class IqSender; |
+ |
+// OfflineStatusSender sends the offline status to the Chromoting Bot. |
+// Each offline status stanza looks as follows: |
+// |
+// <iq type="set" to="remoting@bot.talk.google.com" |
+// from="user@gmail.com/chromoting123123" id="5" xmlns="jabber:client"> |
+// <rem:offline_status rem:hostid="a1ddb11e-8aef-11df-bccf-18a905b9cb5a" |
+// rem:status="100" rem:errorcode="5" |
+// xmlns:rem="google:remoting"> |
+// <rem:signature>.signature.</rem:signature> |
+// </rem:offline_status> |
+// </iq> |
+// |
+// The signature is a base-64 encoded SHA-1 hash, signed with the host's |
+// private RSA key. The message being signed is the full Jid, e.g. |
+// "user@gmail.com/chromoting123123 456". |
rmsousa
2013/07/02 02:09:24
Nit: please update the example and/or the descript
weitao
2013/07/03 19:23:31
Done.
|
+class OfflineStatusSender : SignalStrategy::Listener { |
+ public: |
+ |
+ OfflineStatusSender(const std::string& host_id, |
+ SignalStrategy* signal_strategy, |
+ scoped_refptr<RsaKeyPair> key_pair, |
+ const std::string& directory_bot_jid); |
+ virtual ~OfflineStatusSender(); |
+ |
+ // SignalStrategy::Listener interface. |
+ virtual void OnSignalStrategyStateChange( |
+ SignalStrategy::State state) OVERRIDE; |
+ virtual bool OnSignalStrategyIncomingStanza( |
+ const buzz::XmlElement* stanza) OVERRIDE; |
+ |
+ void SendOfflineStatus(int status, uint errorcode = 0); |
rmsousa
2013/07/02 02:09:24
Do not use default arguments: http://google-styleg
rmsousa
2013/07/02 02:09:24
Please add a comment explaining the function and i
weitao
2013/07/03 19:23:31
Done.
weitao
2013/07/03 19:23:31
Done.
|
+ |
+ private: |
+ // Helper methods used by SendStanza() to generate offline status stanzas. |
+ scoped_ptr<buzz::XmlElement> CreateOfflineStatusMessage(int status, |
+ uint errorcode); |
+ scoped_ptr<buzz::XmlElement> CreateSignature(); |
+ |
+ std::string host_id_; |
+ SignalStrategy* signal_strategy_; |
+ scoped_refptr<RsaKeyPair> key_pair_; |
+ std::string directory_bot_jid_; |
+ scoped_ptr<IqSender> iq_sender_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(OfflineStatusSender); |
+}; |
+ |
+} // namespace remoting |
+ |
+#endif // REMOTING_HOST_OFFLINE_STATUS_SENDER_H_ |