1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DAVProperties.cxx,v $
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"
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 // -------------------------------------------------------------------
68 void DAVProperties::createNeonPropName( const rtl::OUString
& rFullName
,
69 NeonPropName
& rName
)
71 if ( rFullName
.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "DAV:" ) ) == 0 )
73 rName
.nspace
= "DAV:";
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/";
84 = strdup( rtl::OUStringToOString(
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/";
95 = strdup( rtl::OUStringToOString(
97 RTL_CONSTASCII_LENGTH(
98 "http://ucb.openoffice.org/dav/props/" ) ),
99 RTL_TEXTENCODING_UTF8
) );
101 else if ( rFullName
.compareToAscii( RTL_CONSTASCII_STRINGPARAM(
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
) );
121 // Add our namespace to our own properties.
122 rName
.nspace
= "http://ucb.openoffice.org/dav/props/";
124 = strdup( rtl::OUStringToOString( rFullName
,
125 RTL_TEXTENCODING_UTF8
) );
129 // -------------------------------------------------------------------
131 void DAVProperties::createUCBPropName( const char * nspace
,
133 rtl::OUString
& rFullName
)
135 rtl::OUString aNameSpace
136 = rtl::OStringToOUString( nspace
, RTL_TEXTENCODING_UTF8
);
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
;
145 if ( rFullName
.compareToAscii( RTL_CONSTASCII_STRINGPARAM(
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/" ) );
165 // Create property name that encodes, namespace and name ( XML ).
166 rFullName
= rtl::OUString::createFromAscii( "<prop:" );
168 rFullName
+= rtl::OUString::createFromAscii( " xmlns:prop=\"" );
169 rFullName
+= aNameSpace
;
170 rFullName
+= rtl::OUString::createFromAscii( "\">" );
174 // -------------------------------------------------------------------
176 bool DAVProperties::isUCBDeadProperty( const NeonPropName
& rName
)
178 return ( rtl_str_compareIgnoreAsciiCase(
179 rName
.nspace
, "http://ucb.openoffice.org/dav/props/" ) == 0 );