Loading...
Searching...
No Matches
QXmppRosterManager.h
// SPDX-FileCopyrightText: 2010 Manjeet Dahiya <manjeetdahiya@gmail.com>
// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
// SPDX-FileCopyrightText: 2021 Melvin Keskin <melvo@olomono.de>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPROSTERMANAGER_H
#define QXMPPROSTERMANAGER_H
#include "QXmppClientExtension.h"
#include "QXmppPresence.h"
#include "QXmppRosterIq.h"
#include "QXmppSendResult.h"
#include <variant>
#include <QMap>
#include <QObject>
#include <QStringList>
template<typename T>
class QXmppTask;
class QXmppRosterManagerPrivate;
class QXMPP_EXPORT QXmppRosterManager : public QXmppClientExtension
{
Q_OBJECT
public:
using Result = std::variant<QXmpp::Success, QXmppError>;
QXmppRosterManager(QXmppClient *stream);
~QXmppRosterManager() override;
bool isRosterReceived() const;
QStringList getRosterBareJids() const;
QXmppRosterIq::Item getRosterEntry(const QString &bareJid) const;
QStringList getResources(const QString &bareJid) const;
QMap<QString, QXmppPresence> getAllPresencesForBareJid(
const QString &bareJid) const;
QXmppPresence getPresence(const QString &bareJid,
const QString &resource) const;
QXmppTask<Result> addRosterItem(const QString &bareJid, const QString &name = {}, const QSet<QString> &groups = {});
QXmppTask<Result> removeRosterItem(const QString &bareJid);
QXmppTask<Result> renameRosterItem(const QString &bareJid, const QString &name);
QXmppTask<QXmpp::SendResult> subscribeTo(const QString &bareJid, const QString &reason = {});
QXmppTask<QXmpp::SendResult> unsubscribeFrom(const QString &bareJid, const QString &reason = {});
bool handleStanza(const QDomElement &element) override;
public Q_SLOTS:
bool acceptSubscription(const QString &bareJid, const QString &reason = {});
bool refuseSubscription(const QString &bareJid, const QString &reason = {});
bool addItem(const QString &bareJid, const QString &name = {}, const QSet<QString> &groups = {});
bool removeItem(const QString &bareJid);
bool renameItem(const QString &bareJid, const QString &name);
bool subscribe(const QString &bareJid, const QString &reason = {});
bool unsubscribe(const QString &bareJid, const QString &reason = {});
Q_SIGNALS:
void rosterReceived();
void presenceChanged(const QString &bareJid, const QString &resource);
void subscriptionReceived(const QString &bareJid);
void subscriptionRequestReceived(const QString &subscriberBareJid, const QXmppPresence &presence);
void itemAdded(const QString &bareJid);
void itemChanged(const QString &bareJid);
void itemRemoved(const QString &bareJid);
private Q_SLOTS:
void _q_connected();
void _q_disconnected();
void _q_presenceReceived(const QXmppPresence &);
private:
const std::unique_ptr<QXmppRosterManagerPrivate> d;
};
#endif // QXMPPROSTER_H
QXmppClientExtension
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition QXmppClientExtension.h:33
QXmppClientExtension::handleStanza
virtual bool handleStanza(const QDomElement &stanza)
You need to implement this method to process incoming XMPP stanzas.
Definition QXmppClientExtension.cpp:51
QXmppClient
The QXmppClient class is the main class for using QXmpp.
Definition QXmppClient.h:84
QXmppPresence
The QXmppPresence class represents an XMPP presence stanza.
Definition QXmppPresence.h:21
QXmppRosterIq::Item
The QXmppRosterIq::Item class represents a roster entry.
Definition QXmppRosterIq.h:28
QXmppRosterManager
The QXmppRosterManager class provides access to a connected client's roster.
Definition QXmppRosterManager.h:56
QXmppRosterManager::subscriptionReceived
void subscriptionReceived(const QString &bareJid)
QXmppRosterManager::subscriptionRequestReceived
void subscriptionRequestReceived(const QString &subscriberBareJid, const QXmppPresence &presence)
QXmppRosterManager::itemRemoved
void itemRemoved(const QString &bareJid)
QXmppRosterManager::itemChanged
void itemChanged(const QString &bareJid)
QXmppRosterManager::rosterReceived
void rosterReceived()
QXmppRosterManager::itemAdded
void itemAdded(const QString &bareJid)
QXmppRosterManager::presenceChanged
void presenceChanged(const QString &bareJid, const QString &resource)
This signal is emitted when the presence of a particular bareJid and resource changes.
QXmppRosterManager::Result
std::variant< QXmpp::Success, QXmppError > Result
Empty result containing QXmpp::Success or a QXmppError.
Definition QXmppRosterManager.h:61
QXmppTask
Definition QXmppTask.h:62