diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-10 09:04:12 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-10 09:04:12 +0000 |
| commit | 7729fa4a4727c724df9e31cc524334f0629c558b (patch) | |
| tree | 5761e38927607ff8b8e6a9473447a1599cc7b26c /source | |
| parent | 7e200ac65474aba6069dca506db3bb57704d4fdd (diff) | |
| download | qxmpp-7729fa4a4727c724df9e31cc524334f0629c558b.tar.gz | |
RPC: splitting methodName should not be done at the QXmppRpcIq level,
it is perfectly legitimate to not use the INTERFACE.METHOD convention
in a Jabber-RPC IQ
Diffstat (limited to 'source')
| -rw-r--r-- | source/QXmppClient.cpp | 12 | ||||
| -rw-r--r-- | source/QXmppRemoteMethod.cpp | 3 | ||||
| -rw-r--r-- | source/QXmppRpcIq.cpp | 27 | ||||
| -rw-r--r-- | source/QXmppRpcIq.h | 4 |
4 files changed, 20 insertions, 26 deletions
diff --git a/source/QXmppClient.cpp b/source/QXmppClient.cpp index a7f72b1b..400ff7e0 100644 --- a/source/QXmppClient.cpp +++ b/source/QXmppClient.cpp @@ -468,15 +468,21 @@ void QXmppClient::addInvokableInterface( QXmppInvokable *interface ) void QXmppClient::invokeInterfaceMethod( const QXmppRpcInvokeIq &iq ) { QXmppStanza::Error error; - QXmppInvokable *iface = m_interfaces.value(iq.interface()); + + const QStringList methodBits = iq.method().split('.'); + if (methodBits.size() != 2) + return; + const QString interface = methodBits.first(); + const QString method = methodBits.last(); + QXmppInvokable *iface = m_interfaces.value(interface); if (iface) { if ( iface->isAuthorized( iq.from() ) ) { - if ( iface->interfaces().contains( iq.method() ) ) + if ( iface->interfaces().contains(method) ) { - QVariant result = iface->dispatch(iq.method().toLatin1(), + QVariant result = iface->dispatch(method.toLatin1(), iq.arguments() ); QXmppRpcResponseIq resultIq; resultIq.setId(iq.id()); diff --git a/source/QXmppRemoteMethod.cpp b/source/QXmppRemoteMethod.cpp index 579ae285..479bcfb1 100644 --- a/source/QXmppRemoteMethod.cpp +++ b/source/QXmppRemoteMethod.cpp @@ -35,8 +35,7 @@ QXmppRemoteMethod::QXmppRemoteMethod(const QString &jid, const QString &method, { m_payload.setTo( jid ); m_payload.setFrom( client->configuration().jid() ); - m_payload.setInterface( method.section('.', 0, 0 ) ); - m_payload.setMethod( method.section('.', 1) ); + m_payload.setMethod( method ); m_payload.setArguments( args ); } diff --git a/source/QXmppRpcIq.cpp b/source/QXmppRpcIq.cpp index def28458..41007312 100644 --- a/source/QXmppRpcIq.cpp +++ b/source/QXmppRpcIq.cpp @@ -369,23 +369,21 @@ void QXmppRpcInvokeIq::setArguments(const QVariantList &arguments) m_arguments = arguments; } +/// Returns the method name. +/// + QString QXmppRpcInvokeIq::method() const { return m_method; } -void QXmppRpcInvokeIq::setMethod( const QString &method ) -{ - m_method = method; -} -QString QXmppRpcInvokeIq::interface() const -{ - return m_interface; -} +/// Sets the method name. +/// +/// \param method -void QXmppRpcInvokeIq::setInterface( const QString &interface ) +void QXmppRpcInvokeIq::setMethod(const QString &method) { - m_interface = interface; + m_method = method; } bool QXmppRpcInvokeIq::isRpcInvokeIq(const QDomElement &element) @@ -401,12 +399,7 @@ void QXmppRpcInvokeIq::parseElementFromChild(const QDomElement &element) QDomElement queryElement = element.firstChildElement("query"); QDomElement methodElement = queryElement.firstChildElement("methodCall"); - const QString methodName = methodElement.firstChildElement("methodName").text(); - if (methodName.count('.') == 1) - { - m_interface = methodName.split('.').first(); - m_method = methodName.split('.').last(); - } + m_method = methodElement.firstChildElement("methodName").text(); const QDomElement methodParams = methodElement.firstChildElement("params"); m_arguments.clear(); @@ -431,7 +424,7 @@ void QXmppRpcInvokeIq::toXmlElementFromChild(QXmlStreamWriter *writer) const helperToXmlAddAttribute(writer, "xmlns", ns_rpc); writer->writeStartElement("methodCall"); - writer->writeTextElement("methodName", m_interface + "." + m_method); + writer->writeTextElement("methodName", m_method); if (!m_arguments.isEmpty()) { writer->writeStartElement("params"); diff --git a/source/QXmppRpcIq.h b/source/QXmppRpcIq.h index 6ca92e5e..e21222d6 100644 --- a/source/QXmppRpcIq.h +++ b/source/QXmppRpcIq.h @@ -80,9 +80,6 @@ class QXmppRpcInvokeIq : public QXmppIq public: QXmppRpcInvokeIq(); - QString interface() const; - void setInterface( const QString &interface ); - QString method() const; void setMethod( const QString &method ); @@ -100,7 +97,6 @@ protected: private: QVariantList m_arguments; QString m_method; - QString m_interface; friend class QXmppRpcErrorIq; }; |
