|
static bool | isItem (const QDomElement &element) |
|
|
template<typename PayloadChecker > |
static bool | isItem (const QDomElement &element, PayloadChecker isPayloadValid) |
|
The QXmppPubSubItem class represents a publish-subscribe item as defined by XEP-0060: Publish-Subscribe.
To access the payload of an item, you need to create a derived class of this and override QXmppPubSubItem::parsePayload() and QXmppPubSubItem::serializePayload().
It is also required that you override QXmppPubSubItem::isItem() and also check for the correct payload of the PubSub item. This can be easily done by using the protected overload of isItem() with an function that checks the tag name and namespace of the payload. The function is only called if a payload exists.
In short, you need to reimplement these methods:
- Since
- QXmpp 1.5
◆ QXmppPubSubItem()
QXmppPubSubItem::QXmppPubSubItem |
( |
const QString & |
id = {} , |
|
|
const QString & |
publisher = {} |
|
) |
| |
Constructs an item with id and publisher.
- Parameters
-
◆ id()
QString QXmppPubSubItem::id |
( |
| ) |
const |
Returns the ID of the PubSub item.
◆ isItem() [1/2]
bool QXmppPubSubItem::isItem |
( |
const QDomElement & |
element | ) |
|
|
static |
Returns true, if the element is possibly a PubSub item.
◆ isItem() [2/2]
template<typename PayloadChecker >
bool QXmppPubSubItem::isItem |
( |
const QDomElement & |
element, |
|
|
PayloadChecker |
isPayloadValid |
|
) |
| |
|
staticprotected |
Returns true, if the element is a valid PubSub item and (if existant) the payload is correct.
- Parameters
-
element | The element to be checked to be an <item/> element. |
isPayloadValid | A function that validates the payload element (first child element). The functions needs to return true, if the payload is valid. In case there is no payload, the function is not called. |
Here is an example covering how this could be used to check for the XEP-0118: User Tune payload:
auto isPayloadValid = [](const QDomElement &payload) -> bool {
return payload.tagName() == "tune" && payload.namespaceURI() == ns_tune;
};
static bool isItem(const QDomElement &element)
Definition: QXmppPubSubItem.cpp:130
◆ parsePayload()
void QXmppPubSubItem::parsePayload |
( |
const QDomElement & |
payloadElement | ) |
|
|
protectedvirtual |
Parses the payload of the item (the child element of the <item/>).
This method needs to be overriden to perform the payload-specific parsing.
◆ publisher()
QString QXmppPubSubItem::publisher |
( |
| ) |
const |
Returns the JID of the publisher of the item.
◆ serializePayload()
void QXmppPubSubItem::serializePayload |
( |
QXmlStreamWriter * |
writer | ) |
const |
|
protectedvirtual |
Serializes the payload of the item (the child element of the <item/>).
This method needs to be overriden to perform the payload-specific serialization.
◆ setId()
void QXmppPubSubItem::setId |
( |
const QString & |
id | ) |
|
Sets the ID of the PubSub item.
- Parameters
-
◆ setPublisher()
void QXmppPubSubItem::setPublisher |
( |
const QString & |
publisher | ) |
|
Sets the JID of the publisher of the item.
The documentation for this class was generated from the following files: