1/*
2 * libjingle
3 * Copyright 2004--2005, Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 *  1. Redistributions of source code must retain the above copyright notice,
9 *     this list of conditions and the following disclaimer.
10 *  2. Redistributions in binary form must reproduce the above copyright notice,
11 *     this list of conditions and the following disclaimer in the documentation
12 *     and/or other materials provided with the distribution.
13 *  3. The name of the author may not be used to endorse or promote products
14 *     derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _XMPPCLIENTSETTINGS_H_
29#define _XMPPCLIENTSETTINGS_H_
30
31#include "talk/p2p/base/port.h"
32#include "talk/base/cryptstring.h"
33
34namespace buzz {
35
36class XmppUserSettings {
37 public:
38  XmppUserSettings()
39    : use_tls_(false),
40      allow_plain_(false) {
41  }
42
43  void set_user(const std::string & user) { user_ = user; }
44  void set_host(const std::string & host) { host_ = host; }
45  void set_pass(const talk_base::CryptString & pass) { pass_ = pass; }
46  void set_auth_cookie(const std::string & cookie) { auth_cookie_ = cookie; }
47  void set_resource(const std::string & resource) { resource_ = resource; }
48  void set_use_tls(bool use_tls) { use_tls_ = use_tls; }
49  void set_allow_plain(bool f) { allow_plain_ = f; }
50  void set_token_service(const std::string & token_service) {
51    token_service_ = token_service;
52  }
53
54  const std::string & user() const { return user_; }
55  const std::string & host() const { return host_; }
56  const talk_base::CryptString & pass() const { return pass_; }
57  const std::string & auth_cookie() const { return auth_cookie_; }
58  const std::string & resource() const { return resource_; }
59  bool use_tls() const { return use_tls_; }
60  bool allow_plain() const { return allow_plain_; }
61  const std::string & token_service() const { return token_service_; }
62
63 private:
64  std::string user_;
65  std::string host_;
66  talk_base::CryptString pass_;
67  std::string auth_cookie_;
68  std::string resource_;
69  bool use_tls_;
70  bool allow_plain_;
71  std::string token_service_;
72};
73
74class XmppClientSettings : public XmppUserSettings {
75 public:
76  XmppClientSettings()
77    : protocol_(cricket::PROTO_TCP),
78      proxy_(talk_base::PROXY_NONE),
79      proxy_port_(80),
80      use_proxy_auth_(false) {
81  }
82
83  void set_server(const talk_base::SocketAddress & server) {
84      server_ = server;
85  }
86  void set_protocol(cricket::ProtocolType protocol) { protocol_ = protocol; }
87  void set_proxy(talk_base::ProxyType f) { proxy_ = f; }
88  void set_proxy_host(const std::string & host) { proxy_host_ = host; }
89  void set_proxy_port(int port) { proxy_port_ = port; };
90  void set_use_proxy_auth(bool f) { use_proxy_auth_ = f; }
91  void set_proxy_user(const std::string & user) { proxy_user_ = user; }
92  void set_proxy_pass(const talk_base::CryptString & pass) { proxy_pass_ = pass; }
93
94  const talk_base::SocketAddress & server() const { return server_; }
95  cricket::ProtocolType protocol() const { return protocol_; }
96  talk_base::ProxyType proxy() const { return proxy_; }
97  const std::string & proxy_host() const { return proxy_host_; }
98  int proxy_port() const { return proxy_port_; }
99  bool use_proxy_auth() const { return use_proxy_auth_; }
100  const std::string & proxy_user() const { return proxy_user_; }
101  const talk_base::CryptString & proxy_pass() const { return proxy_pass_; }
102
103 private:
104  talk_base::SocketAddress server_;
105  cricket::ProtocolType protocol_;
106  talk_base::ProxyType proxy_;
107  std::string proxy_host_;
108  int proxy_port_;
109  bool use_proxy_auth_;
110  std::string proxy_user_;
111  talk_base::CryptString proxy_pass_;
112};
113
114}
115
116#endif
117