LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mork - MDriver.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 32 43 74.4 %
Date: 2015-06-13 12:38:46 Functions: 8 12 66.7 %
Legend: Lines: hit not hit

          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           4 :         css::uno::Reference< css::uno::XInterface > create(css::uno::Reference< css::uno::XComponentContext > const & context)
      25             :         {
      26           4 :             return static_cast< cppu::OWeakObject * >(new MorkDriver(context));
      27             :         }
      28             :     }
      29             : }
      30             : 
      31           4 : MorkDriver::MorkDriver(css::uno::Reference< css::uno::XComponentContext > const context):
      32             :     context_(context),
      33           4 :     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           4 : }
      39             : 
      40             : // static ServiceInfo
      41             : 
      42           3 : OUString MorkDriver::getImplementationName_Static(  ) throw(css::uno::RuntimeException)
      43             : {
      44           3 :     return OUString(MORK_DRIVER_IMPL_NAME);
      45             : }
      46             : 
      47             : 
      48           3 : css::uno::Sequence< OUString > MorkDriver::getSupportedServiceNames_Static(  ) throw (css::uno::RuntimeException)
      49             : {
      50           3 :     css::uno::Sequence< OUString > aSNS(1);
      51           3 :     aSNS[0] = "com.sun.star.sdbc.Driver";
      52           3 :     return aSNS;
      53             : }
      54             : 
      55           1 : OUString SAL_CALL MorkDriver::getImplementationName()
      56             :     throw (css::uno::RuntimeException, std::exception)
      57             : {
      58           1 :     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           1 : css::uno::Sequence< OUString > MorkDriver::getSupportedServiceNames()
      68             :     throw (css::uno::RuntimeException, std::exception)
      69             : {
      70           1 :     return getSupportedServiceNames_Static();
      71             : }
      72             : 
      73           3 : 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           3 :     css::uno::Reference< css::sdbc::XConnection > xCon;
      82           3 :     OConnection* pCon = new OConnection(this);
      83           3 :     xCon = pCon;    // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
      84           3 :     pCon->construct(url, info);
      85           3 :     return xCon;
      86             : }
      87             : 
      88          24 : 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          24 :     sal_Int32 nLen = url.indexOf(':');
      95          24 :     nLen = url.indexOf(':',nLen+1);
      96          24 :     OUString aAddrbookURI(url.copy(nLen+1));
      97             :     // Get Scheme
      98          24 :     nLen = aAddrbookURI.indexOf(':');
      99          48 :     OUString aAddrbookScheme;
     100          24 :     if ( nLen == -1 )
     101             :     {
     102             :         // There isn't any subschema: - but could be just subschema
     103           3 :         if ( !aAddrbookURI.isEmpty() )
     104             :         {
     105           3 :             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          21 :         aAddrbookScheme = aAddrbookURI.copy(0, nLen);
     119             :     }
     120             : 
     121          48 :     return aAddrbookScheme == "thunderbird" || aAddrbookScheme == "mozilla";
     122             : }
     123             : 
     124           0 : css::uno::Sequence< css::sdbc::DriverPropertyInfo > MorkDriver::getPropertyInfo(
     125             :     OUString const & url,
     126             :     css::uno::Sequence< css::beans::PropertyValue > const & info)
     127             :     throw (css::sdbc::SQLException, css::uno::RuntimeException, std::exception)
     128             : {
     129             :     //... TODO
     130             :     (void) url; (void) info; // avoid warnings
     131           0 :     return css::uno::Sequence< css::sdbc::DriverPropertyInfo >();
     132             : }
     133             : 
     134           0 : sal_Int32 MorkDriver::getMajorVersion() throw (css::uno::RuntimeException, std::exception) {
     135             :     //... TODO
     136           0 :     return 0;
     137             : }
     138             : 
     139           0 : sal_Int32 MorkDriver::getMinorVersion() throw (css::uno::RuntimeException, std::exception) {
     140             :     //... TODO
     141           0 :     return 0;
     142             : }
     143             : 
     144             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11