1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "NConnection.hxx"
21 #include "NDatabaseMetaData.hxx"
22 #include "NCatalog.hxx"
23 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
24 #include "NPreparedStatement.hxx"
25 #include "NStatement.hxx"
26 #include <connectivity/dbexception.hxx>
27 #include <rtl/ref.hxx>
28 #include <rtl/ustring.hxx>
29 #include <sal/log.hxx>
31 using namespace connectivity::evoab
;
32 using namespace dbtools
;
35 using namespace ::com::sun::star::uno
;
36 using namespace ::com::sun::star::beans
;
37 using namespace ::com::sun::star::sdbcx
;
38 using namespace ::com::sun::star::sdbc
;
39 using namespace ::com::sun::star::lang
;
41 OEvoabConnection::OEvoabConnection(OEvoabDriver
const & _rDriver
)
43 , m_eSDBCAddressType(SDBCAddress::EVO_LOCAL
)
47 OEvoabConnection::~OEvoabConnection()
49 ::osl::MutexGuard
aGuard( m_aMutex
);
60 IMPLEMENT_SERVICE_INFO(OEvoabConnection
, "com.sun.star.sdbc.drivers.evoab.Connection", "com.sun.star.sdbc.Connection")
63 void OEvoabConnection::construct(const OUString
& url
, const Sequence
< PropertyValue
>& info
)
65 osl_atomic_increment( &m_refCount
);
66 SAL_INFO("connectivity.evoab2", "OEvoabConnection::construct()::url = " << url
);
69 const char pPwd
[] = "password";
71 const PropertyValue
*pIter
= info
.getConstArray();
72 const PropertyValue
*pEnd
= pIter
+ info
.getLength();
73 for(;pIter
!= pEnd
;++pIter
)
75 if(pIter
->Name
== pPwd
)
77 pIter
->Value
>>= sPassword
;
82 if ( url
== "sdbc:address:evolution:groupwise" )
83 setSDBCAddressType(SDBCAddress::EVO_GWISE
);
84 else if ( url
== "sdbc:address:evolution:ldap" )
85 setSDBCAddressType(SDBCAddress::EVO_LDAP
);
87 setSDBCAddressType(SDBCAddress::EVO_LOCAL
);
89 setPassword(OUStringToOString(sPassword
,RTL_TEXTENCODING_UTF8
));
90 osl_atomic_decrement( &m_refCount
);
94 OUString SAL_CALL
OEvoabConnection::nativeSQL( const OUString
& _sSql
)
96 // when you need to transform SQL92 to you driver specific you can do it here
100 Reference
< XDatabaseMetaData
> SAL_CALL
OEvoabConnection::getMetaData( )
102 ::osl::MutexGuard
aGuard( m_aMutex
);
103 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
105 Reference
< XDatabaseMetaData
> xMetaData
= m_xMetaData
;
108 xMetaData
= new OEvoabDatabaseMetaData(this);
109 m_xMetaData
= xMetaData
;
115 css::uno::Reference
< XTablesSupplier
> OEvoabConnection::createCatalog()
117 ::osl::MutexGuard
aGuard( m_aMutex
);
118 Reference
< XTablesSupplier
> xTab
= m_xCatalog
;
121 xTab
= new OEvoabCatalog(this);
127 Reference
< XStatement
> SAL_CALL
OEvoabConnection::createStatement( )
129 ::osl::MutexGuard
aGuard( m_aMutex
);
130 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
132 Reference
< XStatement
> xStmt
= new OStatement(this);
133 m_aStatements
.push_back(WeakReferenceHelper(xStmt
));
137 Reference
< XPreparedStatement
> SAL_CALL
OEvoabConnection::prepareStatement( const OUString
& sql
)
139 ::osl::MutexGuard
aGuard( m_aMutex
);
140 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
142 rtl::Reference
<OEvoabPreparedStatement
> pStmt
= new OEvoabPreparedStatement( this );
143 pStmt
->construct( sql
);
145 m_aStatements
.push_back(WeakReferenceHelper(*pStmt
));
149 Reference
< XPreparedStatement
> SAL_CALL
OEvoabConnection::prepareCall( const OUString
& /*sql*/ )
151 ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::prepareCall", *this );
154 sal_Bool SAL_CALL
OEvoabConnection::isClosed( )
156 ::osl::MutexGuard
aGuard( m_aMutex
);
157 return OConnection_BASE::rBHelper
.bDisposed
;
162 void SAL_CALL
OEvoabConnection::close( )
164 { // we just dispose us
165 ::osl::MutexGuard
aGuard( m_aMutex
);
166 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
173 Any SAL_CALL
OEvoabConnection::getWarnings( )
175 return m_aWarnings
.getWarnings();
177 void SAL_CALL
OEvoabConnection::clearWarnings( )
179 m_aWarnings
.clearWarnings();
183 void OEvoabConnection::disposing()
185 // we noticed that we should be destroyed in near future so we have to dispose our statements
186 ::osl::MutexGuard
aGuard(m_aMutex
);
187 OConnection_BASE::disposing();
190 // -------------------------------- stubbed methods ------------------------------------------------
191 void SAL_CALL
OEvoabConnection::setAutoCommit( sal_Bool
/*autoCommit*/ )
193 ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setAutoCommit", *this );
195 sal_Bool SAL_CALL
OEvoabConnection::getAutoCommit( )
199 void SAL_CALL
OEvoabConnection::commit( )
202 void SAL_CALL
OEvoabConnection::rollback( )
205 void SAL_CALL
OEvoabConnection::setReadOnly( sal_Bool
/*readOnly*/ )
207 ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setReadOnly", *this );
209 sal_Bool SAL_CALL
OEvoabConnection::isReadOnly( )
213 void SAL_CALL
OEvoabConnection::setCatalog( const OUString
& /*catalog*/ )
215 ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setCatalog", *this );
218 OUString SAL_CALL
OEvoabConnection::getCatalog( )
222 void SAL_CALL
OEvoabConnection::setTransactionIsolation( sal_Int32
/*level*/ )
224 ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setTransactionIsolation", *this );
227 sal_Int32 SAL_CALL
OEvoabConnection::getTransactionIsolation( )
229 return TransactionIsolation::NONE
;
232 Reference
< css::container::XNameAccess
> SAL_CALL
OEvoabConnection::getTypeMap( )
234 ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::getTypeMap", *this );
237 void SAL_CALL
OEvoabConnection::setTypeMap( const Reference
< css::container::XNameAccess
>& /*typeMap*/ )
239 ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setTypeMap", *this );
242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */