You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
168 lines
5.7 KiB
168 lines
5.7 KiB
15 years ago
|
/**************************************************************************
|
||
|
* Copyright (C) 2003 - 2004 by Frerich Raabe <raabe@kde.org> *
|
||
|
* Tobias Koenig <tokoe@kde.org> *
|
||
|
* *
|
||
|
* This program is free software; you can redistribute it and/or modify *
|
||
|
* it under the terms of the GNU General Public License as published by *
|
||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||
|
* (at your option) any later version. *
|
||
|
***************************************************************************/
|
||
|
#ifndef KXMLRPCIFACE_H
|
||
|
#define KXMLRPCIFACE_H
|
||
|
|
||
|
#include <kurl.h>
|
||
|
|
||
15 years ago
|
#include <tqbuffer.h>
|
||
|
#include <tqdom.h>
|
||
|
#include <tqobject.h>
|
||
|
#include <tqvariant.h>
|
||
|
#include <tqvaluelist.h>
|
||
15 years ago
|
|
||
12 years ago
|
namespace TDEIO
|
||
15 years ago
|
{
|
||
|
class Job;
|
||
|
}
|
||
|
|
||
|
namespace KXMLRPC
|
||
|
{
|
||
|
class Query;
|
||
|
class QueryResult;
|
||
|
class Server;
|
||
|
class Result;
|
||
|
|
||
14 years ago
|
class Query : public TQObject
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
public:
|
||
|
|
||
|
|
||
15 years ago
|
static Query *create( const TQVariant &id = TQVariant(),
|
||
13 years ago
|
TQObject *parent = 0, const char *name = 0 );
|
||
15 years ago
|
|
||
|
public slots:
|
||
15 years ago
|
void call( const TQString &server, const TQString &method,
|
||
|
const TQValueList<TQVariant> &args = TQValueList<TQVariant>(),
|
||
|
const TQString &userAgent = "KDE-XMLRPC" );
|
||
15 years ago
|
|
||
|
signals:
|
||
15 years ago
|
void message( const TQValueList<TQVariant> &result, const TQVariant &id );
|
||
|
void fault( int, const TQString&, const TQVariant &id );
|
||
15 years ago
|
void finished( Query* );
|
||
|
|
||
|
private slots:
|
||
12 years ago
|
void slotData( TDEIO::Job *job, const TQByteArray &data );
|
||
|
void slotResult( TDEIO::Job *job );
|
||
15 years ago
|
|
||
|
private:
|
||
15 years ago
|
bool isMessageResponse( const TQDomDocument &doc ) const;
|
||
|
bool isFaultResponse( const TQDomDocument &doc ) const;
|
||
15 years ago
|
|
||
15 years ago
|
Result parseMessageResponse( const TQDomDocument &doc ) const;
|
||
|
Result parseFaultResponse( const TQDomDocument &doc ) const;
|
||
15 years ago
|
|
||
15 years ago
|
TQString markupCall( const TQString &method,
|
||
|
const TQValueList<TQVariant> &args ) const;
|
||
|
TQString marshal( const TQVariant &v ) const;
|
||
|
TQVariant demarshal( const TQDomElement &e ) const;
|
||
15 years ago
|
|
||
13 years ago
|
Query( const TQVariant &id, TQObject *parent = 0, const char *name = 0 );
|
||
15 years ago
|
~Query();
|
||
|
|
||
15 years ago
|
TQByteArray m_buffer;
|
||
|
TQVariant m_id;
|
||
15 years ago
|
|
||
12 years ago
|
TQValueList<TDEIO::Job*> m_pendingJobs;
|
||
15 years ago
|
};
|
||
|
|
||
14 years ago
|
class Server : public TQObject
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
public:
|
||
|
Server( const KURL &url = KURL(),
|
||
13 years ago
|
TQObject *parent = 0, const char *name = 0 );
|
||
15 years ago
|
~Server();
|
||
|
|
||
|
const KURL &url() const { return m_url; }
|
||
|
void setUrl( const KURL &url );
|
||
|
|
||
15 years ago
|
TQString userAgent() const { return m_userAgent; }
|
||
|
void setUserAgent( const TQString &userAgent ) { m_userAgent = userAgent; }
|
||
15 years ago
|
|
||
|
template <typename T>
|
||
15 years ago
|
void call( const TQString &method, const TQValueList<T> &arg,
|
||
|
TQObject* obj1, const char* faultSlot,
|
||
|
TQObject* obj2, const char* messageSlot, const TQVariant &id = TQVariant() );
|
||
15 years ago
|
|
||
|
|
||
|
public slots:
|
||
15 years ago
|
void call( const TQString &method, const TQValueList<TQVariant> &args,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot,
|
||
|
const TQVariant &id = TQVariant() );
|
||
|
void call( const TQString &method, const TQVariant &arg,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot,
|
||
|
const TQVariant &id = TQVariant() );
|
||
|
void call( const TQString &method, int arg ,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot,
|
||
|
const TQVariant &id = TQVariant() );
|
||
|
void call( const TQString &method, bool arg,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot,
|
||
|
const TQVariant &id = TQVariant() );
|
||
|
void call( const TQString &method, double arg,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot,
|
||
|
const TQVariant &id = TQVariant() );
|
||
|
void call( const TQString &method, const TQString &arg,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot,
|
||
|
const TQVariant &id = TQVariant() );
|
||
|
void call( const TQString &method, const TQCString &arg ,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot,
|
||
|
const TQVariant &id = TQVariant() );
|
||
|
void call( const TQString &method, const TQByteArray &arg,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot,
|
||
|
const TQVariant &id = TQVariant() );
|
||
|
void call( const TQString &method, const TQDateTime &arg,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot,
|
||
|
const TQVariant &id = TQVariant() );
|
||
|
void call( const TQString &method, const TQStringList &arg,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot,
|
||
|
const TQVariant &id = TQVariant() );
|
||
15 years ago
|
|
||
|
private slots:
|
||
|
void queryFinished( Query* );
|
||
|
|
||
|
private:
|
||
|
KURL m_url;
|
||
15 years ago
|
TQString m_userAgent;
|
||
15 years ago
|
|
||
15 years ago
|
TQValueList<Query*> mPendingQueries;
|
||
15 years ago
|
};
|
||
|
}
|
||
|
|
||
|
template <typename T>
|
||
15 years ago
|
void KXMLRPC::Server::call( const TQString &method, const TQValueList<T> &arg,
|
||
|
TQObject* faultObj, const char* faultSlot,
|
||
|
TQObject* msgObj, const char* messageSlot, const TQVariant &id )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQValueList<TQVariant> args;
|
||
15 years ago
|
|
||
15 years ago
|
typename TQValueList<T>::ConstIterator it = arg.begin();
|
||
|
typename TQValueList<T>::ConstIterator end = arg.end();
|
||
15 years ago
|
for ( ; it != end; ++it )
|
||
15 years ago
|
args << TQVariant( *it );
|
||
15 years ago
|
|
||
|
return call( method, args, faultObj, faultSlot, msgObj, messageSlot, id );
|
||
|
}
|
||
|
|
||
|
#endif
|