chromeos: bluetooth: add BluetoothInputClient
[chromium-blink-merge.git] / remoting / jingle_glue / xmpp_signal_strategy.h
blob361aac8e56360504da496fce55a3afdf07f83e5d
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
3 // found in the LICENSE file.
5 // The XmppSignalStrategy encapsulates all the logic to perform the signaling
6 // STUN/ICE for jingle via a direct XMPP connection.
7 //
8 // This class is not threadsafe.
10 #ifndef REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_
11 #define REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_
13 #include "remoting/jingle_glue/signal_strategy.h"
15 #include <vector>
17 #include "base/compiler_specific.h"
18 #include "base/observer_list.h"
19 #include "base/threading/non_thread_safe.h"
20 #include "third_party/libjingle/source/talk/base/sigslot.h"
21 #include "third_party/libjingle/source/talk/xmpp/xmppclient.h"
23 namespace remoting {
25 class JingleThread;
27 class XmppSignalStrategy : public base::NonThreadSafe,
28 public SignalStrategy,
29 public buzz::XmppStanzaHandler,
30 public sigslot::has_slots<> {
31 public:
32 XmppSignalStrategy(JingleThread* thread,
33 const std::string& username,
34 const std::string& auth_token,
35 const std::string& auth_token_service);
36 virtual ~XmppSignalStrategy();
38 // SignalStrategy interface.
39 virtual void Connect() OVERRIDE;
40 virtual void Disconnect() OVERRIDE;
41 virtual State GetState() const OVERRIDE;
42 virtual std::string GetLocalJid() const OVERRIDE;
43 virtual void AddListener(Listener* listener) OVERRIDE;
44 virtual void RemoveListener(Listener* listener) OVERRIDE;
45 virtual bool SendStanza(scoped_ptr<buzz::XmlElement> stanza) OVERRIDE;
46 virtual std::string GetNextId() OVERRIDE;
48 // buzz::XmppStanzaHandler interface.
49 virtual bool HandleStanza(const buzz::XmlElement* stanza) OVERRIDE;
51 // This method is used to update the auth info (for example when the OAuth
52 // access token is renewed). It is OK to call this even when we are in the
53 // CONNECTED state. It will be used on the next Connect() call.
54 void SetAuthInfo(const std::string& username,
55 const std::string& auth_token,
56 const std::string& auth_token_service);
58 // Use this method to override the default resource name used (optional).
59 // This will be used on the next Connect() call.
60 void SetResourceName(const std::string& resource_name);
62 private:
63 static buzz::PreXmppAuth* CreatePreXmppAuth(
64 const buzz::XmppClientSettings& settings);
66 void OnConnectionStateChanged(buzz::XmppEngine::State state);
67 void SetState(State new_state);
69 JingleThread* thread_;
71 std::string username_;
72 std::string auth_token_;
73 std::string auth_token_service_;
74 std::string resource_name_;
75 buzz::XmppClient* xmpp_client_;
77 State state_;
79 ObserverList<Listener> listeners_;
81 DISALLOW_COPY_AND_ASSIGN(XmppSignalStrategy);
84 } // namespace remoting
86 #endif // REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_