146dbaceeSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 346dbaceeSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 446dbaceeSAndrew Rist * or more contributor license agreements. See the NOTICE file 546dbaceeSAndrew Rist * distributed with this work for additional information 646dbaceeSAndrew Rist * regarding copyright ownership. The ASF licenses this file 746dbaceeSAndrew Rist * to you under the Apache License, Version 2.0 (the 846dbaceeSAndrew Rist * "License"); you may not use this file except in compliance 946dbaceeSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 1146dbaceeSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 1346dbaceeSAndrew Rist * Unless required by applicable law or agreed to in writing, 1446dbaceeSAndrew Rist * software distributed under the License is distributed on an 1546dbaceeSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1646dbaceeSAndrew Rist * KIND, either express or implied. See the License for the 1746dbaceeSAndrew Rist * specific language governing permissions and limitations 1846dbaceeSAndrew Rist * under the License. 19cdf0e10cSrcweir * 2046dbaceeSAndrew Rist *************************************************************/ 2146dbaceeSAndrew Rist 22cdf0e10cSrcweir #ifndef EXTENSIONS_ABP_DATASOURCEHANDLING_HXX 23cdf0e10cSrcweir #define EXTENSIONS_ABP_DATASOURCEHANDLING_HXX 24cdf0e10cSrcweir 25cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx> 26cdf0e10cSrcweir #include "abptypes.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir //======================================================================== 29cdf0e10cSrcweir namespace com { namespace sun { namespace star { 30cdf0e10cSrcweir namespace lang { 31cdf0e10cSrcweir class XMultiServiceFactory; 32cdf0e10cSrcweir } 33cdf0e10cSrcweir namespace beans { 34cdf0e10cSrcweir class XPropertySet; 35cdf0e10cSrcweir } 36cdf0e10cSrcweir } } } 37cdf0e10cSrcweir 38cdf0e10cSrcweir class Window; 39cdf0e10cSrcweir 40cdf0e10cSrcweir //......................................................................... 41cdf0e10cSrcweir namespace abp 42cdf0e10cSrcweir { 43cdf0e10cSrcweir //......................................................................... 44cdf0e10cSrcweir 45cdf0e10cSrcweir //===================================================================== 46cdf0e10cSrcweir //= ODataSourceContext 47cdf0e10cSrcweir //===================================================================== 48cdf0e10cSrcweir struct ODataSourceContextImpl; 49cdf0e10cSrcweir class ODataSource; 50*7dbe28d4SMatthias Seidel // an non-UNO wrapper for the data source context 51cdf0e10cSrcweir class ODataSourceContext 52cdf0e10cSrcweir { 53cdf0e10cSrcweir private: 54cdf0e10cSrcweir ODataSourceContextImpl* m_pImpl; 55cdf0e10cSrcweir 56cdf0e10cSrcweir public: 57cdf0e10cSrcweir ODataSourceContext( 58cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB 59cdf0e10cSrcweir ); 60cdf0e10cSrcweir 61*7dbe28d4SMatthias Seidel // retrieves the names of all data sources 62cdf0e10cSrcweir void getDataSourceNames( StringBag& _rNames ) const SAL_THROW (( )); 63cdf0e10cSrcweir 64*7dbe28d4SMatthias Seidel // disambiguate the given name by appending successive numbers 65cdf0e10cSrcweir ::rtl::OUString& disambiguate(::rtl::OUString& _rDataSourceName); 66cdf0e10cSrcweir 67*7dbe28d4SMatthias Seidel // creates a new Thunderbird data source 68cdf0e10cSrcweir ODataSource createNewThunderbird( const ::rtl::OUString& _rName ) SAL_THROW (( )); 69cdf0e10cSrcweir 70*7dbe28d4SMatthias Seidel // creates a new Evolution local data source 71cdf0e10cSrcweir ODataSource createNewEvolution( const ::rtl::OUString& _rName ) SAL_THROW (( )); 72cdf0e10cSrcweir 73*7dbe28d4SMatthias Seidel // creates a new Evolution LDAP data source 74cdf0e10cSrcweir ODataSource createNewEvolutionLdap( const ::rtl::OUString& _rName ) SAL_THROW (( )); 75cdf0e10cSrcweir 76*7dbe28d4SMatthias Seidel // creates a new Evolution GROUPWISE data source 77cdf0e10cSrcweir ODataSource createNewEvolutionGroupwise( const ::rtl::OUString& _rName ) SAL_THROW (( )); 78cdf0e10cSrcweir 79*7dbe28d4SMatthias Seidel // creates a new KDE address book data source 80cdf0e10cSrcweir ODataSource createNewKab( const ::rtl::OUString& _rName ) SAL_THROW (( )); 81cdf0e10cSrcweir 82*7dbe28d4SMatthias Seidel // creates a new macOS address book data source 83cdf0e10cSrcweir ODataSource createNewMacab( const ::rtl::OUString& _rName ) SAL_THROW (( )); 84cdf0e10cSrcweir 85*7dbe28d4SMatthias Seidel // creates a new LDAP data source 86cdf0e10cSrcweir ODataSource createNewLDAP( const ::rtl::OUString& _rName ) SAL_THROW (( )); 87cdf0e10cSrcweir 88*7dbe28d4SMatthias Seidel // creates a new Outlook data source 89cdf0e10cSrcweir ODataSource createNewOutlook( const ::rtl::OUString& _rName ) SAL_THROW (( )); 90cdf0e10cSrcweir 91*7dbe28d4SMatthias Seidel // creates a new Outlook express data source 92cdf0e10cSrcweir ODataSource createNewOE( const ::rtl::OUString& _rName ) SAL_THROW (( )); 93cdf0e10cSrcweir 94*7dbe28d4SMatthias Seidel // creates a new dBASE data source 95cdf0e10cSrcweir ODataSource createNewDBase( const ::rtl::OUString& _rName ) SAL_THROW (( )); 96cdf0e10cSrcweir }; 97cdf0e10cSrcweir 98cdf0e10cSrcweir //===================================================================== 99cdf0e10cSrcweir //= ODataSource 100cdf0e10cSrcweir //===================================================================== 101cdf0e10cSrcweir struct ODataSourceImpl; 102cdf0e10cSrcweir struct PackageAccessControl; 103cdf0e10cSrcweir /** a non-UNO wrapper for a data source 104cdf0e10cSrcweir <p>This class allows to access data sources without the need to compile the respective file with 105cdf0e10cSrcweir exception handling enabled (hopefully :).</p> 106cdf0e10cSrcweir <p>In addition to wrapping an UNO data source, an instance of this class can handle at most 107cdf0e10cSrcweir one valid connection, as obtained from the data source.</p> 108cdf0e10cSrcweir */ 109cdf0e10cSrcweir class ODataSource 110cdf0e10cSrcweir { 111cdf0e10cSrcweir private: 112cdf0e10cSrcweir ODataSourceImpl* m_pImpl; 113cdf0e10cSrcweir 114cdf0e10cSrcweir public: 115cdf0e10cSrcweir // ---------------------------------------------------------------- 116cdf0e10cSrcweir // - ctor/dtor/assignment 117cdf0e10cSrcweir // ---------------------------------------------------------------- 118*7dbe28d4SMatthias Seidel // constructs an object which is initially invalid 119cdf0e10cSrcweir ODataSource( 120cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB 121cdf0e10cSrcweir ); 122cdf0e10cSrcweir 123*7dbe28d4SMatthias Seidel // copy ctor 124cdf0e10cSrcweir ODataSource( const ODataSource& _rSource ); 125cdf0e10cSrcweir 126*7dbe28d4SMatthias Seidel // dtor 127cdf0e10cSrcweir ~ODataSource( ); 128cdf0e10cSrcweir 129*7dbe28d4SMatthias Seidel // assignment 130cdf0e10cSrcweir ODataSource& operator=( const ODataSource& _rSource ); 131cdf0e10cSrcweir 132cdf0e10cSrcweir // ---------------------------------------------------------------- 133*7dbe28d4SMatthias Seidel // checks whether or not the object represents a valid data source 134cdf0e10cSrcweir sal_Bool isValid() const SAL_THROW (( )); 135cdf0e10cSrcweir 136cdf0e10cSrcweir // ---------------------------------------------------------------- 137*7dbe28d4SMatthias Seidel // removes the data source represented by the object from the data source context 138cdf0e10cSrcweir void remove() SAL_THROW (( )); 139cdf0e10cSrcweir // TODO: put this into the context class 140cdf0e10cSrcweir 141*7dbe28d4SMatthias Seidel // returns the name of the data source 142cdf0e10cSrcweir ::rtl::OUString 143cdf0e10cSrcweir getName() const SAL_THROW (( )); 144cdf0e10cSrcweir 145*7dbe28d4SMatthias Seidel // renames the data source 146cdf0e10cSrcweir sal_Bool rename( const ::rtl::OUString& _rName ) SAL_THROW (( )); 147cdf0e10cSrcweir // TODO: put this into the context class 148cdf0e10cSrcweir 149cdf0e10cSrcweir // ---------------------------------------------------------------- 150cdf0e10cSrcweir // - connection handling 151cdf0e10cSrcweir // ---------------------------------------------------------------- 152cdf0e10cSrcweir /** connects to the data source represented by this object 153cdf0e10cSrcweir @param _pMessageParent 154cdf0e10cSrcweir the window to use as parent for any error messages. If this is <NULL/>, no messages are displayed 155cdf0e10cSrcweir at all. 156cdf0e10cSrcweir @see isConnected 157cdf0e10cSrcweir */ 158cdf0e10cSrcweir sal_Bool connect( Window* _pMessageParent ) SAL_THROW (( )); 159cdf0e10cSrcweir 160*7dbe28d4SMatthias Seidel // returns <TRUE/> if the object has a valid connection, obtained from its data source 161cdf0e10cSrcweir sal_Bool isConnected( ) const SAL_THROW (( )); 162cdf0e10cSrcweir 163*7dbe28d4SMatthias Seidel // disconnects from the data source (i.e. disposes the UNO connection hold internally) 164cdf0e10cSrcweir void disconnect( ) SAL_THROW (( )); 165cdf0e10cSrcweir 166*7dbe28d4SMatthias Seidel // stores the database file 167cdf0e10cSrcweir void store() SAL_THROW (( )); 168cdf0e10cSrcweir 169*7dbe28d4SMatthias Seidel // register the data source under the given name in the configuration 170cdf0e10cSrcweir void registerDataSource( const ::rtl::OUString& _sRegisteredDataSourceName ) SAL_THROW (( )); 171cdf0e10cSrcweir 172cdf0e10cSrcweir // ---------------------------------------------------------------- 173cdf0e10cSrcweir /** retrieves the tables names from the connection 174cdf0e10cSrcweir <p>to be called when <method>isConnection</method> returns <TRUE/> only</p> 175cdf0e10cSrcweir */ 176cdf0e10cSrcweir const StringBag& getTableNames() const SAL_THROW (( )); 177cdf0e10cSrcweir 178cdf0e10cSrcweir /** determines whether a given table exists 179cdf0e10cSrcweir */ 180cdf0e10cSrcweir bool hasTable( const ::rtl::OUString& _rTableName ) const; 181cdf0e10cSrcweir 182*7dbe28d4SMatthias Seidel // return the intern data source object 183cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDataSource() const SAL_THROW (( )); 184cdf0e10cSrcweir 185cdf0e10cSrcweir 186cdf0e10cSrcweir // ---------------------------------------------------------------- 187cdf0e10cSrcweir /** set a new data source. 188cdf0e10cSrcweir <p>Available to selected clients only</p> 189cdf0e10cSrcweir */ 190cdf0e10cSrcweir void setDataSource( 191cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDS 192cdf0e10cSrcweir ,const ::rtl::OUString& _sName 193cdf0e10cSrcweir ,PackageAccessControl 194cdf0e10cSrcweir ); 195cdf0e10cSrcweir 196cdf0e10cSrcweir private: 197cdf0e10cSrcweir ODataSource( ); // never implemented 198cdf0e10cSrcweir }; 199cdf0e10cSrcweir 200cdf0e10cSrcweir //......................................................................... 201cdf0e10cSrcweir } // namespace abp 202cdf0e10cSrcweir //......................................................................... 203cdf0e10cSrcweir 204cdf0e10cSrcweir #endif // EXTENSIONS_ABP_DATASOURCEHANDLING_HXX 205*7dbe28d4SMatthias Seidel 206*7dbe28d4SMatthias Seidel /* vim: set noet sw=4 ts=4: */ 207