1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_webdav.hxx" 24 25 #include <rtl/ustrbuf.hxx> 26 #include "LockRequest.hxx" 27 28 using namespace http_dav_ucp; 29 30 #define LOCK_HEADER "<?xml version=\"1.0\" encoding=\"utf-8\"?><lockinfo xmlns=\"DAV:\">" 31 #define LOCK_TYPE "<locktype><write/></locktype>" 32 #define LOCK_TRAILER "</lockinfo>" 33 generateRequestBody(const ucb::Lock & inLock)34rtl::OString LockRequest::generateRequestBody( const ucb::Lock& inLock ) 35 { 36 const char *lockScope = NULL; 37 switch ( inLock.Scope ) 38 { 39 //i126305 TODO investigate on this case... 40 case ucb::LockScope_MAKE_FIXED_SIZE: 41 42 case ucb::LockScope_EXCLUSIVE: 43 lockScope = "<lockscope><exclusive/></lockscope>"; 44 break; 45 case ucb::LockScope_SHARED: 46 lockScope = "<lockscope><shared/></lockscope>"; 47 break; 48 } 49 50 rtl::OUStringBuffer aBuffer; 51 aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( LOCK_HEADER )); 52 aBuffer.appendAscii( lockScope ); 53 aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( LOCK_TYPE )); 54 aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<owner>" )); 55 rtl::OUString aStr; 56 inLock.Owner >>= aStr; 57 aBuffer.appendAscii( rtl::OUStringToOString( aStr, RTL_TEXTENCODING_UTF8 ).getStr() ); 58 aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "</owner>" )); 59 aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( LOCK_TRAILER )); 60 return rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ); 61 } 62