LCOV - code coverage report
Current view: top level - desktop/source/deployment/manager - dp_manager.h (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 13 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 18 38.9 %

           Branch data     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                 :            : #ifndef INCLUDED_DP_MANAGER_H
      21                 :            : #define INCLUDED_DP_MANAGER_H
      22                 :            : 
      23                 :            : #include "dp_manager.hrc"
      24                 :            : #include "dp_misc.h"
      25                 :            : #include "dp_interact.h"
      26                 :            : #include "dp_activepackages.hxx"
      27                 :            : #include "rtl/ref.hxx"
      28                 :            : #include "cppuhelper/compbase1.hxx"
      29                 :            : #include "cppuhelper/implbase2.hxx"
      30                 :            : #include "ucbhelper/content.hxx"
      31                 :            : #include "com/sun/star/deployment/XPackageRegistry.hpp"
      32                 :            : #include "com/sun/star/deployment/XPackageManager.hpp"
      33                 :            : #include <memory>
      34                 :            : 
      35                 :            : 
      36                 :            : namespace css = ::com::sun::star;
      37                 :            : 
      38                 :            : namespace dp_manager {
      39                 :            : 
      40                 :            : typedef ::cppu::WeakComponentImplHelper1<
      41                 :            :     css::deployment::XPackageManager > t_pm_helper;
      42                 :            : 
      43                 :            : //==============================================================================
      44                 :            : class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper
      45                 :            : {
      46                 :            :     css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
      47                 :            :     ::rtl::OUString m_context;
      48                 :            :     ::rtl::OUString m_registrationData;
      49                 :            :     ::rtl::OUString m_registrationData_expanded;
      50                 :            :     ::rtl::OUString m_registryCache;
      51                 :            :     bool m_readOnly;
      52                 :            : 
      53                 :            :     ::rtl::OUString m_activePackages;
      54                 :            :     ::rtl::OUString m_activePackages_expanded;
      55                 :            :     ::std::auto_ptr< ActivePackages > m_activePackagesDB;
      56                 :            :     //This mutex is only used for synchronization in addPackage
      57                 :            :     ::osl::Mutex m_addMutex;
      58                 :            :     css::uno::Reference<css::ucb::XProgressHandler> m_xLogFile;
      59                 :            :     inline void logIntern( css::uno::Any const & status );
      60                 :            :     void fireModified();
      61                 :            : 
      62                 :            :     css::uno::Reference<css::deployment::XPackageRegistry> m_xRegistry;
      63                 :            : 
      64                 :            :     void initRegistryBackends();
      65                 :            :     void initActivationLayer(
      66                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
      67                 :            :     ::rtl::OUString detectMediaType(
      68                 :            :         ::ucbhelper::Content const & ucbContent, bool throw_exc = true );
      69                 :            :     ::rtl::OUString insertToActivationLayer(
      70                 :            :         css::uno::Sequence<css::beans::NamedValue> const & properties,
      71                 :            :         ::rtl::OUString const & mediaType,
      72                 :            :         ::ucbhelper::Content const & sourceContent,
      73                 :            :         ::rtl::OUString const & title, ActivePackages::Data * dbData );
      74                 :            :     void insertToActivationLayerDB(
      75                 :            :         ::rtl::OUString const & id, ActivePackages::Data const & dbData );
      76                 :            : 
      77                 :            :     void deletePackageFromCache(
      78                 :            :         css::uno::Reference<css::deployment::XPackage> const & xPackage,
      79                 :            :         ::rtl::OUString const & destFolder );
      80                 :            : 
      81                 :            :     bool isInstalled(
      82                 :            :         css::uno::Reference<css::deployment::XPackage> const & package);
      83                 :            : 
      84                 :            :     bool synchronizeRemovedExtensions(
      85                 :            :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
      86                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
      87                 :            : 
      88                 :            :     bool synchronizeAddedExtensions(
      89                 :            :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
      90                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
      91                 :            : 
      92                 :            :     class CmdEnvWrapperImpl
      93                 :            :         : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment,
      94                 :            :                                           css::ucb::XProgressHandler >
      95                 :            :     {
      96                 :            :         css::uno::Reference<css::ucb::XProgressHandler> m_xLogFile;
      97                 :            :         css::uno::Reference<css::ucb::XProgressHandler> m_xUserProgress;
      98                 :            :         css::uno::Reference<css::task::XInteractionHandler>
      99                 :            :         m_xUserInteractionHandler;
     100                 :            : 
     101                 :            :     public:
     102                 :            :         virtual ~CmdEnvWrapperImpl();
     103                 :            :         CmdEnvWrapperImpl(
     104                 :            :             css::uno::Reference<css::ucb::XCommandEnvironment>
     105                 :            :             const & xUserCmdEnv,
     106                 :            :             css::uno::Reference<css::ucb::XProgressHandler> const & xLogFile );
     107                 :            : 
     108                 :            :         // XCommandEnvironment
     109                 :            :         virtual css::uno::Reference<css::task::XInteractionHandler> SAL_CALL
     110                 :            :         getInteractionHandler() throw (css::uno::RuntimeException);
     111                 :            :         virtual css::uno::Reference<css::ucb::XProgressHandler> SAL_CALL
     112                 :            :         getProgressHandler() throw (css::uno::RuntimeException);
     113                 :            : 
     114                 :            :         // XProgressHandler
     115                 :            :         virtual void SAL_CALL push( css::uno::Any const & Status )
     116                 :            :             throw (css::uno::RuntimeException);
     117                 :            :         virtual void SAL_CALL update( css::uno::Any const & Status )
     118                 :            :             throw (css::uno::RuntimeException);
     119                 :            :         virtual void SAL_CALL pop() throw (css::uno::RuntimeException);
     120                 :            :     };
     121                 :            : 
     122                 :            : protected:
     123                 :            :     inline void check();
     124                 :            :     virtual void SAL_CALL disposing();
     125                 :            : 
     126                 :            :     virtual ~PackageManagerImpl();
     127                 :        380 :     inline PackageManagerImpl(
     128                 :            :         css::uno::Reference<css::uno::XComponentContext>
     129                 :            :         const & xComponentContext, ::rtl::OUString const & context )
     130                 :        380 :         : t_pm_helper( getMutex() ),
     131                 :            :           m_xComponentContext( xComponentContext ),
     132                 :            :           m_context( context ),
     133         [ +  - ]:        760 :           m_readOnly( true )
     134                 :        380 :         {}
     135                 :            : 
     136                 :            : public:
     137                 :            :     static css::uno::Reference<css::deployment::XPackageManager> create(
     138                 :            :         css::uno::Reference<css::uno::XComponentContext>
     139                 :            :         const & xComponentContext, ::rtl::OUString const & context );
     140                 :            : 
     141                 :            :     // XComponent
     142                 :            :     virtual void SAL_CALL dispose() throw (css::uno::RuntimeException);
     143                 :            :     virtual void SAL_CALL addEventListener(
     144                 :            :         css::uno::Reference<css::lang::XEventListener> const & xListener )
     145                 :            :         throw (css::uno::RuntimeException);
     146                 :            :     virtual void SAL_CALL removeEventListener(
     147                 :            :         css::uno::Reference<css::lang::XEventListener> const & xListener )
     148                 :            :         throw (css::uno::RuntimeException);
     149                 :            : 
     150                 :            :     // XModifyBroadcaster
     151                 :            :     virtual void SAL_CALL addModifyListener(
     152                 :            :         css::uno::Reference<css::util::XModifyListener> const & xListener )
     153                 :            :         throw (css::uno::RuntimeException);
     154                 :            :     virtual void SAL_CALL removeModifyListener(
     155                 :            :         css::uno::Reference<css::util::XModifyListener> const & xListener )
     156                 :            :         throw (css::uno::RuntimeException);
     157                 :            : 
     158                 :            :     // XPackageManager
     159                 :            :     virtual ::rtl::OUString SAL_CALL getContext()
     160                 :            :         throw (css::uno::RuntimeException);
     161                 :            :     virtual css::uno::Sequence<
     162                 :            :         css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL
     163                 :            :     getSupportedPackageTypes() throw (css::uno::RuntimeException);
     164                 :            : 
     165                 :            :     virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL
     166                 :            :     createAbortChannel() throw (css::uno::RuntimeException);
     167                 :            : 
     168                 :            :     virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addPackage(
     169                 :            :         ::rtl::OUString const & url,
     170                 :            :         css::uno::Sequence<css::beans::NamedValue> const & properties,
     171                 :            :         ::rtl::OUString const & mediaType,
     172                 :            :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     173                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     174                 :            :         throw (css::deployment::DeploymentException,
     175                 :            :                css::ucb::CommandFailedException,
     176                 :            :                css::ucb::CommandAbortedException,
     177                 :            :                css::lang::IllegalArgumentException,
     178                 :            :                css::uno::RuntimeException);
     179                 :            : 
     180                 :            :     virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL importExtension(
     181                 :            :         css::uno::Reference<css::deployment::XPackage> const & extension,
     182                 :            :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     183                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     184                 :            :         throw (css::deployment::DeploymentException,
     185                 :            :             css::ucb::CommandFailedException,
     186                 :            :             css::ucb::CommandAbortedException,
     187                 :            :             css::lang::IllegalArgumentException,
     188                 :            :             css::uno::RuntimeException);
     189                 :            : 
     190                 :            :     virtual void SAL_CALL removePackage(
     191                 :            :         ::rtl::OUString const & id, ::rtl::OUString const & fileName,
     192                 :            :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     193                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     194                 :            :         throw (css::deployment::DeploymentException,
     195                 :            :                css::ucb::CommandFailedException,
     196                 :            :                css::ucb::CommandAbortedException,
     197                 :            :                css::lang::IllegalArgumentException,
     198                 :            :                css::uno::RuntimeException);
     199                 :            : 
     200                 :            :     ::rtl::OUString getDeployPath( ActivePackages::Data const & data );
     201                 :            :     css::uno::Reference<css::deployment::XPackage> SAL_CALL getDeployedPackage_(
     202                 :            :         ::rtl::OUString const & id, ::rtl::OUString const & fileName,
     203                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
     204                 :            :     css::uno::Reference<css::deployment::XPackage> getDeployedPackage_(
     205                 :            :         ::rtl::OUString const & id, ActivePackages::Data const & data,
     206                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
     207                 :            :         bool ignoreAlienPlatforms = false );
     208                 :            :     virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL
     209                 :            :     getDeployedPackage(
     210                 :            :         ::rtl::OUString const & id, ::rtl::OUString const & fileName,
     211                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     212                 :            :         throw (css::deployment::DeploymentException,
     213                 :            :                css::ucb::CommandFailedException,
     214                 :            :                css::lang::IllegalArgumentException, css::uno::RuntimeException);
     215                 :            : 
     216                 :            :     css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
     217                 :            :     getDeployedPackages_(
     218                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
     219                 :            :     virtual css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
     220                 :            :     SAL_CALL getDeployedPackages(
     221                 :            :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     222                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     223                 :            :         throw (css::deployment::DeploymentException,
     224                 :            :                css::ucb::CommandFailedException,
     225                 :            :                css::ucb::CommandAbortedException,
     226                 :            :                css::lang::IllegalArgumentException,
     227                 :            :                css::uno::RuntimeException);
     228                 :            : 
     229                 :            :     virtual void SAL_CALL reinstallDeployedPackages(
     230                 :            :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     231                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     232                 :            :         throw (css::deployment::DeploymentException,
     233                 :            :                css::ucb::CommandFailedException,
     234                 :            :                css::ucb::CommandAbortedException,
     235                 :            :                css::lang::IllegalArgumentException,
     236                 :            :                css::uno::RuntimeException);
     237                 :            : 
     238                 :            :     virtual ::sal_Bool SAL_CALL isReadOnly(  )
     239                 :            :         throw (::com::sun::star::uno::RuntimeException);
     240                 :            : 
     241                 :            :     virtual ::sal_Bool SAL_CALL synchronize(
     242                 :            :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     243                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     244                 :            :         throw (css::deployment::DeploymentException,
     245                 :            :                css::ucb::CommandFailedException,
     246                 :            :                css::ucb::CommandAbortedException,
     247                 :            :                css::uno::RuntimeException);
     248                 :            : 
     249                 :            :     virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
     250                 :            :     getExtensionsWithUnacceptedLicenses(
     251                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
     252                 :            :         throw (css::deployment::DeploymentException,
     253                 :            :                css::uno::RuntimeException);
     254                 :            : 
     255                 :            :     virtual sal_Int32 SAL_CALL checkPrerequisites(
     256                 :            :         css::uno::Reference<css::deployment::XPackage> const & extension,
     257                 :            :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     258                 :            :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     259                 :            :         throw (css::deployment::DeploymentException,
     260                 :            :                css::ucb::CommandFailedException,
     261                 :            :                css::ucb::CommandAbortedException,
     262                 :            :                css::lang::IllegalArgumentException,
     263                 :            :                css::uno::RuntimeException);
     264                 :            :         };
     265                 :            : 
     266                 :            : //______________________________________________________________________________
     267                 :       1614 : inline void PackageManagerImpl::check()
     268                 :            : {
     269         [ +  - ]:       1614 :     ::osl::MutexGuard guard( getMutex() );
     270 [ +  - ][ -  + ]:       1614 :     if (rBHelper.bInDispose || rBHelper.bDisposed)
     271                 :            :         throw css::lang::DisposedException(
     272                 :            :             OUSTR("PackageManager instance has already been disposed!"),
     273 [ #  # ][ #  # ]:       1614 :             static_cast< ::cppu::OWeakObject * >(this) );
         [ #  # ][ +  - ]
     274                 :       1614 : }
     275                 :            : 
     276                 :            : //______________________________________________________________________________
     277                 :         22 : inline void PackageManagerImpl::logIntern( css::uno::Any const & status )
     278                 :            : {
     279         [ +  + ]:         22 :     if (m_xLogFile.is())
     280                 :         14 :         m_xLogFile->update( status );
     281                 :         22 : }
     282                 :            : 
     283                 :            : }
     284                 :            : 
     285                 :            : #endif
     286                 :            : 
     287                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10