1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _FTP_FTPCONTENTPROVIDER_HXX_
29 #define _FTP_FTPCONTENTPROVIDER_HXX_
30 
31 #include <vector>
32 #include <osl/mutex.hxx>
33 #include <ucbhelper/macros.hxx>
34 #include <ucbhelper/proxydecider.hxx>
35 #include <ucbhelper/providerhelper.hxx>
36 #include <com/sun/star/ucb/XContentProviderManager.hpp>
37 #include "ftphandleprovider.hxx"
38 #include "ftpurl.hxx"
39 
40 // UNO service name for the provider. This name will be used by the UCB to
41 // create instances of the provider.
42 
43 #define FTP_CONTENT_PROVIDER_SERVICE_NAME "com.sun.star.ucb.FTPContentProvider"
44 #define FTP_CONTENT_TYPE "application/ftp-content"
45 
46 
47 /**
48  *  Definition of ftpcontentprovider
49  */
50 
51 
52 
53 namespace ftp {
54 
55 
56 	class FTPLoaderThread;
57 
58 
59 	class FTPContentProvider:
60 		public ::ucbhelper::ContentProviderImplHelper,
61 		public FTPHandleProvider
62 	{
63 	public:
64 
65 		FTPContentProvider(
66             const com::sun::star::uno::Reference<
67             com::sun::star::lang::XMultiServiceFactory>& xMSF );
68 
69 		~FTPContentProvider();
70 
71 		// XInterface
72 		XINTERFACE_DECL()
73 
74 		// XTypeProvider
75 		XTYPEPROVIDER_DECL()
76 
77 		// XServiceInfo
78 		XSERVICEINFO_DECL()
79 
80 		// XContentProvider
81 		virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
82 		queryContent(
83 			const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier )
84 			throw( com::sun::star::ucb::IllegalIdentifierException,
85 				   com::sun::star::uno::RuntimeException );
86 
87 		// FTPHandleProvider.
88 
89 		virtual CURL* handle();
90 
91         virtual bool forHost(const rtl::OUString& host,
92                              const rtl::OUString& port,
93                              const rtl::OUString& username,
94                              rtl::OUString& password,
95                              rtl::OUString& account);
96 
97         virtual bool setHost(const rtl::OUString& host,
98                              const rtl::OUString& port,
99                              const rtl::OUString& username,
100                              const rtl::OUString& password,
101                              const rtl::OUString& account);
102 
103 
104         struct ServerInfo {
105             rtl::OUString host;
106             rtl::OUString port;
107             rtl::OUString username;
108             rtl::OUString password;
109             rtl::OUString account;
110         };
111 
112 	private:
113 
114 		osl::Mutex m_aMutex;
115 		FTPLoaderThread *m_ftpLoaderThread;
116 		ucbhelper::InternetProxyDecider *m_pProxyDecider;
117 		std::vector<ServerInfo> m_ServerInfo;
118 
119 		void init();
120 
121 		com::sun::star::uno::Reference<com::sun::star::ucb::XContentProvider>
122 		getHttpProvider()
123 			throw(com::sun::star::uno::RuntimeException);
124 
125 	};  // end class FTPContentProvider
126 
127 }       // end namespace ftp
128 
129 #endif
130 
131