QXmpp  Version:1.3.0
Public Slots | Signals | Public Member Functions | List of all members
QXmppRosterManager Class Reference

The QXmppRosterManager class provides access to a connected client's roster. More...

#include <QXmppRosterManager.h>

Inheritance diagram for QXmppRosterManager:
Inheritance graph
[legend]
Collaboration diagram for QXmppRosterManager:
Collaboration graph
[legend]

Public Slots

bool acceptSubscription (const QString &bareJid, const QString &reason=QString())
 
bool refuseSubscription (const QString &bareJid, const QString &reason=QString())
 
bool addItem (const QString &bareJid, const QString &name=QString(), const QSet< QString > &groups=QSet< QString >())
 
bool removeItem (const QString &bareJid)
 
bool renameItem (const QString &bareJid, const QString &name)
 
bool subscribe (const QString &bareJid, const QString &reason=QString())
 
bool unsubscribe (const QString &bareJid, const QString &reason=QString())
 

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 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)
 Constructs a roster manager.
 
bool isRosterReceived () const
 
QStringList getRosterBareJids () const
 
QXmppRosterIq::Item getRosterEntry (const QString &bareJid) const
 
QStringList getResources (const QString &bareJid) const
 
QMap< QString, QXmppPresencegetAllPresencesForBareJid (const QString &bareJid) const
 
QXmppPresence getPresence (const QString &bareJid, const QString &resource) const
 
- Public Member Functions inherited from QXmppClientExtension
 QXmppClientExtension ()
 
 ~QXmppClientExtension () override
 
virtual QStringList discoveryFeatures () const
 
virtual QList< QXmppDiscoveryIq::IdentitydiscoveryIdentities () const
 
virtual bool handleStanza (const QDomElement &stanza)=0
 You need to implement this method to process incoming XMPP stanzas. More...
 
- Public Member Functions inherited from QXmppLoggable
 QXmppLoggable (QObject *parent=nullptr)
 

Additional Inherited Members

- Protected Member Functions inherited from QXmppClientExtension
QXmppClientclient ()
 
virtual void setClient (QXmppClient *client)
 
- 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)
 

Detailed Description

The QXmppRosterManager class provides access to a connected client's roster.

Note
It's object should not be created using it's constructor. Instead 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.

Member Function Documentation

◆ acceptSubscription

bool QXmppRosterManager::acceptSubscription ( const QString &  bareJid,
const QString &  reason = QString() 
)
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.

Note
Pre-approving subscription requests is only allowed, if the server supports RFC6121 and advertises the 'urn:xmpp:features:pre-approval' stream feature.
See also
QXmppStreamFeatures::preApprovedSubscriptionsSupported()

◆ addItem

bool QXmppRosterManager::addItem ( const QString &  bareJid,
const QString &  name = QString(),
const QSet< QString > &  groups = QSet<QString>() 
)
slot

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.

Parameters
bareJid
nameOptional name for the item.
groupsOptional groups for the item.

◆ getAllPresencesForBareJid()

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.

Parameters
bareJidas a QString
Returns
Map of resource and its respective presence QMap<QString, QXmppPresence>

◆ getPresence()

QXmppPresence QXmppRosterManager::getPresence ( const QString &  bareJid,
const QString &  resource 
) const

Get the presence of the given resource of the given bareJid.

Parameters
bareJidas a QString
resourceas a QString
Returns
QXmppPresence

◆ getResources()

QStringList QXmppRosterManager::getResources ( const QString &  bareJid) const

Get all the associated resources with the given bareJid.

Parameters
bareJidas a QString
Returns
list of associated resources as a QStringList

◆ getRosterBareJids()

QStringList QXmppRosterManager::getRosterBareJids ( ) const

Function to get all the bareJids present in the roster.

Returns
QStringList list of all the bareJids

◆ getRosterEntry()

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.

Parameters
bareJidas a QString

◆ isRosterReceived()

bool QXmppRosterManager::isRosterReceived ( ) const

Function to check whether the roster has been received or not.

Returns
true if roster received else false

◆ itemAdded

void QXmppRosterManager::itemAdded ( const QString &  bareJid)
signal

This signal is emitted when the roster entry of a particular bareJid is added as a result of roster push.

◆ itemChanged

void QXmppRosterManager::itemChanged ( const QString &  bareJid)
signal

This signal is emitted when the roster entry of a particular bareJid changes as a result of roster push.

◆ itemRemoved

void QXmppRosterManager::itemRemoved ( const QString &  bareJid)
signal

This signal is emitted when the roster entry of a particular bareJid is removed as a result of roster push.

◆ refuseSubscription

bool QXmppRosterManager::refuseSubscription ( const QString &  bareJid,
const QString &  reason = QString() 
)
slot

Refuses a subscription request.

You can call this method in reply to the subscriptionRequest() signal.

◆ removeItem

bool QXmppRosterManager::removeItem ( const QString &  bareJid)
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.

Parameters
bareJid

◆ renameItem

bool QXmppRosterManager::renameItem ( const QString &  bareJid,
const QString &  name 
)
slot

Renames a roster item.

As a result, the server will initiate a roster push, causing the itemChanged() signal to be emitted.

Parameters
bareJid
name

◆ rosterReceived

void QXmppRosterManager::rosterReceived ( )
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.

◆ subscribe

bool QXmppRosterManager::subscribe ( const QString &  bareJid,
const QString &  reason = QString() 
)
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.

◆ subscriptionReceived

void QXmppRosterManager::subscriptionReceived ( const QString &  bareJid)
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().

Note
If you set QXmppConfiguration::autoAcceptSubscriptions() to true, this signal will not be emitted.

◆ unsubscribe

bool QXmppRosterManager::unsubscribe ( const QString &  bareJid,
const QString &  reason = QString() 
)
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.


The documentation for this class was generated from the following files: