1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _FTP_FTPCONTENTPROVIDER_HXX_
25 #define _FTP_FTPCONTENTPROVIDER_HXX_
26 
27 #include <vector>
28 #include <osl/mutex.hxx>
29 #include <ucbhelper/macros.hxx>
30 #include <ucbhelper/proxydecider.hxx>
31 #include <ucbhelper/providerhelper.hxx>
32 #include <com/sun/star/ucb/XContentProviderManager.hpp>
33 #include "ftphandleprovider.hxx"
34 #include "ftpurl.hxx"
35 
36 // UNO service name for the provider. This name will be used by the UCB to
37 // create instances of the provider.
38 
39 #define FTP_CONTENT_PROVIDER_SERVICE_NAME "com.sun.star.ucb.FTPContentProvider"
40 #define FTP_CONTENT_TYPE "application/ftp-content"
41 
42 
43 /**
44  *  Definition of ftpcontentprovider
45  */
46 
47 
48 
49 namespace ftp {
50 
51 
52 	class FTPLoaderThread;
53 
54 
55 	class FTPContentProvider:
56 		public ::ucbhelper::ContentProviderImplHelper,
57 		public FTPHandleProvider
58 	{
59 	public:
60 
61 		FTPContentProvider(
62             const com::sun::star::uno::Reference<
63             com::sun::star::lang::XMultiServiceFactory>& xMSF );
64 
65 		~FTPContentProvider();
66 
67 		// XInterface
68 		XINTERFACE_DECL()
69 
70 		// XTypeProvider
71 		XTYPEPROVIDER_DECL()
72 
73 		// XServiceInfo
74 		XSERVICEINFO_DECL()
75 
76 		// XContentProvider
77 		virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
78 		queryContent(
79 			const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier )
80 			throw( com::sun::star::ucb::IllegalIdentifierException,
81 				   com::sun::star::uno::RuntimeException );
82 
83 		// FTPHandleProvider.
84 
85 		virtual CURL* handle();
86 
87         virtual bool forHost(const rtl::OUString& host,
88                              const rtl::OUString& port,
89                              const rtl::OUString& username,
90                              rtl::OUString& password,
91                              rtl::OUString& account);
92 
93         virtual bool setHost(const rtl::OUString& host,
94                              const rtl::OUString& port,
95                              const rtl::OUString& username,
96                              const rtl::OUString& password,
97                              const rtl::OUString& account);
98 
99 
100         struct ServerInfo {
101             rtl::OUString host;
102             rtl::OUString port;
103             rtl::OUString username;
104             rtl::OUString password;
105             rtl::OUString account;
106         };
107 
108 	private:
109 
110 		osl::Mutex m_aMutex;
111 		FTPLoaderThread *m_ftpLoaderThread;
112 		ucbhelper::InternetProxyDecider *m_pProxyDecider;
113 		std::vector<ServerInfo> m_ServerInfo;
114 
115 		void init();
116 
117 		com::sun::star::uno::Reference<com::sun::star::ucb::XContentProvider>
118 		getHttpProvider()
119 			throw(com::sun::star::uno::RuntimeException);
120 
121 	};  // end class FTPContentProvider
122 
123 }       // end namespace ftp
124 
125 #endif
126 
127