bump product version to 7.2.5.1
[LibreOffice.git] / connectivity / source / drivers / evoab2 / NDriver.cxx
blobd1b7746f47c59a6ec266151fa5f9e6a341946d72
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "NDriver.hxx"
21 #include "NConnection.hxx"
22 #include <com/sun/star/lang/DisposedException.hpp>
23 #include <connectivity/dbexception.hxx>
24 #include <cppuhelper/supportsservice.hxx>
25 #include <com/sun/star/ucb/XContentAccess.hpp>
26 #include <rtl/ref.hxx>
27 #include <strings.hrc>
28 #include <resource/sharedresources.hxx>
30 using namespace osl;
31 using namespace connectivity::evoab;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::sdbcx;
35 using namespace ::com::sun::star::sdbc;
36 using namespace ::com::sun::star::lang;
37 using namespace ::com::sun::star::ucb;
40 OEvoabDriver::OEvoabDriver(const Reference< XComponentContext >& _rxContext) :
41 ODriver_BASE( m_aMutex ), m_xContext( _rxContext )
45 OEvoabDriver::~OEvoabDriver()
49 void OEvoabDriver::disposing()
51 ::osl::MutexGuard aGuard(m_aMutex);
53 // when driver will be destroyed so all our connections have to be destroyed as well
54 for (const auto& rxConnection : m_xConnections)
56 Reference< XComponent > xComp(rxConnection.get(), UNO_QUERY);
57 if (xComp.is())
59 try
61 xComp->dispose();
63 catch (const css::lang::DisposedException&)
65 xComp.clear();
69 m_xConnections.clear();
70 connectivity::OWeakRefArray().swap(m_xConnections); // this really clears
72 ODriver_BASE::disposing();
75 // static ServiceInfo
78 OUString SAL_CALL OEvoabDriver::getImplementationName( )
80 return EVOAB_DRIVER_IMPL_NAME;
81 // this name is referenced in the configuration and in the evoab.xml
82 // Please take care when changing it.
85 sal_Bool SAL_CALL OEvoabDriver::supportsService( const OUString& _rServiceName )
87 return cppu::supportsService(this, _rServiceName);
90 Sequence< OUString > SAL_CALL OEvoabDriver::getSupportedServiceNames( )
92 // which service is supported
93 // for more information @see com.sun.star.sdbc.Driver
94 return { "com.sun.star.sdbc.Driver" };
98 Reference< XConnection > SAL_CALL OEvoabDriver::connect( const OUString& url, const Sequence< PropertyValue >& info )
100 ::osl::MutexGuard aGuard( m_aMutex );
101 if (ODriver_BASE::rBHelper.bDisposed)
102 throw DisposedException();
104 if ( ! acceptsURL(url) )
105 return nullptr;
107 rtl::Reference<OEvoabConnection> pCon = new OEvoabConnection( *this );
108 pCon->construct(url,info);
109 m_xConnections.push_back(WeakReferenceHelper(*pCon));
111 return pCon;
114 sal_Bool SAL_CALL OEvoabDriver::acceptsURL( const OUString& url )
116 return acceptsURL_Stat(url);
120 Sequence< DriverPropertyInfo > SAL_CALL OEvoabDriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ )
122 if ( ! acceptsURL(url) )
124 ::connectivity::SharedResources aResources;
125 const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
126 ::dbtools::throwGenericSQLException(sMessage ,*this);
127 } // if ( ! acceptsURL(url) )
129 // if you have something special to say return it here :-)
130 return Sequence< DriverPropertyInfo >();
134 sal_Int32 SAL_CALL OEvoabDriver::getMajorVersion( )
136 return 1;
139 sal_Int32 SAL_CALL OEvoabDriver::getMinorVersion( )
141 return 0;
144 bool OEvoabDriver::acceptsURL_Stat( std::u16string_view url )
146 return ( url == u"sdbc:address:evolution:local" || url == u"sdbc:address:evolution:groupwise" || url == u"sdbc:address:evolution:ldap" ) && EApiInit();
150 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
151 connectivity_OEvoabDriver_get_implementation(
152 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
154 return cppu::acquire(new OEvoabDriver(context));
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */