QXmpp Version: 1.5.6
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
QXmppPubSubBaseItem Class Reference
Inheritance diagram for QXmppPubSubBaseItem:
Inheritance graph
[legend]

Public Member Functions

 QXmppPubSubBaseItem (const QString &id={}, const QString &publisher={})
 
 QXmppPubSubBaseItem (const QXmppPubSubBaseItem &)
 Default copy-constructor.
 
 QXmppPubSubBaseItem (QXmppPubSubBaseItem &&)
 Default move-constructor.
 
QXmppPubSubBaseItemoperator= (const QXmppPubSubBaseItem &)
 Default assignment operator.
 
QXmppPubSubBaseItemoperator= (QXmppPubSubBaseItem &&)
 Default move-assignment operator.
 
QString id () const
 
void setId (const QString &id)
 
QString publisher () const
 
void setPublisher (const QString &publisher)
 

Static Public Member Functions

static bool isItem (const QDomElement &element)
 

Protected Member Functions

virtual void parsePayload (const QDomElement &payloadElement)
 
virtual void serializePayload (QXmlStreamWriter *writer) const
 

Static Protected Member Functions

template<typename PayloadChecker >
static bool isItem (const QDomElement &element, PayloadChecker isPayloadValid)
 

Detailed Description

The QXmppPubSubBaseItem 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 QXmppPubSubBaseItem::parsePayload() and QXmppPubSubBaseItem::serializePayload().

It is also required that you override QXmppPubSubBaseItem::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

Constructor & Destructor Documentation

◆ QXmppPubSubBaseItem()

QXmppPubSubBaseItem::QXmppPubSubBaseItem ( const QString &  id = {},
const QString &  publisher = {} 
)

Constructs an item with id and publisher.

Parameters
id
publisher

Member Function Documentation

◆ id()

QString QXmppPubSubBaseItem::id ( ) const

Returns the ID of the PubSub item.

◆ isItem() [1/2]

bool QXmppPubSubBaseItem::isItem ( const QDomElement &  element)
static

Returns true, if the element is possibly a PubSub item.

◆ isItem() [2/2]

template<typename PayloadChecker >
bool QXmppPubSubBaseItem::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
elementThe element to be checked to be an <item/> element.
isPayloadValidA 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;
};
bool valid = QXmppPubSubItem::isItem(itemElement, isPayloadValid);

◆ parsePayload()

void QXmppPubSubBaseItem::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 QXmppPubSubBaseItem::publisher ( ) const

Returns the JID of the publisher of the item.

◆ serializePayload()

void QXmppPubSubBaseItem::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 QXmppPubSubBaseItem::setId ( const QString &  id)

Sets the ID of the PubSub item.

Parameters
id

◆ setPublisher()

void QXmppPubSubBaseItem::setPublisher ( const QString &  publisher)

Sets the JID of the publisher of the item.


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