1 /* 2 * Copyright (C) 2008-2021 The QXmpp developers 3 * 4 * Author: 5 * Manjeet Dahiya 6 * 7 * Source: 8 * https://github.com/qxmpp-project/qxmpp 9 * 10 * This file is a part of QXmpp library. 11 * 12 * This library is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU Lesser General Public 14 * License as published by the Free Software Foundation; either 15 * version 2.1 of the License, or (at your option) any later version. 16 * 17 * This library is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * Lesser General Public License for more details. 21 * 22 */ 23 24 #ifndef QXMPPCONFIGURATION_H 25 #define QXMPPCONFIGURATION_H 26 27 #include "QXmppGlobal.h" 28 29 #include <QSharedDataPointer> 30 #include <QString> 31 32 class QNetworkProxy; 33 class QSslCertificate; 34 class QXmppConfigurationPrivate; 35 36 /// \brief The QXmppConfiguration class holds configuration options. 37 /// 38 /// It can be passed to QXmppClient to specify the options when connecting to 39 /// an XMPP server. 40 /// 41 /// It is a container of all the settings, configuration required for 42 /// connecting to an XMPP server. E.g. server name, username, port, type 43 /// of authentication mechanism, type of security used by stream (encryption), 44 /// etc.. 45 /// 46 47 class QXMPP_EXPORT QXmppConfiguration 48 { 49 public: 50 /// An enumeration for type of the Security Mode that is stream is encrypted or not. 51 /// The server may or may not have TLS feature. Server may force the encryption. 52 /// Depending upon all this user can specify following options. 53 enum StreamSecurityMode { 54 TLSEnabled = 0, ///< Encryption is used if available (default). 55 TLSDisabled, ///< No encryption even if the server offers it. 56 TLSRequired, ///< Encryption must be available, otherwise the 57 ///< connection will not be established. 58 LegacySSL ///< Use only legacy SSL mode. 59 }; 60 61 /// An enumeration for various Non-SASL authentication mechanisms available. 62 /// The server may or may not allow QXmppConfiguration::Plain mechanism. So 63 /// specifying the mechanism is just a hint to the library. 64 enum NonSASLAuthMechanism { 65 NonSASLPlain = 0, ///< Plain 66 NonSASLDigest ///< Digest (default) 67 }; 68 69 /// An enumeration for various SASL authentication mechanisms available. 70 /// The server may or may not allow any particular mechanism. So depending 71 /// upon the availability of mechanisms on the server the library will choose 72 /// a mechanism. 73 74 QXmppConfiguration(); 75 QXmppConfiguration(const QXmppConfiguration &other); 76 ~QXmppConfiguration(); 77 QXmppConfiguration &operator=(const QXmppConfiguration &other); 78 79 QString host() const; 80 void setHost(const QString &); 81 82 QString domain() const; 83 void setDomain(const QString &); 84 85 int port() const; 86 void setPort(int); 87 88 QString user() const; 89 void setUser(const QString &); 90 91 QString password() const; 92 void setPassword(const QString &); 93 94 QString resource() const; 95 void setResource(const QString &); 96 97 QString jid() const; 98 void setJid(const QString &jid); 99 100 QString jidBare() const; 101 102 QString facebookAccessToken() const; 103 void setFacebookAccessToken(const QString &); 104 105 QString facebookAppId() const; 106 void setFacebookAppId(const QString &); 107 108 QString googleAccessToken() const; 109 void setGoogleAccessToken(const QString &accessToken); 110 111 QString windowsLiveAccessToken() const; 112 void setWindowsLiveAccessToken(const QString &accessToken); 113 114 bool autoAcceptSubscriptions() const; 115 void setAutoAcceptSubscriptions(bool); 116 117 bool autoReconnectionEnabled() const; 118 void setAutoReconnectionEnabled(bool); 119 120 bool useSASLAuthentication() const; 121 void setUseSASLAuthentication(bool); 122 123 bool useNonSASLAuthentication() const; 124 void setUseNonSASLAuthentication(bool); 125 126 bool ignoreSslErrors() const; 127 void setIgnoreSslErrors(bool); 128 129 QXmppConfiguration::StreamSecurityMode streamSecurityMode() const; 130 void setStreamSecurityMode(QXmppConfiguration::StreamSecurityMode mode); 131 132 QXmppConfiguration::NonSASLAuthMechanism nonSASLAuthMechanism() const; 133 void setNonSASLAuthMechanism(QXmppConfiguration::NonSASLAuthMechanism); 134 135 QString saslAuthMechanism() const; 136 void setSaslAuthMechanism(const QString &mechanism); 137 138 QNetworkProxy networkProxy() const; 139 void setNetworkProxy(const QNetworkProxy &proxy); 140 141 int keepAliveInterval() const; 142 void setKeepAliveInterval(int secs); 143 144 int keepAliveTimeout() const; 145 void setKeepAliveTimeout(int secs); 146 147 QList<QSslCertificate> caCertificates() const; 148 void setCaCertificates(const QList<QSslCertificate> &); 149 150 private: 151 QSharedDataPointer<QXmppConfigurationPrivate> d; 152 }; 153 154 #endif // QXMPPCONFIGURATION_H 155