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-FileCopyrightText: 2024 Filipe Azevedo <pasnox@gmail.com>
//
// 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>;
explicit 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;
Q_SLOT bool acceptSubscription(const QString &bareJid, const QString &reason = {});
Q_SLOT bool refuseSubscription(const QString &bareJid, const QString &reason = {});
Q_SLOT bool addItem(const QString &bareJid, const QString &name = {}, const QSet<QString> &groups = {});
Q_SLOT bool removeItem(const QString &bareJid);
Q_SLOT bool renameItem(const QString &bareJid, const QString &name);
Q_SLOT bool subscribe(const QString &bareJid, const QString &reason = {});
Q_SLOT bool unsubscribe(const QString &bareJid, const QString &reason = {});
Q_SIGNAL void rosterReceived();
Q_SIGNAL void presenceChanged(const QString &bareJid, const QString &resource);
Q_SIGNAL void subscriptionReceived(const QString &bareJid);
Q_SIGNAL void subscriptionRequestReceived(const QString &subscriberBareJid, const QXmppPresence &presence);
Q_SIGNAL void itemAdded(const QString &bareJid);
Q_SIGNAL void itemChanged(const QString &bareJid);
Q_SIGNAL void itemRemoved(const QString &bareJid);
protected:
void onRegistered(QXmppClient *client) override;
void onUnregistered(QXmppClient *client) override;
private:
using RosterResult = std::variant<QXmppRosterIq, QXmppError>;
Q_SLOT void _q_connected();
Q_SLOT void _q_disconnected();
Q_SLOT void _q_presenceReceived(const QXmppPresence &);
void handleSubscriptionRequest(const QString &bareJid, const QXmppPresence &presence);
QXmppTask<RosterResult> requestRoster();
const std::unique_ptr<QXmppRosterManagerPrivate> d;
friend class QXmppMixManager;
};
#endif // QXMPPROSTER_H
QXmppClientExtension::onUnregistered
virtual void onUnregistered(QXmppClient *client)
Definition QXmppClientExtension.cpp:95
QXmppClientExtension::onRegistered
virtual void onRegistered(QXmppClient *client)
Definition QXmppClientExtension.cpp:85
QXmppClientExtension::client
QXmppClient * client() const
Definition QXmppClientExtension.cpp:57
QXmppClientExtension::QXmppClientExtension
QXmppClientExtension()
Definition QXmppClientExtension.cpp:12
QXmppClientExtension::handleStanza
virtual bool handleStanza(const QDomElement &stanza)
You need to implement this method to process incoming XMPP stanzas.
Definition client/compat/removed_api.cpp:44
QXmppPresence
The QXmppPresence class represents an XMPP presence stanza.
Definition QXmppPresence.h:22
QXmppRosterIq::Item
The QXmppRosterIq::Item class represents a roster entry.
Definition QXmppRosterIq.h:34
QXmppRosterManager::addRosterItem
QXmppTask< Result > addRosterItem(const QString &bareJid, const QString &name={}, const QSet< QString > &groups={})
Definition QXmppRosterManager.cpp:330
QXmppRosterManager::isRosterReceived
bool isRosterReceived() const
Definition QXmppRosterManager.cpp:701
QXmppRosterManager::getAllPresencesForBareJid
QMap< QString, QXmppPresence > getAllPresencesForBareJid(const QString &bareJid) const
Definition QXmppRosterManager.cpp:665
QXmppRosterManager::itemAdded
Q_SIGNAL void itemAdded(const QString &bareJid)
QXmppRosterManager::itemChanged
Q_SIGNAL void itemChanged(const QString &bareJid)
QXmppRosterManager::getRosterEntry
QXmppRosterIq::Item getRosterEntry(const QString &bareJid) const
Definition QXmppRosterManager.cpp:633
QXmppRosterManager::getPresence
QXmppPresence getPresence(const QString &bareJid, const QString &resource) const
Definition QXmppRosterManager.cpp:681
QXmppRosterManager::presenceChanged
Q_SIGNAL void presenceChanged(const QString &bareJid, const QString &resource)
This signal is emitted when the presence of a particular bareJid and resource changes.
QXmppRosterManager::subscriptionReceived
Q_SIGNAL void subscriptionReceived(const QString &bareJid)
QXmppRosterManager::getRosterBareJids
QStringList getRosterBareJids() const
Definition QXmppRosterManager.cpp:622
QXmppRosterManager::itemRemoved
Q_SIGNAL void itemRemoved(const QString &bareJid)
QXmppRosterManager::QXmppRosterManager
QXmppRosterManager(QXmppClient *stream)
Definition QXmppRosterManager.cpp:121
QXmppRosterManager::getResources
QStringList getResources(const QString &bareJid) const
Definition QXmppRosterManager.cpp:649
QXmppRosterManager::subscriptionRequestReceived
Q_SIGNAL void subscriptionRequestReceived(const QString &subscriberBareJid, const QXmppPresence &presence)
QXmppRosterManager::rosterReceived
Q_SIGNAL void rosterReceived()
QXmppRosterManager::Result
std::variant< QXmpp::Success, QXmppError > Result
Empty result containing QXmpp::Success or a QXmppError.
Definition QXmppRosterManager.h:89
QXmppTask
Definition QXmppTask.h:46