QXmppClient.h
/*
* Copyright (C) 2008-2019 The QXmpp developers
*
* Author:
* Manjeet Dahiya
*
* Source:
* https://github.com/qxmpp-project/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 QXMPPCLIENT_H
#define QXMPPCLIENT_H
#include <QObject>
#include <QAbstractSocket>
#include "QXmppConfiguration.h"
#include "QXmppLogger.h"
#include "QXmppPresence.h"
class QSslError;
class QXmppClientExtension;
class QXmppClientPrivate;
class QXmppPresence;
class QXmppMessage;
class QXmppIq;
class QXmppStream;
// managers
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 insertExtension(int index, 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;
}
bool isAuthenticated() const;
bool isConnected() const;
bool isActive() const;
void setActive(bool active);
QXmppPresence clientPresence() const;
void setClientPresence(const QXmppPresence &presence);
QXmppConfiguration &configuration();
QXmppLogger *logger() const;
void setLogger(QXmppLogger *logger);
QAbstractSocket::SocketError socketError();
QString socketErrorString() const;
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 sslErrors(const QList<QSslError> &errors);
void stateChanged(QXmppClient::State state);
public slots:
void connectToServer(const QXmppConfiguration&,
const QXmppPresence& initialPresence =
QXmppPresence());
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 // QXMPPCLIENT_H
QXmppPresence
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:36
QXmppClient::KeepAliveError
@ KeepAliveError
Error due to no response to a keep alive.
Definition: QXmppClient.h:94
QXmppRosterManager
The QXmppRosterManager class provides access to a connected client's roster.
Definition: QXmppRosterManager.h:64
QXmppVCardManager
The QXmppVCardManager class gets/sets XMPP vCards. It is an implementation of XEP-0054: vcard-temp.
Definition: QXmppVCardManager.h:56
QXmppClientExtension
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:47
QXmppStanza
The QXmppStanza class is the base class for all XMPP stanzas.
Definition: QXmppStanza.h:90
QXmppClient::SocketError
@ SocketError
Error due to TCP socket.
Definition: QXmppClient.h:93
QXmppClient::findExtension
T * findExtension()
Returns the extension which can be cast into type T*, or 0 if there is no such extension.
Definition: QXmppClient.h:128
QXmppClient::Error
Error
Definition: QXmppClient.h:90
QXmppClient::NoError
@ NoError
No error.
Definition: QXmppClient.h:92
QXmppClient::State
State
This enumeration describes a client state.
Definition: QXmppClient.h:99
QXmppLogger
The QXmppLogger class represents a sink for logging messages.
Definition: QXmppLogger.h:45
QXmppConfiguration
The QXmppConfiguration class holds configuration options.
Definition: QXmppConfiguration.h:48
QXmppClient::DisconnectedState
@ DisconnectedState
Disconnected from the server.
Definition: QXmppClient.h:101
QXmppStream
The QXmppStream class is the base class for all XMPP streams.
Definition: QXmppStream.h:41
QXmppClient::ConnectingState
@ ConnectingState
Trying to connect to the server.
Definition: QXmppClient.h:102
QXmppIq
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:42
QXmppClient
The QXmppClient class is the main class for using QXmpp.
Definition: QXmppClient.h:80
QXmppLoggable
The QXmppLoggable class represents a source of logging messages.
Definition: QXmppLogger.h:111
QXmppVersionManager
The QXmppVersionManager class makes it possible to request for the software version of an entity as d...
Definition: QXmppVersionManager.h:37
QXmppMessage
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:38