bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / source / abpilot / datasourcehandling.hxx
blobf5037915bdf2098059668590b820d19b56aa6192
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_EXTENSIONS_SOURCE_ABPILOT_DATASOURCEHANDLING_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_ABPILOT_DATASOURCEHANDLING_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <memory>
27 #include "abptypes.hxx"
30 namespace com { namespace sun { namespace star {
31 namespace beans {
32 class XPropertySet;
34 } } }
36 namespace weld { class Window; }
39 namespace abp
42 struct ODataSourceContextImpl;
43 class ODataSource;
44 /// a non-UNO wrapper for the data source context
45 class ODataSourceContext
47 private:
48 std::unique_ptr<ODataSourceContextImpl> m_pImpl;
50 public:
51 explicit ODataSourceContext(
52 const css::uno::Reference< css::uno::XComponentContext >& _rxORB
54 ~ODataSourceContext();
56 /// retrieves the names of all data sources
57 void getDataSourceNames( StringBag& _rNames ) const;
59 /// disambiguates the given name by appending successive numbers
60 void disambiguate(OUString& _rDataSourceName);
62 /// creates a new MORK data source
63 ODataSource createNewMORK( const OUString& _rName );
65 /// creates a new Thunderbird data source
66 ODataSource createNewThunderbird( const OUString& _rName );
68 /// creates a new Evolution local data source
69 ODataSource createNewEvolution( const OUString& _rName );
71 /// creates a new Evolution LDAP data source
72 ODataSource createNewEvolutionLdap( const OUString& _rName );
74 /// creates a new Evolution GROUPWISE data source
75 ODataSource createNewEvolutionGroupwise( const OUString& _rName );
77 /// creates a new KDE address book data source
78 ODataSource createNewKab( const OUString& _rName );
80 /// creates a new macOS address book data source
81 ODataSource createNewMacab( const OUString& _rName );
83 /// creates a new dBase data source
84 ODataSource createNewDBase( const OUString& _rName );
87 struct ODataSourceImpl;
88 struct PackageAccessControl;
89 struct AddressSettings;
90 /** a non-UNO wrapper for a data source
91 <p>This class allows to access data sources without the need to compile the respective file with
92 exception handling enabled (hopefully :).</p>
93 <p>In addition to wrapping a UNO data source, an instance of this class can handle at most
94 one valid connection, as obtained from the data source.</p>
96 class ODataSource
98 private:
99 std::unique_ptr<ODataSourceImpl> m_pImpl;
101 public:
103 // - ctor/dtor/assignment
105 /// constructs an object which is initially invalid
106 explicit ODataSource(
107 const css::uno::Reference< css::uno::XComponentContext >& _rxORB
110 /// copy ctor
111 ODataSource( const ODataSource& _rSource );
113 /// dtor
114 ~ODataSource( );
116 /// copy assignment
117 ODataSource& operator=( const ODataSource& _rSource );
119 /// move assignment
120 ODataSource& operator=( ODataSource&& _rSource );
122 /// checks whether or not the object represents a valid data source
123 bool isValid() const;
126 /// removes the data source represented by the object from the data source context
127 void remove();
128 // TODO: put this into the context class
130 /// returns the name of the data source
131 OUString
132 getName() const;
134 /// renames the data source
135 bool rename( const OUString& _rName );
136 // TODO: put this into the context class
139 // - connection handling
141 /** connects to the data source represented by this object
142 @param _pMessageParent
143 the window to use as parent for any error messages. If this is <NULL/>, no messages are displayed
144 at all.
145 @see isConnected
147 bool connect(weld::Window* _pMessageParent);
149 /// returns <TRUE/> if the object has a valid connection, obtained from its data source
150 bool isConnected( ) const;
152 /// disconnects from the data source (i.e. disposes the UNO connection hold internally)
153 void disconnect( );
155 /// stores the database file
156 void store(const AddressSettings& rSettings);
158 /// register the data source under the given name in the configuration
159 void registerDataSource( const OUString& _sRegisteredDataSourceName );
162 /** retrieves the tables names from the connection
163 <p>to be called when <method>isConnected</method> returns <TRUE/> only</p>
165 const StringBag& getTableNames() const;
167 /** determines whether a given table exists
169 bool hasTable( const OUString& _rTableName ) const;
171 /// return the intern data source object
172 css::uno::Reference< css::beans::XPropertySet > getDataSource() const;
175 /** set a new data source.
176 <p>Available to selected clients only</p>
178 void setDataSource(
179 const css::uno::Reference< css::beans::XPropertySet >& _rxDS
180 ,const OUString& _sName
181 ,PackageAccessControl
186 } // namespace abp
189 #endif // INCLUDED_EXTENSIONS_SOURCE_ABPILOT_DATASOURCEHANDLING_HXX
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */