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