1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED 24 #define CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED 25 26 #include <comphelper/stl_types.hxx> 27 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 28 #include <com/sun/star/beans/NamedValue.hpp> 29 #include <com/sun/star/uno/Sequence.h> 30 #include "connectivity/dbtoolsdllapi.hxx" 31 #include <salhelper/singletonref.hxx> 32 #include <comphelper/namedvaluecollection.hxx> 33 #include <unotools/confignode.hxx> 34 35 namespace connectivity 36 { 37 typedef struct 38 { 39 ::comphelper::NamedValueCollection aProperties; 40 ::comphelper::NamedValueCollection aFeatures; 41 ::comphelper::NamedValueCollection aMetaData; 42 ::rtl::OUString sDriverFactory; 43 ::rtl::OUString sDriverTypeDisplayName; 44 } TInstalledDriver; 45 DECLARE_STL_USTRINGACCESS_MAP( TInstalledDriver, TInstalledDrivers); 46 47 class DriversConfigImpl 48 { 49 mutable ::utl::OConfigurationTreeRoot m_aInstalled; 50 mutable TInstalledDrivers m_aDrivers; 51 void Load(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB) const; 52 public: 53 DriversConfigImpl(); 54 getInstalledDrivers(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & _rxORB) const55 const TInstalledDrivers& getInstalledDrivers(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB) const { Load(_rxORB); return m_aDrivers; } 56 }; 57 // 58 // Allows to access all driver which are located in the configuration 59 // 60 class OOO_DLLPUBLIC_DBTOOLS DriversConfig 61 { 62 typedef salhelper::SingletonRef<DriversConfigImpl> OSharedConfigNode; 63 64 const ::comphelper::NamedValueCollection& impl_get(const ::rtl::OUString& _sURL,sal_Int32 _nProps) const; 65 public: 66 DriversConfig(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); 67 ~DriversConfig(); 68 69 DriversConfig( const DriversConfig& ); 70 DriversConfig& operator=( const DriversConfig& ); 71 72 ::rtl::OUString getDriverFactoryName(const ::rtl::OUString& _sUrl) const; 73 ::rtl::OUString getDriverTypeDisplayName(const ::rtl::OUString& _sUrl) const; 74 const ::comphelper::NamedValueCollection& getProperties(const ::rtl::OUString& _sURL) const; 75 const ::comphelper::NamedValueCollection& getFeatures(const ::rtl::OUString& _sURL) const; 76 const ::comphelper::NamedValueCollection& getMetaData(const ::rtl::OUString& _sURL) const; 77 ::com::sun::star::uno::Sequence< ::rtl::OUString > getURLs() const; 78 private: 79 OSharedConfigNode m_aNode; 80 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; 81 }; 82 } 83 #endif // CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED 84