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: XmppUserSettings()22 XmppUserSettings() 23 : use_tls_(buzz::TLS_DISABLED), 24 allow_plain_(false) { 25 } 26 set_user(const std::string & user)27 void set_user(const std::string& user) { user_ = user; } set_host(const std::string & host)28 void set_host(const std::string& host) { host_ = host; } set_pass(const rtc::CryptString & pass)29 void set_pass(const rtc::CryptString& pass) { pass_ = pass; } set_auth_token(const std::string & mechanism,const std::string & token)30 void set_auth_token(const std::string& mechanism, 31 const std::string& token) { 32 auth_mechanism_ = mechanism; 33 auth_token_ = token; 34 } set_resource(const std::string & resource)35 void set_resource(const std::string& resource) { resource_ = resource; } set_use_tls(const TlsOptions use_tls)36 void set_use_tls(const TlsOptions use_tls) { use_tls_ = use_tls; } set_allow_plain(bool f)37 void set_allow_plain(bool f) { allow_plain_ = f; } set_test_server_domain(const std::string & test_server_domain)38 void set_test_server_domain(const std::string& test_server_domain) { 39 test_server_domain_ = test_server_domain; 40 } set_token_service(const std::string & token_service)41 void set_token_service(const std::string& token_service) { 42 token_service_ = token_service; 43 } 44 user()45 const std::string& user() const { return user_; } host()46 const std::string& host() const { return host_; } pass()47 const rtc::CryptString& pass() const { return pass_; } auth_mechanism()48 const std::string& auth_mechanism() const { return auth_mechanism_; } auth_token()49 const std::string& auth_token() const { return auth_token_; } resource()50 const std::string& resource() const { return resource_; } use_tls()51 TlsOptions use_tls() const { return use_tls_; } allow_plain()52 bool allow_plain() const { return allow_plain_; } test_server_domain()53 const std::string& test_server_domain() const { return test_server_domain_; } token_service()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: XmppClientSettings()71 XmppClientSettings() 72 : protocol_(cricket::PROTO_TCP), 73 proxy_(rtc::PROXY_NONE), 74 proxy_port_(80), 75 use_proxy_auth_(false) { 76 } 77 set_server(const rtc::SocketAddress & server)78 void set_server(const rtc::SocketAddress& server) { 79 server_ = server; 80 } set_protocol(cricket::ProtocolType protocol)81 void set_protocol(cricket::ProtocolType protocol) { protocol_ = protocol; } set_proxy(rtc::ProxyType f)82 void set_proxy(rtc::ProxyType f) { proxy_ = f; } set_proxy_host(const std::string & host)83 void set_proxy_host(const std::string& host) { proxy_host_ = host; } set_proxy_port(int port)84 void set_proxy_port(int port) { proxy_port_ = port; }; set_use_proxy_auth(bool f)85 void set_use_proxy_auth(bool f) { use_proxy_auth_ = f; } set_proxy_user(const std::string & user)86 void set_proxy_user(const std::string& user) { proxy_user_ = user; } set_proxy_pass(const rtc::CryptString & pass)87 void set_proxy_pass(const rtc::CryptString& pass) { proxy_pass_ = pass; } 88 server()89 const rtc::SocketAddress& server() const { return server_; } protocol()90 cricket::ProtocolType protocol() const { return protocol_; } proxy()91 rtc::ProxyType proxy() const { return proxy_; } proxy_host()92 const std::string& proxy_host() const { return proxy_host_; } proxy_port()93 int proxy_port() const { return proxy_port_; } use_proxy_auth()94 bool use_proxy_auth() const { return use_proxy_auth_; } proxy_user()95 const std::string& proxy_user() const { return proxy_user_; } proxy_pass()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_ 112