Loading...
Searching...
No Matches
QXmppMucManagerV2.h
// SPDX-FileCopyrightText: 2025 Linus Jahn <lnj@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPMUCMANAGERV2_H
#define QXMPPMUCMANAGERV2_H
#include "QXmppClientExtension.h"
#include "QXmppPubSubEventHandler.h"
#include "QXmppTask.h"
#include <variant>
namespace QXmpp::Private {
struct Bookmarks2Conference;
struct Bookmarks2ConferenceItem;
} // namespace QXmpp::Private
class QXmppError;
class QXmppMucBookmarkPrivate;
class QXMPP_EXPORT QXmppMucBookmark
{
public:
QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppMucBookmark)
QXmppMucBookmark();
QXmppMucBookmark(const QString &jid, const QString &name, bool autojoin, const QString &nick, const QString &password);
QXmppMucBookmark(const QString &jid, QXmpp::Private::Bookmarks2Conference conference);
const QString &jid() const;
void setJid(const QString &jid);
const QString &name() const;
void setName(const QString &name);
const QString &nick() const;
void setNick(const QString &nick);
const QString &password() const;
void setPassword(const QString &password);
bool autojoin() const;
void setAutojoin(bool autojoin);
private:
friend class QXmppMucManagerV2Private;
QSharedDataPointer<QXmppMucBookmarkPrivate> d;
};
Q_DECLARE_METATYPE(QXmppMucBookmark);
struct QXmppMucManagerV2Private;
class QXMPP_EXPORT QXmppMucManagerV2 : public QXmppClientExtension, public QXmppPubSubEventHandler
{
Q_OBJECT
public:
struct BookmarkChange {
QXmppMucBookmark oldBookmark;
QXmppMucBookmark newBookmark;
};
struct Avatar {
QString contentType;
QByteArray data;
};
QXmppMucManagerV2();
~QXmppMucManagerV2();
QStringList discoveryFeatures() const override;
const std::optional<QList<QXmppMucBookmark>> &bookmarks() const;
Q_SIGNAL void bookmarksReset();
Q_SIGNAL void bookmarksAdded(const QList<QXmppMucBookmark> &newBookmarks);
Q_SIGNAL void bookmarksChanged(const QList<QXmppMucManagerV2::BookmarkChange> &bookmarkUpdates);
Q_SIGNAL void bookmarksRemoved(const QList<QString> &removedBookmarkJids);
QXmppTask<QXmpp::Result<>> setBookmark(QXmppMucBookmark &&bookmark);
QXmppTask<QXmpp::Result<>> removeBookmark(const QString &jid);
QXmppTask<QXmpp::Result<>> setRoomAvatar(const QString &jid, const Avatar &avatar);
QXmppTask<QXmpp::Result<>> removeRoomAvatar(const QString &jid);
QXmppTask<QXmpp::Result<std::optional<Avatar>>> fetchRoomAvatar(const QString &jid);
bool handlePubSubEvent(const QDomElement &element, const QString &pubSubService, const QString &nodeName) override;
protected:
void onRegistered(QXmppClient *client) override;
void onUnregistered(QXmppClient *client) override;
private:
void onConnected();
friend class QXmppMucManagerV2Private;
friend class tst_QXmppMuc;
const std::unique_ptr<QXmppMucManagerV2Private> d;
};
Q_DECLARE_METATYPE(QXmppMucManagerV2::BookmarkChange);
#endif // QXMPPMUCMANAGERV2_H
QXmppClientExtension::client
QXmppClient * client() const
Definition QXmppClientExtension.cpp:57
QXmppClientExtension::QXmppClientExtension
QXmppClientExtension()
Definition QXmppClientExtension.cpp:12
QXmppMucBookmark
Definition QXmppMucManagerV2.h:23
QXmppMucBookmark::jid
const QString & jid() const
Returns the (bare) JID of the MUC.
Definition QXmppMucManagerV2.cpp:96
QXmppMucBookmark::setAutojoin
void setAutojoin(bool autojoin)
Sets whether to automatically join this MUC on connection.
Definition QXmppMucManagerV2.cpp:118
QXmppMucBookmark::autojoin
bool autojoin() const
Returns whether to automatically join this MUC on connection.
Definition QXmppMucManagerV2.cpp:116
QXmppMucBookmark::setName
void setName(const QString &name)
Sets the user-defined display name of the MUC.
Definition QXmppMucManagerV2.cpp:103
QXmppMucBookmark::setJid
void setJid(const QString &jid)
Sets the (bare) JID of the MUC.
Definition QXmppMucManagerV2.cpp:98
QXmppMucBookmark::password
const QString & password() const
Returns the required password for the MUC.
Definition QXmppMucManagerV2.cpp:111
QXmppMucBookmark::setPassword
void setPassword(const QString &password)
Sets the required password for the MUC.
Definition QXmppMucManagerV2.cpp:113
QXmppMucBookmark::QXmppMucBookmark
QXmppMucBookmark()
Empty constructor.
Definition QXmppMucManagerV2.cpp:78
QXmppMucBookmark::name
const QString & name() const
Returns the user-defined display name of the MUC.
Definition QXmppMucManagerV2.cpp:101
QXmppMucBookmark::setNick
void setNick(const QString &nick)
Sets the user's preferred nick for this MUC.
Definition QXmppMucManagerV2.cpp:108
QXmppMucBookmark::nick
const QString & nick() const
Returns the user's preferred nick for this MUC.
Definition QXmppMucManagerV2.cpp:106
QXmppMucManagerV2::bookmarksChanged
Q_SIGNAL void bookmarksChanged(const QList< QXmppMucManagerV2::BookmarkChange > &bookmarkUpdates)
QXmppMucManagerV2::setBookmark
QXmppTask< QXmpp::Result<> > setBookmark(QXmppMucBookmark &&bookmark)
Adds or updates the bookmark for a MUC.
Definition QXmppMucManagerV2.cpp:361
QXmppMucManagerV2::QXmppMucManagerV2
QXmppMucManagerV2()
Default constructor.
Definition QXmppMucManagerV2.cpp:180
QXmppMucManagerV2::removeBookmark
QXmppTask< QXmpp::Result<> > removeBookmark(const QString &jid)
Removes a bookmark.
Definition QXmppMucManagerV2.cpp:367
QXmppMucManagerV2::discoveryFeatures
QStringList discoveryFeatures() const override
Supported service discovery features.
Definition QXmppMucManagerV2.cpp:188
QXmppMucManagerV2::bookmarksAdded
Q_SIGNAL void bookmarksAdded(const QList< QXmppMucBookmark > &newBookmarks)
QXmppMucManagerV2::setRoomAvatar
QXmppTask< QXmpp::Result<> > setRoomAvatar(const QString &jid, const Avatar &avatar)
Definition QXmppMucManagerV2.cpp:202
QXmppMucManagerV2::fetchRoomAvatar
QXmppTask< QXmpp::Result< std::optional< Avatar > > > fetchRoomAvatar(const QString &jid)
Definition QXmppMucManagerV2.cpp:240
QXmppMucManagerV2::removeRoomAvatar
QXmppTask< QXmpp::Result<> > removeRoomAvatar(const QString &jid)
Definition QXmppMucManagerV2.cpp:221
QXmppMucManagerV2::bookmarksRemoved
Q_SIGNAL void bookmarksRemoved(const QList< QString > &removedBookmarkJids)
QXmppMucManagerV2::onRegistered
void onRegistered(QXmppClient *client) override
Definition QXmppMucManagerV2.cpp:372
QXmppMucManagerV2::bookmarksReset
Q_SIGNAL void bookmarksReset()
QXmppMucManagerV2::handlePubSubEvent
bool handlePubSubEvent(const QDomElement &element, const QString &pubSubService, const QString &nodeName) override
Handles incoming PubSub events.
Definition QXmppMucManagerV2.cpp:290
QXmppMucManagerV2::bookmarks
const std::optional< QList< QXmppMucBookmark > > & bookmarks() const
Retrieved bookmarks.
Definition QXmppMucManagerV2.cpp:191
QXmppMucManagerV2::onUnregistered
void onUnregistered(QXmppClient *client) override
Definition QXmppMucManagerV2.cpp:377
QXmppPubSubEventHandler
Definition QXmppPubSubEventHandler.h:15
QXmppTask
Definition QXmppTask.h:46
QXmppError
Definition QXmppError.h:17