1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MConnection.hxx,v $
10 * $Revision: 1.18.56.1 $
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 ************************************************************************/
30 #ifndef CONNECTIVITY_SCONNECTION_HXX
31 #define CONNECTIVITY_SCONNECTION_HXX
33 #include "connectivity/CommonTools.hxx"
35 #include "MCatalog.hxx"
36 #include "MColumnAlias.hxx"
37 #include "OSubComponent.hxx"
38 #include "TConnection.hxx"
40 #include <com/sun/star/beans/PropertyValue.hpp>
41 #include <com/sun/star/mozilla/MozillaProductType.hpp>
42 #include <com/sun/star/sdbc/SQLWarning.hpp>
43 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
45 #include <cppuhelper/weakref.hxx>
49 namespace connectivity
55 class ODatabaseMetaData
;
57 class ErrorDescriptor
;
59 namespace SDBCAddress
{
70 // For the moment, we will connect the Mozilla address book to the Mozilla
71 // top-level address book which will display whatever is in the preferences
75 // This one is a base uri which will be completed with the connection data.
77 // This one is for mozilla native address book
79 // This one is for LDAP address book
81 // These two uris will be used to obtain directory factories to access all
82 // address books of the given type.
84 SCHEME_OUTLOOK_EXPRESS
86 const sal_Char
* getSchemeURI( MozillaScheme _eScheme
);
99 const sal_Char
* getSdbcScheme( SdbcScheme _eScheme
);
101 typedef connectivity::OMetaConnection OConnection_BASE
; // implements basics and text encoding
103 struct ConnectionImplData
;
104 class OConnection
: public OConnection_BASE
,
105 public connectivity::OSubComponent
<OConnection
, OConnection_BASE
>
107 friend class connectivity::OSubComponent
<OConnection
, OConnection_BASE
>;
110 //====================================================================
112 //====================================================================
113 ::com::sun::star::sdbc::SQLWarning m_aLastWarning
; // Last SQLWarning generated by
115 MozabDriver
* m_pDriver
; // Pointer to the owning
117 ::std::auto_ptr
< ConnectionImplData
> m_pImplData
;
118 // This is to be able to hold a boost::shared_ptr. If we would hold it as member, it would
119 // not compile the mozillasrc directory, since this directory is compiled without RTTI support
120 // and boost seems to require RTTI on some platforms.
122 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbcx::XTablesSupplier
> m_xCatalog
;
123 // Start of Additions from the land of mozilla
124 OColumnAlias m_aColumnAlias
;
125 rtl::OUString m_sMozillaURI
;
126 rtl::OUString m_sMozillaProfile
;
127 sal_Int32 m_nMaxResultRecords
;
128 MNameMapper
* m_aNameMapper
;
130 rtl::OUString m_sHostName
;
132 rtl::OUString m_sBindDN
;
133 rtl::OUString m_sUser
; // the user name
134 rtl::OUString m_sPassword
;
136 SDBCAddress::sdbc_address_type m_eSDBCAddressType
;
138 sal_Bool m_bForceLoadTable
;
141 virtual void construct( const ::rtl::OUString
& url
,const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& info
) throw(::com::sun::star::sdbc::SQLException
);
142 OConnection(MozabDriver
* _pDriver
);
143 virtual ~OConnection();
145 void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException
);
148 virtual void SAL_CALL
disposing(void);
150 virtual void SAL_CALL
release() throw();
153 DECLARE_SERVICE_INFO();
155 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XStatement
> SAL_CALL
createStatement( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
156 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XPreparedStatement
> SAL_CALL
prepareStatement( const ::rtl::OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
157 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XPreparedStatement
> SAL_CALL
prepareCall( const ::rtl::OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
158 virtual ::rtl::OUString SAL_CALL
nativeSQL( const ::rtl::OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
159 virtual void SAL_CALL
setAutoCommit( sal_Bool autoCommit
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
160 virtual sal_Bool SAL_CALL
getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
161 virtual void SAL_CALL
commit( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
162 virtual void SAL_CALL
rollback( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
163 virtual sal_Bool SAL_CALL
isClosed( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
164 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
> SAL_CALL
getMetaData( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
165 virtual void SAL_CALL
setReadOnly( sal_Bool readOnly
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
166 virtual sal_Bool SAL_CALL
isReadOnly( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
167 virtual void SAL_CALL
setCatalog( const ::rtl::OUString
& catalog
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
168 virtual ::rtl::OUString SAL_CALL
getCatalog( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
169 virtual void SAL_CALL
setTransactionIsolation( sal_Int32 level
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
170 virtual sal_Int32 SAL_CALL
getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
171 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getTypeMap( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
172 virtual void SAL_CALL
setTypeMap( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& typeMap
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
174 virtual void SAL_CALL
close( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
176 virtual ::com::sun::star::uno::Any SAL_CALL
getWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
177 virtual void SAL_CALL
clearWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
179 MozabDriver
* getDriver() const { return m_pDriver
;}
181 // Added to enable me to use SQLInterpreter which requires an
182 // XNameAccess i/f to access tables.
183 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbcx::XTablesSupplier
> SAL_CALL
createCatalog();
186 // Additions from the land of mozilla
187 rtl::OUString
getMozURI() const { return m_sMozillaURI
; }
188 rtl::OUString
getMozProfile() const { return m_sMozillaProfile
; }
189 void setMozProfile(rtl::OUString
&aNewProfile
) { m_sMozillaProfile
= aNewProfile
; }
191 ::com::sun::star::mozilla::MozillaProductType
getProduct()
193 if (m_eSDBCAddressType
== SDBCAddress::ThunderBird
)
194 return ::com::sun::star::mozilla::MozillaProductType_Thunderbird
;
195 return ::com::sun::star::mozilla::MozillaProductType_Mozilla
;
198 // Get Ldap BindDN (user name)
199 rtl::OUString
getBindDN() const { return m_sBindDN
; }
201 rtl::OUString
getPassword() const { return m_sPassword
; }
202 // Get Ldap Host name
203 rtl::OUString
getHost() const { return m_sHostName
; }
204 // Get whether use ssl to connect to ldap
205 sal_Bool
getUseSSL() const {return m_bUseSSL
;}
207 sal_Bool
usesFactory(void) const { return (m_eSDBCAddressType
== SDBCAddress::Outlook
) || (m_eSDBCAddressType
== SDBCAddress::OutlookExp
); }
208 sal_Bool
isLDAP(void) const { return m_eSDBCAddressType
== SDBCAddress::LDAP
; }
209 sal_Bool
isThunderbird(void) const { return m_eSDBCAddressType
== SDBCAddress::ThunderBird
; }
211 sal_Bool
isOutlookExpress() const { return m_eSDBCAddressType
== SDBCAddress::OutlookExp
;}
212 sal_Int32
getMaxResultRecords() const { return m_nMaxResultRecords
; }
214 SDBCAddress::sdbc_address_type
getSDBCAddressType() const { return m_eSDBCAddressType
;}
216 const OColumnAlias
& getColumnAlias() const { return (m_aColumnAlias
); }
218 static ::rtl::OUString
getDriverImplementationName();
220 MNameMapper
* getNameMapper();
221 void setForceLoadTables(sal_Bool aForce
){ m_bForceLoadTable
= aForce
;}
222 sal_Bool
getForceLoadTables() { return m_bForceLoadTable
;}
224 void throwSQLException( const ErrorDescriptor
& _rError
, const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxContext
);
225 void throwSQLException( const sal_uInt16 _nErrorResourceId
, const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxContext
);
228 // make this private - clients should use throwSQLException instead
229 using OConnection_BASE::throwGenericSQLException
;
233 #endif // CONNECTIVITY_SCONNECTION_HXX