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 TALK_XMPP_XMPPCLIENTSETTINGS_H_ 29 #define TALK_XMPP_XMPPCLIENTSETTINGS_H_ 30 31 #include "talk/p2p/base/port.h" 32 #include "talk/xmpp/xmppengine.h" 33 #include "webrtc/base/cryptstring.h" 34 35 namespace buzz { 36 37 class XmppUserSettings { 38 public: 39 XmppUserSettings() 40 : use_tls_(buzz::TLS_DISABLED), 41 allow_plain_(false) { 42 } 43 44 void set_user(const std::string& user) { user_ = user; } 45 void set_host(const std::string& host) { host_ = host; } 46 void set_pass(const rtc::CryptString& pass) { pass_ = pass; } 47 void set_auth_token(const std::string& mechanism, 48 const std::string& token) { 49 auth_mechanism_ = mechanism; 50 auth_token_ = token; 51 } 52 void set_resource(const std::string& resource) { resource_ = resource; } 53 void set_use_tls(const TlsOptions use_tls) { use_tls_ = use_tls; } 54 void set_allow_plain(bool f) { allow_plain_ = f; } 55 void set_test_server_domain(const std::string& test_server_domain) { 56 test_server_domain_ = test_server_domain; 57 } 58 void set_token_service(const std::string& token_service) { 59 token_service_ = token_service; 60 } 61 62 const std::string& user() const { return user_; } 63 const std::string& host() const { return host_; } 64 const rtc::CryptString& pass() const { return pass_; } 65 const std::string& auth_mechanism() const { return auth_mechanism_; } 66 const std::string& auth_token() const { return auth_token_; } 67 const std::string& resource() const { return resource_; } 68 TlsOptions use_tls() const { return use_tls_; } 69 bool allow_plain() const { return allow_plain_; } 70 const std::string& test_server_domain() const { return test_server_domain_; } 71 const std::string& token_service() const { return token_service_; } 72 73 private: 74 std::string user_; 75 std::string host_; 76 rtc::CryptString pass_; 77 std::string auth_mechanism_; 78 std::string auth_token_; 79 std::string resource_; 80 TlsOptions use_tls_; 81 bool allow_plain_; 82 std::string test_server_domain_; 83 std::string token_service_; 84 }; 85 86 class XmppClientSettings : public XmppUserSettings { 87 public: 88 XmppClientSettings() 89 : protocol_(cricket::PROTO_TCP), 90 proxy_(rtc::PROXY_NONE), 91 proxy_port_(80), 92 use_proxy_auth_(false) { 93 } 94 95 void set_server(const rtc::SocketAddress& server) { 96 server_ = server; 97 } 98 void set_protocol(cricket::ProtocolType protocol) { protocol_ = protocol; } 99 void set_proxy(rtc::ProxyType f) { proxy_ = f; } 100 void set_proxy_host(const std::string& host) { proxy_host_ = host; } 101 void set_proxy_port(int port) { proxy_port_ = port; }; 102 void set_use_proxy_auth(bool f) { use_proxy_auth_ = f; } 103 void set_proxy_user(const std::string& user) { proxy_user_ = user; } 104 void set_proxy_pass(const rtc::CryptString& pass) { proxy_pass_ = pass; } 105 106 const rtc::SocketAddress& server() const { return server_; } 107 cricket::ProtocolType protocol() const { return protocol_; } 108 rtc::ProxyType proxy() const { return proxy_; } 109 const std::string& proxy_host() const { return proxy_host_; } 110 int proxy_port() const { return proxy_port_; } 111 bool use_proxy_auth() const { return use_proxy_auth_; } 112 const std::string& proxy_user() const { return proxy_user_; } 113 const rtc::CryptString& proxy_pass() const { return proxy_pass_; } 114 115 private: 116 rtc::SocketAddress server_; 117 cricket::ProtocolType protocol_; 118 rtc::ProxyType proxy_; 119 std::string proxy_host_; 120 int proxy_port_; 121 bool use_proxy_auth_; 122 std::string proxy_user_; 123 rtc::CryptString proxy_pass_; 124 }; 125 126 } 127 128 #endif // TALK_XMPP_XMPPCLIENT_H_ 129