summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/mork/MDriver.cxx
blob: c5998921e32499a3e1bf2c42b819f9dff3874d35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include "MDriver.hxx"
#include "MConnection.hxx"
#include "MNSProfileDiscover.hxx"

#include "resource/mork_res.hrc"
#include "resource/common_res.hrc"

using namespace connectivity::mork;

namespace connectivity
{
    namespace mork
    {
        css::uno::Reference< css::uno::XInterface > create(css::uno::Reference< css::uno::XComponentContext > const & context)
        {
            return static_cast< cppu::OWeakObject * >(new MorkDriver(context));
        }
    }
}

MorkDriver::MorkDriver(css::uno::Reference< css::uno::XComponentContext > const context):
    context_(context),
    m_xFactory(context_->getServiceManager(), css::uno::UNO_QUERY)
{
    SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" );
//    css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceFactory(;
    m_ProfileAccess = new ProfileAccess();
    assert(context.is());
}

// static ServiceInfo
//------------------------------------------------------------------------------
rtl::OUString MorkDriver::getImplementationName_Static(  ) throw(css::uno::RuntimeException)
{
    return rtl::OUString(MORK_DRIVER_IMPL_NAME);
}

//------------------------------------------------------------------------------
css::uno::Sequence< ::rtl::OUString > MorkDriver::getSupportedServiceNames_Static(  ) throw (css::uno::RuntimeException)
{
    css::uno::Sequence< ::rtl::OUString > aSNS(1);
    aSNS[0] = ::rtl::OUString( "com.sun.star.sdbc.Driver");
    return aSNS;
}

rtl::OUString SAL_CALL MorkDriver::getImplementationName()
    throw (css::uno::RuntimeException)
{
    return getImplementationName_Static();
}

sal_Bool SAL_CALL MorkDriver::supportsService(const rtl::OUString& serviceName)
    throw (css::uno::RuntimeException)
{
    css::uno::Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
    const ::rtl::OUString* pSupported = aSupported.getConstArray();
    const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
    for (;pSupported != pEnd && !pSupported->equals(serviceName); ++pSupported)
        ;

    return pSupported != pEnd;
}

css::uno::Sequence< rtl::OUString > MorkDriver::getSupportedServiceNames()
    throw (css::uno::RuntimeException)
{
    return getSupportedServiceNames_Static();
}

css::uno::Reference< css::sdbc::XConnection > MorkDriver::connect(
    rtl::OUString const & url,
    css::uno::Sequence< css::beans::PropertyValue > const & info)
    throw (css::sdbc::SQLException, css::uno::RuntimeException)
{
    SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" );

    (void) url; (void) info; // avoid warnings
    css::uno::Reference< css::sdbc::XConnection > xCon;
    OConnection* pCon = new OConnection(this);
    xCon = pCon;    // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
    pCon->construct(url, info);
    return xCon;
}

sal_Bool MorkDriver::acceptsURL(rtl::OUString const & url)
    throw (css::sdbc::SQLException, css::uno::RuntimeException)
{
    SAL_INFO("connectivity.mork", "=> MorkDriver::acceptsURL()" );

    //... TODO
    (void) url; // avoid warnings
    return true;
}

css::uno::Sequence< css::sdbc::DriverPropertyInfo > MorkDriver::getPropertyInfo(
    rtl::OUString const & url,
    css::uno::Sequence< css::beans::PropertyValue > const & info)
    throw (css::sdbc::SQLException, css::uno::RuntimeException)
{
    //... TODO
    (void) url; (void) info; // avoid warnings
    return css::uno::Sequence< css::sdbc::DriverPropertyInfo >();
}

sal_Int32 MorkDriver::getMajorVersion() throw (css::uno::RuntimeException) {
    //... TODO
    return 0;
}

sal_Int32 MorkDriver::getMinorVersion() throw (css::uno::RuntimeException) {
    //... TODO
    return 0;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */