[Patch] Webdav properties in UDSAtoms

Best, Jan-Pascal van j.p.vanbest at tbm.tudelft.nl
Wed Jun 5 10:15:42 BST 2002


The following patch works for me. It is the same as what I proposed
last to Hamish. OK to apply? (I can do that myself now, yippee!)

Cheers

Jan-Pascal


Index: global.h
===================================================================
RCS file: /home/kde/kdelibs/kio/kio/global.h,v
retrieving revision 1.49
diff -u -3 -p -r1.49 global.h
--- global.h    2002/04/05 22:18:47     1.49
+++ global.h    2002/06/05 09:11:33
@@ -238,7 +238,9 @@ namespace KIO
     UDS_MIME_TYPE = 16384 | UDS_STRING,
     // A mime type to be used for displaying only.
     // But when 'running' the file, the mimetype is re-determined
-    UDS_GUESSED_MIME_TYPE = 16392 | UDS_STRING
+    UDS_GUESSED_MIME_TYPE = 16392 | UDS_STRING,
+    // XML properties, e.g. for WebDAV
+    UDS_XML_PROPERTIES = 32768 | UDS_STRING
   };

   enum CacheControl

Index: http.cc
===================================================================
RCS file: /home/kde/kdelibs/kioslave/http/http.cc,v
retrieving revision 1.506
diff -u -3 -p -r1.506 http.cc
--- http.cc     2002/06/03 03:11:49     1.506
+++ http.cc     2002/06/05 09:08:05
@@ -484,6 +484,15 @@ void HTTPProtocol::listDir( const KURL&
   davStatList( url, false );
 }

+void HTTPProtocol::davSetRequest( const QCString& requestXML )
+{
+  // insert the document into the POST buffer, kill trailing zero byte
+  m_bufPOST = requestXML;
+
+  if (m_bufPOST.size())
+    m_bufPOST.truncate( m_bufPOST.size() - 1 );
+}
+
 void HTTPProtocol::davStatList( const KURL& url, bool stat )
 {
   UDSEntry entry;
@@ -501,10 +510,37 @@ void HTTPProtocol::davStatList( const KU
     request.append( "<D:searchrequest xmlns:D=\"DAV:\">\r\n" );
     request.append( query.utf8() );
     request.append( "</D:searchrequest>\r\n" );
+
+    davSetRequest( request );
+  } else {
+    // We are only after certain features...
+    QCString request;
+    request = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
+    "<propfind xmlns:D=\"DAV:\">";
+
+    // insert additional XML request from the davRequestResponse
metadata
+    if ( hasMetaData( "davRequestResponse" ) )
+      request += metaData( "davRequestResponse" ).utf8();
+    else {
+      // No special request, ask for default properties
+      request += "<D:prop>"
+      "<D:creationdate/>"
+      "<D:getcontentlength/>"
+      "<D:displayname/>"
+      "<D:source/>"
+      "<D:getcontentlanguage/>"
+      "<D:getcontenttype/>"
+      "<D:executable/>"
+      "<D:getlastmodified/>"
+      "<D:getetag/>"
+      "<D:supportedlock/>"
+      "<D:lockdiscovery/>"
+      "<D:resourcetype/>"
+      "</prop>";
+    }
+    request += "</propfind>";

-    // insert the document into the POST buffer, kill trailing zero
byte
-    m_bufPOST = request;
-    if (m_bufPOST.size()) m_bufPOST.truncate( m_bufPOST.size() - 1 );
+    davSetRequest( request );
   }

   // WebDAV Stat or List...
@@ -615,6 +651,15 @@ void HTTPProtocol::davParsePropstats( co
     {
       kdDebug(7113) << "Error: no prop segment in this propstat." <<
endl;
       return;
+    }
+
+    if ( hasMetaData( "davRequestResponse" ) )
+    {
+      atom.m_uds = KIO::UDS_XML_PROPERTIES;
+      QDomDocument doc;
+      doc.appendChild(prop);
+      atom.m_str = doc.toString();
+      entry.append( atom );
     }

     for ( QDomElement property = prop.firstChild().toElement();
Index: http.h
===================================================================
RCS file: /home/kde/kdelibs/kioslave/http/http.h,v
retrieving revision 1.131
diff -u -3 -p -r1.131 http.h
--- http.h      2002/06/03 03:11:49     1.131
+++ http.h      2002/06/05 09:08:05
@@ -238,6 +238,7 @@ protected:
   /**
    * Performs a WebDAV stat or list
    */
+  void davSetRequest( const QCString& requestXML );
   void davStatList( const KURL& url, bool stat = true );
   void davParsePropstats( const QDomNodeList& propstats, KIO::UDSEntry&
entry );
   void davParseActiveLocks( const QDomNodeList& activeLocks,




More information about the kfm-devel mailing list