xmppclientsettings.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #ifndef THIRD_PARTY_LIBJINGLE_XMPP_XMPP_XMPPCLIENTSETTINGS_H_
  11. #define THIRD_PARTY_LIBJINGLE_XMPP_XMPP_XMPPCLIENTSETTINGS_H_
  12. #include "net/base/host_port_pair.h"
  13. #include "third_party/libjingle_xmpp/xmpp/xmppengine.h"
  14. namespace jingle_xmpp {
  15. enum ProtocolType {
  16. PROTO_TCP = 1,
  17. PROTO_SSLTCP = 2, // Pseudo-TLS.
  18. };
  19. class XmppUserSettings {
  20. public:
  21. XmppUserSettings()
  22. : use_tls_(jingle_xmpp::TLS_DISABLED),
  23. allow_plain_(false) {
  24. }
  25. void set_user(const std::string& user) { user_ = user; }
  26. void set_host(const std::string& host) { host_ = host; }
  27. void set_pass(const std::string& pass) { pass_ = pass; }
  28. void set_auth_token(const std::string& mechanism,
  29. const std::string& token) {
  30. auth_mechanism_ = mechanism;
  31. auth_token_ = token;
  32. }
  33. void set_resource(const std::string& resource) { resource_ = resource; }
  34. void set_use_tls(const TlsOptions use_tls) { use_tls_ = use_tls; }
  35. void set_allow_plain(bool f) { allow_plain_ = f; }
  36. void set_token_service(const std::string& token_service) {
  37. token_service_ = token_service;
  38. }
  39. const std::string& user() const { return user_; }
  40. const std::string& host() const { return host_; }
  41. const std::string& pass() const { return pass_; }
  42. const std::string& auth_mechanism() const { return auth_mechanism_; }
  43. const std::string& auth_token() const { return auth_token_; }
  44. const std::string& resource() const { return resource_; }
  45. TlsOptions use_tls() const { return use_tls_; }
  46. bool allow_plain() const { return allow_plain_; }
  47. const std::string& token_service() const { return token_service_; }
  48. private:
  49. std::string user_;
  50. std::string host_;
  51. std::string pass_;
  52. std::string auth_mechanism_;
  53. std::string auth_token_;
  54. std::string resource_;
  55. TlsOptions use_tls_;
  56. bool allow_plain_;
  57. std::string token_service_;
  58. };
  59. class XmppClientSettings : public XmppUserSettings {
  60. public:
  61. XmppClientSettings() : protocol_(PROTO_TCP) {}
  62. void set_server(const net::HostPortPair& server) { server_ = server; }
  63. void set_protocol(ProtocolType protocol) { protocol_ = protocol; }
  64. const net::HostPortPair& server() const { return server_; }
  65. ProtocolType protocol() const { return protocol_; }
  66. private:
  67. net::HostPortPair server_;
  68. ProtocolType protocol_;
  69. };
  70. }
  71. #endif // THIRD_PARTY_LIBJINGLE_XMPP_XMPP_XMPPCLIENT_H_