Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_UCB_SOURCE_UCP_FTP_FTPCONTENTPROVIDER_HXX
21 : #define INCLUDED_UCB_SOURCE_UCP_FTP_FTPCONTENTPROVIDER_HXX
22 :
23 : #include <vector>
24 : #include <osl/mutex.hxx>
25 : #include <ucbhelper/proxydecider.hxx>
26 : #include <ucbhelper/providerhelper.hxx>
27 : #include <com/sun/star/ucb/XContentProviderManager.hpp>
28 : #include "ftphandleprovider.hxx"
29 : #include "ftpurl.hxx"
30 :
31 : // UNO service name for the provider. This name will be used by the UCB to
32 : // create instances of the provider.
33 :
34 : #define FTP_CONTENT_PROVIDER_SERVICE_NAME "com.sun.star.ucb.FTPContentProvider"
35 : #define FTP_CONTENT_TYPE "application/ftp-content"
36 :
37 : /**
38 : * Definition of ftpcontentprovider
39 : */
40 : namespace ftp
41 : {
42 : class FTPLoaderThread;
43 :
44 : class FTPContentProvider:
45 : public ::ucbhelper::ContentProviderImplHelper,
46 : public FTPHandleProvider
47 : {
48 : public:
49 :
50 : explicit FTPContentProvider( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
51 :
52 : virtual ~FTPContentProvider();
53 :
54 : // XInterface
55 : virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
56 : throw( css::uno::RuntimeException,
57 : std::exception ) SAL_OVERRIDE;
58 : virtual void SAL_CALL acquire()
59 : throw() SAL_OVERRIDE;
60 : virtual void SAL_CALL release()
61 : throw() SAL_OVERRIDE;
62 :
63 : // XTypeProvider
64 : virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
65 : throw( css::uno::RuntimeException,
66 : std::exception ) SAL_OVERRIDE;
67 : virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
68 : throw( css::uno::RuntimeException,
69 : std::exception ) SAL_OVERRIDE;
70 :
71 : // XServiceInfo
72 : virtual OUString SAL_CALL getImplementationName()
73 : throw( css::uno::RuntimeException,
74 : std::exception ) SAL_OVERRIDE;
75 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
76 : throw( css::uno::RuntimeException,
77 : std::exception ) SAL_OVERRIDE;
78 : virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
79 : throw( css::uno::RuntimeException,
80 : std::exception ) SAL_OVERRIDE;
81 :
82 : static OUString getImplementationName_Static();
83 : static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
84 :
85 : static css::uno::Reference< css::lang::XSingleServiceFactory >
86 : createServiceFactory( const css::uno::Reference<
87 : css::lang::XMultiServiceFactory >& rxServiceMgr );
88 :
89 : // XContentProvider
90 : virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
91 : queryContent( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier )
92 : throw( css::ucb::IllegalIdentifierException,
93 : css::uno::RuntimeException,
94 : std::exception ) SAL_OVERRIDE;
95 :
96 : // FTPHandleProvider.
97 :
98 : virtual CURL* handle() SAL_OVERRIDE;
99 :
100 : virtual bool forHost(const OUString& host,
101 : const OUString& port,
102 : const OUString& username,
103 : OUString& password,
104 : OUString& account) SAL_OVERRIDE;
105 :
106 : virtual bool setHost(const OUString& host,
107 : const OUString& port,
108 : const OUString& username,
109 : const OUString& password,
110 : const OUString& account) SAL_OVERRIDE;
111 :
112 4 : struct ServerInfo
113 : {
114 : OUString host;
115 : OUString port;
116 : OUString username;
117 : OUString password;
118 : OUString account;
119 : };
120 :
121 : private:
122 :
123 : osl::Mutex m_aMutex;
124 : FTPLoaderThread *m_ftpLoaderThread;
125 : ucbhelper::InternetProxyDecider *m_pProxyDecider;
126 : std::vector<ServerInfo> m_ServerInfo;
127 :
128 : void init();
129 :
130 : css::uno::Reference<css::ucb::XContentProvider> getHttpProvider()
131 : throw(css::uno::RuntimeException);
132 :
133 : }; // end class FTPContentProvider
134 :
135 : } // end namespace ftp
136 :
137 : #endif
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|