QXmlRPC  1.1
Signals | Public Member Functions | Protected Slots | List of all members
xmlrpc::Client Class Reference

The xmlrpc::Client class provides an implementation of the XML-RPC client. More...

#include <client.h>

Inheritance diagram for xmlrpc::Client:

Signals

void done (int requestId, QVariant res)
 request requestId is done with return value res
 
void failed (int requestId, int faultCode, QString faultString)
 request requestId is failed with fault code faultCode and fault description faultString
 
void authenticationRequired (const QString &hostname, quint16 port, QAuthenticator *)
 authenticationRequired signal passed from QHttp
 
void proxyAuthenticationRequired (const QNetworkProxy &, QAuthenticator *)
 proxyAuthenticationRequired signal passed from QHttp
 

Public Member Functions

 Client (QObject *parent=0)
 
 Client (const QString &hostname, quint16 port=80, QObject *parent=0L)
 
void setHost (const QString &hostname, quint16 port=80, QString path="/")
 
void setProxy (const QString &host, int port, const QString &username=QString(), const QString &password=QString())
 
void setSocket (QTcpSocket *socket)
 
void setUser (const QString &userName, const QString &password=QString())
 
void setUserAgent (const QString &userAgent)
 
virtual ~Client ()
 
int request (QList< Variant > params, QString methodName)
 
int request (QString methodName)
 
int request (QString methodName, Variant param1)
 
int request (QString methodName, Variant param1, Variant param2)
 
int request (QString methodName, Variant param1, Variant param2, Variant param3)
 
int request (QString methodName, Variant param1, Variant param2, Variant param3, Variant param4)
 

Protected Slots

void requestFinished (int id, bool error)
 

Detailed Description

The xmlrpc::Client class provides an implementation of the XML-RPC client.

The class works asynchronously, so there are no blocking functions.

Each XML-RPC request has unique identifier, which is returned by xmlrpc::Client::request() and is emited with done() and failed() signals.

client = new xmlrpc::Client(this);
connect( client, SIGNAL(done( int, QVariant )),
this, SLOT(processReturnValue( int, QVariant )) );
connect( client, SIGNAL(failed( int, int, QString )),
this, SLOT(processFault( int, int, QString )) );
client->setHost( "localhost", 7777 );
int requestId = client->request( "sum", x, y )

After the request is finished, done() or failed() signal will be emited with the request id and return value or fault information.

Constructor & Destructor Documentation

xmlrpc::Client::Client ( QObject *  parent = 0)

Constructs a XmlRPC client.

References authenticationRequired(), and proxyAuthenticationRequired().

xmlrpc::Client::Client ( const QString &  hostName,
quint16  port = 80,
QObject *  parent = 0L 
)

Constructs a XmlRPC client for communication with XmlRPC server running on host hostName port.

References setHost().

xmlrpc::Client::~Client ( )
virtual

Destroys the XmlRPC client.

Member Function Documentation

int xmlrpc::Client::request ( QList< Variant params,
QString  methodName 
)

Call method methodName on server side with parameters list params. Returns id of request, used in done() and failed() signals.

The parameters order is changed in overloaded methods to avoid situation when the only parameter is the list.

QList<xmlrpc::Variant> parameter;
...
int requestId = client->request( methodName, parameter );

This leads to this method be called, with parameter treated as parameters list. It's possible to fix this with next code:

client->request( methodName, xmlrpc::Variant(parameter) );

but to avoid such kind of bugs, the parameters order in overloaded methods was changed.

References xmlrpc::Request::composeRequest(), and xmlrpc::Variant::pprint().

Referenced by request().

int xmlrpc::Client::request ( QString  methodName)

Call method methodName on server side with empty parameters list. This is an overloaded member function, provided for convenience.

References request().

int xmlrpc::Client::request ( QString  methodName,
Variant  param1 
)

Call method methodName on server side with one parameter. This is an overloaded member function, provided for convenience.

References request().

int xmlrpc::Client::request ( QString  methodName,
Variant  param1,
Variant  param2 
)

Call method methodName on server side with two parameters. This is an overloaded member function, provided for convenience.

References request().

int xmlrpc::Client::request ( QString  methodName,
Variant  param1,
Variant  param2,
Variant  param3 
)

Call method methodName on server side with three parameters. This is an overloaded member function, provided for convenience.

References request().

int xmlrpc::Client::request ( QString  methodName,
Variant  param1,
Variant  param2,
Variant  param3,
Variant  param4 
)

Call method methodName on server side with four parameters. This is an overloaded member function, provided for convenience.

References request().

void xmlrpc::Client::setHost ( const QString &  hostName,
quint16  port = 80,
QString  path = "/" 
)

Sets the XML-RPC server that is used for requests to hostName on port port and path .

Referenced by Client().

void xmlrpc::Client::setProxy ( const QString &  host,
int  port,
const QString &  userName = QString(),
const QString &  password = QString() 
)

Enables HTTP proxy support, using the proxy server host on port port. username and password can be provided if the proxy server requires authentication.

void xmlrpc::Client::setSocket ( QTcpSocket *  socket)

Replaces the internal QTcpSocket that QHttp uses with socket. This can be useful for adding https support with QtSslSocket.

Check {http://trolltech.com/products/qt/addon/solutions/catalog/4/Utilities/qtsslsocket/} and QHttp::setSocket() for more information.

void xmlrpc::Client::setUser ( const QString &  userName,
const QString &  password = QString() 
)

Set the user name userName and password password for XML-RPC ( or http ) server that require authentication.

void xmlrpc::Client::setUserAgent ( const QString &  userAgent)

Set the user agent HTTP value instead of default "QXMLRPC"


The documentation for this class was generated from the following files: