diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
commit | 47c8a359c5276062c4bc17f0e82410f29081b502 (patch) | |
tree | 2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /dcoprss/xmlrpciface.cpp | |
parent | 6f82532777a35e0e60bbd2b290b2e93e646f349b (diff) | |
download | tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'dcoprss/xmlrpciface.cpp')
-rw-r--r-- | dcoprss/xmlrpciface.cpp | 202 |
1 files changed, 101 insertions, 101 deletions
diff --git a/dcoprss/xmlrpciface.cpp b/dcoprss/xmlrpciface.cpp index e86639eb..64259bbb 100644 --- a/dcoprss/xmlrpciface.cpp +++ b/dcoprss/xmlrpciface.cpp @@ -29,46 +29,46 @@ #include <klocale.h> #include <kmdcodec.h> -#include <qdom.h> +#include <tqdom.h> using namespace KXMLRPC; -Query *Query::create( QObject *parent, const char *name ) +Query *Query::create( TQObject *parent, const char *name ) { return new Query( parent, name ); } -void Query::call( const QString &server, const QString &method, - const QValueList<QVariant> &args, const QString &userAgent ) +void Query::call( const TQString &server, const TQString &method, + const TQValueList<TQVariant> &args, const TQString &userAgent ) { m_buffer.open( IO_ReadWrite ); m_server = server; m_method = method; m_args = args; - const QString xmlMarkup = markupCall( method, args ); + const TQString xmlMarkup = markupCall( method, args ); - QByteArray postData; - QDataStream stream( postData, IO_WriteOnly ); + TQByteArray postData; + TQDataStream stream( postData, IO_WriteOnly ); stream.writeRawBytes( xmlMarkup.utf8(), xmlMarkup.length() ); KIO::TransferJob *job = KIO::http_post( KURL( server ), postData, false ); job->addMetaData( "UserAgent", userAgent ); job->addMetaData( "content-type", "Content-Type: text/xml; charset=utf-8" ); - connect( job, SIGNAL( infoMessage( KIO::Job *, const QString & ) ), - this, SLOT( slotInfoMessage( KIO::Job *, const QString & ) ) ); - connect( job, SIGNAL( data( KIO::Job *, const QByteArray & ) ), - this, SLOT( slotData( KIO::Job *, const QByteArray & ) ) ); - connect( job, SIGNAL( result( KIO::Job * ) ), - this, SLOT( slotResult( KIO::Job * ) ) ); + connect( job, TQT_SIGNAL( infoMessage( KIO::Job *, const TQString & ) ), + this, TQT_SLOT( slotInfoMessage( KIO::Job *, const TQString & ) ) ); + connect( job, TQT_SIGNAL( data( KIO::Job *, const TQByteArray & ) ), + this, TQT_SLOT( slotData( KIO::Job *, const TQByteArray & ) ) ); + connect( job, TQT_SIGNAL( result( KIO::Job * ) ), + this, TQT_SLOT( slotResult( KIO::Job * ) ) ); } -void Query::slotInfoMessage( KIO::Job *, const QString &msg ) +void Query::slotInfoMessage( KIO::Job *, const TQString &msg ) { emit infoMessage( msg ); } -void Query::slotData( KIO::Job *, const QByteArray &data ) +void Query::slotData( KIO::Job *, const TQByteArray &data ) { m_buffer.writeBlock( data ); } @@ -90,7 +90,7 @@ void Query::slotResult( KIO::Job *job ) return; } - QDomDocument doc; + TQDomDocument doc; if ( !doc.setContent( m_buffer.buffer() ) ) { response.m_errorCode = -1; response.m_errorString = i18n( "Received invalid XML markup" ); @@ -119,17 +119,17 @@ void Query::slotResult( KIO::Job *job ) delete this; } -bool Query::isMessageResponse( const QDomDocument &doc ) const +bool Query::isMessageResponse( const TQDomDocument &doc ) const { return doc.documentElement().firstChild().toElement().tagName().lower() == "params"; } -Query::Result Query::parseMessageResponse( const QDomDocument &doc ) const +Query::Result Query::parseMessageResponse( const TQDomDocument &doc ) const { Result response; response.m_success = true; - QDomNode paramNode = doc.documentElement().firstChild().firstChild(); + TQDomNode paramNode = doc.documentElement().firstChild().firstChild(); while ( !paramNode.isNull() ) { response.m_data << demarshal( paramNode.firstChild().toElement() ); paramNode = paramNode.nextSibling(); @@ -138,35 +138,35 @@ Query::Result Query::parseMessageResponse( const QDomDocument &doc ) const return response; } -bool Query::isFaultResponse( const QDomDocument &doc ) const +bool Query::isFaultResponse( const TQDomDocument &doc ) const { return doc.documentElement().firstChild().toElement().tagName().lower() == "fault"; } -Query::Result Query::parseFaultResponse( const QDomDocument &doc ) const +Query::Result Query::parseFaultResponse( const TQDomDocument &doc ) const { Result response; response.m_success = false; - QDomNode errorNode = doc.documentElement().firstChild().firstChild(); - const QVariant errorVariant = demarshal( errorNode.toElement() ); + TQDomNode errorNode = doc.documentElement().firstChild().firstChild(); + const TQVariant errorVariant = demarshal( errorNode.toElement() ); response.m_errorCode = errorVariant.toMap()[ "faultCode" ].toInt(); response.m_errorString = errorVariant.toMap()[ "faultString" ].toString(); return response; } -QString Query::markupCall( const QString &cmd, - const QValueList<QVariant> &args ) const +TQString Query::markupCall( const TQString &cmd, + const TQValueList<TQVariant> &args ) const { - QString markup = "<?xml version='1.0' ?><methodCall>"; + TQString markup = "<?xml version='1.0' ?><methodCall>"; markup += "<methodName>" + cmd + "</methodName>"; if ( !args.isEmpty() ) { markup += "<params>"; - QValueList<QVariant>::ConstIterator it = args.begin(); - QValueList<QVariant>::ConstIterator end = args.end(); + TQValueList<TQVariant>::ConstIterator it = args.begin(); + TQValueList<TQVariant>::ConstIterator end = args.end(); for ( ; it != end; ++it ) markup += "<param>" + marshal( *it ) + "</param>"; markup += "</params>"; @@ -177,46 +177,46 @@ QString Query::markupCall( const QString &cmd, return markup; } -QString Query::marshal( const QVariant &arg ) +TQString Query::marshal( const TQVariant &arg ) { - QString s = "<value>"; + TQString s = "<value>"; switch ( arg.type() ) { - case QVariant::String: - case QVariant::CString: + case TQVariant::String: + case TQVariant::CString: s += "<string>" + arg.toString() + "</string>"; break; - case QVariant::Int: - s += "<int>" + QString::number( arg.toInt() ) + "</int>"; + case TQVariant::Int: + s += "<int>" + TQString::number( arg.toInt() ) + "</int>"; break; - case QVariant::Double: - s += "<double>" + QString::number( arg.toDouble() ) + "</double>"; + case TQVariant::Double: + s += "<double>" + TQString::number( arg.toDouble() ) + "</double>"; break; - case QVariant::Bool: + case TQVariant::Bool: s += "<boolean>"; s += arg.toBool() ? "true" : "false"; s += "</boolean>"; break; - case QVariant::ByteArray: + case TQVariant::ByteArray: s += "<base64>" + KCodecs::base64Encode( arg.toByteArray() ) + "</base64>"; break; - case QVariant::DateTime: + case TQVariant::DateTime: s += "<datetime.iso8601>" + arg.toDateTime().toString( Qt::ISODate ) + "</datetime.iso8601>"; break; - case QVariant::List: { + case TQVariant::List: { s += "<array><data>"; - const QValueList<QVariant> args = arg.toList(); - QValueList<QVariant>::ConstIterator it = args.begin(); - QValueList<QVariant>::ConstIterator end = args.end(); + const TQValueList<TQVariant> args = arg.toList(); + TQValueList<TQVariant>::ConstIterator it = args.begin(); + TQValueList<TQVariant>::ConstIterator end = args.end(); for ( ; it != end; ++it ) s += marshal( *it ); s += "</data></array>"; break; } - case QVariant::Map: { + case TQVariant::Map: { s += "<struct>"; - QMap<QString, QVariant> map = arg.toMap(); - QMap<QString, QVariant>::ConstIterator it = map.begin(); - QMap<QString, QVariant>::ConstIterator end = map.end(); + TQMap<TQString, TQVariant> map = arg.toMap(); + TQMap<TQString, TQVariant>::ConstIterator it = map.begin(); + TQMap<TQString, TQVariant>::ConstIterator end = map.end(); for ( ; it != end; ++it ) { s += "<member>"; s += "<name>" + it.key() + "</name>"; @@ -233,127 +233,127 @@ QString Query::marshal( const QVariant &arg ) return s + "</value>"; } -QVariant Query::demarshal( const QDomElement &elem ) +TQVariant Query::demarshal( const TQDomElement &elem ) { Q_ASSERT( elem.tagName().lower() == "value" ); if ( !elem.firstChild().isElement() ) - return QVariant( elem.text() ); + return TQVariant( elem.text() ); - const QDomElement typeElement = elem.firstChild().toElement(); - const QString typeName = typeElement.tagName().lower(); + const TQDomElement typeElement = elem.firstChild().toElement(); + const TQString typeName = typeElement.tagName().lower(); if ( typeName == "string" ) - return QVariant( typeElement.text() ); + return TQVariant( typeElement.text() ); else if ( typeName == "i4" || typeName == "int" ) - return QVariant( typeElement.text().toInt() ); + return TQVariant( typeElement.text().toInt() ); else if ( typeName == "double" ) - return QVariant( typeElement.text().toDouble() ); + return TQVariant( typeElement.text().toDouble() ); else if ( typeName == "boolean" ) { if ( typeElement.text().lower() == "true" || typeElement.text() == "1" ) - return QVariant( true ); + return TQVariant( true ); else - return QVariant( false ); + return TQVariant( false ); } else if ( typeName == "base64" ) - return QVariant( KCodecs::base64Decode( typeElement.text().latin1() ) ); + return TQVariant( KCodecs::base64Decode( typeElement.text().latin1() ) ); else if ( typeName == "datetime" || typeName == "datetime.iso8601" ) - return QVariant( QDateTime::fromString( typeElement.text(), Qt::ISODate ) ); + return TQVariant( TQDateTime::fromString( typeElement.text(), Qt::ISODate ) ); else if ( typeName == "array" ) { - QValueList<QVariant> values; - QDomNode valueNode = typeElement.firstChild().firstChild(); + TQValueList<TQVariant> values; + TQDomNode valueNode = typeElement.firstChild().firstChild(); while ( !valueNode.isNull() ) { values << demarshal( valueNode.toElement() ); valueNode = valueNode.nextSibling(); } - return QVariant( values ); + return TQVariant( values ); } else if ( typeName == "struct" ) { - QMap<QString, QVariant> map; - QDomNode memberNode = typeElement.firstChild(); + TQMap<TQString, TQVariant> map; + TQDomNode memberNode = typeElement.firstChild(); while ( !memberNode.isNull() ) { - const QString key = memberNode.toElement().elementsByTagName( "name" ).item( 0 ).toElement().text(); - const QVariant data = demarshal( memberNode.toElement().elementsByTagName( "value" ).item( 0 ).toElement() ); + const TQString key = memberNode.toElement().elementsByTagName( "name" ).item( 0 ).toElement().text(); + const TQVariant data = demarshal( memberNode.toElement().elementsByTagName( "value" ).item( 0 ).toElement() ); map[ key ] = data; memberNode = memberNode.nextSibling(); } - return QVariant( map ); + return TQVariant( map ); } else kdWarning() << "Cannot demarshal unknown type " << typeName << endl; - return QVariant(); + return TQVariant(); } -Query::Query( QObject *parent, const char *name ) : QObject( parent, name ) +Query::Query( TQObject *parent, const char *name ) : TQObject( parent, name ) { } -QValueList<QVariant> Server::toVariantList( const QVariant &arg ) +TQValueList<TQVariant> Server::toVariantList( const TQVariant &arg ) { - QValueList<QVariant> args; + TQValueList<TQVariant> args; args << arg ; return args; } -QValueList<QVariant> Server::toVariantList( int arg ) +TQValueList<TQVariant> Server::toVariantList( int arg ) { - QValueList<QVariant> args; + TQValueList<TQVariant> args; args << arg ; return args; } -QValueList<QVariant> Server::toVariantList( bool arg ) +TQValueList<TQVariant> Server::toVariantList( bool arg ) { - QValueList<QVariant> args; + TQValueList<TQVariant> args; args << arg ; return args; } -QValueList<QVariant> Server::toVariantList( double arg ) +TQValueList<TQVariant> Server::toVariantList( double arg ) { - QValueList<QVariant> args; + TQValueList<TQVariant> args; args << arg ; return args; } -QValueList<QVariant> Server::toVariantList( const QString &arg ) +TQValueList<TQVariant> Server::toVariantList( const TQString &arg ) { - QValueList<QVariant> args; + TQValueList<TQVariant> args; args << arg ; return args; } -QValueList<QVariant> Server::toVariantList( const QCString &arg ) +TQValueList<TQVariant> Server::toVariantList( const TQCString &arg ) { - QValueList<QVariant> args; + TQValueList<TQVariant> args; args << arg ; return args; } -QValueList<QVariant> Server::toVariantList( const QByteArray &arg ) +TQValueList<TQVariant> Server::toVariantList( const TQByteArray &arg ) { - QValueList<QVariant> args; + TQValueList<TQVariant> args; args << arg ; return args; } -QValueList<QVariant> Server::toVariantList( const QDateTime &arg ) +TQValueList<TQVariant> Server::toVariantList( const TQDateTime &arg ) { - QValueList<QVariant> args; + TQValueList<TQVariant> args; args << arg ; return args; } -QValueList<QVariant> Server::toVariantList( const QStringList &arg ) +TQValueList<TQVariant> Server::toVariantList( const TQStringList &arg ) { - QValueList<QVariant> args; - QStringList::ConstIterator it = arg.begin(); - QStringList::ConstIterator end = arg.end(); + TQValueList<TQVariant> args; + TQStringList::ConstIterator it = arg.begin(); + TQStringList::ConstIterator end = arg.end(); for ( ; it != end; ++it ) - args << QVariant( *it ); + args << TQVariant( *it ); return args; } -Server::Server( const KURL &url, QObject *parent, const char *name ) - : QObject( parent, name ) +Server::Server( const KURL &url, TQObject *parent, const char *name ) + : TQObject( parent, name ) { if ( url.isValid() ) m_url = url; @@ -364,8 +364,8 @@ void Server::setUrl( const KURL &url ) m_url = url.isValid() ? url : KURL(); } -void Server::call( const QString &method, const QValueList<QVariant> &args, - QObject *receiver, const char *slot ) +void Server::call( const TQString &method, const TQValueList<TQVariant> &args, + TQObject *receiver, const char *slot ) { if ( m_url.isEmpty() ) { kdWarning() << "Cannot execute call to " << method << ": empty server URL" << endl; @@ -373,16 +373,16 @@ void Server::call( const QString &method, const QValueList<QVariant> &args, } Query *query = Query::create( this ); - connect( query, SIGNAL( infoMessage( const QString & ) ), - this, SIGNAL( infoMessage( const QString & ) ) ); - connect( query, SIGNAL( finished( const KXMLRPC::Query::Result & ) ), + connect( query, TQT_SIGNAL( infoMessage( const TQString & ) ), + this, TQT_SIGNAL( infoMessage( const TQString & ) ) ); + connect( query, TQT_SIGNAL( finished( const KXMLRPC::Query::Result & ) ), receiver, slot ); query->call( m_url.url(), method, args, m_userAgent ); } -void Server::call( const QString &method, const QValueList<QVariant> &args, - QObject *receiver, const char *slot, - QObject *infoObject, const char *infoSlot ) +void Server::call( const TQString &method, const TQValueList<TQVariant> &args, + TQObject *receiver, const char *slot, + TQObject *infoObject, const char *infoSlot ) { if ( m_url.isEmpty() ) { kdWarning() << "Cannot execute call to " << method << ": empty server URL" << endl; @@ -390,9 +390,9 @@ void Server::call( const QString &method, const QValueList<QVariant> &args, } Query *query = Query::create( this ); - connect( query, SIGNAL( infoMessage( const QString &msg ) ), + connect( query, TQT_SIGNAL( infoMessage( const TQString &msg ) ), infoObject, infoSlot ); - connect( query, SIGNAL( finished( const KXMLRPC::Query::Result & ) ), + connect( query, TQT_SIGNAL( finished( const KXMLRPC::Query::Result & ) ), receiver, slot ); query->call( m_url.url(), method, args, m_userAgent ); } |