xref: /trunk/main/ucb/source/ucp/webdav/CurlUri.hxx (revision 51ba086b)
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_CURLURI_HXX
24 #define INCLUDED_CURLURI_HXX
25 
26 #include <curl/curl.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 // CurlUri
38 // A URI implementation for use with the Curl library
39 // -------------------------------------------------------------------
40 class CurlUri
41 {
42 	private:
43         CURLU *mCurlUri;
44 		::rtl::OUString	mURI;
45 		::rtl::OUString	mScheme;
46 		::rtl::OUString	mUserName;
47 		::rtl::OUString	mPassword;
48 		::rtl::OUString	mHostName;
49 		sal_Int32		mPort;
50 		::rtl::OUString	mPath;
51 
52         void init( const CURLU * pUri );
53 		void calculateURI ();
54 
55 	public:
56         CurlUri( const ::rtl::OUString & inUri ) throw ( DAVException );
57         CurlUri( const CURLU * inUri ) throw ( DAVException );
58         CurlUri( const CurlUri &curlUri ) throw ( DAVException );
59 		~CurlUri( );
60 
61         bool operator== ( const CurlUri & rOther ) const;
operator !=(const CurlUri & rOther) const62         bool operator!= ( const CurlUri & rOther ) const
63         { return !operator==( rOther ); }
64 
GetURI(void) const65 		const ::rtl::OUString & GetURI( void ) const
66 											{ return mURI; };
GetScheme(void) const67 		const ::rtl::OUString & GetScheme( void ) const
68 											{ return mScheme; };
GetUserName(void) const69 		const ::rtl::OUString & GetUserName( void ) const
70 											{ return mUserName; };
GetPassword(void) const71 		const ::rtl::OUString & GetPassword( void ) const
72 											{ return mPassword; };
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_CURLURI_HXX
103