Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / mozab / MConnection.hxx
blob739feb46f11225daa385d4741443d5b36a4ace27
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef CONNECTIVITY_SCONNECTION_HXX
29 #define CONNECTIVITY_SCONNECTION_HXX
31 #include "connectivity/CommonTools.hxx"
33 #include "MCatalog.hxx"
34 #include "MColumnAlias.hxx"
35 #include "connectivity/OSubComponent.hxx"
36 #include "TConnection.hxx"
38 #include <com/sun/star/beans/PropertyValue.hpp>
39 #include <com/sun/star/mozilla/MozillaProductType.hpp>
40 #include <com/sun/star/sdbc/SQLWarning.hpp>
41 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
43 #include <cppuhelper/weakref.hxx>
45 #include <memory>
47 namespace connectivity
49 namespace mozab
52 class MozabDriver;
53 class ODatabaseMetaData;
54 class MNameMapper;
55 class ErrorDescriptor;
57 namespace SDBCAddress {
58 typedef enum {
59 Unknown = 0,
60 Mozilla = 1,
61 ThunderBird = 2,
62 LDAP = 3,
63 Outlook = 4,
64 OutlookExp = 5
65 } sdbc_address_type;
68 // For the moment, we will connect the Mozilla address book to the Mozilla
69 // top-level address book which will display whatever is in the preferences
70 // file of Mozilla.
71 enum MozillaScheme
73 // This one is a base uri which will be completed with the connection data.
74 SCHEME_MOZILLA,
75 // This one is for mozilla native address book
76 SCHEME_MOZILLA_MDB,
77 // This one is for LDAP address book
78 SCHEME_LDAP,
79 // These two uris will be used to obtain directory factories to access all
80 // address books of the given type.
81 SCHEME_OUTLOOK_MAPI,
82 SCHEME_OUTLOOK_EXPRESS
84 const sal_Char* getSchemeURI( MozillaScheme _eScheme );
86 enum SdbcScheme
88 SDBC_MOZILLA,
89 SDBC_THUNDERBIRD,
90 SDBC_LDAP,
91 SDBC_OUTLOOK_MAPI,
92 SDBC_OUTLOOK_EXPRESS
94 #ifdef __MINGW32__
95 extern "C"
96 #endif
97 const sal_Char* getSdbcScheme( SdbcScheme _eScheme );
99 typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding
101 struct ConnectionImplData;
102 class OConnection : public OConnection_BASE,
103 public connectivity::OSubComponent<OConnection, OConnection_BASE>
105 friend class connectivity::OSubComponent<OConnection, OConnection_BASE>;
107 protected:
108 //====================================================================
109 // Data attributes
110 //====================================================================
111 ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by
112 // an operation
113 MozabDriver* m_pDriver; // Pointer to the owning
114 // driver object
115 ::std::auto_ptr< ConnectionImplData > m_pImplData;
116 // This is to be able to hold a boost::shared_ptr. If we would hold it as member, it would
117 // not compile the mozillasrc directory, since this directory is compiled without RTTI support
118 // and boost seems to require RTTI on some platforms.
119 // Store Catalog
120 ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog;
121 // Start of Additions from the land of mozilla
122 OColumnAlias m_aColumnAlias;
123 rtl::OUString m_sMozillaURI;
124 rtl::OUString m_sMozillaProfile;
125 sal_Int32 m_nMaxResultRecords;
126 MNameMapper* m_aNameMapper;
127 //LDAP only
128 rtl::OUString m_sHostName;
129 sal_Bool m_bUseSSL;
130 rtl::OUString m_sBindDN;
131 rtl::OUString m_sUser; // the user name
132 rtl::OUString m_sPassword;
134 SDBCAddress::sdbc_address_type m_eSDBCAddressType;
136 sal_Bool m_bForceLoadTable;
138 public:
139 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);
140 OConnection(MozabDriver* _pDriver);
141 virtual ~OConnection();
143 void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
145 // OComponentHelper
146 virtual void SAL_CALL disposing(void);
147 // XInterface
148 virtual void SAL_CALL release() throw();
150 // XServiceInfo
151 DECLARE_SERVICE_INFO();
152 // XConnection
153 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);
154 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);
155 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);
156 virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
157 virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
158 virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
159 virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
160 virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
161 virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
162 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);
163 virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
164 virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
165 virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
166 virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
167 virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
168 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
169 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);
170 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);
171 // XCloseable
172 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
173 // XWarningsSupplier
174 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
175 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
177 MozabDriver* getDriver() const { return m_pDriver;}
179 // Added to enable me to use SQLInterpreter which requires an
180 // XNameAccess i/f to access tables.
181 ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog();
184 // Additions from the land of mozilla
185 rtl::OUString getMozURI() const { return m_sMozillaURI; }
186 rtl::OUString getMozProfile() const { return m_sMozillaProfile; }
187 void setMozProfile(rtl::OUString &aNewProfile) { m_sMozillaProfile = aNewProfile; }
189 ::com::sun::star::mozilla::MozillaProductType getProduct()
191 if (m_eSDBCAddressType == SDBCAddress::ThunderBird)
192 return ::com::sun::star::mozilla::MozillaProductType_Thunderbird;
193 return ::com::sun::star::mozilla::MozillaProductType_Mozilla;
196 // Get Ldap BindDN (user name)
197 rtl::OUString getBindDN() const { return m_sBindDN; }
198 // Get Ldap Password
199 rtl::OUString getPassword() const { return m_sPassword; }
200 // Get Ldap Host name
201 rtl::OUString getHost() const { return m_sHostName; }
202 // Get whether use ssl to connect to ldap
203 sal_Bool getUseSSL() const {return m_bUseSSL;}
205 sal_Bool usesFactory(void) const { return (m_eSDBCAddressType == SDBCAddress::Outlook) || (m_eSDBCAddressType == SDBCAddress::OutlookExp); }
206 sal_Bool isLDAP(void) const { return m_eSDBCAddressType == SDBCAddress::LDAP; }
207 sal_Bool isThunderbird(void) const { return m_eSDBCAddressType == SDBCAddress::ThunderBird; }
209 sal_Bool isOutlookExpress() const { return m_eSDBCAddressType == SDBCAddress::OutlookExp;}
210 sal_Int32 getMaxResultRecords() const { return m_nMaxResultRecords; }
212 SDBCAddress::sdbc_address_type getSDBCAddressType() const { return m_eSDBCAddressType;}
214 const OColumnAlias & getColumnAlias() const { return (m_aColumnAlias); }
216 static ::rtl::OUString getDriverImplementationName();
218 MNameMapper* getNameMapper();
219 void setForceLoadTables(sal_Bool aForce){ m_bForceLoadTable = aForce;}
220 sal_Bool getForceLoadTables() { return m_bForceLoadTable;}
222 void throwSQLException( const ErrorDescriptor& _rError, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
223 void throwSQLException( const sal_uInt16 _nErrorResourceId, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
225 private:
226 // make this private - clients should use throwSQLException instead
227 using OConnection_BASE::throwGenericSQLException;
231 #endif // CONNECTIVITY_SCONNECTION_HXX
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */