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 62 63 // ============================================================================= 64 // class ExtensionMigration 65 // ============================================================================= 66 67 typedef ::cppu::WeakImplHelper3< 68 ::com::sun::star::lang::XServiceInfo, 69 ::com::sun::star::lang::XInitialization, 70 ::com::sun::star::task::XJob > ExtensionMigration_BASE; 71 72 class OO3ExtensionMigration : public ExtensionMigration_BASE 73 { 74 private: 75 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_ctx; 76 ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XDocumentBuilder > m_xDocBuilder; 77 ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xSimpleFileAccess; 78 ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; 79 ::osl::Mutex m_aMutex; 80 ::rtl::OUString m_sSourceDir; 81 ::rtl::OUString m_sTargetDir; 82 TStringVector m_aBlackList; 83 84 enum ScanResult 85 { 86 SCANRESULT_NOTFOUND, 87 SCANRESULT_MIGRATE_EXTENSION, 88 SCANRESULT_DONTMIGRATE_EXTENSION 89 }; 90 91 ::osl::FileBase::RC checkAndCreateDirectory( INetURLObject& rDirURL ); 92 ScanResult scanExtensionFolder( const ::rtl::OUString& sExtFolder ); 93 void scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ); 94 bool scanDescriptionXml( const ::rtl::OUString& sDescriptionXmlFilePath ); 95 bool migrateExtension( const ::rtl::OUString& sSourceDir ); 96 97 public: 98 OO3ExtensionMigration(::com::sun::star::uno::Reference< 99 ::com::sun::star::uno::XComponentContext > const & ctx); 100 virtual ~OO3ExtensionMigration(); 101 102 // XServiceInfo 103 virtual ::rtl::OUString SAL_CALL getImplementationName(); 104 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ); 105 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(); 106 107 // XInitialization 108 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ); 109 110 // XJob 111 virtual ::com::sun::star::uno::Any SAL_CALL execute( 112 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments ); 113 }; 114 115 class TmpRepositoryCommandEnv 116 : public ::cppu::WeakImplHelper3< ::com::sun::star::ucb::XCommandEnvironment, 117 ::com::sun::star::task::XInteractionHandler, 118 ::com::sun::star::ucb::XProgressHandler > 119 { 120 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 121 ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_forwardHandler; 122 public: 123 virtual ~TmpRepositoryCommandEnv(); 124 TmpRepositoryCommandEnv(); 125 126 // XCommandEnvironment 127 virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL 128 getInteractionHandler(); 129 virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XProgressHandler > 130 SAL_CALL getProgressHandler(); 131 132 // XInteractionHandler 133 virtual void SAL_CALL handle( 134 ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & xRequest ); 135 136 // XProgressHandler 137 virtual void SAL_CALL push( ::com::sun::star::uno::Any const & Status ); 138 virtual void SAL_CALL update( ::com::sun::star::uno::Any const & Status ); 139 virtual void SAL_CALL pop(); 140 }; 141 142 //......................................................................... 143 } // namespace migration 144 //......................................................................... 145 146 #endif // _DESKTOP_OO3EXTENSIONMIGRATION_HXX_ 147