| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ | 5 #ifndef REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ |
| 6 #define REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ | 6 #define REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 | 11 |
| 12 namespace buzz { | 12 namespace buzz { |
| 13 class XmlElement; | 13 class XmlElement; |
| 14 } // namespace buzz | 14 } // namespace buzz |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 | 17 |
| 18 class IqRequest; | |
| 19 | |
| 20 class SignalStrategy { | 18 class SignalStrategy { |
| 21 public: | 19 public: |
| 22 class StatusObserver { | 20 class StatusObserver { |
| 23 public: | 21 public: |
| 24 enum State { | 22 enum State { |
| 25 START, | 23 START, |
| 26 CONNECTING, | 24 CONNECTING, |
| 27 CONNECTED, | 25 CONNECTED, |
| 28 CLOSED, | 26 CLOSED, |
| 29 }; | 27 }; |
| 30 | 28 |
| 31 // Called when state of the connection is changed. | 29 // Called when state of the connection is changed. |
| 32 virtual void OnStateChange(State state) = 0; | 30 virtual void OnStateChange(State state) = 0; |
| 33 virtual void OnJidChange(const std::string& full_jid) = 0; | 31 virtual void OnJidChange(const std::string& full_jid) = 0; |
| 34 }; | 32 }; |
| 35 | 33 |
| 36 class Listener { | 34 class Listener { |
| 37 public: | 35 public: |
| 38 // Must return true if the stanza was handled, false otherwise. | 36 // Must return true if the stanza was handled, false otherwise. |
| 39 virtual bool OnIncomingStanza(const buzz::XmlElement* stanza) = 0; | 37 virtual bool OnIncomingStanza(const buzz::XmlElement* stanza) = 0; |
| 40 }; | 38 }; |
| 41 | 39 |
| 42 SignalStrategy() {} | 40 SignalStrategy() {} |
| 43 virtual ~SignalStrategy() {} | 41 virtual ~SignalStrategy() {} |
| 44 virtual void Init(StatusObserver* observer) = 0; | 42 virtual void Init(StatusObserver* observer) = 0; |
| 45 virtual void Close() = 0; | 43 virtual void Close() = 0; |
| 46 | 44 |
| 47 // Set a listener that can listen to all incoming messages. Doesn't | 45 // Add a |listener| that can listen to all incoming |
| 48 // take ownership of the |listener|. Can be called with |listener| | 46 // messages. Doesn't take ownership of the |listener|. |
| 49 // set to NULL to unset current listener. It must be unset before | 47 virtual void AddListener(Listener* listener) = 0; |
| 50 // object is destroyed. | 48 |
| 51 virtual void SetListener(Listener* listener) = 0; | 49 // Remove a |listener| previously added with AddListener(). |
| 50 virtual void RemoveListener(Listener* listener) = 0; |
| 52 | 51 |
| 53 // Sends a raw XMPP stanza. Takes ownership of the |stanza|. | 52 // Sends a raw XMPP stanza. Takes ownership of the |stanza|. |
| 54 virtual void SendStanza(buzz::XmlElement* stanza) = 0; | 53 virtual bool SendStanza(buzz::XmlElement* stanza) = 0; |
| 55 | 54 |
| 56 // Returns new ID that should be used for the next outgoing IQ | 55 // Returns new ID that should be used for the next outgoing IQ |
| 57 // request. | 56 // request. |
| 58 virtual std::string GetNextId() = 0; | 57 virtual std::string GetNextId() = 0; |
| 59 | 58 |
| 60 // TODO(sergeyu): Do we really need this method to be part of this | |
| 61 // interface? | |
| 62 virtual IqRequest* CreateIqRequest() = 0; | |
| 63 | |
| 64 private: | 59 private: |
| 65 DISALLOW_COPY_AND_ASSIGN(SignalStrategy); | 60 DISALLOW_COPY_AND_ASSIGN(SignalStrategy); |
| 66 }; | 61 }; |
| 67 | 62 |
| 68 } // namespace remoting | 63 } // namespace remoting |
| 69 | 64 |
| 70 #endif // REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ | 65 #endif // REMOTING_JINGLE_GLUE_SIGNAL_STRATEGY_H_ |
| OLD | NEW |