xref: /aoo41x/main/ucb/source/ucp/ftp/ftpurl.hxx (revision 72cd26dd)
16df1ea1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
36df1ea1fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
46df1ea1fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
56df1ea1fSAndrew Rist  * distributed with this work for additional information
66df1ea1fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
76df1ea1fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
86df1ea1fSAndrew Rist  * "License"); you may not use this file except in compliance
96df1ea1fSAndrew Rist  * with the License.  You may obtain a copy of the License at
106df1ea1fSAndrew Rist  *
116df1ea1fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
126df1ea1fSAndrew Rist  *
136df1ea1fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
146df1ea1fSAndrew Rist  * software distributed under the License is distributed on an
156df1ea1fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166df1ea1fSAndrew Rist  * KIND, either express or implied.  See the License for the
176df1ea1fSAndrew Rist  * specific language governing permissions and limitations
186df1ea1fSAndrew Rist  * under the License.
196df1ea1fSAndrew Rist  *
206df1ea1fSAndrew Rist  *************************************************************/
216df1ea1fSAndrew Rist 
226df1ea1fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir /**************************************************************************
25cdf0e10cSrcweir                                 TODO
26cdf0e10cSrcweir  **************************************************************************
27cdf0e10cSrcweir 
28cdf0e10cSrcweir  *************************************************************************/
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #ifndef _FTP_FTPURL_HXX_
31cdf0e10cSrcweir #define _FTP_FTPURL_HXX_
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "curl.hxx"
34cdf0e10cSrcweir #include <curl/easy.h>
35cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <rtl/ustring.hxx>
38cdf0e10cSrcweir #include <osl/mutex.hxx>
39*72cd26ddSAriel Constenla-Haile #include <osl/file.h>
40cdf0e10cSrcweir #include <vector>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include "ftpdirp.hxx"
43cdf0e10cSrcweir #include "ftpcfunc.hxx"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace ftp {
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     /** Forward declarations.
48cdf0e10cSrcweir      */
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     class FTPHandleProvider;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     enum FTPErrors { FILE_EXIST_DURING_INSERT = CURL_LAST +1,
54cdf0e10cSrcweir                      FOLDER_EXIST_DURING_INSERT,
55cdf0e10cSrcweir                      FOLDER_MIGHT_EXIST_DURING_INSERT,
56cdf0e10cSrcweir                      FILE_MIGHT_EXIST_DURING_INSERT };
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     class malformed_exception { };
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     class curl_exception
63cdf0e10cSrcweir     {
64cdf0e10cSrcweir     public:
65cdf0e10cSrcweir 
curl_exception(sal_Int32 err)66cdf0e10cSrcweir         curl_exception(sal_Int32 err)
67cdf0e10cSrcweir             : n_err(err) { }
68cdf0e10cSrcweir 
code() const69cdf0e10cSrcweir         sal_Int32 code() const { return n_err; }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     private:
73cdf0e10cSrcweir 
74cdf0e10cSrcweir         sal_Int32 n_err;
75cdf0e10cSrcweir     };
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     class CurlInput {
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     public:
80cdf0e10cSrcweir 
81cdf0e10cSrcweir         // returns the number of bytes actually read
82cdf0e10cSrcweir         virtual sal_Int32 read(sal_Int8 *dest,sal_Int32 nBytesRequested) = 0;
83cdf0e10cSrcweir     };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     class FTPURL
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir     public:
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         FTPURL(
91cdf0e10cSrcweir             const rtl::OUString& aIdent,
92cdf0e10cSrcweir             FTPHandleProvider* pFCP = 0
93cdf0e10cSrcweir         )
94cdf0e10cSrcweir             throw(
95cdf0e10cSrcweir                 malformed_exception
96cdf0e10cSrcweir             );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         FTPURL(const FTPURL& r);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir         ~FTPURL();
101cdf0e10cSrcweir 
host() const102cdf0e10cSrcweir         rtl::OUString host() const { return m_aHost; }
103cdf0e10cSrcweir 
port() const104cdf0e10cSrcweir         rtl::OUString port() const { return m_aPort; }
105cdf0e10cSrcweir 
username() const106cdf0e10cSrcweir         rtl::OUString username() const { return m_aUsername; }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         /** This returns the URL, but cleaned from
109cdf0e10cSrcweir          *  unnessary ellipses.
110cdf0e10cSrcweir          */
111cdf0e10cSrcweir 
112cdf0e10cSrcweir         rtl::OUString ident(bool withslash,bool internal) const;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir         /** returns the parent url.
115cdf0e10cSrcweir          */
116cdf0e10cSrcweir 
117cdf0e10cSrcweir         rtl::OUString parent(bool internal = false) const;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         /** sets the unencoded title */
120cdf0e10cSrcweir         void child(const rtl::OUString& title);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         /** returns the unencoded title */
123cdf0e10cSrcweir         rtl::OUString child(void) const;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         std::vector<FTPDirentry> list(sal_Int16 nMode) const
126cdf0e10cSrcweir             throw(curl_exception);
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         // returns a pointer to an open tempfile,
129cdf0e10cSrcweir         // seeked to the beginning of.
130*72cd26ddSAriel Constenla-Haile         oslFileHandle open() throw(curl_exception);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         FTPDirentry direntry() const throw(curl_exception);
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         void insert(bool ReplaceExisting,void* stream) const
135cdf0e10cSrcweir             throw(curl_exception);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         void mkdir(bool ReplaceExisting) const
138cdf0e10cSrcweir             throw(curl_exception);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir         rtl::OUString ren(const rtl::OUString& NewTitle)
141cdf0e10cSrcweir             throw(curl_exception);
142cdf0e10cSrcweir 
143cdf0e10cSrcweir         void del() const
144cdf0e10cSrcweir             throw(curl_exception);
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     private:
148cdf0e10cSrcweir 
149cdf0e10cSrcweir         osl::Mutex m_mutex;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         FTPHandleProvider *m_pFCP;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir         mutable rtl::OUString m_aUsername;
154cdf0e10cSrcweir         bool m_bShowPassword;
155cdf0e10cSrcweir         mutable rtl::OUString m_aHost;
156cdf0e10cSrcweir         mutable rtl::OUString m_aPort;
157cdf0e10cSrcweir         mutable rtl::OUString m_aType;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir         /** Contains the encoded pathsegments of the url.
160cdf0e10cSrcweir          */
161cdf0e10cSrcweir         std::vector<rtl::OUString> m_aPathSegmentVec;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir         void parse(const rtl::OUString& url)
164cdf0e10cSrcweir             throw(
165cdf0e10cSrcweir                 malformed_exception
166cdf0e10cSrcweir             );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         rtl::OUString net_title() const throw(curl_exception);
169cdf0e10cSrcweir     };
170cdf0e10cSrcweir 
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 
174cdf0e10cSrcweir #endif
175