QXmpp Version: 1.15.1
Loading...
Searching...
No Matches
QXmpp

Introduction

QXmpp is a cross-platform C++ XMPP client and server library built on top of the Qt framework (Qt 6.4+). It implements a large number of XMPP Extension Protocols (XEPs) and exposes a modern, reactive API based on C++20 and Qt's property system.

Getting Started

The central class is QXmppClient. Create one, register the managers you need, then connect:

auto *client = new QXmppClient(this);
// Register managers
auto *pubsub = client->addNewExtension<QXmppPubSubManager>();
auto *disco = client->addNewExtension<QXmppDiscoveryManager>();
auto *muc = client->addNewExtension<QXmppMucManagerV2>();
// Connect
config.setJid("user@example.org");
config.setPassword("secret");
client->connectToServer(config);
Main class for starting and managing connections to XMPP servers.
Definition QXmppClient.h:62
The QXmppConfiguration class holds configuration options.
Definition QXmppConfiguration.h:37
void setJid(const QString &jid)
Definition QXmppConfiguration.cpp:239
The QXmppDiscoveryManager class makes it possible to discover information about other entities as def...
Definition QXmppDiscoveryManager.h:23
XEP-0045: Multi-User Chat Manager with support for XEP-0402: PEP Native Bookmarks.
Definition QXmppMucManagerV2.h:52
The QXmppPubSubManager aims to provide publish-subscribe functionality as specified in XEP-0060: Publ...
Definition QXmppPubSubManager.h:21

Async API

All network operations return a QXmppTask<T>, which represents a pending result. QXmppTask supports co_await, making sequential async code straightforward:

QXmppTask<void> MyManager::doSomething()
{
auto result = co_await muc->joinRoom("room@conference.example.org", "MyNick").withContext(this);
if (auto *err = std::get_if<QXmppError>(&result)) {
qWarning() << "Join failed:" << err->description;
co_return;
}
// continue ...
}
Definition QXmppTask.h:330

Alternatively, use .then() to attach a callback:

muc->joinRoom("room@conference.example.org", "MyNick").then(this, [](auto result) {
if (auto *err = std::get_if<QXmppError>(&result)) {
qWarning() << "Join failed:" << err->description;
}
});

Results are typically QXmpp::Result<T>, a std::variant<T, QXmppError>. Always pass a context object (this) to .then() or .withContext() to ensure the callback is not invoked after the object has been destroyed.

Managers

Managers are the primary way to use XMPP features. Register them with QXmppClient and extend QXmppClient by subclassing QXmppClientExtension.

See the Managers module for the full list.

Messaging

  • QXmppCarbonManagerV2 — Message carbons (XEP-0280)
  • QXmppMamManager — Message archive management (XEP-0313)
  • QXmppMessageReceiptManager — Message delivery receipts (XEP-0184)
  • QXmppAttentionManager — Attention requests (XEP-0224)

Contacts & Roster

  • QXmppRosterManager — Contact list (XEP-0162)
  • QXmppVCardManager — vCards (vcard-temp)
  • QXmppUserLocationManager — User location (XEP-0080)
  • QXmppUserTuneManager — User tune (XEP-0118)
  • QXmppVersionManager — Software version (XEP-0092)
  • QXmppEntityTimeManager — Entity time (XEP-0202)

Groupchat

  • QXmppMucManagerV2 — In development: Multi-user chat with reactive API (XEP-0045)
  • QXmppMixManager — Mediated Information eXchange (XEP-0369)

File Sharing

  • QXmppFileSharingManager — Stateless file sharing (XEP-0447)
  • QXmppHttpUploadManager — HTTP file upload service (XEP-0363)
  • QXmppUploadRequestManager — HTTP upload slot requests (XEP-0363)
  • QXmppTransferManager — In-band / SOCKS5 file transfer (XEP-0047, XEP-0065)

End-to-End Encryption

  • QXmppOmemoManager — OMEMO 2 end-to-end encryption (XEP-0384)
  • QXmppAtmManager — Automatic trust management (XEP-0450)
  • QXmppTrustManager — Trust level storage and queries

Calls

  • QXmppCallManager — Jingle audio/video calls (XEP-0166)
  • QXmppCallInviteManager — Call invites (XEP-0482)
  • QXmppJingleMessageInitiationManager — Jingle message initiation (XEP-0353)

Bookmarks & PubSub

  • QXmppPepBookmarkManager — PEP native bookmarks (XEP-0402)
  • QXmppPubSubManager — Publish-subscribe (XEP-0060)

Service Discovery & Utilities

  • QXmppDiscoveryManager — Service discovery (XEP-0030)
  • QXmppBlockingManager — Contact blocking (XEP-0191)
  • QXmppExternalServiceDiscoveryManager — External service discovery (XEP-0215)
  • QXmppRegistrationManager — In-band registration (XEP-0077)
  • QXmppAccountMigrationManager — Account data migration (XEP-0227)
  • QXmppMovedManager — Account migration hints (XEP-0283)

Legacy (deprecated)

  • QXmppMucManager — superseded by QXmppMucManagerV2
  • QXmppCarbonManager — superseded by QXmppCarbonManagerV2
  • QXmppBookmarkManager — superseded by QXmppPepBookmarkManager
  • QXmppArchiveManager — superseded by QXmppMamManager
  • QXmppRpcManager — RPC (XEP-0009)

Low-Level Stanza API

For direct access to XMPP stanzas:

  • QXmppIq
  • QXmppMessage
  • QXmppPresence

Project Links