1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef EXTENSIONS_ABP_DATASOURCEHANDLING_HXX
29*cdf0e10cSrcweir #define EXTENSIONS_ABP_DATASOURCEHANDLING_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
32*cdf0e10cSrcweir #include "abptypes.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir //========================================================================
35*cdf0e10cSrcweir namespace com { namespace sun { namespace star {
36*cdf0e10cSrcweir 	namespace lang {
37*cdf0e10cSrcweir 		class XMultiServiceFactory;
38*cdf0e10cSrcweir 	}
39*cdf0e10cSrcweir 	namespace beans {
40*cdf0e10cSrcweir 		class XPropertySet;
41*cdf0e10cSrcweir 	}
42*cdf0e10cSrcweir } } }
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir class Window;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir //.........................................................................
48*cdf0e10cSrcweir namespace abp
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir //.........................................................................
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir 	//=====================================================================
53*cdf0e10cSrcweir 	//= ODataSourceContext
54*cdf0e10cSrcweir 	//=====================================================================
55*cdf0e10cSrcweir 	struct ODataSourceContextImpl;
56*cdf0e10cSrcweir 	class ODataSource;
57*cdf0e10cSrcweir 	/// a non-UNO wrapper for the data source context
58*cdf0e10cSrcweir 	class ODataSourceContext
59*cdf0e10cSrcweir 	{
60*cdf0e10cSrcweir 	private:
61*cdf0e10cSrcweir 		ODataSourceContextImpl*		m_pImpl;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	public:
64*cdf0e10cSrcweir 		ODataSourceContext(
65*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
66*cdf0e10cSrcweir 		);
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 		/// retrieves the names of all data sources
69*cdf0e10cSrcweir 		void	getDataSourceNames( StringBag& _rNames ) const SAL_THROW (( ));
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 		/// disambiguates the given name by appending auccessive numbers
72*cdf0e10cSrcweir 		::rtl::OUString& disambiguate(::rtl::OUString& _rDataSourceName);
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 		/// creates a new MORK data source
75*cdf0e10cSrcweir 		ODataSource createNewMORK( const ::rtl::OUString& _rName ) SAL_THROW (( ));
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 		/// creates a new Thunderbird data source
78*cdf0e10cSrcweir 		ODataSource createNewThunderbird( const ::rtl::OUString& _rName ) SAL_THROW (( ));
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 		/// creates a new Evolution local data source
81*cdf0e10cSrcweir 		ODataSource createNewEvolution( const ::rtl::OUString& _rName ) SAL_THROW (( ));
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 		/// creates a new Evolution LDAP data source
84*cdf0e10cSrcweir 		ODataSource createNewEvolutionLdap( const ::rtl::OUString& _rName ) SAL_THROW (( ));
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 		/// creates a new Evolution GROUPWISE data source
87*cdf0e10cSrcweir 		ODataSource createNewEvolutionGroupwise( const ::rtl::OUString& _rName ) SAL_THROW (( ));
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 		/// creates a new KDE address book data source
90*cdf0e10cSrcweir 		ODataSource createNewKab( const ::rtl::OUString& _rName ) SAL_THROW (( ));
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 		/// creates a new Mac OS X address book data source
93*cdf0e10cSrcweir 		ODataSource createNewMacab( const ::rtl::OUString& _rName ) SAL_THROW (( ));
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 		/// creates a new LDAP data source
96*cdf0e10cSrcweir 		ODataSource	createNewLDAP( const ::rtl::OUString& _rName ) SAL_THROW (( ));
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 		/// creates a new Outlook data source
99*cdf0e10cSrcweir 		ODataSource	createNewOutlook( const ::rtl::OUString& _rName ) SAL_THROW (( ));
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 		/// creates a new Outlook express data source
102*cdf0e10cSrcweir 		ODataSource	createNewOE( const ::rtl::OUString& _rName ) SAL_THROW (( ));
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 		/// creates a new dBase data source
105*cdf0e10cSrcweir 		ODataSource	createNewDBase( const ::rtl::OUString& _rName ) SAL_THROW (( ));
106*cdf0e10cSrcweir 	};
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	//=====================================================================
109*cdf0e10cSrcweir 	//= ODataSource
110*cdf0e10cSrcweir 	//=====================================================================
111*cdf0e10cSrcweir 	struct ODataSourceImpl;
112*cdf0e10cSrcweir 	struct PackageAccessControl;
113*cdf0e10cSrcweir 	/** a non-UNO wrapper for a data source
114*cdf0e10cSrcweir 		<p>This class allows to access data sources without the need to compile the respective file with
115*cdf0e10cSrcweir 		exception handling enabled (hopefully :).</p>
116*cdf0e10cSrcweir 		<p>In addition to wrapping an UNO data source, an instance of this class can handle at most
117*cdf0e10cSrcweir 		one valid connection, as obtained from the data source.</p>
118*cdf0e10cSrcweir 	*/
119*cdf0e10cSrcweir 	class ODataSource
120*cdf0e10cSrcweir 	{
121*cdf0e10cSrcweir 	private:
122*cdf0e10cSrcweir 		ODataSourceImpl*	m_pImpl;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	public:
125*cdf0e10cSrcweir 		// ----------------------------------------------------------------
126*cdf0e10cSrcweir 		// - ctor/dtor/assignment
127*cdf0e10cSrcweir 		// ----------------------------------------------------------------
128*cdf0e10cSrcweir 		/// constructs an object which is initially invalid
129*cdf0e10cSrcweir 		ODataSource(
130*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
131*cdf0e10cSrcweir 		);
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 		/// copy ctor
134*cdf0e10cSrcweir 		ODataSource( const ODataSource& _rSource );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 		/// dtor
137*cdf0e10cSrcweir 		~ODataSource( );
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 		/// assignment
140*cdf0e10cSrcweir 		ODataSource& operator=( const ODataSource& _rSource );
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 		// ----------------------------------------------------------------
143*cdf0e10cSrcweir 		/// checks whether or not the object represents a valid data source
144*cdf0e10cSrcweir 		sal_Bool	isValid() const SAL_THROW (( ));
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 		// ----------------------------------------------------------------
147*cdf0e10cSrcweir 		/// removes the data source represented by the object from the data source context
148*cdf0e10cSrcweir 		void		remove() SAL_THROW (( ));
149*cdf0e10cSrcweir 			// TODO: put this into the context class
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 		/// returns the name of the data source
152*cdf0e10cSrcweir 		::rtl::OUString
153*cdf0e10cSrcweir 					getName() const SAL_THROW (( ));
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 		/// renames the data source
156*cdf0e10cSrcweir 		sal_Bool	rename( const ::rtl::OUString& _rName ) SAL_THROW (( ));
157*cdf0e10cSrcweir 			// TODO: put this into the context class
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 		// ----------------------------------------------------------------
160*cdf0e10cSrcweir 		// - connection handling
161*cdf0e10cSrcweir 		// ----------------------------------------------------------------
162*cdf0e10cSrcweir 		/** connects to the data source represented by this object
163*cdf0e10cSrcweir 			@param _pMessageParent
164*cdf0e10cSrcweir 				the window to use as parent for any error messages. If this is <NULL/>, no messages are displayed
165*cdf0e10cSrcweir 				at all.
166*cdf0e10cSrcweir 			@see isConnected
167*cdf0e10cSrcweir 		*/
168*cdf0e10cSrcweir 		sal_Bool	connect( Window* _pMessageParent ) SAL_THROW (( ));
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 		/// returns <TRUE/> if the object has a valid connection, obtained from it's data source
171*cdf0e10cSrcweir 		sal_Bool	isConnected( ) const SAL_THROW (( ));
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 		/// disconnects from the data source (i.e. disposes the UNO connection hold internally)
174*cdf0e10cSrcweir 		void		disconnect( ) SAL_THROW (( ));
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 		/// stores the database file
177*cdf0e10cSrcweir 		void		store() SAL_THROW (( ));
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 		/// register the data source under the given name in the configuration
180*cdf0e10cSrcweir 		void		registerDataSource( const ::rtl::OUString& _sRegisteredDataSourceName )  SAL_THROW (( ));
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 		// ----------------------------------------------------------------
183*cdf0e10cSrcweir 		/** retrieves the tables names from the connection
184*cdf0e10cSrcweir 			<p>to be called when <method>isConnection</method> returns <TRUE/> only</p>
185*cdf0e10cSrcweir 		*/
186*cdf0e10cSrcweir 		const StringBag&	getTableNames() const SAL_THROW (( ));
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir         /** determines whether a given table exists
189*cdf0e10cSrcweir         */
190*cdf0e10cSrcweir         bool    hasTable( const ::rtl::OUString& _rTableName ) const;
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 		/// return the intern data source object
193*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDataSource() const SAL_THROW (( ));
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 		// ----------------------------------------------------------------
197*cdf0e10cSrcweir 		/** set a new data source.
198*cdf0e10cSrcweir 			<p>Available to selected clients only</p>
199*cdf0e10cSrcweir 		*/
200*cdf0e10cSrcweir 		void		setDataSource(
201*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDS
202*cdf0e10cSrcweir 			,const ::rtl::OUString& _sName
203*cdf0e10cSrcweir 			,PackageAccessControl
204*cdf0e10cSrcweir 		);
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 	private:
207*cdf0e10cSrcweir 		ODataSource( ); // never implemented
208*cdf0e10cSrcweir 	};
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir //.........................................................................
211*cdf0e10cSrcweir }	// namespace abp
212*cdf0e10cSrcweir //.........................................................................
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir #endif // EXTENSIONS_ABP_DATASOURCEHANDLING_HXX
215*cdf0e10cSrcweir 
216