LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/mozab/bootstrap - MMozillaBootstrap.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 81 0.0 %
Date: 2012-12-27 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             : 
      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             : // --------------------------------------------------------------------------------
      49             : 
      50             : 
      51             : // --------------------------------------------------------------------------------
      52           0 : MozillaBootstrap::MozillaBootstrap(
      53             :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
      54           0 :     : OMozillaBootstrap_BASE(m_aMutex), m_xMSFactory( _rxFactory )
      55             : {
      56           0 : }
      57             : // -----------------------------------------------------------------------------
      58           0 : MozillaBootstrap::~MozillaBootstrap()
      59             : {
      60           0 : }
      61             : // -----------------------------------------------------------------------------
      62           0 : void MozillaBootstrap::Init()
      63             : {
      64           0 :     sal_Bool aProfileExists=sal_False;
      65             : 
      66             : #ifndef MINIMAL_PROFILEDISCOVER
      67             :     //This must be call before any mozilla code
      68             :     MNS_Init(aProfileExists);
      69             : 
      70             :     m_ProfileManager = new ProfileManager();
      71             : #else
      72             :     (void)aProfileExists; /* avoid warning about unused parameter */
      73             : #endif
      74           0 :     m_ProfileAccess = new ProfileAccess();
      75           0 :     bootupProfile(::com::sun::star::mozilla::MozillaProductType_Mozilla,rtl::OUString());
      76           0 : }
      77             : 
      78             : // --------------------------------------------------------------------------------
      79           0 : void MozillaBootstrap::disposing()
      80             : {
      81           0 :     ::osl::MutexGuard aGuard(m_aMutex);
      82           0 :     OMozillaBootstrap_BASE::disposing();
      83           0 : }
      84             : 
      85             : // static ServiceInfo
      86             : //------------------------------------------------------------------------------
      87           0 : rtl::OUString MozillaBootstrap::getImplementationName_Static(  ) throw(RuntimeException)
      88             : {
      89           0 :     return rtl::OUString(MOZAB_MozillaBootstrap_IMPL_NAME);
      90             : }
      91             : //------------------------------------------------------------------------------
      92           0 : Sequence< ::rtl::OUString > MozillaBootstrap::getSupportedServiceNames_Static(  ) throw (RuntimeException)
      93             : {
      94             :     // which service is supported
      95             :     // for more information @see com.sun.star.mozilla.MozillaBootstrap
      96           0 :     Sequence< ::rtl::OUString > aSNS( 1 );
      97           0 :     aSNS[0] = ::rtl::OUString( "com.sun.star.mozilla.MozillaBootstrap");
      98           0 :     return aSNS;
      99             : }
     100             : 
     101             : //------------------------------------------------------------------
     102           0 : ::rtl::OUString SAL_CALL MozillaBootstrap::getImplementationName(  ) throw(RuntimeException)
     103             : {
     104           0 :     return getImplementationName_Static();
     105             : }
     106             : 
     107             : //------------------------------------------------------------------
     108           0 : sal_Bool SAL_CALL MozillaBootstrap::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
     109             : {
     110           0 :     Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
     111           0 :     const ::rtl::OUString* pSupported = aSupported.getConstArray();
     112           0 :     const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
     113           0 :     for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
     114             :         ;
     115             : 
     116           0 :     return pSupported != pEnd;
     117             : }
     118             : 
     119             : //------------------------------------------------------------------
     120           0 : Sequence< ::rtl::OUString > SAL_CALL MozillaBootstrap::getSupportedServiceNames(  ) throw(RuntimeException)
     121             : {
     122           0 :     return getSupportedServiceNames_Static();
     123             : }
     124             : 
     125             : 
     126             : // XProfileDiscover
     127           0 : ::sal_Int32 SAL_CALL MozillaBootstrap::getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException)
     128             : {
     129           0 :     return m_ProfileAccess->getProfileCount(product);
     130             : }
     131           0 : ::sal_Int32 SAL_CALL MozillaBootstrap::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException)
     132             : {
     133           0 :     return m_ProfileAccess->getProfileList(product,list);
     134             : }
     135           0 : ::rtl::OUString SAL_CALL MozillaBootstrap::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
     136             : {
     137           0 :     return m_ProfileAccess->getDefaultProfile(product);
     138             : }
     139           0 : ::rtl::OUString SAL_CALL MozillaBootstrap::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
     140             : {
     141           0 :     return m_ProfileAccess->getProfilePath(product,profileName);
     142             : }
     143           0 : ::sal_Bool SAL_CALL MozillaBootstrap::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
     144             : {
     145           0 :     return m_ProfileAccess->isProfileLocked(product,profileName);
     146             : }
     147           0 : ::sal_Bool SAL_CALL MozillaBootstrap::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
     148             : {
     149           0 :     return m_ProfileAccess->getProfileExists(product,profileName);
     150             : }
     151             : 
     152             : // XProfileManager
     153           0 : ::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
     154             : {
     155             : #ifndef MINIMAL_PROFILEDISCOVER
     156             :     return m_ProfileManager->bootupProfile(product,profileName);
     157             : #else
     158             :     (void)product; /* avoid warning about unused parameter */
     159             :     (void)profileName; /* avoid warning about unused parameter */
     160           0 :         return -1;
     161             : #endif
     162             : }
     163           0 : ::sal_Int32 SAL_CALL MozillaBootstrap::shutdownProfile(  ) throw (::com::sun::star::uno::RuntimeException)
     164             : {
     165             : #ifndef MINIMAL_PROFILEDISCOVER
     166             :     return m_ProfileManager->shutdownProfile();
     167             : #else
     168           0 :     return -1;
     169             : #endif
     170             : }
     171           0 : ::com::sun::star::mozilla::MozillaProductType SAL_CALL MozillaBootstrap::getCurrentProduct(  ) throw (::com::sun::star::uno::RuntimeException)
     172             : {
     173             : #ifndef MINIMAL_PROFILEDISCOVER
     174             :     return m_ProfileManager->getCurrentProduct();
     175             : #else
     176           0 :     return ::com::sun::star::mozilla::MozillaProductType_Default;
     177             : #endif
     178             : }
     179           0 : ::rtl::OUString SAL_CALL MozillaBootstrap::getCurrentProfile(  ) throw (::com::sun::star::uno::RuntimeException)
     180             : {
     181             : #ifndef MINIMAL_PROFILEDISCOVER
     182             :     return m_ProfileManager->getCurrentProfile();
     183             : #else
     184           0 :     return ::rtl::OUString();
     185             : #endif
     186             : }
     187           0 : ::sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked(  ) throw (::com::sun::star::uno::RuntimeException)
     188             : {
     189             : #ifndef MINIMAL_PROFILEDISCOVER
     190             :     return isProfileLocked(getCurrentProduct(),m_ProfileManager->getCurrentProfile());
     191             : #else
     192           0 :     return true;
     193             : #endif
     194             : }
     195           0 : ::rtl::OUString SAL_CALL MozillaBootstrap::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
     196             : {
     197             : #ifndef MINIMAL_PROFILEDISCOVER
     198             :     return m_ProfileManager->setCurrentProfile(product,profileName);
     199             : #else
     200             :     (void)product; /* avoid warning about unused parameter */
     201             :     (void)profileName; /* avoid warning about unused parameter */
     202           0 :     return ::rtl::OUString();
     203             : #endif
     204             : }
     205             : 
     206             : // XProxyRunner
     207           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)
     208             : {
     209             : #ifndef MINIMAL_PROFILEDISCOVER
     210             :     ::rtl::OUString profileName = aCode->getProfileName();
     211             :     ::rtl::OUString currProfileName = getCurrentProfile();
     212             :     ::com::sun::star::mozilla::MozillaProductType currProduct = getCurrentProduct();
     213             : 
     214             :      //if client provides a profileName, we will use it
     215             :     if (!profileName.isEmpty()
     216             :              && ( aCode->getProductType() != currProduct  || !profileName.equals(currProfileName)) )
     217             :         setCurrentProfile(aCode->getProductType(),profileName);
     218             :        MNSRunnable xRunnable;
     219             : 
     220             :     return xRunnable.StartProxy(aCode);
     221             : #else
     222             :     (void)aCode; /* avoid warning about unused parameter */
     223           0 :     return -1;
     224             : #endif
     225             : }
     226             : 
     227             : #ifdef MINIMAL_PROFILEDISCOVER
     228             : #include <cppuhelper/factory.hxx>
     229             : using ::com::sun::star::uno::Reference;
     230             : using ::com::sun::star::uno::Sequence;
     231             : using ::com::sun::star::lang::XSingleServiceFactory;
     232             : using ::com::sun::star::lang::XMultiServiceFactory;
     233             : 
     234           0 : static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
     235             : {
     236           0 :         MozillaBootstrap * pBootstrap = reinterpret_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager));
     237           0 :         return *pBootstrap;
     238             : }
     239             : 
     240           0 : extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL mozbootstrap_component_getFactory(
     241             :                                         const sal_Char* pImplementationName,
     242             :                                         void* pServiceManager,
     243             :                                         void* /*pRegistryKey*/)
     244             : {
     245           0 :         void* pRet = 0;
     246             : 
     247           0 :         if (pServiceManager)
     248             :         {
     249           0 :                 ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplementationName ) );
     250           0 :                 Reference< XSingleServiceFactory > xFactory;
     251           0 :                 if ( aImplName == "com.sun.star.comp.mozilla.MozillaBootstrap" )
     252             :                 {
     253           0 :                     Sequence< ::rtl::OUString > aSNS( 1 );
     254           0 :                     aSNS[0] = ::rtl::OUString( "com.sun.star.mozilla.MozillaBootstrap");
     255             : 
     256             :                     xFactory = ::cppu::createSingleFactory(
     257             :                         reinterpret_cast< XMultiServiceFactory* > ( pServiceManager),
     258           0 :                         aImplName, createInstance, aSNS );
     259             :                 }
     260           0 :                 if ( xFactory.is() )
     261             :                 {
     262           0 :                     xFactory->acquire();
     263           0 :                     pRet = xFactory.get();
     264           0 :                 }
     265             :         }
     266             : 
     267           0 :         return pRet;
     268           0 : };
     269             : 
     270             : #endif
     271             : 
     272             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10