1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
26 #include "abptypes.hxx"
29 namespace com
{ namespace sun
{ namespace star
{
35 namespace vcl
{ class Window
; }
42 struct ODataSourceContextImpl
;
44 /// a non-UNO wrapper for the data source context
45 class ODataSourceContext
48 ODataSourceContextImpl
* m_pImpl
;
52 const ::com::sun::star::uno::Reference
< ::com::sun::star::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 auccessive numbers
60 OUString
& 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 Mac OS X address book data source
81 ODataSource
createNewMacab( const OUString
& _rName
);
83 /// creates a new LDAP data source
84 ODataSource
createNewLDAP( const OUString
& _rName
);
86 /// creates a new Outlook data source
87 ODataSource
createNewOutlook( const OUString
& _rName
);
89 /// creates a new Outlook express data source
90 ODataSource
createNewOE( const OUString
& _rName
);
92 /// creates a new dBase data source
93 ODataSource
createNewDBase( const OUString
& _rName
);
96 struct ODataSourceImpl
;
97 struct PackageAccessControl
;
98 /** a non-UNO wrapper for a data source
99 <p>This class allows to access data sources without the need to compile the respective file with
100 exception handling enabled (hopefully :).</p>
101 <p>In addition to wrapping an UNO data source, an instance of this class can handle at most
102 one valid connection, as obtained from the data source.</p>
107 ODataSourceImpl
* m_pImpl
;
111 // - ctor/dtor/assignment
113 /// constructs an object which is initially invalid
115 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxORB
119 ODataSource( const ODataSource
& _rSource
);
125 ODataSource
& operator=( const ODataSource
& _rSource
);
128 /// checks whether or not the object represents a valid data source
129 bool isValid() const;
132 /// removes the data source represented by the object from the data source context
134 // TODO: put this into the context class
136 /// returns the name of the data source
140 /// renames the data source
141 bool rename( const OUString
& _rName
);
142 // TODO: put this into the context class
145 // - connection handling
147 /** connects to the data source represented by this object
148 @param _pMessageParent
149 the window to use as parent for any error messages. If this is <NULL/>, no messages are displayed
153 bool connect( vcl::Window
* _pMessageParent
);
155 /// returns <TRUE/> if the object has a valid connection, obtained from it's data source
156 bool isConnected( ) const;
158 /// disconnects from the data source (i.e. disposes the UNO connection hold internally)
161 /// stores the database file
164 /// register the data source under the given name in the configuration
165 void registerDataSource( const OUString
& _sRegisteredDataSourceName
);
168 /** retrieves the tables names from the connection
169 <p>to be called when <method>isConnection</method> returns <TRUE/> only</p>
171 const StringBag
& getTableNames() const;
173 /** determines whether a given table exists
175 bool hasTable( const OUString
& _rTableName
) const;
177 /// return the intern data source object
178 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getDataSource() const;
182 /** set a new data source.
183 <p>Available to selected clients only</p>
186 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxDS
187 ,const OUString
& _sName
188 ,PackageAccessControl
192 ODataSource( ); // never implemented
199 #endif // INCLUDED_EXTENSIONS_SOURCE_ABPILOT_DATASOURCEHANDLING_HXX
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */