cid#1607171 Data race condition
[LibreOffice.git] / connectivity / source / inc / file / FConnection.hxx
blob344445e9d322886c447843bb0a496b77ca605de7
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 .
19 #pragma once
21 #include <com/sun/star/ucb/XContent.hpp>
22 #include <com/sun/star/beans/PropertyValue.hpp>
23 #include <connectivity/CommonTools.hxx>
24 #include <rtl/ustring.hxx>
25 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
26 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
27 #include <TConnection.hxx>
28 #include <file/filedllapi.hxx>
29 #include <unotools/weakref.hxx>
31 namespace connectivity::sdbcx { class OCatalog; }
33 namespace connectivity::file
35 class ODatabaseMetaData;
36 class OFileDriver;
38 class OOO_DLLPUBLIC_FILE OConnection : public connectivity::OMetaConnection
40 protected:
42 // Data attributes
44 unotools::WeakReference< ::connectivity::sdbcx::OCatalog > m_xCatalog;
46 OUString m_aFilenameExtension;
47 OFileDriver* m_pDriver; // Pointer to the owning
48 // driver object
49 css::uno::Reference< css::ucb::XDynamicResultSet > m_xDir; // directory
50 css::uno::Reference< css::ucb::XContent> m_xContent;
52 bool m_bAutoCommit;
53 bool m_bReadOnly;
54 bool m_bShowDeleted;
55 bool m_bCaseSensitiveExtension;
56 bool m_bCheckSQL92;
57 bool m_bDefaultTextEncoding;
60 void throwUrlNotValid(const OUString & _rsUrl,const OUString & _rsMessage);
62 virtual ~OConnection() override;
63 public:
65 OConnection(OFileDriver* _pDriver);
67 /// @throws css::sdbc::SQLException
68 /// @throws css::uno::RuntimeException
69 /// @throws css::uno::DeploymentException
70 virtual void construct(const OUString& _rUrl, const css::uno::Sequence< css::beans::PropertyValue >& _rInfo );
72 // OComponentHelper
73 virtual void SAL_CALL disposing() override;
75 // XServiceInfo
76 DECLARE_SERVICE_INFO();
78 // XConnection
79 virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) override;
80 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override;
81 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) override;
82 virtual OUString SAL_CALL nativeSQL( const OUString& sql ) override;
83 virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) override;
84 virtual sal_Bool SAL_CALL getAutoCommit( ) override;
85 virtual void SAL_CALL commit( ) override;
86 virtual void SAL_CALL rollback( ) override;
87 virtual sal_Bool SAL_CALL isClosed( ) override final;
88 virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) override;
89 virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) override;
90 virtual sal_Bool SAL_CALL isReadOnly( ) override;
91 virtual void SAL_CALL setCatalog( const OUString& catalog ) override;
92 virtual OUString SAL_CALL getCatalog( ) override;
93 virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) override;
94 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) override;
95 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap( ) override;
96 virtual void SAL_CALL setTypeMap( const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
97 // XCloseable
98 virtual void SAL_CALL close( ) override final;
99 // XWarningsSupplier
100 virtual css::uno::Any SAL_CALL getWarnings( ) override;
101 virtual void SAL_CALL clearWarnings( ) override;
102 //XUnoTunnel
103 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
104 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
106 // no interface methods
107 css::uno::Reference< css::ucb::XDynamicResultSet > getDir() const;
108 const css::uno::Reference< css::ucb::XContent>& getContent() const { return m_xContent; }
109 // create a catalog or return the catalog already created
110 virtual css::uno::Reference< css::sdbcx::XTablesSupplier > createCatalog();
112 bool matchesExtension( const OUString& _rExt ) const;
114 const OUString& getExtension() const { return m_aFilenameExtension; }
115 bool isCaseSensitiveExtension() const { return m_bCaseSensitiveExtension; }
116 OFileDriver* getDriver() const { return m_pDriver; }
117 bool showDeleted() const { return m_bShowDeleted; }
118 bool isCheckEnabled() const { return m_bCheckSQL92; }
119 bool isTextEncodingDefaulted() const { return m_bDefaultTextEncoding; }
121 public:
122 struct GrantAccess
124 friend class ODatabaseMetaData;
125 private:
126 GrantAccess() { }
129 void setCaseSensitiveExtension( bool _bIsCS, GrantAccess ) { m_bCaseSensitiveExtension = _bIsCS; }
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */