summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorCarsten Driesner <cd@openoffice.org>2010-02-25 09:57:35 +0100
committerCarsten Driesner <cd@openoffice.org>2010-02-25 09:57:35 +0100
commit255d26d575e2ea6efd0dc259196d9c2338de7fb4 (patch)
tree898f431dd606ceb3dc5100302b960db0e1debd8f /desktop
parente033b7ec66dcc250ed801da3cea61aba3d4749bb (diff)
#161436# New migration service to migrate from SO 9.x/OOo 3.x to o5oo
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/migration/migration.cxx129
-rw-r--r--desktop/source/migration/migration_impl.hxx38
-rwxr-xr-xdesktop/source/migration/services/cexportsoo3.cxx71
-rw-r--r--desktop/source/migration/services/makefile.mk47
-rwxr-xr-xdesktop/source/migration/services/migrationoo3.map8
-rwxr-xr-xdesktop/source/migration/services/oo3extensionmigration.cxx656
-rwxr-xr-xdesktop/source/migration/services/oo3extensionmigration.hxx171
7 files changed, 1083 insertions, 37 deletions
diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx
index 7cb230764f..e7c673d1c6 100644
--- a/desktop/source/migration/migration.cxx
+++ b/desktop/source/migration/migration.cxx
@@ -37,6 +37,7 @@
#include <unotools/textsearch.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
#include <unotools/bootstrap.hxx>
#include <rtl/bootstrap.hxx>
#include <tools/config.hxx>
@@ -143,11 +144,11 @@ sal_Bool MigrationImpl::checkMigration()
MigrationImpl::MigrationImpl(const uno::Reference< XMultiServiceFactory >& xFactory)
: m_vrVersions(new strings_v)
, m_xFactory(xFactory)
- , m_vrMigrations(readMigrationSteps())
- , m_aInfo(findInstallation())
- , m_vrFileList(compileFileList())
- , m_vrServiceList(compileServiceList())
{
+ readAvailableMigrations(m_vMigrationsAvailable);
+ sal_Int32 nIndex = findPreferedMigrationProcess(m_vMigrationsAvailable);
+ if ( nIndex >= 0 )
+ m_vrMigrations = readMigrationSteps(m_vMigrationsAvailable[nIndex].name);
}
MigrationImpl::~MigrationImpl()
@@ -157,6 +158,10 @@ MigrationImpl::~MigrationImpl()
sal_Bool MigrationImpl::doMigration()
{
+ // compile file and service list for migration
+ m_vrFileList = compileFileList();
+ m_vrServiceList = compileServiceList();
+
sal_Bool result = sal_False;
try{
copyFiles();
@@ -221,20 +226,61 @@ sal_Bool MigrationImpl::checkMigrationCompleted()
return bMigrationCompleted;
}
-
-migrations_vr MigrationImpl::readMigrationSteps()
+static void insertSorted(migrations_available& rAvailableMigrations, supported_migration& aSupportedMigration)
{
+ bool bInserted( false );
+ migrations_available::iterator pIter = rAvailableMigrations.begin();
+ while ( !bInserted && pIter != rAvailableMigrations.end())
+ {
+ if ( pIter->nPriority < aSupportedMigration.nPriority )
+ {
+ rAvailableMigrations.insert(pIter, aSupportedMigration );
+ bInserted = true;
+ }
+ ++pIter;
+ }
+ if ( !bInserted )
+ rAvailableMigrations.push_back( aSupportedMigration );
+}
+bool MigrationImpl::readAvailableMigrations(migrations_available& rAvailableMigrations)
+{
// get supported version names
- uno::Reference< XNameAccess > aMigrationAccess(getConfigAccess("org.openoffice.Setup/Migration"), uno::UNO_QUERY_THROW);
- uno::Sequence< OUString > seqVersions;
- aMigrationAccess->getByName(OUString::createFromAscii("SupportedVersions")) >>= seqVersions;
- for (sal_Int32 i=0; i<seqVersions.getLength(); i++)
- m_vrVersions->push_back(seqVersions[i].trim());
+ uno::Reference< XNameAccess > aMigrationAccess(getConfigAccess("org.openoffice.Setup/Migration/SupportedVersions"), uno::UNO_QUERY_THROW);
+ uno::Sequence< OUString > seqSupportedVersions = aMigrationAccess->getElementNames();
+
+ const OUString aVersionIdentifiers( RTL_CONSTASCII_USTRINGPARAM( "VersionIdentifiers" ));
+ const OUString aPriorityIdentifier( RTL_CONSTASCII_USTRINGPARAM( "Priority" ));
+ for (sal_Int32 i=0; i<seqSupportedVersions.getLength(); i++)
+ {
+ sal_Int32 nPriority( 0 );
+ uno::Sequence< OUString > seqVersions;
+ uno::Reference< XNameAccess > xMigrationData( aMigrationAccess->getByName(seqSupportedVersions[i]), uno::UNO_QUERY_THROW );
+ xMigrationData->getByName( aVersionIdentifiers ) >>= seqVersions;
+ xMigrationData->getByName( aPriorityIdentifier ) >>= nPriority;
+
+ supported_migration aSupportedMigration;
+ aSupportedMigration.name = seqSupportedVersions[i];
+ aSupportedMigration.nPriority = nPriority;
+ for (sal_Int32 j=0; j<seqVersions.getLength(); j++)
+ aSupportedMigration.supported_versions.push_back(seqVersions[j].trim());
+ insertSorted( rAvailableMigrations, aSupportedMigration );
+ }
+
+ return true;
+}
+
+migrations_vr MigrationImpl::readMigrationSteps(const ::rtl::OUString& rMigrationName)
+{
+ // get migration access
+ uno::Reference< XNameAccess > aMigrationAccess(getConfigAccess("org.openoffice.Setup/Migration/SupportedVersions"), uno::UNO_QUERY_THROW);
+ uno::Reference< XNameAccess > xMigrationData( aMigrationAccess->getByName(rMigrationName), uno::UNO_QUERY_THROW );
+
// get migration description from from org.openoffice.Setup/Migration
// and build vector of migration steps
- uno::Reference< XNameAccess > theNameAccess(getConfigAccess("org.openoffice.Setup/Migration/MigrationSteps"), uno::UNO_QUERY_THROW);
+ OUString aMigrationSteps( RTL_CONSTASCII_USTRINGPARAM( "MigrationSteps" ));
+ uno::Reference< XNameAccess > theNameAccess(xMigrationData->getByName(aMigrationSteps), uno::UNO_QUERY_THROW);
uno::Sequence< OUString > seqMigrations = theNameAccess->getElementNames();
uno::Reference< XNameAccess > tmpAccess;
uno::Reference< XNameAccess > tmpAccess2;
@@ -276,6 +322,20 @@ migrations_vr MigrationImpl::readMigrationSteps()
tmpStep.excludeConfig.push_back(tmpSeq[j]);
}
+ // included extensions...
+ if (tmpAccess->getByName(OUString::createFromAscii("IncludedExtensions")) >>= tmpSeq)
+ {
+ for (sal_Int32 j=0; j<tmpSeq.getLength(); j++)
+ tmpStep.includeExtensions.push_back(tmpSeq[j]);
+ }
+
+ // excluded extensions...
+ if (tmpAccess->getByName(OUString::createFromAscii("ExcludedExtensions")) >>= tmpSeq)
+ {
+ for (sal_Int32 j=0; j<tmpSeq.getLength(); j++)
+ tmpStep.excludeExtensions.push_back(tmpSeq[j]);
+ }
+
// config components
if (tmpAccess->getByName(OUString::createFromAscii("ServiceConfigComponents")) >>= tmpSeq)
{
@@ -283,7 +343,6 @@ migrations_vr MigrationImpl::readMigrationSteps()
tmpStep.configComponents.push_back(tmpSeq[j]);
}
-
// generic service
tmpAccess->getByName(OUString::createFromAscii("MigrationService")) >>= tmpStep.service;
@@ -305,7 +364,7 @@ static FileBase::RC _checkAndCreateDirectory(INetURLObject& dirURL)
return result;
}
-install_info MigrationImpl::findInstallation()
+install_info MigrationImpl::findInstallation(const strings_v& rVersions)
{
rtl::OUString aProductName;
uno::Any aRet = ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME );
@@ -313,9 +372,9 @@ install_info MigrationImpl::findInstallation()
aProductName = aProductName.toAsciiLowerCase();
install_info aInfo;
- strings_v::const_iterator i_ver = m_vrVersions->begin();
+ strings_v::const_iterator i_ver = rVersions.begin();
uno::Reference < util::XStringSubstitution > xSubst( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.PathSubstitution")), uno::UNO_QUERY );
- while (i_ver != m_vrVersions->end())
+ while (i_ver != rVersions.end())
{
::rtl::OUString aVersion, aProfileName;
sal_Int32 nSeparatorIndex = (*i_ver).indexOf('=');
@@ -354,6 +413,28 @@ install_info MigrationImpl::findInstallation()
return aInfo;
}
+sal_Int32 MigrationImpl::findPreferedMigrationProcess(const migrations_available& rAvailableMigrations)
+{
+ bool bFound( false );
+ sal_Int32 nIndex( -1 );
+ sal_Int32 i( 0 );
+
+ migrations_available::const_iterator rIter = rAvailableMigrations.begin();
+ while ( rIter != rAvailableMigrations.end() )
+ {
+ install_info aInstallInfo = findInstallation(rIter->supported_versions);
+ if (aInstallInfo.productname.getLength() > 0 )
+ {
+ m_aInfo = aInstallInfo;
+ nIndex = i;
+ break;
+ }
+ ++i;
+ }
+
+ return nIndex;
+}
+
strings_vr MigrationImpl::applyPatterns(const strings_v& vSet, const strings_v& vPatterns) const
{
using namespace utl;
@@ -520,8 +601,6 @@ void MigrationImpl::copyConfig()
aMsg += OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
OSL_ENSURE(sal_False, aMsg.getStr());
}
-
-
}
// removes elements of vector 2 in vector 1
@@ -629,7 +708,6 @@ void MigrationImpl::copyFiles()
void MigrationImpl::runServices()
{
-
//create stratum for old user layer
OUString aOldLayerURL = m_aInfo.userdata;
aOldLayerURL += OUString::createFromAscii("/user/registry");
@@ -640,7 +718,7 @@ void MigrationImpl::runServices()
aStratumSvc, stratumArgs), uno::UNO_QUERY);
// Build argument array
- uno::Sequence< uno::Any > seqArguments(3);
+ uno::Sequence< uno::Any > seqArguments(4);
seqArguments[0] = uno::makeAny(NamedValue(
OUString::createFromAscii("Productname"),
uno::makeAny(m_aInfo.productname)));
@@ -676,10 +754,21 @@ void MigrationImpl::runServices()
i_comp++;
i++;
}
+
// set old config argument
seqArguments[2] = uno::makeAny(NamedValue(
OUString::createFromAscii("OldConfiguration"),
uno::makeAny(seqComponents)));
+
+ // set black list for extension migration
+ uno::Sequence< rtl::OUString > seqExtBlackList;
+ sal_uInt32 nSize = i_mig->excludeExtensions.size();
+ if ( nSize > 0 )
+ seqExtBlackList = comphelper::arrayToSequence< ::rtl::OUString >(
+ &i_mig->excludeExtensions[0], nSize );
+ seqArguments[3] = uno::makeAny(NamedValue(
+ OUString::createFromAscii("ExtensionBlackList"),
+ uno::makeAny( seqExtBlackList )));
xMigrationJob = uno::Reference< XJob >(m_xFactory->createInstanceWithArguments(
i_mig->service, seqArguments), uno::UNO_QUERY_THROW);
diff --git a/desktop/source/migration/migration_impl.hxx b/desktop/source/migration/migration_impl.hxx
index e07847aed5..aea93b596e 100644
--- a/desktop/source/migration/migration_impl.hxx
+++ b/desktop/source/migration/migration_impl.hxx
@@ -68,11 +68,21 @@ struct migration_step
strings_v includeConfig;
strings_v excludeConfig;
strings_v configComponents;
+ strings_v includeExtensions;
+ strings_v excludeExtensions;
rtl::OUString service;
};
+struct supported_migration
+{
+ rtl::OUString name;
+ sal_Int32 nPriority;
+ strings_v supported_versions;
+};
+
typedef std::vector< migration_step > migrations_v;
typedef std::auto_ptr< migrations_v > migrations_vr;
+typedef std::vector< supported_migration > migrations_available;
class MigrationImpl
{
@@ -80,18 +90,22 @@ class MigrationImpl
private:
strings_vr m_vrVersions;
NS_UNO::Reference< NS_CSS::lang::XMultiServiceFactory > m_xFactory;
- migrations_vr m_vrMigrations; // list of all migration specs from config
- install_info m_aInfo; // info about the version being migrated
- strings_vr m_vrFileList; // final list of files to be copied
- strings_vr m_vrConfigList; // final list of nodes to be copied
- strings_vr m_vrServiceList; // final list of services to be called
-
- // initializer functions...
- migrations_vr readMigrationSteps();
- install_info findInstallation();
- strings_vr compileFileList();
- strings_vr compileConfigList();
- strings_vr compileServiceList();
+
+ migrations_available m_vMigrationsAvailable; // list of all available migrations
+ migrations_vr m_vrMigrations; // list of all migration specs from config
+ install_info m_aInfo; // info about the version being migrated
+ strings_vr m_vrFileList; // final list of files to be copied
+ strings_vr m_vrConfigList; // final list of nodes to be copied
+ strings_vr m_vrServiceList; // final list of services to be called
+
+ // functions to control the migration process
+ bool readAvailableMigrations(migrations_available&);
+ migrations_vr readMigrationSteps(const ::rtl::OUString& rMigrationName);
+ sal_Int32 findPreferedMigrationProcess(const migrations_available&);
+ install_info findInstallation(const strings_v& rVersions);
+ strings_vr compileFileList();
+ strings_vr compileConfigList();
+ strings_vr compileServiceList();
// helpers
void substract(strings_v& va, const strings_v& vb_c) const;
diff --git a/desktop/source/migration/services/cexportsoo3.cxx b/desktop/source/migration/services/cexportsoo3.cxx
new file mode 100755
index 0000000000..b33d78966f
--- /dev/null
+++ b/desktop/source/migration/services/cexportsoo3.cxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cexports.cxx,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_desktop.hxx"
+
+#include "cppuhelper/implementationentry.hxx"
+#include "oo3extensionmigration.hxx"
+
+extern "C"
+{
+
+::cppu::ImplementationEntry entries [] =
+{
+ {
+ migration::OO3ExtensionMigration_create, migration::OO3ExtensionMigration_getImplementationName,
+ migration::OO3ExtensionMigration_getSupportedServiceNames, ::cppu::createSingleComponentFactory,
+ 0, 0
+ },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
+
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ return ::cppu::component_writeInfoHelper(
+ pServiceManager, pRegistryKey, entries );
+}
+
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ return ::cppu::component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey, entries );
+}
+
+}
diff --git a/desktop/source/migration/services/makefile.mk b/desktop/source/migration/services/makefile.mk
index 22d28ee00c..55397a7cb1 100644
--- a/desktop/source/migration/services/makefile.mk
+++ b/desktop/source/migration/services/makefile.mk
@@ -35,6 +35,7 @@ PRJNAME=desktop
TARGET = migrationoo2.uno
ENABLE_EXCEPTIONS=TRUE
COMP1TYPELIST = migrationoo2
+LIBTARGET=NO
# --- Settings -----------------------------------------------------
.INCLUDE : ..$/..$/deployment/inc/dp_misc.mk
@@ -55,7 +56,17 @@ SLOFILES= \
$(SLO)$/basicmigration.obj \
$(SLO)$/wordbookmigration.obj \
$(SLO)$/extensionmigration.obj \
- $(SLO)$/autocorrmigration.obj
+ $(SLO)$/autocorrmigration.obj \
+ $(SLO)$/oo3extensionmigration.obj \
+ $(SLO)$/cexportsoo3.obj \
+
+SHL1OBJS= \
+ $(SLO)$/jvmfwk.obj \
+ $(SLO)$/cexports.obj \
+ $(SLO)$/basicmigration.obj \
+ $(SLO)$/wordbookmigration.obj \
+ $(SLO)$/extensionmigration.obj \
+ $(SLO)$/autocorrmigration.obj \
SHL1TARGET=$(TARGET)
SHL1VERSIONMAP = migrationoo2.map
@@ -72,16 +83,42 @@ SHL1STDLIBS= \
$(JVMFWKLIB) \
$(XMLSCRIPTLIB) \
$(BERKELEYLIB)
-
-
SHL1DEPN=
-SHL1IMPLIB=i$(TARGET)
-SHL1LIBS=$(SLB)$/$(TARGET).lib
+SHL1IMPLIB=imigrationoo2
+#SHL1LIBS=$(SLB)$/$(TARGET).lib
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
DEF1NAME=$(SHL1TARGET)
+COMP2TYPELIST = migrationoo3
+SHL2TARGET=migrationoo3.uno
+SHL2VERSIONMAP = migrationoo3.map
+
+SHL2OBJS= \
+ $(SLO)$/cexportsoo3.obj \
+ $(SLO)$/oo3extensionmigration.obj
+
+SHL2STDLIBS= \
+ $(DEPLOYMENTMISCLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(UCBHELPERLIB) \
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(I18NISOLANGLIB) \
+ $(JVMFWKLIB) \
+ $(XMLSCRIPTLIB) \
+ $(BERKELEYLIB)
+
+SHL2DEPN=
+SHL2IMPLIB=imigrationoo3
+#SHL2LIBS=$(SLB)$/$(SHL2TARGET).lib
+SHL2DEF=$(MISC)$/$(SHL2TARGET).def
+
+DEF2NAME=$(SHL2TARGET)
+
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
diff --git a/desktop/source/migration/services/migrationoo3.map b/desktop/source/migration/services/migrationoo3.map
new file mode 100755
index 0000000000..ac2c3750bf
--- /dev/null
+++ b/desktop/source/migration/services/migrationoo3.map
@@ -0,0 +1,8 @@
+UDK_3_0_0 {
+ global:
+ component_getImplementationEnvironment;
+ component_writeInfo;
+ component_getFactory;
+ local:
+ *;
+};
diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx
new file mode 100755
index 0000000000..07e971b033
--- /dev/null
+++ b/desktop/source/migration/services/oo3extensionmigration.cxx
@@ -0,0 +1,656 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: extensionmigration.cxx,v $
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_desktop.hxx"
+
+#include "oo3extensionmigration.hxx"
+#include <rtl/instance.hxx>
+#include <osl/file.hxx>
+#include <osl/thread.h>
+#include <tools/urlobj.hxx>
+#include <unotools/bootstrap.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/textsearch.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/processfactory.hxx>
+#include <ucbhelper/content.hxx>
+
+#include <com/sun/star/deployment/thePackageManagerFactory.hpp>
+#include <com/sun/star/deployment/XPackageManagerFactory.hpp>
+#include <com/sun/star/task/XInteractionApprove.hpp>
+#include <com/sun/star/task/XInteractionAbort.hpp>
+#include <com/sun/star/ucb/XCommandInfo.hpp>
+#include <com/sun/star/ucb/TransferInfo.hpp>
+#include <com/sun/star/ucb/NameClash.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <com/sun/star/xml/xpath/XXPathAPI.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace migration
+{
+
+static ::rtl::OUString sExtensionSubDir = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/uno_packages/" ) );
+static ::rtl::OUString sSubDirName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cache" ) );
+static ::rtl::OUString sConfigDir = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data" ) );
+static ::rtl::OUString sOrgDir = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data/org" ) );
+static ::rtl::OUString sExcludeDir1 = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data/org" ) );
+static ::rtl::OUString sExcludeDir2 = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data/org/openoffice" ) );
+static ::rtl::OUString sDescriptionXmlFile = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/description.xml" ) );
+static ::rtl::OUString sExtensionRootSubDirName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/uno_packages" ) );
+
+static ::rtl::OUString sConfigurationDataType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.configuration-data"));
+static ::rtl::OUString sConfigurationSchemaType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.configuration-schema"));
+
+// =============================================================================
+// component operations
+// =============================================================================
+
+::rtl::OUString OO3ExtensionMigration_getImplementationName()
+{
+ static ::rtl::OUString* pImplName = 0;
+ if ( !pImplName )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pImplName )
+ {
+ static ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.desktop.migration.OOo3Extensions" ) );
+ pImplName = &aImplName;
+ }
+ }
+ return *pImplName;
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > OO3ExtensionMigration_getSupportedServiceNames()
+{
+ static Sequence< ::rtl::OUString >* pNames = 0;
+ if ( !pNames )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pNames )
+ {
+ static Sequence< ::rtl::OUString > aNames(1);
+ aNames.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.migration.Extensions" ) );
+ pNames = &aNames;
+ }
+ }
+ return *pNames;
+}
+
+// =============================================================================
+// ExtensionMigration
+// =============================================================================
+
+OO3ExtensionMigration::OO3ExtensionMigration(Reference< XComponentContext > const & ctx) :
+m_ctx(ctx)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+OO3ExtensionMigration::~OO3ExtensionMigration()
+{
+}
+
+::osl::FileBase::RC OO3ExtensionMigration::checkAndCreateDirectory( INetURLObject& rDirURL )
+{
+ ::osl::FileBase::RC aResult = ::osl::Directory::create( rDirURL.GetMainURL( INetURLObject::DECODE_TO_IURI ) );
+ if ( aResult == ::osl::FileBase::E_NOENT )
+ {
+ INetURLObject aBaseURL( rDirURL );
+ aBaseURL.removeSegment();
+ checkAndCreateDirectory( aBaseURL );
+ return ::osl::Directory::create( rDirURL.GetMainURL( INetURLObject::DECODE_TO_IURI ) );
+ }
+ else
+ {
+ return aResult;
+ }
+}
+
+void OO3ExtensionMigration::registerConfigurationPackage( const uno::Reference< deployment::XPackage > & xPkg)
+{
+ const ::rtl::OUString sMediaType = xPkg->getPackageType()->getMediaType();
+ if ( (sMediaType.equals(sConfigurationDataType) || sMediaType.equals(sConfigurationSchemaType) ) )
+ {
+ xPkg->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ());
+ xPkg->registerPackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ());
+ }
+}
+
+ void OO3ExtensionMigration::scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions )
+{
+ osl::Directory aScanRootDir( sSourceDir );
+ osl::FileStatus fs(FileStatusMask_Type | FileStatusMask_FileURL);
+ osl::FileBase::RC nRetCode = aScanRootDir.open();
+ if ( nRetCode == osl::Directory::E_None )
+ {
+ sal_uInt32 nHint( 0 );
+ osl::DirectoryItem aItem;
+ while ( aScanRootDir.getNextItem( aItem, nHint ) == osl::Directory::E_None )
+ {
+ if (( aItem.getFileStatus(fs) == osl::FileBase::E_None ) &&
+ ( fs.getFileType() == osl::FileStatus::Directory ))
+ {
+ //Check next folder as the "real" extension folder is below a temp folder!
+ ::rtl::OUString sExtensionFolderURL = fs.getFileURL();
+
+ osl::DirectoryItem aExtDirItem;
+ osl::Directory aExtensionRootDir( sExtensionFolderURL );
+
+ nRetCode = aExtensionRootDir.open();
+ if (( nRetCode == osl::Directory::E_None ) &&
+ ( aExtensionRootDir.getNextItem( aExtDirItem, nHint ) == osl::Directory::E_None ))
+ {
+ bool bFileStatus = aExtDirItem.getFileStatus(fs) == osl::FileBase::E_None;
+ bool bIsDir = fs.getFileType() == osl::FileStatus::Directory;
+
+ if ( bFileStatus && bIsDir )
+ {
+ sExtensionFolderURL = fs.getFileURL();
+ ScanResult eResult = scanExtensionFolder( sExtensionFolderURL );
+ if ( eResult == SCANRESULT_MIGRATE_EXTENSION )
+ aMigrateExtensions.push_back( sExtensionFolderURL );
+ }
+ }
+ }
+ }
+ }
+}
+
+OO3ExtensionMigration::ScanResult OO3ExtensionMigration::scanExtensionFolder( const ::rtl::OUString& sExtFolder )
+{
+ ScanResult aResult = SCANRESULT_NOTFOUND;
+ osl::Directory aDir(sExtFolder);
+
+ // get sub dirs
+ if (aDir.open() == osl::FileBase::E_None)
+ {
+ // work through directory contents...
+ osl::DirectoryItem item;
+ osl::FileStatus fs(FileStatusMask_Type | FileStatusMask_FileURL);
+ TStringVector aDirectories;
+ while ((aDir.getNextItem(item) == osl::FileBase::E_None ) &&
+ ( aResult == SCANRESULT_NOTFOUND ))
+ {
+ if (item.getFileStatus(fs) == osl::FileBase::E_None)
+ {
+ ::rtl::OUString aDirEntryURL;
+ if (fs.getFileType() == osl::FileStatus::Directory)
+ aDirectories.push_back( fs.getFileURL() );
+ else
+ {
+ aDirEntryURL = fs.getFileURL();
+ if ( aDirEntryURL.indexOf( sDescriptionXmlFile ) > 0 )
+ aResult = scanDescriptionXml( aDirEntryURL ) ? SCANRESULT_MIGRATE_EXTENSION : SCANRESULT_DONTMIGRATE_EXTENSION;
+ }
+ }
+ }
+
+ TStringVector::const_iterator pIter = aDirectories.begin();
+ while ( pIter != aDirectories.end() && aResult == SCANRESULT_NOTFOUND )
+ {
+ aResult = scanExtensionFolder( *pIter );
+ ++pIter;
+ }
+ }
+ return aResult;
+}
+
+bool OO3ExtensionMigration::scanDescriptionXml( const ::rtl::OUString& sDescriptionXmlURL )
+{
+ if ( !m_xDocBuilder.is() )
+ {
+ m_xDocBuilder = uno::Reference< xml::dom::XDocumentBuilder >(
+ m_ctx->getServiceManager()->createInstanceWithContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.dom.DocumentBuilder")),
+ m_ctx ), uno::UNO_QUERY );
+ }
+
+ if ( !m_xSimpleFileAccess.is() )
+ {
+ m_xSimpleFileAccess = uno::Reference< ucb::XSimpleFileAccess >(
+ m_ctx->getServiceManager()->createInstanceWithContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")),
+ m_ctx ), uno::UNO_QUERY );
+ }
+
+ ::rtl::OUString aExtIdentifier;
+ if ( m_xDocBuilder.is() && m_xSimpleFileAccess.is() )
+ {
+ try
+ {
+ uno::Reference< io::XInputStream > xIn =
+ m_xSimpleFileAccess->openFileRead( sDescriptionXmlURL );
+
+ if ( xIn.is() )
+ {
+ uno::Reference< xml::dom::XDocument > xDoc = m_xDocBuilder->parse( xIn );
+ if ( xDoc.is() )
+ {
+ uno::Reference< xml::dom::XElement > xRoot = xDoc->getDocumentElement();
+ if ( xRoot.is() &&
+ xRoot->getTagName().equals(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("description"))) )
+ {
+ uno::Reference< xml::xpath::XXPathAPI > xPath(
+ m_ctx->getServiceManager()->createInstanceWithContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.xpath.XPathAPI")),
+ m_ctx),
+ uno::UNO_QUERY);
+
+ xPath->registerNS(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("desc")),
+ xRoot->getNamespaceURI());
+ xPath->registerNS(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("xlink")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http://www.w3.org/1999/xlink")));
+
+ try
+ {
+ uno::Reference< xml::dom::XNode > xRootNode( xRoot, uno::UNO_QUERY );
+ uno::Reference< xml::dom::XNode > xNode(
+ xPath->selectSingleNode(
+ xRootNode,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("desc:identifier/@value")) ));
+ if ( xNode.is() )
+ aExtIdentifier = xNode->getNodeValue();
+ }
+ catch ( xml::xpath::XPathException& )
+ {
+ }
+ catch ( xml::dom::DOMException& )
+ {
+ }
+ }
+ }
+ }
+
+ if ( aExtIdentifier.getLength() > 0 )
+ {
+ // scan extension identifier and try to match with our black list entries
+ for ( sal_uInt32 i = 0; i < m_aBlackList.size(); i++ )
+ {
+ utl::SearchParam param(m_aBlackList[i], utl::SearchParam::SRCH_REGEXP);
+ utl::TextSearch ts(param, LANGUAGE_DONTKNOW);
+
+ xub_StrLen start = 0;
+ xub_StrLen end = static_cast<USHORT>(aExtIdentifier.getLength());
+ if (ts.SearchFrwrd(aExtIdentifier, &start, &end))
+ return false;
+ }
+ }
+ }
+ catch ( ucb::CommandAbortedException& )
+ {
+ }
+ catch ( uno::RuntimeException& )
+ {
+ }
+
+ if ( aExtIdentifier.getLength() == 0 )
+ {
+ // Fallback:
+ // Try to use the folder name to match our black list
+ // as some extensions don't provide an identifier in the
+ // description.xml!
+ for ( sal_uInt32 i = 0; i < m_aBlackList.size(); i++ )
+ {
+ utl::SearchParam param(m_aBlackList[i], utl::SearchParam::SRCH_REGEXP);
+ utl::TextSearch ts(param, LANGUAGE_DONTKNOW);
+
+ xub_StrLen start = 0;
+ xub_StrLen end = static_cast<USHORT>(sDescriptionXmlURL.getLength());
+ if (ts.SearchFrwrd(sDescriptionXmlURL, &start, &end))
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir )
+{
+ if ( !m_xPackageManager.is() )
+ {
+ try
+ {
+ m_xPackageManager = deployment::thePackageManagerFactory::get( m_ctx )->getPackageManager(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "user" )) );
+ }
+ catch ( ucb::CommandFailedException & ){}
+ catch ( uno::RuntimeException & ) {}
+ }
+
+ if ( m_xPackageManager.is() )
+ {
+ try
+ {
+ TmpRepositoryCommandEnv* pCmdEnv = new TmpRepositoryCommandEnv();
+
+ uno::Reference< ucb::XCommandEnvironment > xCmdEnv(
+ static_cast< cppu::OWeakObject* >( pCmdEnv ), uno::UNO_QUERY );
+ uno::Reference< task::XAbortChannel > xAbortChannel;
+ uno::Reference< deployment::XPackage > xPackage =
+ m_xPackageManager->addPackage( sSourceDir, ::rtl::OUString(), xAbortChannel, xCmdEnv );
+
+ if ( xPackage.is() )
+ return true;
+ }
+ catch ( ucb::CommandFailedException& )
+ {
+ }
+ catch ( ucb::CommandAbortedException& )
+ {
+ }
+ catch ( lang::IllegalArgumentException& )
+ {
+ }
+ }
+
+ return false;
+}
+
+bool OO3ExtensionMigration::copy( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir )
+{
+ bool bRet = false;
+
+ INetURLObject aSourceObj( sSourceDir );
+ INetURLObject aDestObj( sTargetDir );
+ String aName = aDestObj.getName();
+ aDestObj.removeSegment();
+ aDestObj.setFinalSlash();
+
+ try
+ {
+ ::ucbhelper::Content aDestPath( aDestObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () );
+ uno::Reference< ucb::XCommandInfo > xInfo = aDestPath.getCommands();
+ ::rtl::OUString aTransferName = ::rtl::OUString::createFromAscii( "transfer" );
+ if ( xInfo->hasCommandByName( aTransferName ) )
+ {
+ aDestPath.executeCommand( aTransferName, uno::makeAny(
+ ucb::TransferInfo( sal_False, aSourceObj.GetMainURL( INetURLObject::NO_DECODE ), aName, ucb::NameClash::OVERWRITE ) ) );
+ bRet = true;
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ return bRet;
+}
+
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OO3ExtensionMigration::getImplementationName() throw (RuntimeException)
+{
+ return OO3ExtensionMigration_getImplementationName();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool OO3ExtensionMigration::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pNames + aNames.getLength();
+ for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
+ ;
+
+ return pNames != pEnd;
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< ::rtl::OUString > OO3ExtensionMigration::getSupportedServiceNames() throw (RuntimeException)
+{
+ return OO3ExtensionMigration_getSupportedServiceNames();
+}
+
+// -----------------------------------------------------------------------------
+// XInitialization
+// -----------------------------------------------------------------------------
+
+void OO3ExtensionMigration::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ const Any* pIter = aArguments.getConstArray();
+ const Any* pEnd = pIter + aArguments.getLength();
+ for ( ; pIter != pEnd ; ++pIter )
+ {
+ beans::NamedValue aValue;
+ *pIter >>= aValue;
+ if ( aValue.Name.equalsAscii( "UserData" ) )
+ {
+ if ( !(aValue.Value >>= m_sSourceDir) )
+ {
+ OSL_ENSURE( false, "ExtensionMigration::initialize: argument UserData has wrong type!" );
+ }
+ }
+ else if ( aValue.Name.equalsAscii( "ExtensionBlackList" ) )
+ {
+ Sequence< ::rtl::OUString > aBlackList;
+ if ( (aValue.Value >>= aBlackList ) && ( aBlackList.getLength() > 0 ))
+ {
+ m_aBlackList.resize( aBlackList.getLength() );
+ ::comphelper::sequenceToArray< ::rtl::OUString >( &m_aBlackList[0], aBlackList );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+TStringVectorPtr getContent( const ::rtl::OUString& rBaseURL )
+{
+ TStringVectorPtr aResult( new TStringVector );
+ ::osl::Directory aDir( rBaseURL);
+ if ( aDir.open() == ::osl::FileBase::E_None )
+ {
+ // iterate over directory content
+ TStringVector aSubDirs;
+ ::osl::DirectoryItem aItem;
+ while ( aDir.getNextItem( aItem ) == ::osl::FileBase::E_None )
+ {
+ ::osl::FileStatus aFileStatus( FileStatusMask_Type | FileStatusMask_FileURL );
+ if ( aItem.getFileStatus( aFileStatus ) == ::osl::FileBase::E_None )
+ aResult->push_back( aFileStatus.getFileURL() );
+ }
+ }
+
+ return aResult;
+}
+
+// -----------------------------------------------------------------------------
+// XJob
+// -----------------------------------------------------------------------------
+
+void OO3ExtensionMigration::copyConfig( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir )
+{
+ ::rtl::OUString sEx1( m_sSourceDir );
+ sEx1 += sExcludeDir1;
+ ::rtl::OUString sEx2( m_sSourceDir );
+ sEx2 += sExcludeDir2;
+
+ TStringVectorPtr aList = getContent( sSourceDir );
+ TStringVector::const_iterator aI = aList->begin();
+ while ( aI != aList->end() )
+ {
+ ::rtl::OUString sSourceLocalName = aI->copy( sSourceDir.getLength() );
+ ::rtl::OUString aTemp = aI->copy( m_sSourceDir.getLength() );
+ if ( aTemp != sExcludeDir1 && aTemp != sExcludeDir2 )
+ {
+ ::rtl::OUString sTargetName = sTargetDir + sSourceLocalName;
+ copy( (*aI), sTargetName );
+ }
+ ++aI;
+ }
+}
+
+Any OO3ExtensionMigration::execute( const Sequence< beans::NamedValue >& )
+ throw (lang::IllegalArgumentException, Exception, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::utl::Bootstrap::PathStatus aStatus = ::utl::Bootstrap::locateUserInstallation( m_sTargetDir );
+ if ( aStatus == ::utl::Bootstrap::PATH_EXISTS )
+ {
+ // copy all extensions
+ ::rtl::OUString sSourceDir( m_sSourceDir );
+ sSourceDir += sExtensionSubDir;
+ sSourceDir += sSubDirName;
+ sSourceDir += sExtensionRootSubDirName;
+ TStringVector aExtensionToMigrate;
+ scanUserExtensions( sSourceDir, aExtensionToMigrate );
+ if ( aExtensionToMigrate.size() > 0 )
+ {
+ TStringVector::iterator pIter = aExtensionToMigrate.begin();
+ while ( pIter != aExtensionToMigrate.end() )
+ {
+ migrateExtension( *pIter );
+ ++pIter;
+ }
+ }
+ }
+
+ return Any();
+}
+
+// -----------------------------------------------------------------------------
+// TmpRepositoryCommandEnv
+// -----------------------------------------------------------------------------
+
+TmpRepositoryCommandEnv::TmpRepositoryCommandEnv()
+{
+}
+
+TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(
+ uno::Reference< task::XInteractionHandler> const & handler)
+ : m_forwardHandler(handler)
+{
+}
+
+TmpRepositoryCommandEnv::~TmpRepositoryCommandEnv()
+{
+}
+// XCommandEnvironment
+//______________________________________________________________________________
+uno::Reference< task::XInteractionHandler > TmpRepositoryCommandEnv::getInteractionHandler()
+throw ( uno::RuntimeException )
+{
+ return this;
+}
+
+//______________________________________________________________________________
+uno::Reference< ucb::XProgressHandler > TmpRepositoryCommandEnv::getProgressHandler()
+throw ( uno::RuntimeException )
+{
+ return this;
+}
+
+// XInteractionHandler
+void TmpRepositoryCommandEnv::handle(
+ uno::Reference< task::XInteractionRequest> const & xRequest )
+ throw ( uno::RuntimeException )
+{
+ uno::Any request( xRequest->getRequest() );
+ OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
+
+ bool approve = true;
+ bool abort = false;
+
+ // select:
+ uno::Sequence< Reference< task::XInteractionContinuation > > conts(
+ xRequest->getContinuations() );
+ Reference< task::XInteractionContinuation > const * pConts =
+ conts.getConstArray();
+ sal_Int32 len = conts.getLength();
+ for ( sal_Int32 pos = 0; pos < len; ++pos )
+ {
+ if (approve) {
+ uno::Reference< task::XInteractionApprove > xInteractionApprove(
+ pConts[ pos ], uno::UNO_QUERY );
+ if (xInteractionApprove.is()) {
+ xInteractionApprove->select();
+ // don't query again for ongoing continuations:
+ approve = false;
+ }
+ }
+ else if (abort) {
+ uno::Reference< task::XInteractionAbort > xInteractionAbort(
+ pConts[ pos ], uno::UNO_QUERY );
+ if (xInteractionAbort.is()) {
+ xInteractionAbort->select();
+ // don't query again for ongoing continuations:
+ abort = false;
+ }
+ }
+ }
+}
+
+// XProgressHandler
+void TmpRepositoryCommandEnv::push( uno::Any const & /*Status*/ )
+throw (uno::RuntimeException)
+{
+}
+
+
+void TmpRepositoryCommandEnv::update( uno::Any const & /*Status */)
+throw (uno::RuntimeException)
+{
+}
+
+void TmpRepositoryCommandEnv::pop() throw (uno::RuntimeException)
+{
+}
+
+// =============================================================================
+// component operations
+// =============================================================================
+
+Reference< XInterface > SAL_CALL OO3ExtensionMigration_create(
+ Reference< XComponentContext > const & ctx )
+ SAL_THROW( () )
+{
+ return static_cast< lang::XTypeProvider * >( new OO3ExtensionMigration(
+ ctx) );
+}
+
+// -----------------------------------------------------------------------------
+
+} // namespace migration
diff --git a/desktop/source/migration/services/oo3extensionmigration.hxx b/desktop/source/migration/services/oo3extensionmigration.hxx
new file mode 100755
index 0000000000..4a2b389310
--- /dev/null
+++ b/desktop/source/migration/services/oo3extensionmigration.hxx
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: extensionmigration.hxx,v $
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DESKTOP_OO3EXTENSIONMIGRATION_HXX_
+#define _DESKTOP_OO3EXTENSIONMIGRATION_HXX_
+
+#include "misc.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/task/XJob.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/deployment/XPackageManager.hpp>
+
+#include <osl/mutex.hxx>
+#include <osl/file.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/compbase3.hxx>
+#include <ucbhelper/content.hxx>
+#include <xmlscript/xmllib_imexp.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class XComponentContext;
+ }
+ namespace deployment {
+ class XPackage;
+ }
+}}}
+
+class INetURLObject;
+
+
+namespace migration
+{
+
+ ::rtl::OUString SAL_CALL OO3ExtensionMigration_getImplementationName();
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OO3ExtensionMigration_getSupportedServiceNames();
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL OO3ExtensionMigration_create(
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext )
+ SAL_THROW( (::com::sun::star::uno::Exception) );
+
+
+ // =============================================================================
+ // class ExtensionMigration
+ // =============================================================================
+
+ typedef ::cppu::WeakImplHelper3<
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XInitialization,
+ ::com::sun::star::task::XJob > ExtensionMigration_BASE;
+
+ class OO3ExtensionMigration : public ExtensionMigration_BASE
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_ctx;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XDocumentBuilder > m_xDocBuilder;
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xSimpleFileAccess;
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > m_xPackageManager;
+ ::osl::Mutex m_aMutex;
+ ::rtl::OUString m_sSourceDir;
+ ::rtl::OUString m_sTargetDir;
+ TStringVector m_aBlackList;
+
+ enum ScanResult
+ {
+ SCANRESULT_NOTFOUND,
+ SCANRESULT_MIGRATE_EXTENSION,
+ SCANRESULT_DONTMIGRATE_EXTENSION
+ };
+
+ ::osl::FileBase::RC checkAndCreateDirectory( INetURLObject& rDirURL );
+ void copyConfig( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir );
+ bool copy( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir );
+ ScanResult scanExtensionFolder( const ::rtl::OUString& sExtFolder );
+ void scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions );
+ bool scanDescriptionXml( const ::rtl::OUString& sDescriptionXmlFilePath );
+ bool migrateExtension( const ::rtl::OUString& sSourceDir );
+ /* fills m_scriptElements and m_dialogElements
+ */
+ void registerConfigurationPackage(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & xPkg);
+
+ public:
+ OO3ExtensionMigration(::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > const & ctx);
+ virtual ~OO3ExtensionMigration();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XJob
+ virtual ::com::sun::star::uno::Any SAL_CALL execute(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception,
+ ::com::sun::star::uno::RuntimeException);
+ };
+
+ class TmpRepositoryCommandEnv
+ : public ::cppu::WeakImplHelper3< ::com::sun::star::ucb::XCommandEnvironment,
+ ::com::sun::star::task::XInteractionHandler,
+ ::com::sun::star::ucb::XProgressHandler >
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_forwardHandler;
+ public:
+ virtual ~TmpRepositoryCommandEnv();
+ TmpRepositoryCommandEnv();
+ TmpRepositoryCommandEnv(
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> const & handler);
+
+ // XCommandEnvironment
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL
+ getInteractionHandler() throw ( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XProgressHandler >
+ SAL_CALL getProgressHandler() throw ( ::com::sun::star::uno::RuntimeException );
+
+ // XInteractionHandler
+ virtual void SAL_CALL handle(
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & xRequest )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XProgressHandler
+ virtual void SAL_CALL push( ::com::sun::star::uno::Any const & Status )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL update( ::com::sun::star::uno::Any const & Status )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL pop() throw (::com::sun::star::uno::RuntimeException);
+ };
+
+//.........................................................................
+} // namespace migration
+//.........................................................................
+
+#endif // _DESKTOP_OO3EXTENSIONMIGRATION_HXX_