OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_JINGLE_CLIENT_H_ | 5 #ifndef REMOTING_JINGLE_GLUE_JINGLE_CLIENT_H_ |
6 #define REMOTING_JINGLE_GLUE_JINGLE_CLIENT_H_ | 6 #define REMOTING_JINGLE_GLUE_JINGLE_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "remoting/jingle_glue/jingle_channel.h" | 10 #include "remoting/jingle_glue/jingle_channel.h" |
11 #include "talk/xmpp/xmppclient.h" | 11 #include "talk/xmpp/xmppclient.h" |
12 | 12 |
13 class MessageLoop; | 13 class MessageLoop; |
14 | 14 |
15 namespace talk_base { | 15 namespace talk_base { |
16 class NetworkManager; | 16 class NetworkManager; |
17 } // namespace talk_base | 17 } // namespace talk_base |
18 | 18 |
| 19 namespace buzz { |
| 20 class PreXmppAuth; |
| 21 } // namespace buzz |
| 22 |
19 namespace cricket { | 23 namespace cricket { |
20 class BasicPortAllocator; | 24 class BasicPortAllocator; |
21 class SessionManager; | 25 class SessionManager; |
22 class TunnelSessionClient; | 26 class TunnelSessionClient; |
23 class SessionManagerTask; | 27 class SessionManagerTask; |
24 class Session; | 28 class Session; |
25 } // namespace cricket | 29 } // namespace cricket |
26 | 30 |
27 namespace remoting { | 31 namespace remoting { |
28 | 32 |
(...skipping 27 matching lines...) Expand all Loading... |
56 scoped_refptr<JingleChannel> channel) = 0; | 60 scoped_refptr<JingleChannel> channel) = 0; |
57 }; | 61 }; |
58 | 62 |
59 JingleClient(); | 63 JingleClient(); |
60 virtual ~JingleClient(); | 64 virtual ~JingleClient(); |
61 | 65 |
62 // Starts jingle thread and XMPP connection inialization. Must be called | 66 // Starts jingle thread and XMPP connection inialization. Must be called |
63 // only once. message_loop() is guaranteed to exist after this method returns, | 67 // only once. message_loop() is guaranteed to exist after this method returns, |
64 // but the connection may not be open yet. |callback| specifies callback | 68 // but the connection may not be open yet. |callback| specifies callback |
65 // object for the client and must not be NULL. | 69 // object for the client and must not be NULL. |
66 // TODO(sergeyu): Replace password with a token. | 70 void Init(const std::string& username, const std::string& auth_token, |
67 void Init(const std::string& username, const std::string& password, | 71 const std::string& auth_token_service, Callback* callback); |
68 Callback* callback); | |
69 | 72 |
70 // Creates new JingleChannel connected to the host with the specified jid. | 73 // Creates new JingleChannel connected to the host with the specified jid. |
71 // The result is returned immediately but the channel fails if the host | 74 // The result is returned immediately but the channel fails if the host |
72 // rejects connection. |host_jid| must be a full jid (includes resource ID). | 75 // rejects connection. |host_jid| must be a full jid (includes resource ID). |
73 // Ownership of the result is transfered to the caller. The channel must | 76 // Ownership of the result is transfered to the caller. The channel must |
74 // be closed/destroyed before JingleClient is destroyed. | 77 // be closed/destroyed before JingleClient is destroyed. |
75 JingleChannel* Connect(const std::string& host_jid, | 78 JingleChannel* Connect(const std::string& host_jid, |
76 JingleChannel::Callback* callback); | 79 JingleChannel::Callback* callback); |
77 | 80 |
78 // Closes XMPP connection and stops the thread. Must be called before the | 81 // Closes XMPP connection and stops the thread. Must be called before the |
(...skipping 15 matching lines...) Expand all Loading... |
94 | 97 |
95 private: | 98 private: |
96 // Used by Connect(). | 99 // Used by Connect(). |
97 class ConnectRequest; | 100 class ConnectRequest; |
98 | 101 |
99 void OnConnectionStateChanged(buzz::XmppEngine::State state); | 102 void OnConnectionStateChanged(buzz::XmppEngine::State state); |
100 | 103 |
101 void OnIncomingTunnel(cricket::TunnelSessionClient* client, buzz::Jid jid, | 104 void OnIncomingTunnel(cricket::TunnelSessionClient* client, buzz::Jid jid, |
102 std::string description, cricket::Session* session); | 105 std::string description, cricket::Session* session); |
103 | 106 |
104 void DoInitialize(); | 107 void DoInitialize(const std::string& username, |
| 108 const std::string& auth_token, |
| 109 const std::string& auth_token_service); |
105 | 110 |
106 // Used by Connect(). | 111 // Used by Connect(). |
107 void DoConnect(ConnectRequest* request, | 112 void DoConnect(ConnectRequest* request, |
108 const std::string& host_jid, | 113 const std::string& host_jid, |
109 JingleChannel::Callback* callback); | 114 JingleChannel::Callback* callback); |
110 | 115 |
111 // Used by Close(). | 116 // Used by Close(). |
112 void DoClose(); | 117 void DoClose(); |
113 | 118 |
114 // Updates current state of the connection. Must be called only in | 119 // Updates current state of the connection. Must be called only in |
115 // the jingle thread. | 120 // the jingle thread. |
116 void UpdateState(State new_state); | 121 void UpdateState(State new_state); |
117 | 122 |
| 123 buzz::PreXmppAuth* CreatePreXmppAuth( |
| 124 const buzz::XmppClientSettings& settings); |
| 125 |
| 126 |
118 buzz::XmppClient* client_; | 127 buzz::XmppClient* client_; |
119 scoped_ptr<JingleThread> thread_; | 128 scoped_ptr<JingleThread> thread_; |
120 State state_; | 129 State state_; |
121 Callback* callback_; | 130 Callback* callback_; |
122 | 131 |
123 std::string username_; | |
124 std::string password_; | |
125 Lock full_jid_lock_; | 132 Lock full_jid_lock_; |
126 std::string full_jid_; | 133 std::string full_jid_; |
127 | 134 |
128 scoped_ptr<talk_base::NetworkManager> network_manager_; | 135 scoped_ptr<talk_base::NetworkManager> network_manager_; |
129 scoped_ptr<cricket::BasicPortAllocator> port_allocator_; | 136 scoped_ptr<cricket::BasicPortAllocator> port_allocator_; |
130 scoped_ptr<cricket::SessionManager> session_manager_; | 137 scoped_ptr<cricket::SessionManager> session_manager_; |
131 scoped_ptr<cricket::TunnelSessionClient> tunnel_session_client_; | 138 scoped_ptr<cricket::TunnelSessionClient> tunnel_session_client_; |
132 cricket::SessionManagerTask* receiver_; | 139 cricket::SessionManagerTask* receiver_; |
133 | 140 |
134 DISALLOW_COPY_AND_ASSIGN(JingleClient); | 141 DISALLOW_COPY_AND_ASSIGN(JingleClient); |
135 }; | 142 }; |
136 | 143 |
137 } // namespace remoting | 144 } // namespace remoting |
138 | 145 |
139 #endif // REMOTING_JINGLE_GLUE_JINGLE_CLIENT_H_ | 146 #endif // REMOTING_JINGLE_GLUE_JINGLE_CLIENT_H_ |
OLD | NEW |