bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / mork / MDriver.cxx
blobaabfbb79db3b6d3a6978be5703e4a3357b1f3c50
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/.
8 */
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):
28 context_(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(
50 OUString const & url,
51 css::uno::Sequence< css::beans::PropertyValue > const &)
53 SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" );
55 // Profile discovery
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)
76 pCon->construct(url);
77 return xCon;
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));
88 // Get Scheme
89 nLen = aAddrbookURI.indexOf(':');
90 OUString aAddrbookScheme;
91 if ( nLen == -1 )
93 // There isn't any subschema: - but could be just subschema
94 if ( !aAddrbookURI.isEmpty() )
96 aAddrbookScheme= aAddrbookURI;
98 else if( url == "sdbc:address:" )
100 return false;
102 else
104 return false;
107 else
109 aAddrbookScheme = aAddrbookURI.copy(0, nLen);
112 return aAddrbookScheme == "thunderbird" || aAddrbookScheme == "mozilla";
115 css::uno::Sequence< css::sdbc::DriverPropertyInfo > MorkDriver::getPropertyInfo(
116 OUString const &,
117 css::uno::Sequence< css::beans::PropertyValue > const &)
119 //... TODO
120 return css::uno::Sequence< css::sdbc::DriverPropertyInfo >();
123 sal_Int32 MorkDriver::getMajorVersion() {
124 //... TODO
125 return 0;
128 sal_Int32 MorkDriver::getMinorVersion() {
129 //... TODO
130 return 0;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */