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