QXmpp Version: 1.5.6
|
The QXmppRosterManager class provides access to a connected client's roster. More...
#include <QXmppRosterManager.h>
Public Types | |
using | Result = std::variant< QXmpp::Success, QXmppError > |
Empty result containing QXmpp::Success or a QXmppError. | |
Public 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={}) |
Signals | |
void | rosterReceived () |
void | presenceChanged (const QString &bareJid, const QString &resource) |
This signal is emitted when the presence of a particular bareJid and resource changes. | |
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) |
Signals inherited from QXmppLoggable | |
void | setGauge (const QString &gauge, double value) |
Sets the given gauge to value. | |
void | logMessage (QXmppLogger::MessageType type, const QString &msg) |
This signal is emitted to send logging messages. | |
void | updateCounter (const QString &counter, qint64 amount=1) |
Updates the given counter by amount. | |
Public Member Functions | |
QXmppRosterManager (QXmppClient *stream) | |
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={}) |
Public Member Functions inherited from QXmppClientExtension | |
QXmppClientExtension () | |
virtual QStringList | discoveryFeatures () const |
virtual QList< QXmppDiscoveryIq::Identity > | discoveryIdentities () const |
virtual bool | handleStanza (const QDomElement &stanza) |
You need to implement this method to process incoming XMPP stanzas. | |
virtual bool | handleStanza (const QDomElement &stanza, const std::optional< QXmppE2eeMetadata > &e2eeMetadata) |
You need to implement this method to process incoming XMPP stanzas. | |
Public Member Functions inherited from QXmppLoggable | |
QXmppLoggable (QObject *parent=nullptr) | |
Additional Inherited Members | |
Protected Member Functions inherited from QXmppClientExtension | |
QXmppClient * | client () |
virtual void | setClient (QXmppClient *client) |
void | injectIq (const QDomElement &element, const std::optional< QXmppE2eeMetadata > &e2eeMetadata) |
bool | injectMessage (QXmppMessage &&message) |
Protected Member Functions inherited from QXmppLoggable | |
void | debug (const QString &message) |
void | info (const QString &message) |
void | warning (const QString &message) |
void | logReceived (const QString &message) |
void | logSent (const QString &message) |
The QXmppRosterManager class provides access to a connected client's roster.
QXmppClient::findExtension<QXmppRosterManager>()
should be used to get the instantiated object of this class.It stores all the Roster and Presence details of all the roster entries (that is all the bareJids) in the client's friend's list. It provides the functionality to get all the bareJids in the client's roster and Roster and Presence details of the same.
After the QXmpp connected successfully to the XMPP server the signal QXmppClient::connected()
is emitted and the roster is requested from the server. Once QXmpp receives the roster the signal QXmppRosterManager::rosterReceived()
is emitted and after that the methods of this class can be used to get the roster entries.
QXmppRosterManager::isRosterReceived()
can be used to find out whether the roster has been received yet.
The itemAdded()
, itemChanged()
and itemRemoved()
signals are emitted whenever roster entries are added, changed or removed.
The presenceChanged()
signal is emitted whenever the presence for a roster item changes.
QXmppRosterManager::QXmppRosterManager | ( | QXmppClient * | client | ) |
Constructs a roster manager.
|
slot |
Accepts an existing subscription request or pre-approves future subscription requests.
You can call this method in reply to the subscriptionRequest() signal or to create a pre-approved subscription.
|
slot |
Adds a new item the roster without sending any subscription requests.
As a result, the server will initiate a roster push, causing the itemAdded() or itemChanged() signal to be emitted.
bareJid | |
name | Optotional name for the item. |
groups | Optional groups for the item. |
QXmppTask< QXmppRosterManager::Result > QXmppRosterManager::addRosterItem | ( | const QString & | bareJid, |
const QString & | name = {} , |
||
const QSet< QString > & | groups = {} |
||
) |
Adds a new item to the roster without sending any subscription requests.
As a result, the server will initiate a roster push, causing the itemAdded() or itemChanged() signal to be emitted.
bareJid | |
name | Optional name for the item. |
groups | Optional groups for the item. |
QMap< QString, QXmppPresence > QXmppRosterManager::getAllPresencesForBareJid | ( | const QString & | bareJid | ) | const |
Get all the presences of all the resources of the given bareJid. A bareJid can have multiple resources and each resource will have a presence associated with it.
bareJid | as a QString |
QXmppPresence QXmppRosterManager::getPresence | ( | const QString & | bareJid, |
const QString & | resource | ||
) | const |
Get the presence of the given resource of the given bareJid.
bareJid | as a QString |
resource | as a QString |
QStringList QXmppRosterManager::getResources | ( | const QString & | bareJid | ) | const |
Get all the associated resources with the given bareJid.
bareJid | as a QString |
QStringList QXmppRosterManager::getRosterBareJids | ( | ) | const |
Function to get all the bareJids present in the roster.
QXmppRosterIq::Item QXmppRosterManager::getRosterEntry | ( | const QString & | bareJid | ) | const |
Returns the roster entry of the given bareJid. If the bareJid is not in the database and empty QXmppRosterIq::Item will be returned.
bareJid | as a QString |
bool QXmppRosterManager::isRosterReceived | ( | ) | const |
Function to check whether the roster has been received or not.
On disconnecting this is reset to false if no stream management is used by the client and so the stream cannot be resumed later.
|
signal |
This signal is emitted when the roster entry of a particular bareJid is added as a result of roster push.
|
signal |
This signal is emitted when the roster entry of a particular bareJid changes as a result of roster push.
|
signal |
This signal is emitted when the roster entry of a particular bareJid is removed as a result of roster push.
|
slot |
Refuses a subscription request.
You can call this method in reply to the subscriptionRequest() signal.
|
slot |
Removes a roster item and cancels subscriptions to and from the contact.
As a result, the server will initiate a roster push, causing the itemRemoved() signal to be emitted.
bareJid |
QXmppTask< QXmppRosterManager::Result > QXmppRosterManager::removeRosterItem | ( | const QString & | bareJid | ) |
Removes a roster item and cancels subscriptions to and from the contact.
As a result, the server will initiate a roster push, causing the itemRemoved() signal to be emitted.
bareJid |
|
slot |
Renames a roster item.
As a result, the server will initiate a roster push, causing the itemChanged() signal to be emitted.
bareJid | |
name |
QXmppTask< QXmppRosterManager::Result > QXmppRosterManager::renameRosterItem | ( | const QString & | bareJid, |
const QString & | name | ||
) |
Renames a roster item.
As a result, the server will initiate a roster push, causing the itemChanged() signal to be emitted.
bareJid | |
name |
|
signal |
This signal is emitted when the Roster IQ is received after a successful connection. That is the roster entries are empty before this signal is emitted. One should use getRosterBareJids() and getRosterEntry() only after this signal has been emitted.
|
slot |
Requests a subscription to the given contact.
As a result, the server will initiate a roster push, causing the itemAdded() or itemChanged() signal to be emitted.
QXmppTask< QXmpp::SendResult > QXmppRosterManager::subscribeTo | ( | const QString & | bareJid, |
const QString & | reason = {} |
||
) |
Requests a subscription to the given contact.
As a result, the server will initiate a roster push, causing the itemAdded() or itemChanged() signal to be emitted.
|
signal |
This signal is emitted when a contact asks to subscribe to your presence.
You can either accept the request by calling acceptSubscription() or refuse it by calling refuseSubscription().
|
signal |
This signal is emitted when a JID asks to subscribe to the user's presence.
The user can either accept the request by calling acceptSubscription() or refuse it by calling refuseSubscription().
subscriberBareJid | bare JID that wants to subscribe to the user's presence |
presence | presence stanza containing the reason / message (presence.statusText()) |
|
slot |
Removes a subscription to the given contact.
As a result, the server will initiate a roster push, causing the itemChanged() signal to be emitted.
QXmppTask< QXmpp::SendResult > QXmppRosterManager::unsubscribeFrom | ( | const QString & | bareJid, |
const QString & | reason = {} |
||
) |
Removes a subscription to the given contact.
As a result, the server will initiate a roster push, causing the itemChanged() signal to be emitted.