LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/mork - MDriver.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 32 51 62.7 %
Date: 2012-12-27 Functions: 6 12 50.0 %
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 "MDriver.hxx"
      11             : #include "MConnection.hxx"
      12             : #include "MNSProfileDiscover.hxx"
      13             : 
      14             : #include "resource/mork_res.hrc"
      15             : #include "resource/common_res.hrc"
      16             : 
      17             : using namespace connectivity::mork;
      18             : 
      19             : namespace connectivity
      20             : {
      21             :     namespace mork
      22             :     {
      23           3 :         css::uno::Reference< css::uno::XInterface > create(css::uno::Reference< css::uno::XComponentContext > const & context)
      24             :         {
      25           3 :             return static_cast< cppu::OWeakObject * >(new MorkDriver(context));
      26             :         }
      27             :     }
      28             : }
      29             : 
      30           3 : MorkDriver::MorkDriver(css::uno::Reference< css::uno::XComponentContext > const context):
      31             :     context_(context),
      32           3 :     m_xFactory(context_->getServiceManager(), css::uno::UNO_QUERY)
      33             : {
      34             :     SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" );
      35             : //    css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceFactory(;
      36           3 :     m_ProfileAccess = new ProfileAccess();
      37             :     assert(context.is());
      38           3 : }
      39             : 
      40             : // static ServiceInfo
      41             : //------------------------------------------------------------------------------
      42           1 : rtl::OUString MorkDriver::getImplementationName_Static(  ) throw(css::uno::RuntimeException)
      43             : {
      44           1 :     return rtl::OUString(MORK_DRIVER_IMPL_NAME);
      45             : }
      46             : 
      47             : //------------------------------------------------------------------------------
      48           1 : css::uno::Sequence< ::rtl::OUString > MorkDriver::getSupportedServiceNames_Static(  ) throw (css::uno::RuntimeException)
      49             : {
      50           1 :     css::uno::Sequence< ::rtl::OUString > aSNS(1);
      51           1 :     aSNS[0] = ::rtl::OUString( "com.sun.star.sdbc.Driver");
      52           1 :     return aSNS;
      53             : }
      54             : 
      55           0 : rtl::OUString SAL_CALL MorkDriver::getImplementationName()
      56             :     throw (css::uno::RuntimeException)
      57             : {
      58           0 :     return getImplementationName_Static();
      59             : }
      60             : 
      61           0 : sal_Bool SAL_CALL MorkDriver::supportsService(const rtl::OUString& serviceName)
      62             :     throw (css::uno::RuntimeException)
      63             : {
      64           0 :     css::uno::Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
      65           0 :     const ::rtl::OUString* pSupported = aSupported.getConstArray();
      66           0 :     const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
      67           0 :     for (;pSupported != pEnd && !pSupported->equals(serviceName); ++pSupported)
      68             :         ;
      69             : 
      70           0 :     return pSupported != pEnd;
      71             : }
      72             : 
      73           0 : css::uno::Sequence< rtl::OUString > MorkDriver::getSupportedServiceNames()
      74             :     throw (css::uno::RuntimeException)
      75             : {
      76           0 :     return getSupportedServiceNames_Static();
      77             : }
      78             : 
      79           3 : css::uno::Reference< css::sdbc::XConnection > MorkDriver::connect(
      80             :     rtl::OUString const & url,
      81             :     css::uno::Sequence< css::beans::PropertyValue > const & info)
      82             :     throw (css::sdbc::SQLException, css::uno::RuntimeException)
      83             : {
      84             :     SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" );
      85             : 
      86             :     (void) url; (void) info; // avoid warnings
      87           3 :     css::uno::Reference< css::sdbc::XConnection > xCon;
      88           3 :     OConnection* pCon = new OConnection(this);
      89           3 :     xCon = pCon;    // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
      90           3 :     pCon->construct(url, info);
      91           3 :     return xCon;
      92             : }
      93             : 
      94          24 : sal_Bool MorkDriver::acceptsURL(rtl::OUString const & url)
      95             :     throw (css::sdbc::SQLException, css::uno::RuntimeException)
      96             : {
      97             :     SAL_INFO("connectivity.mork", "=> MorkDriver::acceptsURL()" );
      98             :     // Skip 'sdbc:mozab: part of URL
      99             :     //
     100          24 :     sal_Int32 nLen = url.indexOf(':');
     101          24 :     nLen = url.indexOf(':',nLen+1);
     102          24 :     OUString aAddrbookURI(url.copy(nLen+1));
     103             :     // Get Scheme
     104          24 :     nLen = aAddrbookURI.indexOf(':');
     105          24 :     OUString aAddrbookScheme;
     106          24 :     if ( nLen == -1 )
     107             :     {
     108             :         // There isn't any subschema: - but could be just subschema
     109           3 :         if ( !aAddrbookURI.isEmpty() )
     110             :         {
     111           3 :             aAddrbookScheme= aAddrbookURI;
     112             :         }
     113           0 :         else if(url == OUString("sdbc:address:") )
     114             :         {
     115           0 :             return false;
     116             :         }
     117             :         else
     118             :         {
     119           0 :             return false;
     120             :         }
     121             :     }
     122             :     else
     123             :     {
     124          21 :         aAddrbookScheme = aAddrbookURI.copy(0, nLen);
     125             :     }
     126             : 
     127          42 :     if ((aAddrbookScheme.compareToAscii( "thunderbird" ) == 0) ||
     128          18 :         (aAddrbookScheme.compareToAscii( "mozilla" ) == 0))
     129             :     {
     130          12 :         return true;
     131             :     }
     132             : 
     133          12 :     return false;
     134             : }
     135             : 
     136           0 : css::uno::Sequence< css::sdbc::DriverPropertyInfo > MorkDriver::getPropertyInfo(
     137             :     rtl::OUString const & url,
     138             :     css::uno::Sequence< css::beans::PropertyValue > const & info)
     139             :     throw (css::sdbc::SQLException, css::uno::RuntimeException)
     140             : {
     141             :     //... TODO
     142             :     (void) url; (void) info; // avoid warnings
     143           0 :     return css::uno::Sequence< css::sdbc::DriverPropertyInfo >();
     144             : }
     145             : 
     146           0 : sal_Int32 MorkDriver::getMajorVersion() throw (css::uno::RuntimeException) {
     147             :     //... TODO
     148           0 :     return 0;
     149             : }
     150             : 
     151           0 : sal_Int32 MorkDriver::getMinorVersion() throw (css::uno::RuntimeException) {
     152             :     //... TODO
     153           0 :     return 0;
     154             : }
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10