QXmpp: QXmppAttentionManager Class Reference

QXmpp Version: 1.14.3

Loading...
Searching...
No Matches
QXmppAttentionManager Class Reference

The QXmppAttentionManager class manages attention requests as defined by XEP-0224: Attention. More...

Inheritance diagram for QXmppAttentionManager:

## Public Member Functions
| QXmppAttentionManager (quint8 allowedAttempts=3, QTime timeFrame=QTime(0, 15, 0))
| QXmppAttentionManager::QXmppAttentionManager.
QStringList | discoveryFeatures () const override
quint8 | allowedAttempts () const
void | setAllowedAttempts (quint8 allowedAttempts)
QTime | allowedAttemptsTimeInterval () const
void | setAllowedAttemptsTimeInterval (QTime interval)
Q_SLOT QString | requestAttention (const QString &jid, const QString &message={})
Q_SIGNAL void | attentionRequested (const QXmppMessage &message, bool isTrusted)
Q_SIGNAL void | attentionRequestRateLimited (const QXmppMessage &message)
Public Member Functions inherited from QXmppClientExtension
| QXmppClientExtension ()
virtual QList< QXmppDiscoIdentity > | 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)
Q_SIGNAL void | setGauge (const QString &gauge, double value)
| Sets the given gauge to value.
Q_SIGNAL void | logMessage (QXmppLogger::MessageType type, const QString &msg)
| This signal is emitted to send logging messages.
Q_SIGNAL void | updateCounter (const QString &counter, qint64 amount=1)
| Updates the given counter by amount.

## Protected Member Functions
void | onRegistered (QXmppClient *client) override
void | onUnregistered (QXmppClient *client) override
Protected Member Functions inherited from QXmppClientExtension
QXmppClient * | client () const
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)
| Logs a debugging message.
void | info (const QString &message)
| Logs an informational message.
void | warning (const QString &message)
| Logs a warning message.
void | logReceived (const QString &message)
| Logs a received packet.
void | logSent (const QString &message)
| Logs a sent packet.

## Detailed Description

The QXmppAttentionManager class manages attention requests as defined by XEP-0224: Attention.

The manager also does some checks, including rate limiting and checking whether the senders are trusted (aka. in the roster).

Rate limited messages are not emitted on the normal attentionRequested() signal and are sent on the attentionRequestRateLimited() signal instead.

To use this manager you still need to instantiate it and register it with the QXmppClient:

auto *attentionManager = new QXmppAttentionManager();
client->addExtension(attentionManager);
QXmppAttentionManager::QXmppAttentionManager
QXmppAttentionManager(quint8 allowedAttempts=3, QTime timeFrame=QTime(0, 15, 0))
QXmppAttentionManager::QXmppAttentionManager.
Definition QXmppAttentionManager.cpp:88
QXmppClientExtension::client
QXmppClient * client() const
Definition QXmppClientExtension.cpp:57

Since
  QXmpp 1.4

## Constructor & Destructor Documentation

## ◆ QXmppAttentionManager()

QXmppAttentionManager::QXmppAttentionManager | ( | quint8 | allowedAttempts = 3,
|  | QTime | timeFrame = QTime(0, 15, 0) )

QXmppAttentionManager::QXmppAttentionManager.

Parameters

  allowedAttempts |
  timeFrame |

## Member Function Documentation

## ◆ allowedAttempts()

quint8 QXmppAttentionManager::allowedAttempts | ( |  | ) | const

Returns the number of allowed attempts of attentions from a bare JID in the set time frame.

See also
  setAllowedAttempts()
  allowedAttemptsTimeInterval()
  setAllowedAttemptsTimeInterval()

## ◆ allowedAttemptsTimeInterval()

QTime QXmppAttentionManager::allowedAttemptsTimeInterval | ( |  | ) | const

Returns the time interval for the allowed attempts for rate limiting.

See also
  setAllowedAttemptsTimeInterval()
  allowedAttempts()
  setAllowedAttemptsTimeInterval()

## ◆ attentionRequested()

Q_SIGNAL void QXmppAttentionManager::attentionRequested | ( | const QXmppMessage & | message,
|  | bool | isTrusted )

This signal is emitted when an attention request was received and it passed the rate limiter.

Parameters

  message | The message with the attention request that was received.
  isTrusted | Whether the sender of the message exists in the user's roster.

## ◆ attentionRequestRateLimited()

Q_SIGNAL void QXmppAttentionManager::attentionRequestRateLimited | ( | const QXmppMessage & | message | ) |

This signal is emitted when an attention request did not pass the rate limiter.

Parameters

  message | The message with the attention request that did not pass the rate limiter.

## ◆ discoveryFeatures()

QStringList QXmppAttentionManager::discoveryFeatures | ( |  | ) | const
| overridevirtual

Returns the XEP-0224: Attention feature.

Reimplemented from QXmppClientExtension.

## ◆ onRegistered()

void QXmppAttentionManager::onRegistered | ( | QXmppClient * | client | ) |
| overrideprotectedvirtual

Called after the extension has been added to a QXmppClient.

Parameters

  client |

Reimplemented from QXmppClientExtension.

## ◆ onUnregistered()

void QXmppAttentionManager::onUnregistered | ( | QXmppClient * | client | ) |
| overrideprotectedvirtual

Called after the extension has been removed from a QXmppClient.

Parameters

  client |

Reimplemented from QXmppClientExtension.

## ◆ requestAttention()

QString QXmppAttentionManager::requestAttention | ( | const QString & | jid,
|  | const QString & | message = {} )

Sends a message of type chat with an attention request to the specified JID.

XEP-0224 allows to include other elements with an attention request, but the QXmppAttentionManager has no method for this purpose. However, such a request can still be made manually.

Parameters

  jid | The address to which the request should be sent.
  message | The message body to include in the attention request.

Returns
  The ID of the sent message, if sent successfully, a null string otherwise. In case an ID is returned, it also corresponds to the origin ID of the message as defined by XEP-0359: Unique and Stable Stanza IDs.

## ◆ setAllowedAttempts()

void QXmppAttentionManager::setAllowedAttempts | ( | quint8 | allowedAttempts | ) |

Sets the number of allowed attempts of attentions from a bare JID in the set time frame.

See also
  allowedAttempts()
  allowedAttemptsTimeInterval()
  setAllowedAttemptsTimeInterval()

## ◆ setAllowedAttemptsTimeInterval()

void QXmppAttentionManager::setAllowedAttemptsTimeInterval | ( | QTime | interval | ) |

Returns the time interval for the allowed attempts for rate limiting.

See also
  allowedAttemptsTimeInterval()
  allowedAttempts()
  setAllowedAttempts()

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

- QXmppAttentionManager.h
- QXmppAttentionManager.cpp