2010-10-27 12:45:03 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2001-08-01 10:08:32 +00:00
|
|
|
|
2014-04-18 20:41:29 +02:00
|
|
|
#ifndef INCLUDED_EXTENSIONS_SOURCE_ABPILOT_DATASOURCEHANDLING_HXX
|
|
|
|
#define INCLUDED_EXTENSIONS_SOURCE_ABPILOT_DATASOURCEHANDLING_HXX
|
2001-08-01 10:08:32 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/uno/Reference.hxx>
|
2014-01-02 23:52:37 +01:00
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
2015-11-17 15:40:14 +02:00
|
|
|
#include <memory>
|
2014-01-02 23:52:37 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
#include "abptypes.hxx"
|
|
|
|
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
namespace com { namespace sun { namespace star {
|
|
|
|
namespace beans {
|
|
|
|
class XPropertySet;
|
|
|
|
}
|
|
|
|
} } }
|
|
|
|
|
2018-02-19 16:33:35 +00:00
|
|
|
namespace weld { class Window; }
|
2001-08-01 10:08:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace abp
|
|
|
|
{
|
|
|
|
|
|
|
|
struct ODataSourceContextImpl;
|
|
|
|
class ODataSource;
|
|
|
|
/// a non-UNO wrapper for the data source context
|
|
|
|
class ODataSourceContext
|
|
|
|
{
|
|
|
|
private:
|
2015-11-17 15:40:14 +02:00
|
|
|
std::unique_ptr<ODataSourceContextImpl> m_pImpl;
|
2001-08-01 10:08:32 +00:00
|
|
|
|
|
|
|
public:
|
2015-09-15 10:43:33 +01:00
|
|
|
explicit ODataSourceContext(
|
2015-09-30 11:48:44 +02:00
|
|
|
const css::uno::Reference< css::uno::XComponentContext >& _rxORB
|
2001-08-01 10:08:32 +00:00
|
|
|
);
|
2013-03-12 19:53:39 +01:00
|
|
|
~ODataSourceContext();
|
2001-08-01 10:08:32 +00:00
|
|
|
|
|
|
|
/// retrieves the names of all data sources
|
2014-06-05 08:15:03 +02:00
|
|
|
void getDataSourceNames( StringBag& _rNames ) const;
|
2001-08-01 10:08:32 +00:00
|
|
|
|
2015-06-16 18:21:52 +02:00
|
|
|
/// disambiguates the given name by appending successive numbers
|
2016-01-11 11:54:13 +02:00
|
|
|
void disambiguate(OUString& _rDataSourceName);
|
2001-08-01 10:08:32 +00:00
|
|
|
|
|
|
|
/// creates a new MORK data source
|
2014-06-05 08:15:03 +02:00
|
|
|
ODataSource createNewMORK( const OUString& _rName );
|
2001-08-01 10:08:32 +00:00
|
|
|
|
2005-09-29 09:40:46 +00:00
|
|
|
/// creates a new Thunderbird data source
|
2014-06-05 08:15:03 +02:00
|
|
|
ODataSource createNewThunderbird( const OUString& _rName );
|
2005-09-29 09:40:46 +00:00
|
|
|
|
2006-02-28 09:38:57 +00:00
|
|
|
/// creates a new Evolution local data source
|
2014-06-05 08:15:03 +02:00
|
|
|
ODataSource createNewEvolution( const OUString& _rName );
|
2003-06-02 07:04:05 +00:00
|
|
|
|
2006-02-28 09:38:57 +00:00
|
|
|
/// creates a new Evolution LDAP data source
|
2014-06-05 08:15:03 +02:00
|
|
|
ODataSource createNewEvolutionLdap( const OUString& _rName );
|
2006-02-28 09:38:57 +00:00
|
|
|
|
|
|
|
/// creates a new Evolution GROUPWISE data source
|
2014-06-05 08:15:03 +02:00
|
|
|
ODataSource createNewEvolutionGroupwise( const OUString& _rName );
|
2006-02-28 09:38:57 +00:00
|
|
|
|
2005-12-19 16:27:42 +00:00
|
|
|
/// creates a new KDE address book data source
|
2014-06-05 08:15:03 +02:00
|
|
|
ODataSource createNewKab( const OUString& _rName );
|
2005-12-19 16:27:42 +00:00
|
|
|
|
2018-11-27 11:40:49 +01:00
|
|
|
/// creates a new macOS address book data source
|
2014-06-05 08:15:03 +02:00
|
|
|
ODataSource createNewMacab( const OUString& _rName );
|
2007-09-13 17:01:49 +00:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
/// creates a new dBase data source
|
2014-06-05 08:15:03 +02:00
|
|
|
ODataSource createNewDBase( const OUString& _rName );
|
2001-08-01 10:08:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ODataSourceImpl;
|
|
|
|
struct PackageAccessControl;
|
2015-06-04 14:19:38 +02:00
|
|
|
struct AddressSettings;
|
2001-08-01 10:08:32 +00:00
|
|
|
/** a non-UNO wrapper for a data source
|
|
|
|
<p>This class allows to access data sources without the need to compile the respective file with
|
|
|
|
exception handling enabled (hopefully :).</p>
|
2019-05-10 09:34:10 +01:00
|
|
|
<p>In addition to wrapping a UNO data source, an instance of this class can handle at most
|
2001-08-01 10:08:32 +00:00
|
|
|
one valid connection, as obtained from the data source.</p>
|
|
|
|
*/
|
|
|
|
class ODataSource
|
|
|
|
{
|
|
|
|
private:
|
2016-08-19 09:27:16 +02:00
|
|
|
std::unique_ptr<ODataSourceImpl> m_pImpl;
|
2001-08-01 10:08:32 +00:00
|
|
|
|
|
|
|
public:
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
// - ctor/dtor/assignment
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
/// constructs an object which is initially invalid
|
2015-09-15 10:43:33 +01:00
|
|
|
explicit ODataSource(
|
2015-09-30 11:48:44 +02:00
|
|
|
const css::uno::Reference< css::uno::XComponentContext >& _rxORB
|
2001-08-01 10:08:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/// copy ctor
|
|
|
|
ODataSource( const ODataSource& _rSource );
|
|
|
|
|
|
|
|
/// dtor
|
|
|
|
~ODataSource( );
|
|
|
|
|
2016-09-11 21:01:42 +01:00
|
|
|
/// copy assignment
|
2001-08-01 10:08:32 +00:00
|
|
|
ODataSource& operator=( const ODataSource& _rSource );
|
|
|
|
|
2016-09-11 21:01:42 +01:00
|
|
|
/// move assignment
|
2019-08-22 15:42:36 +03:00
|
|
|
ODataSource& operator=(ODataSource&& _rSource) noexcept;
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
/// checks whether or not the object represents a valid data source
|
2014-06-05 08:15:03 +02:00
|
|
|
bool isValid() const;
|
2001-08-01 10:08:32 +00:00
|
|
|
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
/// removes the data source represented by the object from the data source context
|
2014-06-05 08:15:03 +02:00
|
|
|
void remove();
|
2001-08-01 10:08:32 +00:00
|
|
|
// TODO: put this into the context class
|
|
|
|
|
|
|
|
/// returns the name of the data source
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString
|
2014-06-05 08:15:03 +02:00
|
|
|
getName() const;
|
2001-08-01 10:08:32 +00:00
|
|
|
|
|
|
|
/// renames the data source
|
2014-06-05 08:15:03 +02:00
|
|
|
bool rename( const OUString& _rName );
|
2001-08-01 10:08:32 +00:00
|
|
|
// TODO: put this into the context class
|
|
|
|
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
// - connection handling
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
/** connects to the data source represented by this object
|
|
|
|
@param _pMessageParent
|
|
|
|
the window to use as parent for any error messages. If this is <NULL/>, no messages are displayed
|
|
|
|
at all.
|
|
|
|
@see isConnected
|
|
|
|
*/
|
2018-02-19 16:33:35 +00:00
|
|
|
bool connect(weld::Window* _pMessageParent);
|
2001-08-01 10:08:32 +00:00
|
|
|
|
2016-01-09 22:55:28 +01:00
|
|
|
/// returns <TRUE/> if the object has a valid connection, obtained from its data source
|
2014-06-05 08:15:03 +02:00
|
|
|
bool isConnected( ) const;
|
2001-08-01 10:08:32 +00:00
|
|
|
|
|
|
|
/// disconnects from the data source (i.e. disposes the UNO connection hold internally)
|
2014-06-05 08:15:03 +02:00
|
|
|
void disconnect( );
|
2001-08-01 10:08:32 +00:00
|
|
|
|
2004-08-02 16:36:51 +00:00
|
|
|
/// stores the database file
|
2015-06-04 14:19:38 +02:00
|
|
|
void store(const AddressSettings& rSettings);
|
2004-08-02 16:36:51 +00:00
|
|
|
|
|
|
|
/// register the data source under the given name in the configuration
|
2014-06-05 08:15:03 +02:00
|
|
|
void registerDataSource( const OUString& _sRegisteredDataSourceName );
|
2004-08-02 16:36:51 +00:00
|
|
|
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
/** retrieves the tables names from the connection
|
2017-03-24 11:36:55 +01:00
|
|
|
<p>to be called when <method>isConnected</method> returns <TRUE/> only</p>
|
2001-08-01 10:08:32 +00:00
|
|
|
*/
|
2014-06-05 08:15:03 +02:00
|
|
|
const StringBag& getTableNames() const;
|
2001-08-01 10:08:32 +00:00
|
|
|
|
2008-03-06 17:37:47 +00:00
|
|
|
/** determines whether a given table exists
|
|
|
|
*/
|
2013-04-07 12:06:47 +02:00
|
|
|
bool hasTable( const OUString& _rTableName ) const;
|
2008-03-06 17:37:47 +00:00
|
|
|
|
2004-08-02 16:36:51 +00:00
|
|
|
/// return the intern data source object
|
2015-09-30 11:48:44 +02:00
|
|
|
css::uno::Reference< css::beans::XPropertySet > getDataSource() const;
|
2004-08-02 16:36:51 +00:00
|
|
|
|
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
/** set a new data source.
|
|
|
|
<p>Available to selected clients only</p>
|
|
|
|
*/
|
|
|
|
void setDataSource(
|
2015-09-30 11:48:44 +02:00
|
|
|
const css::uno::Reference< css::beans::XPropertySet >& _rxDS
|
2013-04-07 12:06:47 +02:00
|
|
|
,const OUString& _sName
|
2004-08-02 16:36:51 +00:00
|
|
|
,PackageAccessControl
|
2001-08-01 10:08:32 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
} // namespace abp
|
2014-02-25 18:36:00 +01:00
|
|
|
|
2001-08-01 10:08:32 +00:00
|
|
|
|
2014-04-18 20:41:29 +02:00
|
|
|
#endif // INCLUDED_EXTENSIONS_SOURCE_ABPILOT_DATASOURCEHANDLING_HXX
|
2001-08-01 10:08:32 +00:00
|
|
|
|
2010-10-27 12:45:03 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|