Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / mork / MDriver.cxx
bloba9ee71078d16ba94d970c7766f34ad3d592635d0
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 <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
22 namespace mork
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):
32 context_(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(;
37 assert(context.is());
40 // static ServiceInfo
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";
52 return aSNS;
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(
74 OUString const & url,
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);
85 return xCon;
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));
97 // Get Scheme
98 nLen = aAddrbookURI.indexOf(':');
99 OUString aAddrbookScheme;
100 if ( nLen == -1 )
102 // There isn't any subschema: - but could be just subschema
103 if ( !aAddrbookURI.isEmpty() )
105 aAddrbookScheme= aAddrbookURI;
107 else if( url == "sdbc:address:" )
109 return false;
111 else
113 return false;
116 else
118 aAddrbookScheme = aAddrbookURI.copy(0, nLen);
121 if (aAddrbookScheme.equalsAscii( "thunderbird" ) ||
122 aAddrbookScheme.equalsAscii( "mozilla" ) )
124 return true;
127 return false;
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)
135 //... TODO
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) {
141 //... TODO
142 return 0;
145 sal_Int32 MorkDriver::getMinorVersion() throw (css::uno::RuntimeException, std::exception) {
146 //... TODO
147 return 0;
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */