aboutsummaryrefslogtreecommitdiff
path: root/source/QXmppClient.cpp
diff options
context:
space:
mode:
authorManjeet Dahiya <manjeetdahiya@gmail.com>2009-11-06 01:26:33 +0000
committerManjeet Dahiya <manjeetdahiya@gmail.com>2009-11-06 01:26:33 +0000
commit5b41934246d2887e3c632415f1f221dfdd10846b (patch)
treec00f85aaed126c6d8001558bd0380302b59f4caf /source/QXmppClient.cpp
parentd95ccb17955aa6a687245ecc5e0b5125f12824a3 (diff)
downloadqxmpp-5b41934246d2887e3c632415f1f221dfdd10846b.tar.gz
Issue 29: allow ConnectToServer to accept a JID instead than a separate user and domain
Diffstat (limited to 'source/QXmppClient.cpp')
-rw-r--r--source/QXmppClient.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/QXmppClient.cpp b/source/QXmppClient.cpp
index 4c3eb0dc..f94dd7da 100644
--- a/source/QXmppClient.cpp
+++ b/source/QXmppClient.cpp
@@ -28,6 +28,7 @@
#include "QXmppMessage.h"
#include "QXmppReconnectionManager.h"
#include "QXmppIbbTransferManager.h"
+#include "QXmppUtils.h"
/// Creates a QXmppClient object.
/// \param parent is passed to the QObject's contructor.
@@ -146,6 +147,39 @@ void QXmppClient::connectToServer(const QString& host, const QString& user,
m_stream->connect();
}
+/// Overloaded function.
+/// \param host host name of the XMPP server where connection has to be made
+/// (e.g. "jabber.org" and "talk.google.com"). It can also be an IP address in
+/// the form of a string (e.g. "192.168.1.25").
+/// \param bareJid BareJid of the account at the specified XMPP server.
+/// E.g. "qxmpp.test1@gmail.com" or qxmpptest@jabber.org.
+/// \param passwd Password for the specified username
+/// \param port Port number at which the XMPP server is listening. The default
+/// value is 5222.
+/// \param initialPresence The initial presence which will be set for this user
+/// after establishing the session. The default value is QXmppPresence::Available
+
+void QXmppClient::connectToServer(const QString& host,
+ const QString& bareJid,
+ const QString& passwd,
+ int port,
+ const QXmppPresence& initialPresence)
+{
+ QString user, domain;
+ QStringList list = bareJid.split("@");
+ if(list.size() == 2)
+ {
+ user = list.at(0);
+ domain = list.at(1);
+ connectToServer(host, user, passwd, domain, port, initialPresence);
+ }
+ else
+ {
+ qWarning("QXmppClient::connectToServer: Invalid bareJid");
+ log(QString("Invalid bareJid"));
+ }
+}
+
/// After successfully connecting to the server use this function to send
/// stanzas to the server. This function can solely be used to send various kind
/// of stanzas to the server. QXmppPacket is a parent class of all the stanzas