bump product version to 7.2.5.1
[LibreOffice.git] / ucb / source / ucp / ftp / ftpurl.hxx
blobb64eb6ecf45421a2f103c1056fbb0d4c109f0e17
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 #pragma once
28 #include "curl.hxx"
30 #include <rtl/ustring.hxx>
31 #include <osl/file.h>
32 #include <vector>
34 #include "ftpdirp.hxx"
36 namespace ftp {
38 /** Forward declarations.
41 class FTPContentProvider;
44 enum FTPErrors { FOLDER_MIGHT_EXIST_DURING_INSERT = CURL_LAST,
45 FILE_MIGHT_EXIST_DURING_INSERT };
47 class malformed_exception : public std::exception { };
49 class curl_exception : public std::exception
51 public:
53 explicit curl_exception(sal_Int32 err)
54 : n_err(err) { }
56 sal_Int32 code() const { return n_err; }
59 private:
61 sal_Int32 n_err;
64 class CurlInput {
65 public:
66 // returns the number of bytes actually read
67 virtual sal_Int32 read(sal_Int8 *dest,sal_Int32 nBytesRequested) = 0;
69 protected:
70 ~CurlInput() {}
74 class FTPURL
76 public:
77 /// @throws malformed_exception
78 FTPURL(
79 const OUString& aIdent,
80 FTPContentProvider* pFCP
83 FTPURL(const FTPURL& r);
85 ~FTPURL();
87 const OUString& host() const { return m_aHost; }
89 const OUString& port() const { return m_aPort; }
91 const OUString& username() const { return m_aUsername; }
93 /** This returns the URL, but cleaned from
94 * unnecessary ellipses.
97 OUString ident(bool withslash,bool internal) const;
99 /** returns the parent url.
102 OUString parent(bool internal = false) const;
104 /** sets the unencoded title */
105 void child(const OUString& title);
107 /** returns the unencoded title */
108 OUString child() const;
110 /// @throws curl_exception
111 std::vector<FTPDirentry> list(sal_Int16 nMode) const;
113 // returns a pointer to an open tempfile,
114 // sought to the beginning of.
115 /// @throws curl_exception
116 oslFileHandle open();
118 /// @throws curl_exception
119 /// @throws malformed_exception
120 FTPDirentry direntry() const;
122 /// @throws curl_exception
123 void insert(bool ReplaceExisting,void* stream) const;
125 /// @throws curl_exception
126 /// @throws malformed_exception
127 void mkdir(bool ReplaceExisting) const;
129 /// @throws curl_exception
130 OUString ren(const OUString& NewTitle);
132 /// @throws curl_exception
133 /// @throws malformed_exception
134 void del() const;
137 private:
139 FTPContentProvider *m_pFCP;
141 mutable OUString m_aUsername;
142 bool m_bShowPassword;
143 mutable OUString m_aHost;
144 mutable OUString m_aPort;
145 mutable OUString m_aType;
147 /** Contains the encoded pathsegments of the url.
149 std::vector<OUString> m_aPathSegmentVec;
151 /// @throws malformed_exception
152 void parse(const OUString& url);
154 /// @throws curl_exception
155 OUString net_title() const;
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */