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