summaryrefslogtreecommitdiffstats
path: root/kresources/blogging/xmlrpcjob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kresources/blogging/xmlrpcjob.cpp')
-rw-r--r--kresources/blogging/xmlrpcjob.cpp192
1 files changed, 96 insertions, 96 deletions
diff --git a/kresources/blogging/xmlrpcjob.cpp b/kresources/blogging/xmlrpcjob.cpp
index 76bee44f8..d99e8add8 100644
--- a/kresources/blogging/xmlrpcjob.cpp
+++ b/kresources/blogging/xmlrpcjob.cpp
@@ -26,8 +26,8 @@
#include "xmlrpcjob.h"
-#include <qvariant.h>
-#include <qregexp.h>
+#include <tqvariant.h>
+#include <tqregexp.h>
#include <kdebug.h>
#include <klocale.h>
@@ -36,8 +36,8 @@
#include <kio/davjob.h>
-#define KIO_ARGS QByteArray packedArgs; \
- QDataStream stream( packedArgs, IO_WriteOnly ); stream
+#define KIO_ARGS TQByteArray packedArgs; \
+ TQDataStream stream( packedArgs, IO_WriteOnly ); stream
using namespace KIO;
@@ -49,32 +49,32 @@ namespace KIO {
XMLRPCResult() {}
bool success() const { return m_success; }
int errorCode() const { return m_errorCode; }
- QString errorString() const { return m_errorString; }
- QValueList<QVariant> data() const { return m_data; }
+ TQString errorString() const { return m_errorString; }
+ TQValueList<TQVariant> data() const { return m_data; }
private:
bool m_success;
int m_errorCode;
- QString m_errorString;
- QValueList<QVariant> m_data;
+ TQString m_errorString;
+ TQValueList<TQVariant> m_data;
};
}
class XmlrpcJob::XmlrpcJobPrivate
{
public:
-// QByteArray savedStaticData;
+// TQByteArray savedStaticData;
};
-XmlrpcJob::XmlrpcJob( const KURL& url, const QString& method,
- const QValueList<QVariant> &params, bool showProgressInfo)
- : TransferJob( url, KIO::CMD_SPECIAL, QByteArray(), QByteArray(),
+XmlrpcJob::XmlrpcJob( const KURL& url, const TQString& method,
+ const TQValueList<TQVariant> &params, bool showProgressInfo)
+ : TransferJob( url, KIO::CMD_SPECIAL, TQByteArray(), TQByteArray(),
showProgressInfo )
{
d = new XmlrpcJobPrivate;
// We couldn't set the args when calling the parent constructor,
// so do it now.
- QDataStream stream( m_packedArgs, IO_WriteOnly );
+ TQDataStream stream( m_packedArgs, IO_WriteOnly );
stream << (int)1 << url;
kdDebug()<<"XMLrpcJob::url="<<url.url()<<endl;
kdDebug()<<"XmlrpcJob::XmlrpcJob, method="<<method<<endl;
@@ -82,7 +82,7 @@ kdDebug()<<"XmlrpcJob::XmlrpcJob, method="<<method<<endl;
if ( ! method.isEmpty() ) {
kdDebug()<<"XmlrpcJob::XmlrpcJob, method not empty."<<endl;
- QString call = markupCall( method, params );
+ TQString call = markupCall( method, params );
staticData = call.utf8();
staticData.truncate( staticData.size() - 1 );
kdDebug() << "Message: " << call << endl;
@@ -99,19 +99,19 @@ XmlrpcJob::~XmlrpcJob()
d = 0;
}
-QString XmlrpcJob::markupCall( const QString &cmd,
- const QValueList<QVariant> &args )
+TQString XmlrpcJob::markupCall( const TQString &cmd,
+ const TQValueList<TQVariant> &args )
{
kdDebug()<<"XmlrpcJob::markupCall, cmd="<<cmd<<endl;
- QString markup = "<?xml version=\"1.0\" ?>\r\n<methodCall>\r\n";
+ TQString markup = "<?xml version=\"1.0\" ?>\r\n<methodCall>\r\n";
markup += "<methodName>" + cmd + "</methodName>\r\n";
if ( !args.isEmpty() )
{
markup += "<params>\r\n";
- 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>\r\n" + marshal( *it ) + "</param>\r\n";
markup += "</params>\r\n";
@@ -126,11 +126,11 @@ kdDebug()<<"XmlrpcJob::markupCall, cmd="<<cmd<<endl;
-void XmlrpcJob::slotData( const QByteArray& data )
+void XmlrpcJob::slotData( const TQByteArray& data )
{
kdDebug()<<"XmlrpcJob::slotData()"<<endl;
if ( m_redirectionURL.isEmpty() || !m_redirectionURL.isValid() || m_error )
- m_str_response.append( QString( data ) );
+ m_str_response.append( TQString( data ) );
}
void XmlrpcJob::slotFinished()
@@ -140,7 +140,7 @@ kdDebug() << m_str_response << endl;
// TODO: Redirection with XML-RPC??
/* if (! m_redirectionURL.isEmpty() && m_redirectionURL.isValid() ) {
- QDataStream istream( m_packedArgs, IO_ReadOnly );
+ TQDataStream istream( m_packedArgs, IO_ReadOnly );
int s_cmd, s_method;
KURL s_url;
istream >> s_cmd;
@@ -149,14 +149,14 @@ kdDebug() << m_str_response << endl;
// PROPFIND
if ( (s_cmd == 7) && (s_method == (int)KIO::HTTP_POST) ) {
m_packedArgs.truncate(0);
- QDataStream stream( m_packedArgs, IO_WriteOnly );
+ TQDataStream stream( m_packedArgs, IO_WriteOnly );
stream << (int)7 << m_redirectionURL << (int)KIO::HTTP_POST;
}
} else */
kdDebug() << "\033[35;40mResult: " << m_str_response << "\033[0;0m" << endl;
- QDomDocument doc;
- QString errMsg;
+ TQDomDocument doc;
+ TQString errMsg;
int errLine, errCol;
if ( doc.setContent( m_str_response, false, &errMsg, &errLine, &errCol ) ) {
if ( isMessageResponse( doc ) ) {
@@ -165,12 +165,12 @@ kdDebug() << m_str_response << endl;
} else if ( isFaultResponse( doc ) ) {
// TODO: Set the error of the job
m_response.clear();
- m_response << QVariant( parseFaultResponse( doc ).errorString() );
+ m_response << TQVariant( parseFaultResponse( doc ).errorString() );
m_responseType = XMLRPCFaultResponse;
} else {
// TODO: Set the error of the job
m_response.clear();
- m_response << QVariant( i18n( "Unknown type of XML markup received. "
+ m_response << TQVariant( i18n( "Unknown type of XML markup received. "
"Markup: \n %1" ).arg( m_str_response ) );
m_responseType = XMLRPCUnknownResponse;
}
@@ -190,18 +190,18 @@ kdDebug() << m_str_response << endl;
-bool XmlrpcJob::isMessageResponse( const QDomDocument &doc )
+bool XmlrpcJob::isMessageResponse( const TQDomDocument &doc )
{
return doc.documentElement().firstChild().toElement()
.tagName().lower() == "params";
}
-XMLRPCResult XmlrpcJob::parseMessageResponse( const QDomDocument &doc )
+XMLRPCResult XmlrpcJob::parseMessageResponse( const TQDomDocument &doc )
{
XMLRPCResult 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();
@@ -214,19 +214,19 @@ XMLRPCResult XmlrpcJob::parseMessageResponse( const QDomDocument &doc )
-bool XmlrpcJob::isFaultResponse( const QDomDocument &doc )
+bool XmlrpcJob::isFaultResponse( const TQDomDocument &doc )
{
return doc.documentElement().firstChild().toElement()
.tagName().lower() == "fault";
}
-XMLRPCResult XmlrpcJob::parseFaultResponse( const QDomDocument &doc )
+XMLRPCResult XmlrpcJob::parseFaultResponse( const TQDomDocument &doc )
{
XMLRPCResult 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();
@@ -237,50 +237,50 @@ XMLRPCResult XmlrpcJob::parseFaultResponse( const QDomDocument &doc )
-QString XmlrpcJob::marshal( const QVariant &arg )
+TQString XmlrpcJob::marshal( const TQVariant &arg )
{
switch ( arg.type() )
{
- case QVariant::String:
- case QVariant::CString:
+ case TQVariant::String:
+ case TQVariant::CString:
return "<value><string>" + arg.toString() + "</string></value>\r\n";
- case QVariant::Int:
- return "<value><int>" + QString::number( arg.toInt() ) +
+ case TQVariant::Int:
+ return "<value><int>" + TQString::number( arg.toInt() ) +
"</int></value>\r\n";
- case QVariant::Double:
- return "<value><double>" + QString::number( arg.toDouble() ) +
+ case TQVariant::Double:
+ return "<value><double>" + TQString::number( arg.toDouble() ) +
"</double></value>\r\n";
- case QVariant::Bool:
+ case TQVariant::Bool:
{
- QString markup = "<value><boolean>";
+ TQString markup = "<value><boolean>";
markup += arg.toBool() ? "1" : "0";
markup += "</boolean></value>\r\n";
return markup;
}
- case QVariant::ByteArray:
+ case TQVariant::ByteArray:
return "<value><base64>" + KCodecs::base64Encode( arg.toByteArray() ) +
"</base64></value>\r\n";
- case QVariant::DateTime:
+ case TQVariant::DateTime:
return "<value><datetime.iso8601>" +
arg.toDateTime().toString( Qt::ISODate ) +
"</datetime.iso8601></value>\r\n";
- case QVariant::List:
+ case TQVariant::List:
{
- QString markup = "<value><array><data>\r\n";
- const QValueList<QVariant> args = arg.toList();
- QValueList<QVariant>::ConstIterator it = args.begin();
- QValueList<QVariant>::ConstIterator end = args.end();
+ TQString markup = "<value><array><data>\r\n";
+ const TQValueList<TQVariant> args = arg.toList();
+ TQValueList<TQVariant>::ConstIterator it = args.begin();
+ TQValueList<TQVariant>::ConstIterator end = args.end();
for ( ; it != end; ++it )
markup += marshal( *it );
markup += "</data></array></value>\r\n";
return markup;
}
- case QVariant::Map:
+ case TQVariant::Map:
{
- QString markup = "<value><struct>\r\n";
- QMap<QString, QVariant> map = arg.toMap();
- QMap<QString, QVariant>::ConstIterator it = map.begin();
- QMap<QString, QVariant>::ConstIterator end = map.end();
+ TQString markup = "<value><struct>\r\n";
+ TQMap<TQString, TQVariant> map = arg.toMap();
+ TQMap<TQString, TQVariant>::ConstIterator it = map.begin();
+ TQMap<TQString, TQVariant>::ConstIterator end = map.end();
for ( ; it != end; ++it )
{
markup += "<member>\r\n";
@@ -295,10 +295,10 @@ QString XmlrpcJob::marshal( const QVariant &arg )
kdWarning() << "Failed to marshal unknown variant type: "
<< arg.type() << endl;
};
- return QString::null;
+ return TQString::null;
}
-QVariant XmlrpcJob::demarshal( const QDomElement &elem )
+TQVariant XmlrpcJob::demarshal( const TQDomElement &elem )
{
Q_ASSERT( elem.tagName().lower() == "value" );
@@ -310,71 +310,71 @@ QVariant XmlrpcJob::demarshal( const QDomElement &elem )
// Actually, the element will still have a child node, so this will not help here.
// The dirty hack is at the end of this method.
kdDebug()<<"XmlrpcJob::demarshal: No child nodes, assume type=string. Text: "<<elem.text()<<endl;
- return QVariant( elem.text() );
+ return TQVariant( elem.text() );
}
kdDebug()<<"Demarshalling element \"" << elem.text() <<"\"" << endl;
- 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" ) {
- QString text( typeElement.text() );
- if ( text.find( QRegExp("^[0-9]{8,8}T") ) >= 0 ) {
+ TQString text( typeElement.text() );
+ if ( text.find( TQRegExp("^[0-9]{8,8}T") ) >= 0 ) {
// It's in the format 20041120T...., so adjust it to correct
- // ISO 8601 Format 2004-11-20T..., else QDateTime::fromString won't work:
+ // ISO 8601 Format 2004-11-20T..., else TQDateTime::fromString won't work:
text = text.insert( 6, '-' );
text = text.insert( 4, '-' );
}
- return QVariant( QDateTime::fromString( text, Qt::ISODate ) );
+ return TQVariant( TQDateTime::fromString( 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 << ", text= " << typeElement.text() << endl;
// FIXME: This is just a workaround, for the issue mentioned at the beginning of this method.
- return QVariant( elem.text() );
+ return TQVariant( elem.text() );
}
- return QVariant();
+ return TQVariant();
}
@@ -383,7 +383,7 @@ kdDebug()<<"Demarshalling element \"" << elem.text() <<"\"" << endl;
/* Convenience methods */
-XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const QString &method, const QValueList<QVariant> &params, bool showProgressInfo )
+XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const TQString &method, const TQValueList<TQVariant> &params, bool showProgressInfo )
{
if ( url.isEmpty() ) {
kdWarning() << "Cannot execute call to " << method << ": empty server URL" << endl;
@@ -395,35 +395,35 @@ XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const QString &method, const QValue
return job;
}
-XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const QString &method,
- const QVariant &arg, bool showProgressInfo )
+XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const TQString &method,
+ const TQVariant &arg, bool showProgressInfo )
{
- QValueList<QVariant> args;
+ TQValueList<TQVariant> args;
args << arg;
return KIO::xmlrpcCall( url, method, args, showProgressInfo );
}
-XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const QString &method,
- const QStringList &arg, bool showProgressInfo )
+XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const TQString &method,
+ const TQStringList &arg, bool showProgressInfo )
{
- 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 KIO::xmlrpcCall( url, method, args, showProgressInfo );
}
template <typename T>
-XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const QString &method,
- const QValueList<T>&arg, bool showProgressInfo )
+XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const TQString &method,
+ const TQValueList<T>&arg, bool showProgressInfo )
{
- QValueList<QVariant> args;
+ TQValueList<TQVariant> args;
- typename QValueList<T>::ConstIterator it = arg.begin();
- typename QValueList<T>::ConstIterator end = arg.end();
+ typename TQValueList<T>::ConstIterator it = arg.begin();
+ typename TQValueList<T>::ConstIterator end = arg.end();
for ( ; it != end; ++it )
- args << QVariant( *it );
+ args << TQVariant( *it );
return KIO::xmlrpcCall( url, method, args, showProgressInfo );
}