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