qxmpp
qxmpp copied to clipboard
QXmppServer: Route stanza for a bare jid to specific resource
As far as I can see, it isn't possible to tell the QXmppServer to route a stanza with a bare JID in the 'to' attribute to a specific resource without changing the 'to' attribute.
If I want to route a message only to the resource with the highest presence priority or the most recently used resource, I must not change the 'to' attribute as stated in RFC 6121 chapter 8.5.2.1.1 (Server Rules for Processing XML Stanzas / Local User / Avalable or Connected Resource / Message) last paragraph:
In all cases, the server MUST NOT rewrite the 'to' attribute (i.e.,
it MUST leave it as <localpart@domainpart> rather than change it to
<localpart@domainpart/resourcepart>).
So this cannot be achieved with QXmppServer. I think that could easily be achieved by either adding a 2nd Parameter const QString& resource = QString() to sendElement(...) and sendPacket(...)
bool sendElement(const QDomElement &element, const QString& resource = QString());
bool sendPacket(const QXmppStanza &stanza, const QString& resource = QString());
or by providing overloaded methods
bool sendElement(const QDomElement &element);
bool sendElement(const QString& resource, const QDomElement &element);
bool sendPacket(const QXmppStanza &stanza);
bool sendPacket(const QString& resource, const QXmppStanza &stanza);
As I don't know the ideas / architecture / coding rules behind qxmpp I cannot estimate whether any of the suggestions would fit or whether it could cause problems.
Currently I think it would be enough to only add the possibility to just specify the resource but maybe someone can think of a use case for specifying the full JID.