LCOV - code coverage report
Current view: top level - desktop/source/migration/services - oo3extensionmigration.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 236 0.0 %
Date: 2012-08-25 Functions: 0 27 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "oo3extensionmigration.hxx"
      31                 :            : #include <rtl/instance.hxx>
      32                 :            : #include <osl/file.hxx>
      33                 :            : #include <osl/thread.h>
      34                 :            : #include <tools/urlobj.hxx>
      35                 :            : #include <unotools/bootstrap.hxx>
      36                 :            : #include <unotools/ucbstreamhelper.hxx>
      37                 :            : #include <unotools/textsearch.hxx>
      38                 :            : #include <comphelper/sequence.hxx>
      39                 :            : #include <comphelper/processfactory.hxx>
      40                 :            : #include <ucbhelper/content.hxx>
      41                 :            : 
      42                 :            : #include <com/sun/star/task/XInteractionApprove.hpp>
      43                 :            : #include <com/sun/star/task/XInteractionAbort.hpp>
      44                 :            : #include <com/sun/star/ucb/XCommandInfo.hpp>
      45                 :            : #include <com/sun/star/ucb/TransferInfo.hpp>
      46                 :            : #include <com/sun/star/ucb/NameClash.hpp>
      47                 :            : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      48                 :            : #include <com/sun/star/xml/xpath/XXPathAPI.hpp>
      49                 :            : #include <com/sun/star/beans/NamedValue.hpp>
      50                 :            : #include <com/sun/star/deployment/ExtensionManager.hpp>
      51                 :            : 
      52                 :            : using namespace ::com::sun::star;
      53                 :            : using namespace ::com::sun::star::uno;
      54                 :            : 
      55                 :            : namespace migration
      56                 :            : {
      57                 :            : 
      58                 :          0 : static ::rtl::OUString sExtensionSubDir = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/uno_packages/" ) );
      59                 :          0 : static ::rtl::OUString sSubDirName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cache" ) );
      60                 :          0 : static ::rtl::OUString sDescriptionXmlFile = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/description.xml" ) );
      61                 :          0 : static ::rtl::OUString sExtensionRootSubDirName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/uno_packages" ) );
      62                 :            : 
      63                 :            : // =============================================================================
      64                 :            : // component operations
      65                 :            : // =============================================================================
      66                 :            : 
      67                 :          0 : ::rtl::OUString OO3ExtensionMigration_getImplementationName()
      68                 :            : {
      69                 :            :     static ::rtl::OUString* pImplName = 0;
      70                 :          0 :     if ( !pImplName )
      71                 :            :     {
      72                 :          0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
      73                 :          0 :         if ( !pImplName )
      74                 :            :         {
      75                 :          0 :             static ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.desktop.migration.OOo3Extensions" ) );
      76                 :          0 :             pImplName = &aImplName;
      77                 :          0 :         }
      78                 :            :     }
      79                 :          0 :     return *pImplName;
      80                 :            : }
      81                 :            : 
      82                 :            : // -----------------------------------------------------------------------------
      83                 :            : 
      84                 :          0 : Sequence< ::rtl::OUString > OO3ExtensionMigration_getSupportedServiceNames()
      85                 :            : {
      86                 :            :     static Sequence< ::rtl::OUString >* pNames = 0;
      87                 :          0 :     if ( !pNames )
      88                 :            :     {
      89                 :          0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
      90                 :          0 :         if ( !pNames )
      91                 :            :         {
      92                 :          0 :             static Sequence< ::rtl::OUString > aNames(1);
      93                 :          0 :             aNames.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.migration.Extensions" ) );
      94                 :          0 :             pNames = &aNames;
      95                 :          0 :         }
      96                 :            :     }
      97                 :          0 :     return *pNames;
      98                 :            : }
      99                 :            : 
     100                 :            : // =============================================================================
     101                 :            : // ExtensionMigration
     102                 :            : // =============================================================================
     103                 :            : 
     104                 :          0 : OO3ExtensionMigration::OO3ExtensionMigration(Reference< XComponentContext > const & ctx) :
     105                 :          0 : m_ctx(ctx)
     106                 :            : {
     107                 :          0 : }
     108                 :            : 
     109                 :            : // -----------------------------------------------------------------------------
     110                 :            : 
     111                 :          0 : OO3ExtensionMigration::~OO3ExtensionMigration()
     112                 :            : {
     113                 :          0 : }
     114                 :            : 
     115                 :          0 : ::osl::FileBase::RC OO3ExtensionMigration::checkAndCreateDirectory( INetURLObject& rDirURL )
     116                 :            : {
     117                 :          0 :     ::osl::FileBase::RC aResult = ::osl::Directory::create( rDirURL.GetMainURL( INetURLObject::DECODE_TO_IURI ) );
     118                 :          0 :     if ( aResult == ::osl::FileBase::E_NOENT )
     119                 :            :     {
     120                 :          0 :         INetURLObject aBaseURL( rDirURL );
     121                 :          0 :         aBaseURL.removeSegment();
     122                 :          0 :         checkAndCreateDirectory( aBaseURL );
     123                 :          0 :         return ::osl::Directory::create( rDirURL.GetMainURL( INetURLObject::DECODE_TO_IURI ) );
     124                 :            :     }
     125                 :            :     else
     126                 :            :     {
     127                 :          0 :         return aResult;
     128                 :            :     }
     129                 :            : }
     130                 :            : 
     131                 :          0 : void OO3ExtensionMigration::scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions )
     132                 :            : {
     133                 :          0 :     osl::Directory    aScanRootDir( sSourceDir );
     134                 :          0 :     osl::FileStatus   fs(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL);
     135                 :          0 :     osl::FileBase::RC nRetCode = aScanRootDir.open();
     136                 :          0 :     if ( nRetCode == osl::Directory::E_None )
     137                 :            :     {
     138                 :          0 :         sal_uInt32    nHint( 0 );
     139                 :          0 :         osl::DirectoryItem aItem;
     140                 :          0 :         while ( aScanRootDir.getNextItem( aItem, nHint ) == osl::Directory::E_None )
     141                 :            :         {
     142                 :          0 :             if (( aItem.getFileStatus(fs) == osl::FileBase::E_None ) &&
     143                 :          0 :                 ( fs.getFileType() == osl::FileStatus::Directory   ))
     144                 :            :             {
     145                 :            :                 //Check next folder as the "real" extension folder is below a temp folder!
     146                 :          0 :                 ::rtl::OUString sExtensionFolderURL = fs.getFileURL();
     147                 :            : 
     148                 :          0 :                 osl::DirectoryItem aExtDirItem;
     149                 :          0 :                 osl::Directory     aExtensionRootDir( sExtensionFolderURL );
     150                 :            : 
     151                 :          0 :                 nRetCode = aExtensionRootDir.open();
     152                 :          0 :                 if (( nRetCode == osl::Directory::E_None ) &&
     153                 :          0 :                     ( aExtensionRootDir.getNextItem( aExtDirItem, nHint ) == osl::Directory::E_None ))
     154                 :            :                 {
     155                 :          0 :                     bool bFileStatus = aExtDirItem.getFileStatus(fs) == osl::FileBase::E_None;
     156                 :          0 :                     bool bIsDir      = fs.getFileType() == osl::FileStatus::Directory;
     157                 :            : 
     158                 :          0 :                     if ( bFileStatus && bIsDir )
     159                 :            :                     {
     160                 :          0 :                         sExtensionFolderURL = fs.getFileURL();
     161                 :          0 :                         ScanResult eResult = scanExtensionFolder( sExtensionFolderURL );
     162                 :          0 :                         if ( eResult == SCANRESULT_MIGRATE_EXTENSION )
     163                 :          0 :                             aMigrateExtensions.push_back( sExtensionFolderURL );
     164                 :            :                     }
     165                 :          0 :                 }
     166                 :            :             }
     167                 :          0 :         }
     168                 :          0 :     }
     169                 :          0 : }
     170                 :            : 
     171                 :          0 : OO3ExtensionMigration::ScanResult OO3ExtensionMigration::scanExtensionFolder( const ::rtl::OUString& sExtFolder )
     172                 :            : {
     173                 :          0 :     ScanResult     aResult = SCANRESULT_NOTFOUND;
     174                 :          0 :     osl::Directory aDir(sExtFolder);
     175                 :            : 
     176                 :            :     // get sub dirs
     177                 :          0 :     if (aDir.open() == osl::FileBase::E_None)
     178                 :            :     {
     179                 :            :         // work through directory contents...
     180                 :          0 :         osl::DirectoryItem item;
     181                 :          0 :         osl::FileStatus fs(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL);
     182                 :          0 :         TStringVector aDirectories;
     183                 :          0 :         while ((aDir.getNextItem(item) == osl::FileBase::E_None ) &&
     184                 :            :                ( aResult == SCANRESULT_NOTFOUND ))
     185                 :            :         {
     186                 :          0 :             if (item.getFileStatus(fs) == osl::FileBase::E_None)
     187                 :            :             {
     188                 :          0 :                 ::rtl::OUString aDirEntryURL;
     189                 :          0 :                 if (fs.getFileType() == osl::FileStatus::Directory)
     190                 :          0 :                     aDirectories.push_back( fs.getFileURL() );
     191                 :            :                 else
     192                 :            :                 {
     193                 :          0 :                     aDirEntryURL = fs.getFileURL();
     194                 :          0 :                     if ( aDirEntryURL.indexOf( sDescriptionXmlFile ) > 0 )
     195                 :          0 :                         aResult = scanDescriptionXml( aDirEntryURL ) ? SCANRESULT_MIGRATE_EXTENSION : SCANRESULT_DONTMIGRATE_EXTENSION;
     196                 :          0 :                 }
     197                 :            :             }
     198                 :            :         }
     199                 :            : 
     200                 :          0 :         TStringVector::const_iterator pIter = aDirectories.begin();
     201                 :          0 :         while ( pIter != aDirectories.end() && aResult == SCANRESULT_NOTFOUND )
     202                 :            :         {
     203                 :          0 :             aResult = scanExtensionFolder( *pIter );
     204                 :          0 :             ++pIter;
     205                 :          0 :         }
     206                 :            :     }
     207                 :          0 :     return aResult;
     208                 :            : }
     209                 :            : 
     210                 :          0 : bool OO3ExtensionMigration::scanDescriptionXml( const ::rtl::OUString& sDescriptionXmlURL )
     211                 :            : {
     212                 :          0 :     if ( !m_xDocBuilder.is() )
     213                 :            :     {
     214                 :            :         m_xDocBuilder = uno::Reference< xml::dom::XDocumentBuilder >(
     215                 :          0 :             m_ctx->getServiceManager()->createInstanceWithContext(
     216                 :            :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.dom.DocumentBuilder")),
     217                 :          0 :                 m_ctx ), uno::UNO_QUERY );
     218                 :            :     }
     219                 :            : 
     220                 :          0 :     if ( !m_xSimpleFileAccess.is() )
     221                 :            :     {
     222                 :          0 :         m_xSimpleFileAccess = ucb::SimpleFileAccess::create(m_ctx);
     223                 :            :     }
     224                 :            : 
     225                 :          0 :     ::rtl::OUString aExtIdentifier;
     226                 :          0 :     if ( m_xDocBuilder.is() && m_xSimpleFileAccess.is() )
     227                 :            :     {
     228                 :            :         try
     229                 :            :         {
     230                 :            :             uno::Reference< io::XInputStream > xIn =
     231                 :          0 :                 m_xSimpleFileAccess->openFileRead( sDescriptionXmlURL );
     232                 :            : 
     233                 :          0 :             if ( xIn.is() )
     234                 :            :             {
     235                 :          0 :                 uno::Reference< xml::dom::XDocument > xDoc = m_xDocBuilder->parse( xIn );
     236                 :          0 :                 if ( xDoc.is() )
     237                 :            :                 {
     238                 :          0 :                     uno::Reference< xml::dom::XElement > xRoot = xDoc->getDocumentElement();
     239                 :          0 :                     if ( xRoot.is() && xRoot->getTagName() == "description" )
     240                 :            :                     {
     241                 :            :                         uno::Reference< xml::xpath::XXPathAPI > xPath(
     242                 :          0 :                             m_ctx->getServiceManager()->createInstanceWithContext(
     243                 :            :                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.xpath.XPathAPI")),
     244                 :          0 :                                 m_ctx),
     245                 :          0 :                             uno::UNO_QUERY);
     246                 :            : 
     247                 :          0 :                         xPath->registerNS(
     248                 :            :                             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("desc")),
     249                 :          0 :                             xRoot->getNamespaceURI());
     250                 :          0 :                         xPath->registerNS(
     251                 :            :                             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("xlink")),
     252                 :          0 :                             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http://www.w3.org/1999/xlink")));
     253                 :            : 
     254                 :            :                         try
     255                 :            :                         {
     256                 :          0 :                             uno::Reference< xml::dom::XNode > xRootNode( xRoot, uno::UNO_QUERY );
     257                 :            :                             uno::Reference< xml::dom::XNode > xNode(
     258                 :          0 :                                 xPath->selectSingleNode(
     259                 :            :                                     xRootNode,
     260                 :          0 :                                     ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("desc:identifier/@value")) ));
     261                 :          0 :                             if ( xNode.is() )
     262                 :          0 :                                 aExtIdentifier = xNode->getNodeValue();
     263                 :            :                         }
     264                 :          0 :                         catch ( const xml::xpath::XPathException& )
     265                 :            :                         {
     266                 :            :                         }
     267                 :          0 :                         catch ( const xml::dom::DOMException& )
     268                 :            :                         {
     269                 :          0 :                         }
     270                 :          0 :                     }
     271                 :          0 :                 }
     272                 :            :             }
     273                 :            : 
     274                 :          0 :             if ( !aExtIdentifier.isEmpty() )
     275                 :            :             {
     276                 :            :                 // scan extension identifier and try to match with our black list entries
     277                 :          0 :                 for ( sal_uInt32 i = 0; i < m_aBlackList.size(); i++ )
     278                 :            :                 {
     279                 :          0 :                     utl::SearchParam param(m_aBlackList[i], utl::SearchParam::SRCH_REGEXP);
     280                 :          0 :                     utl::TextSearch  ts(param, LANGUAGE_DONTKNOW);
     281                 :            : 
     282                 :          0 :                     xub_StrLen start = 0;
     283                 :          0 :                     xub_StrLen end   = static_cast<sal_uInt16>(aExtIdentifier.getLength());
     284                 :          0 :                     if (ts.SearchFrwrd(aExtIdentifier, &start, &end))
     285                 :          0 :                         return false;
     286                 :          0 :                 }
     287                 :          0 :             }
     288                 :            :         }
     289                 :          0 :         catch ( const ucb::CommandAbortedException& )
     290                 :            :         {
     291                 :            :         }
     292                 :          0 :         catch ( const uno::RuntimeException& )
     293                 :            :         {
     294                 :            :         }
     295                 :            : 
     296                 :          0 :         if ( aExtIdentifier.isEmpty() )
     297                 :            :         {
     298                 :            :             // Fallback:
     299                 :            :             // Try to use the folder name to match our black list
     300                 :            :             // as some extensions don't provide an identifier in the
     301                 :            :             // description.xml!
     302                 :          0 :             for ( sal_uInt32 i = 0; i < m_aBlackList.size(); i++ )
     303                 :            :             {
     304                 :          0 :                 utl::SearchParam param(m_aBlackList[i], utl::SearchParam::SRCH_REGEXP);
     305                 :          0 :                 utl::TextSearch  ts(param, LANGUAGE_DONTKNOW);
     306                 :            : 
     307                 :          0 :                 xub_StrLen start = 0;
     308                 :          0 :                 xub_StrLen end   = static_cast<sal_uInt16>(sDescriptionXmlURL.getLength());
     309                 :          0 :                 if (ts.SearchFrwrd(sDescriptionXmlURL, &start, &end))
     310                 :          0 :                     return false;
     311                 :          0 :             }
     312                 :            :         }
     313                 :            :     }
     314                 :            : 
     315                 :          0 :     return true;
     316                 :            : }
     317                 :            : 
     318                 :          0 : bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir )
     319                 :            : {
     320                 :          0 :     if ( !m_xExtensionManager.is() )
     321                 :            :     {
     322                 :            :         try
     323                 :            :         {
     324                 :          0 :             m_xExtensionManager = deployment::ExtensionManager::get( m_ctx );
     325                 :            :         }
     326                 :          0 :         catch ( const ucb::CommandFailedException & ){}
     327                 :          0 :         catch ( const uno::RuntimeException & ) {}
     328                 :            :     }
     329                 :            : 
     330                 :          0 :     if ( m_xExtensionManager.is() )
     331                 :            :     {
     332                 :            :         try
     333                 :            :         {
     334                 :          0 :             TmpRepositoryCommandEnv* pCmdEnv = new TmpRepositoryCommandEnv();
     335                 :            : 
     336                 :            :             uno::Reference< ucb::XCommandEnvironment > xCmdEnv(
     337                 :          0 :                 static_cast< cppu::OWeakObject* >( pCmdEnv ), uno::UNO_QUERY );
     338                 :          0 :             uno::Reference< task::XAbortChannel > xAbortChannel;
     339                 :            :             uno::Reference< deployment::XPackage > xPackage =
     340                 :          0 :                 m_xExtensionManager->addExtension(
     341                 :            :                     sSourceDir, uno::Sequence<beans::NamedValue>(),
     342                 :          0 :                     ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), xAbortChannel, xCmdEnv );
     343                 :            : 
     344                 :          0 :             if ( xPackage.is() )
     345                 :          0 :                 return true;
     346                 :            :         }
     347                 :          0 :         catch ( const ucb::CommandFailedException& )
     348                 :            :         {
     349                 :            :         }
     350                 :          0 :         catch ( const ucb::CommandAbortedException& )
     351                 :            :         {
     352                 :            :         }
     353                 :          0 :         catch ( const lang::IllegalArgumentException& )
     354                 :            :         {
     355                 :            :         }
     356                 :            :     }
     357                 :            : 
     358                 :          0 :     return false;
     359                 :            : }
     360                 :            : 
     361                 :            : 
     362                 :            : // -----------------------------------------------------------------------------
     363                 :            : // XServiceInfo
     364                 :            : // -----------------------------------------------------------------------------
     365                 :            : 
     366                 :          0 : ::rtl::OUString OO3ExtensionMigration::getImplementationName() throw (RuntimeException)
     367                 :            : {
     368                 :          0 :     return OO3ExtensionMigration_getImplementationName();
     369                 :            : }
     370                 :            : 
     371                 :            : // -----------------------------------------------------------------------------
     372                 :            : 
     373                 :          0 : sal_Bool OO3ExtensionMigration::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
     374                 :            : {
     375                 :          0 :     Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
     376                 :          0 :     const ::rtl::OUString* pNames = aNames.getConstArray();
     377                 :          0 :     const ::rtl::OUString* pEnd = pNames + aNames.getLength();
     378                 :          0 :     for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
     379                 :            :         ;
     380                 :            : 
     381                 :          0 :     return pNames != pEnd;
     382                 :            : }
     383                 :            : 
     384                 :            : // -----------------------------------------------------------------------------
     385                 :            : 
     386                 :          0 : Sequence< ::rtl::OUString > OO3ExtensionMigration::getSupportedServiceNames() throw (RuntimeException)
     387                 :            : {
     388                 :          0 :     return OO3ExtensionMigration_getSupportedServiceNames();
     389                 :            : }
     390                 :            : 
     391                 :            : // -----------------------------------------------------------------------------
     392                 :            : // XInitialization
     393                 :            : // -----------------------------------------------------------------------------
     394                 :            : 
     395                 :          0 : void OO3ExtensionMigration::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException)
     396                 :            : {
     397                 :          0 :     ::osl::MutexGuard aGuard( m_aMutex );
     398                 :            : 
     399                 :          0 :     const Any* pIter = aArguments.getConstArray();
     400                 :          0 :     const Any* pEnd = pIter + aArguments.getLength();
     401                 :          0 :     for ( ; pIter != pEnd ; ++pIter )
     402                 :            :     {
     403                 :          0 :         beans::NamedValue aValue;
     404                 :          0 :         *pIter >>= aValue;
     405                 :          0 :         if ( aValue.Name == "UserData" )
     406                 :            :         {
     407                 :          0 :             if ( !(aValue.Value >>= m_sSourceDir) )
     408                 :            :             {
     409                 :            :                 OSL_FAIL( "ExtensionMigration::initialize: argument UserData has wrong type!" );
     410                 :            :             }
     411                 :            :         }
     412                 :          0 :         else if ( aValue.Name == "ExtensionBlackList" )
     413                 :            :         {
     414                 :          0 :             Sequence< ::rtl::OUString > aBlackList;
     415                 :          0 :             if ( (aValue.Value >>= aBlackList ) && ( aBlackList.getLength() > 0 ))
     416                 :            :             {
     417                 :          0 :                 m_aBlackList.resize( aBlackList.getLength() );
     418                 :          0 :                 ::comphelper::sequenceToArray< ::rtl::OUString >( &m_aBlackList[0], aBlackList );
     419                 :          0 :             }
     420                 :            :         }
     421                 :          0 :     }
     422                 :          0 : }
     423                 :            : 
     424                 :          0 : Any OO3ExtensionMigration::execute( const Sequence< beans::NamedValue >& )
     425                 :            :     throw (lang::IllegalArgumentException, Exception, RuntimeException)
     426                 :            : {
     427                 :          0 :     ::osl::MutexGuard aGuard( m_aMutex );
     428                 :            : 
     429                 :          0 :     ::utl::Bootstrap::PathStatus aStatus = ::utl::Bootstrap::locateUserInstallation( m_sTargetDir );
     430                 :          0 :     if ( aStatus == ::utl::Bootstrap::PATH_EXISTS )
     431                 :            :     {
     432                 :            :         // copy all extensions
     433                 :          0 :         ::rtl::OUString sSourceDir( m_sSourceDir );
     434                 :          0 :         sSourceDir += sExtensionSubDir;
     435                 :          0 :         sSourceDir += sSubDirName;
     436                 :          0 :         sSourceDir += sExtensionRootSubDirName;
     437                 :          0 :         TStringVector aExtensionToMigrate;
     438                 :          0 :         scanUserExtensions( sSourceDir, aExtensionToMigrate );
     439                 :          0 :         if ( aExtensionToMigrate.size() > 0 )
     440                 :            :         {
     441                 :          0 :             TStringVector::iterator pIter = aExtensionToMigrate.begin();
     442                 :          0 :             while ( pIter != aExtensionToMigrate.end() )
     443                 :            :             {
     444                 :          0 :                 migrateExtension( *pIter );
     445                 :          0 :                 ++pIter;
     446                 :            :             }
     447                 :          0 :         }
     448                 :            :     }
     449                 :            : 
     450                 :          0 :     return Any();
     451                 :            : }
     452                 :            : 
     453                 :            : // -----------------------------------------------------------------------------
     454                 :            : // TmpRepositoryCommandEnv
     455                 :            : // -----------------------------------------------------------------------------
     456                 :            : 
     457                 :          0 : TmpRepositoryCommandEnv::TmpRepositoryCommandEnv()
     458                 :            : {
     459                 :          0 : }
     460                 :            : 
     461                 :          0 : TmpRepositoryCommandEnv::~TmpRepositoryCommandEnv()
     462                 :            : {
     463                 :          0 : }
     464                 :            : // XCommandEnvironment
     465                 :            : //______________________________________________________________________________
     466                 :          0 : uno::Reference< task::XInteractionHandler > TmpRepositoryCommandEnv::getInteractionHandler()
     467                 :            : throw ( uno::RuntimeException )
     468                 :            : {
     469                 :          0 :     return this;
     470                 :            : }
     471                 :            : 
     472                 :            : //______________________________________________________________________________
     473                 :          0 : uno::Reference< ucb::XProgressHandler > TmpRepositoryCommandEnv::getProgressHandler()
     474                 :            : throw ( uno::RuntimeException )
     475                 :            : {
     476                 :          0 :     return this;
     477                 :            : }
     478                 :            : 
     479                 :            : // XInteractionHandler
     480                 :          0 : void TmpRepositoryCommandEnv::handle(
     481                 :            :     uno::Reference< task::XInteractionRequest> const & xRequest )
     482                 :            :     throw ( uno::RuntimeException )
     483                 :            : {
     484                 :          0 :     uno::Any request( xRequest->getRequest() );
     485                 :            :     OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
     486                 :            : 
     487                 :          0 :     bool approve = true;
     488                 :          0 :     bool abort   = false;
     489                 :            : 
     490                 :            :     // select:
     491                 :            :     uno::Sequence< Reference< task::XInteractionContinuation > > conts(
     492                 :          0 :         xRequest->getContinuations() );
     493                 :            :     Reference< task::XInteractionContinuation > const * pConts =
     494                 :          0 :         conts.getConstArray();
     495                 :          0 :     sal_Int32 len = conts.getLength();
     496                 :          0 :     for ( sal_Int32 pos = 0; pos < len; ++pos )
     497                 :            :     {
     498                 :          0 :         if (approve) {
     499                 :            :             uno::Reference< task::XInteractionApprove > xInteractionApprove(
     500                 :          0 :                 pConts[ pos ], uno::UNO_QUERY );
     501                 :          0 :             if (xInteractionApprove.is()) {
     502                 :          0 :                 xInteractionApprove->select();
     503                 :            :                 // don't query again for ongoing continuations:
     504                 :          0 :                 approve = false;
     505                 :          0 :             }
     506                 :            :         }
     507                 :          0 :         else if (abort) {
     508                 :            :             uno::Reference< task::XInteractionAbort > xInteractionAbort(
     509                 :          0 :                 pConts[ pos ], uno::UNO_QUERY );
     510                 :          0 :             if (xInteractionAbort.is()) {
     511                 :          0 :                 xInteractionAbort->select();
     512                 :            :                 // don't query again for ongoing continuations:
     513                 :          0 :                 abort = false;
     514                 :          0 :             }
     515                 :            :         }
     516                 :          0 :     }
     517                 :          0 : }
     518                 :            : 
     519                 :            : // XProgressHandler
     520                 :          0 : void TmpRepositoryCommandEnv::push( uno::Any const & /*Status*/ )
     521                 :            : throw (uno::RuntimeException)
     522                 :            : {
     523                 :          0 : }
     524                 :            : 
     525                 :            : 
     526                 :          0 : void TmpRepositoryCommandEnv::update( uno::Any const & /*Status */)
     527                 :            : throw (uno::RuntimeException)
     528                 :            : {
     529                 :          0 : }
     530                 :            : 
     531                 :          0 : void TmpRepositoryCommandEnv::pop() throw (uno::RuntimeException)
     532                 :            : {
     533                 :          0 : }
     534                 :            : 
     535                 :            : // =============================================================================
     536                 :            : // component operations
     537                 :            : // =============================================================================
     538                 :            : 
     539                 :          0 : Reference< XInterface > SAL_CALL OO3ExtensionMigration_create(
     540                 :            :     Reference< XComponentContext > const & ctx )
     541                 :            :     SAL_THROW(())
     542                 :            : {
     543                 :            :     return static_cast< lang::XTypeProvider * >( new OO3ExtensionMigration(
     544                 :          0 :         ctx) );
     545                 :            : }
     546                 :            : 
     547                 :            : // -----------------------------------------------------------------------------
     548                 :            : 
     549                 :          0 : }   // namespace migration
     550                 :            : 
     551                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10