LCOV - code coverage report
Current view: top level - libreoffice/ucb/source/ucp/cmis - cmis_provider.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 46 0.0 %
Date: 2012-12-27 Functions: 0 21 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             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License or as specified alternatively below. You may obtain a copy of
       8             :  * the License at http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * Major Contributor(s):
      16             :  * [ Copyright (C) 2011 SUSE <cbosdonnat@suse.com> (initial developer) ]
      17             :  *
      18             :  * All Rights Reserved.
      19             :  *
      20             :  * For minor contributions see the git repository.
      21             :  *
      22             :  * Alternatively, the contents of this file may be used under the terms of
      23             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26             :  * instead of those above.
      27             :  */
      28             : 
      29             : #include <stdio.h>
      30             : 
      31             : #include <comphelper/processfactory.hxx>
      32             : #include <ucbhelper/contentidentifier.hxx>
      33             : #include <ucbhelper/contenthelper.hxx>
      34             : #include <com/sun/star/ucb/ContentCreationException.hpp>
      35             : 
      36             : #include "cmis_content.hxx"
      37             : #include "cmis_provider.hxx"
      38             : #include "cmis_repo_content.hxx"
      39             : 
      40             : using namespace com::sun::star;
      41             : 
      42             : namespace cmis
      43             : {
      44             : uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
      45           0 : ContentProvider::queryContent(
      46             :             const uno::Reference<
      47             :                     com::sun::star::ucb::XContentIdentifier >& Identifier )
      48             :     throw( com::sun::star::ucb::IllegalIdentifierException,
      49             :            uno::RuntimeException )
      50             : {
      51           0 :     osl::MutexGuard aGuard( m_aMutex );
      52             : 
      53             :     // Check, if a content with given id already exists...
      54           0 :     uno::Reference< ucb::XContent > xContent = queryExistingContent( Identifier ).get();
      55           0 :     if ( xContent.is() )
      56             :         return xContent;
      57             : 
      58             :     try
      59             :     {
      60           0 :         URL aUrl( Identifier->getContentIdentifier( ) );
      61           0 :         if ( aUrl.getRepositoryId( ).isEmpty( ) )
      62             :         {
      63           0 :             xContent = new RepoContent( m_xContext, this, Identifier );
      64           0 :             registerNewContent( xContent );
      65             :         }
      66             :         else
      67             :         {
      68           0 :             xContent = new Content( m_xContext, this, Identifier );
      69           0 :             registerNewContent( xContent );
      70           0 :         }
      71             :     }
      72           0 :     catch ( com::sun::star::ucb::ContentCreationException const & )
      73             :     {
      74           0 :         throw com::sun::star::ucb::IllegalIdentifierException();
      75             :     }
      76             : 
      77           0 :     if ( !xContent->getIdentifier().is() )
      78           0 :         throw com::sun::star::ucb::IllegalIdentifierException();
      79             : 
      80           0 :     return xContent;
      81             : }
      82             : 
      83           0 : libcmis::Session* ContentProvider::getSession( const rtl::OUString& sBindingUrl )
      84             : {
      85           0 :     libcmis::Session* pSession = NULL;
      86           0 :     std::map< rtl::OUString, libcmis::Session* >::iterator it = m_aSessionCache.find( sBindingUrl );
      87           0 :     if ( it != m_aSessionCache.end( ) )
      88             :     {
      89           0 :         pSession = it->second;
      90             :     }
      91           0 :     return pSession;
      92             : }
      93             : 
      94           0 : void ContentProvider::registerSession( const rtl::OUString& sBindingUrl, libcmis::Session* pSession )
      95             : {
      96           0 :     m_aSessionCache.insert( std::pair< rtl::OUString, libcmis::Session* >( sBindingUrl, pSession ) );
      97           0 : }
      98             : 
      99           0 : ContentProvider::ContentProvider(
     100             :     const uno::Reference< uno::XComponentContext >& rxContext )
     101           0 : : ::ucbhelper::ContentProviderImplHelper( rxContext )
     102             : {
     103           0 : }
     104             : 
     105           0 : ContentProvider::~ContentProvider()
     106             : {
     107           0 : }
     108             : 
     109           0 : XINTERFACE_IMPL_3( ContentProvider,
     110             :                    lang::XTypeProvider,
     111             :                    lang::XServiceInfo,
     112             :                    com::sun::star::ucb::XContentProvider );
     113             : 
     114           0 : XTYPEPROVIDER_IMPL_3( ContentProvider,
     115             :                       lang::XTypeProvider,
     116             :                       lang::XServiceInfo,
     117             :                       com::sun::star::ucb::XContentProvider );
     118             : 
     119           0 : XSERVICEINFO_IMPL_1_CTX( ContentProvider,
     120             :                      rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
     121             :                        "com.sun.star.comp.CmisContentProvider" )),
     122             :                      rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
     123           0 :                        "com.sun.star.ucb.CmisContentProvider" )) );
     124             : 
     125           0 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
     126             : 
     127             : }
     128             : 
     129           0 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL ucpcmis1_component_getFactory( const sal_Char *pImplName,
     130             :     void *pServiceManager, void * )
     131             : {
     132           0 :     void * pRet = 0;
     133             : 
     134             :     uno::Reference< lang::XMultiServiceFactory > xSMgr
     135           0 :         (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
     136           0 :     uno::Reference< lang::XSingleServiceFactory > xFactory;
     137             : 
     138           0 :     if ( !::cmis::ContentProvider::getImplementationName_Static().compareToAscii( pImplName ) )
     139           0 :         xFactory = ::cmis::ContentProvider::createServiceFactory( xSMgr );
     140             : 
     141           0 :     if ( xFactory.is() )
     142             :     {
     143           0 :         xFactory->acquire();
     144           0 :         pRet = xFactory.get();
     145             :     }
     146             : 
     147           0 :     return pRet;
     148           0 : }
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10