xref: /aoo41x/main/ucb/source/ucp/webdav/SerfUri.hxx (revision 08bb353f)
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 
23 #ifndef INCLUDED_SERFURI_HXX
24 #define INCLUDED_SERFURI_HXX
25 
26 #include <apr_uri.h>
27 #include <rtl/ustring.hxx>
28 #include "DAVException.hxx"
29 
30 namespace http_dav_ucp
31 {
32 
33 #define DEFAULT_HTTP_PORT       80
34 #define DEFAULT_HTTPS_PORT      443
35 
36 // -------------------------------------------------------------------
37 // SerfUri
38 // A URI implementation for use with the neon/expat library
39 // -------------------------------------------------------------------
40 class SerfUri
41 {
42 	private:
43         apr_uri_t mAprUri;
44 		::rtl::OUString	mURI;
45 		::rtl::OUString	mScheme;
46 		::rtl::OUString	mUserInfo;
47 		::rtl::OUString	mHostName;
48 		sal_Int32		mPort;
49 		::rtl::OUString	mPath;
50 
51         void init( const apr_uri_t * pUri );
52 		void calculateURI ();
53 
54 	public:
55         SerfUri( const ::rtl::OUString & inUri ) throw ( DAVException );
56         SerfUri( const apr_uri_t * inUri ) throw ( DAVException );
57 		~SerfUri( );
58 
59         bool operator== ( const SerfUri & rOther ) const;
operator !=(const SerfUri & rOther) const60         bool operator!= ( const SerfUri & rOther ) const
61         { return !operator==( rOther ); }
62 
getAprUri()63         apr_uri_t* getAprUri()
64         {
65             return &mAprUri;
66         }
GetURI(void) const67 		const ::rtl::OUString & GetURI( void ) const
68 											{ return mURI; };
GetScheme(void) const69 		const ::rtl::OUString & GetScheme( void ) const
70 											{ return mScheme; };
GetUserInfo(void) const71 		const ::rtl::OUString & GetUserInfo( void ) const
72 											{ return mUserInfo; };
GetHost(void) const73 		const ::rtl::OUString & GetHost( void ) const
74 											{ return mHostName; };
GetPort(void) const75 		sal_Int32		GetPort( void )		const
76 											{ return mPort; };
GetPath(void) const77 		const ::rtl::OUString &		GetPath( void )	const
78 											{ return mPath; };
79 
80 		::rtl::OUString GetPathBaseName ( void ) const;
81 
82 		::rtl::OUString GetPathBaseNameUnescaped ( void ) const;
83 
SetScheme(const::rtl::OUString & scheme)84 		void SetScheme (const ::rtl::OUString& scheme)
85 			{ mScheme = scheme; calculateURI (); };
86 
87 		void AppendPath (const ::rtl::OUString& rPath);
88 
89 		static ::rtl::OUString escapeSegment( const ::rtl::OUString& segment );
90 		static ::rtl::OUString unescape( const ::rtl::OUString& string );
91 
92         // "host:port", omit ":port" for port 80 and 443
93         static rtl::OUString makeConnectionEndPointString(
94                                         const rtl::OUString & rHostName,
95                                         int nPort );
makeConnectionEndPointString() const96         rtl::OUString makeConnectionEndPointString() const
97         { return makeConnectionEndPointString( GetHost(), GetPort() ); }
98 };
99 
100 } // namespace http_dav_ucp
101 
102 #endif // INCLUDED_SERFURI_HXX
103