1*0a1e2f0eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*0a1e2f0eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*0a1e2f0eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*0a1e2f0eSAndrew Rist * distributed with this work for additional information 6*0a1e2f0eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*0a1e2f0eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*0a1e2f0eSAndrew Rist * "License"); you may not use this file except in compliance 9*0a1e2f0eSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*0a1e2f0eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*0a1e2f0eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*0a1e2f0eSAndrew Rist * software distributed under the License is distributed on an 15*0a1e2f0eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*0a1e2f0eSAndrew Rist * KIND, either express or implied. See the License for the 17*0a1e2f0eSAndrew Rist * specific language governing permissions and limitations 18*0a1e2f0eSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*0a1e2f0eSAndrew Rist *************************************************************/ 21*0a1e2f0eSAndrew Rist 22*0a1e2f0eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DESKTOP_OO3EXTENSIONMIGRATION_HXX_ 25cdf0e10cSrcweir #define _DESKTOP_OO3EXTENSIONMIGRATION_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "misc.hxx" 28cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 29cdf0e10cSrcweir #include <com/sun/star/task/XJob.hpp> 30cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 31cdf0e10cSrcweir #include <com/sun/star/xml/dom/XDocumentBuilder.hpp> 32cdf0e10cSrcweir #include <com/sun/star/ucb/XSimpleFileAccess.hpp> 33cdf0e10cSrcweir #include <com/sun/star/deployment/XExtensionManager.hpp> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <osl/mutex.hxx> 36cdf0e10cSrcweir #include <osl/file.hxx> 37cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> 38cdf0e10cSrcweir #include <cppuhelper/compbase3.hxx> 39cdf0e10cSrcweir #include <ucbhelper/content.hxx> 40cdf0e10cSrcweir #include <xmlscript/xmllib_imexp.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace com { namespace sun { namespace star { 43cdf0e10cSrcweir namespace uno { 44cdf0e10cSrcweir class XComponentContext; 45cdf0e10cSrcweir } 46cdf0e10cSrcweir namespace deployment { 47cdf0e10cSrcweir class XPackage; 48cdf0e10cSrcweir } 49cdf0e10cSrcweir }}} 50cdf0e10cSrcweir 51cdf0e10cSrcweir class INetURLObject; 52cdf0e10cSrcweir 53cdf0e10cSrcweir 54cdf0e10cSrcweir namespace migration 55cdf0e10cSrcweir { 56cdf0e10cSrcweir 57cdf0e10cSrcweir ::rtl::OUString SAL_CALL OO3ExtensionMigration_getImplementationName(); 58cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OO3ExtensionMigration_getSupportedServiceNames(); 59cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL OO3ExtensionMigration_create( 60cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext ) 61cdf0e10cSrcweir SAL_THROW( (::com::sun::star::uno::Exception) ); 62cdf0e10cSrcweir 63cdf0e10cSrcweir 64cdf0e10cSrcweir // ============================================================================= 65cdf0e10cSrcweir // class ExtensionMigration 66cdf0e10cSrcweir // ============================================================================= 67cdf0e10cSrcweir 68cdf0e10cSrcweir typedef ::cppu::WeakImplHelper3< 69cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo, 70cdf0e10cSrcweir ::com::sun::star::lang::XInitialization, 71cdf0e10cSrcweir ::com::sun::star::task::XJob > ExtensionMigration_BASE; 72cdf0e10cSrcweir 73cdf0e10cSrcweir class OO3ExtensionMigration : public ExtensionMigration_BASE 74cdf0e10cSrcweir { 75cdf0e10cSrcweir private: 76cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_ctx; 77cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XDocumentBuilder > m_xDocBuilder; 78cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xSimpleFileAccess; 79cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; 80cdf0e10cSrcweir ::osl::Mutex m_aMutex; 81cdf0e10cSrcweir ::rtl::OUString m_sSourceDir; 82cdf0e10cSrcweir ::rtl::OUString m_sTargetDir; 83cdf0e10cSrcweir TStringVector m_aBlackList; 84cdf0e10cSrcweir 85cdf0e10cSrcweir enum ScanResult 86cdf0e10cSrcweir { 87cdf0e10cSrcweir SCANRESULT_NOTFOUND, 88cdf0e10cSrcweir SCANRESULT_MIGRATE_EXTENSION, 89cdf0e10cSrcweir SCANRESULT_DONTMIGRATE_EXTENSION 90cdf0e10cSrcweir }; 91cdf0e10cSrcweir 92cdf0e10cSrcweir ::osl::FileBase::RC checkAndCreateDirectory( INetURLObject& rDirURL ); 93cdf0e10cSrcweir ScanResult scanExtensionFolder( const ::rtl::OUString& sExtFolder ); 94cdf0e10cSrcweir void scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ); 95cdf0e10cSrcweir bool scanDescriptionXml( const ::rtl::OUString& sDescriptionXmlFilePath ); 96cdf0e10cSrcweir bool migrateExtension( const ::rtl::OUString& sSourceDir ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir public: 99cdf0e10cSrcweir OO3ExtensionMigration(::com::sun::star::uno::Reference< 100cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext > const & ctx); 101cdf0e10cSrcweir virtual ~OO3ExtensionMigration(); 102cdf0e10cSrcweir 103cdf0e10cSrcweir // XServiceInfo 104cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() 105cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 106cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) 107cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 108cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 109cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 110cdf0e10cSrcweir 111cdf0e10cSrcweir // XInitialization 112cdf0e10cSrcweir virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 113cdf0e10cSrcweir throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 114cdf0e10cSrcweir 115cdf0e10cSrcweir // XJob 116cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL execute( 117cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments ) 118cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, 119cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException); 120cdf0e10cSrcweir }; 121cdf0e10cSrcweir 122cdf0e10cSrcweir class TmpRepositoryCommandEnv 123cdf0e10cSrcweir : public ::cppu::WeakImplHelper3< ::com::sun::star::ucb::XCommandEnvironment, 124cdf0e10cSrcweir ::com::sun::star::task::XInteractionHandler, 125cdf0e10cSrcweir ::com::sun::star::ucb::XProgressHandler > 126cdf0e10cSrcweir { 127cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 128cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_forwardHandler; 129cdf0e10cSrcweir public: 130cdf0e10cSrcweir virtual ~TmpRepositoryCommandEnv(); 131cdf0e10cSrcweir TmpRepositoryCommandEnv(); 132cdf0e10cSrcweir 133cdf0e10cSrcweir // XCommandEnvironment 134cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL 135cdf0e10cSrcweir getInteractionHandler() throw ( ::com::sun::star::uno::RuntimeException ); 136cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XProgressHandler > 137cdf0e10cSrcweir SAL_CALL getProgressHandler() throw ( ::com::sun::star::uno::RuntimeException ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir // XInteractionHandler 140cdf0e10cSrcweir virtual void SAL_CALL handle( 141cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & xRequest ) 142cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 143cdf0e10cSrcweir 144cdf0e10cSrcweir // XProgressHandler 145cdf0e10cSrcweir virtual void SAL_CALL push( ::com::sun::star::uno::Any const & Status ) 146cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 147cdf0e10cSrcweir virtual void SAL_CALL update( ::com::sun::star::uno::Any const & Status ) 148cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 149cdf0e10cSrcweir virtual void SAL_CALL pop() throw (::com::sun::star::uno::RuntimeException); 150cdf0e10cSrcweir }; 151cdf0e10cSrcweir 152cdf0e10cSrcweir //......................................................................... 153cdf0e10cSrcweir } // namespace migration 154cdf0e10cSrcweir //......................................................................... 155cdf0e10cSrcweir 156cdf0e10cSrcweir #endif // _DESKTOP_OO3EXTENSIONMIGRATION_HXX_ 157