nss: upgrade to release 3.73
[LibreOffice.git] / ucb / source / ucp / ftp / ftpurl.hxx
blobd35f86948c25fb94a9d60ce6fe97aa312e428367
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"
31 #include <rtl/ustring.hxx>
32 #include <osl/file.h>
33 #include <vector>
35 #include "ftpdirp.hxx"
37 namespace ftp {
39 /** Forward declarations.
42 class FTPContentProvider;
45 enum FTPErrors { FOLDER_MIGHT_EXIST_DURING_INSERT = CURL_LAST,
46 FILE_MIGHT_EXIST_DURING_INSERT };
48 class malformed_exception : public std::exception { };
50 class curl_exception : public std::exception
52 public:
54 explicit curl_exception(sal_Int32 err)
55 : n_err(err) { }
57 sal_Int32 code() const { return n_err; }
60 private:
62 sal_Int32 n_err;
65 class CurlInput {
66 public:
67 // returns the number of bytes actually read
68 virtual sal_Int32 read(sal_Int8 *dest,sal_Int32 nBytesRequested) = 0;
70 protected:
71 ~CurlInput() {}
75 class FTPURL
77 public:
78 /// @throws malformed_exception
79 FTPURL(
80 const OUString& aIdent,
81 FTPContentProvider* pFCP
84 FTPURL(const FTPURL& r);
86 ~FTPURL();
88 const OUString& host() const { return m_aHost; }
90 const OUString& port() const { return m_aPort; }
92 const OUString& username() const { return m_aUsername; }
94 /** This returns the URL, but cleaned from
95 * unnecessary ellipses.
98 OUString ident(bool withslash,bool internal) const;
100 /** returns the parent url.
103 OUString parent(bool internal = false) const;
105 /** sets the unencoded title */
106 void child(const OUString& title);
108 /** returns the unencoded title */
109 OUString child() const;
111 /// @throws curl_exception
112 std::vector<FTPDirentry> list(sal_Int16 nMode) const;
114 // returns a pointer to an open tempfile,
115 // sought to the beginning of.
116 /// @throws curl_exception
117 oslFileHandle open();
119 /// @throws curl_exception
120 /// @throws malformed_exception
121 FTPDirentry direntry() const;
123 /// @throws curl_exception
124 void insert(bool ReplaceExisting,void* stream) const;
126 /// @throws curl_exception
127 /// @throws malformed_exception
128 void mkdir(bool ReplaceExisting) const;
130 /// @throws curl_exception
131 OUString ren(const OUString& NewTitle);
133 /// @throws curl_exception
134 /// @throws malformed_exception
135 void del() const;
138 private:
140 FTPContentProvider *m_pFCP;
142 mutable OUString m_aUsername;
143 bool m_bShowPassword;
144 mutable OUString m_aHost;
145 mutable OUString m_aPort;
146 mutable OUString m_aType;
148 /** Contains the encoded pathsegments of the url.
150 std::vector<OUString> m_aPathSegmentVec;
152 /// @throws malformed_exception
153 void parse(const OUString& url);
155 /// @throws curl_exception
156 OUString net_title() const;
162 #endif
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */