1*51ba086bSDamjan Jovanovic /************************************************************** 2*51ba086bSDamjan Jovanovic * 3*51ba086bSDamjan Jovanovic * Licensed to the Apache Software Foundation (ASF) under one 4*51ba086bSDamjan Jovanovic * or more contributor license agreements. See the NOTICE file 5*51ba086bSDamjan Jovanovic * distributed with this work for additional information 6*51ba086bSDamjan Jovanovic * regarding copyright ownership. The ASF licenses this file 7*51ba086bSDamjan Jovanovic * to you under the Apache License, Version 2.0 (the 8*51ba086bSDamjan Jovanovic * "License"); you may not use this file except in compliance 9*51ba086bSDamjan Jovanovic * with the License. You may obtain a copy of the License at 10*51ba086bSDamjan Jovanovic * 11*51ba086bSDamjan Jovanovic * http://www.apache.org/licenses/LICENSE-2.0 12*51ba086bSDamjan Jovanovic * 13*51ba086bSDamjan Jovanovic * Unless required by applicable law or agreed to in writing, 14*51ba086bSDamjan Jovanovic * software distributed under the License is distributed on an 15*51ba086bSDamjan Jovanovic * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*51ba086bSDamjan Jovanovic * KIND, either express or implied. See the License for the 17*51ba086bSDamjan Jovanovic * specific language governing permissions and limitations 18*51ba086bSDamjan Jovanovic * under the License. 19*51ba086bSDamjan Jovanovic * 20*51ba086bSDamjan Jovanovic *************************************************************/ 21*51ba086bSDamjan Jovanovic 22*51ba086bSDamjan Jovanovic // MARKER(update_precomp.py): autogen include statement, do not remove 23*51ba086bSDamjan Jovanovic #include "precompiled_webdav.hxx" 24*51ba086bSDamjan Jovanovic 25*51ba086bSDamjan Jovanovic #include <rtl/ustrbuf.hxx> 26*51ba086bSDamjan Jovanovic #include "DAVProperties.hxx" 27*51ba086bSDamjan Jovanovic #include "PropfindRequest.hxx" 28*51ba086bSDamjan Jovanovic 29*51ba086bSDamjan Jovanovic using namespace http_dav_ucp; 30*51ba086bSDamjan Jovanovic generatePROPFINDRequestBody(const std::vector<::rtl::OUString> * propNames,const bool onlyPropertyNames)31*51ba086bSDamjan Jovanovicrtl::OString PropfindRequest::generatePROPFINDRequestBody( 32*51ba086bSDamjan Jovanovic const std::vector< ::rtl::OUString > * propNames, 33*51ba086bSDamjan Jovanovic const bool onlyPropertyNames ) 34*51ba086bSDamjan Jovanovic { 35*51ba086bSDamjan Jovanovic #define PROPFIND_HEADER "<?xml version=\"1.0\" encoding=\"utf-8\"?><propfind xmlns=\"DAV:\">" 36*51ba086bSDamjan Jovanovic #define PROPFIND_TRAILER "</propfind>" 37*51ba086bSDamjan Jovanovic 38*51ba086bSDamjan Jovanovic // TODO is it really needed a Unicode string buffer? 39*51ba086bSDamjan Jovanovic // All properties and property names aren't supposed to be ASCII? 40*51ba086bSDamjan Jovanovic rtl::OUStringBuffer aBuffer; 41*51ba086bSDamjan Jovanovic aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( PROPFIND_HEADER )); 42*51ba086bSDamjan Jovanovic 43*51ba086bSDamjan Jovanovic // create and fill body with requested properties 44*51ba086bSDamjan Jovanovic const int nPropCount = ( !onlyPropertyNames && propNames ) 45*51ba086bSDamjan Jovanovic ? propNames->size() 46*51ba086bSDamjan Jovanovic : 0; 47*51ba086bSDamjan Jovanovic if ( nPropCount > 0 ) 48*51ba086bSDamjan Jovanovic { 49*51ba086bSDamjan Jovanovic aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<prop>" ) ); 50*51ba086bSDamjan Jovanovic CurlPropName thePropName; 51*51ba086bSDamjan Jovanovic for ( int theIndex = 0; theIndex < nPropCount; theIndex ++ ) 52*51ba086bSDamjan Jovanovic { 53*51ba086bSDamjan Jovanovic // split fullname into namespace and name! 54*51ba086bSDamjan Jovanovic DAVProperties::createCurlPropName( (*propNames)[ theIndex ], 55*51ba086bSDamjan Jovanovic thePropName ); 56*51ba086bSDamjan Jovanovic 57*51ba086bSDamjan Jovanovic /* <*propname* xmlns="*propns*" /> */ 58*51ba086bSDamjan Jovanovic aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<" )); 59*51ba086bSDamjan Jovanovic aBuffer.appendAscii( thePropName.name ); 60*51ba086bSDamjan Jovanovic aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " xmlnx=\"" )); 61*51ba086bSDamjan Jovanovic aBuffer.appendAscii( thePropName.nspace ); 62*51ba086bSDamjan Jovanovic aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\"/>" )); 63*51ba086bSDamjan Jovanovic } 64*51ba086bSDamjan Jovanovic 65*51ba086bSDamjan Jovanovic aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "</prop>" )); 66*51ba086bSDamjan Jovanovic } 67*51ba086bSDamjan Jovanovic else 68*51ba086bSDamjan Jovanovic { 69*51ba086bSDamjan Jovanovic if ( onlyPropertyNames ) 70*51ba086bSDamjan Jovanovic { 71*51ba086bSDamjan Jovanovic aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<propname/>" )); 72*51ba086bSDamjan Jovanovic } 73*51ba086bSDamjan Jovanovic else 74*51ba086bSDamjan Jovanovic { 75*51ba086bSDamjan Jovanovic aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<allprop/>" )); 76*51ba086bSDamjan Jovanovic } 77*51ba086bSDamjan Jovanovic } 78*51ba086bSDamjan Jovanovic 79*51ba086bSDamjan Jovanovic aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( PROPFIND_TRAILER )); 80*51ba086bSDamjan Jovanovic return rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ); 81*51ba086bSDamjan Jovanovic } 82