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/.
10 #include <cppuhelper/supportsservice.hxx>
11 #include "MDriver.hxx"
12 #include "MConnection.hxx"
13 #include "MNSProfileDiscover.hxx"
15 #include "resource/mork_res.hrc"
16 #include "resource/common_res.hrc"
18 using namespace connectivity::mork
;
20 namespace connectivity
24 css::uno::Reference
< css::uno::XInterface
> create(css::uno::Reference
< css::uno::XComponentContext
> const & context
)
26 return static_cast< cppu::OWeakObject
* >(new MorkDriver(context
));
31 MorkDriver::MorkDriver(css::uno::Reference
< css::uno::XComponentContext
> const context
):
33 m_xFactory(context_
->getServiceManager(), css::uno::UNO_QUERY
)
35 SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" );
36 // css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceFactory(;
42 OUString
MorkDriver::getImplementationName_Static( ) throw(css::uno::RuntimeException
)
44 return OUString(MORK_DRIVER_IMPL_NAME
);
48 css::uno::Sequence
< OUString
> MorkDriver::getSupportedServiceNames_Static( ) throw (css::uno::RuntimeException
)
50 css::uno::Sequence
< OUString
> aSNS(1);
51 aSNS
[0] = "com.sun.star.sdbc.Driver";
55 OUString SAL_CALL
MorkDriver::getImplementationName()
56 throw (css::uno::RuntimeException
, std::exception
)
58 return getImplementationName_Static();
61 sal_Bool SAL_CALL
MorkDriver::supportsService(const OUString
& serviceName
)
62 throw (css::uno::RuntimeException
, std::exception
)
64 return cppu::supportsService(this, serviceName
);
67 css::uno::Sequence
< OUString
> MorkDriver::getSupportedServiceNames()
68 throw (css::uno::RuntimeException
, std::exception
)
70 return getSupportedServiceNames_Static();
73 css::uno::Reference
< css::sdbc::XConnection
> MorkDriver::connect(
75 css::uno::Sequence
< css::beans::PropertyValue
> const & info
)
76 throw (css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
)
78 SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" );
80 (void) url
; (void) info
; // avoid warnings
81 css::uno::Reference
< css::sdbc::XConnection
> xCon
;
82 OConnection
* pCon
= new OConnection(this);
83 xCon
= pCon
; // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
84 pCon
->construct(url
, info
);
88 sal_Bool
MorkDriver::acceptsURL(OUString
const & url
)
89 throw (css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
)
91 SAL_INFO("connectivity.mork", "=> MorkDriver::acceptsURL()" );
92 // Skip 'sdbc:mozab: part of URL
94 sal_Int32 nLen
= url
.indexOf(':');
95 nLen
= url
.indexOf(':',nLen
+1);
96 OUString
aAddrbookURI(url
.copy(nLen
+1));
98 nLen
= aAddrbookURI
.indexOf(':');
99 OUString aAddrbookScheme
;
102 // There isn't any subschema: - but could be just subschema
103 if ( !aAddrbookURI
.isEmpty() )
105 aAddrbookScheme
= aAddrbookURI
;
107 else if( url
== "sdbc:address:" )
118 aAddrbookScheme
= aAddrbookURI
.copy(0, nLen
);
121 if (aAddrbookScheme
.equalsAscii( "thunderbird" ) ||
122 aAddrbookScheme
.equalsAscii( "mozilla" ) )
130 css::uno::Sequence
< css::sdbc::DriverPropertyInfo
> MorkDriver::getPropertyInfo(
131 OUString
const & url
,
132 css::uno::Sequence
< css::beans::PropertyValue
> const & info
)
133 throw (css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
)
136 (void) url
; (void) info
; // avoid warnings
137 return css::uno::Sequence
< css::sdbc::DriverPropertyInfo
>();
140 sal_Int32
MorkDriver::getMajorVersion() throw (css::uno::RuntimeException
, std::exception
) {
145 sal_Int32
MorkDriver::getMinorVersion() throw (css::uno::RuntimeException
, std::exception
) {
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */