LCOV - code coverage report
Current view: top level - desktop/source/deployment/registry/inc - dp_backend.h (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 7 0.0 %
Date: 2014-04-14 Functions: 0 5 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             : #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_REGISTRY_INC_DP_BACKEND_H
      21             : #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_REGISTRY_INC_DP_BACKEND_H
      22             : 
      23             : #include "dp_misc.h"
      24             : #include "dp_resource.h"
      25             : #include "dp_interact.h"
      26             : #include "rtl/ref.hxx"
      27             : #include "cppuhelper/weakref.hxx"
      28             : #include "cppuhelper/implbase1.hxx"
      29             : #include "cppuhelper/compbase1.hxx"
      30             : #include "cppuhelper/compbase2.hxx"
      31             : #include "tools/inetmime.hxx"
      32             : #include "com/sun/star/lang/XEventListener.hpp"
      33             : #include "com/sun/star/deployment/XPackageRegistry.hpp"
      34             : #include "com/sun/star/deployment/XPackageManager.hpp"
      35             : #include "com/sun/star/deployment/InvalidRemovedParameterException.hpp"
      36             : #include <boost/unordered_map.hpp>
      37             : #include <list>
      38             : #include "dp_registry.hrc"
      39             : 
      40             : namespace dp_registry
      41             : {
      42             : namespace backend
      43             : {
      44             : 
      45             : class PackageRegistryBackend;
      46             : 
      47             : #define BACKEND_SERVICE_NAME "com.sun.star.deployment.PackageRegistryBackend"
      48             : 
      49             : typedef ::cppu::WeakComponentImplHelper1<
      50             :     css::deployment::XPackage > t_PackageBase;
      51             : 
      52             : 
      53             : class Package : protected ::dp_misc::MutexHolder, public t_PackageBase
      54             : {
      55             :     PackageRegistryBackend * getMyBackend() const;
      56             :     void processPackage_impl(
      57             :         bool registerPackage,
      58             :         bool startup,
      59             :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
      60             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
      61             : 
      62             : protected:
      63             :     ::rtl::Reference<PackageRegistryBackend> m_myBackend;
      64             :     const OUString m_url;
      65             :     OUString m_name;
      66             :     OUString m_displayName;
      67             :     const css::uno::Reference<css::deployment::XPackageTypeInfo> m_xPackageType;
      68             :     const bool m_bRemoved;
      69             :     //Only set if m_bRemoved = true;
      70             :     const OUString m_identifier;
      71             : 
      72             :     void check() const;
      73             :     void fireModified();
      74             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
      75             : 
      76             :     void checkAborted(
      77             :         ::rtl::Reference< ::dp_misc::AbortChannel > const & abortChannel );
      78             : 
      79             :     // @@@ to be implemented by specific backend:
      80             :     virtual css::beans::Optional< css::beans::Ambiguous<sal_Bool> >
      81             :     isRegistered_(
      82             :         ::osl::ResettableMutexGuard & guard,
      83             :         ::rtl::Reference< ::dp_misc::AbortChannel > const & abortChannel,
      84             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
      85             :         = 0;
      86             :     virtual void processPackage_(
      87             :         ::osl::ResettableMutexGuard & guard,
      88             :         bool registerPackage,
      89             :         bool startup,
      90             :         ::rtl::Reference< ::dp_misc::AbortChannel > const & abortChannel,
      91             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
      92             :         = 0;
      93             : 
      94             :     virtual ~Package();
      95             :     Package( ::rtl::Reference<PackageRegistryBackend> const & myBackend,
      96             :              OUString const & url,
      97             :              OUString const & name,
      98             :              OUString const & displayName,
      99             :              css::uno::Reference<css::deployment::XPackageTypeInfo> const &
     100             :              xPackageType,
     101             :              bool bRemoved,
     102             :              OUString const & identifier);
     103             : 
     104             : public:
     105             : 
     106             :     class TypeInfo :
     107             :         public ::cppu::WeakImplHelper1<css::deployment::XPackageTypeInfo>
     108             :     {
     109             :         const OUString m_mediaType;
     110             :         const OUString m_fileFilter;
     111             :         const OUString m_shortDescr;
     112             :         const sal_uInt16 m_smallIcon;
     113             :     public:
     114             :         virtual ~TypeInfo();
     115           0 :         TypeInfo( OUString const & mediaType,
     116             :                   OUString const & fileFilter,
     117             :                   OUString const & shortDescr,
     118             :                   sal_uInt16 smallIcon)
     119             :             : m_mediaType(mediaType), m_fileFilter(fileFilter),
     120             :               m_shortDescr(shortDescr),
     121           0 :               m_smallIcon(smallIcon)
     122           0 :             {}
     123             :         // XPackageTypeInfo
     124             :         virtual OUString SAL_CALL getMediaType()
     125             :             throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     126             :         virtual OUString SAL_CALL getDescription()
     127             :             throw (css::deployment::ExtensionRemovedException,
     128             :                    css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     129             :         virtual OUString SAL_CALL getShortDescription()
     130             :             throw (css::deployment::ExtensionRemovedException,
     131             :                    css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     132             :         virtual OUString SAL_CALL getFileFilter()
     133             :             throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     134             :         virtual css::uno::Any SAL_CALL getIcon( sal_Bool highContrast,
     135             :                                                 sal_Bool smallIcon )
     136             :             throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     137             :     };
     138             : 
     139             :     // XComponent
     140             :     virtual void SAL_CALL dispose() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             :     virtual void SAL_CALL addEventListener(
     142             :         css::uno::Reference<css::lang::XEventListener> const & xListener )
     143             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     144             :     virtual void SAL_CALL removeEventListener(
     145             :         css::uno::Reference<css::lang::XEventListener> const & xListener )
     146             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     147             : 
     148             :     // XModifyBroadcaster
     149             :     virtual void SAL_CALL addModifyListener(
     150             :         css::uno::Reference<css::util::XModifyListener> const & xListener )
     151             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     152             :     virtual void SAL_CALL removeModifyListener(
     153             :         css::uno::Reference<css::util::XModifyListener> const & xListener )
     154             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     155             : 
     156             :     // XPackage
     157             :     virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL
     158             :     createAbortChannel() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     159             :     virtual css::beans::Optional< css::beans::Ambiguous<sal_Bool> >
     160             :     SAL_CALL isRegistered(
     161             :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     162             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     163             :         throw (css::deployment::DeploymentException,
     164             :                css::ucb::CommandFailedException,
     165             :                css::ucb::CommandAbortedException,
     166             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             : 
     168             :     virtual ::sal_Int32 SAL_CALL checkPrerequisites(
     169             :         const css::uno::Reference< css::task::XAbortChannel >& xAbortChannel,
     170             :         const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv,
     171             :         sal_Bool noLicenseChecking)
     172             :         throw (css::deployment::DeploymentException,
     173             :                css::deployment::ExtensionRemovedException,
     174             :                css::ucb::CommandFailedException,
     175             :                css::ucb::CommandAbortedException,
     176             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     177             : 
     178             :     virtual ::sal_Bool SAL_CALL checkDependencies(
     179             :         const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv )
     180             :         throw (css::deployment::DeploymentException,
     181             :                css::deployment::ExtensionRemovedException,
     182             :                css::ucb::CommandFailedException,
     183             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     184             : 
     185             :     virtual void SAL_CALL registerPackage(
     186             :         sal_Bool startup,
     187             :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     188             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     189             :         throw (css::deployment::DeploymentException,
     190             :                css::deployment::ExtensionRemovedException,
     191             :                css::ucb::CommandFailedException,
     192             :                css::ucb::CommandAbortedException,
     193             :                css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     194             :     virtual void SAL_CALL revokePackage(
     195             :         sal_Bool startup,
     196             :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     197             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     198             :         throw (css::deployment::DeploymentException,
     199             :                css::ucb::CommandFailedException,
     200             :                css::ucb::CommandAbortedException,
     201             :                css::lang::IllegalArgumentException,
     202             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     203             :     virtual sal_Bool SAL_CALL isBundle()
     204             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     205             :     virtual css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
     206             :     SAL_CALL getBundle(
     207             :         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
     208             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     209             :         throw (css::deployment::DeploymentException,
     210             :                css::ucb::CommandFailedException,
     211             :                css::ucb::CommandAbortedException,
     212             :                css::lang::IllegalArgumentException,
     213             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     214             :     virtual OUString SAL_CALL getName()
     215             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     216             :     virtual css::beans::Optional< OUString > SAL_CALL getIdentifier()
     217             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     218             :     virtual OUString SAL_CALL getVersion()
     219             :         throw (css::deployment::ExtensionRemovedException,
     220             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     221             :     virtual OUString SAL_CALL getURL()
     222             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     223             :     virtual OUString SAL_CALL getDisplayName()
     224             :         throw (css::deployment::ExtensionRemovedException,
     225             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     226             :     virtual OUString SAL_CALL getDescription()
     227             :         throw (css::deployment::ExtensionRemovedException,
     228             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     229             :     virtual OUString SAL_CALL getLicenseText()
     230             :         throw (css::deployment::ExtensionRemovedException,
     231             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     232             :     virtual css::uno::Sequence< OUString > SAL_CALL
     233             :     getUpdateInformationURLs()
     234             :         throw (css::deployment::ExtensionRemovedException,
     235             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     236             :     virtual css::beans::StringPair SAL_CALL getPublisherInfo()
     237             :         throw (css::deployment::ExtensionRemovedException,
     238             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     239             :     virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL
     240             :     getIcon( sal_Bool bHighContrast )
     241             :         throw (css::deployment::ExtensionRemovedException,
     242             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     243             :     virtual css::uno::Reference<css::deployment::XPackageTypeInfo> SAL_CALL
     244             :     getPackageType() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     245             :     virtual void SAL_CALL exportTo(
     246             :         OUString const & destFolderURL,
     247             :         OUString const & newTitle,
     248             :         sal_Int32 nameClashAction,
     249             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     250             :         throw (css::deployment::ExtensionRemovedException,
     251             :                css::ucb::CommandFailedException,
     252             :                css::ucb::CommandAbortedException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     253             :     virtual OUString SAL_CALL getRepositoryName()
     254             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     255             :     virtual css::beans::Optional< OUString > SAL_CALL getRegistrationDataURL()
     256             :         throw (css::deployment::ExtensionRemovedException,
     257             :                css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     258             :     virtual sal_Bool SAL_CALL isRemoved()
     259             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     260             : 
     261             : };
     262             : 
     263             : typedef ::cppu::WeakComponentImplHelper2<
     264             :     css::lang::XEventListener,
     265             :     css::deployment::XPackageRegistry > t_BackendBase;
     266             : 
     267             : 
     268             : class PackageRegistryBackend
     269             :     : protected ::dp_misc::MutexHolder, public t_BackendBase
     270             : {
     271             :     //The map held originally WeakReferences. The map entries are removed in the disposing
     272             :     //function, which is called when the XPackages are destructed or they are
     273             :     //explicitly disposed. The latter happens, for example, when a extension is
     274             :     //removed (see dp_manager.cxx). However, because of how the help systems work, now
     275             :     // XPackageManager::getDeployedPackages is called often. This results in a lot
     276             :     //of bindPackage calls which are costly. Therefore we keep hard references in
     277             :     //the map now.
     278             :     typedef ::boost::unordered_map<
     279             :         OUString, css::uno::Reference<css::deployment::XPackage>,
     280             :         OUStringHash > t_string2ref;
     281             :     t_string2ref m_bound;
     282             : 
     283             : protected:
     284             :     OUString m_cachePath;
     285             :     css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
     286             : 
     287             :     OUString m_context;
     288             :     // currently only for library containers:
     289             :     enum {
     290             :         CONTEXT_UNKNOWN,
     291             :         CONTEXT_USER, CONTEXT_SHARED,CONTEXT_BUNDLED, CONTEXT_TMP,
     292             :         CONTEXT_DOCUMENT
     293             :     } m_eContext;
     294             :     bool m_readOnly;
     295             : 
     296             :     struct StrCannotDetectMediaType : public ::dp_misc::StaticResourceString<
     297             :         StrCannotDetectMediaType, RID_STR_CANNOT_DETECT_MEDIA_TYPE> {};
     298             :     struct StrUnsupportedMediaType : public ::dp_misc::StaticResourceString<
     299             :         StrUnsupportedMediaType, RID_STR_UNSUPPORTED_MEDIA_TYPE> {};
     300             : 
     301             :     // @@@ to be implemented by specific backend:
     302             :     virtual css::uno::Reference<css::deployment::XPackage> bindPackage_(
     303             :         OUString const & url, OUString const & mediaType,
     304             :         sal_Bool bRemoved, OUString const & identifier,
     305             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     306             :         = 0;
     307             : 
     308             :     void check();
     309             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     310             : 
     311             :     virtual ~PackageRegistryBackend();
     312             :     PackageRegistryBackend(
     313             :         css::uno::Sequence<css::uno::Any> const & args,
     314             :         css::uno::Reference<css::uno::XComponentContext> const & xContext );
     315             : 
     316             :     /* creates a folder with a unique name.
     317             :        If url is empty then it is created in the backend folder, otherwise
     318             :        at a location relative to that folder specified by url.
     319             :     */
     320             :     OUString createFolder(
     321             :         OUString const & relUrl,
     322             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
     323             :     /* deletes folders and files.
     324             : 
     325             :        All folder all files which end with ".tmp" or ".tmp_" and which are
     326             :        not used are deleted.
     327             :      */
     328             :     void deleteUnusedFolders(
     329             :         OUString const & relUrl,
     330             :         ::std::list< OUString> const & usedFolders);
     331             :     /* deletes one folder with a "temporary" name and the corresponding
     332             :        tmp file, which was used to derive the folder name.
     333             :     */
     334             :     static void deleteTempFolder(
     335             :         OUString const & folderUrl);
     336             : 
     337             :     OUString getSharedRegistrationDataURL(
     338             :         css::uno::Reference<css::deployment::XPackage> const & extension,
     339             :         css::uno::Reference<css::deployment::XPackage> const & item);
     340             : 
     341             :     /* The backends must implement this function, which is called
     342             :        from XPackageRegistry::packageRemoved (also implemented here).
     343             :        This ensure that the backends clean up their registration data
     344             :        when an extension was removed.
     345             :     */
     346             : //    virtual void deleteDbEntry( OUString const & url) = 0;
     347             : 
     348             : 
     349             : 
     350             : public:
     351             :     struct StrRegisteringPackage : public ::dp_misc::StaticResourceString<
     352             :         StrRegisteringPackage, RID_STR_REGISTERING_PACKAGE> {};
     353             :     struct StrRevokingPackage : public ::dp_misc::StaticResourceString<
     354             :         StrRevokingPackage, RID_STR_REVOKING_PACKAGE> {};
     355             : 
     356             :     inline css::uno::Reference<css::uno::XComponentContext> const &
     357           0 :     getComponentContext() const { return m_xComponentContext; }
     358             : 
     359           0 :     inline OUString const & getCachePath() const { return m_cachePath; }
     360           0 :     inline bool transientMode() const { return m_cachePath.isEmpty(); }
     361             : 
     362           0 :     inline OUString getContext() const {return m_context; }
     363             : 
     364             :     // XEventListener
     365             :     virtual void SAL_CALL disposing( css::lang::EventObject const & evt )
     366             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     367             : 
     368             :     // XPackageRegistry
     369             :     virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL bindPackage(
     370             :         OUString const & url, OUString const & mediaType,
     371             :         sal_Bool bRemoved, OUString const & identifier,
     372             :         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
     373             :         throw (css::deployment::DeploymentException,
     374             :                css::deployment::InvalidRemovedParameterException,
     375             :                css::ucb::CommandFailedException,
     376             :                css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     377             : 
     378             : //     virtual void SAL_CALL packageRemoved(
     379             : //         OUString const & url, OUString const & mediaType)
     380             : //         throw (css::deployment::DeploymentException,
     381             : //                css::uno::RuntimeException);
     382             : 
     383             : };
     384             : 
     385             : }
     386             : }
     387             : 
     388             : #endif
     389             : 
     390             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10