1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datasourcehandling.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef EXTENSIONS_ABP_DATASOURCEHANDLING_HXX
32 #define EXTENSIONS_ABP_DATASOURCEHANDLING_HXX
34 #include <com/sun/star/uno/Reference.hxx>
35 #include "abptypes.hxx"
37 //========================================================================
38 namespace com
{ namespace sun
{ namespace star
{
40 class XMultiServiceFactory
;
50 //.........................................................................
53 //.........................................................................
55 //=====================================================================
56 //= ODataSourceContext
57 //=====================================================================
58 struct ODataSourceContextImpl
;
60 /// a non-UNO wrapper for the data source context
61 class ODataSourceContext
64 ODataSourceContextImpl
* m_pImpl
;
68 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
71 /// retrieves the names of all data sources
72 void getDataSourceNames( StringBag
& _rNames
) const SAL_THROW (( ));
74 /// disambiguates the given name by appending auccessive numbers
75 ::rtl::OUString
& disambiguate(::rtl::OUString
& _rDataSourceName
);
77 /// creates a new MORK data source
78 ODataSource
createNewMORK( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
80 /// creates a new Thunderbird data source
81 ODataSource
createNewThunderbird( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
83 /// creates a new Evolution local data source
84 ODataSource
createNewEvolution( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
86 /// creates a new Evolution LDAP data source
87 ODataSource
createNewEvolutionLdap( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
89 /// creates a new Evolution GROUPWISE data source
90 ODataSource
createNewEvolutionGroupwise( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
92 /// creates a new KDE address book data source
93 ODataSource
createNewKab( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
95 /// creates a new Mac OS X address book data source
96 ODataSource
createNewMacab( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
98 /// creates a new LDAP data source
99 ODataSource
createNewLDAP( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
101 /// creates a new Outlook data source
102 ODataSource
createNewOutlook( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
104 /// creates a new Outlook express data source
105 ODataSource
createNewOE( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
107 /// creates a new dBase data source
108 ODataSource
createNewDBase( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
111 //=====================================================================
113 //=====================================================================
114 struct ODataSourceImpl
;
115 struct PackageAccessControl
;
116 /** a non-UNO wrapper for a data source
117 <p>This class allows to access data sources without the need to compile the respective file with
118 exception handling enabled (hopefully :).</p>
119 <p>In addition to wrapping an UNO data source, an instance of this class can handle at most
120 one valid connection, as obtained from the data source.</p>
125 ODataSourceImpl
* m_pImpl
;
128 // ----------------------------------------------------------------
129 // - ctor/dtor/assignment
130 // ----------------------------------------------------------------
133 the service factory to use to access the UNO objects
135 the name of the data source the object should represent
138 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
,
139 const ::rtl::OUString
& _rName
142 /// constructs an object which is initially invalid
144 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
148 ODataSource( const ODataSource
& _rSource
);
154 ODataSource
& operator=( const ODataSource
& _rSource
);
156 // ----------------------------------------------------------------
157 /// checks whether or not the object represents a valid data source
158 sal_Bool
isValid() const SAL_THROW (( ));
160 // ----------------------------------------------------------------
161 /// removes the data source represented by the object from the data source context
162 void remove() SAL_THROW (( ));
163 // TODO: put this into the context class
165 /// returns the name of the data source
167 getName() const SAL_THROW (( ));
169 /// renames the data source
170 sal_Bool
rename( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
171 // TODO: put this into the context class
173 // ----------------------------------------------------------------
174 // - connection handling
175 // ----------------------------------------------------------------
176 /** connects to the data source represented by this object
177 @param _pMessageParent
178 the window to use as parent for any error messages. If this is <NULL/>, no messages are displayed
182 sal_Bool
connect( Window
* _pMessageParent
) SAL_THROW (( ));
184 /// returns <TRUE/> if the object has a valid connection, obtained from it's data source
185 sal_Bool
isConnected( ) const SAL_THROW (( ));
187 /// disconnects from the data source (i.e. disposes the UNO connection hold internally)
188 void disconnect( ) SAL_THROW (( ));
190 /// stores the database file
191 void store() SAL_THROW (( ));
193 /// register the data source under the given name in the configuration
194 void registerDataSource( const ::rtl::OUString
& _sRegisteredDataSourceName
) SAL_THROW (( ));
196 // ----------------------------------------------------------------
197 /** retrieves the tables names from the connection
198 <p>to be called when <method>isConnection</method> returns <TRUE/> only</p>
200 const StringBag
& getTableNames() const SAL_THROW (( ));
202 /** determines whether a given table exists
204 bool hasTable( const ::rtl::OUString
& _rTableName
) const;
206 /// return the intern data source object
207 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getDataSource() const SAL_THROW (( ));
210 // ----------------------------------------------------------------
211 /** set a new data source.
212 <p>Available to selected clients only</p>
215 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxDS
216 ,const ::rtl::OUString
& _sName
217 ,PackageAccessControl
221 ODataSource( ); // never implemented
224 //.........................................................................
226 //.........................................................................
228 #endif // EXTENSIONS_ABP_DATASOURCEHANDLING_HXX