123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- #ifndef QXMPPCLIENT_H
- #define QXMPPCLIENT_H
- #include <QObject>
- #include <QAbstractSocket>
- #include "QXmppConfiguration.h"
- #include "QXmppLogger.h"
- #include "QXmppPresence.h"
- class QXmppClientExtension;
- class QXmppClientPrivate;
- class QXmppPresence;
- class QXmppMessage;
- class QXmppIq;
- class QXmppStream;
- class QXmppDiscoveryIq;
- class QXmppRosterManager;
- class QXmppVCardManager;
- class QXmppVersionManager;
- class QXMPP_EXPORT QXmppClient : public QXmppLoggable
- {
- Q_OBJECT
- Q_ENUMS(Error State)
- Q_PROPERTY(QXmppLogger* logger READ logger WRITE setLogger NOTIFY loggerChanged)
- Q_PROPERTY(State state READ state NOTIFY stateChanged)
- public:
-
-
- enum Error
- {
- NoError,
- SocketError,
- KeepAliveError,
- XmppStreamError,
- };
-
- enum State
- {
- DisconnectedState,
- ConnectingState,
- ConnectedState,
- };
- QXmppClient(QObject *parent = 0);
- ~QXmppClient();
- bool addExtension(QXmppClientExtension* extension);
- bool removeExtension(QXmppClientExtension* extension);
- QList<QXmppClientExtension*> extensions();
-
-
-
-
-
-
-
-
-
-
-
-
- template<typename T>
- T* findExtension()
- {
- QList<QXmppClientExtension*> list = extensions();
- for (int i = 0; i < list.size(); ++i)
- {
- T* extension = qobject_cast<T*>(list.at(i));
- if(extension)
- return extension;
- }
- return 0;
- }
- void connectToServer(const QXmppConfiguration&,
- const QXmppPresence& initialPresence =
- QXmppPresence());
- bool isAuthenticated() const;
- bool isConnected() const;
- QXmppPresence clientPresence() const;
- void setClientPresence(const QXmppPresence &presence);
- QXmppConfiguration &configuration();
- QXmppLogger *logger() const;
- void setLogger(QXmppLogger *logger);
- QAbstractSocket::SocketError socketError();
- State state() const;
- QXmppStanza::Error::Condition xmppStreamError();
- QXmppRosterManager& rosterManager();
- QXmppVCardManager& vCardManager();
- QXmppVersionManager& versionManager();
- signals:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void connected();
-
-
- void disconnected();
-
-
-
-
-
- void error(QXmppClient::Error);
-
- void loggerChanged(QXmppLogger *logger);
-
-
-
-
- void messageReceived(const QXmppMessage &message);
-
-
-
-
- void presenceReceived(const QXmppPresence &presence);
-
-
-
-
- void iqReceived(const QXmppIq &iq);
-
- void stateChanged(QXmppClient::State state);
- public slots:
- void connectToServer(const QString &jid,
- const QString &password);
- void disconnectFromServer();
- bool sendPacket(const QXmppStanza&);
- void sendMessage(const QString& bareJid, const QString& message);
- private slots:
- void _q_elementReceived(const QDomElement &element, bool &handled);
- void _q_reconnect();
- void _q_socketStateChanged(QAbstractSocket::SocketState state);
- void _q_streamConnected();
- void _q_streamDisconnected();
- void _q_streamError(QXmppClient::Error error);
- private:
- QXmppClientPrivate * const d;
- };
- #endif
|