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 #ifndef CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED
28 #define CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED
29 
30 #include <comphelper/stl_types.hxx>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/beans/NamedValue.hpp>
33 #include <com/sun/star/uno/Sequence.h>
34 #include "connectivity/dbtoolsdllapi.hxx"
35 #include <salhelper/singletonref.hxx>
36 #include <comphelper/namedvaluecollection.hxx>
37 #include <unotools/confignode.hxx>
38 
39 namespace connectivity
40 {
41     typedef struct
42     {
43         ::comphelper::NamedValueCollection aProperties;
44         ::comphelper::NamedValueCollection aFeatures;
45         ::comphelper::NamedValueCollection aMetaData;
46         ::rtl::OUString sDriverFactory;
47         ::rtl::OUString sDriverTypeDisplayName;
48     } TInstalledDriver;
49     DECLARE_STL_USTRINGACCESS_MAP( TInstalledDriver, TInstalledDrivers);
50 
51     class DriversConfigImpl
52     {
53         mutable ::utl::OConfigurationTreeRoot   m_aInstalled;
54         mutable TInstalledDrivers       m_aDrivers;
55         void Load(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB) const;
56     public:
57         DriversConfigImpl();
58 
59         const TInstalledDrivers& getInstalledDrivers(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB) const { Load(_rxORB); return m_aDrivers; }
60     };
61     //
62     // Allows to access all driver which are located in the configuration
63     //
64     class OOO_DLLPUBLIC_DBTOOLS DriversConfig
65     {
66         typedef salhelper::SingletonRef<DriversConfigImpl> OSharedConfigNode;
67 
68         const ::comphelper::NamedValueCollection& impl_get(const ::rtl::OUString& _sURL,sal_Int32 _nProps) const;
69     public:
70         DriversConfig(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
71         ~DriversConfig();
72 
73         DriversConfig( const DriversConfig& );
74         DriversConfig& operator=( const DriversConfig& );
75 
76         ::rtl::OUString getDriverFactoryName(const ::rtl::OUString& _sUrl) const;
77         ::rtl::OUString getDriverTypeDisplayName(const ::rtl::OUString& _sUrl) const;
78         const ::comphelper::NamedValueCollection& getProperties(const ::rtl::OUString& _sURL) const;
79         const ::comphelper::NamedValueCollection& getFeatures(const ::rtl::OUString& _sURL) const;
80         const ::comphelper::NamedValueCollection& getMetaData(const ::rtl::OUString& _sURL) const;
81         ::com::sun::star::uno::Sequence< ::rtl::OUString > getURLs() const;
82     private:
83         OSharedConfigNode   m_aNode;
84         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
85     };
86 }
87 #endif // CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED
88