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. 4 5 #ifndef JINGLE_NOTIFIER_COMMUNICATOR_CONNECTION_SETTINGS_H_ 6 #define JINGLE_NOTIFIER_COMMUNICATOR_CONNECTION_SETTINGS_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "base/basictypes.h" 12 #include "jingle/notifier/base/server_information.h" 13 #include "talk/base/socketaddress.h" 14 15 namespace buzz { 16 class XmppClientSettings; 17 } // namespace 18 19 namespace notifier { 20 21 // The port for SSLTCP (just the regular port for SSL). 22 extern const uint16 kSslTcpPort; 23 24 enum SslTcpMode { DO_NOT_USE_SSLTCP, USE_SSLTCP }; 25 26 struct ConnectionSettings { 27 public: 28 ConnectionSettings(const talk_base::SocketAddress& server, 29 SslTcpMode ssltcp_mode, 30 SslTcpSupport ssltcp_support); 31 ConnectionSettings(); 32 ~ConnectionSettings(); 33 34 bool Equals(const ConnectionSettings& settings) const; 35 36 std::string ToString() const; 37 38 // Fill in the connection-related fields of |client_settings|. 39 void FillXmppClientSettings(buzz::XmppClientSettings* client_settings) const; 40 41 talk_base::SocketAddress server; 42 SslTcpMode ssltcp_mode; 43 SslTcpSupport ssltcp_support; 44 }; 45 46 typedef std::vector<ConnectionSettings> ConnectionSettingsList; 47 48 // Given a list of servers in priority order, generate a list of 49 // ConnectionSettings to try in priority order. If |try_ssltcp_first| 50 // is set, for each server that supports SSLTCP, the 51 // ConnectionSettings using SSLTCP will come first. If it is not set, 52 // the ConnectionSettings using SSLTCP will come last. 53 ConnectionSettingsList MakeConnectionSettingsList( 54 const ServerList& servers, 55 bool try_ssltcp_first); 56 57 } // namespace notifier 58 59 #endif // JINGLE_NOTIFIER_COMMUNICATOR_CONNECTION_SETTINGS_H_ 60