1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _DESKTOP_OO3EXTENSIONMIGRATION_HXX_ 29 #define _DESKTOP_OO3EXTENSIONMIGRATION_HXX_ 30 31 #include "misc.hxx" 32 #include <com/sun/star/lang/XServiceInfo.hpp> 33 #include <com/sun/star/task/XJob.hpp> 34 #include <com/sun/star/lang/XInitialization.hpp> 35 #include <com/sun/star/xml/dom/XDocumentBuilder.hpp> 36 #include <com/sun/star/ucb/XSimpleFileAccess.hpp> 37 #include <com/sun/star/deployment/XExtensionManager.hpp> 38 39 #include <osl/mutex.hxx> 40 #include <osl/file.hxx> 41 #include <cppuhelper/implbase3.hxx> 42 #include <cppuhelper/compbase3.hxx> 43 #include <ucbhelper/content.hxx> 44 #include <xmlscript/xmllib_imexp.hxx> 45 46 namespace com { namespace sun { namespace star { 47 namespace uno { 48 class XComponentContext; 49 } 50 namespace deployment { 51 class XPackage; 52 } 53 }}} 54 55 class INetURLObject; 56 57 58 namespace migration 59 { 60 61 ::rtl::OUString SAL_CALL OO3ExtensionMigration_getImplementationName(); 62 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OO3ExtensionMigration_getSupportedServiceNames(); 63 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL OO3ExtensionMigration_create( 64 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext ) 65 SAL_THROW( (::com::sun::star::uno::Exception) ); 66 67 68 // ============================================================================= 69 // class ExtensionMigration 70 // ============================================================================= 71 72 typedef ::cppu::WeakImplHelper3< 73 ::com::sun::star::lang::XServiceInfo, 74 ::com::sun::star::lang::XInitialization, 75 ::com::sun::star::task::XJob > ExtensionMigration_BASE; 76 77 class OO3ExtensionMigration : public ExtensionMigration_BASE 78 { 79 private: 80 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_ctx; 81 ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XDocumentBuilder > m_xDocBuilder; 82 ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xSimpleFileAccess; 83 ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; 84 ::osl::Mutex m_aMutex; 85 ::rtl::OUString m_sSourceDir; 86 ::rtl::OUString m_sTargetDir; 87 TStringVector m_aBlackList; 88 89 enum ScanResult 90 { 91 SCANRESULT_NOTFOUND, 92 SCANRESULT_MIGRATE_EXTENSION, 93 SCANRESULT_DONTMIGRATE_EXTENSION 94 }; 95 96 ::osl::FileBase::RC checkAndCreateDirectory( INetURLObject& rDirURL ); 97 ScanResult scanExtensionFolder( const ::rtl::OUString& sExtFolder ); 98 void scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ); 99 bool scanDescriptionXml( const ::rtl::OUString& sDescriptionXmlFilePath ); 100 bool migrateExtension( const ::rtl::OUString& sSourceDir ); 101 102 public: 103 OO3ExtensionMigration(::com::sun::star::uno::Reference< 104 ::com::sun::star::uno::XComponentContext > const & ctx); 105 virtual ~OO3ExtensionMigration(); 106 107 // XServiceInfo 108 virtual ::rtl::OUString SAL_CALL getImplementationName() 109 throw (::com::sun::star::uno::RuntimeException); 110 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) 111 throw (::com::sun::star::uno::RuntimeException); 112 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 113 throw (::com::sun::star::uno::RuntimeException); 114 115 // XInitialization 116 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 117 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 118 119 // XJob 120 virtual ::com::sun::star::uno::Any SAL_CALL execute( 121 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments ) 122 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, 123 ::com::sun::star::uno::RuntimeException); 124 }; 125 126 class TmpRepositoryCommandEnv 127 : public ::cppu::WeakImplHelper3< ::com::sun::star::ucb::XCommandEnvironment, 128 ::com::sun::star::task::XInteractionHandler, 129 ::com::sun::star::ucb::XProgressHandler > 130 { 131 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 132 ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_forwardHandler; 133 public: 134 virtual ~TmpRepositoryCommandEnv(); 135 TmpRepositoryCommandEnv(); 136 137 // XCommandEnvironment 138 virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL 139 getInteractionHandler() throw ( ::com::sun::star::uno::RuntimeException ); 140 virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XProgressHandler > 141 SAL_CALL getProgressHandler() throw ( ::com::sun::star::uno::RuntimeException ); 142 143 // XInteractionHandler 144 virtual void SAL_CALL handle( 145 ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & xRequest ) 146 throw (::com::sun::star::uno::RuntimeException); 147 148 // XProgressHandler 149 virtual void SAL_CALL push( ::com::sun::star::uno::Any const & Status ) 150 throw (::com::sun::star::uno::RuntimeException); 151 virtual void SAL_CALL update( ::com::sun::star::uno::Any const & Status ) 152 throw (::com::sun::star::uno::RuntimeException); 153 virtual void SAL_CALL pop() throw (::com::sun::star::uno::RuntimeException); 154 }; 155 156 //......................................................................... 157 } // namespace migration 158 //......................................................................... 159 160 #endif // _DESKTOP_OO3EXTENSIONMIGRATION_HXX_ 161