aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-12-10 16:31:32 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-12-10 16:31:32 +0000
commit0fc9ad87ac985ae40b2f205c88f901024967c3ec (patch)
tree77c4501cc928a62e2f130ccaf33adca7a32daba8 /src
parent9f0e20698c338990b0a4c9b50ce376ebfc627101 (diff)
downloadqxmpp-0fc9ad87ac985ae40b2f205c88f901024967c3ec.tar.gz
move RPC stuff to QXmppRpcManager (client-facing API is unchanged for now)
Diffstat (limited to 'src')
-rw-r--r--src/QXmppClient.cpp90
-rw-r--r--src/QXmppClient.h3
-rw-r--r--src/QXmppDiscoveryManager.cpp1
-rw-r--r--src/QXmppOutgoingClient.cpp20
-rw-r--r--src/QXmppOutgoingClient.h9
-rw-r--r--src/QXmppRpcManager.cpp2
-rw-r--r--src/QXmppRpcManager.h4
7 files changed, 10 insertions, 119 deletions
diff --git a/src/QXmppClient.cpp b/src/QXmppClient.cpp
index adf56f04..b396c035 100644
--- a/src/QXmppClient.cpp
+++ b/src/QXmppClient.cpp
@@ -33,6 +33,7 @@
#include "QXmppMucManager.h"
#include "QXmppReconnectionManager.h"
#include "QXmppRpcIq.h"
+#include "QXmppRpcManager.h"
#include "QXmppRemoteMethod.h"
#include "QXmppRosterManager.h"
#include "QXmppUtils.h"
@@ -59,12 +60,11 @@ public:
QXmppMucManager *mucManager; ///< Pointer to the multi-user chat manager
QXmppReconnectionManager *reconnectionManager; ///< Pointer to the reconnection manager
QXmppRosterManager *rosterManager; ///< Pointer to the roster manager
+ QXmppRpcManager *rpcManager; ///< Pointer to the RPC manager
QXmppTransferManager *transferManager;///< Pointer to the transfer manager
QXmppVCardManager *vCardManager; ///< Pointer to the vCard manager
QXmppVersionManager *versionManager; ///< Pointer to the version manager
- QHash<QString,QXmppInvokable*> interfaces;
-
void addProperCapability(QXmppPresence& presence);
QXmppClient *client;
@@ -174,11 +174,6 @@ QXmppClient::QXmppClient(QObject *parent)
check = setReconnectionManager(new QXmppReconnectionManager(this));
Q_ASSERT(check);
- // rpc
- check = connect(d->stream, SIGNAL(rpcCallInvoke(QXmppRpcInvokeIq)),
- this, SLOT(invokeInterfaceMethod(QXmppRpcInvokeIq)));
- Q_ASSERT(check);
-
// logging
d->logger = 0;
setLogger(QXmppLogger::getLogger());
@@ -188,6 +183,9 @@ QXmppClient::QXmppClient(QObject *parent)
d->rosterManager = new QXmppRosterManager(this);
addExtension(d->rosterManager);
+ d->rpcManager = new QXmppRpcManager;
+ addExtension(d->rpcManager);
+
d->archiveManager = new QXmppArchiveManager;
addExtension(d->archiveManager);
@@ -596,62 +594,7 @@ void QXmppClient::slotElementReceived(const QDomElement &element, bool &handled)
void QXmppClient::addInvokableInterface( QXmppInvokable *interface )
{
- d->interfaces[ interface->metaObject()->className() ] = interface;
-}
-
-
-void QXmppClient::invokeInterfaceMethod( const QXmppRpcInvokeIq &iq )
-{
- QXmppStanza::Error error;
-
- const QStringList methodBits = iq.method().split('.');
- if (methodBits.size() != 2)
- return;
- const QString interface = methodBits.first();
- const QString method = methodBits.last();
- QXmppInvokable *iface = d->interfaces.value(interface);
- if (iface)
- {
- if ( iface->isAuthorized( iq.from() ) )
- {
-
- if ( iface->interfaces().contains(method) )
- {
- QVariant result = iface->dispatch(method.toLatin1(),
- iq.arguments() );
- QXmppRpcResponseIq resultIq;
- resultIq.setId(iq.id());
- resultIq.setTo(iq.from());
- resultIq.setFrom(d->stream->configuration().jid());
- resultIq.setValues(QVariantList() << result);
- d->stream->sendPacket( resultIq );
- return;
- }
- else
- {
- error.setType(QXmppStanza::Error::Cancel);
- error.setCondition(QXmppStanza::Error::ItemNotFound);
-
- }
- }
- else
- {
- error.setType(QXmppStanza::Error::Auth);
- error.setCondition(QXmppStanza::Error::Forbidden);
- }
- }
- else
- {
- error.setType(QXmppStanza::Error::Cancel);
- error.setCondition(QXmppStanza::Error::ItemNotFound);
- }
- QXmppRpcErrorIq errorIq;
- errorIq.setId(iq.id());
- errorIq.setTo(iq.from());
- errorIq.setFrom(d->stream->configuration().jid());
- errorIq.setQuery( iq );
- errorIq.setError( error );
- d->stream->sendPacket( errorIq );
+ d->rpcManager->addInvokableInterface(interface);
}
QXmppRemoteMethodResult QXmppClient::callRemoteMethod( const QString &jid,
@@ -667,26 +610,7 @@ QXmppRemoteMethodResult QXmppClient::callRemoteMethod( const QString &jid,
const QVariant &arg9,
const QVariant &arg10 )
{
- QVariantList args;
- if( arg1.isValid() ) args << arg1;
- if( arg2.isValid() ) args << arg2;
- if( arg3.isValid() ) args << arg3;
- if( arg4.isValid() ) args << arg4;
- if( arg5.isValid() ) args << arg5;
- if( arg6.isValid() ) args << arg6;
- if( arg7.isValid() ) args << arg7;
- if( arg8.isValid() ) args << arg8;
- if( arg9.isValid() ) args << arg9;
- if( arg10.isValid() ) args << arg10;
-
- QXmppRemoteMethod method( jid, interface, args, this );
- connect( d->stream, SIGNAL(rpcCallResponse(QXmppRpcResponseIq)),
- &method, SLOT(gotResult(QXmppRpcResponseIq)));
- connect( d->stream, SIGNAL(rpcCallError(QXmppRpcErrorIq)),
- &method, SLOT(gotError(QXmppRpcErrorIq)));
-
-
- return method.call();
+ return d->rpcManager->callRemoteMethod(jid, interface, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}
/// Returns the reference to QXmppArchiveManager, implementation of XEP-0136.
diff --git a/src/QXmppClient.h b/src/QXmppClient.h
index 2437f0d3..ea05bfbc 100644
--- a/src/QXmppClient.h
+++ b/src/QXmppClient.h
@@ -254,7 +254,7 @@ signals:
void iqReceived(const QXmppIq&);
/// \cond
- // Deprecated in relese 0.3.0
+ // Deprecated in release 0.3.0
// Use QXmppDiscoveryManager::informationReceived(const QXmppDiscoveryIq&)
// Notifies that an XMPP service discovery iq stanza is received.
void discoveryIqReceived(const QXmppDiscoveryIq&);
@@ -266,7 +266,6 @@ public slots:
private slots:
void slotElementReceived(const QDomElement &element, bool &handled);
- void invokeInterfaceMethod( const QXmppRpcInvokeIq &iq );
void xmppConnected();
private:
diff --git a/src/QXmppDiscoveryManager.cpp b/src/QXmppDiscoveryManager.cpp
index e481beb5..e09a2318 100644
--- a/src/QXmppDiscoveryManager.cpp
+++ b/src/QXmppDiscoveryManager.cpp
@@ -125,7 +125,6 @@ QXmppDiscoveryIq QXmppDiscoveryManager::capabilities()
// features
QStringList features;
features
- << ns_rpc // XEP-0009: Jabber-RPC
<< ns_chat_states // XEP-0085: Chat State Notifications
<< ns_capabilities // XEP-0115 : Entity Capabilities
<< ns_ping; // XEP-0199: XMPP Ping
diff --git a/src/QXmppOutgoingClient.cpp b/src/QXmppOutgoingClient.cpp
index 8acaade4..2f92fc57 100644
--- a/src/QXmppOutgoingClient.cpp
+++ b/src/QXmppOutgoingClient.cpp
@@ -41,7 +41,6 @@
// IQ types
#include "QXmppBindIq.h"
#include "QXmppPingIq.h"
-#include "QXmppRpcIq.h"
#include "QXmppSessionIq.h"
#include <QBuffer>
@@ -467,25 +466,6 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
}
// extensions
- // XEP-0009: Jabber-RPC
- else if(QXmppRpcInvokeIq::isRpcInvokeIq(nodeRecv))
- {
- QXmppRpcInvokeIq rpcIqPacket;
- rpcIqPacket.parse(nodeRecv);
- emit rpcCallInvoke(rpcIqPacket);
- }
- else if(QXmppRpcResponseIq::isRpcResponseIq(nodeRecv))
- {
- QXmppRpcResponseIq rpcResponseIq;
- rpcResponseIq.parse(nodeRecv);
- emit rpcCallResponse(rpcResponseIq);
- }
- else if(QXmppRpcErrorIq::isRpcErrorIq(nodeRecv))
- {
- QXmppRpcErrorIq rpcErrorIq;
- rpcErrorIq.parse(nodeRecv);
- emit rpcCallError(rpcErrorIq);
- }
// XEP-0078: Non-SASL Authentication
else if(id == d->nonSASLAuthId && type == "result")
{
diff --git a/src/QXmppOutgoingClient.h b/src/QXmppOutgoingClient.h
index 4b39445b..c9e831a3 100644
--- a/src/QXmppOutgoingClient.h
+++ b/src/QXmppOutgoingClient.h
@@ -37,8 +37,6 @@ class QXmppConfiguration;
class QXmppPresence;
class QXmppIq;
class QXmppMessage;
-class QXmppRpcResponseIq;
-class QXmppRpcErrorIq;
class QXmppSrvInfo;
class QXmppOutgoingClientPrivate;
@@ -79,13 +77,6 @@ signals:
/// This signal is emitted when an IQ is received.
void iqReceived(const QXmppIq&);
- /// \cond
- // XEP-0009: Jabber-RPC
- void rpcCallInvoke(const QXmppRpcInvokeIq &invoke);
- void rpcCallResponse(const QXmppRpcResponseIq& result);
- void rpcCallError(const QXmppRpcErrorIq &err);
- /// \endcond
-
protected:
/// \cond
// Overridable methods
diff --git a/src/QXmppRpcManager.cpp b/src/QXmppRpcManager.cpp
index ab327358..e56a41c6 100644
--- a/src/QXmppRpcManager.cpp
+++ b/src/QXmppRpcManager.cpp
@@ -138,7 +138,7 @@ bool QXmppRpcManager::handleStanza(const QDomElement &element)
{
QXmppRpcInvokeIq rpcIqPacket;
rpcIqPacket.parse(element);
- emit rpcCallInvoke(rpcIqPacket);
+ invokeInterfaceMethod(rpcIqPacket);
return true;
}
else if(QXmppRpcResponseIq::isRpcResponseIq(element))
diff --git a/src/QXmppRpcManager.h b/src/QXmppRpcManager.h
index d6317a26..a8b08de8 100644
--- a/src/QXmppRpcManager.h
+++ b/src/QXmppRpcManager.h
@@ -63,15 +63,13 @@ public:
signals:
/// \cond
- void rpcCallInvoke(const QXmppRpcInvokeIq &invoke);
void rpcCallResponse(const QXmppRpcResponseIq& result);
void rpcCallError(const QXmppRpcErrorIq &err);
/// \endcond
-private slots:
+private:
void invokeInterfaceMethod(const QXmppRpcInvokeIq &iq);
-private:
QMap<QString,QXmppInvokable*> m_interfaces;
};