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 "MDriver.hxx"
11 #include "MConnection.hxx"
13 #include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
14 #include <com/sun/star/uno/XComponentContext.hpp>
16 #include <sal/log.hxx>
18 using namespace connectivity::mork
;
20 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* com_sun_star_comp_sdbc_MorkDriver_get_implementation(
21 css::uno::XComponentContext
* context
,
22 css::uno::Sequence
<css::uno::Any
> const &)
24 return cppu::acquire(new MorkDriver(context
));
27 MorkDriver::MorkDriver(const css::uno::Reference
< css::uno::XComponentContext
>& context
):
29 m_xFactory(context_
->getServiceManager(), css::uno::UNO_QUERY
)
31 SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" );
34 OUString SAL_CALL
MorkDriver::getImplementationName()
36 return OUString(MORK_DRIVER_IMPL_NAME
);
39 sal_Bool SAL_CALL
MorkDriver::supportsService(const OUString
& serviceName
)
41 return cppu::supportsService(this, serviceName
);
44 css::uno::Sequence
< OUString
> MorkDriver::getSupportedServiceNames()
46 return { "com.sun.star.sdbc.Driver" };
49 css::uno::Reference
< css::sdbc::XConnection
> MorkDriver::connect(
51 css::uno::Sequence
< css::beans::PropertyValue
> const &)
53 SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" );
56 css::uno::Reference
<css::uno::XInterface
> xInstance
= context_
->getServiceManager()->createInstanceWithContext("com.sun.star.mozilla.MozillaBootstrap", context_
);
57 OSL_ENSURE( xInstance
.is(), "failed to create instance" );
59 css::uno::Reference
<css::mozilla::XMozillaBootstrap
> xMozillaBootstrap(xInstance
, css::uno::UNO_QUERY
);
60 OSL_ENSURE( xMozillaBootstrap
.is(), "failed to create instance" );
62 if (xMozillaBootstrap
.is())
64 OUString defaultProfile
= xMozillaBootstrap
->getDefaultProfile(css::mozilla::MozillaProductType_Thunderbird
);
66 if (!defaultProfile
.isEmpty())
68 m_sProfilePath
= xMozillaBootstrap
->getProfilePath(css::mozilla::MozillaProductType_Thunderbird
, defaultProfile
);
69 SAL_INFO("connectivity.mork", "Using Thunderbird profile " << m_sProfilePath
);
73 css::uno::Reference
< css::sdbc::XConnection
> xCon
;
74 OConnection
* pCon
= new OConnection(this);
75 xCon
= pCon
; // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
80 sal_Bool
MorkDriver::acceptsURL(OUString
const & url
)
82 SAL_INFO("connectivity.mork", "=> MorkDriver::acceptsURL()" );
83 // Skip 'sdbc:mozab: part of URL
85 sal_Int32 nLen
= url
.indexOf(':');
86 nLen
= url
.indexOf(':',nLen
+1);
87 OUString
aAddrbookURI(url
.copy(nLen
+1));
89 nLen
= aAddrbookURI
.indexOf(':');
90 OUString aAddrbookScheme
;
93 // There isn't any subschema: - but could be just subschema
94 if ( !aAddrbookURI
.isEmpty() )
96 aAddrbookScheme
= aAddrbookURI
;
98 else if( url
== "sdbc:address:" )
109 aAddrbookScheme
= aAddrbookURI
.copy(0, nLen
);
112 return aAddrbookScheme
== "thunderbird" || aAddrbookScheme
== "mozilla";
115 css::uno::Sequence
< css::sdbc::DriverPropertyInfo
> MorkDriver::getPropertyInfo(
117 css::uno::Sequence
< css::beans::PropertyValue
> const &)
120 return css::uno::Sequence
< css::sdbc::DriverPropertyInfo
>();
123 sal_Int32
MorkDriver::getMajorVersion() {
128 sal_Int32
MorkDriver::getMinorVersion() {
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */