QXmpp: QXmppMucManagerV2.h Source File

QXmpp Version: 1.14.2

Loading...
Searching...
No Matches
QXmppMucManagerV2.h
1// SPDX-FileCopyrightText: 2025 Linus Jahn <lnj@kaidan.im>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPMUCMANAGERV2_H
6#define QXMPPMUCMANAGERV2_H
7
8#include "QXmppClientExtension.h"
9#include "QXmppPubSubEventHandler.h"
10#include "QXmppTask.h"
11
12#include <variant>
13
14namespace QXmpp::Private {
15struct Bookmarks2Conference;
16struct Bookmarks2ConferenceItem;
17} // namespace QXmpp::Private
18
19class QXmppError;
20class QXmppMucBookmarkPrivate;
21
22 class QXMPP_EXPORT QXmppMucBookmark
23{
24public:
25 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppMucBookmark)
26
27 QXmppMucBookmark();
28 QXmppMucBookmark(const QString &jid, const QString &name, bool autojoin, const QString &nick, const QString &password);
29 QXmppMucBookmark(const QString &jid, QXmpp::Private::Bookmarks2Conference conference);
30
31 const QString &jid() const;
32 void setJid(const QString &jid);
33 const QString &name() const;
34 void setName(const QString &name);
35 const QString &nick() const;
36 void setNick(const QString &nick);
37 const QString &password() const;
38 void setPassword(const QString &password);
39 bool autojoin() const;
40 void setAutojoin(bool autojoin);
41
42private:
43 friend class QXmppMucManagerV2Private;
44 QSharedDataPointer<QXmppMucBookmarkPrivate> d;
45};
46
47Q_DECLARE_METATYPE(QXmppMucBookmark);
48
49struct QXmppMucManagerV2Private;
50
51 class QXMPP_EXPORT QXmppMucManagerV2 : public QXmppClientExtension, public QXmppPubSubEventHandler
52{
53 Q_OBJECT
54
55public:
56 struct BookmarkChange {
57 QXmppMucBookmark oldBookmark;
58 QXmppMucBookmark newBookmark;
59 };
60
61 struct Avatar {
62 QString contentType;
63 QByteArray data;
64 };
65
66 QXmppMucManagerV2();
67 ~QXmppMucManagerV2();
68
69 QStringList discoveryFeatures() const override;
70
71 const std::optional<QList<QXmppMucBookmark>> &bookmarks() const;
72 Q_SIGNAL void bookmarksReset();
73 Q_SIGNAL void bookmarksAdded(const QList<QXmppMucBookmark> &newBookmarks);
74 Q_SIGNAL void bookmarksChanged(const QList<QXmppMucManagerV2::BookmarkChange> &bookmarkUpdates);
75 Q_SIGNAL void bookmarksRemoved(const QList<QString> &removedBookmarkJids);
76
77 QXmppTask<QXmpp::Result<>> setBookmark(QXmppMucBookmark &&bookmark);
78 QXmppTask<QXmpp::Result<>> removeBookmark(const QString &jid);
79
80 QXmppTask<QXmpp::Result<>> setRoomAvatar(const QString &jid, const Avatar &avatar);
81 QXmppTask<QXmpp::Result<>> removeRoomAvatar(const QString &jid);
82 QXmppTask<QXmpp::Result<std::optional<Avatar>>> fetchRoomAvatar(const QString &jid);
83
84 bool handlePubSubEvent(const QDomElement &element, const QString &pubSubService, const QString &nodeName) override;
85
86protected:
87 void onRegistered(QXmppClient *client) override;
88 void onUnregistered(QXmppClient *client) override;
89
90private:
91 void onConnected();
92
93 friend class QXmppMucManagerV2Private;
94 friend class tst_QXmppMuc;
95 const std::unique_ptr<QXmppMucManagerV2Private> d;
96};
97
98Q_DECLARE_METATYPE(QXmppMucManagerV2::BookmarkChange);
99
100#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