QXmppMamManager Class

The QXmppMamManager class makes it possible to access message archives as defined by XEP-0313: Message Archive Management. More...

Header: #include <QXmppMamManager.h>
Since: QXmpp 1.0
Inherits: QXmppClientExtension

Public Functions

(since QXmpp 1.18) QXmppTask<QXmpp::Result<QXmpp::Mam::ArchiveMetadata>> requestMetadata(const QXmpp::Jid &to = {})
(since QXmpp 1.18) QXmppTask<QXmpp::Result<QXmppDataForm>> requestQueryForm(const QXmpp::Jid &to = {}, const QString &node = {})
(since QXmpp 1.18) QXmppTask<QXmpp::Mam::RetrieveResult> retrieve(const QXmpp::Mam::Query &query)
QString retrieveArchivedMessages(const QString &to = QString(), const QString &node = QString(), const QString &jid = QString(), const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime(), const QXmppResultSetQuery &resultSetQuery = QXmppResultSetQuery())
(since QXmpp 1.17) QXmppDiscoFeatureWatch watchAccountSupport() const

Signals

void archivedMessageReceived(const QString &queryId, const QXmppMessage &message)
void resultsRecieved(const QString &queryId, const QXmppResultSetReply &resultSetReply, bool complete)

Detailed Description

To make use of this manager, you need to instantiate it and load it into the QXmppClient instance as follows:

QXmppMamManager *manager = new QXmppMamManager;
client->addExtension(manager);

Checking whether the account supports message archiving using watchAccountSupport() requires the QXmppDiscoveryManager to be registered with the client.

Member Function Documentation

[signal] void QXmppMamManager::archivedMessageReceived(const QString &queryId, const QXmppMessage &message)

This signal is emitted when an archived message is received

queryId.

For queries sent via retrieveArchivedMessages(), only messages sent by the queried archive are emitted (since QXmpp 1.18).

[since QXmpp 1.18] QXmppTask<QXmpp::Result<QXmpp::Mam::ArchiveMetadata>> QXmppMamManager::requestMetadata(const QXmpp::Jid &to = {})

Requests the metadata of an archive, i.e. its first and last message.

This requires the archive to support QXmpp::Namespace::Mam2Extended.

to is the archive to query, null for the archive of the own account.

This function was introduced in QXmpp 1.18.

[since QXmpp 1.18] QXmppTask<QXmpp::Result<QXmppDataForm>> QXmppMamManager::requestQueryForm(const QXmpp::Jid &to = {}, const QString &node = {})

Requests the form with the fields an archive supports in queries.

Besides the fields defined by XEP-0313: Message Archive Management, the form may contain fields specific to the server. They can be used via QXmpp::Mam::Query::additionalFields.

to is the archive to query, null for the archive of the own account. node is the PubSub node to query, usually empty.

This function was introduced in QXmpp 1.18.

[signal] void QXmppMamManager::resultsRecieved(const QString &queryId, const QXmppResultSetReply &resultSetReply, bool complete)

This signal is emitted when all results for a request have been received

complete, queryId, and resultSetReply.

[since QXmpp 1.18] QXmppTask<QXmpp::Mam::RetrieveResult> QXmppMamManager::retrieve(const QXmpp::Mam::Query &query)

Retrieves archived messages and returns them with their context.

The messages are processed by the message pipeline (see QXmpp::Messages): The real sender is resolved (QXmpp::Messages::ResolveSender) and encrypted messages are decrypted. The QXmpp::Messages::Received hook is not run for them and they are not delivered via QXmppClient::messageReceived(). Each context has the origin QXmpp::Messages::Origin::Mam and a QXmpp::Messages::ArchiveInfo attachment. Messages without content after the decryption (e.g. key exchanges) are not returned. To process the messages while the query is still running, use the QXmpp::Mam::MessageReceived hook.

The number of results may be limited by the server, see query's result set query for paging through the archive.

This function was introduced in QXmpp 1.18.

QString QXmppMamManager::retrieveArchivedMessages(const QString &to = QString(), const QString &node = QString(), const QString &jid = QString(), const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime(), const QXmppResultSetQuery &resultSetQuery = QXmppResultSetQuery())

Retrieves archived messages. For each received message, the archiveMessageReceived() signal is emitted. Once all messages are received, the resultsRecieved() signal is emitted. It returns a result set that can be used to page through the results. The number of results may be limited by the server.

Warning: This API does not work with end-to-end encrypted messages. You can use retrieve() for that.

to is an optional entity that should be queried. Leave this empty to query the local archive. node is an optional node that should be queried. This is used when querying a pubsub node. jid is an optional JID to filter the results. start is an optional start time to filter the results, end an optional end time to filter the results. resultSetQuery is an optional Result Set Management query. This can be used to limit the number of results and to page through the archive.

Returns the query id of the request. This can be used to associate the corresponding resultsRecieved signal.

[since QXmpp 1.17] QXmppDiscoFeatureWatch QXmppMamManager::watchAccountSupport() const

Returns a watch on whether the own account supports XEP-0313: Message Archive Management.

The information is requested as long as a copy of the watch exists and shared with all other watches on the account information. This requires the QXmppDiscoveryManager to be registered with the client. If the manager is not registered with a client, a watch that never loads is returned.

This function was introduced in QXmpp 1.17.