update dev300-m58
[ooovba.git] / ucb / source / ucp / ftp / ftpurl.hxx
blob52103f72743d8c929b9e0d8949c1f88f4a33fd7f
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: ftpurl.hxx,v $
10 * $Revision: 1.15 $
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 /**************************************************************************
32 TODO
33 **************************************************************************
35 *************************************************************************/
37 #ifndef _FTP_FTPURL_HXX_
38 #define _FTP_FTPURL_HXX_
40 #include "curl.hxx"
41 #include <curl/easy.h>
42 #include <com/sun/star/io/XOutputStream.hpp>
44 #include <stdio.h>
45 #include <rtl/ustring.hxx>
46 #include <osl/mutex.hxx>
47 #include <vector>
49 #include "ftpdirp.hxx"
50 #include "ftpcfunc.hxx"
52 namespace ftp {
54 /** Forward declarations.
57 class FTPHandleProvider;
60 enum FTPErrors { FILE_EXIST_DURING_INSERT = CURL_LAST +1,
61 FOLDER_EXIST_DURING_INSERT,
62 FOLDER_MIGHT_EXIST_DURING_INSERT,
63 FILE_MIGHT_EXIST_DURING_INSERT };
66 class malformed_exception { };
69 class curl_exception
71 public:
73 curl_exception(sal_Int32 err)
74 : n_err(err) { }
76 sal_Int32 code() const { return n_err; }
79 private:
81 sal_Int32 n_err;
84 class CurlInput {
86 public:
88 // returns the number of bytes actually read
89 virtual sal_Int32 read(sal_Int8 *dest,sal_Int32 nBytesRequested) = 0;
93 class FTPURL
95 public:
97 FTPURL(
98 const rtl::OUString& aIdent,
99 FTPHandleProvider* pFCP = 0
101 throw(
102 malformed_exception
105 FTPURL(const FTPURL& r);
107 ~FTPURL();
109 rtl::OUString host() const { return m_aHost; }
111 rtl::OUString port() const { return m_aPort; }
113 rtl::OUString username() const { return m_aUsername; }
115 /** This returns the URL, but cleaned from
116 * unnessary ellipses.
119 rtl::OUString ident(bool withslash,bool internal) const;
121 /** returns the parent url.
124 rtl::OUString parent(bool internal = false) const;
126 /** sets the unencoded title */
127 void child(const rtl::OUString& title);
129 /** returns the unencoded title */
130 rtl::OUString child(void) const;
132 std::vector<FTPDirentry> list(sal_Int16 nMode) const
133 throw(curl_exception);
135 // returns a pointer to an open tempfile,
136 // seeked to the beginning of.
137 FILE* open() throw(curl_exception);
139 FTPDirentry direntry() const throw(curl_exception);
141 void insert(bool ReplaceExisting,void* stream) const
142 throw(curl_exception);
144 void mkdir(bool ReplaceExisting) const
145 throw(curl_exception);
147 rtl::OUString ren(const rtl::OUString& NewTitle)
148 throw(curl_exception);
150 void del() const
151 throw(curl_exception);
154 private:
156 osl::Mutex m_mutex;
158 FTPHandleProvider *m_pFCP;
160 mutable rtl::OUString m_aUsername;
161 bool m_bShowPassword;
162 mutable rtl::OUString m_aHost;
163 mutable rtl::OUString m_aPort;
164 mutable rtl::OUString m_aType;
166 /** Contains the encoded pathsegments of the url.
168 std::vector<rtl::OUString> m_aPathSegmentVec;
170 void parse(const rtl::OUString& url)
171 throw(
172 malformed_exception
175 rtl::OUString net_title() const throw(curl_exception);
181 #endif