davjob.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <kurl.h>
00022
00023 #include <qobject.h>
00024 #include <qptrlist.h>
00025 #include <qstring.h>
00026 #include <qstringlist.h>
00027 #include <qguardedptr.h>
00028 #include <qdom.h>
00029
00030 #include <sys/types.h>
00031 #include <sys/stat.h>
00032
00033 #include <kdebug.h>
00034 #include <kio/jobclasses.h>
00035 #include <kio/global.h>
00036 #include <kio/http.h>
00037 #include <kio/davjob.h>
00038 #include <kio/job.h>
00039 #include <kio/slaveinterface.h>
00040
00041 #define KIO_ARGS QByteArray packedArgs; QDataStream stream( packedArgs, IO_WriteOnly ); stream
00042
00043 using namespace KIO;
00044
00045 DavJob::DavJob( const KURL& url, int method, const QString& request, bool showProgressInfo )
00046 : TransferJob( url, KIO::CMD_SPECIAL, QByteArray(), QByteArray(), showProgressInfo )
00047 {
00048
00049
00050 QDataStream stream( m_packedArgs, IO_WriteOnly );
00051 stream << (int) 7 << url << method;
00052
00053 staticData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + request.utf8();
00054 staticData.truncate( staticData.size() - 1 );
00055 }
00056
00057 void DavJob::slotData( const QByteArray& data )
00058 {
00059 m_str_response.append( QString( data ) );
00060 }
00061
00062 void DavJob::slotFinished()
00063 {
00064
00065
00066
00067 if ( ! m_response.setContent( m_str_response, true ) ) {
00068
00069 QDomElement root = m_response.createElementNS( "DAV:", "error-report" );
00070 m_response.appendChild( root );
00071
00072 QDomElement el = m_response.createElementNS( "DAV:", "offending-response" );
00073 QDomText textnode = m_response.createTextNode( m_str_response );
00074 el.appendChild( textnode );
00075 root.appendChild( el );
00076 }
00077
00078
00079 TransferJob::slotFinished();
00080 }
00081
00082
00083
00084 DavJob* KIO::davPropFind( const KURL& url, const QDomDocument& properties, QString depth, bool showProgressInfo )
00085 {
00086 DavJob *job = new DavJob( url, (int) KIO::DAV_PROPFIND, properties.toString(), showProgressInfo );
00087 job->addMetaData( "davDepth", depth );
00088 return job;
00089 }
00090
00091
00092 DavJob* KIO::davPropPatch( const KURL& url, const QDomDocument& properties, bool showProgressInfo )
00093 {
00094 return new DavJob( url, (int) KIO::DAV_PROPPATCH, properties.toString(), showProgressInfo );
00095 }
00096
00097 DavJob* KIO::davSearch( const KURL& url, const QString& nsURI, const QString& qName, const QString& query, bool showProgressInfo )
00098 {
00099 QDomDocument doc;
00100 QDomElement searchrequest = doc.createElementNS( "DAV:", "searchrequest" );
00101 QDomElement searchelement = doc.createElementNS( nsURI, qName );
00102 QDomText text = doc.createTextNode( query );
00103 searchelement.appendChild( text );
00104 searchrequest.appendChild( searchelement );
00105 doc.appendChild( searchrequest );
00106 return new DavJob( url, KIO::DAV_SEARCH, doc.toString(), showProgressInfo );
00107 }
00108
00109 #include "davjob.moc"
This file is part of the documentation for kdelibs Version 3.1.0.