LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mozab/bootstrap - MMozillaBootstrap.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 78 0.0 %
Date: 2014-04-14 Functions: 0 28 0.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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <cppuhelper/supportsservice.hxx>
      21             : #include "MMozillaBootstrap.hxx"
      22             : 
      23             : using namespace com::sun::star::uno;
      24             : using namespace com::sun::star::lang;
      25             : using namespace com::sun::star::mozilla;
      26             : using namespace connectivity::mozab;
      27             : #include <MNSFolders.hxx>
      28             : #include "MNSProfileDiscover.hxx"
      29             : #ifndef MINIMAL_PROFILEDISCOVER
      30             : #  include "MNSProfileManager.hxx"
      31             : #  include "MNSRunnable.hxx"
      32             : #endif
      33             : #include <MNSInit.hxx>
      34             : 
      35             : static MozillaBootstrap *pMozillaBootstrap=NULL;
      36           0 : static Reference<XMozillaBootstrap> xMozillaBootstrap;
      37           0 : extern "C" SAL_DLLPUBLIC_EXPORT void*  SAL_CALL OMozillaBootstrap_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
      38             : {
      39           0 :     if (!pMozillaBootstrap)
      40             :     {
      41           0 :         pMozillaBootstrap=new connectivity::mozab::MozillaBootstrap( _rxFactory );
      42           0 :         pMozillaBootstrap->Init();
      43           0 :         xMozillaBootstrap = pMozillaBootstrap;
      44             :     }
      45           0 :     return  pMozillaBootstrap;
      46             : }
      47             : 
      48           0 : MozillaBootstrap::MozillaBootstrap(
      49             :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
      50             :     : OMozillaBootstrap_BASE(m_aMutex), m_xMSFactory( _rxFactory ),
      51           0 :       m_ProfileAccess(NULL), m_ProfileManager(NULL)
      52             : {
      53           0 : }
      54             : 
      55           0 : MozillaBootstrap::~MozillaBootstrap()
      56             : {
      57           0 : }
      58             : 
      59           0 : void MozillaBootstrap::Init()
      60             : {
      61           0 :     sal_Bool aProfileExists=sal_False;
      62             : 
      63             : #ifndef MINIMAL_PROFILEDISCOVER
      64             :     //This must be call before any mozilla code
      65             :     MNS_Init(aProfileExists);
      66             : 
      67             :     m_ProfileManager = new ProfileManager();
      68             : #else
      69             :     (void)aProfileExists; /* avoid warning about unused parameter */
      70             : #endif
      71           0 :     m_ProfileAccess = new ProfileAccess();
      72           0 :     bootupProfile(::com::sun::star::mozilla::MozillaProductType_Mozilla,OUString());
      73           0 : }
      74             : 
      75             : 
      76           0 : void MozillaBootstrap::disposing()
      77             : {
      78           0 :     ::osl::MutexGuard aGuard(m_aMutex);
      79           0 :     OMozillaBootstrap_BASE::disposing();
      80           0 : }
      81             : 
      82             : // static ServiceInfo
      83             : 
      84           0 : OUString MozillaBootstrap::getImplementationName_Static(  ) throw(RuntimeException)
      85             : {
      86           0 :     return OUString(MOZAB_MozillaBootstrap_IMPL_NAME);
      87             : }
      88             : 
      89           0 : Sequence< OUString > MozillaBootstrap::getSupportedServiceNames_Static(  ) throw (RuntimeException)
      90             : {
      91             :     // which service is supported
      92             :     // for more information @see com.sun.star.mozilla.MozillaBootstrap
      93           0 :     Sequence< OUString > aSNS( 1 );
      94           0 :     aSNS[0] = "com.sun.star.mozilla.MozillaBootstrap";
      95           0 :     return aSNS;
      96             : }
      97             : 
      98             : 
      99           0 : OUString SAL_CALL MozillaBootstrap::getImplementationName(  ) throw(RuntimeException, std::exception)
     100             : {
     101           0 :     return getImplementationName_Static();
     102             : }
     103             : 
     104           0 : sal_Bool SAL_CALL MozillaBootstrap::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
     105             : {
     106           0 :     return cppu::supportsService(this, _rServiceName);
     107             : }
     108             : 
     109             : 
     110           0 : Sequence< OUString > SAL_CALL MozillaBootstrap::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
     111             : {
     112           0 :     return getSupportedServiceNames_Static();
     113             : }
     114             : 
     115             : 
     116             : // XProfileDiscover
     117           0 : ::sal_Int32 SAL_CALL MozillaBootstrap::getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException, std::exception)
     118             : {
     119           0 :     return m_ProfileAccess->getProfileCount(product);
     120             : }
     121           0 : ::sal_Int32 SAL_CALL MozillaBootstrap::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< OUString >& list ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     122             : {
     123           0 :     return m_ProfileAccess->getProfileList(product,list);
     124             : }
     125           0 : OUString SAL_CALL MozillaBootstrap::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     126             : {
     127           0 :     return m_ProfileAccess->getDefaultProfile(product);
     128             : }
     129           0 : OUString SAL_CALL MozillaBootstrap::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     130             : {
     131           0 :     return m_ProfileAccess->getProfilePath(product,profileName);
     132             : }
     133           0 : sal_Bool SAL_CALL MozillaBootstrap::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     134             : {
     135           0 :     return m_ProfileAccess->isProfileLocked(product,profileName);
     136             : }
     137           0 : sal_Bool SAL_CALL MozillaBootstrap::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     138             : {
     139           0 :     return m_ProfileAccess->getProfileExists(product,profileName);
     140             : }
     141             : 
     142             : // XProfileManager
     143           0 : ::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     144             : {
     145             : #ifndef MINIMAL_PROFILEDISCOVER
     146             :     return m_ProfileManager->bootupProfile(product,profileName);
     147             : #else
     148             :     (void)product; /* avoid warning about unused parameter */
     149             :     (void)profileName; /* avoid warning about unused parameter */
     150           0 :         return -1;
     151             : #endif
     152             : }
     153           0 : ::sal_Int32 SAL_CALL MozillaBootstrap::shutdownProfile(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     154             : {
     155             : #ifndef MINIMAL_PROFILEDISCOVER
     156             :     return m_ProfileManager->shutdownProfile();
     157             : #else
     158           0 :     return -1;
     159             : #endif
     160             : }
     161           0 : ::com::sun::star::mozilla::MozillaProductType SAL_CALL MozillaBootstrap::getCurrentProduct(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     162             : {
     163             : #ifndef MINIMAL_PROFILEDISCOVER
     164             :     return m_ProfileManager->getCurrentProduct();
     165             : #else
     166           0 :     return ::com::sun::star::mozilla::MozillaProductType_Default;
     167             : #endif
     168             : }
     169           0 : OUString SAL_CALL MozillaBootstrap::getCurrentProfile(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     170             : {
     171             : #ifndef MINIMAL_PROFILEDISCOVER
     172             :     return m_ProfileManager->getCurrentProfile();
     173             : #else
     174           0 :     return OUString();
     175             : #endif
     176             : }
     177           0 : sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     178             : {
     179             : #ifndef MINIMAL_PROFILEDISCOVER
     180             :     return isProfileLocked(getCurrentProduct(),m_ProfileManager->getCurrentProfile());
     181             : #else
     182           0 :     return true;
     183             : #endif
     184             : }
     185           0 : OUString SAL_CALL MozillaBootstrap::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     186             : {
     187             : #ifndef MINIMAL_PROFILEDISCOVER
     188             :     return m_ProfileManager->setCurrentProfile(product,profileName);
     189             : #else
     190             :     (void)product; /* avoid warning about unused parameter */
     191             :     (void)profileName; /* avoid warning about unused parameter */
     192           0 :     return OUString();
     193             : #endif
     194             : }
     195             : 
     196             : // XProxyRunner
     197           0 : ::sal_Int32 SAL_CALL MozillaBootstrap::Run( const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     198             : {
     199             : #ifndef MINIMAL_PROFILEDISCOVER
     200             :     OUString profileName = aCode->getProfileName();
     201             :     OUString currProfileName = getCurrentProfile();
     202             :     ::com::sun::star::mozilla::MozillaProductType currProduct = getCurrentProduct();
     203             : 
     204             :      //if client provides a profileName, we will use it
     205             :     if (!profileName.isEmpty()
     206             :              && ( aCode->getProductType() != currProduct  || !profileName.equals(currProfileName)) )
     207             :         setCurrentProfile(aCode->getProductType(),profileName);
     208             :        MNSRunnable xRunnable;
     209             : 
     210             :     return xRunnable.StartProxy(aCode);
     211             : #else
     212             :     (void)aCode; /* avoid warning about unused parameter */
     213           0 :     return -1;
     214             : #endif
     215             : }
     216             : 
     217             : #ifdef MINIMAL_PROFILEDISCOVER
     218             : #include <cppuhelper/factory.hxx>
     219             : using ::com::sun::star::uno::Reference;
     220             : using ::com::sun::star::uno::Sequence;
     221             : using ::com::sun::star::lang::XSingleServiceFactory;
     222             : using ::com::sun::star::lang::XMultiServiceFactory;
     223             : 
     224           0 : static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
     225             : {
     226           0 :         MozillaBootstrap * pBootstrap = reinterpret_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager));
     227           0 :         return *pBootstrap;
     228             : }
     229             : 
     230           0 : extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL mozbootstrap_component_getFactory(
     231             :                                         const sal_Char* pImplementationName,
     232             :                                         void* pServiceManager,
     233             :                                         void* /*pRegistryKey*/)
     234             : {
     235           0 :         void* pRet = 0;
     236             : 
     237           0 :         if (pServiceManager)
     238             :         {
     239           0 :                 OUString aImplName( OUString::createFromAscii( pImplementationName ) );
     240           0 :                 Reference< XSingleServiceFactory > xFactory;
     241           0 :                 if ( aImplName == "com.sun.star.comp.mozilla.MozillaBootstrap" )
     242             :                 {
     243           0 :                     Sequence< OUString > aSNS( 1 );
     244           0 :                     aSNS[0] = "com.sun.star.mozilla.MozillaBootstrap";
     245             : 
     246           0 :                     xFactory = ::cppu::createSingleFactory(
     247             :                         reinterpret_cast< XMultiServiceFactory* > ( pServiceManager),
     248           0 :                         aImplName, createInstance, aSNS );
     249             :                 }
     250           0 :                 if ( xFactory.is() )
     251             :                 {
     252           0 :                     xFactory->acquire();
     253           0 :                     pRet = xFactory.get();
     254           0 :                 }
     255             :         }
     256             : 
     257           0 :         return pRet;
     258           0 : };
     259             : 
     260             : #endif
     261             : 
     262             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10