1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 /**************************************************************************
22 **************************************************************************
24 *************************************************************************/
30 #include <rtl/ustring.hxx>
34 #include "ftpdirp.hxx"
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
53 explicit curl_exception(sal_Int32 err
)
56 sal_Int32
code() const { return n_err
; }
66 // returns the number of bytes actually read
67 virtual sal_Int32
read(sal_Int8
*dest
,sal_Int32 nBytesRequested
) = 0;
77 /// @throws malformed_exception
79 const OUString
& aIdent
,
80 FTPContentProvider
* pFCP
83 FTPURL(const FTPURL
& r
);
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
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: */