diff options
| author | Manjeet Dahiya <manjeetdahiya@gmail.com> | 2009-09-07 15:17:44 +0000 |
|---|---|---|
| committer | Manjeet Dahiya <manjeetdahiya@gmail.com> | 2009-09-07 15:17:44 +0000 |
| commit | 0b606b76e679c587fb14c2472de1b809954f29bf (patch) | |
| tree | e5e62344d87a95d9fc1601bea953befe7512ca0d /source | |
| parent | da98f95e3130149725c3e96313619404dd7debd3 (diff) | |
| download | qxmpp-0b606b76e679c587fb14c2472de1b809954f29bf.tar.gz | |
XEP-0054: vcard-temp implementation and other code cleanups
Diffstat (limited to 'source')
| -rw-r--r-- | source/QXmppClient.cpp | 32 | ||||
| -rw-r--r-- | source/QXmppClient.h | 16 | ||||
| -rw-r--r-- | source/QXmppConfiguration.cpp | 7 | ||||
| -rw-r--r-- | source/QXmppConfiguration.h | 15 | ||||
| -rw-r--r-- | source/QXmppIq.cpp | 3 | ||||
| -rw-r--r-- | source/QXmppLogger.cpp | 6 | ||||
| -rw-r--r-- | source/QXmppMessage.cpp | 3 | ||||
| -rw-r--r-- | source/QXmppMessage.h | 4 | ||||
| -rw-r--r-- | source/QXmppPresence.cpp | 14 | ||||
| -rw-r--r-- | source/QXmppPresence.h | 1 | ||||
| -rw-r--r-- | source/QXmppReconnectionManager.cpp | 29 | ||||
| -rw-r--r-- | source/QXmppReconnectionManager.h | 26 | ||||
| -rw-r--r-- | source/QXmppRoster.cpp | 24 | ||||
| -rw-r--r-- | source/QXmppRoster.h | 18 | ||||
| -rw-r--r-- | source/QXmppRosterIq.cpp | 3 | ||||
| -rw-r--r-- | source/QXmppRosterIq.h | 3 | ||||
| -rw-r--r-- | source/QXmppStanza.cpp | 6 | ||||
| -rw-r--r-- | source/QXmppStream.cpp | 127 | ||||
| -rw-r--r-- | source/QXmppStream.h | 7 | ||||
| -rw-r--r-- | source/QXmppUtils.cpp | 54 | ||||
| -rw-r--r-- | source/QXmppUtils.h | 16 | ||||
| -rw-r--r-- | source/QXmppVCard.cpp | 101 | ||||
| -rw-r--r-- | source/QXmppVCard.h | 55 | ||||
| -rw-r--r-- | source/QXmppVCardManager.cpp | 44 | ||||
| -rw-r--r-- | source/QXmppVCardManager.h | 52 | ||||
| -rw-r--r-- | source/source.pro | 8 |
26 files changed, 575 insertions, 99 deletions
diff --git a/source/QXmppClient.cpp b/source/QXmppClient.cpp index 7fcfe1fb..1403b393 100644 --- a/source/QXmppClient.cpp +++ b/source/QXmppClient.cpp @@ -34,12 +34,12 @@ QXmppClient::QXmppClient(QObject *parent) {
m_stream = new QXmppStream(this);
- bool check = connect(m_stream, SIGNAL(messageReceived(const QXmppMessage&)), this,
- SIGNAL(messageReceived(const QXmppMessage&)));
+ bool check = connect(m_stream, SIGNAL(messageReceived(const QXmppMessage&)),
+ this, SIGNAL(messageReceived(const QXmppMessage&)));
Q_ASSERT(check);
- check = connect(m_stream, SIGNAL(presenceReceived(const QXmppPresence&)), this,
- SIGNAL(presenceReceived(const QXmppPresence&)));
+ check = connect(m_stream, SIGNAL(presenceReceived(const QXmppPresence&)),
+ this, SIGNAL(presenceReceived(const QXmppPresence&)));
Q_ASSERT(check);
check = connect(m_stream, SIGNAL(iqReceived(const QXmppIq&)), this,
@@ -70,8 +70,10 @@ QXmppConfiguration& QXmppClient::getConfiguration() return m_config;
}
-void QXmppClient::connectToServer(const QString& host, const QString& user, const QString& passwd,
- const QString& domain, int port, const QXmppPresence& initialPresence)
+void QXmppClient::connectToServer(const QString& host, const QString& user,
+ const QString& passwd, const QString& domain,
+ int port,
+ const QXmppPresence& initialPresence)
{
m_config.setHost(host);
m_config.setUser(user);
@@ -84,7 +86,8 @@ void QXmppClient::connectToServer(const QString& host, const QString& user, cons m_stream->connect();
}
-void QXmppClient::connectToServer(const QXmppConfiguration& config, const QXmppPresence& initialPresence)
+void QXmppClient::connectToServer(const QXmppConfiguration& config,
+ const QXmppPresence& initialPresence)
{
m_config = config;
@@ -172,18 +175,20 @@ QXmppReconnectionManager* QXmppClient::getReconnectionManager() return m_reconnectionManager;
}
-bool QXmppClient::setReconnectionManager(QXmppReconnectionManager* reconnectionManager)
+bool QXmppClient::setReconnectionManager(QXmppReconnectionManager*
+ reconnectionManager)
{
if(m_reconnectionManager)
delete m_reconnectionManager;
m_reconnectionManager = reconnectionManager;
- bool check = connect(this, SIGNAL(connected()), m_reconnectionManager, SLOT(connected()));
+ bool check = connect(this, SIGNAL(connected()), m_reconnectionManager,
+ SLOT(connected()));
Q_ASSERT(check);
- check = connect(this, SIGNAL(error(QXmppClient::Error)), m_reconnectionManager,
- SLOT(error(QXmppClient::Error)));
+ check = connect(this, SIGNAL(error(QXmppClient::Error)),
+ m_reconnectionManager, SLOT(error(QXmppClient::Error)));
Q_ASSERT(check);
}
@@ -191,3 +196,8 @@ QAbstractSocket::SocketError QXmppClient::getSocketError() {
return m_stream->getSocketError();
}
+
+QXmppVCardManager& QXmppClient::getVCardManager()
+{
+ return m_stream->getVCardManager();
+}
diff --git a/source/QXmppClient.h b/source/QXmppClient.h index 69fd6006..79e28d6e 100644 --- a/source/QXmppClient.h +++ b/source/QXmppClient.h @@ -37,6 +37,7 @@ class QXmppPacket; class QXmppIq;
class QXmppRoster;
class QXmppReconnectionManager;
+class QXmppVCardManager;
class QXmppClient : public QObject
{
@@ -52,16 +53,23 @@ public: QXmppClient(QObject *parent = 0);
~QXmppClient();
- void connectToServer(const QString& host, const QString& user, const QString& passwd,
- const QString& domain, int port = 5222,
- const QXmppPresence& initialPresence = QXmppPresence());
- void connectToServer(const QXmppConfiguration&, const QXmppPresence& initialPresence = QXmppPresence());
+ void connectToServer(const QString& host,
+ const QString& user,
+ const QString& passwd,
+ const QString& domain,
+ int port = 5222,
+ const QXmppPresence& initialPresence =
+ QXmppPresence());
+ void connectToServer(const QXmppConfiguration&,
+ const QXmppPresence& initialPresence =
+ QXmppPresence());
void disconnect();
QXmppRoster& getRoster();
QXmppConfiguration& getConfiguration();
QXmppReconnectionManager* getReconnectionManager();
bool setReconnectionManager(QXmppReconnectionManager*);
const QXmppPresence& getClientPresence() const;
+ QXmppVCardManager& getVCardManager();
signals:
void connected();
diff --git a/source/QXmppConfiguration.cpp b/source/QXmppConfiguration.cpp index b42b0472..f62d1d98 100644 --- a/source/QXmppConfiguration.cpp +++ b/source/QXmppConfiguration.cpp @@ -24,8 +24,11 @@ #include "QXmppConfiguration.h"
-QXmppConfiguration::QXmppConfiguration():m_resource("QXmpp"), m_autoAcceptSubscriptions(true),
- m_sendIntialPresence(true), m_sendRosterRequest(true), m_port(5222),
+QXmppConfiguration::QXmppConfiguration() : m_resource("QXmpp"),
+ m_autoAcceptSubscriptions(true),
+ m_sendIntialPresence(true),
+ m_sendRosterRequest(true),
+ m_port(5222),
m_keepAlivePingsInterval(100), m_autoReconnectionEnabled(true)
{
diff --git a/source/QXmppConfiguration.h b/source/QXmppConfiguration.h index 82fcccea..b8db22dc 100644 --- a/source/QXmppConfiguration.h +++ b/source/QXmppConfiguration.h @@ -64,11 +64,16 @@ private: QString m_domain;
QString m_resource;
- bool m_autoAcceptSubscriptions; // default is true
- bool m_sendIntialPresence; // default is true
- bool m_sendRosterRequest; // default is true
- int m_keepAlivePingsInterval; // interval in seconds, if negative it won't ping
- bool m_autoReconnectionEnabled; // will keep reconnecting if disconnected, default is true
+ // default is true
+ bool m_autoAcceptSubscriptions;
+ // default is true
+ bool m_sendIntialPresence;
+ // default is true
+ bool m_sendRosterRequest;
+ // interval in seconds, if negative it won't ping
+ int m_keepAlivePingsInterval;
+ // will keep reconnecting if disconnected, default is true
+ bool m_autoReconnectionEnabled;
};
#endif // QXMPPCONFIGURATION_H
diff --git a/source/QXmppIq.cpp b/source/QXmppIq.cpp index 6010ba03..68857c0d 100644 --- a/source/QXmppIq.cpp +++ b/source/QXmppIq.cpp @@ -124,7 +124,8 @@ void QXmppIq::setTypeFromStr(const QString& str) else
{
setType(static_cast<QXmppIq::Type>(-1));
- qWarning("QXmppIq::setTypeFromStr() invalid input string type: %s", qPrintable(str));
+ qWarning("QXmppIq::setTypeFromStr() invalid input string type: %s",
+ qPrintable(str));
return;
}
}
diff --git a/source/QXmppLogger.cpp b/source/QXmppLogger.cpp index 30b57eb9..b6c7638d 100644 --- a/source/QXmppLogger.cpp +++ b/source/QXmppLogger.cpp @@ -60,7 +60,8 @@ void QXmppLogger::log(const QString& str) case QXmppLogger::FILE:
m_file.open(QIODevice::Append);
m_stream.setDevice(&m_file);
- m_stream << QTime::currentTime().toString("hh:mm:ss.zzz") << " : "<< str << "\n\n";
+ m_stream << QTime::currentTime().toString("hh:mm:ss.zzz") << " : "<<
+ str << "\n\n";
m_file.close();
break;
case QXmppLogger::STDOUT:
@@ -80,7 +81,8 @@ void QXmppLogger::log(const QByteArray& str) case QXmppLogger::FILE:
m_file.open(QIODevice::Append);
m_stream.setDevice(&m_file);
- m_stream << QTime::currentTime().toString("hh:mm:ss.zzz") << " : "<< str << "\n\n";
+ m_stream << QTime::currentTime().toString("hh:mm:ss.zzz") << " : "<<
+ str << "\n\n";
m_file.close();
break;
case QXmppLogger::STDOUT:
diff --git a/source/QXmppMessage.cpp b/source/QXmppMessage.cpp index 9ec72be4..54f599bb 100644 --- a/source/QXmppMessage.cpp +++ b/source/QXmppMessage.cpp @@ -102,7 +102,8 @@ void QXmppMessage::setTypeFromStr(const QString& str) else
{
setType(static_cast<QXmppMessage::Type>(-1));
- qWarning("QXmppMessage::setTypeFromStr() invalid input string type: %s", qPrintable(str));
+ qWarning("QXmppMessage::setTypeFromStr() invalid input string type: %s",
+ qPrintable(str));
return;
}
}
diff --git a/source/QXmppMessage.h b/source/QXmppMessage.h index 8755ba5d..ed99eb0e 100644 --- a/source/QXmppMessage.h +++ b/source/QXmppMessage.h @@ -39,8 +39,8 @@ public: Headline
};
- QXmppMessage(const QString& from = "", const QString& to = "", const QString& body = "",
- const QString& thread = "");
+ QXmppMessage(const QString& from = "", const QString& to = "",
+ const QString& body = "", const QString& thread = "");
~QXmppMessage();
QXmppMessage::Type getType() const;
diff --git a/source/QXmppPresence.cpp b/source/QXmppPresence.cpp index fa4c3eb4..f6348a51 100644 --- a/source/QXmppPresence.cpp +++ b/source/QXmppPresence.cpp @@ -26,7 +26,8 @@ #include "QXmppUtils.h"
#include <QtDebug>
-QXmppPresence::QXmppPresence(QXmppPresence::Type type, const QXmppPresence::Status& status)
+QXmppPresence::QXmppPresence(QXmppPresence::Type type,
+ const QXmppPresence::Status& status)
: QXmppStanza(), m_type(type), m_status(status)
{
@@ -178,15 +179,17 @@ void QXmppPresence::setTypeFromStr(const QString& str) else
{
type = static_cast<QXmppPresence::Type>(-1);
- qWarning("QXmppPresence::setTypeFromStr() invalid input string type: %s", qPrintable(str));
+ qWarning("QXmppPresence::setTypeFromStr() invalid input string type: %s",
+ qPrintable(str));
setType(type);
return;
}
}
QXmppPresence::Status::Status(QXmppPresence::Status::Type type,
- const QString statusText, int priority): m_type(type),
- m_statusText(statusText), m_priority(priority)
+ const QString statusText, int priority) :
+ m_type(type),
+ m_statusText(statusText), m_priority(priority)
{
}
@@ -269,7 +272,8 @@ QString QXmppPresence::Status::getTypeStr() const text = "chat";
break;
default:
- qWarning("QXmppPresence::Status::getTypeStr() invalid type %d", (int)getType());
+ qWarning("QXmppPresence::Status::getTypeStr() invalid type %d",
+ (int)getType());
break;
}
return text;
diff --git a/source/QXmppPresence.h b/source/QXmppPresence.h index f416f1ff..526fbe20 100644 --- a/source/QXmppPresence.h +++ b/source/QXmppPresence.h @@ -94,6 +94,7 @@ private: QXmppPresence::Status m_status;
QString getTypeStr() const;
+ QByteArray getExtensionsXML() const;
};
#endif // QXMPPPRESENCE_H
diff --git a/source/QXmppReconnectionManager.cpp b/source/QXmppReconnectionManager.cpp index 1cda682a..31183abc 100644 --- a/source/QXmppReconnectionManager.cpp +++ b/source/QXmppReconnectionManager.cpp @@ -1,9 +1,34 @@ +/*
+ * Copyright (C) 2008-2009 Manjeet Dahiya
+ *
+ * Author:
+ * Manjeet Dahiya
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+
#include "QXmppReconnectionManager.h"
#include "QXmppClient.h"
#include "QXmppUtils.h"
-QXmppReconnectionManager::QXmppReconnectionManager(QXmppClient* client):m_timer(this),
- m_reconnectionTries(0), m_client(client), QObject(client)
+QXmppReconnectionManager::QXmppReconnectionManager(QXmppClient* client) :
+ m_timer(this),
+ m_reconnectionTries(0), m_client(client), QObject(client)
{
m_timer.setSingleShot(true);
bool check = connect(&m_timer, SIGNAL(timeout()), SLOT(reconnect()));
diff --git a/source/QXmppReconnectionManager.h b/source/QXmppReconnectionManager.h index 77f0e5b6..7dc0ac23 100644 --- a/source/QXmppReconnectionManager.h +++ b/source/QXmppReconnectionManager.h @@ -1,3 +1,27 @@ +/*
+ * Copyright (C) 2008-2009 Manjeet Dahiya
+ *
+ * Author:
+ * Manjeet Dahiya
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+
#ifndef QXMPPRECONNECTIONMANAGER_H
#define QXMPPRECONNECTIONMANAGER_H
@@ -5,8 +29,6 @@ #include <QTimer>
#include "QXmppClient.h"
-class QXmppClient;
-
class QXmppReconnectionManager : public QObject
{
Q_OBJECT
diff --git a/source/QXmppRoster.cpp b/source/QXmppRoster.cpp index 0c114e92..0eade27c 100644 --- a/source/QXmppRoster.cpp +++ b/source/QXmppRoster.cpp @@ -62,8 +62,10 @@ void QXmppRoster::rosterIqReceived(const QXmppRosterIq& rosterIq) m_entries[bareJid].setBareJid(bareJid);
m_entries[bareJid].setName(items.at(i).getSubscriptionStatus());
m_entries[bareJid].setSubscriptionType(
- static_cast<QXmppRosterEntry::SubscriptionType>(items.at(i).getSubscriptionType()));
- m_entries[bareJid].setSubscriptionStatus(items.at(i).getSubscriptionStatus());
+ static_cast<QXmppRosterEntry::SubscriptionType>(
+ items.at(i).getSubscriptionType()));
+ m_entries[bareJid].setSubscriptionStatus(
+ items.at(i).getSubscriptionStatus());
m_entries[bareJid].setGroups(items.at(i).getGroups());
emit rosterChanged(bareJid);
}
@@ -88,7 +90,8 @@ QString QXmppRoster::QXmppRosterEntry::getName() const return m_name;
}
-QXmppRoster::QXmppRosterEntry::SubscriptionType QXmppRoster::QXmppRosterEntry::getSubscriptionType() const
+QXmppRoster::QXmppRosterEntry::SubscriptionType
+ QXmppRoster::QXmppRosterEntry::getSubscriptionType() const
{
return m_type;
}
@@ -113,7 +116,8 @@ void QXmppRoster::QXmppRosterEntry::setName(const QString& str) m_name = str;
}
-void QXmppRoster::QXmppRosterEntry::setSubscriptionType(QXmppRosterEntry::SubscriptionType type)
+void QXmppRoster::QXmppRosterEntry::setSubscriptionType(
+ QXmppRosterEntry::SubscriptionType type)
{
m_type = type;
}
@@ -138,7 +142,8 @@ QStringList QXmppRoster::getRosterBareJids() const return m_entries.keys();
}
-QXmppRoster::QXmppRosterEntry QXmppRoster::getRosterEntry(const QString& bareJid) const
+QXmppRoster::QXmppRosterEntry QXmppRoster::getRosterEntry(
+ const QString& bareJid) const
{
// will return blank entry if bareJid does'nt exist
if(m_entries.contains(bareJid))
@@ -150,7 +155,8 @@ QXmppRoster::QXmppRosterEntry QXmppRoster::getRosterEntry(const QString& bareJid }
}
-QMap<QString, QXmppRoster::QXmppRosterEntry> QXmppRoster::getRosterEntries() const
+QMap<QString, QXmppRoster::QXmppRosterEntry>
+ QXmppRoster::getRosterEntries() const
{
return m_entries;
}
@@ -165,7 +171,8 @@ QStringList QXmppRoster::getResources(const QString& bareJid) const return QStringList();
}
-QMap<QString, QXmppPresence> QXmppRoster::getAllPresencesForBareJid(const QString& bareJid) const
+QMap<QString, QXmppPresence> QXmppRoster::getAllPresencesForBareJid(
+ const QString& bareJid) const
{
if(m_presences.contains(bareJid))
return m_presences[bareJid];
@@ -176,7 +183,8 @@ QMap<QString, QXmppPresence> QXmppRoster::getAllPresencesForBareJid(const QStrin }
}
-QXmppPresence QXmppRoster::getPresence(const QString& bareJid, const QString& resource) const
+QXmppPresence QXmppRoster::getPresence(const QString& bareJid,
+ const QString& resource) const
{
if(m_presences.contains(bareJid) && m_presences[bareJid].contains(resource))
return m_presences[bareJid][resource];
diff --git a/source/QXmppRoster.h b/source/QXmppRoster.h index 13f0082c..f9982083 100644 --- a/source/QXmppRoster.h +++ b/source/QXmppRoster.h @@ -69,7 +69,8 @@ public: QString m_bareJid;
SubscriptionType m_type;
QString m_name;
- QString m_subscriptionStatus; // can be subscribe/unsubscribe (attribute "ask")
+ // can be subscribe/unsubscribe (attribute "ask")
+ QString m_subscriptionStatus;
QSet<QString> m_groups;
};
@@ -82,17 +83,22 @@ public: QStringList getResources(const QString& bareJid) const;
QMap<QString, QMap<QString, QXmppPresence> > getAllPresences() const;
- QMap<QString, QXmppPresence> getAllPresencesForBareJid(const QString& bareJid) const;
- QXmppPresence getPresence(const QString& bareJid, const QString& resource) const;
+ QMap<QString, QXmppPresence> getAllPresencesForBareJid(
+ const QString& bareJid) const;
+ QXmppPresence getPresence(const QString& bareJid,
+ const QString& resource) const;
signals:
void presenceChanged(const QString& bareJid, const QString& resource);
void rosterChanged(const QString& bareJid);
private:
- QXmppStream* m_stream; //reverse pointer to stream
- QMap<QString, QXmppRoster::QXmppRosterEntry> m_entries; //map of bareJid and its rosterEntry
- QMap<QString, QMap<QString, QXmppPresence> > m_presences; // map of resources of the jid and map of resouces and presences
+ //reverse pointer to stream
+ QXmppStream* m_stream;
+ //map of bareJid and its rosterEntry
+ QMap<QString, QXmppRoster::QXmppRosterEntry> m_entries;
+ // map of resources of the jid and map of resouces and presences
+ QMap<QString, QMap<QString, QXmppPresence> > m_presences;
private slots:
void presenceReceived(const QXmppPresence&);
diff --git a/source/QXmppRosterIq.cpp b/source/QXmppRosterIq.cpp index bcb670ea..44708ded 100644 --- a/source/QXmppRosterIq.cpp +++ b/source/QXmppRosterIq.cpp @@ -68,7 +68,8 @@ QByteArray QXmppRosterIq::toXmlElementFromChild() const return data.toAscii();
}
-QXmppRosterIq::Item::SubscriptionType QXmppRosterIq::Item::getSubscriptionType() const
+QXmppRosterIq::Item::SubscriptionType
+ QXmppRosterIq::Item::getSubscriptionType() const
{
return m_type;
}
diff --git a/source/QXmppRosterIq.h b/source/QXmppRosterIq.h index 22bc1354..06aec148 100644 --- a/source/QXmppRosterIq.h +++ b/source/QXmppRosterIq.h @@ -64,7 +64,8 @@ public: QString m_bareJid;
SubscriptionType m_type;
QString m_name;
- QString m_subscriptionStatus; // can be subscribe/unsubscribe (attribute "ask")
+ // can be subscribe/unsubscribe (attribute "ask")
+ QString m_subscriptionStatus;
QSet<QString> m_groups;
};
diff --git a/source/QXmppStanza.cpp b/source/QXmppStanza.cpp index 32b47e7b..039dafe9 100644 --- a/source/QXmppStanza.cpp +++ b/source/QXmppStanza.cpp @@ -31,7 +31,8 @@ int QXmppStanza::s_uniqeIdNo = 0;
QXmppStanza::Error::Error(): m_type(static_cast<QXmppStanza::Error::Type>(-1)),
- m_condition(static_cast<QXmppStanza::Error::Condition>(-1)), m_text("")
+ m_condition(static_cast<QXmppStanza::Error::Condition>(-1)),
+ m_text("")
{
}
@@ -40,7 +41,8 @@ QXmppStanza::Error::Error(Type type, Condition cond, const QString& text): {
}
-QXmppStanza::Error::Error(const QString& type, const QString& cond, const QString& text):
+QXmppStanza::Error::Error(const QString& type, const QString& cond,
+ const QString& text):
m_text(text)
{
setTypeFromStr(type);
diff --git a/source/QXmppStream.cpp b/source/QXmppStream.cpp index 959e576f..65a480ae 100644 --- a/source/QXmppStream.cpp +++ b/source/QXmppStream.cpp @@ -34,6 +34,7 @@ #include "QXmppRosterIq.h"
#include "QXmppMessage.h"
#include "QXmppConstants.h"
+#include "QXmppVCard.h"
#include <QDomDocument>
#include <QStringList>
@@ -44,31 +45,46 @@ static const QByteArray streamRootElementStart = "<?xml version=\"1.0\"?><stream static const QByteArray streamRootElementEnd = "</stream:stream>";
QXmppStream::QXmppStream(QXmppClient* client)
- : QObject(client), m_roster(this), m_client(client), m_sessionAvaliable(false)
+ : QObject(client), m_roster(this), m_client(client),
+ m_sessionAvaliable(false), m_vCardManager(m_client)
{
- bool check = QObject::connect(&m_socket, SIGNAL(hostFound()), this, SLOT(socketHostFound()));
+ bool check = QObject::connect(&m_socket, SIGNAL(hostFound()),
+ this, SLOT(socketHostFound()));
Q_ASSERT(check);
- check = QObject::connect(&m_socket, SIGNAL(connected()), this, SLOT(socketConnected()));
+ check = QObject::connect(&m_socket, SIGNAL(connected()),
+ this, SLOT(socketConnected()));
Q_ASSERT(check);
- check = QObject::connect(&m_socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
+ check = QObject::connect(&m_socket, SIGNAL(disconnected()),
+ this, SLOT(socketDisconnected()));
Q_ASSERT(check);
- check = QObject::connect(&m_socket, SIGNAL(readyRead()), this, SLOT(socketReadReady()));
+ check = QObject::connect(&m_socket, SIGNAL(readyRead()),
+ this, SLOT(socketReadReady()));
Q_ASSERT(check);
- check = QObject::connect(&m_socket, SIGNAL(encrypted()), this, SLOT(socketEncrypted()));
+ check = QObject::connect(&m_socket, SIGNAL(encrypted()),
+ this, SLOT(socketEncrypted()));
Q_ASSERT(check);
- check = QObject::connect(&m_socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(socketSslErrors(const QList<QSslError> &)));
+ check = QObject::connect(&m_socket,
+ SIGNAL(sslErrors(const QList<QSslError>&)), this,
+ SLOT(socketSslErrors(const QList<QSslError>&)));
Q_ASSERT(check);
- check = QObject::connect(&m_socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(socketError(QAbstractSocket::SocketError)));
+ check = QObject::connect(&m_socket,
+ SIGNAL(error(QAbstractSocket::SocketError)), this,
+ SLOT(socketError(QAbstractSocket::SocketError)));
Q_ASSERT(check);
- check = QObject::connect(this, SIGNAL(presenceReceived(const QXmppPresence&)),
- &m_roster, SLOT(presenceReceived(const QXmppPresence&)));
+ check = QObject::connect(this,
+ SIGNAL(presenceReceived(const QXmppPresence&)),
+ &m_roster,
+ SLOT(presenceReceived(const QXmppPresence&)));
Q_ASSERT(check);
check = QObject::connect(this, SIGNAL(rosterIqReceived(const QXmppRosterIq&)),
&m_roster, SLOT(rosterIqReceived(const QXmppRosterIq&)));
Q_ASSERT(check);
+
+ check = QObject::connect(this, SIGNAL(vCardIqReceived(const QXmppRosterIq&)),
+ &m_vCardManager, SLOT(vCardIqReceived(const QXmppRosterIq&)));
+ Q_ASSERT(check);
}
QXmppStream::~QXmppStream()
@@ -84,8 +100,10 @@ QXmppConfiguration& QXmppStream::getConfiguration() void QXmppStream::connect()
{
// work with time out
- log(QString("Connecting to: %1:%2").arg(getConfiguration().getHost()).arg(getConfiguration().getPort()));
- m_socket.connectToHost(getConfiguration().getHost(), getConfiguration().getPort());
+ log(QString("Connecting to: %1:%2").arg(getConfiguration().
+ getHost()).arg(getConfiguration().getPort()));
+ m_socket.connectToHost(getConfiguration().
+ getHost(), getConfiguration().getPort());
}
void QXmppStream::socketSslErrors(const QList<QSslError> & error)
@@ -169,13 +187,16 @@ void QXmppStream::parser(const QByteArray& data) {
if(element.namespaceURI() == ns_tls)
{
- if(element.tagName() == "starttls" && element.firstChildElement().tagName() == "required")
+ if(element.tagName() == "starttls" &&
+ element.firstChildElement().tagName() ==
+ "required")
{
sendStartTls();
return;
}
}
- else if(element.namespaceURI() == ns_sasl && element.tagName() == "mechanisms")
+ else if(element.namespaceURI() == ns_sasl &&
+ element.tagName() == "mechanisms")
{
log(QString("Mechanisms:"));
QDomElement subElement = element.firstChildElement();
@@ -191,11 +212,13 @@ void QXmppStream::parser(const QByteArray& data) }
sendAuthPlain();
}
- else if(element.namespaceURI() == ns_bind && element.tagName() == "bind")
+ else if(element.namespaceURI() == ns_bind &&
+ element.tagName() == "bind")
{
sendBindIQ();
}
- else if(element.namespaceURI() == ns_session && element.tagName() == "session")
+ else if(element.namespaceURI() == ns_session &&
+ element.tagName() == "session")
{
m_sessionAvaliable = true;
}
@@ -220,7 +243,6 @@ void QXmppStream::parser(const QByteArray& data) sendStartStream();
}
}
-//===========done below=======================================================================
else if(ns == ns_client)
{
if(nodeRecv.tagName() == "iq")
@@ -239,7 +261,8 @@ void QXmppStream::parser(const QByteArray& data) if(id == m_sessionId)
{
- // get back add configuration whether to send roster and intial presence in beginning
+ // get back add configuration whether to send
+ // roster and intial presence in beginning
// process SessionIq
// xmpp connection made
@@ -257,7 +280,8 @@ void QXmppStream::parser(const QByteArray& data) else if(id == m_bindId)
{
QXmppBind bind(type);
- QString jid = nodeRecv.firstChildElement("bind").firstChildElement("jid").text();
+ QString jid = nodeRecv.firstChildElement("bind").
+ firstChildElement("jid").text();
bind.setResource(jidToResource(jid));
bind.setJid(jidToBareJid(jid));
bind.setId(id);
@@ -266,9 +290,12 @@ void QXmppStream::parser(const QByteArray& data) processBindIq(bind);
iqPacket = bind;
}
- else if(nodeRecv.firstChildElement("query").namespaceURI() == ns_roster)
+ else if(nodeRecv.firstChildElement("query").
+ namespaceURI() == ns_roster)
{
- QDomElement itemElement = nodeRecv.firstChildElement("query").firstChildElement("item");
+ QDomElement itemElement = nodeRecv.
+ firstChildElement("query").
+ firstChildElement("item");
QXmppRosterIq rosterIq(nodeRecv.attribute("type"));
rosterIq.setId(id);
rosterIq.setTo(to);
@@ -277,17 +304,27 @@ void QXmppStream::parser(const QByteArray& data) {
QXmppRosterIq::Item item;
item.setBareJid(itemElement.attribute("jid"));
- item.setSubscriptionTypeFromStr(itemElement.attribute("subscription"));
- item.setSubscriptionStatus(itemElement.attribute("ask"));
+ item.setSubscriptionTypeFromStr(
+ itemElement.attribute("subscription"));
+ item.setSubscriptionStatus(
+ itemElement.attribute("ask"));
rosterIq.addItem(item);
itemElement = itemElement.nextSiblingElement();
}
processRosterIq(rosterIq);
iqPacket = rosterIq;
}
- //else if(call extension)
- //{
- //}
+ // extensions
+ // vCard - XEP-0054
+ // http://xmpp.org/extensions/xep-0054.html
+ else if(nodeRecv.firstChildElement("vCard").
+ namespaceURI() == ns_vcard)
+ {
+ QXmppVCard vcardIq;
+ vcardIq.parse(nodeRecv);
+ emit vCardIqReceived(vcardIq);
+ iqPacket = vcardIq;
+ }
else // didn't understant the iq...reply with error
{
QXmppIq iq(QXmppIq::Error);
@@ -310,19 +347,24 @@ void QXmppStream::parser(const QByteArray& data) presence.setFrom(nodeRecv.attribute("from"));
presence.setTo(nodeRecv.attribute("to"));
- QString statusText = nodeRecv.firstChildElement("status").text();
- QString show = nodeRecv.firstChildElement("show").text();
- int priority = nodeRecv.firstChildElement("priority").text().toInt();
+ QString statusText = nodeRecv.
+ firstChildElement("status").text();
+ QString show = nodeRecv.
+ firstChildElement("show").text();
+ int priority = nodeRecv.
+ firstChildElement("priority").text().toInt();
QXmppPresence::Status status;
status.setTypeFromStr(show);
status.setStatusText(statusText);
status.setPriority(priority);
presence.setStatus(status);
- QDomElement errorElement = nodeRecv.firstChildElement("error");
+ QDomElement errorElement = nodeRecv.
+ firstChildElement("error");
if(!errorElement.isNull())
{
- QXmppStanza::Error error = parseStanzaError(errorElement);
+ QXmppStanza::Error error =
+ parseStanzaError(errorElement);
presence.setError(error);
}
@@ -333,14 +375,17 @@ void QXmppStream::parser(const QByteArray& data) QString from = nodeRecv.attribute("from");
QString to = nodeRecv.attribute("to");
QString type = nodeRecv.attribute("type");
- QString body = unescapeString(nodeRecv.firstChildElement("body").text());
- QString sub = unescapeString(nodeRecv.firstChildElement("subject").text());
+ QString body = unescapeString(
+ nodeRecv.firstChildElement("body").text());
+ QString sub = unescapeString(
+ nodeRecv.firstChildElement("subject").text());
QString thread = nodeRecv.firstChildElement("thread").text();
QXmppMessage message(from, to, body, thread);
message.setSubject(sub);
message.setTypeFromStr(type);
- QDomElement errorElement = nodeRecv.firstChildElement("error");
+ QDomElement errorElement = nodeRecv.
+ firstChildElement("error");
if(!errorElement.isNull())
{
QXmppStanza::Error error = parseStanzaError(errorElement);
@@ -399,7 +444,8 @@ void QXmppStream::sendStartTls() void QXmppStream::sendAuthPlain()
{
QByteArray data = "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>";
- QString userPass('\0' + getConfiguration().getUser() + '\0' + getConfiguration().getPasswd());
+ QString userPass('\0' + getConfiguration().getUser() +
+ '\0' + getConfiguration().getPasswd());
data += userPass.toUtf8().toBase64();
data += "</auth>";
sendToServer(data);
@@ -545,7 +591,9 @@ void QXmppStream::processRosterIq(const QXmppRosterIq& rosterIq) // then after recieving following iq user requests contact for subscription
// check thet "from" is newly added in the roster...and remove this ask thing...and do this for all items
- if(rosterIq.getItems().at(0).getSubscriptionType() == QXmppRosterIq::Item::From && rosterIq.getItems().at(0).getSubscriptionStatus().isEmpty())
+ if(rosterIq.getItems().at(0).getSubscriptionType() ==
+ QXmppRosterIq::Item::From && rosterIq.getItems().at(0).
+ getSubscriptionStatus().isEmpty())
sendSubscriptionRequest(rosterIq.getItems().at(0).getBareJid());
break;
default:
@@ -585,3 +633,8 @@ QAbstractSocket::SocketError QXmppStream::getSocketError() {
return m_socketError;
}
+
+QXmppVCardManager& QXmppStream::getVCardManager()
+{
+ return m_vCardManager;
+}
diff --git a/source/QXmppStream.h b/source/QXmppStream.h index 7ea95be1..037f082d 100644 --- a/source/QXmppStream.h +++ b/source/QXmppStream.h @@ -30,6 +30,7 @@ #include "QXmppConfiguration.h"
#include "QXmppRoster.h"
#include "QXmppStanza.h"
+#include "QXmppVCardManager.h"
class QDomElement;
@@ -40,6 +41,7 @@ class QXmppPresence; class QXmppIq;
class QXmppBind;
class QXmppRosterIq;
+class QXmppVCard;
class QXmppMessage;
class QXmppStream : public QObject
@@ -54,6 +56,7 @@ public: void sendSubscriptionRequest(const QString& to);
void disconnect();
QXmppRoster& getRoster();
+ QXmppVCardManager& getVCardManager();
void sendPacket(const QXmppPacket&);
QAbstractSocket::SocketError getSocketError();
@@ -77,6 +80,7 @@ signals: void messageReceived(const QXmppMessage&);
void iqReceived(const QXmppIq&);
void rosterIqReceived(const QXmppRosterIq&);
+ void vCardIqReceived(const QXmppVCard&);
private slots:
void socketHostFound();
@@ -100,6 +104,9 @@ private: // m_xmppStreamError;
// m_xmppStanzaError;
+
+ QXmppVCardManager m_vCardManager;
+
QXmppConfiguration& getConfiguration();
void parser(const QByteArray&);
void sendStartStream();
diff --git a/source/QXmppUtils.cpp b/source/QXmppUtils.cpp index 493d1266..04c2a4ab 100644 --- a/source/QXmppUtils.cpp +++ b/source/QXmppUtils.cpp @@ -27,6 +27,8 @@ #include <QString>
#include <QTextStream>
#include <QByteArray>
+#include <QBuffer>
+#include <QImageReader>
QString jidToResource(const QString& jid)
{
@@ -38,7 +40,8 @@ QString jidToBareJid(const QString& jid) return jid.left(jid.indexOf(QChar('/')));
}
-void helperToXmlAddAttribute(QTextStream& stream, const QString& name, const QString& value)
+void helperToXmlAddAttribute(QTextStream& stream, const QString& name,
+ const QString& value)
{
if(!value.isEmpty())
stream << " " << name <<"='" << value << "'";
@@ -49,7 +52,15 @@ void helperToXmlAddElement(QTextStream& stream, const QString& name, int value) stream << "<" << name << ">" << value << "</" << name << ">";
}
-void helperToXmlAddElement(QTextStream& stream, const QString& name, const QString& value)
+void helperToXmlAddElement(QTextStream& stream, const QString& name,
+ const QString& value)
+{
+ if(!value.isEmpty())
+ stream << "<" << name << ">" << value << "</" << name << ">";
+}
+
+void helperToXmlAddElement(QTextStream& stream, const QString& name,
+ const QByteArray& value)
{
if(!value.isEmpty())
stream << "<" << name << ">" << value << "</" << name << ">";
@@ -84,3 +95,42 @@ QString unescapeString(const QString& str) strOut.replace("&", QChar('&'));
return strOut;
}
+
+QString getImageType(const QByteArray& image)
+{
+ QBuffer buffer;
+ buffer.setData(image);
+ buffer.open(QIODevice::ReadOnly);
+ QString format = QImageReader::imageFormat(&buffer);
+
+ if(format.toUpper() == "PNG")
+ return "image/png";
+ else if(format.toUpper() == "MNG")
+ return "video/x-mng";
+ else if(format.toUpper() == "GIF")
+ return "image/gif";
+ else if(format.toUpper() == "BMP")
+ return "image/bmp";
+ else if(format.toUpper() == "XPM")
+ return "image/x-xpm";
+ else if(format.toUpper() == "SVG")
+ return "image/svg+xml";
+ else if(format.toUpper() == "JPEG")
+ return "image/jpeg";
+
+ return "image/unknown";
+}
+
+QString getImageHash(const QByteArray& image)
+{
+ return "";
+}
+
+QImage getImageFromByteArray(const QByteArray& image)
+{
+ QBuffer buffer;
+ buffer.setData(image);
+ buffer.open(QIODevice::ReadOnly);
+ QImageReader imageReader(&buffer);
+ return imageReader.read();
+}
diff --git a/source/QXmppUtils.h b/source/QXmppUtils.h index 99bcef2c..cb753003 100644 --- a/source/QXmppUtils.h +++ b/source/QXmppUtils.h @@ -29,13 +29,19 @@ class QTextStream;
class QByteArray;
class QString;
+class QImage;
QString jidToResource(const QString& jid);
QString jidToBareJid(const QString& jid);
-void helperToXmlAddAttribute(QTextStream& stream, const QString& name, const QString& value);
-void helperToXmlAddElement(QTextStream& stream, const QString& name, const QString& value);
-void helperToXmlAddElement(QTextStream& stream, const QString& name, int value);
+void helperToXmlAddAttribute(QTextStream& stream, const QString& name,
+ const QString& value);
+void helperToXmlAddElement(QTextStream& stream, const QString& name,
+ const QString& value);
+void helperToXmlAddElement(QTextStream& stream, const QString& name,
+ const QByteArray& value);
+void helperToXmlAddElement(QTextStream& stream, const QString& name,
+ int value);
void log(const QString& str);
void log(const QByteArray& str);
@@ -43,4 +49,8 @@ void log(const QByteArray& str); QString escapeString(const QString& str);
QString unescapeString(const QString& str);
+QString getImageType(const QByteArray& image);
+QString getImageHash(const QByteArray& image);
+QImage getImageFromByteArray(const QByteArray& image);
+
#endif // QXMPPUTILS_H
diff --git a/source/QXmppVCard.cpp b/source/QXmppVCard.cpp new file mode 100644 index 00000000..35333319 --- /dev/null +++ b/source/QXmppVCard.cpp @@ -0,0 +1,101 @@ +/*
+ * Copyright (C) 2008-2009 Manjeet Dahiya
+ *
+ * Author:
+ * Manjeet Dahiya
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+
+#include "QXmppVCard.h"
+#include "QXmppUtils.h"
+#include "QXmppConstants.h"
+
+#include <QTextStream>
+#include <QImage>
+
+QXmppVCard::QXmppVCard(const QString& jid) : QXmppIq(QXmppIq::Get)
+{
+ // for self jid should be empty
+ setTo(jid);
+}
+
+QString QXmppVCard::getFullName() const
+{
+ return m_fullName;
+}
+
+void QXmppVCard::setFullName(const QString& str)
+{
+ m_fullName = str;
+}
+
+const QByteArray& QXmppVCard::getPhoto() const
+{
+ return m_photo;
+}
+
+void QXmppVCard::setPhoto(const QByteArray& photo)
+{
+ m_photo = photo;
+}
+
+void QXmppVCard::parse(const QDomElement& nodeRecv)
+{
+ QString id = nodeRecv.attribute("id");
+ QString to = nodeRecv.attribute("to");
+ QString from = nodeRecv.attribute("from");
+ QString type = nodeRecv.attribute("type");
+ setTypeFromStr(type);
+ setId(id);
+ setTo(to);
+ setFrom(from);
+
+ // vCard
+ setFullName(nodeRecv.firstChildElement("vCard").
+ firstChildElement("FN").text());
+ QByteArray base64data = nodeRecv.firstChildElement("vCard").
+ firstChildElement("PHOTO").
+ firstChildElement("BINVAL").text().toAscii();
+ setPhoto(QByteArray::fromBase64(base64data));
+}
+
+QByteArray QXmppVCard::toXmlElementFromChild() const
+{
+ QString data;
+ QTextStream stream(&data);
+
+ stream << "<vCard";
+ helperToXmlAddAttribute(stream, "xmlns", ns_vcard);
+ stream << ">";
+ helperToXmlAddElement(stream, "FN", getFullName());
+
+ stream << "<PHOTO";
+ helperToXmlAddElement(stream, "TYPE", getImageType(getPhoto()));
+ helperToXmlAddElement(stream, "BINVAL", getPhoto());
+ stream << "</PHOTO>";
+
+ stream << "</vCard>";
+
+ return data.toAscii();
+}
+
+const QImage& QXmppVCard::getPhotoAsImage() const
+{
+ return getImageFromByteArray(getPhoto());
+}
diff --git a/source/QXmppVCard.h b/source/QXmppVCard.h new file mode 100644 index 00000000..fc8a76c9 --- /dev/null +++ b/source/QXmppVCard.h @@ -0,0 +1,55 @@ +/*
+ * Copyright (C) 2008-2009 Manjeet Dahiya
+ *
+ * Author:
+ * Manjeet Dahiya
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+
+#ifndef QXMPPVCARD_H
+#define QXMPPVCARD_H
+
+#include "QXmppIq.h"
+#include <QMap>
+#include <QDomElement>
+
+class QImage;
+
+class QXmppVCard : public QXmppIq
+{
+public:
+ QXmppVCard(const QString& bareJid = "");
+
+ QString getFullName() const;
+ void setFullName(const QString&);
+
+ const QImage& getPhotoAsImage() const;
+ const QByteArray& getPhoto() const;
+ void setPhoto(const QByteArray&);
+
+ void parse(const QDomElement&);
+
+private:
+ QByteArray toXmlElementFromChild() const;
+
+ QString m_fullName;
+ QByteArray m_photo;
+};
+
+#endif // QXMPPVCARD_H
diff --git a/source/QXmppVCardManager.cpp b/source/QXmppVCardManager.cpp new file mode 100644 index 00000000..aa391477 --- /dev/null +++ b/source/QXmppVCardManager.cpp @@ -0,0 +1,44 @@ +/*
+ * Copyright (C) 2008-2009 Manjeet Dahiya
+ *
+ * Author:
+ * Manjeet Dahiya
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+
+#include "QXmppVCardManager.h"
+#include "QXmppVCard.h"
+#include "QXmppUtils.h"
+
+QXmppVCardManager::QXmppVCardManager(QXmppClient* client) :
+ m_client(client), QObject(client)
+{
+}
+
+void QXmppVCardManager::requestVCard(const QString& jid)
+{
+ QXmppVCard vcardIq(jid);
+ m_client->sendPacket(vcardIq);
+}
+
+void QXmppVCardManager::vCardIqReceived(const QXmppVCard& vcard)
+{
+ emit vCardReceived(vcard);
+}
+
diff --git a/source/QXmppVCardManager.h b/source/QXmppVCardManager.h new file mode 100644 index 00000000..97e37574 --- /dev/null +++ b/source/QXmppVCardManager.h @@ -0,0 +1,52 @@ +/*
+ * Copyright (C) 2008-2009 Manjeet Dahiya
+ *
+ * Author:
+ * Manjeet Dahiya
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+
+#ifndef QXMPPVCARDMANAGER_H
+#define QXMPPVCARDMANAGER_H
+
+#include <QObject>
+#include "QXmppClient.h"
+
+class QXmppVCard;
+
+class QXmppVCardManager : public QObject
+{
+ Q_OBJECT
+
+public:
+ QXmppVCardManager(QXmppClient* client);
+ void requestVCard(const QString& bareJid);
+
+signals:
+ void vCardReceived(const QXmppVCard&);
+
+private slots:
+ void vCardIqReceived(const QXmppVCard&);
+
+private:
+ // reference to to client object (no ownership)
+ QXmppClient* m_client;
+};
+
+#endif // QXMPPVCARDMANAGER_H
diff --git a/source/source.pro b/source/source.pro index b804e234..49a65344 100644 --- a/source/source.pro +++ b/source/source.pro @@ -22,7 +22,9 @@ HEADERS += QXmppUtils.h \ QXmppStanza.h \
QXmppStream.h \
QXmppLogger.h \
- QXmppReconnectionManager.h
+ QXmppReconnectionManager.h \
+ QXmppVCardManager.h \
+ QXmppVCard.h
# Source files
SOURCES += QXmppUtils.cpp \
@@ -40,4 +42,6 @@ SOURCES += QXmppUtils.cpp \ QXmppStanza.cpp \
QXmppStream.cpp \
QXmppLogger.cpp \
- QXmppReconnectionManager.cpp
+ QXmppReconnectionManager.cpp \
+ QXmppVCardManager.cpp \
+ QXmppVCard.cpp
|
