Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : */
9 :
10 : #include <cppuhelper/supportsservice.hxx>
11 : #include "MDriver.hxx"
12 : #include "MConnection.hxx"
13 : #include "MNSProfileDiscover.hxx"
14 :
15 : #include "resource/mork_res.hrc"
16 : #include "resource/common_res.hrc"
17 :
18 : using namespace connectivity::mork;
19 :
20 : namespace connectivity
21 : {
22 : namespace mork
23 : {
24 6 : css::uno::Reference< css::uno::XInterface > create(css::uno::Reference< css::uno::XComponentContext > const & context)
25 : {
26 6 : return static_cast< cppu::OWeakObject * >(new MorkDriver(context));
27 : }
28 : }
29 : }
30 :
31 6 : MorkDriver::MorkDriver(css::uno::Reference< css::uno::XComponentContext > const context):
32 : context_(context),
33 6 : m_xFactory(context_->getServiceManager(), css::uno::UNO_QUERY)
34 : {
35 : SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" );
36 : // css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceFactory(;
37 : assert(context.is());
38 6 : }
39 :
40 : // static ServiceInfo
41 :
42 2 : OUString MorkDriver::getImplementationName_Static( ) throw(css::uno::RuntimeException)
43 : {
44 2 : return OUString(MORK_DRIVER_IMPL_NAME);
45 : }
46 :
47 :
48 2 : css::uno::Sequence< OUString > MorkDriver::getSupportedServiceNames_Static( ) throw (css::uno::RuntimeException)
49 : {
50 2 : css::uno::Sequence< OUString > aSNS(1);
51 2 : aSNS[0] = "com.sun.star.sdbc.Driver";
52 2 : return aSNS;
53 : }
54 :
55 0 : OUString SAL_CALL MorkDriver::getImplementationName()
56 : throw (css::uno::RuntimeException, std::exception)
57 : {
58 0 : return getImplementationName_Static();
59 : }
60 :
61 0 : sal_Bool SAL_CALL MorkDriver::supportsService(const OUString& serviceName)
62 : throw (css::uno::RuntimeException, std::exception)
63 : {
64 0 : return cppu::supportsService(this, serviceName);
65 : }
66 :
67 0 : css::uno::Sequence< OUString > MorkDriver::getSupportedServiceNames()
68 : throw (css::uno::RuntimeException, std::exception)
69 : {
70 0 : return getSupportedServiceNames_Static();
71 : }
72 :
73 6 : 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)
77 : {
78 : SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" );
79 :
80 : (void) url; (void) info; // avoid warnings
81 6 : css::uno::Reference< css::sdbc::XConnection > xCon;
82 6 : OConnection* pCon = new OConnection(this);
83 6 : xCon = pCon; // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
84 6 : pCon->construct(url, info);
85 6 : return xCon;
86 : }
87 :
88 48 : sal_Bool MorkDriver::acceptsURL(OUString const & url)
89 : throw (css::sdbc::SQLException, css::uno::RuntimeException, std::exception)
90 : {
91 : SAL_INFO("connectivity.mork", "=> MorkDriver::acceptsURL()" );
92 : // Skip 'sdbc:mozab: part of URL
93 :
94 48 : sal_Int32 nLen = url.indexOf(':');
95 48 : nLen = url.indexOf(':',nLen+1);
96 48 : OUString aAddrbookURI(url.copy(nLen+1));
97 : // Get Scheme
98 48 : nLen = aAddrbookURI.indexOf(':');
99 96 : OUString aAddrbookScheme;
100 48 : if ( nLen == -1 )
101 : {
102 : // There isn't any subschema: - but could be just subschema
103 6 : if ( !aAddrbookURI.isEmpty() )
104 : {
105 6 : aAddrbookScheme= aAddrbookURI;
106 : }
107 0 : else if( url == "sdbc:address:" )
108 : {
109 0 : return false;
110 : }
111 : else
112 : {
113 0 : return false;
114 : }
115 : }
116 : else
117 : {
118 42 : aAddrbookScheme = aAddrbookURI.copy(0, nLen);
119 : }
120 :
121 84 : if (aAddrbookScheme.equalsAscii( "thunderbird" ) ||
122 36 : aAddrbookScheme.equalsAscii( "mozilla" ) )
123 : {
124 24 : return true;
125 : }
126 :
127 72 : return false;
128 : }
129 :
130 0 : 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)
134 : {
135 : //... TODO
136 : (void) url; (void) info; // avoid warnings
137 0 : return css::uno::Sequence< css::sdbc::DriverPropertyInfo >();
138 : }
139 :
140 0 : sal_Int32 MorkDriver::getMajorVersion() throw (css::uno::RuntimeException, std::exception) {
141 : //... TODO
142 0 : return 0;
143 : }
144 :
145 0 : sal_Int32 MorkDriver::getMinorVersion() throw (css::uno::RuntimeException, std::exception) {
146 : //... TODO
147 0 : return 0;
148 : }
149 :
150 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|