Update ooo320-m1
[ooovba.git] / ucb / source / ucp / webdav / DAVProperties.cxx
blobe3a1edd700a881ea04c9abb86118e4f4ef472662
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DAVProperties.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
34 #include <string.h>
35 #include "DAVProperties.hxx"
37 using namespace webdav_ucp;
39 const ::rtl::OUString DAVProperties::CREATIONDATE =
40 ::rtl::OUString::createFromAscii( "DAV:creationdate" );
41 const ::rtl::OUString DAVProperties::DISPLAYNAME =
42 ::rtl::OUString::createFromAscii( "DAV:displayname" );
43 const ::rtl::OUString DAVProperties::GETCONTENTLANGUAGE =
44 ::rtl::OUString::createFromAscii( "DAV:getcontentlanguage" );
45 const ::rtl::OUString DAVProperties::GETCONTENTLENGTH =
46 ::rtl::OUString::createFromAscii( "DAV:getcontentlength" );
47 const ::rtl::OUString DAVProperties::GETCONTENTTYPE =
48 ::rtl::OUString::createFromAscii( "DAV:getcontenttype" );
49 const ::rtl::OUString DAVProperties::GETETAG =
50 ::rtl::OUString::createFromAscii( "DAV:getetag" );
51 const ::rtl::OUString DAVProperties::GETLASTMODIFIED =
52 ::rtl::OUString::createFromAscii( "DAV:getlastmodified" );
53 const ::rtl::OUString DAVProperties::LOCKDISCOVERY =
54 ::rtl::OUString::createFromAscii( "DAV:lockdiscovery" );
55 const ::rtl::OUString DAVProperties::RESOURCETYPE =
56 ::rtl::OUString::createFromAscii( "DAV:resourcetype" );
57 const ::rtl::OUString DAVProperties::SOURCE =
58 ::rtl::OUString::createFromAscii( "DAV:source" );
59 const ::rtl::OUString DAVProperties::SUPPORTEDLOCK =
60 ::rtl::OUString::createFromAscii( "DAV:supportedlock" );
62 const ::rtl::OUString DAVProperties::EXECUTABLE =
63 ::rtl::OUString::createFromAscii(
64 "http://apache.org/dav/props/executable" );
66 // -------------------------------------------------------------------
67 // static
68 void DAVProperties::createNeonPropName( const rtl::OUString & rFullName,
69 NeonPropName & rName )
71 if ( rFullName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "DAV:" ) ) == 0 )
73 rName.nspace = "DAV:";
74 rName.name
75 = strdup( rtl::OUStringToOString(
76 rFullName.copy( RTL_CONSTASCII_LENGTH( "DAV:" ) ),
77 RTL_TEXTENCODING_UTF8 ) );
79 else if ( rFullName.compareToAscii( RTL_CONSTASCII_STRINGPARAM(
80 "http://apache.org/dav/props/" ) ) == 0 )
82 rName.nspace = "http://apache.org/dav/props/";
83 rName.name
84 = strdup( rtl::OUStringToOString(
85 rFullName.copy(
86 RTL_CONSTASCII_LENGTH(
87 "http://apache.org/dav/props/" ) ),
88 RTL_TEXTENCODING_UTF8 ) );
90 else if ( rFullName.compareToAscii( RTL_CONSTASCII_STRINGPARAM(
91 "http://ucb.openoffice.org/dav/props/" ) ) == 0 )
93 rName.nspace = "http://ucb.openoffice.org/dav/props/";
94 rName.name
95 = strdup( rtl::OUStringToOString(
96 rFullName.copy(
97 RTL_CONSTASCII_LENGTH(
98 "http://ucb.openoffice.org/dav/props/" ) ),
99 RTL_TEXTENCODING_UTF8 ) );
101 else if ( rFullName.compareToAscii( RTL_CONSTASCII_STRINGPARAM(
102 "<prop:" ) ) == 0 )
104 // Support for 3rd party namespaces/props
106 rtl::OString aFullName
107 = rtl::OUStringToOString( rFullName, RTL_TEXTENCODING_UTF8 );
109 // Format: <prop:the_propname xmlns:prop="the_namespace">
111 sal_Int32 nStart = RTL_CONSTASCII_LENGTH( "<prop:" );
112 sal_Int32 nLen = aFullName.indexOf( ' ' ) - nStart;
113 rName.name = strdup( aFullName.copy( nStart, nLen ) );
115 nStart = aFullName.indexOf( '=', nStart + nLen ) + 2; // after ="
116 nLen = aFullName.getLength() - RTL_CONSTASCII_LENGTH( "\">" ) - nStart;
117 rName.nspace = strdup( aFullName.copy( nStart, nLen ) );
119 else
121 // Add our namespace to our own properties.
122 rName.nspace = "http://ucb.openoffice.org/dav/props/";
123 rName.name
124 = strdup( rtl::OUStringToOString( rFullName,
125 RTL_TEXTENCODING_UTF8 ) );
129 // -------------------------------------------------------------------
130 // static
131 void DAVProperties::createUCBPropName( const char * nspace,
132 const char * name,
133 rtl::OUString & rFullName )
135 rtl::OUString aNameSpace
136 = rtl::OStringToOUString( nspace, RTL_TEXTENCODING_UTF8 );
137 rtl::OUString aName
138 = rtl::OStringToOUString( name, RTL_TEXTENCODING_UTF8 );
140 // Note: Concatenating strings BEFORE comparing against known namespaces
141 // is important. See RFC 2815 ( 23.4.2 Meaning of Qualified Names ).
142 rFullName = aNameSpace;
143 rFullName += aName;
145 if ( rFullName.compareToAscii( RTL_CONSTASCII_STRINGPARAM(
146 "DAV:" ) ) == 0 )
148 // Okay, Just concat strings.
150 else if ( rFullName.compareToAscii( RTL_CONSTASCII_STRINGPARAM(
151 "http://apache.org/dav/props/" ) ) == 0 )
153 // Okay, Just concat strings.
155 else if ( rFullName.compareToAscii( RTL_CONSTASCII_STRINGPARAM(
156 "http://ucb.openoffice.org/dav/props/" ) ) == 0 )
158 // Remove namespace from our own properties.
159 rFullName = rFullName.copy(
160 RTL_CONSTASCII_LENGTH(
161 "http://ucb.openoffice.org/dav/props/" ) );
163 else
165 // Create property name that encodes, namespace and name ( XML ).
166 rFullName = rtl::OUString::createFromAscii( "<prop:" );
167 rFullName += aName;
168 rFullName += rtl::OUString::createFromAscii( " xmlns:prop=\"" );
169 rFullName += aNameSpace;
170 rFullName += rtl::OUString::createFromAscii( "\">" );
174 // -------------------------------------------------------------------
175 // static
176 bool DAVProperties::isUCBDeadProperty( const NeonPropName & rName )
178 return ( rtl_str_compareIgnoreAsciiCase(
179 rName.nspace, "http://ucb.openoffice.org/dav/props/" ) == 0 );