LCOV - code coverage report
Current view: top level - desktop/source/deployment/registry - dp_registry.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 156 175 89.1 %
Date: 2014-04-11 Functions: 14 15 93.3 %
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 "dp_registry.hrc"
      22             : #include "dp_misc.h"
      23             : #include "dp_resource.h"
      24             : #include "dp_interact.h"
      25             : #include "dp_ucb.h"
      26             : #include "osl/diagnose.h"
      27             : #include "rtl/ustrbuf.hxx"
      28             : #include "rtl/uri.hxx"
      29             : #include "cppuhelper/compbase2.hxx"
      30             : #include "cppuhelper/exc_hlp.hxx"
      31             : #include "comphelper/sequence.hxx"
      32             : #include "ucbhelper/content.hxx"
      33             : #include "com/sun/star/uno/DeploymentException.hpp"
      34             : #include "com/sun/star/lang/DisposedException.hpp"
      35             : #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
      36             : #include "com/sun/star/lang/XServiceInfo.hpp"
      37             : #include "com/sun/star/lang/XSingleComponentFactory.hpp"
      38             : #include "com/sun/star/lang/XSingleServiceFactory.hpp"
      39             : #include "com/sun/star/util/XUpdatable.hpp"
      40             : #include "com/sun/star/container/XContentEnumerationAccess.hpp"
      41             : #include "com/sun/star/deployment/PackageRegistryBackend.hpp"
      42             : #include <boost/unordered_map.hpp>
      43             : #include <set>
      44             : #include <boost/unordered_set.hpp>
      45             : 
      46             : using namespace ::dp_misc;
      47             : using namespace ::com::sun::star;
      48             : using namespace ::com::sun::star::uno;
      49             : using namespace ::com::sun::star::ucb;
      50             : 
      51             : 
      52             : namespace dp_registry {
      53             : 
      54             : namespace backend {
      55             : namespace bundle {
      56             : Reference<deployment::XPackageRegistry> create(
      57             :     Reference<deployment::XPackageRegistry> const & xRootRegistry,
      58             :     OUString const & context, OUString const & cachePath, bool readOnly,
      59             :     Reference<XComponentContext> const & xComponentContext );
      60             : }
      61             : }
      62             : 
      63             : namespace {
      64             : 
      65             : typedef ::cppu::WeakComponentImplHelper2<
      66             :     deployment::XPackageRegistry, util::XUpdatable > t_helper;
      67             : 
      68             : 
      69             : class PackageRegistryImpl : private MutexHolder, public t_helper
      70             : {
      71             :     struct ci_string_hash {
      72        7614 :         ::std::size_t operator () ( OUString const & str ) const {
      73        7614 :             return str.toAsciiLowerCase().hashCode();
      74             :         }
      75             :     };
      76             :     struct ci_string_equals {
      77        1485 :         bool operator () ( OUString const & str1, OUString const & str2 ) const{
      78        1485 :             return str1.equalsIgnoreAsciiCase( str2 );
      79             :         }
      80             :     };
      81             :     typedef ::boost::unordered_map<
      82             :         OUString, Reference<deployment::XPackageRegistry>,
      83             :         ci_string_hash, ci_string_equals > t_string2registry;
      84             :     typedef ::boost::unordered_map<
      85             :         OUString, OUString,
      86             :         ci_string_hash, ci_string_equals > t_string2string;
      87             :     typedef ::std::set<
      88             :         Reference<deployment::XPackageRegistry> > t_registryset;
      89             : 
      90             :     t_string2registry m_mediaType2backend;
      91             :     t_string2string m_filter2mediaType;
      92             :     t_registryset m_ambiguousBackends;
      93             :     t_registryset m_allBackends;
      94             :     ::std::vector< Reference<deployment::XPackageTypeInfo> > m_typesInfos;
      95             : 
      96             :     void insertBackend(
      97             :         Reference<deployment::XPackageRegistry> const & xBackend );
      98             : 
      99             : protected:
     100             :     inline void check();
     101             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     102             : 
     103             :     virtual ~PackageRegistryImpl();
     104         256 :     PackageRegistryImpl() : t_helper( getMutex() ) {}
     105             : 
     106             : 
     107             : public:
     108             :     static Reference<deployment::XPackageRegistry> create(
     109             :         OUString const & context,
     110             :         OUString const & cachePath, bool readOnly,
     111             :         Reference<XComponentContext> const & xComponentContext );
     112             : 
     113             :     // XUpdatable
     114             :     virtual void SAL_CALL update() throw (RuntimeException, std::exception) SAL_OVERRIDE;
     115             : 
     116             :     // XPackageRegistry
     117             :     virtual Reference<deployment::XPackage> SAL_CALL bindPackage(
     118             :         OUString const & url, OUString const & mediaType, sal_Bool bRemoved,
     119             :         OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv )
     120             :         throw (deployment::DeploymentException,
     121             :                deployment::InvalidRemovedParameterException,
     122             :                CommandFailedException,
     123             :                lang::IllegalArgumentException, RuntimeException, std::exception) SAL_OVERRIDE;
     124             :     virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL
     125             :     getSupportedPackageTypes() throw (RuntimeException, std::exception) SAL_OVERRIDE;
     126             :     virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType)
     127             :                 throw (deployment::DeploymentException,
     128             :                 RuntimeException, std::exception) SAL_OVERRIDE;
     129             : 
     130             : };
     131             : 
     132             : 
     133          46 : inline void PackageRegistryImpl::check()
     134             : {
     135          46 :     ::osl::MutexGuard guard( getMutex() );
     136          46 :     if (rBHelper.bInDispose || rBHelper.bDisposed) {
     137             :         throw lang::DisposedException(
     138             :             "PackageRegistry instance has already been disposed!",
     139           0 :             static_cast<OWeakObject *>(this) );
     140          46 :     }
     141          46 : }
     142             : 
     143             : 
     144         256 : void PackageRegistryImpl::disposing()
     145             : {
     146             :     // dispose all backends:
     147         256 :     t_registryset::const_iterator iPos( m_allBackends.begin() );
     148         256 :     t_registryset::const_iterator const iEnd( m_allBackends.end() );
     149        1971 :     for ( ; iPos != iEnd; ++iPos ) {
     150        1715 :         try_dispose( *iPos );
     151             :     }
     152         256 :     m_mediaType2backend = t_string2registry();
     153         256 :     m_ambiguousBackends = t_registryset();
     154         256 :     m_allBackends = t_registryset();
     155             : 
     156         256 :     t_helper::disposing();
     157         256 : }
     158             : 
     159             : 
     160         512 : PackageRegistryImpl::~PackageRegistryImpl()
     161             : {
     162         512 : }
     163             : 
     164             : 
     165        3686 : OUString normalizeMediaType( OUString const & mediaType )
     166             : {
     167        3686 :     OUStringBuffer buf;
     168        3686 :     sal_Int32 index = 0;
     169             :     for (;;) {
     170        7372 :         buf.append( mediaType.getToken( 0, '/', index ).trim() );
     171        7372 :         if (index < 0)
     172        3686 :             break;
     173        3686 :         buf.append( '/' );
     174             :     }
     175        3686 :     return buf.makeStringAndClear();
     176             : }
     177             : 
     178             : 
     179             : 
     180           4 : void PackageRegistryImpl::packageRemoved(
     181             :     OUString const & url, OUString const & mediaType)
     182             :     throw (css::deployment::DeploymentException,
     183             :            css::uno::RuntimeException, std::exception)
     184             : {
     185             :     const t_string2registry::const_iterator i =
     186           4 :         m_mediaType2backend.find(mediaType);
     187             : 
     188           4 :     if (i != m_mediaType2backend.end())
     189             :     {
     190           4 :         i->second->packageRemoved(url, mediaType);
     191             :     }
     192           4 : }
     193             : 
     194        1715 : void PackageRegistryImpl::insertBackend(
     195             :     Reference<deployment::XPackageRegistry> const & xBackend )
     196             : {
     197        1715 :     m_allBackends.insert( xBackend );
     198             :     typedef ::boost::unordered_set<OUString, OUStringHash> t_stringset;
     199        1715 :     t_stringset ambiguousFilters;
     200             : 
     201             :     const Sequence< Reference<deployment::XPackageTypeInfo> > packageTypes(
     202        3430 :         xBackend->getSupportedPackageTypes() );
     203        5390 :     for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos )
     204             :     {
     205             :         Reference<deployment::XPackageTypeInfo> const & xPackageType =
     206        3675 :             packageTypes[ pos ];
     207        3675 :         m_typesInfos.push_back( xPackageType );
     208             : 
     209             :         const OUString mediaType( normalizeMediaType(
     210        3675 :                                       xPackageType->getMediaType() ) );
     211             :         ::std::pair<t_string2registry::iterator, bool> mb_insertion(
     212             :             m_mediaType2backend.insert( t_string2registry::value_type(
     213        3675 :                                             mediaType, xBackend ) ) );
     214        3675 :         if (mb_insertion.second)
     215             :         {
     216             :             // add parameterless media-type, too:
     217        3675 :             sal_Int32 semi = mediaType.indexOf( ';' );
     218        3675 :             if (semi >= 0) {
     219             :                 m_mediaType2backend.insert(
     220             :                     t_string2registry::value_type(
     221        1225 :                         mediaType.copy( 0, semi ), xBackend ) );
     222             :             }
     223        3675 :             const OUString fileFilter( xPackageType->getFileFilter() );
     224             :             //The package backend shall also be called to determine the mediatype
     225             :             //(XPackageRegistry.bindPackage) when the URL points to a directory.
     226        3675 :             const bool bExtension = (mediaType == "application/vnd.sun.star.package-bundle");
     227        3675 :             if (fileFilter.isEmpty() || fileFilter == "*.*" || fileFilter == "*" || bExtension)
     228             :             {
     229        1470 :                 m_ambiguousBackends.insert( xBackend );
     230             :             }
     231             :             else
     232             :             {
     233        2205 :                 sal_Int32 nIndex = 0;
     234        2205 :                 do {
     235        2205 :                     OUString token( fileFilter.getToken( 0, ';', nIndex ) );
     236        2205 :                     if (token.match( "*." ))
     237        2205 :                         token = token.copy( 1 );
     238        2205 :                     if (token.isEmpty())
     239           0 :                         continue;
     240             :                     // mark any further wildcards ambig:
     241        4410 :                     bool ambig = (token.indexOf('*') >= 0 ||
     242        4410 :                                   token.indexOf('?') >= 0);
     243        2205 :                     if (! ambig) {
     244             :                         ::std::pair<t_string2string::iterator, bool> ins(
     245             :                             m_filter2mediaType.insert(
     246             :                                 t_string2string::value_type(
     247        2205 :                                     token, mediaType ) ) );
     248        2205 :                         ambig = !ins.second;
     249        2205 :                         if (ambig) {
     250             :                             // filter has already been in: add previously
     251             :                             // added backend to ambig set
     252             :                             const t_string2registry::const_iterator iFind(
     253             :                                 m_mediaType2backend.find(
     254             :                                     /* media-type of pr. added backend */
     255         245 :                                     ins.first->second ) );
     256             :                             OSL_ASSERT(
     257             :                                 iFind != m_mediaType2backend.end() );
     258         245 :                             if (iFind != m_mediaType2backend.end())
     259         245 :                                 m_ambiguousBackends.insert( iFind->second );
     260             :                         }
     261             :                     }
     262        2205 :                     if (ambig) {
     263         245 :                         m_ambiguousBackends.insert( xBackend );
     264             :                         // mark filter to be removed later from filters map:
     265         245 :                         ambiguousFilters.insert( token );
     266        2205 :                     }
     267             :                 }
     268        2205 :                 while (nIndex >= 0);
     269        3675 :             }
     270             :         }
     271             : #if OSL_DEBUG_LEVEL > 0
     272             :         else
     273             :         {
     274             :             OUStringBuffer buf;
     275             :             buf.appendAscii( "more than one PackageRegistryBackend for media-type=\"" );
     276             :             buf.append( mediaType );
     277             :             buf.appendAscii( "\" => " );
     278             :             buf.append( Reference<lang::XServiceInfo>(
     279             :                             xBackend, UNO_QUERY_THROW )->
     280             :                         getImplementationName() );
     281             :             buf.appendAscii( "\"!" );
     282             :             OSL_FAIL( OUStringToOString(
     283             :                             buf.makeStringAndClear(),
     284             :                             RTL_TEXTENCODING_UTF8).getStr() );
     285             :         }
     286             : #endif
     287        3675 :     }
     288             : 
     289             :     // cut out ambiguous filters:
     290        1715 :     t_stringset::const_iterator iPos( ambiguousFilters.begin() );
     291        1715 :     const t_stringset::const_iterator iEnd( ambiguousFilters.end() );
     292        1960 :     for ( ; iPos != iEnd; ++iPos ) {
     293         245 :         m_filter2mediaType.erase( *iPos );
     294        1715 :     }
     295        1715 : }
     296             : 
     297             : 
     298         256 : Reference<deployment::XPackageRegistry> PackageRegistryImpl::create(
     299             :     OUString const & context,
     300             :     OUString const & cachePath, bool readOnly,
     301             :     Reference<XComponentContext> const & xComponentContext )
     302             : {
     303         256 :     PackageRegistryImpl * that = new PackageRegistryImpl;
     304         256 :     Reference<deployment::XPackageRegistry> xRet(that);
     305             : 
     306             :     // auto-detect all registered package registries:
     307             :     Reference<container::XEnumeration> xEnum(
     308             :         Reference<container::XContentEnumerationAccess>(
     309         256 :             xComponentContext->getServiceManager(),
     310         768 :             UNO_QUERY_THROW )->createContentEnumeration(
     311         768 :                 "com.sun.star.deployment.PackageRegistryBackend" ) );
     312         256 :     if (xEnum.is())
     313             :     {
     314        1982 :         while (xEnum->hasMoreElements())
     315             :         {
     316        1481 :             Any element( xEnum->nextElement() );
     317        2962 :             Sequence<Any> registryArgs(cachePath.isEmpty() ? 1 : 3 );
     318        1481 :             registryArgs[ 0 ] <<= context;
     319        1481 :             if (!cachePath.isEmpty())
     320             :             {
     321             :                 Reference<lang::XServiceInfo> xServiceInfo(
     322        1481 :                     element, UNO_QUERY_THROW );
     323             :                 OUString registryCachePath(
     324             :                     makeURL( cachePath,
     325             :                              ::rtl::Uri::encode(
     326        1481 :                                  xServiceInfo->getImplementationName(),
     327             :                                  rtl_UriCharClassPchar,
     328             :                                  rtl_UriEncodeIgnoreEscapes,
     329        2962 :                                  RTL_TEXTENCODING_UTF8 ) ) );
     330        1481 :                 registryArgs[ 1 ] <<= registryCachePath;
     331        1481 :                 registryArgs[ 2 ] <<= readOnly;
     332        1481 :                 if (! readOnly)
     333             :                     create_folder( 0, registryCachePath,
     334        2973 :                                    Reference<XCommandEnvironment>() );
     335             :             }
     336             : 
     337        2940 :             Reference<deployment::XPackageRegistry> xBackend;
     338        2940 :             Reference<lang::XSingleComponentFactory> xFac( element, UNO_QUERY );
     339        1470 :             if (xFac.is()) {
     340             :                 xBackend.set(
     341        1470 :                     xFac->createInstanceWithArgumentsAndContext(
     342        1470 :                         registryArgs, xComponentContext ), UNO_QUERY );
     343             :             }
     344             :             else {
     345             :                 Reference<lang::XSingleServiceFactory> xSingleServiceFac(
     346           0 :                     element, UNO_QUERY_THROW );
     347             :                 xBackend.set(
     348           0 :                     xSingleServiceFac->createInstanceWithArguments(
     349           0 :                         registryArgs ), UNO_QUERY );
     350             :             }
     351        1470 :             if (! xBackend.is()) {
     352             :                 throw DeploymentException(
     353             :                     "cannot instantiate PackageRegistryBackend service: "
     354           0 :                     + Reference<lang::XServiceInfo>(
     355           0 :                         element, UNO_QUERY_THROW )->getImplementationName(),
     356           0 :                     static_cast<OWeakObject *>(that) );
     357             :             }
     358             : 
     359        1470 :             that->insertBackend( xBackend );
     360        1481 :         }
     361             :     }
     362             : 
     363             :     // Insert bundle back-end.
     364             :     // Always register as last, because we want to add extensions also as folders
     365             :     // and as a default we accept every folder, which was not recognized by the other
     366             :     // backends.
     367             :     Reference<deployment::XPackageRegistry> extensionBackend =
     368             :         ::dp_registry::backend::bundle::create(
     369         490 :             that, context, cachePath, readOnly, xComponentContext);
     370         245 :     that->insertBackend(extensionBackend);
     371             : 
     372             :     Reference<lang::XServiceInfo> xServiceInfo(
     373         490 :         extensionBackend, UNO_QUERY_THROW );
     374             : 
     375             :     OSL_ASSERT(xServiceInfo.is());
     376             :     OUString registryCachePath(
     377             :         makeURL( cachePath,
     378             :                  ::rtl::Uri::encode(
     379         245 :                      xServiceInfo->getImplementationName(),
     380             :                      rtl_UriCharClassPchar,
     381             :                      rtl_UriEncodeIgnoreEscapes,
     382         490 :                      RTL_TEXTENCODING_UTF8 ) ) );
     383         245 :     create_folder( 0, registryCachePath, Reference<XCommandEnvironment>());
     384             : 
     385             : 
     386             : #if OSL_DEBUG_LEVEL > 1
     387             :     // dump tables:
     388             :     {
     389             :         t_registryset allBackends;
     390             :         dp_misc::TRACE("> [dp_registry.cxx] media-type detection:\n\n" );
     391             :         for ( t_string2string::const_iterator iPos(
     392             :                   that->m_filter2mediaType.begin() );
     393             :               iPos != that->m_filter2mediaType.end(); ++iPos )
     394             :         {
     395             :             OUStringBuffer buf;
     396             :             buf.appendAscii( "extension \"" );
     397             :             buf.append( iPos->first );
     398             :             buf.appendAscii( "\" maps to media-type \"" );
     399             :             buf.append( iPos->second );
     400             :             buf.appendAscii( "\" maps to backend " );
     401             :             const Reference<deployment::XPackageRegistry> xBackend(
     402             :                 that->m_mediaType2backend.find( iPos->second )->second );
     403             :             allBackends.insert( xBackend );
     404             :             buf.append( Reference<lang::XServiceInfo>(
     405             :                             xBackend, UNO_QUERY_THROW )
     406             :                         ->getImplementationName() );
     407             :             dp_misc::writeConsole( buf.makeStringAndClear() + "\n");
     408             :         }
     409             :         dp_misc::TRACE( "> [dp_registry.cxx] ambiguous backends:\n\n" );
     410             :         for ( t_registryset::const_iterator iPos(
     411             :                   that->m_ambiguousBackends.begin() );
     412             :               iPos != that->m_ambiguousBackends.end(); ++iPos )
     413             :         {
     414             :             OUStringBuffer buf;
     415             :             buf.append(
     416             :                 Reference<lang::XServiceInfo>(
     417             :                     *iPos, UNO_QUERY_THROW )->getImplementationName() );
     418             :             buf.appendAscii( ": " );
     419             :             const Sequence< Reference<deployment::XPackageTypeInfo> > types(
     420             :                 (*iPos)->getSupportedPackageTypes() );
     421             :             for ( sal_Int32 pos = 0; pos < types.getLength(); ++pos ) {
     422             :                 Reference<deployment::XPackageTypeInfo> const & xInfo =
     423             :                     types[ pos ];
     424             :                 buf.append( xInfo->getMediaType() );
     425             :                 const OUString filter( xInfo->getFileFilter() );
     426             :                 if (!filter.isEmpty()) {
     427             :                     buf.appendAscii( " (" );
     428             :                     buf.append( filter );
     429             :                     buf.appendAscii( ")" );
     430             :                 }
     431             :                 if (pos < (types.getLength() - 1))
     432             :                     buf.appendAscii( ", " );
     433             :             }
     434             :             dp_misc::TRACE(buf.makeStringAndClear() + "\n\n");
     435             :         }
     436             :         allBackends.insert( that->m_ambiguousBackends.begin(),
     437             :                             that->m_ambiguousBackends.end() );
     438             :         OSL_ASSERT( allBackends == that->m_allBackends );
     439             :     }
     440             : #endif
     441             : 
     442         490 :     return xRet;
     443             : }
     444             : 
     445             : // XUpdatable: broadcast to backends
     446             : 
     447          32 : void PackageRegistryImpl::update() throw (RuntimeException, std::exception)
     448             : {
     449          32 :     check();
     450          32 :     t_registryset::const_iterator iPos( m_allBackends.begin() );
     451          32 :     const t_registryset::const_iterator iEnd( m_allBackends.end() );
     452         256 :     for ( ; iPos != iEnd; ++iPos ) {
     453         224 :         const Reference<util::XUpdatable> xUpdatable( *iPos, UNO_QUERY );
     454         224 :         if (xUpdatable.is())
     455          32 :             xUpdatable->update();
     456         224 :     }
     457          32 : }
     458             : 
     459             : // XPackageRegistry
     460             : 
     461          14 : Reference<deployment::XPackage> PackageRegistryImpl::bindPackage(
     462             :     OUString const & url, OUString const & mediaType_, sal_Bool bRemoved,
     463             :     OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv )
     464             :     throw (deployment::DeploymentException, deployment::InvalidRemovedParameterException,
     465             :            CommandFailedException,
     466             :            lang::IllegalArgumentException, RuntimeException, std::exception)
     467             : {
     468          14 :     check();
     469          14 :     OUString mediaType(mediaType_);
     470          14 :     if (mediaType.isEmpty())
     471             :     {
     472           3 :         ::ucbhelper::Content ucbContent;
     473           3 :         if (create_ucb_content(
     474           3 :                 &ucbContent, url, xCmdEnv, false /* no throw */ )
     475           3 :                 && !ucbContent.isFolder())
     476             :         {
     477           2 :             OUString title( StrTitle::getTitle( ucbContent ) );
     478             :             for (;;)
     479             :             {
     480             :                 const t_string2string::const_iterator iFind(
     481           4 :                     m_filter2mediaType.find(title) );
     482           4 :                 if (iFind != m_filter2mediaType.end()) {
     483           0 :                     mediaType = iFind->second;
     484           0 :                     break;
     485             :                 }
     486           4 :                 sal_Int32 point = title.indexOf( '.', 1 /* consume . */ );
     487           4 :                 if (point < 0)
     488           2 :                     break;
     489           2 :                 title = title.copy(point);
     490           4 :             }
     491           3 :         }
     492             :     }
     493          14 :     if (mediaType.isEmpty())
     494             :     {
     495             :         // try ambiguous backends:
     496           3 :         t_registryset::const_iterator iPos( m_ambiguousBackends.begin() );
     497           3 :         const t_registryset::const_iterator iEnd( m_ambiguousBackends.end() );
     498           7 :         for ( ; iPos != iEnd; ++iPos )
     499             :         {
     500             :             try {
     501           7 :                 return (*iPos)->bindPackage( url, mediaType, bRemoved,
     502           7 :                     identifier, xCmdEnv );
     503             :             }
     504           4 :             catch (const lang::IllegalArgumentException &) {
     505             :             }
     506             :         }
     507             :         throw lang::IllegalArgumentException(
     508           0 :             getResourceString(RID_STR_CANNOT_DETECT_MEDIA_TYPE) + url,
     509           0 :             static_cast<OWeakObject *>(this), static_cast<sal_Int16>(-1) );
     510             :     }
     511             :     else
     512             :     {
     513             :         // get backend by media-type:
     514             :         t_string2registry::const_iterator iFind(
     515          11 :             m_mediaType2backend.find( normalizeMediaType(mediaType) ) );
     516          11 :         if (iFind == m_mediaType2backend.end()) {
     517             :             // xxx todo: more sophisticated media-type argument parsing...
     518           0 :             sal_Int32 q = mediaType.indexOf( ';' );
     519           0 :             if (q >= 0) {
     520             :                 iFind = m_mediaType2backend.find(
     521             :                     normalizeMediaType(
     522             :                         // cut parameters:
     523           0 :                         mediaType.copy( 0, q ) ) );
     524             :             }
     525             :         }
     526          11 :         if (iFind == m_mediaType2backend.end()) {
     527             :             throw lang::IllegalArgumentException(
     528           0 :                 getResourceString(RID_STR_UNSUPPORTED_MEDIA_TYPE) + mediaType,
     529           0 :                 static_cast<OWeakObject *>(this), static_cast<sal_Int16>(-1) );
     530             :         }
     531          11 :         return iFind->second->bindPackage( url, mediaType, bRemoved,
     532          11 :             identifier, xCmdEnv );
     533          14 :     }
     534             : }
     535             : 
     536             : 
     537             : Sequence< Reference<deployment::XPackageTypeInfo> >
     538           0 : PackageRegistryImpl::getSupportedPackageTypes() throw (RuntimeException, std::exception)
     539             : {
     540           0 :     return comphelper::containerToSequence(m_typesInfos);
     541             : }
     542             : } // anon namespace
     543             : 
     544             : 
     545         256 : Reference<deployment::XPackageRegistry> SAL_CALL create(
     546             :     OUString const & context,
     547             :     OUString const & cachePath, bool readOnly,
     548             :     Reference<XComponentContext> const & xComponentContext )
     549             : {
     550             :     return PackageRegistryImpl::create(
     551         256 :         context, cachePath, readOnly, xComponentContext );
     552             : }
     553             : 
     554             : } // namespace dp_registry
     555             : 
     556             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10