| 1 | /* |
|---|
| 2 | * QuteCom, a voice over Internet phone |
|---|
| 3 | * Copyright (C) 2004-2010 Mbdsys |
|---|
| 4 | * |
|---|
| 5 | * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | * it under the terms of the GNU General Public License as published by |
|---|
| 7 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | * (at your option) any later version. |
|---|
| 9 | * |
|---|
| 10 | * This program is distributed in the hope that it will be useful, |
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | * GNU General Public License for more details. |
|---|
| 14 | * |
|---|
| 15 | * You should have received a copy of the GNU General Public License |
|---|
| 16 | * along with this program; if not, write to the Free Software |
|---|
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | #include <coipmanager_base/account/JabberAccount.h> |
|---|
| 21 | |
|---|
| 22 | #include <util/Logger.h> |
|---|
| 23 | #include <util/String.h> |
|---|
| 24 | |
|---|
| 25 | const std::string JabberAccount::DEFAULT_JABBER_SERVER = String::null; |
|---|
| 26 | const int JabberAccount::DEFAULT_JABBER_PORT = 5222; |
|---|
| 27 | const std::string JabberAccount::DEFAULT_JABBER_RESOURCE = "QuteCom"; |
|---|
| 28 | const bool JabberAccount::DEFAULT_JABBER_USE_TLS = true; |
|---|
| 29 | const bool JabberAccount::DEFAULT_JABBER_REQUIRE_TLS = true; |
|---|
| 30 | const bool JabberAccount::DEFAULT_JABBER_USE_OLD_SSL = false; |
|---|
| 31 | const bool JabberAccount::DEFAULT_JABBER_AUTH_PLAIN_IN_CLEAR = false; |
|---|
| 32 | const std::string JabberAccount::DEFAULT_JABBER_CONNECTION_SERVER = String::null; |
|---|
| 33 | |
|---|
| 34 | JabberAccount::JabberAccount() |
|---|
| 35 | : IAccount(String::null, String::null, EnumAccountType::AccountTypeJabber) { |
|---|
| 36 | |
|---|
| 37 | _jabberServer = DEFAULT_JABBER_SERVER; |
|---|
| 38 | _jabberServerPort = DEFAULT_JABBER_PORT; |
|---|
| 39 | _resource = DEFAULT_JABBER_RESOURCE; |
|---|
| 40 | _tlsUsed = DEFAULT_JABBER_USE_TLS; |
|---|
| 41 | _tlsRequired = DEFAULT_JABBER_REQUIRE_TLS; |
|---|
| 42 | _oldSSLUsed = DEFAULT_JABBER_USE_OLD_SSL; |
|---|
| 43 | _authPlainInClearUsed = DEFAULT_JABBER_AUTH_PLAIN_IN_CLEAR; |
|---|
| 44 | _connectionServer = DEFAULT_JABBER_CONNECTION_SERVER; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | JabberAccount::JabberAccount(const std::string & login, const std::string & password) |
|---|
| 48 | : IAccount(login, password, EnumAccountType::AccountTypeJabber) { |
|---|
| 49 | |
|---|
| 50 | _jabberServer = DEFAULT_JABBER_SERVER; |
|---|
| 51 | _jabberServerPort = DEFAULT_JABBER_PORT; |
|---|
| 52 | _resource = DEFAULT_JABBER_RESOURCE; |
|---|
| 53 | _tlsUsed = DEFAULT_JABBER_USE_TLS; |
|---|
| 54 | _tlsRequired = DEFAULT_JABBER_REQUIRE_TLS; |
|---|
| 55 | _oldSSLUsed = DEFAULT_JABBER_USE_OLD_SSL; |
|---|
| 56 | _authPlainInClearUsed = DEFAULT_JABBER_AUTH_PLAIN_IN_CLEAR; |
|---|
| 57 | _connectionServer = DEFAULT_JABBER_CONNECTION_SERVER; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | JabberAccount::JabberAccount(const JabberAccount & account) |
|---|
| 61 | : IAccount(account) { |
|---|
| 62 | copy(account); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | JabberAccount::JabberAccount(const IAccount * iAccount) { |
|---|
| 66 | const JabberAccount * account = dynamic_cast<const JabberAccount *>(iAccount); |
|---|
| 67 | if (account) { |
|---|
| 68 | copy(*account); |
|---|
| 69 | } else { |
|---|
| 70 | LOG_FATAL("given IAccount is not an JabberAccount"); |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | void JabberAccount::copy(const JabberAccount & account) { |
|---|
| 75 | IAccount::copy(account); |
|---|
| 76 | _jabberServer = account._jabberServer; |
|---|
| 77 | _jabberServerPort = account._jabberServerPort; |
|---|
| 78 | _resource = account._resource; |
|---|
| 79 | _tlsUsed = account._tlsUsed; |
|---|
| 80 | _tlsRequired = account._tlsRequired; |
|---|
| 81 | _oldSSLUsed = account._oldSSLUsed; |
|---|
| 82 | _authPlainInClearUsed = account._authPlainInClearUsed; |
|---|
| 83 | _connectionServer = account._connectionServer; |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | JabberAccount::~JabberAccount() { |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | JabberAccount * JabberAccount::clone() const { |
|---|
| 90 | return new JabberAccount(*this); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | void JabberAccount::setServer(const std::string & jabberServer) { |
|---|
| 94 | _jabberServer = jabberServer; |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | std::string JabberAccount::getServer() const { |
|---|
| 98 | return _jabberServer; |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | void JabberAccount::setServerPort(int jabberServerPort) { |
|---|
| 102 | _jabberServerPort = jabberServerPort; |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | int JabberAccount::getServerPort() const { |
|---|
| 106 | return _jabberServerPort; |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | void JabberAccount::setResource(const std::string & resource) { |
|---|
| 110 | _resource = resource; |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | std::string JabberAccount::getResource() const { |
|---|
| 114 | return _resource; |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | void JabberAccount::setTLS(bool useTLS) { |
|---|
| 118 | _tlsUsed = useTLS; |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | bool JabberAccount::isTLSUsed() const { |
|---|
| 122 | return _tlsUsed; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | void JabberAccount::setTLSRequired(bool requireTLS) { |
|---|
| 126 | _tlsRequired = requireTLS; |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | bool JabberAccount::isTLSRequired() const { |
|---|
| 130 | return _tlsRequired; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | void JabberAccount::setOldSSLUsed(bool oldSSLUsed) { |
|---|
| 134 | _oldSSLUsed = oldSSLUsed; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | bool JabberAccount::isOldSSLUsed() const { |
|---|
| 138 | return _oldSSLUsed; |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | void JabberAccount::setAuthPlainInClearUsed(bool useAuthPlainInClear) { |
|---|
| 142 | _authPlainInClearUsed = useAuthPlainInClear; |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | bool JabberAccount::isAuthPlainInClearUsed() const { |
|---|
| 146 | return _authPlainInClearUsed; |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | void JabberAccount::setConnectionServer(const std::string & connectionServer) { |
|---|
| 150 | _connectionServer = connectionServer; |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | std::string JabberAccount::getConnectionServer() const { |
|---|
| 154 | return _connectionServer; |
|---|
| 155 | } |
|---|