bump product version to 5.0.4.1
[LibreOffice.git] / ucb / source / ucp / ftp / ftpurl.hxx
blobecb88416a0eada925f0a35134c6fad29ae6ae04a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 /**************************************************************************
21 TODO
22 **************************************************************************
24 *************************************************************************/
26 #ifndef INCLUDED_UCB_SOURCE_UCP_FTP_FTPURL_HXX
27 #define INCLUDED_UCB_SOURCE_UCP_FTP_FTPURL_HXX
29 #include "curl.hxx"
30 #include <curl/easy.h>
31 #include <com/sun/star/io/XOutputStream.hpp>
33 #include <rtl/ustring.hxx>
34 #include <osl/mutex.hxx>
35 #include <osl/file.h>
36 #include <vector>
38 #include "ftpdirp.hxx"
39 #include "ftpcfunc.hxx"
41 namespace ftp {
43 /** Forward declarations.
46 class FTPHandleProvider;
49 enum FTPErrors { FILE_EXIST_DURING_INSERT = CURL_LAST +1,
50 FOLDER_EXIST_DURING_INSERT,
51 FOLDER_MIGHT_EXIST_DURING_INSERT,
52 FILE_MIGHT_EXIST_DURING_INSERT };
54 class malformed_exception : public std::exception { };
56 class curl_exception : public std::exception
58 public:
60 curl_exception(sal_Int32 err)
61 : n_err(err) { }
63 sal_Int32 code() const { return n_err; }
66 private:
68 sal_Int32 n_err;
71 class CurlInput {
72 public:
73 // returns the number of bytes actually read
74 virtual sal_Int32 read(sal_Int8 *dest,sal_Int32 nBytesRequested) = 0;
76 protected:
77 ~CurlInput() {}
81 class FTPURL
83 public:
85 FTPURL(
86 const OUString& aIdent,
87 FTPHandleProvider* pFCP = 0
89 throw(
90 malformed_exception
93 FTPURL(const FTPURL& r);
95 ~FTPURL();
97 OUString host() const { return m_aHost; }
99 OUString port() const { return m_aPort; }
101 OUString username() const { return m_aUsername; }
103 /** This returns the URL, but cleaned from
104 * unnessary ellipses.
107 OUString ident(bool withslash,bool internal) const;
109 /** returns the parent url.
112 OUString parent(bool internal = false) const;
114 /** sets the unencoded title */
115 void child(const OUString& title);
117 /** returns the unencoded title */
118 OUString child() const;
120 std::vector<FTPDirentry> list(sal_Int16 nMode) const
121 throw(curl_exception);
123 // returns a pointer to an open tempfile,
124 // sought to the beginning of.
125 oslFileHandle open() throw(curl_exception);
127 FTPDirentry direntry() const
128 throw(curl_exception, malformed_exception);
130 void insert(bool ReplaceExisting,void* stream) const
131 throw(curl_exception);
133 void mkdir(bool ReplaceExisting) const
134 throw(curl_exception, malformed_exception);
136 OUString ren(const OUString& NewTitle)
137 throw(curl_exception);
139 void del() const
140 throw(curl_exception, malformed_exception);
143 private:
145 FTPHandleProvider *m_pFCP;
147 mutable OUString m_aUsername;
148 bool m_bShowPassword;
149 mutable OUString m_aHost;
150 mutable OUString m_aPort;
151 mutable OUString m_aType;
153 /** Contains the encoded pathsegments of the url.
155 std::vector<OUString> m_aPathSegmentVec;
157 void parse(const OUString& url)
158 throw(
159 malformed_exception
162 OUString net_title() const throw(curl_exception);
168 #endif
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */