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 "webrtc/base/socketaddress.h"
14
15namespace buzz {
16class XmppClientSettings;
17}  // namespace
18
19namespace notifier {
20
21// The port for SSLTCP (just the regular port for SSL).
22extern const uint16 kSslTcpPort;
23
24enum SslTcpMode { DO_NOT_USE_SSLTCP, USE_SSLTCP };
25
26struct ConnectionSettings {
27 public:
28  ConnectionSettings(const rtc::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  rtc::SocketAddress server;
42  SslTcpMode ssltcp_mode;
43  SslTcpSupport ssltcp_support;
44};
45
46typedef 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.
53ConnectionSettingsList MakeConnectionSettingsList(
54    const ServerList& servers,
55    bool try_ssltcp_first);
56
57}  // namespace notifier
58
59#endif  // JINGLE_NOTIFIER_COMMUNICATOR_CONNECTION_SETTINGS_H_
60