bump product version to 4.1.6.2
[LibreOffice.git] / connectivity / source / drivers / mork / MDriver.cxx
blob2cd17fc2c5a1d944468d0ef76054653fe5d160d9
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"
12 #include "MNSProfileDiscover.hxx"
14 #include "resource/mork_res.hrc"
15 #include "resource/common_res.hrc"
17 using namespace connectivity::mork;
19 namespace connectivity
21 namespace mork
23 css::uno::Reference< css::uno::XInterface > create(css::uno::Reference< css::uno::XComponentContext > const & context)
25 return static_cast< cppu::OWeakObject * >(new MorkDriver(context));
30 MorkDriver::MorkDriver(css::uno::Reference< css::uno::XComponentContext > const context):
31 context_(context),
32 m_xFactory(context_->getServiceManager(), css::uno::UNO_QUERY)
34 SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" );
35 // css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceFactory(;
36 assert(context.is());
39 // static ServiceInfo
40 //------------------------------------------------------------------------------
41 OUString MorkDriver::getImplementationName_Static( ) throw(css::uno::RuntimeException)
43 return OUString(MORK_DRIVER_IMPL_NAME);
46 //------------------------------------------------------------------------------
47 css::uno::Sequence< OUString > MorkDriver::getSupportedServiceNames_Static( ) throw (css::uno::RuntimeException)
49 css::uno::Sequence< OUString > aSNS(1);
50 aSNS[0] = OUString( "com.sun.star.sdbc.Driver");
51 return aSNS;
54 OUString SAL_CALL MorkDriver::getImplementationName()
55 throw (css::uno::RuntimeException)
57 return getImplementationName_Static();
60 sal_Bool SAL_CALL MorkDriver::supportsService(const OUString& serviceName)
61 throw (css::uno::RuntimeException)
63 css::uno::Sequence< OUString > aSupported(getSupportedServiceNames());
64 const OUString* pSupported = aSupported.getConstArray();
65 const OUString* pEnd = pSupported + aSupported.getLength();
66 for (;pSupported != pEnd && !pSupported->equals(serviceName); ++pSupported)
69 return pSupported != pEnd;
72 css::uno::Sequence< OUString > MorkDriver::getSupportedServiceNames()
73 throw (css::uno::RuntimeException)
75 return getSupportedServiceNames_Static();
78 css::uno::Reference< css::sdbc::XConnection > MorkDriver::connect(
79 OUString const & url,
80 css::uno::Sequence< css::beans::PropertyValue > const & info)
81 throw (css::sdbc::SQLException, css::uno::RuntimeException)
83 SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" );
85 (void) url; (void) info; // avoid warnings
86 css::uno::Reference< css::sdbc::XConnection > xCon;
87 OConnection* pCon = new OConnection(this);
88 xCon = pCon; // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
89 pCon->construct(url, info);
90 return xCon;
93 sal_Bool MorkDriver::acceptsURL(OUString const & url)
94 throw (css::sdbc::SQLException, css::uno::RuntimeException)
96 SAL_INFO("connectivity.mork", "=> MorkDriver::acceptsURL()" );
97 // Skip 'sdbc:mozab: part of URL
99 sal_Int32 nLen = url.indexOf(':');
100 nLen = url.indexOf(':',nLen+1);
101 OUString aAddrbookURI(url.copy(nLen+1));
102 // Get Scheme
103 nLen = aAddrbookURI.indexOf(':');
104 OUString aAddrbookScheme;
105 if ( nLen == -1 )
107 // There isn't any subschema: - but could be just subschema
108 if ( !aAddrbookURI.isEmpty() )
110 aAddrbookScheme= aAddrbookURI;
112 else if(url == OUString("sdbc:address:") )
114 return false;
116 else
118 return false;
121 else
123 aAddrbookScheme = aAddrbookURI.copy(0, nLen);
126 if ((aAddrbookScheme.compareToAscii( "thunderbird" ) == 0) ||
127 (aAddrbookScheme.compareToAscii( "mozilla" ) == 0))
129 return true;
132 return false;
135 css::uno::Sequence< css::sdbc::DriverPropertyInfo > MorkDriver::getPropertyInfo(
136 OUString const & url,
137 css::uno::Sequence< css::beans::PropertyValue > const & info)
138 throw (css::sdbc::SQLException, css::uno::RuntimeException)
140 //... TODO
141 (void) url; (void) info; // avoid warnings
142 return css::uno::Sequence< css::sdbc::DriverPropertyInfo >();
145 sal_Int32 MorkDriver::getMajorVersion() throw (css::uno::RuntimeException) {
146 //... TODO
147 return 0;
150 sal_Int32 MorkDriver::getMinorVersion() throw (css::uno::RuntimeException) {
151 //... TODO
152 return 0;
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */