henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_LIBJINGLE_XMPP_XMPPCLIENTSETTINGS_H_ |
| 12 | #define WEBRTC_LIBJINGLE_XMPP_XMPPCLIENTSETTINGS_H_ |
| 13 | |
| 14 | #include "webrtc/p2p/base/port.h" |
| 15 | #include "webrtc/libjingle/xmpp/xmppengine.h" |
| 16 | #include "webrtc/base/cryptstring.h" |
| 17 | |
| 18 | namespace buzz { |
| 19 | |
| 20 | class XmppUserSettings { |
| 21 | public: |
| 22 | XmppUserSettings() |
| 23 | : use_tls_(buzz::TLS_DISABLED), |
| 24 | allow_plain_(false) { |
| 25 | } |
| 26 | |
| 27 | void set_user(const std::string& user) { user_ = user; } |
| 28 | void set_host(const std::string& host) { host_ = host; } |
| 29 | void set_pass(const rtc::CryptString& pass) { pass_ = pass; } |
| 30 | void set_auth_token(const std::string& mechanism, |
| 31 | const std::string& token) { |
| 32 | auth_mechanism_ = mechanism; |
| 33 | auth_token_ = token; |
| 34 | } |
| 35 | void set_resource(const std::string& resource) { resource_ = resource; } |
| 36 | void set_use_tls(const TlsOptions use_tls) { use_tls_ = use_tls; } |
| 37 | void set_allow_plain(bool f) { allow_plain_ = f; } |
| 38 | void set_test_server_domain(const std::string& test_server_domain) { |
| 39 | test_server_domain_ = test_server_domain; |
| 40 | } |
| 41 | void set_token_service(const std::string& token_service) { |
| 42 | token_service_ = token_service; |
| 43 | } |
| 44 | |
| 45 | const std::string& user() const { return user_; } |
| 46 | const std::string& host() const { return host_; } |
| 47 | const rtc::CryptString& pass() const { return pass_; } |
| 48 | const std::string& auth_mechanism() const { return auth_mechanism_; } |
| 49 | const std::string& auth_token() const { return auth_token_; } |
| 50 | const std::string& resource() const { return resource_; } |
| 51 | TlsOptions use_tls() const { return use_tls_; } |
| 52 | bool allow_plain() const { return allow_plain_; } |
| 53 | const std::string& test_server_domain() const { return test_server_domain_; } |
| 54 | const std::string& token_service() const { return token_service_; } |
| 55 | |
| 56 | private: |
| 57 | std::string user_; |
| 58 | std::string host_; |
| 59 | rtc::CryptString pass_; |
| 60 | std::string auth_mechanism_; |
| 61 | std::string auth_token_; |
| 62 | std::string resource_; |
| 63 | TlsOptions use_tls_; |
| 64 | bool allow_plain_; |
| 65 | std::string test_server_domain_; |
| 66 | std::string token_service_; |
| 67 | }; |
| 68 | |
| 69 | class XmppClientSettings : public XmppUserSettings { |
| 70 | public: |
| 71 | XmppClientSettings() |
| 72 | : protocol_(cricket::PROTO_TCP), |
| 73 | proxy_(rtc::PROXY_NONE), |
| 74 | proxy_port_(80), |
| 75 | use_proxy_auth_(false) { |
| 76 | } |
| 77 | |
| 78 | void set_server(const rtc::SocketAddress& server) { |
| 79 | server_ = server; |
| 80 | } |
| 81 | void set_protocol(cricket::ProtocolType protocol) { protocol_ = protocol; } |
| 82 | void set_proxy(rtc::ProxyType f) { proxy_ = f; } |
| 83 | void set_proxy_host(const std::string& host) { proxy_host_ = host; } |
| 84 | void set_proxy_port(int port) { proxy_port_ = port; }; |
| 85 | void set_use_proxy_auth(bool f) { use_proxy_auth_ = f; } |
| 86 | void set_proxy_user(const std::string& user) { proxy_user_ = user; } |
| 87 | void set_proxy_pass(const rtc::CryptString& pass) { proxy_pass_ = pass; } |
| 88 | |
| 89 | const rtc::SocketAddress& server() const { return server_; } |
| 90 | cricket::ProtocolType protocol() const { return protocol_; } |
| 91 | rtc::ProxyType proxy() const { return proxy_; } |
| 92 | const std::string& proxy_host() const { return proxy_host_; } |
| 93 | int proxy_port() const { return proxy_port_; } |
| 94 | bool use_proxy_auth() const { return use_proxy_auth_; } |
| 95 | const std::string& proxy_user() const { return proxy_user_; } |
| 96 | const rtc::CryptString& proxy_pass() const { return proxy_pass_; } |
| 97 | |
| 98 | private: |
| 99 | rtc::SocketAddress server_; |
| 100 | cricket::ProtocolType protocol_; |
| 101 | rtc::ProxyType proxy_; |
| 102 | std::string proxy_host_; |
| 103 | int proxy_port_; |
| 104 | bool use_proxy_auth_; |
| 105 | std::string proxy_user_; |
| 106 | rtc::CryptString proxy_pass_; |
| 107 | }; |
| 108 | |
| 109 | } |
| 110 | |
| 111 | #endif // WEBRTC_LIBJINGLE_XMPP_XMPPCLIENT_H_ |