• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
34 namespace buzz {
35 
36 class XmppUserSettings {
37  public:
XmppUserSettings()38   XmppUserSettings()
39     : use_tls_(false),
40       allow_plain_(false) {
41   }
42 
set_user(const std::string & user)43   void set_user(const std::string & user) { user_ = user; }
set_host(const std::string & host)44   void set_host(const std::string & host) { host_ = host; }
set_pass(const talk_base::CryptString & pass)45   void set_pass(const talk_base::CryptString & pass) { pass_ = pass; }
set_auth_cookie(const std::string & cookie)46   void set_auth_cookie(const std::string & cookie) { auth_cookie_ = cookie; }
set_resource(const std::string & resource)47   void set_resource(const std::string & resource) { resource_ = resource; }
set_use_tls(bool use_tls)48   void set_use_tls(bool use_tls) { use_tls_ = use_tls; }
set_allow_plain(bool f)49   void set_allow_plain(bool f) { allow_plain_ = f; }
set_token_service(const std::string & token_service)50   void set_token_service(const std::string & token_service) {
51     token_service_ = token_service;
52   }
53 
user()54   const std::string & user() const { return user_; }
host()55   const std::string & host() const { return host_; }
pass()56   const talk_base::CryptString & pass() const { return pass_; }
auth_cookie()57   const std::string & auth_cookie() const { return auth_cookie_; }
resource()58   const std::string & resource() const { return resource_; }
use_tls()59   bool use_tls() const { return use_tls_; }
allow_plain()60   bool allow_plain() const { return allow_plain_; }
token_service()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 
74 class XmppClientSettings : public XmppUserSettings {
75  public:
XmppClientSettings()76   XmppClientSettings()
77     : protocol_(cricket::PROTO_TCP),
78       proxy_(talk_base::PROXY_NONE),
79       proxy_port_(80),
80       use_proxy_auth_(false) {
81   }
82 
set_server(const talk_base::SocketAddress & server)83   void set_server(const talk_base::SocketAddress & server) {
84       server_ = server;
85   }
set_protocol(cricket::ProtocolType protocol)86   void set_protocol(cricket::ProtocolType protocol) { protocol_ = protocol; }
set_proxy(talk_base::ProxyType f)87   void set_proxy(talk_base::ProxyType f) { proxy_ = f; }
set_proxy_host(const std::string & host)88   void set_proxy_host(const std::string & host) { proxy_host_ = host; }
set_proxy_port(int port)89   void set_proxy_port(int port) { proxy_port_ = port; };
set_use_proxy_auth(bool f)90   void set_use_proxy_auth(bool f) { use_proxy_auth_ = f; }
set_proxy_user(const std::string & user)91   void set_proxy_user(const std::string & user) { proxy_user_ = user; }
set_proxy_pass(const talk_base::CryptString & pass)92   void set_proxy_pass(const talk_base::CryptString & pass) { proxy_pass_ = pass; }
93 
server()94   const talk_base::SocketAddress & server() const { return server_; }
protocol()95   cricket::ProtocolType protocol() const { return protocol_; }
proxy()96   talk_base::ProxyType proxy() const { return proxy_; }
proxy_host()97   const std::string & proxy_host() const { return proxy_host_; }
proxy_port()98   int proxy_port() const { return proxy_port_; }
use_proxy_auth()99   bool use_proxy_auth() const { return use_proxy_auth_; }
proxy_user()100   const std::string & proxy_user() const { return proxy_user_; }
proxy_pass()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