update emoji autocorrect entries from po-files
[LibreOffice.git] / connectivity / source / drivers / mozab / MConnection.hxx
blobec7d017b6a448fe0d7b6d71cad18578f59449512
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 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCONNECTION_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCONNECTION_HXX
23 #include <connectivity/CommonTools.hxx>
25 #include "MCatalog.hxx"
26 #include "MColumnAlias.hxx"
27 #include <connectivity/OSubComponent.hxx>
28 #include "TConnection.hxx"
30 #include <com/sun/star/beans/PropertyValue.hpp>
31 #include <com/sun/star/mozilla/MozillaProductType.hpp>
32 #include <com/sun/star/sdbc/SQLWarning.hpp>
33 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
35 #include <cppuhelper/weakref.hxx>
37 #include <memory>
39 namespace connectivity
41 namespace mozab
44 class MozabDriver;
45 class MNameMapper;
46 class ErrorDescriptor;
48 namespace SDBCAddress {
49 typedef enum {
50 Unknown = 0,
51 Mozilla = 1,
52 ThunderBird = 2,
53 LDAP = 3,
54 Outlook = 4,
55 OutlookExp = 5
56 } sdbc_address_type;
59 // For the moment, we will connect the Mozilla address book to the Mozilla
60 // top-level address book which will display whatever is in the preferences
61 // file of Mozilla.
62 enum MozillaScheme
64 // This one is a base uri which will be completed with the connection data.
65 SCHEME_MOZILLA,
66 // This one is for mozilla native address book
67 SCHEME_MOZILLA_MDB,
68 // This one is for LDAP address book
69 SCHEME_LDAP,
70 // These two uris will be used to obtain directory factories to access all
71 // address books of the given type.
72 SCHEME_OUTLOOK_MAPI,
73 SCHEME_OUTLOOK_EXPRESS
75 const sal_Char* getSchemeURI( MozillaScheme _eScheme );
77 enum SdbcScheme
79 SDBC_MOZILLA,
80 SDBC_THUNDERBIRD,
81 SDBC_LDAP,
82 SDBC_OUTLOOK_MAPI,
83 SDBC_OUTLOOK_EXPRESS
85 #ifdef __MINGW32__
86 extern "C"
87 #endif
88 const sal_Char* getSdbcScheme( SdbcScheme _eScheme );
90 typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding
92 struct ConnectionImplData;
93 class OConnection : public OConnection_BASE,
94 public connectivity::OSubComponent<OConnection, OConnection_BASE>
96 friend class connectivity::OSubComponent<OConnection, OConnection_BASE>;
98 protected:
100 // Data attributes
102 ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by
103 // an operation
104 MozabDriver* m_pDriver; // Pointer to the owning
105 // driver object
106 ::std::unique_ptr< ConnectionImplData > m_pImplData;
107 // This is to be able to hold a boost::shared_ptr. If we would hold it as member, it would
108 // not compile the mozillasrc directory, since this directory is compiled without RTTI support
109 // and boost seems to require RTTI on some platforms.
110 // Store Catalog
111 ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog;
112 // Start of Additions from the land of mozilla
113 OColumnAlias m_aColumnAlias;
114 OUString m_sMozillaURI;
115 OUString m_sMozillaProfile;
116 sal_Int32 m_nMaxResultRecords;
117 MNameMapper* m_aNameMapper;
118 //LDAP only
119 OUString m_sHostName;
120 sal_Bool m_bUseSSL;
121 OUString m_sBindDN;
122 OUString m_sUser; // the user name
123 OUString m_sPassword;
125 SDBCAddress::sdbc_address_type m_eSDBCAddressType;
127 sal_Bool m_bForceLoadTable;
129 public:
130 virtual void construct( const OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
131 OConnection(MozabDriver* _pDriver);
132 virtual ~OConnection();
134 void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
136 // OComponentHelper
137 virtual void SAL_CALL disposing();
138 // XInterface
139 virtual void SAL_CALL release() throw();
141 // XServiceInfo
142 DECLARE_SERVICE_INFO();
143 // XConnection
144 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);
145 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
146 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
147 virtual OUString SAL_CALL nativeSQL( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
148 virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
149 virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
150 virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
151 virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
152 virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
153 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);
154 virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
155 virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
156 virtual void SAL_CALL setCatalog( const OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
157 virtual OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
158 virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
159 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
160 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);
161 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);
162 // XCloseable
163 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
164 // XWarningsSupplier
165 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
166 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
168 MozabDriver* getDriver() const { return m_pDriver;}
170 // Added to enable me to use SQLInterpreter which requires an
171 // XNameAccess i/f to access tables.
172 ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog();
175 // Additions from the land of mozilla
176 OUString getMozURI() const { return m_sMozillaURI; }
177 OUString getMozProfile() const { return m_sMozillaProfile; }
178 void setMozProfile(OUString &aNewProfile) { m_sMozillaProfile = aNewProfile; }
180 ::com::sun::star::mozilla::MozillaProductType getProduct()
182 if (m_eSDBCAddressType == SDBCAddress::ThunderBird)
183 return ::com::sun::star::mozilla::MozillaProductType_Thunderbird;
184 return ::com::sun::star::mozilla::MozillaProductType_Mozilla;
187 // Get Ldap BindDN (user name)
188 OUString getBindDN() const { return m_sBindDN; }
189 // Get Ldap Password
190 OUString getPassword() const { return m_sPassword; }
191 // Get Ldap Host name
192 OUString getHost() const { return m_sHostName; }
193 // Get whether use ssl to connect to ldap
194 sal_Bool getUseSSL() const {return m_bUseSSL;}
196 sal_Bool usesFactory() const { return (m_eSDBCAddressType == SDBCAddress::Outlook) || (m_eSDBCAddressType == SDBCAddress::OutlookExp); }
197 sal_Bool isLDAP() const { return m_eSDBCAddressType == SDBCAddress::LDAP; }
198 sal_Bool isThunderbird() const { return m_eSDBCAddressType == SDBCAddress::ThunderBird; }
200 sal_Bool isOutlookExpress() const { return m_eSDBCAddressType == SDBCAddress::OutlookExp;}
201 sal_Int32 getMaxResultRecords() const { return m_nMaxResultRecords; }
203 SDBCAddress::sdbc_address_type getSDBCAddressType() const { return m_eSDBCAddressType;}
205 const OColumnAlias & getColumnAlias() const { return m_aColumnAlias; }
207 static OUString getDriverImplementationName();
209 MNameMapper* getNameMapper();
210 void setForceLoadTables(sal_Bool aForce){ m_bForceLoadTable = aForce;}
211 sal_Bool getForceLoadTables() { return m_bForceLoadTable;}
213 void throwSQLException( const ErrorDescriptor& _rError, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
214 void throwSQLException( const sal_uInt16 _nErrorResourceId, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
216 private:
217 // make this private - clients should use throwSQLException instead
218 using OConnection_BASE::throwGenericSQLException;
223 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MCONNECTION_HXX
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */