aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-04-20 14:45:50 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2012-04-20 14:45:50 +0000
commit5940e91a4af209e7d3adbe90e98c4ff953993198 (patch)
treeca16245e6a6e26e1505bf35f2955de48d2647c07
parent46cd5c8b9dc98e791198d1a3c744e24876c94f66 (diff)
downloadqxmpp-5940e91a4af209e7d3adbe90e98c4ff953993198.tar.gz
rename XMLRPC to QXmppRpcMarshaller
-rw-r--r--src/base/QXmppRpcIq.cpp16
-rw-r--r--src/base/QXmppRpcIq.h9
-rw-r--r--tests/tests.cpp4
3 files changed, 15 insertions, 14 deletions
diff --git a/src/base/QXmppRpcIq.cpp b/src/base/QXmppRpcIq.cpp
index a2647077..adfc5db4 100644
--- a/src/base/QXmppRpcIq.cpp
+++ b/src/base/QXmppRpcIq.cpp
@@ -32,7 +32,7 @@
#include "QXmppRpcIq.h"
#include "QXmppUtils.h"
-void XMLRPC::marshall(QXmlStreamWriter *writer, const QVariant &value)
+void QXmppRpcMarshaller::marshall(QXmlStreamWriter *writer, const QVariant &value)
{
writer->writeStartElement("value");
switch( value.type() )
@@ -104,7 +104,7 @@ void XMLRPC::marshall(QXmlStreamWriter *writer, const QVariant &value)
writer->writeEndElement();
}
-QVariant XMLRPC::demarshall(const QDomElement &elem, QStringList &errors)
+QVariant QXmppRpcMarshaller::demarshall(const QDomElement &elem, QStringList &errors)
{
if ( elem.tagName().toLower() != "value" )
{
@@ -297,7 +297,7 @@ void QXmppRpcResponseIq::parseElementFromChild(const QDomElement &element)
while (!param.isNull())
{
QStringList errors;
- const QVariant value = XMLRPC::demarshall(param.firstChildElement("value"), errors);
+ const QVariant value = QXmppRpcMarshaller::demarshall(param.firstChildElement("value"), errors);
if (!errors.isEmpty())
break;
m_values << value;
@@ -308,7 +308,7 @@ void QXmppRpcResponseIq::parseElementFromChild(const QDomElement &element)
{
QStringList errors;
const QDomElement errElement = contents.firstChildElement("value");
- const QVariant error = XMLRPC::demarshall(errElement, errors);
+ const QVariant error = QXmppRpcMarshaller::demarshall(errElement, errors);
if (!errors.isEmpty())
return;
m_faultCode = error.toMap()["faultCode"].toInt();
@@ -328,7 +328,7 @@ void QXmppRpcResponseIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
QMap<QString,QVariant> fault;
fault["faultCode"] = m_faultCode;
fault["faultString"] = m_faultString;
- XMLRPC::marshall(writer, fault);
+ QXmppRpcMarshaller::marshall(writer, fault);
writer->writeEndElement();
}
else if (!m_values.isEmpty())
@@ -337,7 +337,7 @@ void QXmppRpcResponseIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
foreach (const QVariant &arg, m_values)
{
writer->writeStartElement("param");
- XMLRPC::marshall(writer, arg);
+ QXmppRpcMarshaller::marshall(writer, arg);
writer->writeEndElement();
}
writer->writeEndElement();
@@ -409,7 +409,7 @@ void QXmppRpcInvokeIq::parseElementFromChild(const QDomElement &element)
while (!param.isNull())
{
QStringList errors;
- QVariant arg = XMLRPC::demarshall(param.firstChildElement("value"), errors);
+ QVariant arg = QXmppRpcMarshaller::demarshall(param.firstChildElement("value"), errors);
if (!errors.isEmpty())
break;
m_arguments << arg;
@@ -431,7 +431,7 @@ void QXmppRpcInvokeIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
foreach(const QVariant &arg, m_arguments)
{
writer->writeStartElement("param");
- XMLRPC::marshall(writer, arg);
+ QXmppRpcMarshaller::marshall(writer, arg);
writer->writeEndElement();
}
writer->writeEndElement();
diff --git a/src/base/QXmppRpcIq.h b/src/base/QXmppRpcIq.h
index dda79a34..3b9e4792 100644
--- a/src/base/QXmppRpcIq.h
+++ b/src/base/QXmppRpcIq.h
@@ -31,11 +31,12 @@
class QXmlStreamWriter;
class QDomElement;
-namespace XMLRPC
+class QXMPP_EXPORT QXmppRpcMarshaller
{
- void marshall( QXmlStreamWriter *writer, const QVariant &value);
- QVariant demarshall(const QDomElement &elem, QStringList &errors);
-}
+public:
+ static void marshall( QXmlStreamWriter *writer, const QVariant &value);
+ static QVariant demarshall(const QDomElement &elem, QStringList &errors);
+};
/// \brief The QXmppRpcResponseIq class represents an IQ used to carry
/// an RPC response as specified by XEP-0009: Jabber-RPC.
diff --git a/tests/tests.cpp b/tests/tests.cpp
index 5cfdf372..d68d2a39 100644
--- a/tests/tests.cpp
+++ b/tests/tests.cpp
@@ -1346,7 +1346,7 @@ static void checkVariant(const QVariant &value, const QByteArray &xml)
QBuffer buffer;
buffer.open(QIODevice::ReadWrite);
QXmlStreamWriter writer(&buffer);
- XMLRPC::marshall(&writer, value);
+ QXmppRpcMarshaller::marshall(&writer, value);
qDebug() << "expect " << xml;
qDebug() << "writing" << buffer.data();
QCOMPARE(buffer.data(), xml);
@@ -1356,7 +1356,7 @@ static void checkVariant(const QVariant &value, const QByteArray &xml)
QCOMPARE(doc.setContent(xml, true), true);
QDomElement element = doc.documentElement();
QStringList errors;
- QVariant test = XMLRPC::demarshall(element, errors);
+ QVariant test = QXmppRpcMarshaller::demarshall(element, errors);
if (!errors.isEmpty())
qDebug() << errors;
QCOMPARE(errors, QStringList());