From 195afc0e0159c8ed89c4b374a9d9ba6aacfddc6b Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Mon, 9 Aug 2010 14:36:32 +0000 Subject: rework internal XML RPC APIs --- source/xmlrpc.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'source/xmlrpc.h') diff --git a/source/xmlrpc.h b/source/xmlrpc.h index d27ec491..f9b179df 100644 --- a/source/xmlrpc.h +++ b/source/xmlrpc.h @@ -1,5 +1,5 @@ -#ifndef PACKET_H -#define PACKET_H +#ifndef QXMPPXMLRPC_H +#define QXMPPXMLRPC_H #include #include @@ -19,15 +19,19 @@ * @code * QList args; * args << m_db << m_username << m_password << dbQuery; -* RequestMessage msg( "data.query", args ); -* ResponseMessage resp( SomeHttpDispatchObject( msg.xml() ) ); -* if( resp.isValid() ) +* RequestMessage msg; +* msg.setMethod("data.query"); +* msg.setArguments(args); +* +* ResponseMessage resp; +* if (resp.parse(someDomElement)) * { * int rows = resp.values().first().toMap()["widgets"].toInt(); * } * else * qWarning("Error: %s", resp.error().latin1() ); * @endcode +* * This example will construct invoke the data.query() method on the XMLRPC * interface with the args. It will then check for the response to see if * it was valid. If its valid the message contains a struct of values, one of @@ -49,11 +53,6 @@ namespace XMLRPC class RequestMessage { public: - /** - * Creates a method packet that will call method with a list of args. - */ - RequestMessage(const QByteArray &method = QByteArray(), const QVariantList &args = QVariantList()); - /** * Parse an xml packet. */ @@ -65,7 +64,10 @@ public: void writeXml( QXmlStreamWriter *writer ) const; QByteArray method() const; - QVariantList args() const; + void setMethod(const QByteArray &method); + + QVariantList arguments() const; + void setArguments(const QVariantList &args); private: QByteArray m_method; @@ -79,11 +81,6 @@ private: class ResponseMessage { public: - /** - * Create a new response message with data. - */ - ResponseMessage(const QVariantList &values = QVariantList()); - /** * Parse an xml packet. */ @@ -95,6 +92,7 @@ public: void writeXml( QXmlStreamWriter *writer ) const; QVariantList values() const; + void setValues(const QVariantList &values); private: QList m_values; -- cgit v1.2.3