Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / evoab / LConfigAccess.cxx
bloba7441cb0da6ea9491320483045c08b07490791cd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: LConfigAccess.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "LConfigAccess.hxx"
34 #include "LDriver.hxx"
35 #ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
36 #include "LDebug.hxx"
37 #endif
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::beans;
43 //.........................................................................
44 namespace connectivity
46 namespace evoab
48 //-----------------------------------------------------------------
49 Reference< XPropertySet > createDriverConfigNode( Reference< XMultiServiceFactory > _rxORB, ::rtl::OUString _sDriverImplementationName )
51 OSL_TRACE("createDriverConfigNode()entered");
53 Reference< XPropertySet > xNode;
54 try
56 //=============================================================
57 // create the config provider
58 Reference< XMultiServiceFactory > xConfigProvider(
59 _rxORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ) ),
60 UNO_QUERY
62 OSL_ENSURE( xConfigProvider.is(), "createDriverConfigNode: could not create the config provider!" );
64 if ( xConfigProvider.is() )
66 ::rtl::OUString sCompleteNodePath = ::rtl::OUString::createFromAscii ("/org.openoffice.Office.DataAccess/DriverSettings/" );
67 sCompleteNodePath += _sDriverImplementationName;
68 //sCompleteNodePath += OEvoabConnection::getDriverImplementationName();
69 //sCompleteNodePath += ::rtl::OUString::createFromAscii ("com.sun.star.comp.sdbc.MozabDriver");
70 EVO_TRACE_STRING("createDriverConfigNode()::sCompleteNodePath = %s\n", sCompleteNodePath );
72 //=========================================================
73 // arguments for creating the config access
74 Sequence< Any > aArguments(2);
75 // the path to the node to open
76 aArguments[0] <<= PropertyValue(
77 ::rtl::OUString::createFromAscii( "nodepath"),
79 makeAny( sCompleteNodePath ),
80 PropertyState_DIRECT_VALUE
82 // the depth: -1 means unlimited
83 aArguments[1] <<= PropertyValue(
84 ::rtl::OUString::createFromAscii( "depth"),
86 makeAny( (sal_Int32)-1 ),
87 PropertyState_DIRECT_VALUE
90 //=========================================================
91 // create the access
92 Reference< XInterface > xAccess = xConfigProvider->createInstanceWithArguments(
93 ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ),
94 aArguments
96 OSL_ENSURE( xAccess.is(), "createDriverConfigNode: invalid access returned (should throw an exception instead)!" );
98 xNode = xNode.query( xAccess );
101 catch( const Exception& )
103 OSL_ENSURE( sal_False, "createDriverConfigNode: caught an exception while accessing the driver's config node!" );
106 // outta here
107 return xNode;
110 //-----------------------------------------------------------------
111 namespace
113 // a private helper to accessing the point where we store the reference
114 // to the factory
115 Reference< XMultiServiceFactory >& accessFactoryStorage( )
117 static Reference< XMultiServiceFactory > xEvoabServiceFactory;
118 return xEvoabServiceFactory;
122 //-----------------------------------------------------------------
123 void setEvoabServiceFactory( const Reference< XMultiServiceFactory >& _rxFactory )
125 accessFactoryStorage( ) = _rxFactory;
128 //-----------------------------------------------------------------
129 const Reference< XMultiServiceFactory >& getEvoabServiceFactory( )
131 return accessFactoryStorage( );
134 //-----------------------------------------------------------------
135 ::rtl::OUString getFullPathExportingCommand( Reference< XMultiServiceFactory > _rxORB )
137 ::rtl::OUString sFullPathExportingCommand;
139 //Reference< XMultiServiceFactory > xFactory = getEvoabServiceFactory();
140 //OSL_ENSURE( xFactory.is(), "getPreferredProfileName: invalid service factory!" );
141 OSL_ENSURE( _rxORB.is(), "getFullPathExportingCommand: invalid service factory!" );
142 if ( _rxORB.is() )
146 Reference< XPropertySet > xDriverNode = createDriverConfigNode( _rxORB, OEvoabDriver::getImplementationName_Static() );
147 Reference< XPropertySet > xEvoPrefsNode;
148 if ( xDriverNode.is() )
149 xDriverNode->getPropertyValue( ::rtl::OUString::createFromAscii( "EvolutionPreferences" ) ) >>= xEvoPrefsNode;
150 OSL_ENSURE( xEvoPrefsNode.is(), "getFullPathExportingCommand: could not access the node for the evolution preferences!" );
151 if ( xEvoPrefsNode.is() )
152 xEvoPrefsNode->getPropertyValue( ::rtl::OUString::createFromAscii( "FullPathExportingCommand" ) ) >>= sFullPathExportingCommand;
154 catch( const Exception& )
156 OSL_ENSURE( sal_False, "getFullPathExportingCommand: caught an exception!" );
159 return sFullPathExportingCommand;
164 //.........................................................................