summaryrefslogtreecommitdiff
path: root/desktop/source
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/source')
-rw-r--r--desktop/source/app/app.cxx38
-rwxr-xr-x[-rw-r--r--]desktop/source/app/check_ext_deps.cxx305
-rw-r--r--desktop/source/app/makefile.mk14
-rw-r--r--desktop/source/deployment/dp_services.cxx19
-rw-r--r--desktop/source/deployment/gui/dp_gui.h9
-rwxr-xr-x[-rw-r--r--]desktop/source/deployment/gui/dp_gui.hrc3
-rwxr-xr-x[-rw-r--r--]desktop/source/deployment/gui/dp_gui_dialog.src20
-rwxr-xr-x[-rw-r--r--]desktop/source/deployment/gui/dp_gui_dialog2.cxx170
-rwxr-xr-x[-rw-r--r--]desktop/source/deployment/gui/dp_gui_dialog2.hxx40
-rwxr-xr-x[-rw-r--r--]desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx203
-rwxr-xr-x[-rw-r--r--]desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx13
-rwxr-xr-xdesktop/source/deployment/gui/dp_gui_extlistbox.cxx100
-rwxr-xr-xdesktop/source/deployment/gui/dp_gui_extlistbox.hxx26
-rwxr-xr-x[-rw-r--r--]desktop/source/deployment/gui/dp_gui_service.cxx2
-rwxr-xr-x[-rw-r--r--]desktop/source/deployment/gui/dp_gui_theextmgr.cxx179
-rwxr-xr-x[-rw-r--r--]desktop/source/deployment/gui/dp_gui_theextmgr.hxx22
-rw-r--r--desktop/source/deployment/gui/dp_gui_updatedata.hxx40
-rw-r--r--desktop/source/deployment/gui/dp_gui_updatedialog.cxx403
-rw-r--r--desktop/source/deployment/gui/dp_gui_updatedialog.hxx25
-rw-r--r--desktop/source/deployment/gui/dp_gui_updatedialog.src12
-rw-r--r--desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx50
-rw-r--r--desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx6
-rw-r--r--desktop/source/deployment/gui/license_dialog.cxx11
-rw-r--r--desktop/source/deployment/gui/license_dialog.hxx1
-rw-r--r--desktop/source/deployment/inc/dp_descriptioninfoset.hxx15
-rw-r--r--desktop/source/deployment/inc/dp_misc.h33
-rw-r--r--desktop/source/deployment/inc/dp_ucb.h7
-rwxr-xr-xdesktop/source/deployment/inc/dp_update.hxx147
-rw-r--r--desktop/source/deployment/inc/dp_version.hxx7
-rw-r--r--desktop/source/deployment/makefile.mk1
-rw-r--r--desktop/source/deployment/manager/dp_activepackages.cxx28
-rw-r--r--desktop/source/deployment/manager/dp_activepackages.hxx19
-rw-r--r--desktop/source/deployment/manager/dp_commandenvironments.cxx286
-rw-r--r--desktop/source/deployment/manager/dp_commandenvironments.hxx160
-rw-r--r--desktop/source/deployment/manager/dp_extensionmanager.cxx1361
-rw-r--r--desktop/source/deployment/manager/dp_extensionmanager.hxx307
-rw-r--r--desktop/source/deployment/manager/dp_informationprovider.cxx380
-rw-r--r--desktop/source/deployment/manager/dp_manager.cxx909
-rw-r--r--desktop/source/deployment/manager/dp_manager.h69
-rw-r--r--desktop/source/deployment/manager/dp_manager.hrc2
-rw-r--r--desktop/source/deployment/manager/dp_manager.src4
-rw-r--r--desktop/source/deployment/manager/dp_managerfac.cxx4
-rw-r--r--desktop/source/deployment/manager/dp_properties.cxx169
-rw-r--r--desktop/source/deployment/manager/dp_properties.hxx81
-rw-r--r--desktop/source/deployment/manager/makefile.mk5
-rw-r--r--desktop/source/deployment/migration/dp_migration.cxx251
-rw-r--r--desktop/source/deployment/migration/makefile.mk41
-rw-r--r--desktop/source/deployment/misc/dp_descriptioninfoset.cxx250
-rw-r--r--desktop/source/deployment/misc/dp_misc.cxx177
-rw-r--r--desktop/source/deployment/misc/dp_ucb.cxx46
-rwxr-xr-xdesktop/source/deployment/misc/dp_update.cxx397
-rw-r--r--desktop/source/deployment/misc/dp_version.cxx6
-rw-r--r--desktop/source/deployment/misc/makefile.mk6
-rw-r--r--desktop/source/deployment/registry/component/dp_compbackenddb.cxx156
-rw-r--r--desktop/source/deployment/registry/component/dp_compbackenddb.hxx120
-rw-r--r--desktop/source/deployment/registry/component/dp_component.cxx540
-rw-r--r--desktop/source/deployment/registry/component/makefile.mk3
-rw-r--r--desktop/source/deployment/registry/configuration/dp_configuration.cxx275
-rw-r--r--desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx186
-rw-r--r--desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx96
-rw-r--r--desktop/source/deployment/registry/configuration/makefile.mk3
-rw-r--r--desktop/source/deployment/registry/dp_backend.cxx274
-rw-r--r--desktop/source/deployment/registry/dp_backenddb.cxx649
-rw-r--r--desktop/source/deployment/registry/dp_registry.cxx35
-rw-r--r--desktop/source/deployment/registry/executable/dp_executable.cxx94
-rw-r--r--desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx84
-rw-r--r--desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx79
-rw-r--r--desktop/source/deployment/registry/executable/makefile.mk3
-rw-r--r--desktop/source/deployment/registry/help/dp_help.cxx318
-rw-r--r--desktop/source/deployment/registry/help/dp_helpbackenddb.cxx178
-rw-r--r--desktop/source/deployment/registry/help/dp_helpbackenddb.hxx92
-rw-r--r--desktop/source/deployment/registry/help/makefile.mk3
-rw-r--r--desktop/source/deployment/registry/inc/dp_backend.h105
-rw-r--r--desktop/source/deployment/registry/inc/dp_backenddb.hxx170
-rw-r--r--desktop/source/deployment/registry/makefile.mk3
-rw-r--r--desktop/source/deployment/registry/package/dp_description.cxx205
-rw-r--r--desktop/source/deployment/registry/package/dp_description.hxx125
-rw-r--r--desktop/source/deployment/registry/package/dp_extbackenddb.cxx135
-rw-r--r--desktop/source/deployment/registry/package/dp_extbackenddb.hxx96
-rw-r--r--desktop/source/deployment/registry/package/dp_package.cxx568
-rw-r--r--desktop/source/deployment/registry/package/makefile.mk2
-rw-r--r--desktop/source/deployment/registry/script/dp_script.cxx304
-rw-r--r--desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx88
-rw-r--r--desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx76
-rw-r--r--desktop/source/deployment/registry/script/makefile.mk3
-rw-r--r--desktop/source/deployment/registry/sfwk/dp_sfwk.cxx24
-rw-r--r--desktop/source/deployment/unopkg/unopkg.src7
-rw-r--r--desktop/source/inc/exithelper.hxx2
-rwxr-xr-x[-rw-r--r--]desktop/source/migration/migration.cxx2
-rw-r--r--desktop/source/migration/services/cexports.cxx12
-rwxr-xr-xdesktop/source/migration/services/extensionmigration.cxx540
-rwxr-xr-xdesktop/source/migration/services/extensionmigration.hxx130
-rw-r--r--desktop/source/migration/services/makefile.mk2
-rw-r--r--desktop/source/migration/services/oo3extensionmigration.cxx15
-rw-r--r--desktop/source/migration/services/oo3extensionmigration.hxx4
-rw-r--r--desktop/source/offacc/acceptor.cxx6
-rw-r--r--desktop/source/offacc/acceptor.hxx1
-rw-r--r--desktop/source/pkgchk/unopkg/unopkg_app.cxx254
-rw-r--r--desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx57
-rw-r--r--desktop/source/pkgchk/unopkg/unopkg_misc.cxx42
-rw-r--r--desktop/source/pkgchk/unopkg/unopkg_shared.h10
-rw-r--r--desktop/source/splash/splash.cxx27
-rw-r--r--desktop/source/splash/splash.hxx1
103 files changed, 9441 insertions, 3642 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 6f00d47332ac..bba615e0ebbc 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -84,6 +84,7 @@
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/task/XJobExecutor.hpp>
+#include <com/sun/star/task/XRestartManager.hpp>
#ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_
#include <com/sun/star/task/XJob.hpp>
#endif
@@ -103,6 +104,7 @@
#include <vos/security.hxx>
#include <vos/ref.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/componentcontext.hxx>
#include <comphelper/configurationhelper.hxx>
#ifndef _UTL__HXX_
#include <unotools/configmgr.hxx>
@@ -140,6 +142,7 @@
#include <sfx2/sfx.hrc>
#include <ucbhelper/contentbroker.hxx>
#include <unotools/bootstrap.hxx>
+#include <cppuhelper/bootstrap.hxx>
#include "vos/process.hxx"
@@ -1409,10 +1412,13 @@ void Desktop::Main()
tools::InitTestToolLib();
RTL_LOGFILE_CONTEXT_TRACE( aLog, "} tools::InitTestToolLib" );
+ // Check if bundled or shared extensions were added /removed
+ // and process those extensions (has to be done before checking
+ // the extension dependencies!
+ SynchronizeExtensionRepositories();
bool bAbort = CheckExtensionDependencies();
if ( bAbort )
return;
-
// First Start Wizard allowed ?
if ( ! pCmdLineArgs->IsNoFirstStartWizard())
{
@@ -1456,7 +1462,6 @@ void Desktop::Main()
}
SetSplashScreenProgress(50);
-
// Backing Component
sal_Bool bCrashed = sal_False;
sal_Bool bExistsRecoveryData = sal_False;
@@ -1627,6 +1632,7 @@ void Desktop::Main()
// call Application::Execute to process messages in vcl message loop
RTL_LOGFILE_PRODUCT_TRACE( "PERFORMANCE - enter Application::Execute()" );
+ Reference< ::com::sun::star::task::XRestartManager > xRestartManager;
try
{
// The JavaContext contains an interaction handler which is used when
@@ -1634,7 +1640,10 @@ void Desktop::Main()
com::sun::star::uno::ContextLayer layer2(
new svt::JavaContext( com::sun::star::uno::getCurrentContext() ) );
- Execute();
+ ::comphelper::ComponentContext aContext( xSMgr );
+ xRestartManager.set( aContext.getSingleton( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.OfficeRestartManager" ) ) ), UNO_QUERY );
+ if ( !xRestartManager.is() || !xRestartManager->isRestartRequested( sal_True ) )
+ Execute();
}
catch(const com::sun::star::document::CorruptedFilterConfigurationException& exFilterCfg)
{
@@ -1647,6 +1656,9 @@ void Desktop::Main()
FatalError( MakeStartupErrorMessage(exAnyCfg.Message) );
}
+ // check whether the shutdown is caused by restart
+ sal_Bool bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) );
+
if (xGlobalBroadcaster.is())
{
css::document::EventObject aEvent;
@@ -1655,22 +1667,18 @@ void Desktop::Main()
}
delete pResMgr;
-
// Restore old value
if ( pCmdLineArgs->IsHeadless() )
SvtMiscOptions().SetUseSystemFileDialog( bUseSystemFileDialog );
// remove temp directory
RemoveTemporaryDirectory();
-
// The acceptors in the AcceptorMap must be released (in DeregisterServices)
// with the solar mutex unlocked, to avoid deadlock:
nAcquireCount = Application::ReleaseSolarMutex();
DeregisterServices();
Application::AcquireSolarMutex(nAcquireCount);
-
tools::DeInitTestToolLib();
-
// be sure that path/language options gets destroyed before
// UCB is deinitialized
RTL_LOGFILE_CONTEXT_TRACE( aLog, "-> dispose path/language options" );
@@ -1683,6 +1691,14 @@ void Desktop::Main()
RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- deinit ucb" );
RTL_LOGFILE_CONTEXT_TRACE( aLog, "FINISHED WITH Destop::Main" );
+ if ( bRestartRequested )
+ {
+#ifdef MACOSX
+ DoRestart();
+#endif
+ // wouldn't the solution be more clean if SalMain returns the exit code to the system?
+ _exit( ExitHelper::E_NORMAL_RESTART );
+ }
}
IMPL_LINK( Desktop, ImplInitFilterHdl, ConvertData*, pData )
@@ -2933,6 +2949,14 @@ void Desktop::SetSplashScreenProgress(sal_Int32 iProgress)
}
}
+void Desktop::SetSplashScreenText( const ::rtl::OUString& rText )
+{
+ if( m_rSplashScreen.is() )
+ {
+ m_rSplashScreen->setText( rText );
+ }
+}
+
void Desktop::CloseSplashScreen()
{
if(m_rSplashScreen.is())
diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx
index 8b73e0c2c525..664e63c7f6ca 100644..100755
--- a/desktop/source/app/check_ext_deps.cxx
+++ b/desktop/source/app/check_ext_deps.cxx
@@ -27,35 +27,202 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_desktop.hxx"
+#include "osl/file.hxx"
+#include "osl/mutex.hxx"
+
#include <rtl/bootstrap.hxx>
#include <rtl/ustring.hxx>
+#include <rtl/logfile.hxx>
+#include "cppuhelper/compbase3.hxx"
+
+#include "vcl/wrkwin.hxx"
+#include "vcl/timer.hxx"
+
#include <unotools/configmgr.hxx>
+#include "toolkit/helper/vclunohelper.hxx"
#include <comphelper/processfactory.hxx>
#include <comphelper/sequence.hxx>
#include <cppuhelper/bootstrap.hxx>
-
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include "com/sun/star/deployment/XPackage.hpp"
-#include "com/sun/star/deployment/XPackageManager.hpp"
-#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
+#include "com/sun/star/deployment/ExtensionManager.hpp"
+#include "com/sun/star/deployment/LicenseException.hpp"
+#include "com/sun/star/deployment/ui/LicenseDialog.hpp"
#include <com/sun/star/task/XJob.hpp>
#include <com/sun/star/task/XJobExecutor.hpp>
+#include <com/sun/star/task/XInteractionApprove.hpp>
+#include <com/sun/star/task/XInteractionAbort.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp"
#include <com/sun/star/util/XChangesBatch.hpp>
#include "app.hxx"
+#include "../deployment/inc/dp_misc.h"
+
using rtl::OUString;
using namespace desktop;
using namespace com::sun::star;
-#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+#define UNISTRING(s) OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+namespace
+{
+//For use with XExtensionManager.synchronize
+class SilentCommandEnv
+ : public ::cppu::WeakImplHelper3< ucb::XCommandEnvironment,
+ task::XInteractionHandler,
+ ucb::XProgressHandler >
+{
+ Desktop *mpDesktop;
+ sal_Int32 mnLevel;
+ sal_Int32 mnProgress;
+
+public:
+ SilentCommandEnv( Desktop* pDesktop );
+ virtual ~SilentCommandEnv();
+
+ // XCommandEnvironment
+ virtual uno::Reference<task::XInteractionHandler > SAL_CALL
+ getInteractionHandler() throw (uno::RuntimeException);
+ virtual uno::Reference<ucb::XProgressHandler >
+ SAL_CALL getProgressHandler() throw (uno::RuntimeException);
+
+ // XInteractionHandler
+ virtual void SAL_CALL handle(
+ uno::Reference<task::XInteractionRequest > const & xRequest )
+ throw (uno::RuntimeException);
+
+ // XProgressHandler
+ virtual void SAL_CALL push( uno::Any const & Status )
+ throw (uno::RuntimeException);
+ virtual void SAL_CALL update( uno::Any const & Status )
+ throw (uno::RuntimeException);
+ virtual void SAL_CALL pop() throw (uno::RuntimeException);
+};
+
+//-----------------------------------------------------------------------------
+SilentCommandEnv::SilentCommandEnv( Desktop* pDesktop )
+{
+ mpDesktop = pDesktop;
+ mnLevel = 0;
+ mnProgress = 25;
+}
+
+//-----------------------------------------------------------------------------
+SilentCommandEnv::~SilentCommandEnv()
+{
+ mpDesktop->SetSplashScreenText( OUString() );
+}
+
+//-----------------------------------------------------------------------------
+Reference<task::XInteractionHandler> SilentCommandEnv::getInteractionHandler()
+ throw (uno::RuntimeException)
+{
+ return this;
+}
+
+//-----------------------------------------------------------------------------
+Reference<ucb::XProgressHandler> SilentCommandEnv::getProgressHandler()
+ throw (uno::RuntimeException)
+{
+ return this;
+}
+//-----------------------------------------------------------------------------
+// XInteractionHandler
+void SilentCommandEnv::handle( Reference< task::XInteractionRequest> const & xRequest )
+ throw (uno::RuntimeException)
+{
+ deployment::LicenseException licExc;
+
+ uno::Any request( xRequest->getRequest() );
+ bool bApprove = true;
+
+ if ( request >>= licExc )
+ {
+ uno::Reference< uno::XComponentContext > xContext = comphelper_getProcessComponentContext();
+ uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
+ deployment::ui::LicenseDialog::create(
+ xContext, VCLUnoHelper::GetInterface( NULL ),
+ licExc.ExtensionName, licExc.Text ) );
+ sal_Int16 res = xDialog->execute();
+ if ( res == ui::dialogs::ExecutableDialogResults::CANCEL )
+ bApprove = false;
+ else if ( res == ui::dialogs::ExecutableDialogResults::OK )
+ bApprove = true;
+ else
+ {
+ OSL_ASSERT(0);
+ }
+ }
+
+ // We approve everything here
+ 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 ( bApprove )
+ {
+ uno::Reference< task::XInteractionApprove > xInteractionApprove( pConts[ pos ], uno::UNO_QUERY );
+ if ( xInteractionApprove.is() )
+ xInteractionApprove->select();
+ }
+ else
+ {
+ uno::Reference< task::XInteractionAbort > xInteractionAbort( pConts[ pos ], uno::UNO_QUERY );
+ if ( xInteractionAbort.is() )
+ xInteractionAbort->select();
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+// XProgressHandler
+void SilentCommandEnv::push( uno::Any const & rStatus )
+ throw (uno::RuntimeException)
+{
+ OUString sText;
+ mnLevel += 1;
+
+ if ( rStatus.hasValue() && ( rStatus >>= sText) )
+ {
+ if ( mnLevel <= 3 )
+ mpDesktop->SetSplashScreenText( sText );
+ else
+ mpDesktop->SetSplashScreenProgress( ++mnProgress );
+ }
+}
+
+//-----------------------------------------------------------------------------
+void SilentCommandEnv::update( uno::Any const & rStatus )
+ throw (uno::RuntimeException)
+{
+ OUString sText;
+ if ( rStatus.hasValue() && ( rStatus >>= sText) )
+ {
+ mpDesktop->SetSplashScreenText( sText );
+ }
+}
+
+//-----------------------------------------------------------------------------
+void SilentCommandEnv::pop() throw (uno::RuntimeException)
+{
+ mnLevel -= 1;
+}
+
+} // end namespace
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
static const OUString sConfigSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) );
static const OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) );
-
//------------------------------------------------------------------------------
static sal_Int16 impl_showExtensionDialog( uno::Reference< uno::XComponentContext > &xContext )
{
@@ -79,55 +246,75 @@ static sal_Int16 impl_showExtensionDialog( uno::Reference< uno::XComponentContex
//------------------------------------------------------------------------------
// Check dependencies of all packages
//------------------------------------------------------------------------------
-static bool impl_checkDependencies( const uno::Reference< deployment::XPackageManager > &xPackageManager )
+static bool impl_checkDependencies( const uno::Reference< uno::XComponentContext > &xContext )
{
- uno::Sequence< uno::Reference< deployment::XPackage > > packages;
+ uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages;
+ uno::Reference< deployment::XExtensionManager > xExtensionManager = deployment::ExtensionManager::get( xContext );
+
+ if ( !xExtensionManager.is() )
+ {
+ OSL_ENSURE( 0, "Could not get the Extension Manager!" );
+ return true;
+ }
try {
- packages = xPackageManager->getDeployedPackages( uno::Reference< task::XAbortChannel >(),
- uno::Reference< ucb::XCommandEnvironment >() );
+ xAllPackages = xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(),
+ uno::Reference< ucb::XCommandEnvironment >() );
}
- catch ( deployment::DeploymentException & ) { /* handleGeneralError(e.Cause);*/ }
- catch ( ucb::CommandFailedException & ) { /* handleGeneralError(e.Reason);*/ }
- catch ( ucb::CommandAbortedException & ) {}
+ catch ( deployment::DeploymentException & ) { return true; }
+ catch ( ucb::CommandFailedException & ) { return true; }
+ catch ( ucb::CommandAbortedException & ) { return true; }
catch ( lang::IllegalArgumentException & e ) {
throw uno::RuntimeException( e.Message, e.Context );
}
- for ( sal_Int32 i = 0; i < packages.getLength(); ++i )
+ sal_Int32 nMax = 2;
+#ifdef DEBUG
+ nMax = 3;
+#endif
+
+ for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i )
{
- bool bRegistered = false;
- try {
- beans::Optional< beans::Ambiguous< sal_Bool > > option( packages[i]->isRegistered( uno::Reference< task::XAbortChannel >(),
- uno::Reference< ucb::XCommandEnvironment >() ) );
- if ( option.IsPresent )
- {
- ::beans::Ambiguous< sal_Bool > const & reg = option.Value;
- if ( reg.IsAmbiguous )
- bRegistered = false;
- else
- bRegistered = reg.Value ? true : false;
- }
- else
- bRegistered = false;
- }
- catch ( uno::RuntimeException & ) { throw; }
- catch ( uno::Exception & exc) {
- (void) exc;
- OSL_ENSURE( 0, ::rtl::OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
- bRegistered = false;
- }
+ uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i];
- if ( bRegistered )
+ for ( sal_Int32 j = 0; (j<nMax) && (j < xPackageList.getLength()); ++j )
{
- bool bDependenciesValid = false;
- try {
- bDependenciesValid = packages[i]->checkDependencies( uno::Reference< ucb::XCommandEnvironment >() );
- }
- catch ( deployment::DeploymentException & ) {}
- if ( ! bDependenciesValid )
+ uno::Reference< deployment::XPackage > xPackage = xPackageList[j];
+ if ( xPackage.is() )
{
- return false;
+ bool bRegistered = false;
+ try {
+ beans::Optional< beans::Ambiguous< sal_Bool > > option( xPackage->isRegistered( uno::Reference< task::XAbortChannel >(),
+ uno::Reference< ucb::XCommandEnvironment >() ) );
+ if ( option.IsPresent )
+ {
+ ::beans::Ambiguous< sal_Bool > const & reg = option.Value;
+ if ( reg.IsAmbiguous )
+ bRegistered = false;
+ else
+ bRegistered = reg.Value ? true : false;
+ }
+ else
+ bRegistered = false;
+ }
+ catch ( uno::RuntimeException & ) { throw; }
+ catch ( uno::Exception & exc) {
+ (void) exc;
+ OSL_ENSURE( 0, ::rtl::OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
+
+ if ( bRegistered )
+ {
+ bool bDependenciesValid = false;
+ try {
+ bDependenciesValid = xPackage->checkDependencies( uno::Reference< ucb::XCommandEnvironment >() );
+ }
+ catch ( deployment::DeploymentException & ) {}
+ if ( ! bDependenciesValid )
+ {
+ return false;
+ }
+ }
}
}
}
@@ -164,31 +351,11 @@ static void impl_setNeedsCompatCheck()
static bool impl_check()
{
uno::Reference< uno::XComponentContext > xContext = comphelper_getProcessComponentContext();
- uno::Reference< deployment::XPackageManager > xManager;
- bool bDependenciesValid = true;
-
- try {
- xManager = deployment::thePackageManagerFactory::get( xContext )->getPackageManager( UNISTRING("user") );
- }
- catch ( ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
- if ( xManager.is() )
- bDependenciesValid = impl_checkDependencies( xManager );
-
- if ( bDependenciesValid )
- {
- try {
- xManager = deployment::thePackageManagerFactory::get( xContext )->getPackageManager( UNISTRING("shared") );
- }
- catch ( ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- if ( xManager.is() )
- bDependenciesValid = impl_checkDependencies( xManager );
- }
+ bool bDependenciesValid = impl_checkDependencies( xContext );
short nRet = 0;
+
if ( !bDependenciesValid )
nRet = impl_showExtensionDialog( xContext );
@@ -202,7 +369,7 @@ static bool impl_check()
}
//------------------------------------------------------------------------------
-// to check, if we need checking the dependencies of the extensions again, we compare
+// to check if we need checking the dependencies of the extensions again, we compare
// the build id of the office with the one of the last check
//------------------------------------------------------------------------------
static bool impl_needsCompatCheck()
@@ -235,6 +402,9 @@ static bool impl_needsCompatCheck()
pset->setPropertyValue( OUString::createFromAscii("LastCompatibilityCheckID"), result );
Reference< util::XChangesBatch >( pset, UNO_QUERY_THROW )->commitChanges();
}
+#ifdef DEBUG
+ bNeedsCheck = true;
+#endif
}
catch (const Exception&) {}
@@ -254,3 +424,8 @@ sal_Bool Desktop::CheckExtensionDependencies()
return bAbort;
}
+void Desktop::SynchronizeExtensionRepositories()
+{
+ RTL_LOGFILE_CONTEXT(aLog,"desktop (jl) ::Desktop::SynchronizeExtensionRepositories");
+ dp_misc::syncRepositories( new SilentCommandEnv( this ) );
+}
diff --git a/desktop/source/app/makefile.mk b/desktop/source/app/makefile.mk
index d9db7c163481..085d8520e7ad 100644
--- a/desktop/source/app/makefile.mk
+++ b/desktop/source/app/makefile.mk
@@ -35,11 +35,24 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.INCLUDE : ../deployment/inc/dp_misc.mk
.IF "$(ENABLE_GNOMEVFS)"=="TRUE"
CFLAGS+=-DGNOME_VFS_ENABLED
.ENDIF
+# .IF "$(OS)" == "WNT"
+# .IF "$(COM)" == "GCC"
+# DEPLOYMENTMISCLIB = -ldeploymentmisc$(DLLPOSTFIX)
+# .ELSE
+# DEPLOYMENTMISCLIB = ideploymentmisc$(DLLPOSTFIX).lib
+# .ENDIF
+# .ELIF "$(OS)" == "OS2"
+# DEPLOYMENTMISCLIB = ideploymentmisc$(DLLPOSTFIX).lib
+# .ELSE
+# DEPLOYMENTMISCLIB = -ldeploymentmisc$(DLLPOSTFIX)
+# .ENDIF
+
SHL1TARGET = sofficeapp
SHL1OBJS = \
$(SLO)$/app.obj \
@@ -67,6 +80,7 @@ SHL1STDLIBS = \
$(COMPHELPERLIB) \
$(CPPUHELPERLIB) \
$(CPPULIB) \
+ $(DEPLOYMENTMISCLIB) \
$(I18NISOLANGLIB) \
$(SALLIB) \
$(SFXLIB) \
diff --git a/desktop/source/deployment/dp_services.cxx b/desktop/source/deployment/dp_services.cxx
index c83a62bfd17e..f7ebf66355ba 100644
--- a/desktop/source/deployment/dp_services.cxx
+++ b/desktop/source/deployment/dp_services.cxx
@@ -28,7 +28,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_desktop.hxx"
-#define COMPHELPER_SERVICEDECL_COMPONENT_HELPER_MAX_ARGS 11
+#define COMPHELPER_SERVICEDECL_COMPONENT_HELPER_MAX_ARGS 12
#include "comphelper/servicedecl.hxx"
using namespace com::sun::star;
@@ -69,13 +69,11 @@ namespace factory {
extern sdecl::ServiceDecl const serviceDecl;
bool singleton_entries( uno::Reference<registry::XRegistryKey> const& );
}
-}
-
-namespace dp_log {
extern sdecl::ServiceDecl const serviceDecl;
+bool singleton_entries( uno::Reference<registry::XRegistryKey> const& );
}
-namespace dp_migration {
+namespace dp_log {
extern sdecl::ServiceDecl const serviceDecl;
}
@@ -108,10 +106,11 @@ sal_Bool SAL_CALL component_writeInfo(
dp_registry::backend::executable::serviceDecl,
dp_manager::factory::serviceDecl,
dp_log::serviceDecl,
- dp_migration::serviceDecl,
- dp_info::serviceDecl ) &&
+ dp_info::serviceDecl,
+ dp_manager::serviceDecl) &&
dp_manager::factory::singleton_entries( pRegistryKey ) &&
- dp_info::singleton_entries( pRegistryKey );
+ dp_info::singleton_entries( pRegistryKey ) &&
+ dp_manager::singleton_entries( pRegistryKey);
}
void * SAL_CALL component_getFactory(
@@ -129,8 +128,8 @@ void * SAL_CALL component_getFactory(
dp_registry::backend::executable::serviceDecl,
dp_manager::factory::serviceDecl,
dp_log::serviceDecl,
- dp_migration::serviceDecl,
- dp_info::serviceDecl );
+ dp_info::serviceDecl,
+ dp_manager::serviceDecl);
}
} // extern "C"
diff --git a/desktop/source/deployment/gui/dp_gui.h b/desktop/source/deployment/gui/dp_gui.h
index 85e6eaef3544..092b232ce96d 100644
--- a/desktop/source/deployment/gui/dp_gui.h
+++ b/desktop/source/deployment/gui/dp_gui.h
@@ -79,21 +79,18 @@ enum PackageState { REGISTERED, NOT_REGISTERED, AMBIGUOUS, NOT_AVAILABLE };
class SelectedPackage: public salhelper::SimpleReferenceObject {
public:
SelectedPackage() {}
- SelectedPackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> &xPackage,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> &xPackageManager )
- : m_xPackage( xPackage ),
- m_xPackageManager( xPackageManager )
+ SelectedPackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> &xPackage)
+ : m_xPackage( xPackage )
{}
virtual ~SelectedPackage();
::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> getPackage() const { return m_xPackage; }
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> getPackageManager() const { return m_xPackageManager; }
+
private:
SelectedPackage(SelectedPackage &); // not defined
void operator =(SelectedPackage &); // not defined
::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage;
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> m_xPackageManager;
};
} // namespace dp_gui
diff --git a/desktop/source/deployment/gui/dp_gui.hrc b/desktop/source/deployment/gui/dp_gui.hrc
index 1d2f4869cc7f..5f52b042edf3 100644..100755
--- a/desktop/source/deployment/gui/dp_gui.hrc
+++ b/desktop/source/deployment/gui/dp_gui.hrc
@@ -153,6 +153,7 @@
#define RID_STR_REMOVING_PACKAGES (RID_DEPLOYMENT_GUI_START+86)
#define RID_STR_ENABLING_PACKAGES (RID_DEPLOYMENT_GUI_START+87)
#define RID_STR_DISABLING_PACKAGES (RID_DEPLOYMENT_GUI_START+88)
+#define RID_STR_ACCEPT_LICENSE (RID_DEPLOYMENT_GUI_START+89)
#define RID_STR_INSTALL_FOR_ALL (RID_DEPLOYMENT_GUI_START+90)
#define RID_STR_INSTALL_FOR_ME (RID_DEPLOYMENT_GUI_START+91)
@@ -161,6 +162,7 @@
#define RID_STR_EXIT_BTN (RID_DEPLOYMENT_GUI_START+94)
#define RID_STR_NO_ADMIN_PRIVILEGE (RID_DEPLOYMENT_GUI_START+95)
#define RID_STR_ERROR_MISSING_DEPENDENCIES (RID_DEPLOYMENT_GUI_START+96)
+#define RID_STR_ERROR_MISSING_LICENSE (RID_DEPLOYMENT_GUI_START+97)
#define WARNINGBOX_CONCURRENTINSTANCE (RID_DEPLOYMENT_GUI_START+100)
@@ -172,7 +174,6 @@
#define RID_WARNINGBOX_DISABLE_SHARED_EXTENSION (RID_DEPLOYMENT_GUI_START+106)
#define RID_DLG_LICENSE RID_DEPLOYMENT_LICENSE_START
-#define WARNINGBOX_NOSHAREDALLOWED (RID_DEPLOYMENT_LICENSE_START+1)
diff --git a/desktop/source/deployment/gui/dp_gui_dialog.src b/desktop/source/deployment/gui/dp_gui_dialog.src
index 79c0c5172030..15823288ee20 100644..100755
--- a/desktop/source/deployment/gui/dp_gui_dialog.src
+++ b/desktop/source/deployment/gui/dp_gui_dialog.src
@@ -72,6 +72,11 @@ String RID_STR_DISABLING_PACKAGES
Text [ en-US ] = "Disabling %EXTENSION_NAME";
};
+String RID_STR_ACCEPT_LICENSE
+{
+ Text [ en-US ] = "Accept license for %EXTENSION_NAME";
+};
+
String RID_STR_INSTALL_FOR_ALL
{
Text [ en-US ] = "~For all users";
@@ -109,6 +114,11 @@ String RID_STR_ERROR_MISSING_DEPENDENCIES
Text [ en-US ] = "The extension cannot be enabled as the following system dependencies are not fulfilled:";
};
+String RID_STR_ERROR_MISSING_LICENSE
+{
+ Text [ en-US ] = "This extension is disabled because you haven't accepted the license yet.\n";
+};
+
// Dialog layout
// ---------------------------------------------------
// row 1 | multi line edit
@@ -131,7 +141,7 @@ String RID_STR_ERROR_MISSING_DEPENDENCIES
#define ROW1_Y RSC_SP_DLG_INNERBORDER_TOP
#define ROW1_HEIGHT 16*RSC_CD_FIXEDTEXT_HEIGHT
#define ROW2_Y ROW1_Y+ROW1_HEIGHT+RSC_SP_CTRL_GROUP_Y
-#define ROW2_HEIGHT 2*RSC_CD_FIXEDTEXT_HEIGHT
+#define ROW2_HEIGHT 3*RSC_CD_FIXEDTEXT_HEIGHT
#define ROW3_Y ROW2_Y+ROW2_HEIGHT+RSC_SP_CTRL_GROUP_Y
#define ROW3_HEIGHT 3*RSC_CD_FIXEDTEXT_HEIGHT
#define ROW4_Y ROW3_Y+ROW3_HEIGHT+RSC_SP_CTRL_GROUP_Y
@@ -282,14 +292,6 @@ ModalDialog RID_DLG_LICENSE
-WarningBox WARNINGBOX_NOSHAREDALLOWED
-{
- Buttons = WB_OK ;
- DefButton = WB_DEF_OK;
- Message[ en-US ] ="The extension \'%NAME\' cannot be installed under \"%PRODUCTNAME Extensions\", because "
- "every user has to agree to the license agreement of the extension. The extension will not be installed.";
-};
-
WarningBox RID_WARNINGBOX_INSTALL_EXTENSION {
Buttons = WB_OK_CANCEL;
DefButton = WB_DEF_OK;
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index 71fda4d9b3e0..1a66ff38e4a4 100644..100755
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -37,7 +37,10 @@
#include "dp_gui_extlistbox.hxx"
#include "dp_gui_shared.hxx"
#include "dp_gui_theextmgr.hxx"
+#include "dp_gui_extensioncmdqueue.hxx"
#include "dp_misc.h"
+#include "dp_update.hxx"
+#include "dp_identifier.hxx"
#include "vcl/ctrl.hxx"
#include "vcl/menu.hxx"
@@ -74,8 +77,6 @@
#include "com/sun/star/uno/Any.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
-#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
-
#include <map>
#include <vector>
#include <boost/shared_ptr.hpp>
@@ -108,17 +109,6 @@ struct StrAllFiles : public rtl::StaticWithInit< const OUString, StrAllFiles >
};
//------------------------------------------------------------------------------
-UpdateListEntry::UpdateListEntry( const uno::Reference< deployment::XPackage > &xPackage,
- const uno::Reference< deployment::XPackageManager > &xPackageManager ) :
- m_xPackage( xPackage ),
- m_xPackageManager( xPackageManager )
-{}
-
-//------------------------------------------------------------------------------
-UpdateListEntry::~UpdateListEntry()
-{}
-
-//------------------------------------------------------------------------------
// ExtBoxWithBtns_Impl
//------------------------------------------------------------------------------
@@ -279,6 +269,9 @@ void ExtBoxWithBtns_Impl::SetButtonPos( const Rectangle& rRect )
// -----------------------------------------------------------------------
void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry )
{
+ bool bShowOptionBtn = true;
+
+ pEntry->m_bHasButtons = false;
if ( ( pEntry->m_eState == REGISTERED ) || ( pEntry->m_eState == NOT_AVAILABLE ) )
{
m_pEnableBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_DISABLE ) );
@@ -288,26 +281,36 @@ void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry )
{
m_pEnableBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_ENABLE ) );
m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_ENABLE );
+ bShowOptionBtn = false;
}
- if ( ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps )
+ if ( ( !pEntry->m_bUser || ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps )
+ && !pEntry->m_bMissingLic )
m_pEnableBtn->Hide();
else
{
m_pEnableBtn->Enable( !pEntry->m_bLocked );
m_pEnableBtn->Show();
+ pEntry->m_bHasButtons = true;
}
- if ( pEntry->m_bHasOptions )
+ if ( pEntry->m_bHasOptions && bShowOptionBtn )
{
m_pOptionsBtn->Enable( pEntry->m_bHasOptions );
m_pOptionsBtn->Show();
+ pEntry->m_bHasButtons = true;
}
else
m_pOptionsBtn->Hide();
- m_pRemoveBtn->Show();
- m_pRemoveBtn->Enable( !pEntry->m_bLocked );
+ if ( pEntry->m_bUser || pEntry->m_bShared )
+ {
+ m_pRemoveBtn->Enable( !pEntry->m_bLocked );
+ m_pRemoveBtn->Show();
+ pEntry->m_bHasButtons = true;
+ }
+ else
+ m_pRemoveBtn->Hide();
}
// -----------------------------------------------------------------------
@@ -394,17 +397,13 @@ void ExtBoxWithBtns_Impl::MouseButtonDown( const MouseEvent& rMEvt )
switch( ShowPopupMenu( aMousePos, nPos ) )
{
case CMD_NONE: break;
- case CMD_ENABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackageManager,
- GetEntryData( nPos )->m_xPackage, true );
+ case CMD_ENABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, true );
break;
- case CMD_DISABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackageManager,
- GetEntryData( nPos )->m_xPackage, false );
+ case CMD_DISABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, false );
break;
- case CMD_UPDATE: m_pParent->updatePackage( GetEntryData( nPos )->m_xPackageManager,
- GetEntryData( nPos )->m_xPackage );
+ case CMD_UPDATE: m_pParent->updatePackage( GetEntryData( nPos )->m_xPackage );
break;
- case CMD_REMOVE: m_pParent->removePackage( GetEntryData( nPos )->m_xPackageManager,
- GetEntryData( nPos )->m_xPackage );
+ case CMD_REMOVE: m_pParent->removePackage( GetEntryData( nPos )->m_xPackage );
break;
}
}
@@ -506,11 +505,14 @@ IMPL_LINK( ExtBoxWithBtns_Impl, HandleEnableBtn, void*, EMPTYARG )
if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND )
{
TEntry_Impl pEntry = GetEntryData( nActive );
- const bool bEnable( pEntry->m_eState != REGISTERED );
- m_pParent->enablePackage( pEntry->m_xPackageManager,
- pEntry->m_xPackage,
- bEnable );
+ if ( pEntry->m_bMissingLic )
+ m_pParent->acceptLicense( pEntry->m_xPackage );
+ else
+ {
+ const bool bEnable( pEntry->m_eState != REGISTERED );
+ m_pParent->enablePackage( pEntry->m_xPackage, bEnable );
+ }
}
return 1;
@@ -524,8 +526,7 @@ IMPL_LINK( ExtBoxWithBtns_Impl, HandleRemoveBtn, void*, EMPTYARG )
if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND )
{
TEntry_Impl pEntry = GetEntryData( nActive );
- m_pParent->removePackage( pEntry->m_xPackageManager,
- pEntry->m_xPackage );
+ m_pParent->removePackage( pEntry->m_xPackage );
}
return 1;
@@ -571,21 +572,21 @@ String DialogHelper::getResourceString( USHORT id )
}
//------------------------------------------------------------------------------
-bool DialogHelper::IsSharedPkgMgr( const uno::Reference< deployment::XPackageManager > &xPackageManager )
+bool DialogHelper::IsSharedPkgMgr( const uno::Reference< deployment::XPackage > &xPackage )
{
- if ( xPackageManager->getContext().equals( OUSTR("shared") ) )
+ if ( xPackage->getRepositoryName().equals( OUSTR("shared") ) )
return true;
else
return false;
}
//------------------------------------------------------------------------------
-bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::XPackageManager > &xPackageManager,
+bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::XPackage > &xPackage,
Window *pParent,
const USHORT nResID,
bool &bHadWarning )
{
- if ( !bHadWarning && IsSharedPkgMgr( xPackageManager ) )
+ if ( !bHadWarning && IsSharedPkgMgr( xPackage ) )
{
const ::vos::OGuard guard( Application::GetSolarMutex() );
WarningBox aInfoBox( pParent, getResId( nResID ) );
@@ -759,17 +760,16 @@ void ExtMgrDialog::setGetExtensionsURL( const ::rtl::OUString &rURL )
//------------------------------------------------------------------------------
long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage,
- const uno::Reference< deployment::XPackageManager > &xPackageManager )
+ bool bLicenseMissing )
{
m_aUpdateBtn.Enable( true );
- return m_pExtensionBox->addEntry( xPackage, xPackageManager );
+ return m_pExtensionBox->addEntry( xPackage, bLicenseMissing );
}
//------------------------------------------------------------------------------
-void ExtMgrDialog::prepareChecking( const uno::Reference< deployment::XPackageManager > &xPackageManager )
+void ExtMgrDialog::prepareChecking()
{
- if ( xPackageManager.is() )
- m_pExtensionBox->prepareChecking( xPackageManager );
+ m_pExtensionBox->prepareChecking();
}
//------------------------------------------------------------------------------
@@ -793,68 +793,82 @@ bool ExtMgrDialog::removeExtensionWarn( const OUString &rExtensionName ) const
}
//------------------------------------------------------------------------------
-bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager,
- const uno::Reference< deployment::XPackage > &xPackage,
+bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage,
bool bEnable )
{
- if ( !xPackageManager.is() || !xPackage.is() )
+ if ( !xPackage.is() )
return false;
if ( bEnable )
{
- if ( ! continueOnSharedExtension( xPackageManager, this, RID_WARNINGBOX_ENABLE_SHARED_EXTENSION, m_bEnableWarning ) )
+ if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_ENABLE_SHARED_EXTENSION, m_bEnableWarning ) )
return false;
}
else
{
- if ( ! continueOnSharedExtension( xPackageManager, this, RID_WARNINGBOX_DISABLE_SHARED_EXTENSION, m_bDisableWarning ) )
+ if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_DISABLE_SHARED_EXTENSION, m_bDisableWarning ) )
return false;
}
- m_pManager->enablePackage( xPackage, bEnable );
+ m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable );
return true;
}
//------------------------------------------------------------------------------
-bool ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager,
- const uno::Reference< deployment::XPackage > &xPackage )
+bool ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackage > &xPackage )
{
- if ( !xPackageManager.is() || !xPackage.is() )
+ if ( !xPackage.is() )
return false;
- if ( !IsSharedPkgMgr( xPackageManager ) || m_bDeleteWarning )
+ if ( !IsSharedPkgMgr( xPackage ) || m_bDeleteWarning )
{
if ( ! removeExtensionWarn( xPackage->getDisplayName() ) )
return false;
}
- if ( ! continueOnSharedExtension( xPackageManager, this, RID_WARNINGBOX_REMOVE_SHARED_EXTENSION, m_bDeleteWarning ) )
+ if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_REMOVE_SHARED_EXTENSION, m_bDeleteWarning ) )
return false;
- m_pManager->removePackage( xPackageManager, xPackage );
+ m_pManager->getCmdQueue()->removeExtension( xPackage );
return true;
}
//------------------------------------------------------------------------------
-bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager,
- const uno::Reference< deployment::XPackage > &xPackage )
+bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > &xPackage )
{
- if ( !xPackageManager.is() || !xPackage.is() )
+ if ( !xPackage.is() )
return false;
- std::vector< TUpdateListEntry > vEntries;
- TUpdateListEntry pEntry( new UpdateListEntry( xPackage, xPackageManager ) );
- vEntries.push_back( pEntry );
+ // get the extension with highest version
+ uno::Sequence<uno::Reference<deployment::XPackage> > seqExtensions =
+ m_pManager->getExtensionManager()->getExtensionsWithSameIdentifier(
+ dp_misc::getIdentifier(xPackage), xPackage->getName(), uno::Reference<ucb::XCommandEnvironment>());
+ uno::Reference<deployment::XPackage> extension =
+ dp_misc::getExtensionWithHighestVersion(seqExtensions);
+ OSL_ASSERT(extension.is());
+ std::vector< css::uno::Reference< css::deployment::XPackage > > vEntries;
+ vEntries.push_back(extension);
- m_pManager->updatePackages( vEntries );
+ m_pManager->getCmdQueue()->checkForUpdates( vEntries );
return true;
}
//------------------------------------------------------------------------------
-uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker( const uno::Reference< deployment::XPackageManager > &xPackageManager )
+bool ExtMgrDialog::acceptLicense( const uno::Reference< deployment::XPackage > &xPackage )
+{
+ if ( !xPackage.is() )
+ return false;
+
+ m_pManager->getCmdQueue()->acceptLicense( xPackage );
+
+ return true;
+}
+
+//------------------------------------------------------------------------------
+uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker()
{
const uno::Any mode( static_cast< sal_Int16 >( ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE ) );
const uno::Reference< uno::XComponentContext > xContext( m_pManager->getContext() );
@@ -872,7 +886,8 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker( const uno::Reference< de
t_string2string title2filter;
OUString sDefaultFilter( StrAllFiles::get() );
- const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( xPackageManager->getSupportedPackageTypes() );
+ const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes(
+ m_pManager->getExtensionManager()->getSupportedPackageTypes() );
for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos )
{
@@ -1026,8 +1041,7 @@ IMPL_LINK( ExtMgrDialog, HandleAddBtn, void*, EMPTYARG )
{
setBusy( true );
- uno::Reference< deployment::XPackageManager > xUserPkgMgr = m_pManager->getUserPkgMgr();
- uno::Sequence< OUString > aFileList = raiseAddPicker( xUserPkgMgr );
+ uno::Sequence< OUString > aFileList = raiseAddPicker();
if ( aFileList.getLength() )
{
@@ -1298,23 +1312,22 @@ UpdateRequiredDialog::~UpdateRequiredDialog()
//------------------------------------------------------------------------------
long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage,
- const uno::Reference< deployment::XPackageManager > &xPackageManager )
+ bool bLicenseMissing )
{
// We will only add entries to the list with unsatisfied dependencies
- if ( !checkDependencies( xPackage ) )
+ if ( !bLicenseMissing && !checkDependencies( xPackage ) )
{
- m_bHasLockedEntries |= (bool) xPackageManager->isReadOnly();
+ m_bHasLockedEntries |= m_pManager->isReadOnly( xPackage );
m_aUpdateBtn.Enable( true );
- return m_pExtensionBox->addEntry( xPackage, xPackageManager );
+ return m_pExtensionBox->addEntry( xPackage );
}
return 0;
}
//------------------------------------------------------------------------------
-void UpdateRequiredDialog::prepareChecking( const uno::Reference< deployment::XPackageManager > &xPackageManager )
+void UpdateRequiredDialog::prepareChecking()
{
- if ( xPackageManager.is() )
- m_pExtensionBox->prepareChecking( xPackageManager );
+ m_pExtensionBox->prepareChecking();
}
//------------------------------------------------------------------------------
@@ -1331,11 +1344,10 @@ void UpdateRequiredDialog::checkEntries()
}
//------------------------------------------------------------------------------
-bool UpdateRequiredDialog::enablePackage( const uno::Reference< deployment::XPackageManager > &,
- const uno::Reference< deployment::XPackage > &xPackage,
- bool bEnable )
+bool UpdateRequiredDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage,
+ bool bEnable )
{
- m_pManager->enablePackage( xPackage, bEnable );
+ m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable );
return true;
}
@@ -1451,20 +1463,18 @@ IMPL_LINK( UpdateRequiredDialog, HandleUpdateBtn, void*, EMPTYARG )
{
::osl::ClearableMutexGuard aGuard( m_aMutex );
- std::vector< TUpdateListEntry > vUpdateEntries;
+ std::vector< uno::Reference< deployment::XPackage > > vUpdateEntries;
sal_Int32 nCount = m_pExtensionBox->GetEntryCount();
for ( sal_Int32 i = 0; i < nCount; ++i )
{
TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( i );
- TUpdateListEntry pUpdateEntry( new UpdateListEntry( pEntry->m_xPackage,
- pEntry->m_xPackageManager ) );
- vUpdateEntries.push_back( pUpdateEntry );
+ vUpdateEntries.push_back( pEntry->m_xPackage );
}
aGuard.clear();
- m_pManager->updatePackages( vUpdateEntries );
+ m_pManager->getCmdQueue()->checkForUpdates( vUpdateEntries );
return 1;
}
@@ -1719,7 +1729,7 @@ void UpdateRequiredDialog::disableAllEntries()
for ( long nIndex = 0; nIndex < nCount; nIndex++ )
{
TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( nIndex );
- enablePackage( pEntry->m_xPackageManager, pEntry->m_xPackage, false );
+ enablePackage( pEntry->m_xPackage, false );
}
setBusy( false );
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx
index d5e939ace8a9..f0a85cce98c0 100644..100755
--- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx
@@ -46,7 +46,6 @@
#include "com/sun/star/awt/XWindow.hpp"
#include "com/sun/star/deployment/XPackage.hpp"
-#include "com/sun/star/deployment/XPackageManager.hpp"
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/ui/dialogs/XExecutableDialog.hpp"
#include "com/sun/star/util/XModifyListener.hpp"
@@ -82,16 +81,16 @@ public:
virtual void updateProgress( const long nProgress ) = 0;
virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0;
- virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & ) = 0;
+ virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
+ bool bLicenseMissing = false ) = 0;
- virtual void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ) = 0;
+ virtual void prepareChecking() = 0;
virtual void checkEntries() = 0;
static ResId getResId( USHORT nId );
static String getResourceString( USHORT id );
- static bool IsSharedPkgMgr( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &);
- static bool continueOnSharedExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &,
+ static bool IsSharedPkgMgr( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &);
+ static bool continueOnSharedExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
Window *pParent,
const USHORT nResID,
bool &bHadWarning );
@@ -160,19 +159,17 @@ public:
void setGetExtensionsURL( const ::rtl::OUString &rURL );
virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & );
- bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
+ bool bLicenseMissing = false );
+ bool enablePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
bool bEnable );
- bool removePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
- bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
+ bool removePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
+ bool updatePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
+ bool acceptLicense(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
- virtual void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager );
+ virtual void prepareChecking();
virtual void checkEntries();
- ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager );
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker();
};
//==============================================================================
@@ -235,17 +232,14 @@ public:
void selectEntry( long nPos );
virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & );
- bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
- bool bEnable );
- bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
+ bool bLicenseMissing = false );
+ bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable );
+ bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
- virtual void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager );
+ virtual void prepareChecking();
virtual void checkEntries();
- ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager );
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker();
bool installForAllUsers( bool &bInstallForAll ) const;
bool installExtensionWarn( const ::rtl::OUString &rExtensionURL ) const;
diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
index 58a5ab1c19ea..8bd8a6191201 100644..100755
--- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
@@ -36,10 +36,10 @@
#include <cstddef>
#include "com/sun/star/beans/PropertyValue.hpp"
+#include "com/sun/star/beans/NamedValue.hpp"
#include "com/sun/star/deployment/DependencyException.hpp"
#include "com/sun/star/deployment/LicenseException.hpp"
-#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp"
#include "com/sun/star/deployment/VersionException.hpp"
#include "com/sun/star/deployment/InstallException.hpp"
#include "com/sun/star/deployment/PlatformException.hpp"
@@ -48,7 +48,6 @@
#include "com/sun/star/deployment/DeploymentException.hpp"
#include "com/sun/star/deployment/UpdateInformationProvider.hpp"
#include "com/sun/star/deployment/XPackage.hpp"
-#include "com/sun/star/deployment/XPackageManager.hpp"
#include "com/sun/star/task/XAbortChannel.hpp"
#include "com/sun/star/task/XInteractionAbort.hpp"
@@ -77,6 +76,7 @@
#include "comphelper/anytostring.hxx"
#include "vcl/msgbox.hxx"
#include "toolkit/helper/vclunohelper.hxx"
+#include "comphelper/processfactory.hxx"
#include "dp_gui.h"
#include "dp_gui_thread.hxx"
@@ -110,12 +110,15 @@ using ::rtl::OUString;
namespace {
-OUString getVersion( const uno::Reference< deployment::XPackage > &rPackage )
+OUString getVersion( OUString const & sVersion )
{
- OUString sVersion( rPackage->getVersion());
return ( sVersion.getLength() == 0 ) ? OUString( RTL_CONSTASCII_USTRINGPARAM( "0" ) ) : sVersion;
}
+OUString getVersion( const uno::Reference< deployment::XPackage > &rPackage )
+{
+ return getVersion( rPackage->getVersion());
+}
}
@@ -193,37 +196,30 @@ public:
//------------------------------------------------------------------------------
struct ExtensionCmd
{
- enum E_CMD_TYPE { ADD, ENABLE, DISABLE, REMOVE, CHECK_FOR_UPDATES };
+ enum E_CMD_TYPE { ADD, ENABLE, DISABLE, REMOVE, CHECK_FOR_UPDATES, ACCEPT_LICENSE };
E_CMD_TYPE m_eCmdType;
bool m_bWarnUser;
OUString m_sExtensionURL;
- uno::Reference< deployment::XPackageManager > m_xPackageManager;
- uno::Reference< deployment::XPackage > m_xPackage;
- std::vector< TUpdateListEntry > m_vExtensionList;
+ OUString m_sRepository;
+ uno::Reference< deployment::XPackage > m_xPackage;
+ std::vector< uno::Reference< deployment::XPackage > > m_vExtensionList;
ExtensionCmd( const E_CMD_TYPE eCommand,
- const uno::Reference< deployment::XPackageManager > &rPackageManager,
const OUString &rExtensionURL,
+ const OUString &rRepository,
const bool bWarnUser )
: m_eCmdType( eCommand ),
m_bWarnUser( bWarnUser ),
m_sExtensionURL( rExtensionURL ),
- m_xPackageManager( rPackageManager ) {};
+ m_sRepository( rRepository ) {};
ExtensionCmd( const E_CMD_TYPE eCommand,
- const uno::Reference< deployment::XPackageManager > &rPackageManager,
const uno::Reference< deployment::XPackage > &rPackage )
: m_eCmdType( eCommand ),
m_bWarnUser( false ),
- m_xPackageManager( rPackageManager ),
m_xPackage( rPackage ) {};
ExtensionCmd( const E_CMD_TYPE eCommand,
- const uno::Reference< deployment::XPackage > &rPackage )
- : m_eCmdType( eCommand ),
- m_bWarnUser( false ),
- m_xPackage( rPackage ) {};
- ExtensionCmd( const E_CMD_TYPE eCommand,
- const std::vector< TUpdateListEntry > &vExtensionList )
+ const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList )
: m_eCmdType( eCommand ),
m_bWarnUser( false ),
m_vExtensionList( vExtensionList ) {};
@@ -239,14 +235,14 @@ public:
TheExtensionManager *pManager,
const uno::Reference< uno::XComponentContext > & rContext );
- void addExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager,
- const OUString &rExtensionURL,
+ void addExtension( const OUString &rExtensionURL,
+ const OUString &rRepository,
const bool bWarnUser );
- void removeExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager,
- const uno::Reference< deployment::XPackage > &rPackage );
+ void removeExtension( const uno::Reference< deployment::XPackage > &rPackage );
void enableExtension( const uno::Reference< deployment::XPackage > &rPackage,
const bool bEnable );
- void checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList );
+ void checkForUpdates( const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList );
+ void acceptLicense( const uno::Reference< deployment::XPackage > &rPackage );
void stop();
bool isBusy();
@@ -263,17 +259,18 @@ private:
virtual void SAL_CALL onTerminated();
void _addExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv,
- const uno::Reference< deployment::XPackageManager > &xPackageManager,
const OUString &rPackageURL,
+ const OUString &rRepository,
const bool bWarnUser );
void _removeExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv,
- const uno::Reference< deployment::XPackageManager > &xPackageManager,
const uno::Reference< deployment::XPackage > &xPackage );
void _enableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv,
const uno::Reference< deployment::XPackage > &xPackage );
void _disableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv,
const uno::Reference< deployment::XPackage > &xPackage );
- void _checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList );
+ void _checkForUpdates( const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList );
+ void _acceptLicense( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv,
+ const uno::Reference< deployment::XPackage > &xPackage );
enum Input { NONE, START, STOP };
@@ -288,6 +285,7 @@ private:
const OUString m_sAddingPackages;
const OUString m_sRemovingPackages;
const OUString m_sDefaultCmd;
+ const OUString m_sAcceptLicense;
osl::Condition m_wakeup;
osl::Mutex m_mutex;
Input m_eInput;
@@ -376,7 +374,6 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const &
lang::WrappedTargetException wtExc;
deployment::DependencyException depExc;
deployment::LicenseException licExc;
- deployment::LicenseIndividualAgreementException licAgreementExc;
deployment::VersionException verExc;
deployment::InstallException instExc;
deployment::PlatformException platExc;
@@ -438,23 +435,12 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const &
|| (n == RET_CANCEL && !Application::IsDialogCancelEnabled());
}
}
- else if (request >>= licAgreementExc)
- {
- vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ResId warnId(WARNINGBOX_NOSHAREDALLOWED, *DeploymentGuiResMgr::get());
- WarningBox warn( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL, warnId);
- String msgText = warn.GetMessText();
- msgText.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() );
- msgText.SearchAndReplaceAllAscii("%NAME", licAgreementExc.ExtensionName);
- warn.SetMessText(msgText);
- warn.Execute();
- abort = true;
- }
else if (request >>= licExc)
{
uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
deployment::ui::LicenseDialog::create(
- m_xContext, VCLUnoHelper::GetInterface( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL ), licExc.Text ) );
+ m_xContext, VCLUnoHelper::GetInterface( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL ),
+ licExc.ExtensionName, licExc.Text ) );
sal_Int16 res = xDialog->execute();
if ( res == ui::dialogs::ExecutableDialogResults::CANCEL )
abort = true;
@@ -468,7 +454,8 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const &
else if (request >>= verExc)
{
sal_uInt32 id;
- switch (dp_misc::comparePackageVersions( verExc.New, verExc.Deployed ))
+ switch (dp_misc::compareVersions(
+ verExc.NewVersion, verExc.Deployed->getVersion() ))
{
case dp_misc::LESS:
id = RID_WARNINGBOX_VERSION_LESS;
@@ -480,8 +467,8 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const &
id = RID_WARNINGBOX_VERSION_GREATER;
break;
}
- OSL_ASSERT( verExc.New.is() && verExc.Deployed.is() );
- bool bEqualNames = verExc.New->getDisplayName().equals(
+ OSL_ASSERT( verExc.Deployed.is() );
+ bool bEqualNames = verExc.NewDisplayName.equals(
verExc.Deployed->getDisplayName());
{
vos::OGuard guard(Application::GetSolarMutex());
@@ -506,9 +493,9 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const &
{
s = String(ResId(RID_STR_WARNINGBOX_VERSION_GREATER_DIFFERENT_NAMES, *DeploymentGuiResMgr::get()));
}
- s.SearchAndReplaceAllAscii( "$NAME", verExc.New->getDisplayName());
+ s.SearchAndReplaceAllAscii( "$NAME", verExc.NewDisplayName);
s.SearchAndReplaceAllAscii( "$OLDNAME", verExc.Deployed->getDisplayName());
- s.SearchAndReplaceAllAscii( "$NEW", getVersion(verExc.New) );
+ s.SearchAndReplaceAllAscii( "$NEW", getVersion(verExc.NewVersion) );
s.SearchAndReplaceAllAscii( "$DEPLOYED", getVersion(verExc.Deployed) );
box.SetMessText(s);
approve = box.Execute() == RET_OK;
@@ -527,7 +514,7 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const &
{
vos::OGuard guard(Application::GetSolarMutex());
- approve = m_pDialogHelper->installExtensionWarn( instExc.New->getDisplayName() );
+ approve = m_pDialogHelper->installExtensionWarn( instExc.displayName );
}
else
approve = false;
@@ -644,6 +631,7 @@ ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper,
m_sAddingPackages( DialogHelper::getResourceString( RID_STR_ADDING_PACKAGES ) ),
m_sRemovingPackages( DialogHelper::getResourceString( RID_STR_REMOVING_PACKAGES ) ),
m_sDefaultCmd( DialogHelper::getResourceString( RID_STR_ADD_PACKAGES ) ),
+ m_sAcceptLicense( DialogHelper::getResourceString( RID_STR_ACCEPT_LICENSE ) ),
m_eInput( NONE ),
m_bTerminated( false ),
m_bStopped( false ),
@@ -653,8 +641,8 @@ ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper,
}
//------------------------------------------------------------------------------
-void ExtensionCmdQueue::Thread::addExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager,
- const ::rtl::OUString &rExtensionURL,
+void ExtensionCmdQueue::Thread::addExtension( const ::rtl::OUString &rExtensionURL,
+ const ::rtl::OUString &rRepository,
const bool bWarnUser )
{
::osl::MutexGuard aGuard( m_mutex );
@@ -665,7 +653,26 @@ void ExtensionCmdQueue::Thread::addExtension( const uno::Reference< deployment::
if ( rExtensionURL.getLength() )
{
- TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ADD, rPackageManager, rExtensionURL, bWarnUser ) );
+ TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ADD, rExtensionURL, rRepository, bWarnUser ) );
+
+ m_queue.push( pEntry );
+ m_eInput = START;
+ m_wakeup.set();
+ }
+}
+
+//------------------------------------------------------------------------------
+void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deployment::XPackage > &rPackage )
+{
+ ::osl::MutexGuard aGuard( m_mutex );
+
+ //If someone called stop then we do not remove the extension -> game over!
+ if ( m_bStopped )
+ return;
+
+ if ( rPackage.is() )
+ {
+ TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::REMOVE, rPackage ) );
m_queue.push( pEntry );
m_eInput = START;
@@ -674,8 +681,7 @@ void ExtensionCmdQueue::Thread::addExtension( const uno::Reference< deployment::
}
//------------------------------------------------------------------------------
-void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager,
- const uno::Reference< deployment::XPackage > &rPackage )
+void ExtensionCmdQueue::Thread::acceptLicense( const uno::Reference< deployment::XPackage > &rPackage )
{
::osl::MutexGuard aGuard( m_mutex );
@@ -683,9 +689,9 @@ void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deploymen
if ( m_bStopped )
return;
- if ( rPackageManager.is() && rPackage.is() )
+ if ( rPackage.is() )
{
- TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::REMOVE, rPackageManager, rPackage ) );
+ TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ACCEPT_LICENSE, rPackage ) );
m_queue.push( pEntry );
m_eInput = START;
@@ -715,7 +721,8 @@ void ExtensionCmdQueue::Thread::enableExtension( const uno::Reference< deploymen
}
//------------------------------------------------------------------------------
-void ExtensionCmdQueue::Thread::checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList )
+void ExtensionCmdQueue::Thread::checkForUpdates(
+ const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList )
{
::osl::MutexGuard aGuard( m_mutex );
@@ -819,10 +826,10 @@ void ExtensionCmdQueue::Thread::execute()
switch ( pEntry->m_eCmdType ) {
case ExtensionCmd::ADD :
- _addExtension( currentCmdEnv, pEntry->m_xPackageManager, pEntry->m_sExtensionURL, pEntry->m_bWarnUser );
+ _addExtension( currentCmdEnv, pEntry->m_sExtensionURL, pEntry->m_sRepository, pEntry->m_bWarnUser );
break;
case ExtensionCmd::REMOVE :
- _removeExtension( currentCmdEnv, pEntry->m_xPackageManager, pEntry->m_xPackage );
+ _removeExtension( currentCmdEnv, pEntry->m_xPackage );
break;
case ExtensionCmd::ENABLE :
_enableExtension( currentCmdEnv, pEntry->m_xPackage );
@@ -833,6 +840,9 @@ void ExtensionCmdQueue::Thread::execute()
case ExtensionCmd::CHECK_FOR_UPDATES :
_checkForUpdates( pEntry->m_vExtensionList );
break;
+ case ExtensionCmd::ACCEPT_LICENSE :
+ _acceptLicense( currentCmdEnv, pEntry->m_xPackage );
+ break;
}
}
//catch ( deployment::DeploymentException &)
@@ -912,8 +922,8 @@ void ExtensionCmdQueue::Thread::execute()
//------------------------------------------------------------------------------
void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv,
- const uno::Reference< deployment::XPackageManager > &xPackageManager,
const OUString &rPackageURL,
+ const OUString &rRepository,
const bool bWarnUser )
{
//check if we have a string in anyTitle. For example "unopkg gui \" caused anyTitle to be void
@@ -936,17 +946,16 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv
}
rCmdEnv->setWarnUser( bWarnUser );
- uno::Reference< task::XAbortChannel > xAbortChannel( xPackageManager->createAbortChannel() );
+ uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager();
+ uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() );
OUString sTitle = searchAndReplaceAll( m_sAddingPackages, OUSTR("%EXTENSION_NAME"), sName );
rCmdEnv->progressSection( sTitle, xAbortChannel );
try
{
- uno::Reference< deployment::XPackage > xPackage( xPackageManager->addPackage(
- rPackageURL, OUString() /* detect media-type */,
- xAbortChannel, rCmdEnv.get() ) );
- OSL_ASSERT( xPackage.is() );
- }
+ xExtMgr->addExtension(rPackageURL, uno::Sequence<beans::NamedValue>(),
+ rRepository, xAbortChannel, rCmdEnv.get() );
+ }
catch ( ucb::CommandFailedException & )
{
// When the extension is already installed we'll get a dialog asking if we want to overwrite. If we then press
@@ -962,18 +971,22 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv
//------------------------------------------------------------------------------
void ExtensionCmdQueue::Thread::_removeExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv,
- const uno::Reference< deployment::XPackageManager > &xPackageManager,
const uno::Reference< deployment::XPackage > &xPackage )
{
- uno::Reference< task::XAbortChannel > xAbortChannel( xPackageManager->createAbortChannel() );
+ uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager();
+ uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() );
OUString sTitle = searchAndReplaceAll( m_sRemovingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() );
rCmdEnv->progressSection( sTitle, xAbortChannel );
OUString id( dp_misc::getIdentifier( xPackage ) );
try
{
- xPackageManager->removePackage( id, xPackage->getName(), xAbortChannel, rCmdEnv.get() );
+ xExtMgr->removeExtension( id, xPackage->getName(), xPackage->getRepositoryName(), xAbortChannel, rCmdEnv.get() );
}
+ catch ( deployment::DeploymentException & )
+ {}
+ catch ( ucb::CommandFailedException & )
+ {}
catch ( ucb::CommandAbortedException & )
{}
@@ -983,7 +996,8 @@ void ExtensionCmdQueue::Thread::_removeExtension( ::rtl::Reference< ProgressCmdE
}
//------------------------------------------------------------------------------
-void ExtensionCmdQueue::Thread::_checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList )
+void ExtensionCmdQueue::Thread::_checkForUpdates(
+ const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList )
{
UpdateDialog* pUpdateDialog;
std::vector< UpdateData > vData;
@@ -1042,13 +1056,14 @@ void ExtensionCmdQueue::Thread::_enableExtension( ::rtl::Reference< ProgressCmdE
if ( !xPackage.is() )
return;
- uno::Reference< task::XAbortChannel > xAbortChannel( xPackage->createAbortChannel() );
+ uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager();
+ uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() );
OUString sTitle = searchAndReplaceAll( m_sEnablingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() );
rCmdEnv->progressSection( sTitle, xAbortChannel );
try
{
- xPackage->registerPackage( xAbortChannel, rCmdEnv.get() );
+ xExtMgr->enableExtension( xPackage, xAbortChannel, rCmdEnv.get() );
if ( m_pDialogHelper )
m_pDialogHelper->updatePackageInfo( xPackage );
}
@@ -1063,13 +1078,36 @@ void ExtensionCmdQueue::Thread::_disableExtension( ::rtl::Reference< ProgressCmd
if ( !xPackage.is() )
return;
- uno::Reference< task::XAbortChannel > xAbortChannel( xPackage->createAbortChannel() );
+ uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager();
+ uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() );
OUString sTitle = searchAndReplaceAll( m_sDisablingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() );
rCmdEnv->progressSection( sTitle, xAbortChannel );
try
{
- xPackage->revokePackage( xAbortChannel, rCmdEnv.get() );
+ xExtMgr->disableExtension( xPackage, xAbortChannel, rCmdEnv.get() );
+ if ( m_pDialogHelper )
+ m_pDialogHelper->updatePackageInfo( xPackage );
+ }
+ catch ( ::ucb::CommandAbortedException & )
+ {}
+}
+
+//------------------------------------------------------------------------------
+void ExtensionCmdQueue::Thread::_acceptLicense( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv,
+ const uno::Reference< deployment::XPackage > &xPackage )
+{
+ if ( !xPackage.is() )
+ return;
+
+ uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager();
+ uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() );
+ OUString sTitle = searchAndReplaceAll( m_sAcceptLicense, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() );
+ rCmdEnv->progressSection( sTitle, xAbortChannel );
+
+ try
+ {
+ xExtMgr->checkPrerequisitesAndEnable( xPackage, xAbortChannel, rCmdEnv.get() );
if ( m_pDialogHelper )
m_pDialogHelper->updatePackageInfo( xPackage );
}
@@ -1120,17 +1158,16 @@ ExtensionCmdQueue::~ExtensionCmdQueue() {
stop();
}
-void ExtensionCmdQueue::addExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager,
- const ::rtl::OUString & extensionURL,
+void ExtensionCmdQueue::addExtension( const ::rtl::OUString & extensionURL,
+ const ::rtl::OUString & repository,
const bool bWarnUser )
{
- m_thread->addExtension( rPackageManager, extensionURL, bWarnUser );
+ m_thread->addExtension( extensionURL, repository, bWarnUser );
}
-void ExtensionCmdQueue::removeExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager,
- const uno::Reference< deployment::XPackage > &rPackage )
+void ExtensionCmdQueue::removeExtension( const uno::Reference< deployment::XPackage > &rPackage )
{
- m_thread->removeExtension( rPackageManager, rPackage );
+ m_thread->removeExtension( rPackage );
}
void ExtensionCmdQueue::enableExtension( const uno::Reference< deployment::XPackage > &rPackage,
@@ -1139,11 +1176,21 @@ void ExtensionCmdQueue::enableExtension( const uno::Reference< deployment::XPack
m_thread->enableExtension( rPackage, bEnable );
}
-void ExtensionCmdQueue::checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList )
+void ExtensionCmdQueue::checkForUpdates( const std::vector<uno::Reference<deployment::XPackage > > &vExtensionList )
{
m_thread->checkForUpdates( vExtensionList );
}
+void ExtensionCmdQueue::acceptLicense( const uno::Reference< deployment::XPackage > &rPackage )
+{
+ m_thread->acceptLicense( rPackage );
+}
+
+void ExtensionCmdQueue::syncRepositories( const uno::Reference< uno::XComponentContext > &xContext )
+{
+ dp_misc::syncRepositories( new ProgressCmdEnv( xContext, NULL, OUSTR("Extension Manager") ) );
+}
+
void ExtensionCmdQueue::stop()
{
m_thread->stop();
diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx
index f984c71c6c1c..7ac00e2740d4 100644..100755
--- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx
+++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx
@@ -40,7 +40,6 @@
/// @HTML
namespace com { namespace sun { namespace star {
- namespace deployment { class XPackageManager; }
namespace task { class XInteractionRequest; }
namespace uno { class XComponentContext; }
} } }
@@ -78,14 +77,16 @@ public:
/**
*/
- void addExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &rPackageManager,
- const ::rtl::OUString &rExtensionURL,
+ void addExtension( const ::rtl::OUString &rExtensionURL,
+ const ::rtl::OUString &rRepository,
const bool bWarnUser );
- void removeExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &rPackageManager,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage );
+ void removeExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage );
void enableExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage,
const bool bEnable );
- void checkForUpdates( const std::vector< TUpdateListEntry > &vList );
+ void checkForUpdates(const std::vector< ::com::sun::star::uno::Reference<
+ ::com::sun::star::deployment::XPackage > > &vList );
+ void acceptLicense( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage );
+ static void syncRepositories( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext );
/**
This call does not block. It signals the internal thread
that it should install the remaining extensions and then terminate.
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
index bcaa3252ea8f..24b47aa223e3 100755
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
@@ -44,6 +44,10 @@
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+#define USER_PACKAGE_MANAGER OUSTR("user")
+#define SHARED_PACKAGE_MANAGER OUSTR("shared")
+#define BUNDLED_PACKAGE_MANAGER OUSTR("bundled")
+
using namespace ::com::sun::star;
namespace dp_gui {
@@ -52,19 +56,20 @@ namespace dp_gui {
// struct Entry_Impl
//------------------------------------------------------------------------------
Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage,
- const uno::Reference< deployment::XPackageManager > &xPackageManager,
- PackageState eState ) :
+ const PackageState eState, const bool bReadOnly ) :
m_bActive( false ),
- m_bLocked( false ),
+ m_bLocked( bReadOnly ),
m_bHasOptions( false ),
+ m_bUser( false ),
m_bShared( false ),
m_bNew( false ),
m_bChecked( false ),
m_bMissingDeps( false ),
+ m_bHasButtons( false ),
+ m_bMissingLic( false ),
m_eState( eState ),
m_pPublisher( NULL ),
- m_xPackage( xPackage ),
- m_xPackageManager( xPackageManager )
+ m_xPackage( xPackage )
{
m_sTitle = xPackage->getDisplayName();
m_sVersion = xPackage->getVersion();
@@ -85,8 +90,6 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage,
else
m_aIconHC = m_aIcon;
- m_bLocked = m_xPackageManager->isReadOnly();
-
if ( eState == AMBIGUOUS )
m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS );
else if ( eState == NOT_REGISTERED )
@@ -106,14 +109,11 @@ StringCompare Entry_Impl::CompareTo( const CollatorWrapper *pCollator, const TEn
eCompare = m_sVersion.CompareTo( pEntry->m_sVersion );
if ( eCompare == COMPARE_EQUAL )
{
- if ( m_xPackageManager != pEntry->m_xPackageManager )
- {
- sal_Int32 nCompare = m_xPackageManager->getContext().compareTo( pEntry->m_xPackageManager->getContext() );
- if ( nCompare < 0 )
- eCompare = COMPARE_LESS;
- else if ( nCompare > 0 )
- eCompare = COMPARE_GREATER;
- }
+ sal_Int32 nCompare = m_xPackage->getRepositoryName().compareTo( pEntry->m_xPackage->getRepositoryName() );
+ if ( nCompare < 0 )
+ eCompare = COMPARE_LESS;
+ else if ( nCompare > 0 )
+ eCompare = COMPARE_GREATER;
}
}
return eCompare;
@@ -373,6 +373,8 @@ void ExtensionBox_Impl::CalcActiveHeight( const long nPos )
aSize.Height() = 10000;
rtl::OUString aText( m_vEntries[ nPos ]->m_sErrorText );
+ if ( aText.getLength() )
+ aText += OUSTR("\n");
aText += m_vEntries[ nPos ]->m_sDescription;
Rectangle aRect = GetTextRect( Rectangle( Point(), aSize ), aText,
@@ -382,7 +384,10 @@ void ExtensionBox_Impl::CalcActiveHeight( const long nPos )
if ( aTextHeight < m_nStdHeight )
aTextHeight = m_nStdHeight;
- m_nActiveHeight = aTextHeight + m_nExtraHeight;
+ if ( m_vEntries[ nPos ]->m_bHasButtons )
+ m_nActiveHeight = aTextHeight + m_nExtraHeight;
+ else
+ m_nActiveHeight = aTextHeight + 2;
}
//------------------------------------------------------------------------------
@@ -599,7 +604,12 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr
aPos.Y() += aTextHeight;
if ( pEntry->m_bActive )
{
- DrawText( Rectangle( aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - m_nExtraHeight ),
+ long nExtraHeight = 0;
+
+ if ( pEntry->m_bHasButtons )
+ nExtraHeight = m_nExtraHeight;
+
+ DrawText( Rectangle( aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - nExtraHeight ),
sDescription, TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
}
else
@@ -619,7 +629,7 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr
}
// Draw status icons
- if ( pEntry->m_bShared )
+ if ( !pEntry->m_bUser )
{
aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SMALL_ICON_SIZE), TOP_OFFSET );
if ( pEntry->m_bLocked )
@@ -627,7 +637,7 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr
else
DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aSharedImageHC : m_aSharedImage );
}
- if ( ( pEntry->m_eState == AMBIGUOUS ) || pEntry->m_bMissingDeps )
+ if ( ( pEntry->m_eState == AMBIGUOUS ) || pEntry->m_bMissingDeps || pEntry->m_bMissingLic )
{
aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SPACE_BETWEEN + 2*SMALL_ICON_SIZE), TOP_OFFSET );
DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aWarningImageHC : m_aWarningImage );
@@ -946,29 +956,24 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl pEntry, const long nStar
//------------------------------------------------------------------------------
long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage,
- const uno::Reference< deployment::XPackageManager > &xPackageManager )
+ bool bLicenseMissing )
{
- long nPos = 0;
+ long nPos = 0;
PackageState eState = m_pManager->getPackageState( xPackage );
+ bool bLocked = m_pManager->isReadOnly( xPackage );
- TEntry_Impl pEntry( new Entry_Impl( xPackage, xPackageManager, eState ) );
+ TEntry_Impl pEntry( new Entry_Impl( xPackage, eState, bLocked ) );
xPackage->addEventListener( uno::Reference< lang::XEventListener > ( m_xRemoveListener, uno::UNO_QUERY ) );
::osl::ClearableMutexGuard guard(m_entriesMutex);
if ( m_vEntries.empty() )
{
- pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage );
- pEntry->m_bShared = ( m_pManager->getSharedPkgMgr() == xPackageManager );
- pEntry->m_bNew = m_bInCheckMode;
m_vEntries.push_back( pEntry );
}
else
{
if ( !FindEntryPos( pEntry, 0, m_vEntries.size()-1, nPos ) )
{
- pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage );
- pEntry->m_bShared = ( m_pManager->getSharedPkgMgr() == xPackageManager );
- pEntry->m_bNew = m_bInCheckMode;
m_vEntries.insert( m_vEntries.begin()+nPos, pEntry );
}
else if ( !m_bInCheckMode )
@@ -976,6 +981,16 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &
OSL_ENSURE( 0, "ExtensionBox_Impl::addEntry(): Will not add duplicate entries" );
}
}
+
+ pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage );
+ pEntry->m_bUser = xPackage->getRepositoryName().equals( USER_PACKAGE_MANAGER );
+ pEntry->m_bShared = xPackage->getRepositoryName().equals( SHARED_PACKAGE_MANAGER );
+ pEntry->m_bNew = m_bInCheckMode;
+ pEntry->m_bMissingLic = bLicenseMissing;
+
+ if ( bLicenseMissing )
+ pEntry->m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_MISSING_LICENSE );
+
//access to m_nActive must be guarded
if ( !m_bInCheckMode && m_bHasActive && ( m_nActive >= nPos ) )
m_nActive += 1;
@@ -1005,9 +1020,12 @@ void ExtensionBox_Impl::updateEntry( const uno::Reference< deployment::XPackage
(*iIndex)->m_sVersion = xPackage->getVersion();
(*iIndex)->m_sDescription = xPackage->getDescription();
+ if ( eState == REGISTERED )
+ (*iIndex)->m_bMissingLic = false;
+
if ( eState == AMBIGUOUS )
(*iIndex)->m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS );
- else
+ else if ( ! (*iIndex)->m_bMissingLic )
(*iIndex)->m_sErrorText = String();
if ( IsReallyVisible() )
@@ -1091,16 +1109,13 @@ void ExtensionBox_Impl::RemoveUnlocked()
}
//------------------------------------------------------------------------------
-void ExtensionBox_Impl::prepareChecking( const uno::Reference< deployment::XPackageManager > &xPackageMgr )
+void ExtensionBox_Impl::prepareChecking()
{
m_bInCheckMode = true;
typedef std::vector< TEntry_Impl >::iterator ITER;
for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex )
{
- if ( (*iIndex)->m_xPackageManager == xPackageMgr )
- (*iIndex)->m_bChecked = false;
- else
- (*iIndex)->m_bChecked = true;
+ (*iIndex)->m_bChecked = false;
(*iIndex)->m_bNew = false;
}
}
@@ -1119,17 +1134,30 @@ void ExtensionBox_Impl::checkEntries()
{
if ( (*iIndex)->m_bChecked == false )
{
+ (*iIndex)->m_bChecked = true;
bNeedsUpdate = true;
nPos = iIndex-m_vEntries.begin();
if ( (*iIndex)->m_bNew )
- {
+ { // add entry to list and correct active pos
if ( nNewPos == - 1)
nNewPos = nPos;
if ( nPos <= m_nActive )
m_nActive += 1;
+ iIndex++;
+ }
+ else
+ { // remove entry from list
+ if ( nPos < m_nActive )
+ m_nActive -= 1;
+ else if ( ( nPos == m_nActive ) && ( nPos == (long) m_vEntries.size() - 1 ) )
+ m_nActive -= 1;
+ m_vRemovedEntries.push_back( *iIndex );
+ m_vEntries.erase( iIndex );
+ iIndex = m_vEntries.begin() + nPos;
}
}
- iIndex++;
+ else
+ iIndex++;
}
guard.clear();
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
index 16ef974deff9..762f50296690 100755
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
@@ -38,7 +38,6 @@
#include "com/sun/star/lang/Locale.hpp"
#include "com/sun/star/lang/XEventListener.hpp"
#include "com/sun/star/deployment/XPackage.hpp"
-#include "com/sun/star/deployment/XPackageManager.hpp"
#include <boost/shared_ptr.hpp>
@@ -65,13 +64,16 @@ typedef ::boost::shared_ptr< Entry_Impl > TEntry_Impl;
struct Entry_Impl
{
- bool m_bActive;
- bool m_bLocked;
- bool m_bHasOptions;
- bool m_bShared;
- bool m_bNew;
- bool m_bChecked;
- bool m_bMissingDeps;
+ bool m_bActive :1;
+ bool m_bLocked :1;
+ bool m_bHasOptions :1;
+ bool m_bUser :1;
+ bool m_bShared :1;
+ bool m_bNew :1;
+ bool m_bChecked :1;
+ bool m_bMissingDeps :1;
+ bool m_bHasButtons :1;
+ bool m_bMissingLic :1;
PackageState m_eState;
String m_sTitle;
String m_sVersion;
@@ -84,11 +86,9 @@ struct Entry_Impl
svt::FixedHyperlink *m_pPublisher;
::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage;
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> m_xPackageManager;
Entry_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager,
- PackageState eState );
+ const PackageState eState, const bool bReadOnly );
~Entry_Impl();
StringCompare CompareTo( const CollatorWrapper *pCollator, const TEntry_Impl pEntry ) const;
@@ -207,11 +207,11 @@ public:
//-----------------
virtual void selectEntry( const long nPos );
long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager );
+ bool bLicenseMissing = false );
void updateEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
void removeEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
- void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageMgr );
+ void prepareChecking();
void checkEntries();
TheExtensionManager* getExtensionManager() const { return m_pManager; }
diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx
index 578ff04a6c88..29bedf1b229f 100644..100755
--- a/desktop/source/deployment/gui/dp_gui_service.cxx
+++ b/desktop/source/deployment/gui/dp_gui_service.cxx
@@ -46,6 +46,7 @@
#include "boost/bind.hpp"
#include "license_dialog.hxx"
#include "dp_gui_dialog2.hxx"
+#include "dp_gui_extensioncmdqueue.hxx"
using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -264,6 +265,7 @@ void ServiceImpl::startExecuteModal(
+ ::utl::ConfigManager::GetDirectConfigProperty(
::utl::ConfigManager::PRODUCTVERSION).get<OUString>();
app->SetDisplayName(sTitle);
+ ExtensionCmdQueue::syncRepositories( m_xComponentContext );
}
}
else
diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
index 796918202a52..d0347c7cbf4e 100644..100755
--- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
+++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
@@ -36,17 +36,20 @@
#include "toolkit/helper/vclunohelper.hxx"
#include "com/sun/star/beans/XPropertySet.hpp"
-#include "com/sun/star/deployment/XPackageManagerFactory.hpp"
-#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
#include "dp_gui_dialog2.hxx"
#include "dp_gui_extensioncmdqueue.hxx"
#include "dp_gui_theextmgr.hxx"
#include "dp_gui_theextmgr.hxx"
#include "dp_identifier.hxx"
+#include "dp_update.hxx"
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+#define USER_PACKAGE_MANAGER OUSTR("user")
+#define SHARED_PACKAGE_MANAGER OUSTR("shared")
+#define BUNDLED_PACKAGE_MANAGER OUSTR("bundled")
+
using namespace ::com::sun::star;
using ::rtl::OUString;
@@ -65,16 +68,11 @@ TheExtensionManager::TheExtensionManager( Window *pParent,
m_xContext( xContext ),
m_pParent( pParent ),
m_pExtMgrDialog( NULL ),
- m_pUpdReqDialog( NULL )
+ m_pUpdReqDialog( NULL ),
+ m_pExecuteCmdQueue( NULL )
{
- m_sPackageManagers.realloc(2);
- m_sPackageManagers[0] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( OUSTR("user") );
- m_sPackageManagers[1] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( OUSTR("shared") );;
-
- for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i )
- {
- m_sPackageManagers[i]->addModifyListener( this );
- }
+ m_xExtensionManager = deployment::ExtensionManager::get( xContext );
+ m_xExtensionManager->addModifyListener( this );
uno::Reference< lang::XMultiServiceFactory > xConfig(
xContext->getServiceManager()->createInstanceWithContext(
@@ -121,6 +119,8 @@ TheExtensionManager::~TheExtensionManager()
delete m_pUpdReqDialog;
if ( m_pExtMgrDialog )
delete m_pExtMgrDialog;
+ if ( m_pExecuteCmdQueue )
+ delete m_pExecuteCmdQueue;
}
//------------------------------------------------------------------------------
@@ -133,14 +133,16 @@ void TheExtensionManager::createDialog( const bool bCreateUpdDlg )
if ( !m_pUpdReqDialog )
{
m_pUpdReqDialog = new UpdateRequiredDialog( NULL, this );
- m_pExecuteCmdQueue.reset( new ExtensionCmdQueue( (DialogHelper*) m_pUpdReqDialog, this, m_xContext ) );
+ delete m_pExecuteCmdQueue;
+ m_pExecuteCmdQueue = new ExtensionCmdQueue( (DialogHelper*) m_pUpdReqDialog, this, m_xContext );
createPackageList();
}
}
else if ( !m_pExtMgrDialog )
{
m_pExtMgrDialog = new ExtMgrDialog( m_pParent, this );
- m_pExecuteCmdQueue.reset( new ExtensionCmdQueue( (DialogHelper*) m_pExtMgrDialog, this, m_xContext ) );
+ delete m_pExecuteCmdQueue;
+ m_pExecuteCmdQueue = new ExtensionCmdQueue( (DialogHelper*) m_pExtMgrDialog, this, m_xContext );
m_pExtMgrDialog->setGetExtensionsURL( m_sGetExtensionsURL );
createPackageList();
}
@@ -205,27 +207,29 @@ bool TheExtensionManager::isVisible()
//------------------------------------------------------------------------------
bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bParentVisible*/ )
{
- std::vector< TUpdateListEntry > vEntries;
+ std::vector< uno::Reference< deployment::XPackage > > vEntries;
+ uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages;
- for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i )
+ try {
+ xAllPackages = m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(),
+ uno::Reference< ucb::XCommandEnvironment >() );
+ } catch ( deployment::DeploymentException & ) {
+ return false;
+ } catch ( ucb::CommandFailedException & ) {
+ return false;
+ } catch ( ucb::CommandAbortedException & ) {
+ return false;
+ } catch ( lang::IllegalArgumentException & e ) {
+ throw uno::RuntimeException( e.Message, e.Context );
+ }
+
+ for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i )
{
- uno::Sequence< uno::Reference< deployment::XPackage > > xPackages;
- try {
- xPackages = m_sPackageManagers[i]->getDeployedPackages( uno::Reference< task::XAbortChannel >(),
- uno::Reference< ucb::XCommandEnvironment >() );
- for ( sal_Int32 k = 0; k < xPackages.getLength(); ++k )
- {
- TUpdateListEntry pEntry( new UpdateListEntry( xPackages[k], m_sPackageManagers[i] ) );
- vEntries.push_back( pEntry );
- }
- } catch ( deployment::DeploymentException & ) {
- continue;
- } catch ( ucb::CommandFailedException & ) {
- continue;
- } catch ( ucb::CommandAbortedException & ) {
- return true;
- } catch ( lang::IllegalArgumentException & e ) {
- throw uno::RuntimeException( e.Message, e.Context );
+ uno::Reference< deployment::XPackage > xPackage = dp_misc::getExtensionWithHighestVersion(xAllPackages[i]);
+ OSL_ASSERT(xPackage.is());
+ if ( xPackage.is() )
+ {
+ vEntries.push_back( xPackage );
}
}
@@ -234,32 +238,6 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare
}
//------------------------------------------------------------------------------
-bool TheExtensionManager::enablePackage( const uno::Reference< deployment::XPackage > &xPackage,
- bool bEnable )
-{
- m_pExecuteCmdQueue->enableExtension( xPackage, bEnable );
-
- return true;
-}
-
-//------------------------------------------------------------------------------
-bool TheExtensionManager::removePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager,
- const uno::Reference< deployment::XPackage > &xPackage )
-{
- m_pExecuteCmdQueue->removeExtension( xPackageManager, xPackage );
-
- return true;
-}
-
-//------------------------------------------------------------------------------
-bool TheExtensionManager::updatePackages( const std::vector< TUpdateListEntry > &vList )
-{
- m_pExecuteCmdQueue->checkForUpdates( vList );
-
- return true;
-}
-
-//------------------------------------------------------------------------------
bool TheExtensionManager::installPackage( const OUString &rPackageURL, bool bWarnUser )
{
if ( rPackageURL.getLength() == 0 )
@@ -267,22 +245,20 @@ bool TheExtensionManager::installPackage( const OUString &rPackageURL, bool bWar
createDialog( false );
- uno::Reference< deployment::XPackageManager > xUserPkgMgr = getUserPkgMgr();
- uno::Reference< deployment::XPackageManager > xSharedPkgMgr = getSharedPkgMgr();
-
bool bInstall = true;
bool bInstallForAll = false;
- if ( !bWarnUser && ! xSharedPkgMgr->isReadOnly() )
+ // DV! missing function is read only repository from extension manager
+ if ( !bWarnUser && ! m_xExtensionManager->isReadOnlyRepository( SHARED_PACKAGE_MANAGER ) )
bInstall = getDialogHelper()->installForAllUsers( bInstallForAll );
if ( !bInstall )
return false;
if ( bInstallForAll )
- m_pExecuteCmdQueue->addExtension( xSharedPkgMgr, rPackageURL, false );
+ m_pExecuteCmdQueue->addExtension( rPackageURL, SHARED_PACKAGE_MANAGER, false );
else
- m_pExecuteCmdQueue->addExtension( xUserPkgMgr, rPackageURL, bWarnUser );
+ m_pExecuteCmdQueue->addExtension( rPackageURL, USER_PACKAGE_MANAGER, bWarnUser );
return true;
}
@@ -312,40 +288,52 @@ void TheExtensionManager::terminateDialog()
}
//------------------------------------------------------------------------------
-bool TheExtensionManager::createPackageList( const uno::Reference< deployment::XPackageManager > &xPackageManager )
+void TheExtensionManager::createPackageList()
{
- uno::Sequence< uno::Reference< deployment::XPackage > > packages;
+ uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages;
try {
- packages = xPackageManager->getDeployedPackages( uno::Reference< task::XAbortChannel >(),
- uno::Reference< ucb::XCommandEnvironment >() );
+ xAllPackages = m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(),
+ uno::Reference< ucb::XCommandEnvironment >() );
} catch ( deployment::DeploymentException & ) {
- //handleGeneralError(e.Cause);
- return true;
+ return;
} catch ( ucb::CommandFailedException & ) {
- //handleGeneralError(e.Reason);
- return true;
+ return;
} catch ( ucb::CommandAbortedException & ) {
- return false;
+ return;
} catch ( lang::IllegalArgumentException & e ) {
throw uno::RuntimeException( e.Message, e.Context );
}
- for ( sal_Int32 j = 0; j < packages.getLength(); ++j )
+ for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i )
{
- getDialogHelper()->addPackageToList( packages[j], xPackageManager );
- }
+ uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i];
- return true;
-}
+ for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j )
+ {
+ uno::Reference< deployment::XPackage > xPackage = xPackageList[j];
+ if ( xPackage.is() )
+ {
+ PackageState eState = getPackageState( xPackage );
+ getDialogHelper()->addPackageToList( xPackage );
+ // When the package is enabled, we can stop here, otherwise we have to look for
+ // another version of this package
+ if ( ( eState == REGISTERED ) || ( eState == NOT_AVAILABLE ) )
+ break;
+ }
+ }
+ }
-//------------------------------------------------------------------------------
-void TheExtensionManager::createPackageList()
-{
- for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i )
+ uno::Sequence< uno::Reference< deployment::XPackage > > xNoLicPackages;
+ xNoLicPackages = m_xExtensionManager->getExtensionsWithUnacceptedLicenses( SHARED_PACKAGE_MANAGER,
+ uno::Reference< ucb::XCommandEnvironment >() );
+ for ( sal_Int32 i = 0; i < xNoLicPackages.getLength(); ++i )
{
- if ( ! createPackageList( m_sPackageManagers[i] ) )
- break;
+ uno::Reference< deployment::XPackage > xPackage = xNoLicPackages[i];
+ if ( xPackage.is() )
+ {
+ getDialogHelper()->addPackageToList( xPackage, true );
+ }
}
}
@@ -378,6 +366,17 @@ PackageState TheExtensionManager::getPackageState( const uno::Reference< deploym
}
//------------------------------------------------------------------------------
+bool TheExtensionManager::isReadOnly( const uno::Reference< deployment::XPackage > &xPackage ) const
+{
+ if ( m_xExtensionManager.is() && xPackage.is() )
+ {
+ return m_xExtensionManager->isReadOnlyRepository( xPackage->getRepositoryName() );
+ }
+ else
+ return true;
+}
+
+//------------------------------------------------------------------------------
// The function investigates if the extension supports options.
bool TheExtensionManager::supportsOptions( const uno::Reference< deployment::XPackage > &xPackage ) const
{
@@ -488,16 +487,12 @@ void TheExtensionManager::notifyTermination( ::lang::EventObject const & rEvt )
//------------------------------------------------------------------------------
// XModifyListener
-void TheExtensionManager::modified( ::lang::EventObject const & rEvt )
+void TheExtensionManager::modified( ::lang::EventObject const & /*rEvt*/ )
throw ( uno::RuntimeException )
{
- uno::Reference< deployment::XPackageManager > xPackageManager( rEvt.Source, uno::UNO_QUERY );
- if ( xPackageManager.is() )
- {
- getDialogHelper()->prepareChecking( xPackageManager );
- createPackageList( xPackageManager );
- getDialogHelper()->checkEntries();
- }
+ getDialogHelper()->prepareChecking();
+ createPackageList();
+ getDialogHelper()->checkEntries();
}
//------------------------------------------------------------------------------
diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx
index 1cdd1851d59e..094e25e249b7 100644..100755
--- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx
+++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx
@@ -33,7 +33,8 @@
#include "cppuhelper/implbase2.hxx"
#include "com/sun/star/container/XNameAccess.hpp"
-#include "com/sun/star/deployment/XPackageManager.hpp"
+#include "com/sun/star/deployment/XExtensionManager.hpp"
+#include "com/sun/star/deployment/ExtensionManager.hpp"
#include "com/sun/star/frame/XDesktop.hpp"
#include "com/sun/star/frame/XTerminateListener.hpp"
#include "com/sun/star/uno/XComponentContext.hpp"
@@ -57,21 +58,17 @@ class TheExtensionManager :
private:
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > m_xDesktop;
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> > m_sPackageManagers;
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xNameAccessNodes;
- ::std::auto_ptr< ExtensionCmdQueue > m_pExecuteCmdQueue;
-
Window *m_pParent;
ExtMgrDialog *m_pExtMgrDialog;
UpdateRequiredDialog *m_pUpdReqDialog;
+ ExtensionCmdQueue *m_pExecuteCmdQueue;
::rtl::OUString m_sGetExtensionsURL;
- // liste der packages ( xpackage?, mit parent manager, ... )
-
void createPackageList();
- bool createPackageList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager );
public:
static ::rtl::Reference<TheExtensionManager> s_ExtMgr;
@@ -85,6 +82,7 @@ public:
Dialog* getDialog() { return m_pExtMgrDialog ? (Dialog*) m_pExtMgrDialog : (Dialog*) m_pUpdReqDialog; }
DialogHelper* getDialogHelper() { return m_pExtMgrDialog ? (DialogHelper*) m_pExtMgrDialog : (DialogHelper*) m_pUpdReqDialog; }
+ ExtensionCmdQueue* getCmdQueue() const { return m_pExecuteCmdQueue; }
void SetText( const ::rtl::OUString &rTitle );
void Show();
@@ -94,12 +92,6 @@ public:
//-----------------
bool checkUpdates( bool showUpdateOnly, bool parentVisible );
- bool updatePackages( const std::vector< TUpdateListEntry > &vList );
-
- bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
- bool bEnable );
- bool removePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
bool installPackage( const ::rtl::OUString &rPackageURL, bool bWarnUser = false );
bool queryTermination();
@@ -109,8 +101,8 @@ public:
bool supportsOptions( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const;
PackageState getPackageState( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext; }
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > getUserPkgMgr() const { return m_sPackageManagers[0]; }
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > getSharedPkgMgr() const { return m_sPackageManagers[1]; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > getExtensionManager() const { return m_xExtensionManager; }
+ bool isReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const;
//-----------------
static ::rtl::Reference<TheExtensionManager> get(
diff --git a/desktop/source/deployment/gui/dp_gui_updatedata.hxx b/desktop/source/deployment/gui/dp_gui_updatedata.hxx
index dda6126f70d0..76eb8af31e8e 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedata.hxx
+++ b/desktop/source/deployment/gui/dp_gui_updatedata.hxx
@@ -35,7 +35,6 @@
namespace com { namespace sun { namespace star { namespace deployment {
- class XPackageManager;
class XPackage;
}}}}
namespace com { namespace sun { namespace star { namespace xml { namespace dom {
@@ -45,31 +44,42 @@ namespace com { namespace sun { namespace star { namespace xml { namespace dom {
namespace dp_gui {
-struct UpdateListEntry
+struct UpdateData
{
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage;
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> m_xPackageManager;
-
- UpdateListEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage,
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager );
- ~UpdateListEntry();
-};
-
-typedef ::boost::shared_ptr< UpdateListEntry > TUpdateListEntry;
+ UpdateData( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > const & aExt):
+ bIsShared(false), aInstalledPackage(aExt){};
+ //When entries added to the listbox then there can be one for the user update and one
+ //for the shared update. However, both list entries will contain the same UpdateData.
+ //isShared is used to indicate which one is used for the shared entry.
+ bool bIsShared;
-struct UpdateData
-{
+ //The currently installed extension which is going to be updated. If the extension exist in
+ //multiple repositories then it is the one with the highest version.
::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > aInstalledPackage;
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > aPackageManager;
- // The content of the update information
+ //The version of the update
+ ::rtl::OUString updateVersion;
+
+ //For online update
+ // ======================
+ // The content of the update information.
+ //Only if aUpdateInfo is set then there is an online update available with a better version
+ //than any of the currently installed extensions with the same identifier.
::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > aUpdateInfo;
//The URL of the locally downloaded extension. It will only be set if there were no errors
//during the download
::rtl::OUString sLocalURL;
//The URL of the website wher the download can be obtained.
::rtl::OUString sWebsiteURL;
+
+ //For local update
+ //=====================
+ //The locale extension which is used as update for the user or shared repository.
+ //If set then the data for the online update (aUpdateInfo, sLocalURL, sWebsiteURL)
+ //are to be ignored.
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage >
+ aUpdateSource;
};
}
diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
index 61479f799e6f..b27cd8da81fe 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
+++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
@@ -54,7 +54,8 @@
#include "com/sun/star/deployment/DeploymentException.hpp"
#include "com/sun/star/deployment/UpdateInformationProvider.hpp"
#include "com/sun/star/deployment/XPackage.hpp"
-#include "com/sun/star/deployment/XPackageManager.hpp"
+#include "com/sun/star/deployment/XExtensionManager.hpp"
+#include "com/sun/star/deployment/ExtensionManager.hpp"
#include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
#include "com/sun/star/frame/XDesktop.hpp"
#include "com/sun/star/frame/XDispatch.hpp"
@@ -111,6 +112,7 @@
#include "dp_identifier.hxx"
#include "dp_version.hxx"
#include "dp_misc.h"
+#include "dp_update.hxx"
#include "dp_gui.h"
#include "dp_gui.hrc"
@@ -150,7 +152,6 @@ rtl::OUString confineToParagraph(rtl::OUString const & text) {
struct UpdateDialog::DisabledUpdate {
rtl::OUString name;
css::uno::Sequence< rtl::OUString > unsatisfiedDependencies;
- bool permission;
// We also want to show release notes and publisher for disabled updates
::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > aUpdateInfo;
};
@@ -229,7 +230,7 @@ public:
Thread(
css::uno::Reference< css::uno::XComponentContext > const & context,
UpdateDialog & dialog,
- const std::vector< TUpdateListEntry > &vExtensionList);
+ const std::vector< css::uno::Reference< css::deployment::XPackage > > & vExtensionList);
void stop();
@@ -240,18 +241,21 @@ private:
struct Entry {
explicit Entry(
css::uno::Reference< css::deployment::XPackage > const & thePackage,
- css::uno::Reference< css::deployment::XPackageManager > const &
- thePackageManager,
rtl::OUString const & theVersion);
css::uno::Reference< css::deployment::XPackage > package;
- css::uno::Reference< css::deployment::XPackageManager > packageManager;
rtl::OUString version;
+ //Indicates that the extension provides its own update URLs.
+ //If this is true, then we must not use the default update
+ //URL to find the update information.
+ bool bProvidesOwnUpdate;
css::uno::Reference< css::xml::dom::XNode > info;
+ UpdateDialog::DisabledUpdate disableUpdate;
+ dp_gui::UpdateData updateData;
};
- // A multimap in case an extension is installed in both "user" and "shared":
- typedef std::multimap< rtl::OUString, Entry > Map;
+ // A multimap in case an extension is installed in "user", "shared" or "bundled"
+ typedef std::map< rtl::OUString, Entry > Map;
virtual ~Thread();
@@ -269,21 +273,25 @@ private:
css::uno::Sequence< rtl::OUString > const & urls,
rtl::OUString const & identifier) const;
- void handle(
+ void getOwnUpdateInformation(
css::uno::Reference< css::deployment::XPackage > const & package,
- css::uno::Reference< css::deployment::XPackageManager > const &
- packageManager,
Map * map);
+ ::rtl::OUString getUpdateDisplayString(
+ dp_gui::UpdateData const & data, ::rtl::OUString const & version = ::rtl::OUString()) const;
+
+ void prepareUpdateData(
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & updateInfo,
+ UpdateDialog::DisabledUpdate & out_du,
+ dp_gui::UpdateData & out_data) const;
+
bool update(
- css::uno::Reference< css::deployment::XPackage > const & package,
- css::uno::Reference< css::deployment::XPackageManager > const &
- packageManager,
- css::uno::Reference< css::xml::dom::XNode > const & updateInfo) const;
+ UpdateDialog::DisabledUpdate const & du,
+ dp_gui::UpdateData const & data) const;
css::uno::Reference< css::uno::XComponentContext > m_context;
UpdateDialog & m_dialog;
- std::vector< dp_gui::TUpdateListEntry > m_vExtensionList;
+ std::vector< css::uno::Reference< css::deployment::XPackage > > m_vExtensionList;
css::uno::Reference< css::deployment::XUpdateInformationProvider > m_updateInformation;
css::uno::Reference< css::task::XInteractionHandler > m_xInteractionHdl;
@@ -295,7 +303,7 @@ private:
UpdateDialog::Thread::Thread(
css::uno::Reference< css::uno::XComponentContext > const & context,
UpdateDialog & dialog,
- const std::vector< dp_gui::TUpdateListEntry > &vExtensionList):
+ const std::vector< css::uno::Reference< css::deployment::XPackage > > &vExtensionList):
m_context(context),
m_dialog(dialog),
m_vExtensionList(vExtensionList),
@@ -333,13 +341,14 @@ void UpdateDialog::Thread::stop() {
UpdateDialog::Thread::Entry::Entry(
css::uno::Reference< css::deployment::XPackage > const & thePackage,
- css::uno::Reference< css::deployment::XPackageManager > const &
- thePackageManager,
rtl::OUString const & theVersion):
+
package(thePackage),
- packageManager(thePackageManager),
- version(theVersion)
-{}
+ version(theVersion),
+ bProvidesOwnUpdate(false),
+ updateData(thePackage)
+{
+}
UpdateDialog::Thread::~Thread()
{
@@ -349,65 +358,94 @@ UpdateDialog::Thread::~Thread()
void UpdateDialog::Thread::execute()
{
- OSL_ASSERT( ! m_vExtensionList.empty() );
- Map map;
+ {
+ vos::OGuard g( Application::GetSolarMutex() );
+ if ( m_stop ) {
+ return;
+ }
+ }
+ css::uno::Reference<css::deployment::XExtensionManager> extMgr =
+ css::deployment::ExtensionManager::get(m_context);
+
+ std::vector<std::pair<css::uno::Reference<css::deployment::XPackage>, css::uno::Any > > errors;
+
+ dp_misc::UpdateInfoMap updateInfoMap = dp_misc::getOnlineUpdateInfos(
+ m_context, extMgr, m_updateInformation, &m_vExtensionList, errors);
- typedef std::vector< TUpdateListEntry >::const_iterator ITER;
- for ( ITER iIndex = m_vExtensionList.begin(); iIndex < m_vExtensionList.end(); ++iIndex )
+ typedef std::vector<std::pair<css::uno::Reference<css::deployment::XPackage>,
+ css::uno::Any> >::const_iterator ITERROR;
+ for (ITERROR ite = errors.begin(); ite != errors.end(); ite ++)
+ handleSpecificError(ite->first, ite->second);
+
+ for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++)
{
- css::uno::Reference< css::deployment::XPackage > p = (*iIndex)->m_xPackage;
- css::uno::Reference< css::deployment::XPackageManager > m = (*iIndex)->m_xPackageManager;
- if ( p.is() )
+ dp_misc::UpdateInfo const & info = i->second;
+ UpdateData updateData(info.extension);
+ DisabledUpdate disableUpdate;
+ //determine if online updates meet the requirements
+ prepareUpdateData(info.info, disableUpdate, updateData);
+
+ //determine if the update is installed in the user or shared repository
+ rtl::OUString sOnlineVersion;
+ if (info.info.is())
+ sOnlineVersion = info.version;
+ rtl::OUString sVersionUser;
+ rtl::OUString sVersionShared;
+ rtl::OUString sVersionBundled;
+ css::uno::Sequence< css::uno::Reference< css::deployment::XPackage> > extensions;
+ try {
+ extensions = extMgr->getExtensionsWithSameIdentifier(
+ dp_misc::getIdentifier(info.extension), info.extension->getName(),
+ css::uno::Reference<css::ucb::XCommandEnvironment>());
+ } catch (css::lang::IllegalArgumentException& ) {
+ OSL_ASSERT(0);
+ }
+ OSL_ASSERT(extensions.getLength() == 3);
+ if (extensions[0].is() )
+ sVersionUser = extensions[0]->getVersion();
+ if (extensions[1].is() )
+ sVersionShared = extensions[1]->getVersion();
+ if (extensions[2].is() )
+ sVersionBundled = extensions[2]->getVersion();
+
+ bool bSharedReadOnly = extMgr->isReadOnlyRepository(OUSTR("shared"));
+
+ dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension(
+ bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion);
+ dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension(
+ bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion);
+
+ css::uno::Reference<css::deployment::XPackage> updateSource;
+ if (sourceUser != dp_misc::UPDATE_SOURCE_NONE)
{
+ if (sourceUser == dp_misc::UPDATE_SOURCE_SHARED)
{
- vos::OGuard g( Application::GetSolarMutex() );
- if ( m_stop ) {
- return;
- }
+ updateData.aUpdateSource = extensions[1];
+ updateData.updateVersion = extensions[1]->getVersion();
}
- handle( p, m, &map );
+ else if (sourceUser == dp_misc::UPDATE_SOURCE_BUNDLED)
+ {
+ updateData.aUpdateSource = extensions[2];
+ updateData.updateVersion = extensions[2]->getVersion();
+ }
+ if (!update(disableUpdate, updateData))
+ return;
}
- }
- if (!map.empty()) {
- const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL());
- if (sDefaultURL.getLength())
+ if (sourceShared != dp_misc::UPDATE_SOURCE_NONE)
{
- css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >
- infos(
- getUpdateInformation(
- css::uno::Reference< css::deployment::XPackage >(),
- css::uno::Sequence< rtl::OUString >(&sDefaultURL, 1), rtl::OUString()));
- for (sal_Int32 i = 0; i < infos.getLength(); ++i) {
- css::uno::Reference< css::xml::dom::XNode > node(
- infos[i], css::uno::UNO_QUERY_THROW);
- dp_misc::DescriptionInfoset infoset(m_context, node);
- boost::optional< rtl::OUString > id(infoset.getIdentifier());
- if (!id) {
- continue;
- }
- Map::iterator end(map.upper_bound(*id));
- for (Map::iterator j(map.lower_bound(*id)); j != end; ++j) {
- rtl::OUString v(infoset.getVersion());
- if (dp_misc::compareVersions(v, j->second.version) ==
- dp_misc::GREATER)
- {
- j->second.version = v;
- j->second.info = node;
- }
- }
- }
- for (Map::const_iterator i(map.begin()); i != map.end(); ++i) {
- if (i->second.info.is() &&
- !update(
- i->second.package, i->second.packageManager,
- i->second.info))
- {
- break;
- }
+ if (sourceShared == dp_misc::UPDATE_SOURCE_BUNDLED)
+ {
+ updateData.aUpdateSource = extensions[2];
+ updateData.updateVersion = extensions[2]->getVersion();
}
+ updateData.bIsShared = true;
+ if (!update(disableUpdate, updateData))
+ return;
}
}
+
+
vos::OGuard g(Application::GetSolarMutex());
if (!m_stop) {
m_dialog.checkingDone();
@@ -446,142 +484,95 @@ void UpdateDialog::Thread::handleSpecificError(
}
}
-css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >
-UpdateDialog::Thread::getUpdateInformation(
- css::uno::Reference< css::deployment::XPackage > const & package,
- css::uno::Sequence< rtl::OUString > const & urls,
- rtl::OUString const & identifier) const
+::rtl::OUString UpdateDialog::Thread::getUpdateDisplayString(
+ dp_gui::UpdateData const & data, ::rtl::OUString const & version) const
{
- try {
- return m_updateInformation->getUpdateInformation(urls, identifier);
- } catch (css::uno::RuntimeException &) {
- throw;
- } catch (css::ucb::CommandFailedException & e) {
- handleSpecificError(package, e.Reason);
- } catch (css::ucb::CommandAbortedException &) {
- } catch (css::uno::Exception & e) {
- handleSpecificError(package, css::uno::makeAny(e));
+ OSL_ASSERT(data.aInstalledPackage.is());
+ rtl::OUStringBuffer b(data.aInstalledPackage->getDisplayName());
+ b.append(static_cast< sal_Unicode >(' '));
+ {
+ vos::OGuard g( Application::GetSolarMutex() );
+ if(!m_stop)
+ b.append(m_dialog.m_version);
}
- return
- css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >();
-}
+ b.append(static_cast< sal_Unicode >(' '));
+ if (version.getLength())
+ b.append(version);
+ else
+ b.append(data.updateVersion);
-void UpdateDialog::Thread::handle(
- css::uno::Reference< css::deployment::XPackage > const & package,
- css::uno::Reference< css::deployment::XPackageManager > const &
- packageManager,
- Map * map)
-{
- rtl::OUString id(dp_misc::getIdentifier(package));
- css::uno::Sequence< rtl::OUString > urls(
- package->getUpdateInformationURLs());
- if (urls.getLength() == 0) {
- map->insert(
- Map::value_type(
- id, Entry(package, packageManager, package->getVersion())));
- } else {
- css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >
- infos(getUpdateInformation(package, urls, id));
- rtl::OUString latestVersion(package->getVersion());
- sal_Int32 latestIndex = -1;
- for (sal_Int32 i = 0; i < infos.getLength(); ++i) {
- dp_misc::DescriptionInfoset infoset(
- m_context,
- css::uno::Reference< css::xml::dom::XNode >(
- infos[i], css::uno::UNO_QUERY_THROW));
- boost::optional< rtl::OUString > id2(infoset.getIdentifier());
- if (!id2) {
- continue;
- }
- if (*id2 == id) {
- rtl::OUString v(infoset.getVersion());
- if (dp_misc::compareVersions(v, latestVersion) ==
- dp_misc::GREATER)
- {
- latestVersion = v;
- latestIndex = i;
- }
- }
- }
- if (latestIndex != -1) {
- update(
- package, packageManager,
- css::uno::Reference< css::xml::dom::XNode >(
- infos[latestIndex], css::uno::UNO_QUERY_THROW));
+ if (data.sWebsiteURL.getLength())
+ {
+ b.append(static_cast< sal_Unicode >(' '));
+ {
+ vos::OGuard g( Application::GetSolarMutex() );
+ if(!m_stop)
+ b.append(m_dialog.m_browserbased);
}
}
+ return b.makeStringAndClear();
}
-bool UpdateDialog::Thread::update(
- css::uno::Reference< css::deployment::XPackage > const & package,
- css::uno::Reference< css::deployment::XPackageManager > const &
- packageManager,
- css::uno::Reference< css::xml::dom::XNode > const & updateInfo) const
+/** out_data will only be filled if all dependencies are ok.
+ */
+void UpdateDialog::Thread::prepareUpdateData(
+ css::uno::Reference< css::xml::dom::XNode > const & updateInfo,
+ UpdateDialog::DisabledUpdate & out_du,
+ dp_gui::UpdateData & out_data) const
{
+ if (!updateInfo.is())
+ return;
dp_misc::DescriptionInfoset infoset(m_context, updateInfo);
OSL_ASSERT(infoset.getVersion().getLength() != 0);
css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > ds(
dp_misc::Dependencies::check(infoset));
- UpdateDialog::DisabledUpdate du;
- du.aUpdateInfo = updateInfo;
- du.unsatisfiedDependencies.realloc(ds.getLength());
+ out_du.aUpdateInfo = updateInfo;
+ out_du.unsatisfiedDependencies.realloc(ds.getLength());
for (sal_Int32 i = 0; i < ds.getLength(); ++i) {
- du.unsatisfiedDependencies[i] = dp_misc::Dependencies::getErrorText(ds[i]);
+ out_du.unsatisfiedDependencies[i] = dp_misc::Dependencies::getErrorText(ds[i]);
}
- du.permission = ! packageManager->isReadOnly();
+
const ::boost::optional< ::rtl::OUString> updateWebsiteURL(infoset.getLocalizedUpdateWebsiteURL());
- rtl::OUStringBuffer b(package->getDisplayName());
- b.append(static_cast< sal_Unicode >(' '));
- {
- vos::OGuard g( Application::GetSolarMutex() );
- if ( m_stop )
- return !m_stop;
- else
- b.append(m_dialog.m_version);
- }
- b.append(static_cast< sal_Unicode >(' '));
- b.append(infoset.getVersion());
- if (updateWebsiteURL)
+
+ out_du.name = getUpdateDisplayString(out_data, infoset.getVersion());
+
+ if (out_du.unsatisfiedDependencies.getLength() == 0)
{
- b.append(static_cast< sal_Unicode >(' '));
- {
- vos::OGuard g( Application::GetSolarMutex() );
- if ( m_stop )
- return !m_stop;
- else
- b.append(m_dialog.m_browserbased);
- }
+ out_data.aUpdateInfo = updateInfo;
+ out_data.updateVersion = infoset.getVersion();
+ if (updateWebsiteURL)
+ out_data.sWebsiteURL = *updateWebsiteURL;
}
- du.name = b.makeStringAndClear();
+}
- if (du.unsatisfiedDependencies.getLength() == 0 && du.permission)
+bool UpdateDialog::Thread::update(
+ UpdateDialog::DisabledUpdate const & du,
+ dp_gui::UpdateData const & data) const
+{
+ bool ret = false;
+ if (du.unsatisfiedDependencies.getLength() == 0)
{
- dp_gui::UpdateData data;
- data.aInstalledPackage = package;
- data.aPackageManager = packageManager;
- data.aUpdateInfo = updateInfo;
- if (updateWebsiteURL)
- data.sWebsiteURL = *updateWebsiteURL;
vos::OGuard g(Application::GetSolarMutex());
if (!m_stop) {
- m_dialog.addEnabledUpdate(du.name, data);
+ m_dialog.addEnabledUpdate(getUpdateDisplayString(data), data);
}
- return !m_stop;
+ ret = !m_stop;
} else {
vos::OGuard g(Application::GetSolarMutex());
if (!m_stop) {
- m_dialog.addDisabledUpdate(du);
+ m_dialog.addDisabledUpdate(du);
}
- return !m_stop;
+ ret = !m_stop;
}
+ return ret;
}
// UpdateDialog ----------------------------------------------------------
UpdateDialog::UpdateDialog(
css::uno::Reference< css::uno::XComponentContext > const & context,
Window * parent,
- const std::vector< dp_gui::TUpdateListEntry > &vExtensionList,
+ const std::vector<css::uno::Reference< css::deployment::XPackage > > &vExtensionList,
std::vector< dp_gui::UpdateData > * updateData):
ModalDialog(parent,DpGuiResId(RID_DLG_UPDATE)),
m_context(context),
@@ -611,8 +602,6 @@ UpdateDialog::UpdateDialog(
m_noInstall(String(DpGuiResId(RID_DLG_UPDATE_NOINSTALL))),
m_noDependency(String(DpGuiResId(RID_DLG_UPDATE_NODEPENDENCY))),
m_noDependencyCurVer(String(DpGuiResId(RID_DLG_UPDATE_NODEPENDENCY_CUR_VER))),
- m_noPermission(String(DpGuiResId(RID_DLG_UPDATE_NOPERMISSION))),
- m_noPermissionVista(String(DpGuiResId(RID_DLG_UPDATE_NOPERMISSION_VISTA))),
m_browserbased(String(DpGuiResId(RID_DLG_UPDATE_BROWSERBASED))),
m_version(String(DpGuiResId(RID_DLG_UPDATE_VERSION))),
m_updateData(*updateData),
@@ -626,6 +615,9 @@ UpdateDialog::UpdateDialog(
// m_extensionManagerDialog(extensionManagerDialog)
{
OSL_ASSERT(updateData != NULL);
+
+ m_xExtensionManager = css::deployment::ExtensionManager::get( context );
+
css::uno::Reference< css::awt::XToolkit > toolkit;
try {
toolkit = css::uno::Reference< css::awt::XToolkit >(
@@ -666,9 +658,6 @@ UpdateDialog::UpdateDialog(
if ( ! dp_misc::office_is_running())
m_help.Disable();
FreeResource();
- String sTemp(m_noPermissionVista);
- sTemp.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() );
- m_noPermissionVista = sTemp;
initDescription();
}
@@ -998,12 +987,25 @@ void UpdateDialog::clearDescription()
bool UpdateDialog::showDescription(css::uno::Reference< css::xml::dom::XNode > const & aUpdateInfo)
{
dp_misc::DescriptionInfoset infoset(m_context, aUpdateInfo);
- std::pair< rtl::OUString, rtl::OUString > pairPub = infoset.getLocalizedPublisherNameAndURL();
- rtl::OUString sPub = pairPub.first;
- rtl::OUString sURL = pairPub.second;
- rtl::OUString sRel = infoset.getLocalizedReleaseNotesURL();
+ return showDescription(infoset.getLocalizedPublisherNameAndURL(),
+ infoset.getLocalizedReleaseNotesURL());
+}
- if ( sPub.getLength() == 0 && sURL.getLength() == 0 && sRel.getLength() == 0 )
+bool UpdateDialog::showDescription(css::uno::Reference< css::deployment::XPackage > const & aExtension)
+{
+ OSL_ASSERT(aExtension.is());
+ css::beans::StringPair pubInfo = aExtension->getPublisherInfo();
+ return showDescription(std::make_pair(pubInfo.First, pubInfo.Second),
+ OUSTR(""));
+}
+
+bool UpdateDialog::showDescription(std::pair< rtl::OUString, rtl::OUString > const & pairPublisher,
+ rtl::OUString const & sReleaseNotes)
+{
+ rtl::OUString sPub = pairPublisher.first;
+ rtl::OUString sURL = pairPublisher.second;
+
+ if ( sPub.getLength() == 0 && sURL.getLength() == 0 && sReleaseNotes.getLength() == 0 )
// nothing to show
return false;
@@ -1017,7 +1019,7 @@ bool UpdateDialog::showDescription(css::uno::Reference< css::xml::dom::XNode > c
bPublisher = true;
}
- if ( sRel.getLength() > 0 )
+ if ( sReleaseNotes.getLength() > 0 )
{
if ( !bPublisher )
{
@@ -1026,7 +1028,7 @@ bool UpdateDialog::showDescription(css::uno::Reference< css::xml::dom::XNode > c
}
m_ReleaseNotesLabel.Show();
m_ReleaseNotesLink.Show();
- m_ReleaseNotesLink.SetURL( sRel );
+ m_ReleaseNotesLink.SetURL( sReleaseNotes );
}
return true;
}
@@ -1055,6 +1057,16 @@ bool UpdateDialog::showDescription( const String& rDescription, bool bWithPublis
return true;
}
+bool UpdateDialog::isReadOnly( const css::uno::Reference< css::deployment::XPackage > &xPackage ) const
+{
+ if ( m_xExtensionManager.is() && xPackage.is() )
+ {
+ return m_xExtensionManager->isReadOnlyRepository( xPackage->getRepositoryName() );
+ }
+ else
+ return true;
+}
+
IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG)
{
rtl::OUStringBuffer b;
@@ -1074,7 +1086,12 @@ IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG)
const std::vector< UpdateDialog::DisabledUpdate >::size_type sizeDisabled =
m_disabledUpdates.size();
if (pos < sizeEnabled)
- bInserted = showDescription(m_enabledUpdates[pos].aUpdateInfo);
+ {
+ if (m_enabledUpdates[pos].aUpdateSource.is())
+ bInserted = showDescription(m_enabledUpdates[pos].aUpdateSource);
+ else
+ bInserted = showDescription(m_enabledUpdates[pos].aUpdateInfo);
+ }
else if (pos >= sizeEnabled
&& pos < (sizeEnabled + sizeDisabled))
bInserted = showDescription(m_disabledUpdates[pos - sizeEnabled].aUpdateInfo);
@@ -1120,16 +1137,6 @@ IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG)
b.appendAscii(RTL_CONSTASCII_STRINGPARAM(" "));
b.append(m_noDependencyCurVer);
}
- if (!data.permission) {
- if (b.getLength() == 0) {
- b.append(m_noInstall);
- }
- b.append(LF);
- if (isVista())
- b.append(m_noPermissionVista);
- else
- b.append(m_noPermission);
- }
break;
}
case GENERAL_ERROR:
@@ -1233,10 +1240,10 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG)
typedef ::std::vector<UpdateData>::const_iterator CIT;
for (CIT i = m_enabledUpdates.begin(); i < m_enabledUpdates.end(); i++)
{
- OSL_ASSERT(i->aPackageManager.is());
+ OSL_ASSERT(i->aInstalledPackage.is());
//If the user has no write access to the shared folder then the update
//for a shared extension is disable, that is it cannot be in m_enabledUpdates
- OSL_ASSERT(i->aPackageManager->isReadOnly() == sal_False);
+// OSL_ASSERT(isReadOnly(i->aInstalledPackage) == sal_False);
#if 0
// TODO: check!
OSL_ASSERT(m_extensionManagerDialog.get());
@@ -1248,6 +1255,7 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG)
#endif
}
+
for (USHORT i = 0; i < m_updates.getItemCount(); ++i) {
UpdateDialog::Index const * p =
static_cast< UpdateDialog::Index const * >(
@@ -1256,6 +1264,7 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG)
m_updateData.push_back(m_enabledUpdates[p->index.enabledUpdate]);
}
}
+
EndDialog(RET_OK);
return 0;
}
diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx
index 1a8484e2c20f..32c317cb8735 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx
+++ b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx
@@ -60,7 +60,8 @@ class Window;
namespace com { namespace sun { namespace star {
namespace awt { class XThrobber; }
- namespace deployment { class XPackageManager; }
+ namespace deployment { class XExtensionManager;
+ class XPackage; }
namespace uno { class XComponentContext; }
} } }
@@ -82,16 +83,17 @@ public:
@param parent
the parent window, may be null
- @param selectedPackages
- if non-null, only check for updates for the selected packages
-
- @param packageManagers
- if non-null, check for updates for all managed packages
+ @param vExtensionList
+ check for updates for the contained extensions. There must only be one extension with
+ a particular identifier. If one extension is installed in several repositories, then the
+ one with the highest version must be used, because it contains the latest known update
+ information.
*/
UpdateDialog(
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context,
Window * parent,
- const std::vector< dp_gui::TUpdateListEntry > &vExtensionList,
+ const std::vector< com::sun::star::uno::Reference<
+ com::sun::star::deployment::XPackage > > & vExtensionList,
std::vector< dp_gui::UpdateData > * updateData);
~UpdateDialog();
@@ -141,6 +143,7 @@ private:
UpdateDialog & m_dialog;
};
+
friend class CheckListBox;
void insertItem(
@@ -168,9 +171,14 @@ private:
void initDescription();
void clearDescription();
+ bool showDescription(::com::sun::star::uno::Reference<
+ ::com::sun::star::deployment::XPackage > const & aExtension);
+ bool showDescription(std::pair< rtl::OUString, rtl::OUString > const & pairPublisher,
+ rtl::OUString const & sReleaseNotes);
bool showDescription( ::com::sun::star::uno::Reference<
::com::sun::star::xml::dom::XNode > const & aUpdateInfo);
bool showDescription( const String& rDescription, bool bWithPublisher );
+ bool isReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const;
DECL_LINK(selectionHandler, void *);
DECL_LINK(allHandler, void *);
@@ -204,8 +212,6 @@ private:
rtl::OUString m_noInstall;
rtl::OUString m_noDependency;
rtl::OUString m_noDependencyCurVer;
- rtl::OUString m_noPermission;
- rtl::OUString m_noPermissionVista;
rtl::OUString m_browserbased;
rtl::OUString m_version;
std::vector< dp_gui::UpdateData > m_enabledUpdates;
@@ -214,6 +220,7 @@ private:
std::vector< UpdateDialog::SpecificError > m_specificErrors;
std::vector< dp_gui::UpdateData > & m_updateData;
rtl::Reference< UpdateDialog::Thread > m_thread;
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager;
Point m_aFirstLinePos;
Size m_aFirstLineSize;
diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.src b/desktop/source/deployment/gui/dp_gui_updatedialog.src
index b86a8ad66f08..325d98c88d48 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedialog.src
+++ b/desktop/source/deployment/gui/dp_gui_updatedialog.src
@@ -244,18 +244,6 @@ ModalDialog RID_DLG_UPDATE {
String RID_DLG_UPDATE_NODEPENDENCY_CUR_VER {
Text[en-US] = "You have OpenOffice.org %VERSION";
};
- String RID_DLG_UPDATE_NOPERMISSION {
- Text[en-US] = "No write permission (shared extension).";
- };
- String RID_DLG_UPDATE_NOPERMISSION_VISTA {
- Text[en-US] = "No write permission. %PRODUCTNAME needs to run as administrator.\n"
- "Please follow these steps to update this shared extension:\n"
- "1. Close Extension Manager dialog.\n"
- "2. Exit %PRODUCTNAME.\n"
- "3. Exit %PRODUCTNAME Quickstarter located in the tray area of Windows.\n"
- "4. Run %PRODUCTNAME as administrator. In order to do this call the context menu of the %PRODUCTNAME program icon and choose \'Run as administrator\'.\n"
- "5. Call the Extension Manager dialog and update this shared extension.\n";
- };
String RID_DLG_UPDATE_BROWSERBASED {
Text[en-US] = "browser based update";
};
diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx
index 113e6d2069ac..067a703ec413 100644
--- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx
+++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx
@@ -46,6 +46,7 @@
#include "cppuhelper/implbase3.hxx"
#include "com/sun/star/beans/PropertyValue.hpp"
+#include "com/sun/star/beans/NamedValue.hpp"
#include "com/sun/star/xml/dom/XElement.hpp"
#include "com/sun/star/xml/dom/XNode.hpp"
#include "com/sun/star/xml/dom/XNodeList.hpp"
@@ -53,7 +54,8 @@
#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
#include "com/sun/star/ucb/XCommandEnvironment.hpp"
#include "com/sun/star/ucb/XProgressHandler.hpp"
-#include "com/sun/star/deployment/XPackageManager.hpp"
+#include "com/sun/star/deployment/XExtensionManager.hpp"
+#include "com/sun/star/deployment/ExtensionManager.hpp"
#include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
#include "com/sun/star/deployment/DependencyException.hpp"
#include "com/sun/star/deployment/LicenseException.hpp"
@@ -256,6 +258,8 @@ UpdateInstallDialog::UpdateInstallDialog(
{
FreeResource();
+ m_xExtensionManager = css::deployment::ExtensionManager::get( xCtx );
+
m_cancel.SetClickHdl(LINK(this, UpdateInstallDialog, cancelHandler));
m_mle_info.EnableCursor(FALSE);
if ( ! dp_misc::office_is_running())
@@ -376,13 +380,12 @@ void UpdateInstallDialog::Thread::downloadExtensions()
{
UpdateData & curData = *i;
- OSL_ASSERT(curData.aUpdateInfo.is());
+ if (!curData.aUpdateInfo.is() || curData.aUpdateSource.is())
+ continue;
//We assume that m_aVecUpdateData contains only information about extensions which
//can be downloaded directly.
OSL_ASSERT(curData.sWebsiteURL.getLength() == 0);
- if (!curData.aUpdateInfo.is())
- continue;
//update the name of the extension which is to be downloaded
{
::vos::OGuard g(Application::GetSolarMutex());
@@ -487,15 +490,13 @@ void UpdateInstallDialog::Thread::installExtensions()
// osl::Thread::wait(v);
bool bError = false;
bool bLicenseDeclined = false;
- cssu::Reference<css::deployment::XPackage> xPackage;
+ cssu::Reference<css::deployment::XPackage> xExtension;
UpdateData & curData = *i;
cssu::Exception exc;
try
{
- if (curData.sLocalURL.getLength() == 0)
- continue;
cssu::Reference< css::task::XAbortChannel > xAbortChannel(
- curData.aPackageManager->createAbortChannel() );
+ curData.aInstalledPackage->createAbortChannel() );
{
vos::OGuard g(Application::GetSolarMutex());
if (m_stop) {
@@ -503,8 +504,35 @@ void UpdateInstallDialog::Thread::installExtensions()
}
m_abort = xAbortChannel;
}
- xPackage = curData.aPackageManager->addPackage(
- curData.sLocalURL, OUString(), xAbortChannel, m_updateCmdEnv.get());
+ if (!curData.aUpdateSource.is() && curData.sLocalURL.getLength())
+ {
+ css::beans::NamedValue prop(OUSTR("EXTENSION_UPDATE"), css::uno::makeAny(OUSTR("1")));
+ if (!curData.bIsShared)
+ xExtension = m_dialog.getExtensionManager()->addExtension(
+ curData.sLocalURL, css::uno::Sequence<css::beans::NamedValue>(&prop, 1),
+ OUSTR("user"), xAbortChannel, m_updateCmdEnv.get());
+ else
+ xExtension = m_dialog.getExtensionManager()->addExtension(
+ curData.sLocalURL, css::uno::Sequence<css::beans::NamedValue>(&prop, 1),
+ OUSTR("shared"), xAbortChannel, m_updateCmdEnv.get());
+ }
+ else if (curData.aUpdateSource.is())
+ {
+ OSL_ASSERT(curData.aUpdateSource.is());
+ //I am not sure if we should obtain the install properties and pass them into
+ //add extension. Currently it contains only "SUPPRESS_LICENSE". So it it could happen
+ //that a license is displayed when updating from the shared repository, although the
+ //shared extension was installed using "SUPPRESS_LICENSE".
+ css::beans::NamedValue prop(OUSTR("EXTENSION_UPDATE"), css::uno::makeAny(OUSTR("1")));
+ if (!curData.bIsShared)
+ xExtension = m_dialog.getExtensionManager()->addExtension(
+ curData.aUpdateSource->getURL(), css::uno::Sequence<css::beans::NamedValue>(&prop, 1),
+ OUSTR("user"), xAbortChannel, m_updateCmdEnv.get());
+ else
+ xExtension = m_dialog.getExtensionManager()->addExtension(
+ curData.aUpdateSource->getURL(), css::uno::Sequence<css::beans::NamedValue>(&prop, 1),
+ OUSTR("shared"), xAbortChannel, m_updateCmdEnv.get());
+ }
}
catch (css::deployment::DeploymentException & de)
{
@@ -533,7 +561,7 @@ void UpdateInstallDialog::Thread::installExtensions()
m_dialog.setError(UpdateInstallDialog::ERROR_LICENSE_DECLINED,
curData.aInstalledPackage->getDisplayName(), OUString());
}
- else if (!xPackage.is() || bError)
+ else if (!xExtension.is() || bError)
{
::vos::OGuard g(Application::GetSolarMutex());
if (m_stop) {
diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx
index c3d01c8ee6d9..c0e64a8028e8 100644
--- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx
+++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx
@@ -41,6 +41,9 @@
#include "dp_gui_autoscrolledit.hxx"
/// @HTML
+namespace com { namespace sun { namespace star { namespace deployment {
+ class XExtensionManager;
+}}}}
namespace com { namespace sun { namespace star { namespace uno {
class XComponentContext;
}}}}
@@ -102,9 +105,12 @@ private:
};
void setError(INSTALL_ERROR err, ::rtl::OUString const & sExtension, ::rtl::OUString const & exceptionMessage);
void setError(::rtl::OUString const & exceptionMessage);
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > getExtensionManager() const
+ { return m_xExtensionManager; }
rtl::Reference< Thread > m_thread;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xComponentContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager;
//Signals that an error occurred during download and installation
bool m_bError;
bool m_bNoEntry;
diff --git a/desktop/source/deployment/gui/license_dialog.cxx b/desktop/source/deployment/gui/license_dialog.cxx
index 50992eb07a97..9698e257b953 100644
--- a/desktop/source/deployment/gui/license_dialog.cxx
+++ b/desktop/source/deployment/gui/license_dialog.cxx
@@ -116,6 +116,7 @@ struct LicenseDialogImpl : public ModalDialog
LicenseDialogImpl(
Window * pParent,
css::uno::Reference< css::uno::XComponentContext > const & xContext,
+ const ::rtl::OUString & sExtensionName,
const ::rtl::OUString & sLicenseText);
virtual void Activate();
@@ -193,6 +194,7 @@ void LicenseView::Notify( SfxBroadcaster&, const SfxHint& rHint )
LicenseDialogImpl::LicenseDialogImpl(
Window * pParent,
cssu::Reference< cssu::XComponentContext > const & xContext,
+ const ::rtl::OUString & sExtensionName,
const ::rtl::OUString & sLicenseText):
ModalDialog(pParent, DpGuiResId(RID_DLG_LICENSE))
,m_xComponentContext(xContext)
@@ -225,6 +227,7 @@ LicenseDialogImpl::LicenseDialogImpl(
m_fiArrow1.Show(true);
m_fiArrow2.Show(false);
m_mlLicense.SetText(sLicenseText);
+ m_ftHead.SetText(m_ftHead.GetText() + OUString('\n') + sExtensionName);
m_mlLicense.SetEndReachedHdl( LINK(this, LicenseDialogImpl, EndReachedHdl) );
m_mlLicense.SetScrolledHdl( LINK(this, LicenseDialogImpl, ScrolledHdl) );
@@ -296,7 +299,7 @@ LicenseDialog::LicenseDialog( Sequence<Any> const& args,
Reference<XComponentContext> const& xComponentContext)
: m_xComponentContext(xComponentContext)
{
- comphelper::unwrapArgs( args, m_parent, m_sLicenseText );
+ comphelper::unwrapArgs( args, m_parent, m_sExtensionName, m_sLicenseText );
}
// XExecutableDialog
@@ -315,8 +318,10 @@ sal_Int16 LicenseDialog::execute() throw (RuntimeException)
sal_Int16 LicenseDialog::solar_execute()
{
- std::auto_ptr<LicenseDialogImpl> dlg(new LicenseDialogImpl(
- VCLUnoHelper::GetWindow(m_parent), m_xComponentContext, m_sLicenseText));
+ std::auto_ptr<LicenseDialogImpl> dlg(
+ new LicenseDialogImpl(
+ VCLUnoHelper::GetWindow(m_parent),
+ m_xComponentContext, m_sExtensionName, m_sLicenseText));
return dlg->Execute();
}
diff --git a/desktop/source/deployment/gui/license_dialog.hxx b/desktop/source/deployment/gui/license_dialog.hxx
index 4733922dc607..bb4a6b6646c8 100644
--- a/desktop/source/deployment/gui/license_dialog.hxx
+++ b/desktop/source/deployment/gui/license_dialog.hxx
@@ -48,6 +48,7 @@ class LicenseDialog
{
Reference<XComponentContext> const m_xComponentContext;
Reference<awt::XWindow> /* const */ m_parent;
+ OUString m_sExtensionName;
OUString /* const */ m_sLicenseText;
OUString m_initialTitle;
diff --git a/desktop/source/deployment/inc/dp_descriptioninfoset.hxx b/desktop/source/deployment/inc/dp_descriptioninfoset.hxx
index e58ff1e71acd..37e616bb1a0b 100644
--- a/desktop/source/deployment/inc/dp_descriptioninfoset.hxx
+++ b/desktop/source/deployment/inc/dp_descriptioninfoset.hxx
@@ -62,6 +62,7 @@ struct DESKTOP_DEPLOYMENTMISC_DLLPUBLIC SimpleLicenseAttributes
bool suppressIfRequired;
};
+
/**
Access to the content of an XML <code>description</code> element.
@@ -216,6 +217,8 @@ public:
*/
::rtl::OUString getIconURL( sal_Bool bHighContrast ) const;
+ bool hasDescription() const;
+
private:
SAL_DLLPRIVATE ::boost::optional< ::rtl::OUString > getOptionalValue(
::rtl::OUString const & expression) const;
@@ -279,6 +282,18 @@ private:
::com::sun::star::xml::xpath::XXPathAPI > m_xpath;
};
+inline bool DescriptionInfoset::hasDescription() const
+{
+ return m_element.is();
+}
+
+/** creates a DescriptionInfoset object.
+
+ The argument sExtensionFolderURL is a file URL to extension folder containing
+ the description.xml.
+ */
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+DescriptionInfoset getDescriptionInfoset(::rtl::OUString const & sExtensionFolderURL);
}
#endif
diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h
index a717e7797c8a..61e3fcc45418 100644
--- a/desktop/source/deployment/inc/dp_misc.h
+++ b/desktop/source/deployment/inc/dp_misc.h
@@ -36,6 +36,7 @@
#include "com/sun/star/lang/XComponent.hpp"
#include "com/sun/star/lang/DisposedException.hpp"
#include "com/sun/star/deployment/XPackageRegistry.hpp"
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
#include "com/sun/star/awt/XWindow.hpp"
#include "dp_misc_api.hxx"
@@ -69,14 +70,33 @@ inline void try_dispose( ::com::sun::star::uno::Reference< ::com::sun::star::uno
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
::rtl::OUString expandUnoRcTerm( ::rtl::OUString const & term );
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+::rtl::OUString makeRcTerm( ::rtl::OUString const & url );
+
//==============================================================================
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
::rtl::OUString expandUnoRcUrl( ::rtl::OUString const & url );
//==============================================================================
+
+/** appends a relative path to a url.
+
+ The relative path must already be correctly encoded for use in an URL.
+ If the URL starts with vnd.sun.star.expand then the relative path will
+ be again encoded for use in an "expand" URL.
+ */
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString makeURL(
::rtl::OUString const & baseURL, ::rtl::OUString const & relPath );
+
+/** appends a relative path to a url.
+
+ This is the same as makeURL, but the relative Path must me a segment
+ of an system path.
+ */
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString makeURLAppendSysPathSegment(
+ ::rtl::OUString const & baseURL, ::rtl::OUString const & relPath );
+
//==============================================================================
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString generateRandomPipeId();
@@ -97,11 +117,6 @@ oslProcess raiseProcess( ::rtl::OUString const & appURL,
::com::sun::star::uno::Sequence< ::rtl::OUString > const & args );
//==============================================================================
-/** returns the default update URL (for the update information) which
- is used when an extension does not provide its own URL.
-*/
-DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
-::rtl::OUString getExtensionDefaultUpdateURL();
/** writes the argument string to the console.
On Linux/Unix/etc. it converts the UTF16 string to an ANSI string using
@@ -151,6 +166,14 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
void TRACE(::rtl::OUString const & sText);
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
void TRACE(::rtl::OString const & sText);
+
+/** registers or revokes shared or bundled extensions which have been
+ recently added or removed.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+void syncRepositories(::com::sun::star::uno::Reference<
+ ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv);
+
}
#endif
diff --git a/desktop/source/deployment/inc/dp_ucb.h b/desktop/source/deployment/inc/dp_ucb.h
index 6f9127504860..03144388e8a8 100644
--- a/desktop/source/deployment/inc/dp_ucb.h
+++ b/desktop/source/deployment/inc/dp_ucb.h
@@ -28,6 +28,7 @@
#if ! defined INCLUDED_DP_UCB_H
#define INCLUDED_DP_UCB_H
+#include <list>
#include "rtl/byteseq.hxx"
#include "rtl/instance.hxx"
#include "com/sun/star/ucb/XCommandEnvironment.hpp"
@@ -79,6 +80,12 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
bool readLine( ::rtl::OUString * res, ::rtl::OUString const & startingWith,
::ucbhelper::Content & ucb_content, rtl_TextEncoding textenc );
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+bool readProperties( ::std::list< ::std::pair< ::rtl::OUString, ::rtl::OUString> > & out_result,
+ ::ucbhelper::Content & ucb_content);
+
+
+
}
#endif
diff --git a/desktop/source/deployment/inc/dp_update.hxx b/desktop/source/deployment/inc/dp_update.hxx
new file mode 100755
index 000000000000..01511b1f2d21
--- /dev/null
+++ b/desktop/source/deployment/inc/dp_update.hxx
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_UPDATE_HXX
+#define INCLUDED_DP_UPDATE_HXX
+
+
+#include "com/sun/star/deployment/XPackage.hpp"
+#include "com/sun/star/deployment/XExtensionManager.hpp"
+#include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/xml/dom/XNode.hpp"
+
+#include "rtl/ustrbuf.hxx"
+#include "dp_misc_api.hxx"
+
+#include <map>
+#include <vector>
+
+namespace dp_misc {
+
+/** returns the default update URL (for the update information) which
+ is used when an extension does not provide its own URL.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+::rtl::OUString getExtensionDefaultUpdateURL();
+
+enum UPDATE_SOURCE
+{
+ UPDATE_SOURCE_NONE,
+ UPDATE_SOURCE_SHARED,
+ UPDATE_SOURCE_BUNDLED,
+ UPDATE_SOURCE_ONLINE
+};
+
+/* determine if an update is available which is installed in the
+ user repository.
+
+ If the return value is UPDATE_SOURCE_NONE, then no update is
+ available, otherwise the return value determine from which the
+ repository the update is used.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+UPDATE_SOURCE isUpdateUserExtension(
+ bool bReadOnlyShared,
+ ::rtl::OUString const & userVersion,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion);
+
+/* determine if an update is available which is installed in the
+ shared repository.
+
+ If the return value is UPDATE_SOURCE_NONE, then no update is
+ available, otherwise the return value determine from which the
+ repository the update is used.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+UPDATE_SOURCE isUpdateSharedExtension(
+ bool bReadOnlyShared,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion);
+
+/* determines the extension with the highest identifier and returns it
+
+ */
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage>
+getExtensionWithHighestVersion(
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId);
+
+
+struct UpdateInfo
+{
+ UpdateInfo( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & ext);
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::deployment::XPackage> extension;
+//version of the update
+ ::rtl::OUString version;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > info;
+};
+
+typedef std::map< ::rtl::OUString, UpdateInfo > UpdateInfoMap;
+
+/*
+ @param extensionList
+ List of extension for which online update information are to be obtained. If NULL, then
+ for update information are obtained for all installed extension. There may be only one extension
+ with a particular identifier contained in the list. If one extension is installed
+ in several repositories, then the one with the highest version must be used, because it contains
+ the more recent URLs for getting the update information (if at all).
+ @param out_errors
+ the first member of the pair is the extension and the second the exception that was produced
+ when processing the extension.
+
+ @return
+ A map of UpdateInfo instances. If the parameter extensionList was given, then the map contains
+ at only information for those extensions.
+ */
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+UpdateInfoMap getOnlineUpdateInfos(
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const &xContext,
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager> const & xExtMgr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XUpdateInformationProvider > const & updateInformation,
+ std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > const * extensionList,
+ ::std::vector< ::std::pair< ::com::sun::star::uno::Reference<
+ ::com::sun::star::deployment::XPackage>, ::com::sun::star::uno::Any> > & out_errors);
+
+/* retunrs the highest version from the provided arguments.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+::rtl::OUString getHighestVersion(
+ ::rtl::OUString const & userVersion,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion);
+
+}
+
+#endif
diff --git a/desktop/source/deployment/inc/dp_version.hxx b/desktop/source/deployment/inc/dp_version.hxx
index 9808ebaab388..c459333f97a9 100644
--- a/desktop/source/deployment/inc/dp_version.hxx
+++ b/desktop/source/deployment/inc/dp_version.hxx
@@ -43,13 +43,6 @@ enum Order { LESS, EQUAL, GREATER };
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Order compareVersions(
::rtl::OUString const & version1, ::rtl::OUString const & version2);
-
-DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Order comparePackageVersions(
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage >
- const & package1,
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage >
- const & package2);
-
}
#endif
diff --git a/desktop/source/deployment/makefile.mk b/desktop/source/deployment/makefile.mk
index 173ff35bec1d..6d83a5c1004b 100644
--- a/desktop/source/deployment/makefile.mk
+++ b/desktop/source/deployment/makefile.mk
@@ -53,7 +53,6 @@ SHL1VERSIONMAP = $(SOLARENV)/src/component.map
SHL1LIBS = \
$(SLB)$/deployment_manager.lib \
- $(SLB)$/deployment_migration.lib \
$(SLB)$/deployment_registry.lib \
$(SLB)$/deployment_registry_executable.lib \
$(SLB)$/deployment_registry_component.lib \
diff --git a/desktop/source/deployment/manager/dp_activepackages.cxx b/desktop/source/deployment/manager/dp_activepackages.cxx
index 04dc22b77a77..8f6b6b82c0b7 100644
--- a/desktop/source/deployment/manager/dp_activepackages.cxx
+++ b/desktop/source/deployment/manager/dp_activepackages.cxx
@@ -96,9 +96,27 @@ static char const legacyPrefix[] = "org.openoffice.legacy.";
OSL_ASSERT(i2 >= 0);
d.fileName = ::rtl::OUString(
value.getStr() + i1 + 1, i2 - i1 - 1, RTL_TEXTENCODING_UTF8);
- d.mediaType = ::rtl::OUString(
- value.getStr() + i2 + 1, value.getLength() - i2 - 1,
- RTL_TEXTENCODING_UTF8);
+ sal_Int32 i3 = value.indexOf(separator, i2 + 1);
+
+ if (i3 < 0)
+ {
+ //Before ActivePackages::Data::version was added
+ d.mediaType = ::rtl::OUString(
+ value.getStr() + i2 + 1, value.getLength() - i2 - 1,
+ RTL_TEXTENCODING_UTF8);
+ }
+ else
+ {
+ sal_Int32 i4 = value.indexOf(separator, i3 + 1);
+ d.mediaType = ::rtl::OUString(
+ value.getStr() + i2 + 1, i3 - i2 -1, RTL_TEXTENCODING_UTF8);
+ d.version = ::rtl::OUString(
+ value.getStr() + i3 + 1, i4 - i3 - 1,
+ RTL_TEXTENCODING_UTF8);
+ d.failedPrerequisites = ::rtl::OUString(
+ value.getStr() + i4 + 1, value.getLength() - i4 - 1,
+ RTL_TEXTENCODING_UTF8);
+ }
return d;
}
@@ -172,6 +190,10 @@ void ActivePackages::put(::rtl::OUString const & id, Data const & data) {
b.append(::rtl::OUStringToOString(data.fileName, RTL_TEXTENCODING_UTF8));
b.append(separator);
b.append(::rtl::OUStringToOString(data.mediaType, RTL_TEXTENCODING_UTF8));
+ b.append(separator);
+ b.append(::rtl::OUStringToOString(data.version, RTL_TEXTENCODING_UTF8));
+ b.append(separator);
+ b.append(::rtl::OUStringToOString(data.failedPrerequisites, RTL_TEXTENCODING_UTF8));
m_map.put(newKey(id), b.makeStringAndClear());
}
diff --git a/desktop/source/deployment/manager/dp_activepackages.hxx b/desktop/source/deployment/manager/dp_activepackages.hxx
index 1c58f76be245..7d9c7e32cfb4 100644
--- a/desktop/source/deployment/manager/dp_activepackages.hxx
+++ b/desktop/source/deployment/manager/dp_activepackages.hxx
@@ -42,9 +42,28 @@ namespace dp_manager {
class ActivePackages {
public:
struct Data {
+ Data(): failedPrerequisites(::rtl::OUString::valueOf((sal_Int32)0))
+ {}
+ /* name of the temporary file (shared, user extension) or the name of
+ the folder of the bundled extension.
+ It does not contain the trailing '_' of the folder.
+ UTF-8 encoded
+ */
::rtl::OUString temporaryName;
+ /* The file name (shared, user) or the folder name (bundled)
+ If the key is the file name, then file name is not encoded.
+ If the key is the idendifier then the file name is UTF-8 encoded.
+ */
::rtl::OUString fileName;
::rtl::OUString mediaType;
+ ::rtl::OUString version;
+ /* If this string contains the value according to
+ com::sun::star::deployment::Prerequisites or "0". That is, if
+ the value is > 0 then
+ the call to XPackage::checkPrerequisites failed.
+ In this case the extension must not be registered.
+ */
+ ::rtl::OUString failedPrerequisites;
};
typedef ::std::vector< ::std::pair< ::rtl::OUString, Data > > Entries;
diff --git a/desktop/source/deployment/manager/dp_commandenvironments.cxx b/desktop/source/deployment/manager/dp_commandenvironments.cxx
new file mode 100644
index 000000000000..c2801ba1d965
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_commandenvironments.cxx
@@ -0,0 +1,286 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "com/sun/star/deployment/VersionException.hpp"
+#include "com/sun/star/deployment/LicenseException.hpp"
+#include "com/sun/star/deployment/InstallException.hpp"
+#include "com/sun/star/task/XInteractionApprove.hpp"
+#include "com/sun/star/task/XInteractionAbort.hpp"
+#include "com/sun/star/task/XInteractionHandler.hpp"
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "dp_commandenvironments.hxx"
+
+namespace deployment = com::sun::star::deployment;
+namespace lang = com::sun::star::lang;
+namespace task = com::sun::star::task;
+namespace ucb = com::sun::star::ucb;
+namespace uno = com::sun::star::uno;
+namespace css = com::sun::star;
+
+#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+using ::com::sun::star::uno::Reference;
+using ::rtl::OUString;
+
+namespace dp_manager {
+
+BaseCommandEnv::BaseCommandEnv()
+{
+}
+
+BaseCommandEnv::BaseCommandEnv(
+ Reference< task::XInteractionHandler> const & handler)
+ : m_forwardHandler(handler)
+{
+}
+
+BaseCommandEnv::~BaseCommandEnv()
+{
+}
+// XCommandEnvironment
+//______________________________________________________________________________
+Reference<task::XInteractionHandler> BaseCommandEnv::getInteractionHandler()
+throw (uno::RuntimeException)
+{
+ return this;
+}
+
+//______________________________________________________________________________
+Reference<ucb::XProgressHandler> BaseCommandEnv::getProgressHandler()
+throw (uno::RuntimeException)
+{
+ return this;
+}
+
+void BaseCommandEnv::handle(
+ Reference< task::XInteractionRequest> const & /*xRequest*/ )
+ throw (uno::RuntimeException)
+{
+}
+
+void BaseCommandEnv::handle_(bool approve, bool abort,
+ Reference< task::XInteractionRequest> const & xRequest )
+{
+ if (approve == false && abort == false)
+ {
+ //not handled so far -> forwarding
+ if (m_forwardHandler.is())
+ m_forwardHandler->handle(xRequest);
+ else
+ return; //cannot handle
+ }
+ else
+ {
+ // 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) {
+ 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) {
+ 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 BaseCommandEnv::push( uno::Any const & /*Status*/ )
+throw (uno::RuntimeException)
+{
+}
+
+
+void BaseCommandEnv::update( uno::Any const & /*Status */)
+throw (uno::RuntimeException)
+{
+}
+
+void BaseCommandEnv::pop() throw (uno::RuntimeException)
+{
+}
+//==============================================================================
+
+TmpRepositoryCommandEnv::TmpRepositoryCommandEnv()
+{
+}
+
+TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(
+ css::uno::Reference< css::task::XInteractionHandler> const & handler):
+ BaseCommandEnv(handler)
+{
+}
+// XInteractionHandler
+void TmpRepositoryCommandEnv::handle(
+ Reference< task::XInteractionRequest> const & xRequest )
+ throw (uno::RuntimeException)
+{
+ uno::Any request( xRequest->getRequest() );
+ OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
+
+ deployment::VersionException verExc;
+ deployment::LicenseException licExc;
+ deployment::InstallException instExc;
+
+ bool approve = false;
+ bool abort = false;
+
+ if ((request >>= verExc)
+ || (request >>= licExc)
+ || (request >>= instExc))
+ {
+ approve = true;
+ }
+
+ handle_(approve, abort, xRequest);
+}
+//================================================================================
+
+LicenseCommandEnv::LicenseCommandEnv(
+ css::uno::Reference< css::task::XInteractionHandler> const & handler,
+ bool bSuppressLicense,
+ OUString const & repository):
+ BaseCommandEnv(handler), m_repository(repository),
+ m_bSuppressLicense(bSuppressLicense)
+{
+}
+// XInteractionHandler
+void LicenseCommandEnv::handle(
+ Reference< task::XInteractionRequest> const & xRequest )
+ throw (uno::RuntimeException)
+{
+ uno::Any request( xRequest->getRequest() );
+ OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
+
+
+ deployment::LicenseException licExc;
+
+ bool approve = false;
+ bool abort = false;
+
+ if (request >>= licExc)
+ {
+ if (m_bSuppressLicense
+ || m_repository.equals(OUSTR("bundled"))
+ || licExc.AcceptBy.equals(OUSTR("admin")))
+ {
+ //always approve in bundled case, because we do not support
+ //showing licenses anyway.
+ //The "admin" already accepted the license when installing the
+ // shared extension
+ approve = true;
+ }
+ }
+
+ handle_(approve, abort, xRequest);
+}
+
+//================================================================================
+//================================================================================
+
+NoLicenseCommandEnv::NoLicenseCommandEnv(
+ css::uno::Reference< css::task::XInteractionHandler> const & handler):
+ BaseCommandEnv(handler)
+{
+}
+// XInteractionHandler
+void NoLicenseCommandEnv::handle(
+ Reference< task::XInteractionRequest> const & xRequest )
+ throw (uno::RuntimeException)
+{
+ uno::Any request( xRequest->getRequest() );
+ OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
+
+
+ deployment::LicenseException licExc;
+
+ bool approve = false;
+ bool abort = false;
+
+ if (request >>= licExc)
+ {
+ approve = true;
+ }
+ handle_(approve, abort, xRequest);
+}
+
+
+// NoExceptionCommandEnv::NoExceptionCommandEnv(
+// css::uno::Reference< css::task::XInteractionHandler> const & handler,
+// css::uno::Type const & type):
+// BaseCommandEnv(handler),
+// m_type(type)
+// {
+// }
+// // XInteractionHandler
+// void NoExceptionCommandEnv::handle(
+// Reference< task::XInteractionRequest> const & xRequest )
+// throw (uno::RuntimeException)
+// {
+// uno::Any request( xRequest->getRequest() );
+// OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
+
+
+// deployment::LicenseException licExc;
+
+// bool approve = false;
+// bool abort = false;
+
+// if (request.getValueType() == m_type)
+// {
+// approve = true;
+// }
+// handle_(approve, abort, xRequest);
+// }
+
+
+
+} // namespace dp_manager
+
+
diff --git a/desktop/source/deployment/manager/dp_commandenvironments.hxx b/desktop/source/deployment/manager/dp_commandenvironments.hxx
new file mode 100644
index 000000000000..aa21f8281c72
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_commandenvironments.hxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_COMMANDENVIRONMENTS_HXX
+#define INCLUDED_DP_COMMANDENVIRONMENTS_HXX
+
+
+#include "cppuhelper/compbase3.hxx"
+//#include "cppuhelper/implbase2.hxx"
+#include "ucbhelper/content.hxx"
+#include "com/sun/star/uno/Type.hxx"
+
+
+namespace css = ::com::sun::star;
+
+namespace dp_manager {
+
+
+
+/**
+ This command environment is to be used when an extension is temporarily
+ stored in the "tmp" repository. It prevents all kind of user interaction.
+ */
+class BaseCommandEnv
+ : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment,
+ css::task::XInteractionHandler,
+ css::ucb::XProgressHandler >
+{
+protected:
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler;
+
+ void handle_(bool approve, bool abort,
+ css::uno::Reference< css::task::XInteractionRequest> const & xRequest );
+public:
+ virtual ~BaseCommandEnv();
+ BaseCommandEnv();
+ BaseCommandEnv(
+ css::uno::Reference< css::task::XInteractionHandler> const & handler);
+
+ // XCommandEnvironment
+ virtual css::uno::Reference<css::task::XInteractionHandler > SAL_CALL
+ getInteractionHandler() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference<css::ucb::XProgressHandler >
+ SAL_CALL getProgressHandler() throw (css::uno::RuntimeException);
+
+ // XInteractionHandler
+ virtual void SAL_CALL handle(
+ css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (css::uno::RuntimeException);
+
+ // XProgressHandler
+ virtual void SAL_CALL push( css::uno::Any const & Status )
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL update( css::uno::Any const & Status )
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL pop() throw (css::uno::RuntimeException);
+};
+
+class TmpRepositoryCommandEnv : public BaseCommandEnv
+{
+public:
+ TmpRepositoryCommandEnv();
+ TmpRepositoryCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler);
+
+// XInteractionHandler
+ virtual void SAL_CALL handle(
+ css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (css::uno::RuntimeException);
+
+};
+
+/** this class is for use in XPackageManager::synchronize.
+
+ It handles particular license cases.
+ */
+class LicenseCommandEnv : public BaseCommandEnv
+{
+private:
+ ::rtl::OUString m_repository;
+ bool m_bSuppressLicense;
+public:
+ LicenseCommandEnv(){};
+ LicenseCommandEnv(
+ css::uno::Reference< css::task::XInteractionHandler> const & handler,
+ bool bSuppressLicense,
+ ::rtl::OUString const & repository);
+
+// XInteractionHandler
+ virtual void SAL_CALL handle(
+ css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (css::uno::RuntimeException);
+
+};
+
+/** this class is for use in XPackageManager::checkPrerequisites
+
+ It always prohibits a license interaction
+ */
+class NoLicenseCommandEnv : public BaseCommandEnv
+{
+
+public:
+ NoLicenseCommandEnv(){};
+ NoLicenseCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler);
+
+// XInteractionHandler
+ virtual void SAL_CALL handle(
+ css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (css::uno::RuntimeException);
+
+};
+
+// class NoExceptionCommandEnv : public BaseCommandEnv
+// {
+// css::uno::Type m_type;
+// public:
+// NoExceptionCommandEnv::NoExceptionCommandEnv(){};
+// NoExceptionCommandEnv::NoExceptionCommandEnv(
+// css::uno::Reference< css::task::XInteractionHandler> const & handler,
+// css::uno::Type const & type);
+
+// // XInteractionHandler
+// virtual void SAL_CALL handle(
+// css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+// throw (css::uno::RuntimeException);
+
+// };
+
+}
+
+
+
+
+#endif
+
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx
new file mode 100644
index 000000000000..de9d97db2b48
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx
@@ -0,0 +1,1361 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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/implbase1.hxx>
+
+#include "comphelper/servicedecl.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "rtl/bootstrap.hxx"
+#include "com/sun/star/deployment/ExtensionManager.hpp"
+#include "com/sun/star/deployment/XExtensionManager.hpp"
+#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
+#include "com/sun/star/deployment/XPackageManager.hpp"
+#include "com/sun/star/deployment/XPackageManagerFactory.hpp"
+#include "com/sun/star/deployment/XPackage.hpp"
+#include "com/sun/star/deployment/InstallException.hpp"
+#include "com/sun/star/deployment/VersionException.hpp"
+#include "com/sun/star/deployment/LicenseException.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/registry/XRegistryKey.hpp"
+#include "com/sun/star/beans/Optional.hpp"
+#include "com/sun/star/task/XInteractionApprove.hpp"
+#include "com/sun/star/beans/Ambiguous.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/io/XInputStream.hpp"
+#include "com/sun/star/util/XModifyBroadcaster.hpp"
+#include "comphelper/sequence.hxx"
+#include "xmlscript/xml_helper.hxx"
+#include "osl/diagnose.h"
+#include "dp_interact.h"
+#include "dp_resource.h"
+#include "dp_ucb.h"
+#include "dp_identifier.hxx"
+#include "dp_descriptioninfoset.hxx"
+#include "dp_extensionmanager.hxx"
+#include "dp_commandenvironments.hxx"
+#include "dp_properties.hxx"
+#include "boost/bind.hpp"
+
+#include <list>
+#include <hash_map>
+#include <algorithm>
+
+namespace deploy = com::sun::star::deployment;
+namespace lang = com::sun::star::lang;
+namespace registry = com::sun::star::registry;
+namespace task = com::sun::star::task;
+namespace ucb = com::sun::star::ucb;
+namespace uno = com::sun::star::uno;
+namespace beans = com::sun::star::beans;
+namespace util = com::sun::star::util;
+namespace css = com::sun::star;
+
+
+//#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+using ::com::sun::star::uno::Reference;
+using ::rtl::OUString;
+
+namespace {
+
+struct CompIdentifiers
+{
+ bool operator() (::std::vector<Reference<deploy::XPackage> > const & a,
+ ::std::vector<Reference<deploy::XPackage> > const & b)
+ {
+
+ if (getName(a).compareTo(getName(b)) < 0)
+ return true;
+ return false;
+ }
+
+ OUString getName(::std::vector<Reference<deploy::XPackage> > const & a);
+};
+
+OUString CompIdentifiers::getName(::std::vector<Reference<deploy::XPackage> > const & a)
+{
+ OSL_ASSERT(a.size() == 3);
+ //get the first non-null reference
+ Reference<deploy::XPackage> extension;
+ ::std::vector<Reference<deploy::XPackage> >::const_iterator it = a.begin();
+ for (; it != a.end(); it++)
+ {
+ if (it->is())
+ {
+ extension = *it;
+ break;
+ }
+ }
+ OSL_ASSERT(extension.is());
+ return extension->getDisplayName();
+}
+
+void writeLastModified(OUString & url, Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+{
+ //Write the lastmodified file
+ try {
+ ::rtl::Bootstrap::expandMacros(url);
+ ::ucbhelper::Content ucbStamp(url, xCmdEnv );
+ dp_misc::erase_path( url, xCmdEnv );
+ ::rtl::OString stamp("1" );
+ Reference<css::io::XInputStream> xData(
+ ::xmlscript::createInputStream(
+ ::rtl::ByteSequence(
+ reinterpret_cast<sal_Int8 const *>(stamp.getStr()),
+ stamp.getLength() ) ) );
+ ucbStamp.writeStream( xData, true /* replace existing */ );
+ }
+ catch(...)
+ {
+ uno::Any exc(::cppu::getCaughtException());
+ throw deploy::DeploymentException(
+ OUSTR("Failed to update") + url, 0, exc);
+ }
+}
+} //end namespace
+
+namespace dp_manager {
+
+
+
+//------------------------------------------------------------------------------
+
+//ToDo: bundled extension
+ExtensionManager::ExtensionManager( Reference< uno::XComponentContext > const& xContext) :
+ ::cppu::WeakComponentImplHelper1< css::deployment::XExtensionManager >(getMutex()),
+ m_xContext( xContext )
+{
+ Reference<deploy::XPackageManagerFactory> xPackageManagerFactory(
+ deploy::thePackageManagerFactory::get(m_xContext));
+ m_userRepository = xPackageManagerFactory->getPackageManager(OUSTR("user"));
+ m_sharedRepository = xPackageManagerFactory->getPackageManager(OUSTR("shared"));
+ m_bundledRepository = xPackageManagerFactory->getPackageManager(OUSTR("bundled"));
+ m_tmpRepository = xPackageManagerFactory->getPackageManager(OUSTR("tmp"));
+
+ m_repositoryNames.push_back(OUSTR("user"));
+ m_repositoryNames.push_back(OUSTR("shared"));
+ m_repositoryNames.push_back(OUSTR("bundled"));
+}
+
+//------------------------------------------------------------------------------
+
+ExtensionManager::~ExtensionManager()
+{
+}
+
+Reference<task::XAbortChannel> ExtensionManager::createAbortChannel()
+ throw (uno::RuntimeException)
+{
+ return new dp_misc::AbortChannel;
+}
+
+css::uno::Reference<css::deployment::XPackageManager>
+ExtensionManager::getPackageManager(::rtl::OUString const & repository)
+ throw (css::lang::IllegalArgumentException)
+{
+ Reference<deploy::XPackageManager> xPackageManager;
+ if (repository.equals(OUSTR("user")))
+ xPackageManager = m_userRepository;
+ else if (repository.equals(OUSTR("shared")))
+ xPackageManager = m_sharedRepository;
+ else if (repository.equals(OUSTR("bundled")))
+ xPackageManager = m_bundledRepository;
+ else
+ throw lang::IllegalArgumentException(
+ OUSTR("No valid repository name provided."),
+ static_cast<cppu::OWeakObject*>(this), 0);
+ return xPackageManager;
+}
+
+
+/*
+ Enters the XPackage objects into a map. They must be all from the
+ same repository. The value type of the map is a vector, where each vector
+ represents an extension with a particular identifier. The first member
+ is represents the user extension, the second the shared extension and the
+ third the bundled extension.
+ */
+void ExtensionManager::addExtensionsToMap(
+ id2extensions & mapExt,
+ uno::Sequence<Reference<deploy::XPackage> > const & seqExt,
+ OUString const & repository)
+{
+ //Determine the index in the vector where these extensions are to be
+ //added.
+ ::std::list<OUString>::const_iterator citNames =
+ m_repositoryNames.begin();
+ int index = 0;
+ for (;citNames != m_repositoryNames.end(); citNames++, index++)
+ {
+ if (citNames->equals(repository))
+ break;
+ }
+
+ for (int i = 0; i < seqExt.getLength(); i++)
+ {
+ Reference<deploy::XPackage> const & xExtension = seqExt[i];
+ OUString id = dp_misc::getIdentifier(xExtension);
+ id2extensions::iterator ivec = mapExt.find(id);
+ if (ivec == mapExt.end())
+ {
+ ::std::vector<Reference<deploy::XPackage> > vec(3);
+ vec[index] = xExtension;
+ mapExt[id] = vec;
+ }
+ else
+ {
+ ivec->second[index] = xExtension;
+ }
+ }
+}
+
+/*
+ returns a list containing extensions with the same identifier from
+ all repositories (user, shared, bundled) If one repository does not
+ have this extension, then the list contains an empty Referenc. The list
+ is ordered according to the priority of the repostories:
+ 1. user
+ 2. shared
+ 3. bundled
+
+ The number of elements is always three, unless the number of repository
+ changes.
+ */
+::std::list<Reference<deploy::XPackage> >
+ ExtensionManager::getExtensionsWithSameId(
+ OUString const & identifier, OUString const & fileName,
+ Reference< ucb::XCommandEnvironment> const & /*xCmdEnv*/)
+
+{
+ ::std::list<Reference<deploy::XPackage> > extensionList;
+ try
+ { //will throw an exception if the extension does not exist
+ extensionList.push_back(m_userRepository->getDeployedPackage(
+ identifier, fileName, Reference<ucb::XCommandEnvironment>()));
+ } catch(lang::IllegalArgumentException &)
+ {
+ extensionList.push_back(Reference<deploy::XPackage>());
+ }
+ try
+ {
+ extensionList.push_back(m_sharedRepository->getDeployedPackage(
+ identifier, fileName, Reference<ucb::XCommandEnvironment>()));
+ } catch (lang::IllegalArgumentException &)
+ {
+ extensionList.push_back(Reference<deploy::XPackage>());
+ }
+ try
+ {
+ extensionList.push_back(m_bundledRepository->getDeployedPackage(
+ identifier, fileName, Reference<ucb::XCommandEnvironment>()));
+ } catch (lang::IllegalArgumentException &)
+ {
+ extensionList.push_back(Reference<deploy::XPackage>());
+ }
+ OSL_ASSERT(extensionList.size() == 3);
+ return extensionList;
+}
+
+uno::Sequence<Reference<deploy::XPackage> >
+ExtensionManager::getExtensionsWithSameIdentifier(
+ OUString const & identifier,
+ OUString const & fileName,
+ Reference< ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (
+ deploy::DeploymentException,
+ ucb::CommandFailedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ try
+ {
+ ::std::list<Reference<deploy::XPackage> > listExtensions =
+ getExtensionsWithSameId(
+ identifier, fileName, xCmdEnv);
+ sal_Bool bHasExtension = false;
+
+ //throw an IllegalArgumentException if there is no extension at all.
+ typedef ::std::list<Reference<deploy::XPackage> >::const_iterator CIT;
+ for (CIT i = listExtensions.begin(); i != listExtensions.end(); i++)
+ bHasExtension |= i->is();
+ if (!bHasExtension)
+ throw lang::IllegalArgumentException(
+ OUSTR("Could not find extension: ") + identifier + OUSTR(", ") + fileName,
+ static_cast<cppu::OWeakObject*>(this), -1);
+
+ return comphelper::containerToSequence<
+ Reference<deploy::XPackage>,
+ ::std::list<Reference<deploy::XPackage> >
+ > (listExtensions);
+ }
+ catch (deploy::DeploymentException & )
+ {
+ throw;
+ }
+ catch ( ucb::CommandFailedException & )
+ {
+ throw;
+ }
+ catch (lang::IllegalArgumentException &)
+ {
+ throw;
+ }
+ catch (...)
+ {
+ uno::Any exc = ::cppu::getCaughtException();
+ throw deploy::DeploymentException(
+ OUSTR("Extension Manager: exception during getExtensionsWithSameIdentifier"),
+ static_cast<OWeakObject*>(this), exc);
+ }
+}
+
+
+
+bool ExtensionManager::isUserDisabled(
+ OUString const & identifier, OUString const & fileName)
+{
+ ::std::list<Reference<deploy::XPackage> > listExtensions;
+
+ try {
+ listExtensions = getExtensionsWithSameId(identifier, fileName);
+ } catch (lang::IllegalArgumentException & ) {
+ }
+ OSL_ASSERT(listExtensions.size() == 3);
+
+ return isUserDisabled( ::comphelper::containerToSequence<
+ Reference<deploy::XPackage>,
+ ::std::list<Reference<deploy::XPackage> >
+ > (listExtensions));
+}
+
+bool ExtensionManager::isUserDisabled(
+ uno::Sequence<Reference<deploy::XPackage> > const & seqExtSameId)
+{
+ OSL_ASSERT(seqExtSameId.getLength() == 3);
+ Reference<deploy::XPackage> const & userExtension = seqExtSameId[0];
+ if (userExtension.is())
+ {
+ beans::Optional<beans::Ambiguous<sal_Bool> > reg =
+ userExtension->isRegistered(Reference<task::XAbortChannel>(),
+ Reference<ucb::XCommandEnvironment>());
+ //If the value is ambiguous is than we assume that the extension
+ //is enabled, but something went wrong during enabling. We do not
+ //automatically disable user extensions.
+ if (reg.IsPresent &&
+ ! reg.Value.IsAmbiguous && ! reg.Value.Value)
+ return true;
+ }
+ return false;
+}
+
+/*
+ This method determines the active extension (XPackage.registerPackage) with a
+ particular identifier.
+
+ The parameter bUserDisabled determines if the user extension is disabled.
+
+ When the user repository contains an extension with the given identifier and
+ it is not disabled by the user, then it is always registered. Otherwise an
+ extension is only registered when there is no registered extension in one of
+ the repositories with a higher priority. That is, if the extension is from
+ the shared repository and an active extension with the same identifer is in
+ the user repository, then the extension is not registered. Similarly a
+ bundled extension is not registered if there is an active extension with the
+ same identifier in the shared or user repository.
+*/
+void ExtensionManager::activateExtension(
+ OUString const & identifier, OUString const & fileName,
+ bool bUserDisabled,
+ bool bStartup,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+{
+ ::std::list<Reference<deploy::XPackage> > listExtensions;
+ try {
+ listExtensions = getExtensionsWithSameId(identifier, fileName);
+ } catch (lang::IllegalArgumentException &) {
+ }
+ OSL_ASSERT(listExtensions.size() == 3);
+
+ activateExtension(
+ ::comphelper::containerToSequence<
+ Reference<deploy::XPackage>,
+ ::std::list<Reference<deploy::XPackage> >
+ > (listExtensions),
+ bUserDisabled, bStartup, xAbortChannel, xCmdEnv);
+
+ fireModified();
+}
+
+void ExtensionManager::activateExtension(
+ uno::Sequence<Reference<deploy::XPackage> > const & seqExt,
+ bool bUserDisabled,
+ bool bStartup,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+{
+ bool bActive = false;
+ sal_Int32 len = seqExt.getLength();
+ for (sal_Int32 i = 0; i < len; i++)
+ {
+ Reference<deploy::XPackage> const & aExt = seqExt[i];
+ if (aExt.is())
+ {
+ //get the registration value of the current iteration
+ beans::Optional<beans::Ambiguous<sal_Bool> > optReg =
+ aExt->isRegistered(xAbortChannel, xCmdEnv);
+ //If nothing can be registered then break
+ if (!optReg.IsPresent)
+ break;
+
+ //Check if this is a disabled user extension,
+ if (i == 0 && bUserDisabled)
+ {
+ aExt->revokePackage(xAbortChannel, xCmdEnv);
+ continue;
+ }
+
+ //If we have already determined an active extension then we must
+ //make sure to unregister all extensions with the same id in
+ //repositories with a lower priority
+ if (bActive)
+ {
+ aExt->revokePackage(xAbortChannel, xCmdEnv);
+ }
+ else
+ {
+ //This is the first extension in the ordered list, which becomes
+ //the active extension
+ bActive = true;
+ //Register if not already done.
+ //reregister if the value is ambiguous, which indicates that
+ //something went wrong during last registration.
+ aExt->registerPackage(bStartup, xAbortChannel, xCmdEnv);
+ }
+ }
+ }
+}
+
+Reference<deploy::XPackage> ExtensionManager::backupExtension(
+ OUString const & identifier, OUString const & fileName,
+ Reference<deploy::XPackageManager> const & xPackageManager,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+{
+ Reference<deploy::XPackage> xBackup;
+ Reference<ucb::XCommandEnvironment> tmpCmdEnv(
+ new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler()));
+ Reference<deploy::XPackage> xOldExtension;
+ xOldExtension = xPackageManager->getDeployedPackage(
+ identifier, fileName, tmpCmdEnv);
+
+ if (xOldExtension.is())
+ {
+ xBackup = m_tmpRepository->addPackage(
+ xOldExtension->getURL(), uno::Sequence<beans::NamedValue>(),
+ OUString(), Reference<task::XAbortChannel>(), tmpCmdEnv);
+
+ OSL_ENSURE(xBackup.is(), "Failed to backup extension");
+ }
+ return xBackup;
+}
+
+//The supported package types are actually determined by the registry. However
+//creating a registry
+//(desktop/source/deployment/registry/dp_registry.cxx:PackageRegistryImpl) will
+//create all the backends, so that the registry can obtain from them the package
+//types. Creating the registry will also set up the registry folder containing
+//all the subfolders for the respective backends.
+//Because all repositories support the same backends, we can just delegate this
+//call to one of the repositories.
+uno::Sequence< Reference<deploy::XPackageTypeInfo> >
+ExtensionManager::getSupportedPackageTypes()
+ throw (uno::RuntimeException)
+{
+ return m_userRepository->getSupportedPackageTypes();
+}
+
+// Only add to shared and user repository
+Reference<deploy::XPackage> ExtensionManager::addExtension(
+ OUString const & url, uno::Sequence<beans::NamedValue> const & properties,
+ OUString const & repository,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ Reference<deploy::XPackage> xNewExtension;
+ //Determine the repository to use
+ Reference<deploy::XPackageManager> xPackageManager;
+ if (repository.equals(OUSTR("user")))
+ xPackageManager = m_userRepository;
+ else if (repository.equals(OUSTR("shared")))
+ xPackageManager = m_sharedRepository;
+ else
+ throw lang::IllegalArgumentException(
+ OUSTR("No valid repository name provided."),
+ static_cast<cppu::OWeakObject*>(this), 0);
+ ::osl::MutexGuard guard(getMutex());
+ Reference<deploy::XPackage> xTmpExtension =
+ getTempExtension(url, xAbortChannel, xCmdEnv);
+ const OUString sIdentifier = dp_misc::getIdentifier(xTmpExtension);
+ const OUString sFileName = xTmpExtension->getName();
+ const OUString sDisplayName = xTmpExtension->getDisplayName();
+ const OUString sVersion = xTmpExtension->getVersion();
+ dp_misc::DescriptionInfoset info(dp_misc::getDescriptionInfoset(xTmpExtension->getURL()));
+ const ::boost::optional<dp_misc::SimpleLicenseAttributes> licenseAttributes =
+ info.getSimpleLicenseAttributes();
+ Reference<deploy::XPackage> xOldExtension;
+ Reference<deploy::XPackage> xExtensionBackup;
+
+ uno::Any excOccurred1;
+ uno::Any excOccurred2;
+ bool bUserDisabled = false;
+ try
+ {
+ bUserDisabled = isUserDisabled(sIdentifier, sFileName);
+ try
+ {
+ xOldExtension = xPackageManager->getDeployedPackage(
+ sIdentifier, sFileName, xCmdEnv);
+ }
+ catch (lang::IllegalArgumentException &)
+ {
+ }
+ bool bCanInstall = false;
+ try
+ {
+ if (xOldExtension.is())
+ {
+ //throws a CommandFailedException if the user cancels
+ //the action.
+ checkUpdate(sVersion, sDisplayName,xOldExtension, xCmdEnv);
+ }
+ else
+ {
+ //throws a CommandFailedException if the user cancels
+ //the action.
+ checkInstall(sDisplayName, xCmdEnv);
+ }
+ //Prevent showing the license if requested.
+ Reference<ucb::XCommandEnvironment> _xCmdEnv(xCmdEnv);
+ ExtensionProperties props(OUString(), properties, Reference<ucb::XCommandEnvironment>());
+ if (licenseAttributes && licenseAttributes->suppressIfRequired
+ && props.isSuppressedLicense())
+ _xCmdEnv = Reference<ucb::XCommandEnvironment>(
+ new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler()));
+
+ bCanInstall = xTmpExtension->checkPrerequisites(
+ xAbortChannel, _xCmdEnv, xOldExtension.is() || props.isExtensionUpdate()) == 0 ? true : false;
+ }
+ catch (deploy::DeploymentException& ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (ucb::CommandFailedException & ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (ucb::CommandAbortedException & ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (lang::IllegalArgumentException &) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (uno::RuntimeException &) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (...) {
+ excOccurred1 = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during addExtension, url: ")
+ + url, static_cast<OWeakObject*>(this), excOccurred1);
+ excOccurred1 <<= exc;
+ }
+
+ if (bCanInstall)
+ {
+ if (xOldExtension.is())
+ {
+ xOldExtension->revokePackage(xAbortChannel, xCmdEnv);
+ //save the old user extension in case the user aborts
+ //store the extension in the tmp repository, this will overwrite
+ //xTmpPackage (same identifier). Do not let the user abort or
+ //interact
+ Reference<ucb::XCommandEnvironment> tmpCmdEnv(
+ new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler()));
+ //importing the old extension in the tmp repository will remove
+ //the xTmpExtension
+ xTmpExtension = 0;
+ xExtensionBackup = m_tmpRepository->importExtension(
+ xOldExtension, Reference<task::XAbortChannel>(),
+ tmpCmdEnv);
+ }
+ xNewExtension = xPackageManager->addPackage(
+ url, properties, OUString(), xAbortChannel, xCmdEnv);
+ //If we add a user extension and there is already one which was
+ //disabled by a user, then the newly installed one is enabled. If we
+ //add to another repository then the user extension remains
+ //disabled.
+ bool bUserDisabled2 = bUserDisabled;
+ if (repository.equals(OUSTR("user")))
+ bUserDisabled2 = false;
+ activateExtension(
+ dp_misc::getIdentifier(xNewExtension),
+ xNewExtension->getName(), bUserDisabled2, false, xAbortChannel, xCmdEnv);
+ fireModified();
+ }
+ }
+ catch (deploy::DeploymentException& ) {
+ excOccurred2 = ::cppu::getCaughtException();
+ } catch (ucb::CommandFailedException & ) {
+ excOccurred2 = ::cppu::getCaughtException();
+ } catch (ucb::CommandAbortedException & ) {
+ excOccurred2 = ::cppu::getCaughtException();
+ } catch (lang::IllegalArgumentException &) {
+ excOccurred2 = ::cppu::getCaughtException();
+ } catch (uno::RuntimeException &) {
+ excOccurred2 = ::cppu::getCaughtException();
+ } catch (...) {
+ excOccurred2 = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during addExtension, url: ")
+ + url, static_cast<OWeakObject*>(this), excOccurred2);
+ excOccurred2 <<= exc;
+ }
+
+ if (excOccurred2.hasValue())
+ {
+ //It does not matter what exception is thrown. We try to
+ //recover the original status.
+ //If the user aborted installation then a ucb::CommandAbortedException
+ //is thrown.
+ //Use a private AbortChannel so the user cannot interrupt.
+ try
+ {
+ Reference<ucb::XCommandEnvironment> tmpCmdEnv(
+ new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler()));
+ if (xExtensionBackup.is())
+ {
+ Reference<deploy::XPackage> xRestored =
+ xPackageManager->importExtension(
+ xExtensionBackup, Reference<task::XAbortChannel>(),
+ tmpCmdEnv);
+ }
+ activateExtension(
+ sIdentifier, sFileName, bUserDisabled, false,
+ Reference<task::XAbortChannel>(), tmpCmdEnv);
+ if (xTmpExtension.is() || xExtensionBackup.is())
+ m_tmpRepository->removePackage(
+ sIdentifier, OUString(), xAbortChannel, xCmdEnv);
+ fireModified();
+ }
+ catch (...)
+ {
+ }
+ ::cppu::throwException(excOccurred2);
+ }
+ if (xTmpExtension.is() || xExtensionBackup.is())
+ m_tmpRepository->removePackage(
+ sIdentifier,OUString(), xAbortChannel, xCmdEnv);
+
+ if (excOccurred1.hasValue())
+ ::cppu::throwException(excOccurred1);
+
+ return xNewExtension;
+}
+
+void ExtensionManager::removeExtension(
+ OUString const & identifier, OUString const & fileName,
+ OUString const & repository,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ uno::Any excOccurred1;
+ Reference<deploy::XPackage> xExtensionBackup;
+ Reference<deploy::XPackageManager> xPackageManager;
+ bool bUserDisabled = false;
+ ::osl::MutexGuard guard(getMutex());
+ try
+ {
+//Determine the repository to use
+ if (repository.equals(OUSTR("user")))
+ xPackageManager = m_userRepository;
+ else if (repository.equals(OUSTR("shared")))
+ xPackageManager = m_sharedRepository;
+ else
+ throw lang::IllegalArgumentException(
+ OUSTR("No valid repository name provided."),
+ static_cast<cppu::OWeakObject*>(this), 0);
+
+ bUserDisabled = isUserDisabled(identifier, fileName);
+ //Backup the extension, in case the user cancels the action
+ xExtensionBackup = backupExtension(
+ identifier, fileName, xPackageManager, xCmdEnv);
+
+ //revoke the extension if it is active
+ Reference<deploy::XPackage> xOldExtension =
+ xPackageManager->getDeployedPackage(
+ identifier, fileName, xCmdEnv);
+ xOldExtension->revokePackage(xAbortChannel, xCmdEnv);
+
+ xPackageManager->removePackage(
+ identifier, fileName, xAbortChannel, xCmdEnv);
+ activateExtension(identifier, fileName, bUserDisabled, false,
+ xAbortChannel, xCmdEnv);
+ fireModified();
+ }
+ catch (deploy::DeploymentException& ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (ucb::CommandFailedException & ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (ucb::CommandAbortedException & ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (lang::IllegalArgumentException &) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (uno::RuntimeException &) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (...) {
+ excOccurred1 = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during removeEtension"),
+ static_cast<OWeakObject*>(this), excOccurred1);
+ excOccurred1 <<= exc;
+ }
+
+ if (excOccurred1.hasValue())
+ {
+ //User aborted installation, restore the previous situation.
+ //Use a private AbortChannel so the user cannot interrupt.
+ try
+ {
+ Reference<ucb::XCommandEnvironment> tmpCmdEnv(
+ new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler()));
+ if (xExtensionBackup.is())
+ {
+ Reference<deploy::XPackage> xRestored =
+ xPackageManager->importExtension(
+ xExtensionBackup, Reference<task::XAbortChannel>(),
+ tmpCmdEnv);
+ activateExtension(
+ identifier, fileName, bUserDisabled, false,
+ Reference<task::XAbortChannel>(),
+ tmpCmdEnv);
+
+ m_tmpRepository->removePackage(
+ dp_misc::getIdentifier(xExtensionBackup),
+ xExtensionBackup->getName(), xAbortChannel, xCmdEnv);
+ fireModified();
+ }
+ }
+ catch (...)
+ {
+ }
+ ::cppu::throwException(excOccurred1);
+ }
+
+ if (xExtensionBackup.is())
+ m_tmpRepository->removePackage(
+ dp_misc::getIdentifier(xExtensionBackup),
+ xExtensionBackup->getName(), xAbortChannel, xCmdEnv);
+}
+
+// Only enable extensions from shared and user repository
+void ExtensionManager::enableExtension(
+ Reference<deploy::XPackage> const & extension,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ ::osl::MutexGuard guard(getMutex());
+ bool bUserDisabled = false;
+ uno::Any excOccurred;
+ try
+ {
+ if (!extension.is())
+ return;
+ OUString repository = extension->getRepositoryName();
+ if (!repository.equals(OUSTR("user")))
+ throw lang::IllegalArgumentException(
+ OUSTR("No valid repository name provided."),
+ static_cast<cppu::OWeakObject*>(this), 0);
+
+ bUserDisabled = isUserDisabled(dp_misc::getIdentifier(extension),
+ extension->getName());
+
+ activateExtension(dp_misc::getIdentifier(extension),
+ extension->getName(), false, false,
+ xAbortChannel, xCmdEnv);
+ }
+ catch (deploy::DeploymentException& ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (ucb::CommandFailedException & ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (ucb::CommandAbortedException & ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (lang::IllegalArgumentException &) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (uno::RuntimeException &) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (...) {
+ excOccurred = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during enableExtension"),
+ static_cast<OWeakObject*>(this), excOccurred);
+ excOccurred <<= exc;
+ }
+
+ if (excOccurred.hasValue())
+ {
+ try
+ {
+ activateExtension(dp_misc::getIdentifier(extension),
+ extension->getName(), bUserDisabled, false,
+ xAbortChannel, xCmdEnv);
+ }
+ catch (...)
+ {
+ }
+ ::cppu::throwException(excOccurred);
+ }
+}
+
+/**
+ */
+sal_Int32 ExtensionManager::checkPrerequisitesAndEnable(
+ Reference<deploy::XPackage> const & extension,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ try
+ {
+ if (!extension.is())
+ return 0;
+ ::osl::MutexGuard guard(getMutex());
+ sal_Int32 ret = 0;
+ Reference<deploy::XPackageManager> mgr =
+ getPackageManager(extension->getRepositoryName());
+ ret = mgr->checkPrerequisites(extension, xAbortChannel, xCmdEnv);
+ if (ret)
+ {
+ //There are some unfulfilled prerequisites, try to revoke
+ extension->revokePackage(xAbortChannel, xCmdEnv);
+ }
+ const OUString id(dp_misc::getIdentifier(extension));
+ activateExtension(id, extension->getName(),
+ isUserDisabled(id, extension->getName()), false,
+ xAbortChannel, xCmdEnv);
+ return ret;
+ }
+ catch (deploy::DeploymentException& ) {
+ throw;
+ } catch (ucb::CommandFailedException & ) {
+ throw;
+ } catch (ucb::CommandAbortedException & ) {
+ throw;
+ } catch (lang::IllegalArgumentException &) {
+ throw;
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (...) {
+ uno::Any excOccurred = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during disableExtension"),
+ static_cast<OWeakObject*>(this), excOccurred);
+ throw exc;
+ }
+}
+
+
+void ExtensionManager::disableExtension(
+ Reference<deploy::XPackage> const & extension,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ ::osl::MutexGuard guard(getMutex());
+ uno::Any excOccurred;
+ bool bUserDisabled = false;
+ try
+ {
+ if (!extension.is())
+ return;
+ const OUString repository( extension->getRepositoryName());
+ if (!repository.equals(OUSTR("user")))
+ throw lang::IllegalArgumentException(
+ OUSTR("No valid repository name provided."),
+ static_cast<cppu::OWeakObject*>(this), 0);
+
+ const OUString id(dp_misc::getIdentifier(extension));
+ bUserDisabled = isUserDisabled(id, extension->getName());
+
+ activateExtension(id, extension->getName(), true, false,
+ xAbortChannel, xCmdEnv);
+ }
+ catch (deploy::DeploymentException& ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (ucb::CommandFailedException & ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (ucb::CommandAbortedException & ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (lang::IllegalArgumentException &) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (uno::RuntimeException &) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (...) {
+ excOccurred = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during disableExtension"),
+ static_cast<OWeakObject*>(this), excOccurred);
+ excOccurred <<= exc;
+ }
+
+ if (excOccurred.hasValue())
+ {
+ try
+ {
+ activateExtension(dp_misc::getIdentifier(extension),
+ extension->getName(), bUserDisabled, false,
+ xAbortChannel, xCmdEnv);
+ }
+ catch (...)
+ {
+ }
+ ::cppu::throwException(excOccurred);
+ }
+}
+
+uno::Sequence< Reference<deploy::XPackage> >
+ ExtensionManager::getDeployedExtensions(
+ OUString const & repository,
+ Reference<task::XAbortChannel> const &xAbort,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ return getPackageManager(repository)->getDeployedPackages(
+ xAbort, xCmdEnv);
+}
+
+Reference<deploy::XPackage>
+ ExtensionManager::getDeployedExtension(
+ OUString const & repository,
+ OUString const & identifier,
+ OUString const & filename,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ return getPackageManager(repository)->getDeployedPackage(
+ identifier, filename, xCmdEnv);
+}
+
+uno::Sequence< uno::Sequence<Reference<deploy::XPackage> > >
+ ExtensionManager::getAllExtensions(
+ Reference<task::XAbortChannel> const & xAbort,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ try
+ {
+ id2extensions mapExt;
+
+ uno::Sequence<Reference<deploy::XPackage> > userExt =
+ m_userRepository->getDeployedPackages(xAbort, xCmdEnv);
+ addExtensionsToMap(mapExt, userExt, OUSTR("user"));
+ uno::Sequence<Reference<deploy::XPackage> > sharedExt =
+ m_sharedRepository->getDeployedPackages(xAbort, xCmdEnv);
+ addExtensionsToMap(mapExt, sharedExt, OUSTR("shared"));
+ uno::Sequence<Reference<deploy::XPackage> > bundledExt =
+ m_bundledRepository->getDeployedPackages(xAbort, xCmdEnv);
+ addExtensionsToMap(mapExt, bundledExt, OUSTR("bundled"));
+
+ //copy the values of the map to a vector for sorting
+ ::std::vector< ::std::vector<Reference<deploy::XPackage> > >
+ vecExtensions;
+ id2extensions::const_iterator mapIt = mapExt.begin();
+ for (;mapIt != mapExt.end(); mapIt++)
+ vecExtensions.push_back(mapIt->second);
+
+ //sort the element according to the identifier
+ ::std::sort(vecExtensions.begin(), vecExtensions.end(), CompIdentifiers());
+
+ ::std::vector< ::std::vector<Reference<deploy::XPackage> > >::const_iterator
+ citVecVec = vecExtensions.begin();
+ sal_Int32 j = 0;
+ uno::Sequence< uno::Sequence<Reference<deploy::XPackage> > > seqSeq(vecExtensions.size());
+ for (;citVecVec != vecExtensions.end(); citVecVec++, j++)
+ {
+ seqSeq[j] = comphelper::containerToSequence(*citVecVec);
+ }
+ return seqSeq;
+
+ } catch (deploy::DeploymentException& ) {
+ throw;
+ } catch (ucb::CommandFailedException & ) {
+ throw;
+ } catch (ucb::CommandAbortedException & ) {
+ throw;
+ } catch (lang::IllegalArgumentException &) {
+ throw;
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (...) {
+ uno::Any exc = ::cppu::getCaughtException();
+ throw deploy::DeploymentException(
+ OUSTR("Extension Manager: exception during enableExtension"),
+ static_cast<OWeakObject*>(this), exc);
+ }
+}
+
+//only to be called from unopkg!!!
+void ExtensionManager::reinstallDeployedExtensions(
+ OUString const & repository,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException, ucb::CommandAbortedException,
+ lang::IllegalArgumentException, uno::RuntimeException)
+{
+ try
+ {
+ Reference<deploy::XPackageManager>
+ xPackageManager = getPackageManager(repository);
+
+ ::osl::MutexGuard guard(getMutex());
+ xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv);
+ //We must sync here, otherwise we will get exceptions when extensions
+ //are removed.
+ dp_misc::syncRepositories(xCmdEnv);
+ const uno::Sequence< Reference<deploy::XPackage> > extensions(
+ xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv));
+
+ for ( sal_Int32 pos = 0; pos < extensions.getLength(); ++pos )
+ {
+ try
+ {
+ const OUString id = dp_misc::getIdentifier(extensions[ pos ]);
+ const OUString fileName = extensions[ pos ]->getName();
+ OSL_ASSERT(id.getLength());
+ activateExtension(id, fileName, false, false, xAbortChannel, xCmdEnv );
+ }
+ catch (lang::DisposedException &)
+ {
+ }
+ }
+ } catch (deploy::DeploymentException& ) {
+ throw;
+ } catch (ucb::CommandFailedException & ) {
+ throw;
+ } catch (ucb::CommandAbortedException & ) {
+ throw;
+ } catch (lang::IllegalArgumentException &) {
+ throw;
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (...) {
+ uno::Any exc = ::cppu::getCaughtException();
+ throw deploy::DeploymentException(
+ OUSTR("Extension Manager: exception during enableExtension"),
+ static_cast<OWeakObject*>(this), exc);
+ }
+}
+
+sal_Bool ExtensionManager::synchronize(
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ try
+ {
+ sal_Bool bModified = sal_False;
+
+ ::osl::MutexGuard guard(getMutex());
+ String sSynchronizingShared(StrSyncRepository::get());
+ sSynchronizingShared.SearchAndReplaceAllAscii( "%NAME", OUSTR("shared"));
+ dp_misc::ProgressLevel progressShared(xCmdEnv, sSynchronizingShared);
+ bModified = m_sharedRepository->synchronize(xAbortChannel, xCmdEnv);
+ progressShared.update(OUSTR("\n\n"));
+
+ String sSynchronizingBundled(StrSyncRepository::get());
+ sSynchronizingBundled.SearchAndReplaceAllAscii( "%NAME", OUSTR("bundled"));
+ dp_misc::ProgressLevel progressBundled(xCmdEnv, sSynchronizingBundled);
+ bModified |= m_bundledRepository->synchronize(xAbortChannel, xCmdEnv);
+ progressBundled.update(OUSTR("\n\n"));
+
+ try
+ {
+ const uno::Sequence<uno::Sequence<Reference<deploy::XPackage> > >
+ seqSeqExt = getAllExtensions(xAbortChannel, xCmdEnv);
+ for (sal_Int32 i = 0; i < seqSeqExt.getLength(); i++)
+ {
+ uno::Sequence<Reference<deploy::XPackage> > const & seqExt =
+ seqSeqExt[i];
+ activateExtension(seqExt, isUserDisabled(seqExt), true,
+ xAbortChannel, xCmdEnv);
+ }
+ }
+ catch (...)
+ {
+ //We catch the exception, so we can write the lastmodified file
+ //so we will no repeat this everytime OOo starts.
+ OSL_ENSURE(0, "Extensions Manager: synchronize");
+ }
+ OUString lastSyncBundled(RTL_CONSTASCII_USTRINGPARAM(
+ "$BUNDLED_EXTENSIONS_USER/lastsynchronized"));
+ writeLastModified(lastSyncBundled, xCmdEnv);
+ OUString lastSyncShared(RTL_CONSTASCII_USTRINGPARAM(
+ "$SHARED_EXTENSIONS_USER/lastsynchronized"));
+ writeLastModified(lastSyncShared, xCmdEnv);
+ return bModified;
+ } catch (deploy::DeploymentException& ) {
+ throw;
+ } catch (ucb::CommandFailedException & ) {
+ throw;
+ } catch (ucb::CommandAbortedException & ) {
+ throw;
+ } catch (lang::IllegalArgumentException &) {
+ throw;
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (...) {
+ uno::Any exc = ::cppu::getCaughtException();
+ throw deploy::DeploymentException(
+ OUSTR("Extension Manager: exception in synchronize"),
+ static_cast<OWeakObject*>(this), exc);
+ }
+}
+
+// Notify the user when a new extension is to be installed. This is only the
+// case when one uses the system integration to install an extension (double
+// clicking on .oxt file etc.)). The function must only be called if there is no
+// extension with the same identifier already deployed. Then the checkUpdate
+// function will inform the user that the extension is about to be installed In
+// case the user cancels the installation a CommandFailed exception is
+// thrown.
+void ExtensionManager::checkInstall(
+ OUString const & displayName,
+ Reference<ucb::XCommandEnvironment> const & cmdEnv)
+{
+ uno::Any request(
+ deploy::InstallException(
+ OUSTR("Extension ") + displayName +
+ OUSTR(" is about to be installed."),
+ static_cast<OWeakObject *>(this), displayName));
+ bool approve = false, abort = false;
+ if (! dp_misc::interactContinuation(
+ request, task::XInteractionApprove::static_type(),
+ cmdEnv, &approve, &abort ))
+ {
+ OSL_ASSERT( !approve && !abort );
+ throw deploy::DeploymentException(
+ dp_misc::getResourceString(RID_STR_ERROR_WHILE_ADDING) + displayName,
+ static_cast<OWeakObject *>(this), request );
+ }
+ if (abort || !approve)
+ throw ucb::CommandFailedException(
+ dp_misc::getResourceString(RID_STR_ERROR_WHILE_ADDING) + displayName,
+ static_cast<OWeakObject *>(this), request );
+}
+
+/* The function will make the user interaction in case there is an extension
+installed with the same id. This function may only be called if there is already
+an extension.
+*/
+void ExtensionManager::checkUpdate(
+ OUString const & newVersion,
+ OUString const & newDisplayName,
+ Reference<deploy::XPackage> const & oldExtension,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+{
+ // package already deployed, interact --force:
+ uno::Any request(
+ (deploy::VersionException(
+ dp_misc::getResourceString(
+ RID_STR_PACKAGE_ALREADY_ADDED ) + newDisplayName,
+ static_cast<OWeakObject *>(this), newVersion, newDisplayName,
+ oldExtension ) ) );
+ bool replace = false, abort = false;
+ if (! dp_misc::interactContinuation(
+ request, task::XInteractionApprove::static_type(),
+ xCmdEnv, &replace, &abort )) {
+ OSL_ASSERT( !replace && !abort );
+ throw deploy::DeploymentException(
+ dp_misc::getResourceString(
+ RID_STR_ERROR_WHILE_ADDING) + newDisplayName,
+ static_cast<OWeakObject *>(this), request );
+ }
+ if (abort || !replace)
+ throw ucb::CommandFailedException(
+ dp_misc::getResourceString(
+ RID_STR_PACKAGE_ALREADY_ADDED) + newDisplayName,
+ static_cast<OWeakObject *>(this), request );
+}
+
+Reference<deploy::XPackage> ExtensionManager::getTempExtension(
+ OUString const & url,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & /*xCmdEnv*/)
+
+{
+ Reference<ucb::XCommandEnvironment> tmpCmdEnvA(new TmpRepositoryCommandEnv());
+ Reference<deploy::XPackage> xTmpPackage = m_tmpRepository->addPackage(
+ url, uno::Sequence<beans::NamedValue>(),OUString(), xAbortChannel, tmpCmdEnvA);
+ if (!xTmpPackage.is())
+ {
+ throw deploy::DeploymentException(
+ OUSTR("Extension Manager: Failed to create temporary XPackage for url: ") + url,
+ static_cast<OWeakObject*>(this), uno::Any());
+
+ }
+ return xTmpPackage;
+}
+
+uno::Sequence<Reference<deploy::XPackage> > SAL_CALL
+ExtensionManager::getExtensionsWithUnacceptedLicenses(
+ OUString const & repository,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (deploy::DeploymentException,
+ uno::RuntimeException)
+{
+ Reference<deploy::XPackageManager>
+ xPackageManager = getPackageManager(repository);
+ ::osl::MutexGuard guard(getMutex());
+ return xPackageManager->getExtensionsWithUnacceptedLicenses(xCmdEnv);
+}
+
+sal_Bool ExtensionManager::isReadOnlyRepository(::rtl::OUString const & repository)
+ throw (uno::RuntimeException)
+{
+ return getPackageManager(repository)->isReadOnly();
+}
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+namespace sdecl = comphelper::service_decl;
+sdecl::class_<ExtensionManager> servicePIP;
+extern sdecl::ServiceDecl const serviceDecl(
+ servicePIP,
+ // a private one:
+ "com.sun.star.comp.deployment.ExtensionManager",
+ "com.sun.star.comp.deployment.ExtensionManager");
+
+//------------------------------------------------------------------------------
+bool singleton_entries(
+ uno::Reference< registry::XRegistryKey > const & xRegistryKey )
+{
+ try {
+ uno::Reference< registry::XRegistryKey > xKey(
+ xRegistryKey->createKey(
+ serviceDecl.getImplementationName() +
+ // xxx todo: use future generated function to get singleton name
+ OUSTR("/UNO/SINGLETONS/"
+ "com.sun.star.deployment.ExtensionManager") ) );
+ xKey->setStringValue( serviceDecl.getSupportedServiceNames()[0] );
+ return true;
+ }
+ catch (registry::InvalidRegistryException & exc) {
+ (void) exc; // avoid warnings
+ OSL_ENSURE( 0, ::rtl::OUStringToOString(
+ exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ return false;
+ }
+}
+
+// XModifyBroadcaster
+//______________________________________________________________________________
+void ExtensionManager::addModifyListener(
+ Reference<util::XModifyListener> const & xListener )
+ throw (uno::RuntimeException)
+{
+ check();
+ rBHelper.addListener( ::getCppuType( &xListener ), xListener );
+}
+
+//______________________________________________________________________________
+void ExtensionManager::removeModifyListener(
+ Reference<util::XModifyListener> const & xListener )
+ throw (uno::RuntimeException)
+{
+ check();
+ rBHelper.removeListener( ::getCppuType( &xListener ), xListener );
+}
+
+void ExtensionManager::check()
+{
+ ::osl::MutexGuard guard( getMutex() );
+ if (rBHelper.bInDispose || rBHelper.bDisposed) {
+ throw lang::DisposedException(
+ OUSTR("ExtensionManager instance has already been disposed!"),
+ static_cast<OWeakObject *>(this) );
+ }
+}
+
+void ExtensionManager::fireModified()
+{
+ ::cppu::OInterfaceContainerHelper * pContainer = rBHelper.getContainer(
+ util::XModifyListener::static_type() );
+ if (pContainer != 0) {
+ pContainer->forEach<util::XModifyListener>(
+ boost::bind(&util::XModifyListener::modified, _1,
+ lang::EventObject(static_cast<OWeakObject *>(this))) );
+ }
+}
+
+} // namespace dp_manager
+
+
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx
new file mode 100644
index 000000000000..64cada7da3ac
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx
@@ -0,0 +1,307 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+
+#if ! defined INCLUDED_DP_EXTENSIONMANAGER_H
+#define INCLUDED_DP_EXTENSIONMANAGER_H
+
+#include "dp_manager.hrc"
+#include "dp_misc.h"
+#include "dp_interact.h"
+#include "dp_activepackages.hxx"
+#include "rtl/ref.hxx"
+#include "cppuhelper/compbase1.hxx"
+#include "ucbhelper/content.hxx"
+#include "com/sun/star/deployment/XPackageRegistry.hpp"
+#include "com/sun/star/deployment/XPackageManager.hpp"
+#include "osl/mutex.hxx"
+#include <list>
+
+
+namespace css = ::com::sun::star;
+
+namespace dp_manager {
+
+typedef ::std::hash_map<
+ ::rtl::OUString,
+ ::std::vector<css::uno::Reference<css::deployment::XPackage> >,
+ ::rtl::OUStringHash > id2extensions;
+
+
+class ExtensionManager : private ::dp_misc::MutexHolder,
+ public ::cppu::WeakComponentImplHelper1< css::deployment::XExtensionManager >
+{
+public:
+ ExtensionManager( css::uno::Reference< css::uno::XComponentContext >const& xContext);
+ virtual ~ExtensionManager();
+
+ static css::uno::Sequence< ::rtl::OUString > getServiceNames();
+ static ::rtl::OUString getImplName();
+
+ void check();
+ void fireModified();
+
+public:
+
+// XModifyBroadcaster
+ virtual void SAL_CALL addModifyListener(
+ css::uno::Reference<css::util::XModifyListener> const & xListener )
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL removeModifyListener(
+ css::uno::Reference<css::util::XModifyListener> const & xListener )
+ throw (css::uno::RuntimeException);
+
+//XExtensionManager
+ virtual css::uno::Sequence<
+ css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL
+ getSupportedPackageTypes()
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL
+ createAbortChannel() throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addExtension(
+ ::rtl::OUString const & url,
+ css::uno::Sequence<css::beans::NamedValue> const & properties,
+ ::rtl::OUString const & repository,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual void SAL_CALL removeExtension(
+ ::rtl::OUString const & identifier,
+ ::rtl::OUString const & filename,
+ ::rtl::OUString const & repository,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual void SAL_CALL enableExtension(
+ css::uno::Reference<css::deployment::XPackage> const & extension,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual void SAL_CALL disableExtension(
+ css::uno::Reference<css::deployment::XPackage> const & extension,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+
+ virtual sal_Int32 SAL_CALL checkPrerequisitesAndEnable(
+ css::uno::Reference<css::deployment::XPackage> const & extension,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+
+ virtual css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
+ SAL_CALL getDeployedExtensions(
+ ::rtl::OUString const & repository,
+ css::uno::Reference<css::task::XAbortChannel> const &,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Reference< css::deployment::XPackage>
+ SAL_CALL getDeployedExtension(
+ ::rtl::OUString const & repository,
+ ::rtl::OUString const & identifier,
+ ::rtl::OUString const & filename,
+ css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (
+ css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> >
+ SAL_CALL getExtensionsWithSameIdentifier(
+ ::rtl::OUString const & identifier,
+ ::rtl::OUString const & filename,
+ css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (
+ css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Sequence< css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > >
+ SAL_CALL getAllExtensions(
+ css::uno::Reference<css::task::XAbortChannel> const &,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+
+ virtual void SAL_CALL reinstallDeployedExtensions(
+ ::rtl::OUString const & repository,
+ css::uno::Reference< css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (
+ css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL synchronize(
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
+ getExtensionsWithUnacceptedLicenses(
+ ::rtl::OUString const & repository,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (css::deployment::DeploymentException,
+ css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL isReadOnlyRepository(::rtl::OUString const & repository)
+ throw (css::uno::RuntimeException);
+
+private:
+
+ struct StrSyncRepository : public ::dp_misc::StaticResourceString<
+ StrSyncRepository, RID_STR_SYNCHRONIZING_REPOSITORY> {};
+
+ struct ExtensionInfos
+ {
+ ::rtl::OUString identifier;
+ ::rtl::OUString fileName;
+ ::rtl::OUString displayName;
+ ::rtl::OUString version;
+ };
+
+ css::uno::Reference< css::uno::XComponentContext> m_xContext;
+
+ css::uno::Reference<css::deployment::XPackageManager> m_userRepository;
+ css::uno::Reference<css::deployment::XPackageManager> m_sharedRepository;
+ css::uno::Reference<css::deployment::XPackageManager> m_bundledRepository;
+ css::uno::Reference<css::deployment::XPackageManager> m_tmpRepository;
+
+ /* contains the names of all repositories (except tmp) in order of there
+ priority. That is, the first element is "user" follod by "shared" and
+ then "bundled"
+ */
+ ::std::list< ::rtl::OUString > m_repositoryNames;
+
+ bool isUserDisabled(::rtl::OUString const & identifier,
+ ::rtl::OUString const & filename);
+
+ bool isUserDisabled(
+ css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExtSameId);
+
+ void activateExtension(
+ ::rtl::OUString const & identifier,
+ ::rtl::OUString const & fileName,
+ bool bUserDisabled, bool bStartup,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+ void activateExtension(
+ css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt,
+ bool bUserDisabled, bool bStartup,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
+
+
+ ::std::list<css::uno::Reference<css::deployment::XPackage> >
+ getExtensionsWithSameId(::rtl::OUString const & identifier,
+ ::rtl::OUString const & fileName,
+ css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv =
+ css::uno::Reference< css::ucb::XCommandEnvironment>());
+
+ css::uno::Reference<css::deployment::XPackage> backupExtension(
+ ::rtl::OUString const & identifier, ::rtl::OUString const & fileName,
+ css::uno::Reference<css::deployment::XPackageManager> const & xPackageManager,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+ void checkInstall(
+ ::rtl::OUString const & displayName,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & cmdEnv);
+
+ void checkUpdate(
+ ::rtl::OUString const & newVersion,
+ ::rtl::OUString const & newDisplayName,
+ css::uno::Reference<css::deployment::XPackage> const & oldExtension,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+ css::uno::Reference<css::deployment::XPackage> getTempExtension(
+ ::rtl::OUString const & url,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+
+ void addExtensionsToMap(
+ id2extensions & mapExt,
+ css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt,
+ ::rtl::OUString const & repository);
+
+ css::uno::Reference<css::deployment::XPackageManager>
+ getPackageManager(::rtl::OUString const & repository)
+ throw (css::lang::IllegalArgumentException);
+};
+
+}
+
+
+
+
+#endif
+
diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx
index 9f2e0c9e1177..4cc43a8386d8 100644
--- a/desktop/source/deployment/manager/dp_informationprovider.cxx
+++ b/desktop/source/deployment/manager/dp_informationprovider.cxx
@@ -32,11 +32,10 @@
#include "comphelper/servicedecl.hxx"
-#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
#include "com/sun/star/deployment/UpdateInformationProvider.hpp"
#include "com/sun/star/deployment/XPackage.hpp"
#include "com/sun/star/deployment/XPackageInformationProvider.hpp"
-#include "com/sun/star/deployment/XPackageManager.hpp"
+#include "com/sun/star/deployment/ExtensionManager.hpp"
#include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/registry/XRegistryKey.hpp"
@@ -56,6 +55,7 @@
#include "dp_identifier.hxx"
#include "dp_version.hxx"
#include "dp_misc.h"
+#include "dp_update.hxx"
namespace beans = com::sun::star::beans ;
namespace deployment = com::sun::star::deployment ;
@@ -104,21 +104,10 @@ private:
uno::Reference< uno::XComponentContext> mxContext;
- rtl::OUString getPackageLocation( const uno::Reference< deployment::XPackageManager > _xManager,
+ rtl::OUString getPackageLocation( const rtl::OUString& repository,
const rtl::OUString& _sExtensionId );
uno::Reference< deployment::XUpdateInformationProvider > mxUpdateInformation;
-
- uno::Sequence< uno::Reference< xml::dom::XElement > >
- getUpdateInformation( uno::Sequence< rtl::OUString > const & urls,
- rtl::OUString const & identifier ) const;
- uno::Sequence< uno::Reference< deployment::XPackage > >
- getPackages( const uno::Reference< deployment::XPackageManager > _xManager );
- uno::Sequence< uno::Sequence< rtl::OUString > > isUpdateAvailable( const uno::Reference< deployment::XPackageManager > _xManager,
- const rtl::OUString& _sExtensionId );
- uno::Sequence< uno::Sequence< rtl::OUString > > getExtensionList( const uno::Reference< deployment::XPackageManager > _xManager );
- uno::Sequence< uno::Sequence< rtl::OUString > > concatLists( uno::Sequence< uno::Sequence< rtl::OUString > > aFirst,
- uno::Sequence< uno::Sequence< rtl::OUString > > aSecond );
};
//------------------------------------------------------------------------------
@@ -148,15 +137,18 @@ void SAL_CALL PackageInformationProvider::handle( uno::Reference< task::XInterac
//------------------------------------------------------------------------------
rtl::OUString PackageInformationProvider::getPackageLocation(
- const uno::Reference< deployment::XPackageManager > _xManager,
- const rtl::OUString& _rExtensionId )
+ const rtl::OUString & repository,
+ const rtl::OUString& _rExtensionId )
{
rtl::OUString aLocationURL;
+ uno::Reference<deployment::XExtensionManager> xManager =
+ deployment::ExtensionManager::get(mxContext);
- if ( _xManager.is() )
+ if ( xManager.is() )
{
const uno::Sequence< uno::Reference< deployment::XPackage > > packages(
- _xManager->getDeployedPackages(
+ xManager->getDeployedExtensions(
+ repository,
uno::Reference< task::XAbortChannel >(),
static_cast < XCommandEnvironment *> (this) ) );
@@ -187,32 +179,21 @@ rtl::OUString SAL_CALL
PackageInformationProvider::getPackageLocation( const rtl::OUString& _sExtensionId )
throw ( uno::RuntimeException )
{
- uno::Reference< deployment::XPackageManager > xManager;
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- rtl::OUString aLocationURL = getPackageLocation( xManager, _sExtensionId );
+ rtl::OUString aLocationURL = getPackageLocation( UNISTRING("user"), _sExtensionId );
if ( aLocationURL.getLength() == 0 )
{
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- aLocationURL = getPackageLocation( xManager, _sExtensionId );
+ aLocationURL = getPackageLocation( UNISTRING("shared"), _sExtensionId );
+ }
+ if ( aLocationURL.getLength() == 0 )
+ {
+ aLocationURL = getPackageLocation( UNISTRING("bundled"), _sExtensionId );
}
-
if ( aLocationURL.getLength() )
{
::ucbhelper::Content aContent( aLocationURL, NULL );
aLocationURL = aContent.getURL();
}
-
return aLocationURL;
}
@@ -222,252 +203,157 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL
PackageInformationProvider::isUpdateAvailable( const rtl::OUString& _sExtensionId )
throw ( uno::RuntimeException )
{
- uno::Sequence< uno::Sequence< rtl::OUString > > aUpdateListUser;
-
- uno::Reference< deployment::XPackageManager > xManager;
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- aUpdateListUser = isUpdateAvailable( xManager, _sExtensionId );
-
- uno::Sequence< uno::Sequence< rtl::OUString > > aUpdateListShared;
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- aUpdateListShared = isUpdateAvailable( xManager, _sExtensionId );
-
- if ( !aUpdateListUser.hasElements() )
- return aUpdateListShared;
- else if ( !aUpdateListShared.hasElements() )
- return aUpdateListUser;
- else
- return concatLists( aUpdateListUser, aUpdateListShared );
-}
-
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::getExtensionList()
- throw ( uno::RuntimeException )
-{
- uno::Sequence< uno::Sequence< rtl::OUString > > aListUser;
-
- uno::Reference< deployment::XPackageManager > xManager;
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- aListUser = getExtensionList( xManager );
-
- uno::Sequence< uno::Sequence< rtl::OUString > > aListShared;
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- aListShared = getExtensionList( xManager );
+ uno::Sequence< uno::Sequence< rtl::OUString > > aList;
- if ( !aListUser.hasElements() )
- return aListShared;
- else if ( !aListShared.hasElements() )
- return aListUser;
- else
- return concatLists( aListUser, aListShared );
-}
+ uno::Reference<deployment::XExtensionManager> extMgr =
+ deployment::ExtensionManager::get(mxContext);
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Reference< deployment::XPackage > >
- PackageInformationProvider::getPackages( const uno::Reference< deployment::XPackageManager > _xMgr )
-{
- uno::Sequence< uno::Reference< deployment::XPackage > > packages;
- try {
- packages = _xMgr->getDeployedPackages( uno::Reference< task::XAbortChannel >(),
- static_cast < XCommandEnvironment *> (this) );
- }
- catch ( deployment::DeploymentException & )
- {}
- catch ( css_ucb::CommandFailedException & )
- {}
- catch ( css_ucb::CommandAbortedException & )
- {}
- catch ( lang::IllegalArgumentException & e )
+ if (!extMgr.is())
{
- throw uno::RuntimeException(e.Message, e.Context);
+ OSL_ASSERT(0);
+ return aList;
}
-
- return packages;
-}
-
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Reference< xml::dom::XElement > >
- PackageInformationProvider::getUpdateInformation( uno::Sequence< rtl::OUString > const & urls,
- rtl::OUString const & identifier ) const
-{
- try
+ std::vector<std::pair<uno::Reference<deployment::XPackage>, uno::Any > > errors;
+ dp_misc::UpdateInfoMap updateInfoMap;
+ if (_sExtensionId.getLength())
{
- return mxUpdateInformation->getUpdateInformation( urls, identifier );
+ std::vector<uno::Reference<deployment::XPackage> > vecExtensions;
+ uno::Reference<deployment::XPackage> extension;
+ try
+ {
+ extension = dp_misc::getExtensionWithHighestVersion(
+ extMgr->getExtensionsWithSameIdentifier(
+ _sExtensionId, _sExtensionId, uno::Reference<css_ucb::XCommandEnvironment>()));
+ vecExtensions.push_back(extension);
+ }
+ catch (lang::IllegalArgumentException &)
+ {
+ OSL_ASSERT(0);
+ }
+ updateInfoMap = dp_misc::getOnlineUpdateInfos(
+ mxContext, extMgr, mxUpdateInformation, &vecExtensions, errors);
}
- catch ( uno::RuntimeException & ) {
- throw;
+ else
+ {
+ updateInfoMap = dp_misc::getOnlineUpdateInfos(
+ mxContext, extMgr, mxUpdateInformation, NULL, errors);
}
- catch ( css_ucb::CommandFailedException & ) {}
- catch ( css_ucb::CommandAbortedException & ) {}
- catch ( uno::Exception & ) {}
-
- return uno::Sequence< uno::Reference< xml::dom::XElement > >();
-}
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Sequence< rtl::OUString > >
- PackageInformationProvider::isUpdateAvailable(
- const uno::Reference< deployment::XPackageManager > _xManager,
- const rtl::OUString& _sExtensionId )
-{
- uno::Sequence< uno::Sequence< rtl::OUString > > aList;
- sal_Int32 nCount = 0;
- bool bPackageFound = false;
-
- // If the package manager is readonly then the user cannot modify anything anyway
- // so we can abort the search here
- if ( _xManager.is() && ! _xManager->isReadOnly() )
+ int nCount = 0;
+ for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++)
{
- uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( _xManager ) );
- uno::Sequence< uno::Reference< xml::dom::XElement > > defaultInfos;
+ dp_misc::UpdateInfo const & info = i->second;
- for ( int pos = packages.getLength(); pos-- && !bPackageFound; )
+ rtl::OUString sOnlineVersion;
+ if (info.info.is())
{
- uno::Reference< deployment::XPackage > package( packages[ pos ] );
- uno::Sequence< rtl::OUString > urls( package->getUpdateInformationURLs());
- uno::Sequence< uno::Reference< xml::dom::XElement > > infos;
- rtl::OUString id( dp_misc::getIdentifier( package ) );
-
- if ( _sExtensionId.getLength() )
- {
- if ( _sExtensionId == id )
- bPackageFound = true;
- else /* we have an ID and the IDs don't match, continue with next package */
- continue;
- }
-
- if ( urls.getLength() != 0)
- {
- infos = getUpdateInformation( urls, id );
- }
- else
- {
- if ( defaultInfos.getLength() == 0 )
- {
- const rtl::OUString defaultURL( dp_misc::getExtensionDefaultUpdateURL() );
- if ( defaultURL.getLength() )
- defaultInfos = getUpdateInformation( uno::Sequence< rtl::OUString >( &defaultURL, 1 ),
- rtl::OUString() );
- }
- infos = defaultInfos;
- }
- rtl::OUString latestVersion( package->getVersion() );
- sal_Int32 latestIndex = -1;
- for ( sal_Int32 i = 0; i < infos.getLength(); ++i )
- {
- dp_misc::DescriptionInfoset infoset( mxContext,
- uno::Reference< xml::dom::XNode >( infos[i], uno::UNO_QUERY_THROW));
- boost::optional< rtl::OUString > id2( infoset.getIdentifier() );
+ // check, if there are unsatisfied dependencies and ignore this online update
+ dp_misc::DescriptionInfoset infoset(mxContext, info.info);
+ uno::Sequence< uno::Reference< xml::dom::XElement > >
+ ds( dp_misc::Dependencies::check( infoset ) );
+ if ( ! ds.getLength() )
+ sOnlineVersion = info.version;
+ }
- if (!id2)
- continue;
+ rtl::OUString sVersionUser;
+ rtl::OUString sVersionShared;
+ rtl::OUString sVersionBundled;
+ uno::Sequence< uno::Reference< deployment::XPackage> > extensions;
+ try {
+ extensions = extMgr->getExtensionsWithSameIdentifier(
+ dp_misc::getIdentifier(info.extension), info.extension->getName(),
+ uno::Reference<css_ucb::XCommandEnvironment>());
+ } catch (lang::IllegalArgumentException& ) {
+ OSL_ASSERT(0);
+ }
+ OSL_ASSERT(extensions.getLength() == 3);
+ if (extensions[0].is() )
+ sVersionUser = extensions[0]->getVersion();
+ if (extensions[1].is() )
+ sVersionShared = extensions[1]->getVersion();
+ if (extensions[2].is() )
+ sVersionBundled = extensions[2]->getVersion();
+
+ bool bSharedReadOnly = extMgr->isReadOnlyRepository(OUSTR("shared"));
+
+ dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension(
+ bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion);
+ dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension(
+ bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion);
+
+ rtl::OUString updateVersionUser;
+ rtl::OUString updateVersionShared;
+ if (sourceUser != dp_misc::UPDATE_SOURCE_NONE)
+ updateVersionUser = dp_misc::getHighestVersion(
+ rtl::OUString(), sVersionShared, sVersionBundled, sOnlineVersion);
+ if (sourceShared != dp_misc::UPDATE_SOURCE_NONE)
+ updateVersionShared = dp_misc::getHighestVersion(
+ rtl::OUString(), rtl::OUString(), sVersionBundled, sOnlineVersion);
+ rtl::OUString updateVersion;
+ if (dp_misc::compareVersions(updateVersionUser, updateVersionShared) == dp_misc::GREATER)
+ updateVersion = updateVersionUser;
+ else
+ updateVersion = updateVersionShared;
+ if (updateVersion.getLength())
+ {
- if (*id2 == id)
- {
- // check, if there are unsatisfied dependencies and ignore those updates
- uno::Sequence< uno::Reference< xml::dom::XElement > > ds( dp_misc::Dependencies::check( infoset ) );
- if ( ds.getLength() )
- continue;
-
- rtl::OUString v( infoset.getVersion() );
- if ( dp_misc::compareVersions( v, latestVersion ) == dp_misc::GREATER )
- {
- latestVersion = v;
- latestIndex = i;
- }
- }
- }
- if ( latestIndex != -1 )
- {
- rtl::OUString aNewEntry[2];
- aNewEntry[0] = id;
- aNewEntry[1] = latestVersion;
- aList.realloc( ++nCount );
- aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
- }
+ rtl::OUString aNewEntry[2];
+ aNewEntry[0] = i->first;
+ aNewEntry[1] = updateVersion;
+ aList.realloc( ++nCount );
+ aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
}
}
return aList;
}
//------------------------------------------------------------------------------
-uno::Sequence< uno::Sequence< rtl::OUString > >
- PackageInformationProvider::getExtensionList(
- const uno::Reference< deployment::XPackageManager > _xManager )
+uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::getExtensionList()
+ throw ( uno::RuntimeException )
{
- uno::Sequence< uno::Sequence< rtl::OUString > > aList;
+ const uno::Reference<deployment::XExtensionManager> mgr =
+ deployment::ExtensionManager::get(mxContext);
- if ( _xManager.is() )
- {
- uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( _xManager ) );
+ if (!mgr.is())
+ return uno::Sequence< uno::Sequence< rtl::OUString > >();
- aList.realloc( packages.getLength() );
+ const uno::Sequence< uno::Sequence< uno::Reference<deployment::XPackage > > >
+ allExt = mgr->getAllExtensions(
+ uno::Reference< task::XAbortChannel >(),
+ static_cast < XCommandEnvironment *> (this) );
- for ( int pos = packages.getLength(); pos--; )
- {
- uno::Reference< deployment::XPackage > package( packages[ pos ] );
- rtl::OUString aNewEntry[2];
-
- aNewEntry[0] = dp_misc::getIdentifier( package );
- aNewEntry[1] = package->getVersion();
- aList[ pos ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
- }
- }
- return aList;
-}
+ uno::Sequence< uno::Sequence< rtl::OUString > > retList;
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Sequence< rtl::OUString > > PackageInformationProvider::concatLists(
- uno::Sequence< uno::Sequence< rtl::OUString > > aFirst,
- uno::Sequence< uno::Sequence< rtl::OUString > > aSecond )
-{
- sal_Int32 nFirstCount = aFirst.getLength();
- sal_Int32 nSecondCount = aSecond.getLength();
- sal_Int32 nIndex = nFirstCount;
+ sal_Int32 cAllIds = allExt.getLength();
+ retList.realloc(cAllIds);
- for ( sal_Int32 i=0; i < nSecondCount; i++ )
+ for (sal_Int32 i = 0; i < cAllIds; i++)
{
- bool bDuplicateEntry = false;
- for ( sal_Int32 j=0; j < nFirstCount; j++ )
+ //The inner sequence contains extensions with the same identifier from
+ //all the different repositories, that is user, share, bundled.
+ const uno::Sequence< uno::Reference< deployment::XPackage > > &
+ seqExtension = allExt[i];
+ sal_Int32 cExt = seqExtension.getLength();
+ OSL_ASSERT(cExt == 3);
+ for (sal_Int32 j = 0; j < cExt; j++)
{
- if ( aFirst[ j ][0] == aSecond[ i ][0] )
+ //ToDo according to the old code the first found extenions is used
+ //even if another one with the same id has a better version.
+ uno::Reference< deployment::XPackage > const & xExtension( seqExtension[j] );
+ if (xExtension.is())
{
- bDuplicateEntry = true;
+ rtl::OUString aNewEntry[2];
+ aNewEntry[0] = dp_misc::getIdentifier(xExtension);
+ aNewEntry[1] = xExtension->getVersion();
+ retList[i] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
break;
}
}
- if ( !bDuplicateEntry )
- {
- nIndex += 1;
- aFirst.realloc( nIndex );
- aFirst[ nIndex - 1 ] = aSecond[ i ];
- }
}
- return aFirst;
+ return retList;
}
+
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index 3f13cb021aae..44bc4d469f2f 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -39,6 +39,7 @@
#include "rtl/bootstrap.hxx"
#include "osl/diagnose.h"
#include "osl/file.hxx"
+#include "osl/security.hxx"
#include "cppuhelper/weakref.hxx"
#include "cppuhelper/exc_hlp.hxx"
#include "cppuhelper/implbase1.hxx"
@@ -57,11 +58,18 @@
#include "com/sun/star/ucb/NameClash.hpp"
#include "com/sun/star/deployment/VersionException.hpp"
#include "com/sun/star/deployment/InstallException.hpp"
+#include "com/sun/star/deployment/Prerequisites.hpp"
#include "com/sun/star/task/XInteractionApprove.hpp"
#include "com/sun/star/ucb/UnsupportedCommandException.hpp"
#include "boost/bind.hpp"
-#include <vector>
+#include "tools/urlobj.hxx"
+#include "osl/file.hxx"
+#include <vector>
+#include <list>
+#include "dp_descriptioninfoset.hxx"
+#include "dp_commandenvironments.hxx"
+#include "dp_properties.hxx"
using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -91,6 +99,28 @@ struct MatchTempDir
}
};
+
+namespace {
+OUString getExtensionFolder(OUString const & parentFolder,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+{
+ ::ucbhelper::Content tempFolder(
+ parentFolder, xCmdEnv );
+ Reference<sdbc::XResultSet> xResultSet(
+ tempFolder.createCursor(
+ Sequence<OUString>( &StrTitle::get(), 1 ),
+ ::ucbhelper::INCLUDE_FOLDERS_ONLY ) );
+
+ OUString title;
+ while (xResultSet->next())
+ {
+ title = Reference<sdbc::XRow>(
+ xResultSet, UNO_QUERY_THROW )->getString(1 /* Title */ ) ;
+ break;
+ }
+ return title;
+}
+}
//______________________________________________________________________________
void PackageManagerImpl::initActivationLayer(
Reference<XCommandEnvironment> const & xCmdEnv )
@@ -135,7 +165,8 @@ void PackageManagerImpl::initActivationLayer(
{
ActivePackages::Data dbData;
insertToActivationLayer(
- mediaType, sourceContent, title, &dbData );
+ Sequence<css::beans::NamedValue>(),mediaType, sourceContent,
+ title, &dbData );
insertToActivationLayerDB( title, dbData );
//TODO #i73136#: insertToActivationLayerDB needs id not
@@ -151,12 +182,24 @@ void PackageManagerImpl::initActivationLayer(
// user|share:
OSL_ASSERT( m_activePackages.getLength() > 0 );
m_activePackages_expanded = expandUnoRcUrl( m_activePackages );
- create_folder( 0, m_activePackages_expanded, xCmdEnv, !m_readOnly );
+ m_registrationData_expanded = expandUnoRcUrl(m_registrationData);
+ if (!m_readOnly)
+ create_folder( 0, m_activePackages_expanded, xCmdEnv, true);
+
+ OUString dbName;
+ if (m_context.equals(OUSTR("user")))
+ dbName = m_activePackages_expanded + OUSTR(".db");
+ else
+ {
+ //Create the extension data base in the user installation
+ create_folder( 0, m_registrationData_expanded, xCmdEnv, true);
+ dbName = m_registrationData_expanded + OUSTR("/extensions.db");
+ }
+ //The data base can always be written because it it always in the user installation
m_activePackagesDB.reset(
- new ActivePackages(
- m_activePackages_expanded + OUSTR(".db"), m_readOnly ) );
+ new ActivePackages( dbName, false ) );
- if (! m_readOnly)
+ if (! m_readOnly && ! m_context.equals(OUSTR("bundled")))
{
// clean up activation layer, scan for zombie temp dirs:
ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() );
@@ -169,17 +212,37 @@ void PackageManagerImpl::initActivationLayer(
::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
// get all temp directories:
::std::vector<OUString> tempEntries;
- while (xResultSet->next()) {
+ ::std::vector<OUString> removedEntries;
+ while (xResultSet->next())
+ {
OUString title(
Reference<sdbc::XRow>(
xResultSet, UNO_QUERY_THROW )->getString(
1 /* Title */ ) );
- tempEntries.push_back( ::rtl::Uri::encode(
- title, rtl_UriCharClassPchar,
- rtl_UriEncodeIgnoreEscapes,
- RTL_TEXTENCODING_UTF8 ) );
+
+ const char extensionRemoved[] = "removed";
+ if (title.endsWithAsciiL(
+ extensionRemoved, sizeof(extensionRemoved) - 1))
+ {
+ //save the file name withouth the "removed" part
+ sal_Int32 index = title.lastIndexOfAsciiL(
+ extensionRemoved, sizeof(extensionRemoved) - 1);
+ OUString remFile = title.copy(0, index);
+ removedEntries.push_back(::rtl::Uri::encode(
+ remFile, rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8 ) );
+ }
+ else
+ {
+ tempEntries.push_back( ::rtl::Uri::encode(
+ title, rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8 ) );
+ }
}
+ bool bShared = m_context.equals(OUSTR("shared")) ? true : false;
for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos )
{
OUString const & tempEntry = tempEntries[ pos ];
@@ -187,14 +250,52 @@ void PackageManagerImpl::initActivationLayer(
if (::std::find_if( id2temp.begin(), id2temp.end(), match ) ==
id2temp.end())
{
+ const OUString url(
+ makeURL(m_activePackages_expanded, tempEntry ) );
+
+ //In case of shared extensions, new entries are regarded as
+ //added extensions if there is no xxx.tmpremoved file.
+ if (bShared)
+ {
+ if (::std::find(removedEntries.begin(), removedEntries.end(), tempEntry) ==
+ removedEntries.end())
+ {
+ continue;
+ }
+ else
+ {
+ //Make sure only the same user removes the extension, who
+ //previously unregistered it. This is avoid races if multiple instances
+ //of OOo are running which all have write access to the shared installation.
+ //For example, a user removes the extension, but keeps OOo
+ //running. Parts of the extension may still be loaded and used by OOo.
+ //Therefore the extension is only deleted the next time the extension manager is
+ //run after restarting OOo. While OOo is still running, another user starts OOo
+ //which would deleted the extension files. If the same user starts another
+ //instance of OOo then the lock file will prevent this.
+ OUString aUserName;
+ ::osl::Security aSecurity;
+ aSecurity.getUserName( aUserName );
+ ucbhelper::Content remFileContent(
+ url + OUSTR("removed"), Reference<XCommandEnvironment>());
+ ::rtl::ByteSequence data = dp_misc::readFile(remFileContent);
+ ::rtl::OString osData(reinterpret_cast<const sal_Char*>(data.getConstArray()),
+ data.getLength());
+ OUString sData = ::rtl::OStringToOUString(
+ osData, RTL_TEXTENCODING_UTF8);
+ if (!sData.equals(aUserName))
+ continue;
+ }
+ }
// temp entry not needed anymore:
- const OUString url( makeURL( m_activePackages_expanded,
- tempEntry ) );
erase_path( url + OUSTR("_"),
Reference<XCommandEnvironment>(),
false /* no throw: ignore errors */ );
erase_path( url, Reference<XCommandEnvironment>(),
false /* no throw: ignore errors */ );
+ //delete the xxx.tmpremoved file
+ erase_path(url + OUSTR("removed"),
+ Reference<XCommandEnvironment>(), false);
}
}
}
@@ -206,9 +307,9 @@ void PackageManagerImpl::initRegistryBackends()
{
if (m_registryCache.getLength() > 0)
create_folder( 0, m_registryCache,
- Reference<XCommandEnvironment>(), !m_readOnly );
+ Reference<XCommandEnvironment>(), false);
m_xRegistry.set( ::dp_registry::create(
- m_context, m_registryCache, m_readOnly,
+ m_context, m_registryCache, false,
m_xComponentContext ) );
}
@@ -223,12 +324,14 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
OUString packages, logFile, stampURL;
if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("user") )) {
- that->m_activePackages = OUSTR("vnd.sun.star.expand:$UNO_"
- "USER_PACKAGES_CACHE/uno_packages");
- that->m_registryCache = OUSTR("vnd.sun.star.expand:$UNO_"
- "USER_PACKAGES_CACHE/registry");
- logFile = OUSTR("vnd.sun.star.expand:$UNO_"
- "USER_PACKAGES_CACHE/log.txt");
+ that->m_activePackages = OUSTR(
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages");
+ that->m_registrationData = OUSTR(
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE");
+ that->m_registryCache = OUSTR(
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/registry");
+ logFile = OUSTR(
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/log.txt");
//We use the extension .sys for the file because on Windows Vista a sys
//(as well as exe and dll) file
//will not be written in the VirtualStore. For example if the process has no
@@ -240,25 +343,42 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
//using virtualization it appears that he/she can. Then a shared extension can
//be installed but is only visible for the user (because the extension is in
//the virtual store).
- stampURL = OUSTR("vnd.sun.star.expand:$UNO_"
- "USER_PACKAGES_CACHE/stamp.sys");
+ stampURL = OUSTR(
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/stamp.sys");
}
else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) {
- that->m_activePackages = OUSTR("vnd.sun.star.expand:$UNO_"
- "SHARED_PACKAGES_CACHE/uno_packages");
- that->m_registryCache = OUSTR("vnd.sun.star.expand:$UNO_"
- "SHARED_PACKAGES_CACHE/registry");
-// The current logging implementation does not work for shared, because it requires
-// write access to the logfile. When two users run OOo at the same time on the same machine
-// then the
-// second will fail because it does not get write access. One cannot write into the
-// user's home, because then people may complain that when installing shared extension
-// stuff is written in their home.
-// logFile = OUSTR("vnd.sun.star.expand:$UNO_"
-// "SHARED_PACKAGES_CACHE/log.txt");
- //See description for stampURL for user packages.
- stampURL = OUSTR("vnd.sun.star.expand:$UNO_"
- "SHARED_PACKAGES_CACHE/stamp.sys");
+ that->m_activePackages = OUSTR(
+ "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages");
+ that->m_registrationData = OUSTR(
+ "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER");
+ that->m_registryCache = OUSTR(
+ "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/registry");
+ logFile = OUSTR(
+ "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/log.txt");
+ stampURL = OUSTR(
+ "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/stamp.sys");
+ }
+ else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") )) {
+ that->m_activePackages = OUSTR(
+ "vnd.sun.star.expand:$BUNDLED_EXTENSIONS");
+ that->m_registrationData = OUSTR(
+ "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER");
+ that->m_registryCache = OUSTR(
+ "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/registry");
+ logFile = OUSTR(
+ "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/log.txt");
+ //No stamp file. We assume that bundled is always readonly. It must not be
+ //modified from ExtensionManager but only by the installer
+ }
+ else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") )) {
+ that->m_activePackages = OUSTR(
+ "vnd.sun.star.expand:$TMP_EXTENSIONS/extensions");
+ that->m_registrationData = OUSTR(
+ "vnd.sun.star.expand:$TMP_EXTENSIONS");
+ that->m_registryCache = OUSTR(
+ "vnd.sun.star.expand:$TMP_EXTENSIONS/registry");
+ stampURL = OUSTR(
+ "vnd.sun.star.expand:$TMP_EXTENSIONS/stamp.sys");
}
else if (! context.matchAsciiL(
RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:/") )) {
@@ -270,29 +390,15 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
Reference<XCommandEnvironment> xCmdEnv;
try {
- bool renewal = false;
-
+ //There is no stampURL for the bundled folder
if (stampURL.getLength() > 0)
{
- // currently no automatic renewal possible, because quickstarter
- // already hinders from deleting registry directory...
-
#define CURRENT_STAMP "1"
-// renewal = true;
-// {
-// ::ucbhelper::Content ucbStamp;
-// if (create_ucb_content(
-// &ucbStamp, stampURL, xCmdEnv, false /* no throw */ ))
-// {
-// OUString line;
-// renewal = !readLine( &line, OUSTR(CURRENT_STAMP), ucbStamp,
-// RTL_TEXTENCODING_ASCII_US );
-// }
-// }
-
try {
+ //The osl file API does not allow to find out if one can write
+ //into a folder. Therefore we try to write a file. Then we delete
+ //it, so that it does not hinder uninstallation of OOo
// probe writing:
- erase_path( stampURL, xCmdEnv );
::ucbhelper::Content ucbStamp( stampURL, xCmdEnv );
::rtl::OString stamp(
RTL_CONSTASCII_STRINGPARAM(CURRENT_STAMP) );
@@ -302,8 +408,15 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
reinterpret_cast<sal_Int8 const *>(stamp.getStr()),
stamp.getLength() ) ) );
ucbStamp.writeStream( xData, true /* replace existing */ );
+ that->m_readOnly = false;
+ erase_path( stampURL, xCmdEnv );
}
catch (RuntimeException &) {
+ try {
+ erase_path( stampURL, xCmdEnv );
+ } catch (...)
+ {
+ }
throw;
}
catch (Exception &) {
@@ -324,12 +437,6 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
xCmdEnv.set( new CmdEnvWrapperImpl( xCmdEnv, that->m_xLogFile ) );
}
- OSL_ENSURE( !that->m_readOnly || !renewal,
- "### ought to reinstall all packages, but cannot write!" );
- if (!that->m_readOnly && renewal) // try to reinstall
- that->reinstallDeployedPackages(
- Reference<task::XAbortChannel>(), xCmdEnv );
-
that->initRegistryBackends();
that->initActivationLayer( xCmdEnv );
@@ -484,7 +591,7 @@ OUString PackageManagerImpl::detectMediaType(
try {
Reference<deployment::XPackage> xPackage(
m_xRegistry->bindPackage(
- url, OUString(), ucbContent.getCommandEnvironment() ) );
+ url, OUString(), false, OUString(), ucbContent.getCommandEnvironment() ) );
const Reference<deployment::XPackageTypeInfo> xPackageType(
xPackage->getPackageType() );
OSL_ASSERT( xPackageType.is() );
@@ -504,6 +611,7 @@ OUString PackageManagerImpl::detectMediaType(
//______________________________________________________________________________
OUString PackageManagerImpl::insertToActivationLayer(
+ Sequence<beans::NamedValue> const & properties,
OUString const & mediaType, ::ucbhelper::Content const & sourceContent_,
OUString const & title, ActivePackages::Data * dbData )
{
@@ -564,10 +672,22 @@ OUString PackageManagerImpl::insertToActivationLayer(
title, NameClash::OVERWRITE ))
throw RuntimeException( OUSTR("UCB transferContent() failed!"), 0 );
+
// write to DB:
+ //bundled extensions should only be added by the synchronizeAddedExtensions
+ //functions. Moreover, there is no "temporary folder" for bundled extensions.
+ OSL_ASSERT(!m_context.equals(OUSTR("bundled")));
+ OUString sFolderUrl = makeURLAppendSysPathSegment(destFolderContent.getURL(), title);
+ DescriptionInfoset info =
+ dp_misc::getDescriptionInfoset(sFolderUrl);
dbData->temporaryName = tempEntry;
dbData->fileName = title;
dbData->mediaType = mediaType;
+ dbData->version = info.getVersion();
+
+ //No write the properties file next to the extension
+ ExtensionProperties props(sFolderUrl, properties, xCmdEnv);
+ props.write();
return destFolder;
}
@@ -575,6 +695,8 @@ OUString PackageManagerImpl::insertToActivationLayer(
void PackageManagerImpl::insertToActivationLayerDB(
OUString const & id, ActivePackages::Data const & dbData )
{
+ //access to the database must be guarded. See removePackage
+ const ::osl::MutexGuard guard( getMutex() );
m_activePackagesDB->put( id, dbData );
}
@@ -582,81 +704,40 @@ void PackageManagerImpl::insertToActivationLayerDB(
/* The function returns true if there is an extension with the same id already
installed which needs to be uninstalled, before the new extension can be installed.
*/
-bool PackageManagerImpl::checkUpdate(
- Reference<deployment::XPackage> const & package,
- Reference<XCommandEnvironment> const & origCmdEnv,
- Reference<XCommandEnvironment> const & wrappedCmdEnv )
+bool PackageManagerImpl::isInstalled(
+ Reference<deployment::XPackage> const & package)
{
OUString id(dp_misc::getIdentifier(package));
OUString fn(package->getName());
- bool removeExisting = false;
+ bool bInstalled = false;
if (m_activePackagesDB->has( id, fn ))
{
- // package already deployed, interact --force:
- Any request(
- (deployment::VersionException(
- getResourceString( RID_STR_PACKAGE_ALREADY_ADDED ) + id,
- static_cast<OWeakObject *>(this), package,
- getDeployedPackage_( id, fn, origCmdEnv ) ) ) );
- bool replace = false, abort = false;
- if (! interactContinuation(
- request, task::XInteractionApprove::static_type(),
- wrappedCmdEnv, &replace, &abort )) {
- OSL_ASSERT( !replace && !abort );
- throw deployment::DeploymentException(
- getResourceString(RID_STR_ERROR_WHILE_ADDING) + id,
- static_cast<OWeakObject *>(this), request );
- }
- if (abort || !replace)
- throw CommandFailedException(
- getResourceString(RID_STR_PACKAGE_ALREADY_ADDED) + id,
- static_cast<OWeakObject *>(this), request );
-
- // remove clashing package before registering new version:
- removeExisting = true;
+ bInstalled = true;
}
- return removeExisting;
+ return bInstalled;
}
+
+// XPackageManager
//______________________________________________________________________________
-// Notify the user when a new extension is to be installed. This is only the case
-//when unopkg gui extension1 is used (used by system integration (double click on .oxt
-// file etc.)). In case there is already this extension then the function returns
-//true.
-//ToDo: Function always returns true or throws an exception
-bool PackageManagerImpl::checkInstall(
- Reference<deployment::XPackage> const & package,
- Reference<XCommandEnvironment> const & cmdEnv)
+Reference<deployment::XPackage> PackageManagerImpl::importExtension(
+ Reference<deployment::XPackage> const & extension,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<XCommandEnvironment> const & xCmdEnv_ )
+ throw (deployment::DeploymentException, CommandFailedException,
+ CommandAbortedException, lang::IllegalArgumentException,
+ RuntimeException)
{
- OUString id(dp_misc::getIdentifier(package));
- if ( ! m_activePackagesDB->has( id, package->getName() ))
- {
- Any request(
- deployment::InstallException(
- OUSTR("Extension ") + id + OUSTR(" is about to be installed."),
- static_cast<OWeakObject *>(this), package));
- bool approve = false, abort = false;
- if (! interactContinuation(
- request, task::XInteractionApprove::static_type(),
- cmdEnv, &approve, &abort ))
- {
- OSL_ASSERT( !approve && !abort );
- throw deployment::DeploymentException(
- getResourceString(RID_STR_ERROR_WHILE_ADDING) + id,
- static_cast<OWeakObject *>(this), request );
- }
- if (abort || !approve)
- throw CommandFailedException(
- getResourceString(RID_STR_ERROR_WHILE_ADDING) + id,
- static_cast<OWeakObject *>(this), request );
-
- }
- return true;
+ return addPackage(extension->getURL(), Sequence<beans::NamedValue>(),
+ OUString(), xAbortChannel, xCmdEnv_);
}
-// XPackageManager
-//______________________________________________________________________________
+/* The function adds an extension but does not register it!!!
+ It may not do any user interaction. This is done in XExtensionManager::addExtension
+*/
Reference<deployment::XPackage> PackageManagerImpl::addPackage(
- OUString const & url, OUString const & mediaType_,
+ OUString const & url,
+ css::uno::Sequence<css::beans::NamedValue> const & properties,
+ OUString const & mediaType_,
Reference<task::XAbortChannel> const & xAbortChannel,
Reference<XCommandEnvironment> const & xCmdEnv_ )
throw (deployment::DeploymentException, CommandFailedException,
@@ -729,84 +810,34 @@ Reference<deployment::XPackage> PackageManagerImpl::addPackage(
}
ActivePackages::Data dbData;
destFolder = insertToActivationLayer(
- mediaType, sourceContent, title, &dbData );
+ properties, mediaType, sourceContent, title, &dbData );
// bind activation package:
- //Because every extension will be unpacked in a folder, which was created with a unique name
- //we will always have two different XPackage objects, even if the second extension is the same.
+ //Because every shared/user extension will be unpacked in a folder,
+ //which was created with a unique name we will always have two different
+ //XPackage objects, even if the second extension is the same.
//Therefore bindPackage does not need a guard here.
xPackage = m_xRegistry->bindPackage(
- makeURL( destFolder, title_enc ), mediaType, xCmdEnv );
+ makeURL( destFolder, title_enc ), mediaType, false, OUString(), xCmdEnv );
OSL_ASSERT( xPackage.is() );
if (xPackage.is())
{
bool install = false;
- OUString id;
-
try
{
- id = dp_misc::getIdentifier( xPackage );
- //checkInstall throws an exception if the user denies the installation
- checkInstall(xPackage, xCmdEnv);
- //checkUpdate throws an exception if the user cancels the interaction.
- //For example, he may be asked if he wants to replace the older version
- //with the new version.
- //checkUpdates must be called before checkPrerequisites
- bool bAlreadyInstalled = checkUpdate(
- xPackage, xCmdEnv_, xCmdEnv );
-
- if (xPackage->checkPrerequisites(xAbortChannel, xCmdEnv, bAlreadyInstalled, m_context))
+ OUString const id = dp_misc::getIdentifier( xPackage );
+
+ ::osl::MutexGuard g(m_addMutex);
+ if (isInstalled(xPackage))
{
- //This guard is used to prevent that an extension is installed twice. Do not use it in other
- //functions.
- //Imagine addPackage is called two times by different threads for the same extension quickly
- //after each other.
- //The second call would calculate "bAlreadyInstalled = false" if the first thread has not yet reached
- //insertToActivationLayerDB.
- ::osl::MutexGuard g(m_addMutex);
-
- //Holds the database data of the old extension, in case we need to roll back.
- ActivePackages::Data oldDbData;
- if (bAlreadyInstalled)
- {
- // Remove extension which is already installed. It is not removed from disk, only
- // the different contents are being unregisterd. We remember the databas information
- // in case we need to roll back this operation.
- // When the user canceled the operation (CommandAbortedException) than the package is still
- // fully functional.
- // Do not guard the complete function with the getMutex
- removePackage_(id, xPackage->getName(), xAbortChannel,
- xCmdEnv, & oldDbData);
- }
- install = true;
- const ::osl::MutexGuard guard( getMutex() );
- try
- {
- //throws CommandAbortedException if the user cancelled the installation.
- xPackage->registerPackage(xAbortChannel, xCmdEnv);
- }
- catch(CommandAbortedException & )
- { //ToDo: Interaction so that the gui can display an appropriate string.
- //See also removePackage_
- //User aborted installation, restore the previous situation.
- //Use a private AbortChannel so the user cannot interrupt.
- xPackage->revokePackage(new AbortChannel(), xCmdEnv);
- if (bAlreadyInstalled)
- {
- OUString instFolder = makeURL( m_activePackages, oldDbData.temporaryName)
- + OUSTR("_");
- Reference<deployment::XPackage> xOldPgk = m_xRegistry->bindPackage(
- makeURL( instFolder, oldDbData.fileName ), oldDbData.mediaType, xCmdEnv );
- xOldPgk->registerPackage(new AbortChannel(), xCmdEnv);
- insertToActivationLayerDB(dp_misc::getIdentifier( xOldPgk ), oldDbData);
- }
- throw;
- }
- //access to the database must be guarded. See removePackage_
- insertToActivationLayerDB(id, dbData);
+ //Do not guard the complete function with the getMutex
+ removePackage(id, xPackage->getName(), xAbortChannel,
+ xCmdEnv);
}
+ install = true;
+ insertToActivationLayerDB(id, dbData);
}
catch (...)
{
@@ -817,6 +848,7 @@ Reference<deployment::XPackage> PackageManagerImpl::addPackage(
{
deletePackageFromCache( xPackage, destFolder );
}
+ //ToDo: We should notify only if the extension is registered
fireModified();
}
return xPackage;
@@ -861,57 +893,15 @@ void PackageManagerImpl::deletePackageFromCache(
}
//______________________________________________________________________________
-void PackageManagerImpl::removePackage_(
- OUString const & id, OUString const & fileName,
- Reference<task::XAbortChannel> const & xAbortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv,
- ActivePackages::Data * out_dbData)
-{
- Reference<deployment::XPackage> xPackage;
- {
- try {
- const ::osl::MutexGuard guard(getMutex());
- xPackage = getDeployedPackage_(id, fileName, xCmdEnv );
- m_activePackagesDB->get(out_dbData, id, fileName);
- beans::Optional< beans::Ambiguous<sal_Bool> > option(
- xPackage->isRegistered( Reference<task::XAbortChannel>(),
- xCmdEnv ) );
- if (!option.IsPresent || option.Value.IsAmbiguous || option.Value.Value)
- xPackage->revokePackage( xAbortChannel, xCmdEnv );
- m_activePackagesDB->erase( id, fileName ); // to be removed upon next start
- }
- catch (CommandAbortedException &)
- {
- //ToDo: interaction, so that gui can show an appropriate string
- //reregister the package
- //Create our own XAbortChannel, so the user cannot interrupt the registration.
- xPackage->registerPackage(new AbortChannel(), xCmdEnv);
- throw;
- }
- }
- try_dispose( xPackage );
-}
-
-//______________________________________________________________________________
void PackageManagerImpl::removePackage(
OUString const & id, ::rtl::OUString const & fileName,
- Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<task::XAbortChannel> const & /*xAbortChannel*/,
Reference<XCommandEnvironment> const & xCmdEnv_ )
throw (deployment::DeploymentException, CommandFailedException,
CommandAbortedException, lang::IllegalArgumentException,
RuntimeException)
{
check();
- if (m_readOnly)
- {
- OUString message;
- if (m_context == OUSTR("shared"))
- message = OUSTR("You need write permissions in order to remove a shared extension!");
- else
- message = OUSTR("You need write permissions in order to remove this extension!");
- throw deployment::DeploymentException(
- message, static_cast<OWeakObject *>(this), Any() );
- }
Reference<XCommandEnvironment> xCmdEnv;
if (m_xLogFile.is())
@@ -920,7 +910,48 @@ void PackageManagerImpl::removePackage(
xCmdEnv.set( xCmdEnv_ );
try {
- removePackage_( id, fileName, xAbortChannel, xCmdEnv, NULL);
+ Reference<deployment::XPackage> xPackage;
+ {
+ const ::osl::MutexGuard guard(getMutex());
+ //Check if this extension exist and throw an IllegalArgumentException
+ //if it does not
+ //If the files of the extension are already removed, or there is a
+ //different extension at the same place, for example after updating the
+ //extension, then the returned object is that which uses the database data.
+ xPackage = getDeployedPackage_(id, fileName, xCmdEnv );
+
+
+ //Because the extension is only removed the next time the extension
+ //manager runs after restarting OOo, we need to indicate that a
+ //shared extension was "deleted". When a user starts OOo, then it
+ //will check if something changed in the shared repository. Based on
+ //the flag file it will then recognize, that the extension was
+ //deleted and can then update the extnesion database of the shared
+ //extensions in the user installation.
+ if ( xPackage.is() && !m_readOnly && !xPackage->isRemoved() && m_context.equals(OUSTR("shared")))
+ {
+ ActivePackages::Data val;
+ m_activePackagesDB->get( & val, id, fileName);
+ OSL_ASSERT(val.temporaryName.getLength());
+ OUString url(makeURL(m_activePackages_expanded,
+ val.temporaryName + OUSTR("removed")));
+ ::ucbhelper::Content contentRemoved(url, xCmdEnv );
+ OUString aUserName;
+ ::osl::Security aSecurity;
+ aSecurity.getUserName( aUserName );
+
+ ::rtl::OString stamp = ::rtl::OUStringToOString(aUserName, RTL_TEXTENCODING_UTF8);
+ Reference<css::io::XInputStream> xData(
+ ::xmlscript::createInputStream(
+ ::rtl::ByteSequence(
+ reinterpret_cast<sal_Int8 const *>(stamp.getStr()),
+ stamp.getLength() ) ) );
+ contentRemoved.writeStream( xData, true /* replace existing */ );
+ }
+ m_activePackagesDB->erase( id, fileName ); // to be removed upon next start
+ }
+ try_dispose( xPackage );
+
fireModified();
}
catch (RuntimeException &) {
@@ -955,10 +986,16 @@ OUString PackageManagerImpl::getDeployPath( ActivePackages::Data const & data )
{
::rtl::OUStringBuffer buf;
buf.append( data.temporaryName );
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_/") );
- buf.append( ::rtl::Uri::encode( data.fileName, rtl_UriCharClassPchar,
+ //The bundled extensions are not contained in an additional folder
+ //with a unique name. data.temporaryName contains already the
+ //UTF8 encoded folder name. See PackageManagerImpl::synchronize
+ if (!m_context.equals(OUSTR("bundled")))
+ {
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_/") );
+ buf.append( ::rtl::Uri::encode( data.fileName, rtl_UriCharClassPchar,
rtl_UriEncodeIgnoreEscapes,
RTL_TEXTENCODING_UTF8 ) );
+ }
return makeURL( m_activePackages, buf.makeStringAndClear() );
}
@@ -997,8 +1034,22 @@ Reference<deployment::XPackage> PackageManagerImpl::getDeployedPackage_(
static_cast<sal_Int16>(-1) );
}
}
- return m_xRegistry->bindPackage(
- getDeployPath( data ), data.mediaType, xCmdEnv );
+ Reference<deployment::XPackage> xExtension;
+ try
+ {
+ //Ignore extensions where XPackage::checkPrerequisites failed.
+ //They must not be usable for this user.
+ if (data.failedPrerequisites.equals(OUSTR("0")))
+ {
+ xExtension = m_xRegistry->bindPackage(
+ getDeployPath( data ), data.mediaType, false, OUString(), xCmdEnv );
+ }
+ }
+ catch (deployment::InvalidRemovedParameterException& e)
+ {
+ xExtension = e.Extension;
+ }
+ return xExtension;
}
//______________________________________________________________________________
@@ -1012,6 +1063,8 @@ PackageManagerImpl::getDeployedPackages_(
ActivePackages::Entries::const_iterator const iEnd( id2temp.end() );
for ( ; iPos != iEnd; ++iPos )
{
+ if (! iPos->second.failedPrerequisites.equals(OUSTR("0")))
+ continue;
try {
packages.push_back(
getDeployedPackage_(
@@ -1124,25 +1177,18 @@ PackageManagerImpl::getDeployedPackages(
}
//______________________________________________________________________________
+
+
+//ToDo: the function must not call registerPackage, do this in
+//XExtensionManager.reinstallDeployedExtensions
void PackageManagerImpl::reinstallDeployedPackages(
- Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<task::XAbortChannel> const & /*xAbortChannel*/,
Reference<XCommandEnvironment> const & xCmdEnv_ )
throw (deployment::DeploymentException,
CommandFailedException, CommandAbortedException,
lang::IllegalArgumentException, RuntimeException)
{
check();
- if (m_readOnly)
- {
- OUString message;
- if (m_context == OUSTR("shared"))
- message = OUSTR("You need write permissions in order to install shared extensions!");
- else
- message = OUSTR("You need write permissions in order to install extensions!");
- throw deployment::DeploymentException(
- message, static_cast<OWeakObject *>(this), Any() );
- }
-
if (office_is_running())
throw RuntimeException(
OUSTR("You must close any running Office process before "
@@ -1167,12 +1213,7 @@ void PackageManagerImpl::reinstallDeployedPackages(
if (xUpdatable.is())
xUpdatable->update();
- // reregister all:
- const ::osl::MutexGuard guard( getMutex() );
- const Sequence< Reference<deployment::XPackage> > packages(
- getDeployedPackages_( xCmdEnv ) );
- for ( sal_Int32 pos = 0; pos < packages.getLength(); ++pos )
- packages[ pos ]->registerPackage( xAbortChannel, xCmdEnv );
+ //registering is done by the ExtensionManager service.
}
catch (RuntimeException &) {
throw;
@@ -1205,6 +1246,362 @@ void PackageManagerImpl::reinstallDeployedPackages(
{
return m_readOnly;
}
+bool PackageManagerImpl::synchronizeRemovedExtensions(
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
+{
+
+ //find all which are in the extension data base but which
+ //are removed already.
+ OSL_ASSERT(!m_context.equals(OUSTR("user")));
+ bool bModified = false;
+ ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() );
+
+ typedef ActivePackages::Entries::const_iterator ITActive;
+ bool bShared = m_context.equals(OUSTR("shared"));
+
+ for (ITActive i = id2temp.begin(); i != id2temp.end(); i++)
+ {
+ try
+ {
+ //Get the URL to the extensions folder, first make the url for the
+ //shared repository including the temporary name
+ OUString url = makeURL(m_activePackages, i->second.temporaryName);
+ if (bShared)
+ url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName);
+
+ bool bRemoved = false;
+ //Check if the URL to the extension is still the same
+ ::ucbhelper::Content contentExtension;
+
+ if (!create_ucb_content(
+ &contentExtension, url,
+ Reference<XCommandEnvironment>(), false))
+ {
+ bRemoved = true;
+ }
+
+ //The folder is in the extension database, but it can still be deleted.
+ //look for the xxx.tmpremoved file
+ //There can also be the case that a different extension was installed
+ //in a "temp" folder with name that is already used.
+ if (!bRemoved && bShared)
+ {
+ ::ucbhelper::Content contentRemoved;
+
+ if (create_ucb_content(
+ &contentRemoved,
+ m_activePackages_expanded + OUSTR("/") +
+ i->second.temporaryName + OUSTR("removed"),
+ Reference<XCommandEnvironment>(), false))
+ {
+ bRemoved = true;
+ }
+ }
+
+ if (!bRemoved)
+ {
+ //There may be another extensions at the same place
+ dp_misc::DescriptionInfoset infoset =
+ dp_misc::getDescriptionInfoset(url);
+ OSL_ENSURE(infoset.hasDescription(),
+ "Extension Manager: bundled and shared extensions "
+ "must have an identifer and a version");
+ if (infoset.hasDescription() &&
+ infoset.getIdentifier() &&
+ (! i->first.equals(*(infoset.getIdentifier()))
+ || ! i->second.version.equals(infoset.getVersion())))
+ {
+ bRemoved = true;
+ }
+
+ }
+ if (bRemoved)
+ {
+ Reference<deployment::XPackage> xPackage = m_xRegistry->bindPackage(
+ url, i->second.mediaType, true, i->first, xCmdEnv );
+ OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object.
+ xPackage->revokePackage(xAbortChannel, xCmdEnv);
+ removePackage(xPackage->getIdentifier().Value, xPackage->getName(),
+ xAbortChannel, xCmdEnv);
+ bModified |= true;
+ }
+ }
+ catch( uno::Exception & )
+ {
+ OSL_ASSERT(0);
+ }
+ }
+ return bModified;
+}
+
+
+bool PackageManagerImpl::synchronizeAddedExtensions(
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
+{
+ bool bModified = false;
+ ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() );
+ //check if the folder exist at all. The shared extension folder
+ //may not exist for a normal user.
+ if (!create_ucb_content(
+ NULL, m_activePackages_expanded, Reference<css::ucb::XCommandEnvironment>(), false))
+ return bModified;
+ ::ucbhelper::Content tempFolder(
+ m_activePackages_expanded, xCmdEnv );
+
+ Reference<sdbc::XResultSet> xResultSet(
+ tempFolder.createCursor(
+ Sequence<OUString>( &StrTitle::get(), 1 ),
+ ::ucbhelper::INCLUDE_FOLDERS_ONLY ) );
+
+ while (xResultSet->next())
+ {
+ try
+ {
+ OUString title(
+ Reference<sdbc::XRow>(
+ xResultSet, UNO_QUERY_THROW )->getString(
+ 1 /* Title */ ) );
+ //The temporary folders of user and shared have an '_' at then end.
+ //But the name in ActivePackages.temporaryName is saved without.
+ OUString title2 = title;
+ bool bNotBundled = !m_context.equals(OUSTR("bundled"));
+ if (bNotBundled)
+ {
+ OSL_ASSERT(title2[title2.getLength() -1] == '_');
+ title2 = title2.copy(0, title2.getLength() -1);
+ }
+ OUString titleEncoded = ::rtl::Uri::encode(
+ title2, rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8);
+
+ //It it sufficient to check for the folder name, because when the administor
+ //installed the extension it was already checked if there is one with the
+ //same identifier.
+ const MatchTempDir match(titleEncoded);
+ if (::std::find_if( id2temp.begin(), id2temp.end(), match ) ==
+ id2temp.end())
+ {
+
+ // The folder was not found in the data base, so it must be
+ // an added extension
+ OUString url(m_activePackages_expanded + OUSTR("/") + titleEncoded);
+ OUString sExtFolder;
+ if (bNotBundled) //that is, shared
+ {
+ //Check if the extension was not "deleted" already which is indicated
+ //by a xxx.tmpremoved file
+ ::ucbhelper::Content contentRemoved;
+ if (create_ucb_content(&contentRemoved, url + OUSTR("removed"),
+ Reference<XCommandEnvironment>(), false))
+ continue;
+ sExtFolder = getExtensionFolder(
+ m_activePackages_expanded +
+ OUString(OUSTR("/")) + titleEncoded + OUSTR("_"), xCmdEnv);
+ url = makeURLAppendSysPathSegment(m_activePackages_expanded, title);
+ url = makeURLAppendSysPathSegment(url, sExtFolder);
+ }
+ Reference<deployment::XPackage> xPackage = m_xRegistry->bindPackage(
+ url, OUString(), false, OUString(), xCmdEnv );
+ if (xPackage.is())
+ {
+ //Prepare the database entry
+ ActivePackages::Data dbData;
+
+ dbData.temporaryName = titleEncoded;
+ if (bNotBundled)
+ dbData.fileName = sExtFolder;
+ else
+ dbData.fileName = title;
+ dbData.mediaType = xPackage->getPackageType()->getMediaType();
+ dbData.version = xPackage->getVersion();
+ OSL_ENSURE(dbData.version.getLength() > 0,
+ "Extension Manager: bundled and shared extensions must have "
+ "an identifier and a version");
+
+ OUString id = dp_misc::getIdentifier( xPackage );
+
+ //We provide a special command environment that will prevent
+ //showing a license if simple-licens/@accept-by = "admin"
+ //It will also prevent showing the license for bundled extensions
+ //which is not supported.
+ OSL_ASSERT(!m_context.equals(OUSTR("user")));
+
+ // shall the license be suppressed?
+ DescriptionInfoset info =
+ dp_misc::getDescriptionInfoset(url);
+ ::boost::optional<dp_misc::SimpleLicenseAttributes>
+ attr = info.getSimpleLicenseAttributes();
+ ExtensionProperties props(url,xCmdEnv);
+ bool bNoLicense = false;
+ if (attr && attr->suppressIfRequired && props.isSuppressedLicense())
+ bNoLicense = true;
+
+ Reference<ucb::XCommandEnvironment> licCmdEnv(
+ new LicenseCommandEnv(xCmdEnv->getInteractionHandler(),
+ bNoLicense, m_context));
+ sal_Int32 failedPrereq = xPackage->checkPrerequisites(
+ xAbortChannel, licCmdEnv, false);
+ //Remember that this failed. For example, the user
+ //could have declined the license. Then the next time the
+ //extension folder is investigated we do not want to
+ //try to install the extension again.
+ dbData.failedPrerequisites = OUString::valueOf(failedPrereq);
+ insertToActivationLayerDB(id, dbData);
+ bModified |= true;
+ }
+ }
+ }
+ catch (uno::Exception &)
+ {
+ OSL_ASSERT(0);
+ }
+ }
+ return bModified;
+}
+
+sal_Bool PackageManagerImpl::synchronize(
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::uno::RuntimeException)
+{
+ check();
+ bool bModified = false;
+ if (m_context.equals(OUSTR("user")))
+ return bModified;
+ bModified |=
+ synchronizeRemovedExtensions(xAbortChannel, xCmdEnv);
+ bModified |= synchronizeAddedExtensions(xAbortChannel, xCmdEnv);
+
+ return bModified;
+}
+
+Sequence< Reference<deployment::XPackage> > PackageManagerImpl::getExtensionsWithUnacceptedLicenses(
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (deployment::DeploymentException, RuntimeException)
+{
+ ::std::vector<Reference<deployment::XPackage> > vec;
+
+ try
+ {
+ const ::osl::MutexGuard guard( getMutex() );
+ // clean up activation layer, scan for zombie temp dirs:
+ ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() );
+
+ ActivePackages::Entries::const_iterator i = id2temp.begin();
+ bool bShared = m_context.equals(OUSTR("shared"));
+
+ for (; i != id2temp.end(); i++ )
+ {
+ //Get the database entry
+ ActivePackages::Data const & dbData = i->second;
+ sal_Int32 failedPrereq = dbData.failedPrerequisites.toInt32();
+ //If the installation failed for other reason then the license then we
+ //ignore it.
+ if (failedPrereq ^= deployment::Prerequisites::LICENSE)
+ continue;
+
+ //Prepare the URL to the extension
+ OUString url = makeURL(m_activePackages, i->second.temporaryName);
+ if (bShared)
+ url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName);
+
+ Reference<deployment::XPackage> p = m_xRegistry->bindPackage(
+ url, OUString(), false, OUString(), xCmdEnv );
+
+ if (p.is())
+ vec.push_back(p);
+
+ }
+ return ::comphelper::containerToSequence(vec);
+ }
+ catch (deployment::DeploymentException &)
+ {
+ throw;
+ }
+ catch (RuntimeException&)
+ {
+ throw;
+ }
+ catch (...)
+ {
+ Any exc = ::cppu::getCaughtException();
+ deployment::DeploymentException de(
+ OUSTR("PackageManagerImpl::getExtensionsWithUnacceptedLicenses"),
+ static_cast<OWeakObject*>(this), exc);
+ exc <<= de;
+ ::cppu::throwException(exc);
+ }
+
+ return ::comphelper::containerToSequence(vec);
+}
+
+sal_Int32 PackageManagerImpl::checkPrerequisites(
+ css::uno::Reference<css::deployment::XPackage> const & extension,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException)
+{
+ try
+ {
+ if (!extension.is())
+ return 0;
+ if (!m_context.equals(extension->getRepositoryName()))
+ throw lang::IllegalArgumentException(
+ OUSTR("PackageManagerImpl::checkPrerequisites: extension is not"
+ " from this repository."), 0, 0);
+
+ ActivePackages::Data dbData;
+ OUString id = dp_misc::getIdentifier(extension);
+ if (m_activePackagesDB->get( &dbData, id, OUString()))
+ {
+ //If the license was already displayed, then do not show it again
+ Reference<ucb::XCommandEnvironment> _xCmdEnv = xCmdEnv;
+ sal_Int32 prereq = dbData.failedPrerequisites.toInt32();
+ if ( !(prereq & deployment::Prerequisites::LICENSE))
+ _xCmdEnv = new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler());
+
+ sal_Int32 failedPrereq = extension->checkPrerequisites(
+ xAbortChannel, _xCmdEnv, false);
+ dbData.failedPrerequisites = OUString::valueOf(failedPrereq);
+ insertToActivationLayerDB(id, dbData);
+ }
+ else
+ {
+ throw lang::IllegalArgumentException(
+ OUSTR("PackageManagerImpl::checkPrerequisites: unknown extension"),
+ 0, 0);
+
+ }
+ return 0;
+ }
+ catch (deployment::DeploymentException& ) {
+ throw;
+ } catch (ucb::CommandFailedException & ) {
+ throw;
+ } catch (ucb::CommandAbortedException & ) {
+ throw;
+ } catch (lang::IllegalArgumentException &) {
+ throw;
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (...) {
+ uno::Any excOccurred = ::cppu::getCaughtException();
+ deployment::DeploymentException exc(
+ OUSTR("PackageManagerImpl::checkPrerequisites: exception "),
+ static_cast<OWeakObject*>(this), excOccurred);
+ throw exc;
+ }
+}
//##############################################################################
diff --git a/desktop/source/deployment/manager/dp_manager.h b/desktop/source/deployment/manager/dp_manager.h
index ffa7252d7883..8fe0f662011b 100644
--- a/desktop/source/deployment/manager/dp_manager.h
+++ b/desktop/source/deployment/manager/dp_manager.h
@@ -53,6 +53,8 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper
{
css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
::rtl::OUString m_context;
+ ::rtl::OUString m_registrationData;
+ ::rtl::OUString m_registrationData_expanded;
::rtl::OUString m_registryCache;
bool m_readOnly;
@@ -73,6 +75,7 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper
::rtl::OUString detectMediaType(
::ucbhelper::Content const & ucbContent, bool throw_exc = true );
::rtl::OUString insertToActivationLayer(
+ css::uno::Sequence<css::beans::NamedValue> const & properties,
::rtl::OUString const & mediaType,
::ucbhelper::Content const & sourceContent,
::rtl::OUString const & title, ActivePackages::Data * dbData );
@@ -83,16 +86,16 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper
css::uno::Reference<css::deployment::XPackage> const & xPackage,
::rtl::OUString const & destFolder );
- bool checkUpdate(
- css::uno::Reference<css::deployment::XPackage> const & package,
- css::uno::Reference<css::ucb::XCommandEnvironment> const & origCmdEnv,
- css::uno::Reference<css::ucb::XCommandEnvironment> const &
- wrappedCmdEnv );
+ bool isInstalled(
+ css::uno::Reference<css::deployment::XPackage> const & package);
- bool checkInstall(
- css::uno::Reference<css::deployment::XPackage> const & package,
- css::uno::Reference<css::ucb::XCommandEnvironment> const & cmdEnv);
+ bool synchronizeRemovedExtensions(
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+ bool synchronizeAddedExtensions(
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
class CmdEnvWrapperImpl
: public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment,
@@ -135,7 +138,7 @@ protected:
: t_pm_helper( getMutex() ),
m_xComponentContext( xComponentContext ),
m_context( context ),
- m_readOnly( false )
+ m_readOnly( true )
{}
public:
@@ -171,7 +174,9 @@ public:
createAbortChannel() throw (css::uno::RuntimeException);
virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addPackage(
- ::rtl::OUString const & url, ::rtl::OUString const & mediaType,
+ ::rtl::OUString const & url,
+ css::uno::Sequence<css::beans::NamedValue> const & properties,
+ ::rtl::OUString const & mediaType,
css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
throw (css::deployment::DeploymentException,
@@ -180,17 +185,15 @@ public:
css::lang::IllegalArgumentException,
css::uno::RuntimeException);
- /* Unregisters the package but does not remove it from disk.
- When the operation is canceled by the user, a CommandAbortedException
- is thrown. Then the package is still fully functional.
- @param out_oldData
- can be NULL
- */
- void removePackage_(
- ::rtl::OUString const & id, ::rtl::OUString const & fileName,
+ virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL importExtension(
+ css::uno::Reference<css::deployment::XPackage> const & extension,
css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
- css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
- ActivePackages::Data * out_oldData);
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
virtual void SAL_CALL removePackage(
::rtl::OUString const & id, ::rtl::OUString const & fileName,
@@ -242,7 +245,31 @@ public:
virtual ::sal_Bool SAL_CALL isReadOnly( )
throw (::com::sun::star::uno::RuntimeException);
-};
+
+ virtual ::sal_Bool SAL_CALL synchronize(
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
+ getExtensionsWithUnacceptedLicenses(
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (css::deployment::DeploymentException,
+ css::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL checkPrerequisites(
+ css::uno::Reference<css::deployment::XPackage> const & extension,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+ };
//______________________________________________________________________________
inline void PackageManagerImpl::check()
diff --git a/desktop/source/deployment/manager/dp_manager.hrc b/desktop/source/deployment/manager/dp_manager.hrc
index bdbfc079cda6..6131cc381abf 100644
--- a/desktop/source/deployment/manager/dp_manager.hrc
+++ b/desktop/source/deployment/manager/dp_manager.hrc
@@ -35,5 +35,5 @@
#define RID_STR_PACKAGE_ALREADY_ADDED (RID_DEPLOYMENT_MANAGER_START+2)
#define RID_STR_COPYING_PACKAGE (RID_DEPLOYMENT_MANAGER_START+3)
#define RID_STR_NO_SUCH_PACKAGE (RID_DEPLOYMENT_MANAGER_START+4)
-
+#define RID_STR_SYNCHRONIZING_REPOSITORY (RID_DEPLOYMENT_MANAGER_START+5)
#endif
diff --git a/desktop/source/deployment/manager/dp_manager.src b/desktop/source/deployment/manager/dp_manager.src
index 95ede4aa6227..7d38b880c37a 100644
--- a/desktop/source/deployment/manager/dp_manager.src
+++ b/desktop/source/deployment/manager/dp_manager.src
@@ -53,3 +53,7 @@ String RID_STR_NO_SUCH_PACKAGE
Text [ en-US ] = "There is no such extension deployed: ";
};
+String RID_STR_SYNCHRONIZING_REPOSITORY
+{
+ Text [ en-US ] = "Synchronizing repository for %NAME extensions";
+};
diff --git a/desktop/source/deployment/manager/dp_managerfac.cxx b/desktop/source/deployment/manager/dp_managerfac.cxx
index d4c9df1d57af..f6fde6b07d60 100644
--- a/desktop/source/deployment/manager/dp_managerfac.cxx
+++ b/desktop/source/deployment/manager/dp_managerfac.cxx
@@ -53,6 +53,7 @@ class PackageManagerFactoryImpl : private MutexHolder, public t_pmfac_helper
Reference<deployment::XPackageManager> m_xUserMgr;
Reference<deployment::XPackageManager> m_xSharedMgr;
+ Reference<deployment::XPackageManager> m_xBundledMgr;
typedef ::std::hash_map<
OUString, WeakReference<deployment::XPackageManager>,
::rtl::OUStringHash > t_string2weakref;
@@ -141,6 +142,7 @@ void PackageManagerFactoryImpl::disposing()
// the below are already disposed:
m_xUserMgr.clear();
m_xSharedMgr.clear();
+ m_xBundledMgr.clear();
}
// XPackageManagerFactory
@@ -172,6 +174,8 @@ PackageManagerFactoryImpl::getPackageManager( OUString const & context )
m_xUserMgr = xRet;
else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") ))
m_xSharedMgr = xRet;
+ else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") ))
+ m_xBundledMgr = xRet;
}
else
{
diff --git a/desktop/source/deployment/manager/dp_properties.cxx b/desktop/source/deployment/manager/dp_properties.cxx
new file mode 100644
index 000000000000..df579944c6e4
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_properties.cxx
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * 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
+ *
+ * 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 "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "xmlscript/xml_helper.hxx"
+#include "ucbhelper/content.hxx"
+#include <list>
+
+#include "dp_ucb.h"
+#include "rtl/ustrbuf.hxx"
+#include "dp_properties.hxx"
+
+namespace lang = com::sun::star::lang;
+namespace task = com::sun::star::task;
+namespace ucb = com::sun::star::ucb;
+namespace uno = com::sun::star::uno;
+namespace css = com::sun::star;
+
+#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+using ::com::sun::star::uno::Reference;
+using ::rtl::OUString;
+
+#define PROP_SUPPRESS_LICENSE "SUPPRESS_LICENSE"
+#define PROP_EXTENSION_UPDATE "EXTENSION_UPDATE"
+
+namespace dp_manager {
+
+//Reading the file
+ExtensionProperties::ExtensionProperties(
+ OUString const & urlExtension,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv) :
+ m_xCmdEnv(xCmdEnv)
+{
+ m_propFileUrl = urlExtension + OUSTR("properties");
+
+ ::std::list< ::std::pair< OUString, OUString> > props;
+ if (! dp_misc::create_ucb_content(NULL, m_propFileUrl, 0, false))
+ return;
+
+ ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv);
+ dp_misc::readProperties(props, contentProps);
+
+ typedef ::std::list< ::std::pair< OUString, OUString> >::const_iterator CI;
+ for (CI i = props.begin(); i != props.end(); i++)
+ {
+ if (i->first.equals(OUSTR(PROP_SUPPRESS_LICENSE)))
+ m_prop_suppress_license = i->second;
+ }
+}
+
+//Writing the file
+ExtensionProperties::ExtensionProperties(
+ OUString const & urlExtension,
+ uno::Sequence<css::beans::NamedValue> const & properties,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv) :
+ m_xCmdEnv(xCmdEnv)
+{
+ m_propFileUrl = urlExtension + OUSTR("properties");
+
+ for (sal_Int32 i = 0; i < properties.getLength(); i++)
+ {
+ css::beans::NamedValue const & v = properties[i];
+ if (v.Name.equals(OUSTR(PROP_SUPPRESS_LICENSE)))
+ {
+ m_prop_suppress_license = getPropertyValue(v);
+ }
+ else if (v.Name.equals(OUSTR(PROP_EXTENSION_UPDATE)))
+ {
+ m_prop_extension_update = getPropertyValue(v);
+ }
+ else
+ {
+ throw lang::IllegalArgumentException(
+ OUSTR("Extension Manager: unknown property"), 0, -1);
+ }
+ }
+}
+
+OUString ExtensionProperties::getPropertyValue(css::beans::NamedValue const & v)
+{
+ OUString value(OUSTR("0"));
+ if (v.Value >>= value)
+ {
+ if (value.equals(OUSTR("1")))
+ value = OUSTR("1");
+ }
+ else
+ {
+ throw lang::IllegalArgumentException(
+ OUSTR("Extension Manager: wrong property value"), 0, -1);
+ }
+ return value;
+}
+void ExtensionProperties::write()
+{
+ ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv);
+ ::rtl::OUStringBuffer buf;
+
+ if (m_prop_suppress_license)
+ {
+ buf.append(OUSTR(PROP_SUPPRESS_LICENSE));
+ buf.append(OUSTR("="));
+ buf.append(*m_prop_suppress_license);
+ }
+
+ ::rtl::OString stamp = ::rtl::OUStringToOString(
+ buf.makeStringAndClear(), RTL_TEXTENCODING_UTF8);
+ Reference<css::io::XInputStream> xData(
+ ::xmlscript::createInputStream(
+ ::rtl::ByteSequence(
+ reinterpret_cast<sal_Int8 const *>(stamp.getStr()),
+ stamp.getLength() ) ) );
+ contentProps.writeStream( xData, true /* replace existing */ );
+}
+
+bool ExtensionProperties::isSuppressedLicense()
+{
+ bool ret = false;
+ if (m_prop_suppress_license)
+ {
+ if (m_prop_suppress_license->equals(OUSTR("1")))
+ ret = true;
+ }
+ return ret;
+}
+
+bool ExtensionProperties::isExtensionUpdate()
+{
+ bool ret = false;
+ if (m_prop_extension_update)
+ {
+ if (m_prop_extension_update->equals(OUSTR("1")))
+ ret = true;
+ }
+ return ret;
+}
+
+} // namespace dp_manager
+
+
diff --git a/desktop/source/deployment/manager/dp_properties.hxx b/desktop/source/deployment/manager/dp_properties.hxx
new file mode 100644
index 000000000000..97fc8b8c5394
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_properties.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * 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: dp_manager.h,v $
+ * $Revision: 1.17 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_PROPERTIES_HXX
+#define INCLUDED_DP_PROPERTIES_HXX
+
+
+
+#include "com/sun/star/beans/NamedValue.hpp"
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include "boost/optional.hpp"
+
+
+namespace css = ::com::sun::star;
+
+namespace dp_manager {
+
+
+
+/**
+
+ */
+class ExtensionProperties
+{
+protected:
+ ::rtl::OUString m_propFileUrl;
+ const css::uno::Reference<css::ucb::XCommandEnvironment> m_xCmdEnv;
+ ::boost::optional< ::rtl::OUString> m_prop_suppress_license;
+ ::boost::optional< ::rtl::OUString> m_prop_extension_update;
+
+ ::rtl::OUString getPropertyValue(css::beans::NamedValue const & v);
+public:
+
+ virtual ~ExtensionProperties() {};
+ ExtensionProperties(::rtl::OUString const & urlExtension,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+ ExtensionProperties(::rtl::OUString const & urlExtension,
+ css::uno::Sequence<css::beans::NamedValue> const & properties,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+ void write();
+
+ bool isSuppressedLicense();
+
+ bool isExtensionUpdate();
+};
+}
+
+
+
+
+#endif
+
diff --git a/desktop/source/deployment/manager/makefile.mk b/desktop/source/deployment/manager/makefile.mk
index a9ff47881fc3..4dc6405e34bf 100644
--- a/desktop/source/deployment/manager/makefile.mk
+++ b/desktop/source/deployment/manager/makefile.mk
@@ -45,7 +45,10 @@ SLOFILES = \
$(SLO)$/dp_activepackages.obj \
$(SLO)$/dp_manager.obj \
$(SLO)$/dp_managerfac.obj \
- $(SLO)$/dp_informationprovider.obj
+ $(SLO)$/dp_informationprovider.obj \
+ $(SLO)$/dp_extensionmanager.obj \
+ $(SLO)$/dp_commandenvironments.obj \
+ $(SLO)$/dp_properties.obj
.INCLUDE : ..$/target.pmk
.INCLUDE : target.mk
diff --git a/desktop/source/deployment/migration/dp_migration.cxx b/desktop/source/deployment/migration/dp_migration.cxx
deleted file mode 100644
index 49362f7e2f5f..000000000000
--- a/desktop/source/deployment/migration/dp_migration.cxx
+++ /dev/null
@@ -1,251 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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 "dp_misc.h"
-#include "dp_ucb.h"
-#include "cppuhelper/implbase1.hxx"
-#include "cppuhelper/implbase2.hxx"
-#include "cppuhelper/exc_hlp.hxx"
-#include "ucbhelper/content.hxx"
-#include "comphelper/anytostring.hxx"
-#include "comphelper/servicedecl.hxx"
-#include "com/sun/star/lang/WrappedTargetException.hpp"
-#include "com/sun/star/task/XJob.hpp"
-#include "com/sun/star/task/XInteractionAbort.hpp"
-#include "com/sun/star/task/XInteractionApprove.hpp"
-#include "com/sun/star/sdbc/XResultSet.hpp"
-#include "com/sun/star/sdbc/XRow.hpp"
-#include "com/sun/star/ucb/XContentAccess.hpp"
-#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
-
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::ucb;
-using namespace ::com::sun::star::uno;
-using namespace ::dp_misc;
-using ::rtl::OUString;
-
-namespace dp_migration {
-
-class MigrationImpl : public ::cppu::WeakImplHelper1<task::XJob>
-{
- struct CommandEnvironmentImpl
- : public ::cppu::WeakImplHelper2< XCommandEnvironment,
- task::XInteractionHandler >
- {
- // XCommandEnvironment
- virtual Reference<task::XInteractionHandler> SAL_CALL
- getInteractionHandler() throw (RuntimeException);
- virtual Reference<XProgressHandler> SAL_CALL getProgressHandler()
- throw (RuntimeException);
- // XInteractionHandler
- virtual void SAL_CALL handle(
- Reference<task::XInteractionRequest> const & xRequest )
- throw (RuntimeException);
- };
-
- const Reference<XComponentContext> m_xContext;
- OUString m_userData;
-
-protected:
- virtual ~MigrationImpl();
-public:
- MigrationImpl( Sequence<Any> const & args,
- Reference<XComponentContext> const & xComponentContext );
-
- // XJob
- virtual Any SAL_CALL execute( Sequence<beans::NamedValue> const & args )
- throw (lang::IllegalArgumentException, Exception, RuntimeException);
-};
-
-MigrationImpl::~MigrationImpl()
-{
-}
-
-MigrationImpl::MigrationImpl(
- Sequence<Any> const & args, Reference<XComponentContext> const & xContext )
- : m_xContext(xContext)
-{
- for ( sal_Int32 pos = args.getLength(); pos--; )
- {
- const beans::NamedValue nv(args[pos].get<beans::NamedValue>());
- if (nv.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UserData") ))
- m_userData = nv.Value.get<OUString>();
- }
- if (m_userData.getLength() == 0)
- throw lang::IllegalArgumentException( OUSTR("missing UserData!"), 0,
- static_cast<sal_Int16>(-1) );
-}
-
-// XJob
-Any MigrationImpl::execute( Sequence<beans::NamedValue> const & )
- throw (lang::IllegalArgumentException, Exception, RuntimeException)
-{
- const Reference<deployment::XPackageManager> xManager(
- deployment::thePackageManagerFactory::get(
- m_xContext )->getPackageManager( OUSTR("user") ) );
- ::ucbhelper::Content packagesDir;
- if (create_ucb_content( &packagesDir,
- makeURL( m_userData, OUSTR("user/uno_packages") ),
- Reference<XCommandEnvironment>(),
- false /* no throw */ ))
- {
- const Reference<XCommandEnvironment> xCmdEnv(
- new CommandEnvironmentImpl );
- OUString const & strTitle = StrTitle::get();
- const Reference<sdbc::XResultSet> xResultSet(
- packagesDir.createCursor( Sequence<OUString>( &strTitle, 1 ),
- ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
- while (xResultSet->next())
- {
- Reference<sdbc::XRow> xRow( xResultSet, UNO_QUERY_THROW );
- const OUString title( xRow->getString( 1 /* Title */ ) );
- // exclude stampIt, not migratable to OOo 2.0:
- if (title.matchIgnoreAsciiCaseAsciiL(
- RTL_CONSTASCII_STRINGPARAM("SSICONCT.") ))
- continue;
- const OUString sourceURL( Reference<XContentAccess>(
- xResultSet, UNO_QUERY_THROW )
- ->queryContentIdentifierString() );
- try {
- xManager->addPackage(
- sourceURL, OUString() /* detect media-type */,
- Reference<task::XAbortChannel>(), xCmdEnv );
- }
- catch (RuntimeException &) {
- throw;
- }
- catch (Exception &) {
- OSL_ENSURE( 0, ::rtl::OUStringToOString(
- ::comphelper::anyToString(
- ::cppu::getCaughtException() ),
- RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- }
- }
- return Any();
-}
-
-// XCommandEnvironment
-Reference<task::XInteractionHandler>
-MigrationImpl::CommandEnvironmentImpl::getInteractionHandler()
- throw (RuntimeException)
-{
- return this;
-}
-
-Reference<XProgressHandler>
-MigrationImpl::CommandEnvironmentImpl::getProgressHandler()
- throw (RuntimeException)
-{
- return Reference<XProgressHandler>();
-}
-
-// XInteractionHandler
-void MigrationImpl::CommandEnvironmentImpl::handle(
- Reference<task::XInteractionRequest> const & xRequest )
- throw (RuntimeException)
-{
- Any request( xRequest->getRequest() );
- OSL_ASSERT( request.getValueTypeClass() == TypeClass_EXCEPTION );
-#if OSL_DEBUG_LEVEL > 1
- OSL_TRACE( "[dp_migration.cxx] incoming request:\n%s\n",
- ::rtl::OUStringToOString( ::comphelper::anyToString(request),
- RTL_TEXTENCODING_UTF8 ).getStr() );
-#endif
-
- // selections:
- bool approve = false;
- bool abort = false;
-
- lang::WrappedTargetException wtExc;
- if (request >>= wtExc) {
- OSL_ENSURE( 0, ::rtl::OUStringToOString(
- ::comphelper::anyToString(wtExc.TargetException),
- RTL_TEXTENCODING_UTF8 ).getStr() );
-
- // ignore intermediate errors of legacy packages, i.e.
- // former pkgchk behaviour:
- const Reference<deployment::XPackage> xPackage(
- wtExc.Context, UNO_QUERY );
- OSL_ASSERT( xPackage.is() );
- if (xPackage.is()) {
- const Reference<deployment::XPackageTypeInfo> xPackageType(
- xPackage->getPackageType() );
- OSL_ASSERT( xPackageType.is() );
- if (xPackageType.is()) {
- approve = (xPackage->isBundle() &&
- xPackageType->getMediaType().matchAsciiL(
- RTL_CONSTASCII_STRINGPARAM(
- "application/"
- "vnd.sun.star.legacy-package-bundle") ));
- }
- }
- abort = !approve;
- }
- else
- return; // unknown request => no selection at all
-
- // select:
- const Sequence< Reference<task::XInteractionContinuation> > conts(
- xRequest->getContinuations() );
- for ( sal_Int32 pos = 0; pos < conts.getLength(); ++pos )
- {
- if (approve) {
- const Reference<task::XInteractionApprove> xInteractionApprove(
- conts[ pos ], UNO_QUERY );
- if (xInteractionApprove.is()) {
- xInteractionApprove->select();
- // don't query again for ongoing continuations:
- approve = false;
- }
- }
- else if (abort) {
- const Reference<task::XInteractionAbort> xInteractionAbort(
- conts[ pos ], UNO_QUERY );
- if (xInteractionAbort.is()) {
- xInteractionAbort->select();
- // don't query again for ongoing continuations:
- abort = false;
- }
- }
- }
-}
-
-namespace sdecl = comphelper::service_decl;
-sdecl::class_<MigrationImpl, sdecl::with_args<true> > serviceMI;
-extern sdecl::ServiceDecl const serviceDecl(
- serviceMI,
- // a private one (config entry):
- "com.sun.star.comp.deployment.migration.Migration_2_0",
- "com.sun.star.comp.deployment.migration.Migration_2_0" );
-
-} // namespace dp_migration
-
diff --git a/desktop/source/deployment/migration/makefile.mk b/desktop/source/deployment/migration/makefile.mk
deleted file mode 100644
index a37b7e5bebf8..000000000000
--- a/desktop/source/deployment/migration/makefile.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# 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.
-#
-#*************************************************************************
-
-PRJ = ..$/..$/..
-
-PRJNAME = desktop
-TARGET = deployment_migration
-ENABLE_EXCEPTIONS = TRUE
-
-.INCLUDE : settings.mk
-
-SLOFILES = \
- $(SLO)$/dp_migration.obj
-
-.INCLUDE : ..$/target.pmk
-.INCLUDE : target.mk
-
diff --git a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx
index 049f781dfd90..b4132db61f03 100644
--- a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx
+++ b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx
@@ -35,6 +35,7 @@
#include "comphelper/sequence.hxx"
#include "comphelper/makesequence.hxx"
+#include "comphelper/processfactory.hxx"
#include "boost/optional.hpp"
#include "com/sun/star/beans/Optional.hpp"
#include "com/sun/star/lang/XMultiComponentFactory.hpp"
@@ -47,17 +48,23 @@
#include "com/sun/star/xml/dom/DOMException.hpp"
#include "com/sun/star/xml/dom/XNode.hpp"
#include "com/sun/star/xml/dom/XNodeList.hpp"
+#include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
+#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
#include "cppuhelper/implbase1.hxx"
+#include "cppuhelper/implbase2.hxx"
#include "cppuhelper/weak.hxx"
+#include "cppuhelper/exc_hlp.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
-
+#include "ucbhelper/content.hxx"
namespace {
namespace css = ::com::sun::star;
+using css::uno::Reference;
+using ::rtl::OUString;
class EmptyNodeList: public ::cppu::WeakImplHelper1< css::xml::dom::XNodeList >
{
@@ -110,10 +117,251 @@ css::uno::Reference< css::xml::dom::XNode > EmptyNodeList::item(::sal_Int32)
}
}
+/**The class uses the UCB to access the description.xml file in an
+ extension. The UCB must have been initialized already. It also
+ requires that the extension has already be unzipped to a particular
+ location.
+ */
+class ExtensionDescription
+{
+public:
+ /**throws an exception if the description.xml is not
+ available, cannot be read, does not contain the expected data,
+ or any other error occured. Therefore it shoult only be used with
+ new extensions.
+
+ Throws com::sun::star::uno::RuntimeException,
+ com::sun::star::deployment::DeploymentException,
+ dp_registry::backend::bundle::NoDescriptionException.
+ */
+ ExtensionDescription(
+ const css::uno::Reference<css::uno::XComponentContext>& xContext,
+ const ::rtl::OUString& installDir,
+ const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv);
+
+ ~ExtensionDescription();
+
+ css::uno::Reference<css::xml::dom::XNode> getRootElement() const
+ {
+ return m_xRoot;
+ }
+
+ ::rtl::OUString getExtensionRootUrl() const
+ {
+ return m_sExtensionRootUrl;
+ }
+
+
+private:
+ css::uno::Reference<css::xml::dom::XNode> m_xRoot;
+ ::rtl::OUString m_sExtensionRootUrl;
+};
+
+class NoDescriptionException
+{
+};
+
+class FileDoesNotExistFilter
+ : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment,
+ css::task::XInteractionHandler >
+
+{
+ //css::uno::Reference<css::task::XInteractionHandler> m_xHandler;
+ bool m_bExist;
+ css::uno::Reference< css::ucb::XCommandEnvironment > m_xCommandEnv;
+
+public:
+ virtual ~FileDoesNotExistFilter();
+ FileDoesNotExistFilter(
+ const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv);
+
+ bool exist();
+ // XCommandEnvironment
+ virtual css::uno::Reference<css::task::XInteractionHandler > SAL_CALL
+ getInteractionHandler() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference<css::ucb::XProgressHandler >
+ SAL_CALL getProgressHandler() throw (css::uno::RuntimeException);
+
+ // XInteractionHandler
+ virtual void SAL_CALL handle(
+ css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (css::uno::RuntimeException);
+};
+
+ExtensionDescription::ExtensionDescription(
+ const Reference<css::uno::XComponentContext>& xContext,
+ const OUString& installDir,
+ const Reference< css::ucb::XCommandEnvironment >& xCmdEnv)
+{
+ try {
+ m_sExtensionRootUrl = installDir;
+ //may throw ::com::sun::star::ucb::ContentCreationException
+ //If there is no description.xml then ucb will start an interaction which
+ //brings up a dialog.We want to prevent this. Therefore we wrap the xCmdEnv
+ //and filter the respective exception out.
+ OUString sDescriptionUri(installDir + OUSTR("/description.xml"));
+ Reference<css::ucb::XCommandEnvironment> xFilter =
+ static_cast<css::ucb::XCommandEnvironment*>(
+ new FileDoesNotExistFilter(xCmdEnv));
+ ::ucbhelper::Content descContent(sDescriptionUri, xFilter);
+
+ //throws an com::sun::star::uno::Exception if the file is not available
+ Reference<css::io::XInputStream> xIn;
+ try
+ { //throws com.sun.star.ucb.InteractiveAugmentedIOException
+ xIn = descContent.openStream();
+ }
+ catch (css::uno::Exception& )
+ {
+ if ( ! static_cast<FileDoesNotExistFilter*>(xFilter.get())->exist())
+ throw NoDescriptionException();
+ throw;
+ }
+ if (!xIn.is())
+ {
+ throw css::uno::Exception(
+ OUSTR("Could not get XInputStream for description.xml of extension ") +
+ sDescriptionUri, 0);
+ }
+
+ //get root node of description.xml
+ Reference<css::xml::dom::XDocumentBuilder> xDocBuilder(
+ xContext->getServiceManager()->createInstanceWithContext(
+ OUSTR("com.sun.star.xml.dom.DocumentBuilder"),
+ xContext ), css::uno::UNO_QUERY);
+ if (!xDocBuilder.is())
+ throw css::uno::Exception(OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0);
+
+ if (xDocBuilder->isNamespaceAware() == sal_False)
+ {
+ throw css::uno::Exception(
+ OUSTR("Service com.sun.star.xml.dom.DocumentBuilder is not namespace aware."), 0);
+ }
+
+ Reference<css::xml::dom::XDocument> xDoc = xDocBuilder->parse(xIn);
+ if (!xDoc.is())
+ {
+ throw css::uno::Exception(sDescriptionUri + OUSTR(" contains data which cannot be parsed. "), 0);
+ }
+
+ //check for proper root element and namespace
+ Reference<css::xml::dom::XElement> xRoot = xDoc->getDocumentElement();
+ if (!xRoot.is())
+ {
+ throw css::uno::Exception(
+ sDescriptionUri + OUSTR(" contains no root element."), 0);
+ }
+
+ if ( ! xRoot->getTagName().equals(OUSTR("description")))
+ {
+ throw css::uno::Exception(
+ sDescriptionUri + OUSTR(" does not contain the root element <description>."), 0);
+ }
+
+ m_xRoot = Reference<css::xml::dom::XNode>(
+ xRoot, css::uno::UNO_QUERY_THROW);
+ OUString nsDescription = xRoot->getNamespaceURI();
+
+ //check if this namespace is supported
+ if ( ! nsDescription.equals(OUSTR("http://openoffice.org/extensions/description/2006")))
+ {
+ throw css::uno::Exception(sDescriptionUri + OUSTR(" contains a root element with an unsupported namespace. "), 0);
+ }
+ } catch (css::uno::RuntimeException &) {
+ throw;
+ } catch (css::deployment::DeploymentException &) {
+ throw;
+ } catch (css::uno::Exception & e) {
+ css::uno::Any a(cppu::getCaughtException());
+ throw css::deployment::DeploymentException(
+ e.Message, Reference< css::uno::XInterface >(), a);
+ }
+}
+
+ExtensionDescription::~ExtensionDescription()
+{
+}
+
+//======================================================================
+FileDoesNotExistFilter::FileDoesNotExistFilter(
+ const Reference< css::ucb::XCommandEnvironment >& xCmdEnv):
+ m_bExist(true), m_xCommandEnv(xCmdEnv)
+{}
+
+FileDoesNotExistFilter::~FileDoesNotExistFilter()
+{
+};
+
+bool FileDoesNotExistFilter::exist()
+{
+ return m_bExist;
+}
+ // XCommandEnvironment
+Reference<css::task::XInteractionHandler >
+ FileDoesNotExistFilter::getInteractionHandler() throw (css::uno::RuntimeException)
+{
+ return static_cast<css::task::XInteractionHandler*>(this);
+}
+
+Reference<css::ucb::XProgressHandler >
+ FileDoesNotExistFilter::getProgressHandler() throw (css::uno::RuntimeException)
+{
+ return m_xCommandEnv.is()
+ ? m_xCommandEnv->getProgressHandler()
+ : Reference<css::ucb::XProgressHandler>();
+}
+
+// XInteractionHandler
+//If the interaction was caused by a non-existing file which is specified in the ctor
+//of FileDoesNotExistFilter, then we do nothing
+void FileDoesNotExistFilter::handle(
+ Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (css::uno::RuntimeException)
+{
+ css::uno::Any request( xRequest->getRequest() );
+
+ css::ucb::InteractiveAugmentedIOException ioexc;
+ if ((request>>= ioexc) && ioexc.Code == css::ucb::IOErrorCode_NOT_EXISTING )
+ {
+ m_bExist = false;
+ return;
+ }
+ Reference<css::task::XInteractionHandler> xInteraction;
+ if (m_xCommandEnv.is()) {
+ xInteraction = m_xCommandEnv->getInteractionHandler();
+ }
+ if (xInteraction.is()) {
+ xInteraction->handle(xRequest);
+ }
+}
+
}
namespace dp_misc {
+DescriptionInfoset getDescriptionInfoset(OUString const & sExtensionFolderURL)
+{
+ Reference< css::xml::dom::XNode > root;
+ Reference<css::uno::XComponentContext> context =
+ comphelper_getProcessComponentContext();
+ OSL_ASSERT(context.is());
+ try {
+ root =
+ ExtensionDescription(
+ context, sExtensionFolderURL,
+ Reference< css::ucb::XCommandEnvironment >()).
+ getRootElement();
+ } catch (NoDescriptionException &) {
+ } catch (css::deployment::DeploymentException & e) {
+ throw css::uno::RuntimeException(
+ (OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.deployment.DeploymentException: ")) +
+ e.Message), 0);
+ }
+ return DescriptionInfoset(context, root);
+}
+
DescriptionInfoset::DescriptionInfoset(
css::uno::Reference< css::uno::XComponentContext > const & context,
css::uno::Reference< css::xml::dom::XNode > const & element):
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index 3ed2d554b59f..fe3490903043 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -30,6 +30,7 @@
#include "dp_misc.h"
+#include "dp_version.hxx"
#include "dp_interact.h"
#include "rtl/uri.hxx"
#include "rtl/digest.h"
@@ -42,10 +43,14 @@
#include "osl/thread.hxx"
#include "osl/mutex.hxx"
#include "com/sun/star/ucb/CommandAbortedException.hpp"
+#include "com/sun/star/task/XInteractionHandler.hpp"
#include "com/sun/star/bridge/UnoUrlResolver.hpp"
#include "com/sun/star/bridge/XUnoUrlResolver.hpp"
+#include "com/sun/star/deployment/ExtensionManager.hpp"
+#include "com/sun/star/task/XRestartManager.hpp"
#include "boost/scoped_array.hpp"
#include "boost/shared_ptr.hpp"
+#include <comphelper/processfactory.hxx>
#ifdef WNT
//#include "tools/prewin.h"
@@ -138,6 +143,103 @@ bool existsOfficePipe()
return pipe.is();
}
+
+//Returns true if the Folder was more recently modified then
+//the lastsynchronized file. That is the repository needs to
+//be synchronized.
+bool compareExtensionFolderWithLastSynchronizedFile(
+ OUString const & folderURL, OUString const & fileURL)
+{
+ bool bNeedsSync = false;
+ ::osl::DirectoryItem itemExtFolder;
+ ::osl::File::RC err1 =
+ ::osl::DirectoryItem::get(folderURL, itemExtFolder);
+ //If it does not exist, then there is nothing to be done
+ if (err1 == ::osl::File::E_NOENT)
+ {
+ return false;
+ }
+ else if (err1 != ::osl::File::E_None)
+ {
+ OSL_ENSURE(0, "Cannot access extension folder");
+ return true; //sync just in case
+ }
+
+ //If last synchronized does not exist, then OOo is started for the first time
+ ::osl::DirectoryItem itemFile;
+ ::osl::File::RC err2 = ::osl::DirectoryItem::get(fileURL, itemFile);
+ if (err2 == ::osl::File::E_NOENT)
+ {
+ return true;
+
+ }
+ else if (err2 != ::osl::File::E_None)
+ {
+ OSL_ENSURE(0, "Cannot access file lastsynchronized");
+ return true; //sync just in case
+ }
+
+ //compare the modification time of the extension folder and the last
+ //modified file
+ ::osl::FileStatus statFolder(FileStatusMask_ModifyTime);
+ ::osl::FileStatus statFile(FileStatusMask_ModifyTime);
+ if (itemExtFolder.getFileStatus(statFolder) == ::osl::File::E_None)
+ {
+ if (itemFile.getFileStatus(statFile) == ::osl::File::E_None)
+ {
+ TimeValue timeFolder = statFolder.getModifyTime();
+ TimeValue timeFile = statFile.getModifyTime();
+
+ if (timeFile.Seconds < timeFolder.Seconds)
+ bNeedsSync = true;
+ }
+ else
+ {
+ OSL_ASSERT(0);
+ bNeedsSync = true;
+ }
+ }
+ else
+ {
+ OSL_ASSERT(0);
+ bNeedsSync = true;
+ }
+ return bNeedsSync;
+}
+
+bool needToSyncRepostitory(OUString const & name)
+{
+ OUString folder;
+ OUString file;
+ if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled"))))
+ {
+ folder = OUString(
+ RTL_CONSTASCII_USTRINGPARAM("$BUNDLED_EXTENSIONS"));
+ file = OUString (
+ RTL_CONSTASCII_USTRINGPARAM(
+ "$BUNDLED_EXTENSIONS_USER/lastsynchronized"));
+ }
+ else if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("shared"))))
+ {
+ folder = OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "$UNO_SHARED_PACKAGES_CACHE/uno_packages"));
+ file = OUString (
+ RTL_CONSTASCII_USTRINGPARAM(
+ "$SHARED_EXTENSIONS_USER/lastsynchronized"));
+ }
+ else
+ {
+ OSL_ASSERT(0);
+ return true;
+ }
+ ::rtl::Bootstrap::expandMacros(folder);
+ ::rtl::Bootstrap::expandMacros(file);
+ return compareExtensionFolderWithLastSynchronizedFile(
+ folder, file);
+}
+
+
} // anon namespace
//==============================================================================
@@ -197,6 +299,19 @@ OUString makeURL( OUString const & baseURL, OUString const & relPath_ )
return buf.makeStringAndClear();
}
+OUString makeURLAppendSysPathSegment( OUString const & baseURL, OUString const & relPath_ )
+{
+ OUString segment = relPath_;
+ OSL_ASSERT(segment.indexOf(static_cast<sal_Unicode>('/')) == -1);
+
+ ::rtl::Uri::encode(
+ segment, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8);
+ return makeURL(baseURL, segment);
+}
+
+
+
//==============================================================================
OUString expandUnoRcTerm( OUString const & term_ )
{
@@ -205,6 +320,22 @@ OUString expandUnoRcTerm( OUString const & term_ )
return term;
}
+OUString makeRcTerm( OUString const & url )
+{
+ OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ "vnd.sun.star.expand:") ) );
+ if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) {
+ // cut protocol:
+ OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) );
+ // decode uric class chars:
+ rcterm = ::rtl::Uri::decode(
+ rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
+ return rcterm;
+ }
+ else
+ return url;
+}
+
//==============================================================================
OUString expandUnoRcUrl( OUString const & url )
{
@@ -346,17 +477,6 @@ Reference<XInterface> resolveUnoURL(
}
}
-OUString getExtensionDefaultUpdateURL()
-{
- ::rtl::OUString sUrl(
- RTL_CONSTASCII_USTRINGPARAM(
- "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version")
- ":Version:ExtensionUpdateURL}"));
- ::rtl::Bootstrap::expandMacros(sUrl);
- return sUrl;
-}
-
-
#ifdef WNT
void writeConsoleWithStream(::rtl::OUString const & sText, HANDLE stream)
{
@@ -467,4 +587,39 @@ void TRACE(::rtl::OString const & sText)
#endif
}
+void syncRepositories(Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+{
+ Reference<deployment::XExtensionManager> xExtensionManager;
+ //synchronize shared before bundled otherewise there are
+ //more revoke and registration calls.
+ sal_Bool bModified = false;
+ if (needToSyncRepostitory(OUString(RTL_CONSTASCII_USTRINGPARAM("shared")))
+ || needToSyncRepostitory(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled"))))
+ {
+ xExtensionManager =
+ deployment::ExtensionManager::get(
+ comphelper_getProcessComponentContext());
+
+ if (xExtensionManager.is())
+ {
+ bModified = xExtensionManager->synchronize(
+ Reference<task::XAbortChannel>(), xCmdEnv);
+ }
+ }
+
+ if (bModified)
+ {
+ Reference<task::XRestartManager> restarter(
+ comphelper_getProcessComponentContext()->getValueByName(
+ OUSTR( "/singletons/com.sun.star.task.OfficeRestartManager") ), UNO_QUERY );
+ if (restarter.is())
+ {
+ restarter->requestRestart(xCmdEnv.is() == sal_True ? xCmdEnv->getInteractionHandler() :
+ Reference<task::XInteractionHandler>());
+ }
+ }
+}
+
+
+
}
diff --git a/desktop/source/deployment/misc/dp_ucb.cxx b/desktop/source/deployment/misc/dp_ucb.cxx
index 571aef9c1b95..795a492aa0d5 100644
--- a/desktop/source/deployment/misc/dp_ucb.cxx
+++ b/desktop/source/deployment/misc/dp_ucb.cxx
@@ -271,4 +271,50 @@ bool readLine( OUString * res, OUString const & startingWith,
return false;
}
+bool readProperties( ::std::list< ::std::pair< ::rtl::OUString, ::rtl::OUString> > & out_result,
+ ::ucbhelper::Content & ucb_content )
+{
+ // read whole file:
+ ::rtl::ByteSequence bytes( readFile( ucb_content ) );
+ OUString file( reinterpret_cast<sal_Char const *>(bytes.getConstArray()),
+ bytes.getLength(), RTL_TEXTENCODING_UTF8);
+ sal_Int32 pos = 0;
+
+ for (;;)
+ {
+
+ ::rtl::OUStringBuffer buf;
+ sal_Int32 start = pos;
+
+ bool bEOF = false;
+ pos = file.indexOf( LF, pos );
+ if (pos < 0) { // EOF
+ buf.append( file.copy( start ) );
+ bEOF = true;
+ }
+ else
+ {
+ if (pos > 0 && file[ pos - 1 ] == CR)
+ // consume extra CR
+ buf.append( file.copy( start, pos - start - 1 ) );
+ else
+ buf.append( file.copy( start, pos - start ) );
+ pos++;
+ }
+ OUString aLine = buf.makeStringAndClear();
+
+ sal_Int32 posEqual = aLine.indexOf('=');
+ if (posEqual > 0 && (posEqual + 1) < aLine.getLength())
+ {
+ OUString name = aLine.copy(0, posEqual);
+ OUString value = aLine.copy(posEqual + 1);
+ out_result.push_back(::std::make_pair(name, value));
+ }
+
+ if (bEOF)
+ break;
+ }
+ return false;
+}
+
}
diff --git a/desktop/source/deployment/misc/dp_update.cxx b/desktop/source/deployment/misc/dp_update.cxx
new file mode 100755
index 000000000000..52011f1f0ca0
--- /dev/null
+++ b/desktop/source/deployment/misc/dp_update.cxx
@@ -0,0 +1,397 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dp_update.hxx"
+#include "dp_version.hxx"
+#include "dp_identifier.hxx"
+#include "dp_descriptioninfoset.hxx"
+
+#include "rtl/bootstrap.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+using ::rtl::OString;
+
+
+namespace dp_misc {
+namespace {
+
+int determineHighestVersion(
+ ::rtl::OUString const & userVersion,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion)
+{
+ int index = 0;
+ OUString greatest = userVersion;
+ if (dp_misc::compareVersions(sharedVersion, greatest) == dp_misc::GREATER)
+ {
+ index = 1;
+ greatest = sharedVersion;
+ }
+ if (dp_misc::compareVersions(bundledVersion, greatest) == dp_misc::GREATER)
+ {
+ index = 2;
+ greatest = bundledVersion;
+ }
+ if (dp_misc::compareVersions(onlineVersion, greatest) == dp_misc::GREATER)
+ {
+ index = 3;
+ }
+ return index;
+}
+
+Sequence< Reference< xml::dom::XElement > >
+getUpdateInformation( Reference<deployment::XUpdateInformationProvider > const & updateInformation,
+ Sequence< OUString > const & urls,
+ OUString const & identifier,
+ uno::Any & out_error)
+{
+ try {
+ return updateInformation->getUpdateInformation(urls, identifier);
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (ucb::CommandFailedException & e) {
+ out_error = e.Reason;
+ } catch (ucb::CommandAbortedException &) {
+ } catch (uno::Exception & e) {
+ out_error = uno::makeAny(e);
+ }
+ return
+ Sequence<Reference< xml::dom::XElement > >();
+}
+
+//Put in anonymous namespace
+
+void getOwnUpdateInfos(
+ Reference<uno::XComponentContext> const & xContext,
+ Reference<deployment::XUpdateInformationProvider > const & updateInformation,
+ UpdateInfoMap& inout_map, std::vector<std::pair<Reference<deployment::XPackage>, uno::Any> > & out_errors,
+ bool & out_allFound)
+{
+ bool allHaveOwnUpdateInformation = true;
+ for (UpdateInfoMap::iterator i = inout_map.begin(); i != inout_map.end(); i++)
+ {
+ OSL_ASSERT(i->second.extension.is());
+ Sequence<OUString> urls(i->second.extension->getUpdateInformationURLs());
+ if (urls.getLength())
+ {
+ const OUString id = dp_misc::getIdentifier(i->second.extension);
+ uno::Any anyError;
+ //It is unclear from the idl if there can be a null reference returned.
+ //However all valid information should be the same
+ Sequence<Reference< xml::dom::XElement > >
+ infos(getUpdateInformation(updateInformation, urls, id, anyError));
+ if (anyError.hasValue())
+ out_errors.push_back(std::make_pair(i->second.extension, anyError));
+
+ for (sal_Int32 j = 0; j < infos.getLength(); ++j)
+ {
+ dp_misc::DescriptionInfoset infoset(
+ xContext,
+ Reference< xml::dom::XNode >(infos[j], UNO_QUERY_THROW));
+ if (!infoset.hasDescription())
+ continue;
+ boost::optional< OUString > id2(infoset.getIdentifier());
+ if (!id2)
+ continue;
+ OSL_ASSERT(*id2 == id);
+ if (*id2 == id)
+ {
+ i->second.version = infoset.getVersion();
+ i->second.info = Reference< xml::dom::XNode >(
+ infos[j], UNO_QUERY_THROW);
+ }
+ break;
+ }
+ }
+ else
+ {
+ allHaveOwnUpdateInformation &= false;
+ }
+ }
+ out_allFound = allHaveOwnUpdateInformation;
+}
+
+void getDefaultUpdateInfos(
+ Reference<uno::XComponentContext> const & xContext,
+ Reference<deployment::XUpdateInformationProvider > const & updateInformation,
+ UpdateInfoMap& inout_map,
+ std::vector<std::pair<Reference<deployment::XPackage>, uno::Any> > & out_errors)
+{
+ const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL());
+ OSL_ASSERT(sDefaultURL.getLength());
+
+ Any anyError;
+ Sequence< Reference< xml::dom::XElement > >
+ infos(
+ getUpdateInformation(
+ updateInformation,
+ Sequence< OUString >(&sDefaultURL, 1), OUString(), anyError));
+ if (anyError.hasValue())
+ out_errors.push_back(std::make_pair(Reference<deployment::XPackage>(), anyError));
+ for (sal_Int32 i = 0; i < infos.getLength(); ++i)
+ {
+ Reference< xml::dom::XNode > node(infos[i], UNO_QUERY_THROW);
+ dp_misc::DescriptionInfoset infoset(xContext, node);
+ boost::optional< OUString > id(infoset.getIdentifier());
+ if (!id) {
+ continue;
+ }
+ UpdateInfoMap::iterator j = inout_map.find(*id);
+ if (j != inout_map.end())
+ {
+ //skip those extension which provide its own update urls
+ if (j->second.extension->getUpdateInformationURLs().getLength())
+ continue;
+ OUString v(infoset.getVersion());
+ //look for the highest version in the online repository
+ if (dp_misc::compareVersions(v, j->second.version) ==
+ dp_misc::GREATER)
+ {
+ j->second.version = v;
+ j->second.info = node;
+ }
+ }
+ }
+}
+
+
+} // anon namespace
+
+
+OUString getExtensionDefaultUpdateURL()
+{
+ ::rtl::OUString sUrl(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version")
+ ":Version:ExtensionUpdateURL}"));
+ ::rtl::Bootstrap::expandMacros(sUrl);
+ return sUrl;
+}
+
+/* returns the index of the greatest version, starting with 0
+
+ */
+UPDATE_SOURCE isUpdateUserExtension(
+ bool bReadOnlyShared,
+ ::rtl::OUString const & userVersion,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion)
+{
+ UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE;
+ if (bReadOnlyShared)
+ {
+ if (userVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ userVersion, sharedVersion, bundledVersion, onlineVersion);
+ if (index == 1)
+ retVal = UPDATE_SOURCE_SHARED;
+ else if (index == 2)
+ retVal = UPDATE_SOURCE_BUNDLED;
+ else if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+ }
+ else if (sharedVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ OUString(), sharedVersion, bundledVersion, onlineVersion);
+ if (index == 2)
+ retVal = UPDATE_SOURCE_BUNDLED;
+ else if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+
+ }
+ else if (bundledVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ OUString(), OUString(), bundledVersion, onlineVersion);
+ if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+ }
+ }
+ else
+ {
+ if (userVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ userVersion, sharedVersion, bundledVersion, onlineVersion);
+ if (index == 1)
+ retVal = UPDATE_SOURCE_SHARED;
+ else if (index == 2)
+ retVal = UPDATE_SOURCE_BUNDLED;
+ else if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+ }
+ }
+
+ return retVal;
+}
+
+UPDATE_SOURCE isUpdateSharedExtension(
+ bool bReadOnlyShared,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion)
+{
+ if (bReadOnlyShared)
+ return UPDATE_SOURCE_NONE;
+ UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE;
+
+ if (sharedVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ OUString(), sharedVersion, bundledVersion, onlineVersion);
+ if (index == 2)
+ retVal = UPDATE_SOURCE_BUNDLED;
+ else if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+ }
+ else if (bundledVersion.getLength())
+ {
+ int index = determineHighestVersion(
+ OUString(), OUString(), bundledVersion, onlineVersion);
+ if (index == 3)
+ retVal = UPDATE_SOURCE_ONLINE;
+ }
+ return retVal;
+}
+
+Reference<deployment::XPackage>
+getExtensionWithHighestVersion(
+ Sequence<Reference<deployment::XPackage> > const & seqExt)
+{
+ if (seqExt.getLength() == 0)
+ return Reference<deployment::XPackage>();
+
+ Reference<deployment::XPackage> greatest;
+ sal_Int32 len = seqExt.getLength();
+
+ for (sal_Int32 i = 0; i < len; i++)
+ {
+ if (!greatest.is())
+ {
+ greatest = seqExt[i];
+ continue;
+ }
+ Reference<deployment::XPackage> const & current = seqExt[i];
+ //greatest has a value
+ if (! current.is())
+ continue;
+
+ if (dp_misc::compareVersions(current->getVersion(), greatest->getVersion()) == dp_misc::GREATER)
+ greatest = current;
+ }
+ return greatest;
+}
+
+UpdateInfo::UpdateInfo( Reference< deployment::XPackage> const & ext):
+extension(ext)
+{
+}
+
+
+
+UpdateInfoMap getOnlineUpdateInfos(
+ Reference<uno::XComponentContext> const &xContext,
+ Reference<deployment::XExtensionManager> const & xExtMgr,
+ Reference<deployment::XUpdateInformationProvider > const & updateInformation,
+ std::vector<Reference<deployment::XPackage > > const * extensionList,
+ std::vector<std::pair< Reference<deployment::XPackage>, uno::Any> > & out_errors)
+{
+ OSL_ASSERT(xExtMgr.is());
+ UpdateInfoMap infoMap;
+ if (!xExtMgr.is())
+ return infoMap;
+
+ if (!extensionList)
+ {
+ const uno::Sequence< uno::Sequence< Reference<deployment::XPackage > > > seqAllExt = xExtMgr->getAllExtensions(
+ Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>());
+
+ //fill the UpdateInfoMap. key = extension identifier, value = UpdateInfo
+ for (int pos = seqAllExt.getLength(); pos --; )
+ {
+ uno::Sequence<Reference<deployment::XPackage> > const & seqExt = seqAllExt[pos];
+
+ Reference<deployment::XPackage> extension = getExtensionWithHighestVersion(seqExt);
+ OSL_ASSERT(extension.is());
+
+ std::pair<UpdateInfoMap::iterator, bool> insertRet = infoMap.insert(
+ UpdateInfoMap::value_type(
+ dp_misc::getIdentifier(extension), UpdateInfo(extension)));
+ OSL_ASSERT(insertRet.second == true);
+ }
+ }
+ else
+ {
+ typedef std::vector<Reference<deployment::XPackage > >::const_iterator CIT;
+ for (CIT i = extensionList->begin(); i != extensionList->end(); i++)
+ {
+ OSL_ASSERT(i->is());
+ std::pair<UpdateInfoMap::iterator, bool> insertRet = infoMap.insert(
+ UpdateInfoMap::value_type(
+ dp_misc::getIdentifier(*i), UpdateInfo(*i)));
+ OSL_ASSERT(insertRet.second == true);
+ }
+ }
+
+ //Now find the update information for the extensions which provide their own
+ //URLs to update information.
+ bool allInfosObtained = false;
+ getOwnUpdateInfos(xContext, updateInformation, infoMap, out_errors, allInfosObtained);
+
+ if (!allInfosObtained)
+ getDefaultUpdateInfos(xContext, updateInformation, infoMap, out_errors);
+ return infoMap;
+}
+OUString getHighestVersion(
+ ::rtl::OUString const & userVersion,
+ ::rtl::OUString const & sharedVersion,
+ ::rtl::OUString const & bundledVersion,
+ ::rtl::OUString const & onlineVersion)
+{
+ int index = determineHighestVersion(userVersion, sharedVersion, bundledVersion, onlineVersion);
+ switch (index)
+ {
+ case 0: return userVersion;
+ case 1: return sharedVersion;
+ case 2: return bundledVersion;
+ case 3: return onlineVersion;
+ default: OSL_ASSERT(0);
+ }
+
+ return OUString();
+}
+} //namespace dp_misc
diff --git a/desktop/source/deployment/misc/dp_version.cxx b/desktop/source/deployment/misc/dp_version.cxx
index 1668ebe4a0b7..c0da0533b54c 100644
--- a/desktop/source/deployment/misc/dp_version.cxx
+++ b/desktop/source/deployment/misc/dp_version.cxx
@@ -70,11 +70,5 @@ namespace dp_misc {
return ::dp_misc::EQUAL;
}
-::dp_misc::Order comparePackageVersions(
- css::uno::Reference< css::deployment::XPackage > const & package1,
- css::uno::Reference< css::deployment::XPackage > const & package2)
-{
- return compareVersions(package1->getVersion(), package2->getVersion());
-}
}
diff --git a/desktop/source/deployment/misc/makefile.mk b/desktop/source/deployment/misc/makefile.mk
index e191169202fd..3e4bd68cb4c0 100644
--- a/desktop/source/deployment/misc/makefile.mk
+++ b/desktop/source/deployment/misc/makefile.mk
@@ -65,7 +65,8 @@ SHL1OBJS = \
$(SLO)$/dp_version.obj \
$(SLO)$/dp_descriptioninfoset.obj \
$(SLO)$/dp_dependencies.obj \
- $(SLO)$/dp_platform.obj
+ $(SLO)$/dp_platform.obj \
+ $(SLO)$/dp_update.obj
SHL1STDLIBS = \
$(BERKELEYLIB) \
@@ -75,7 +76,8 @@ SHL1STDLIBS = \
$(TOOLSLIB) \
$(UCBHELPERLIB) \
$(UNOTOOLSLIB) \
- $(XMLSCRIPTLIB)
+ $(XMLSCRIPTLIB) \
+ $(COMPHELPERLIB)
.IF "$(GUI)"=="OS2"
SHL1IMPLIB = ideploymentmisc$(DLLPOSTFIX)
LIB1TARGET = $(SLB)$/_deplmisc.lib
diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx
new file mode 100644
index 000000000000..898e7c931f6d
--- /dev/null
+++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx
@@ -0,0 +1,156 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "rtl/string.h"
+#include "rtl/bootstrap.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
+#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
+#include "dp_misc.h"
+
+#include "dp_compbackenddb.hxx"
+
+
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010"
+#define NS_PREFIX "comp"
+#define ROOT_ELEMENT_NAME "component-backend-db"
+#define KEY_ELEMENT_NAME "component"
+
+namespace dp_registry {
+namespace backend {
+namespace component {
+
+ComponentBackendDb::ComponentBackendDb(
+ Reference<XComponentContext> const & xContext,
+ ::rtl::OUString const & url):BackendDb(xContext, url)
+{
+
+}
+
+OUString ComponentBackendDb::getDbNSName()
+{
+ return OUSTR(EXTENSION_REG_NS);
+}
+
+OUString ComponentBackendDb::getNSPrefix()
+{
+ return OUSTR(NS_PREFIX);
+}
+
+OUString ComponentBackendDb::getRootElementName()
+{
+ return OUSTR(ROOT_ELEMENT_NAME);
+}
+
+OUString ComponentBackendDb::getKeyElementName()
+{
+ return OUSTR(KEY_ELEMENT_NAME);
+}
+
+void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
+{
+ try{
+ Reference<css::xml::dom::XNode> componentNode = writeKeyElement(url);
+ writeSimpleElement(OUSTR("java-type-library"),
+ OUString::valueOf((sal_Bool) data.javaTypeLibrary),
+ componentNode);
+
+ writeSimpleList(
+ data.implementationNames,
+ OUSTR("implementation-names"),
+ OUSTR("name"),
+ componentNode);
+
+ writeVectorOfPair(
+ data.singletons,
+ OUSTR("singletons"),
+ OUSTR("item"),
+ OUSTR("key"),
+ OUSTR("value"),
+ componentNode);
+
+ save();
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & url)
+{
+ try
+ {
+ ComponentBackendDb::Data retData;
+ Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
+ if (aNode.is())
+ {
+ bool bJava = readSimpleElement(OUSTR("java-type-library"), aNode)
+ .equals(OUSTR("true")) ? true : false;
+ retData.javaTypeLibrary = bJava;
+
+ retData.implementationNames =
+ readList(
+ aNode,
+ OUSTR("implementation-names"),
+ OUSTR("name"));
+
+ retData.singletons =
+ readVectorOfPair(
+ aNode,
+ OUSTR("singletons"),
+ OUSTR("item"),
+ OUSTR("key"),
+ OUSTR("value"));
+ }
+ return retData;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+
+} // namespace bundle
+} // namespace backend
+} // namespace dp_registry
+
diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx
new file mode 100644
index 000000000000..b9a5ed737b7c
--- /dev/null
+++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_COMPBACKENDDB_HXX
+#define INCLUDED_DP_COMPBACKENDDB_HXX
+
+#include "rtl/ustring.hxx"
+#include "rtl/string.hxx"
+#include <vector>
+#include <list>
+#include "dp_backenddb.hxx"
+
+namespace css = ::com::sun::star;
+
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class XComponentContext;
+ }
+ namespace xml { namespace dom {
+ class XDocument;
+ class XNode;
+ }}
+ namespace xml { namespace xpath {
+ class XXPathAPI;
+ }}
+}}}
+
+namespace dp_registry {
+namespace backend {
+namespace component {
+
+/* The XML file stores the extensions which are currently registered.
+ They will be removed when they are revoked.
+ The format looks like this:
+
+<?xml version="1.0"?>
+<component-backend-db xmlns="http://openoffice.org/extensionmanager/component-registry/2010">
+ <component url="vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages/5CD5.tmp_/leaves1.oxt/extensionoptions.jar">
+ <name>FileName</name>
+ <java-type-library>true</java-type-library>
+ <implementation-names>
+ <name>com.sun.star.comp.extensionoptions.OptionsEventHandler$_OptionsEventHandler</name>
+ ...
+ </implementation-names>
+ <singletons>
+ <item>
+ <key>com.sun.star.java.theJavaVirtualMachine</key>
+ <value>com.sun.star.java.JavaVirtualMachine</value>
+ </item>
+ ...
+ </singletons>
+ </component>
+
+ <component ...>
+ ...
+</component-backend-db>
+ */
+class ComponentBackendDb: public dp_registry::backend::BackendDb
+{
+protected:
+ virtual ::rtl::OUString getDbNSName();
+ virtual ::rtl::OUString getNSPrefix();
+ virtual ::rtl::OUString getRootElementName();
+ virtual ::rtl::OUString getKeyElementName();
+
+public:
+ struct Data
+ {
+ Data(): javaTypeLibrary(false) {};
+
+ ::std::list< ::rtl::OUString> implementationNames;
+ /* every singleton has a key and a value
+ */
+ ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString> >singletons;
+ bool javaTypeLibrary;
+ };
+
+public:
+
+ ComponentBackendDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url);
+
+ void addEntry(::rtl::OUString const & url, Data const & data);
+
+ Data getEntry(::rtl::OUString const & url);
+
+
+};
+
+
+
+}
+}
+}
+#endif
+
diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index e6781e2a1746..e0844c227669 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -58,7 +58,7 @@
#include <vector>
#include <memory>
#include <algorithm>
-
+#include "dp_compbackenddb.hxx"
using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -74,6 +74,8 @@ namespace {
typedef ::std::list<OUString> t_stringlist;
typedef ::std::vector< ::std::pair<OUString, OUString> > t_stringpairvec;
+#define IMPLEMENTATION_NAME "com.sun.star.comp.deployment.component.PackageRegistryBackend"
+
/** return a vector of bootstrap variables which have been provided
as command arguments.
*/
@@ -119,7 +121,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
BackendImpl * getMyBackend() const;
const OUString m_loader;
- Reference<XComponentContext> m_xRemoteContext;
+ ComponentBackendDb::Data m_registeredComponentsDb;
enum reg {
REG_UNINIT, REG_VOID, REG_REGISTERED, REG_NOT_REGISTERED, REG_MAYBE_REGISTERED
@@ -139,6 +141,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
virtual void processPackage_(
::osl::ResettableMutexGuard & guard,
bool registerPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const & abortChannel,
Reference<XCommandEnvironment> const & xCmdEnv );
@@ -149,16 +152,12 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
const Reference<registry::XSimpleRegistry> getRDB_RO() const;
public:
- inline ComponentPackageImpl(
+ ComponentPackageImpl(
::rtl::Reference<PackageRegistryBackend> const & myBackend,
OUString const & url, OUString const & name,
Reference<deployment::XPackageTypeInfo> const & xPackageType,
- OUString const & loader )
- : Package( myBackend, url, name, name /* display-name */,
- xPackageType ),
- m_loader( loader ),
- m_registered( REG_UNINIT )
- {}
+ OUString const & loader, bool bRemoved,
+ OUString const & identifier);
};
friend class ComponentPackageImpl;
@@ -179,19 +178,17 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
virtual void processPackage_(
::osl::ResettableMutexGuard & guard,
bool registerPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const & abortChannel,
Reference<XCommandEnvironment> const & xCmdEnv );
public:
- inline TypelibraryPackageImpl(
+ TypelibraryPackageImpl(
::rtl::Reference<PackageRegistryBackend> const & myBackend,
OUString const & url, OUString const & name,
Reference<deployment::XPackageTypeInfo> const & xPackageType,
- bool jarFile )
- : Package( myBackend, url, name, name /* display-name */,
- xPackageType ),
- m_jarFile( jarFile )
- {}
+ bool jarFile, bool bRemoved,
+ OUString const & identifier);
};
friend class TypelibraryPackageImpl;
@@ -212,6 +209,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
// PackageRegistryBackend
virtual Reference<deployment::XPackage> bindPackage_(
OUString const & url, OUString const & mediaType,
+ sal_Bool bRemoved, OUString const & identifier,
Reference<XCommandEnvironment> const & xCmdEnv );
virtual void SAL_CALL disposing();
@@ -230,6 +228,13 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
OUString m_commonRDB_RO;
OUString m_nativeRDB_RO;
+ std::auto_ptr<ComponentBackendDb> m_backendDb;
+
+ void addDataToDb(OUString const & url, ComponentBackendDb::Data const & data);
+ void deleteDataFromDb(OUString const & url);
+ ComponentBackendDb::Data readDataFromDb(OUString const & url);
+
+
//These rdbs are for writing new service entries. The rdb files are copies
//which are created when services are added or removed.
Reference<registry::XSimpleRegistry> m_xCommonRDB;
@@ -275,6 +280,25 @@ public:
};
//______________________________________________________________________________
+
+BackendImpl::ComponentPackageImpl::ComponentPackageImpl(
+ ::rtl::Reference<PackageRegistryBackend> const & myBackend,
+ OUString const & url, OUString const & name,
+ Reference<deployment::XPackageTypeInfo> const & xPackageType,
+ OUString const & loader, bool bRemoved,
+ OUString const & identifier)
+ : Package( myBackend, url, name, name /* display-name */,
+ xPackageType, bRemoved, identifier),
+ m_loader( loader ),
+ m_registered( REG_UNINIT )
+{
+ if (bRemoved)
+ {
+ m_registeredComponentsDb = getMyBackend()->readDataFromDb(url);
+ }
+}
+
+
const Reference<registry::XSimpleRegistry>
BackendImpl::ComponentPackageImpl::getRDB() const
{
@@ -332,7 +356,7 @@ BackendImpl * BackendImpl::ComponentPackageImpl::getMyBackend() const
//______________________________________________________________________________
void BackendImpl::ComponentPackageImpl::disposing()
{
- m_xRemoteContext.clear();
+// m_xRemoteContext.clear();
Package::disposing();
}
@@ -371,59 +395,59 @@ void BackendImpl::disposing()
}
}
+
void BackendImpl::initServiceRdbFiles()
{
const Reference<XCommandEnvironment> xCmdEnv;
- if (! m_readOnly)
+
+ ::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv );
+ ::ucbhelper::Content oldRDB;
+ // switch common rdb:
+ if (m_commonRDB_RO.getLength() > 0)
{
- ::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv );
- ::ucbhelper::Content oldRDB;
- // switch common rdb:
- if (m_commonRDB_RO.getLength() > 0)
- {
- create_ucb_content(
- &oldRDB, makeURL( getCachePath(), m_commonRDB_RO),
- xCmdEnv, false /* no throw */ );
- }
- m_commonRDB = m_commonRDB_RO.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM("common.rdb") )
- ? OUSTR("common_.rdb") : OUSTR("common.rdb");
- if (oldRDB.get().is())
- {
- if (! cacheDir.transferContent(
+ create_ucb_content(
+ &oldRDB, makeURL( getCachePath(), m_commonRDB_RO),
+ xCmdEnv, false /* no throw */ );
+ }
+ m_commonRDB = m_commonRDB_RO.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("common.rdb") )
+ ? OUSTR("common_.rdb") : OUSTR("common.rdb");
+ if (oldRDB.get().is())
+ {
+ if (! cacheDir.transferContent(
oldRDB, ::ucbhelper::InsertOperation_COPY,
m_commonRDB, NameClash::OVERWRITE ))
- {
-
- throw RuntimeException(
- OUSTR("UCB transferContent() failed!"), 0 );
- }
- oldRDB = ::ucbhelper::Content();
- }
- // switch native rdb:
- if (m_nativeRDB_RO.getLength() > 0)
{
- create_ucb_content(
- &oldRDB, makeURL(getCachePath(), m_nativeRDB_RO),
- xCmdEnv, false /* no throw */ );
+
+ throw RuntimeException(
+ OUSTR("UCB transferContent() failed!"), 0 );
}
- const OUString plt_rdb( getPlatformString() + OUSTR(".rdb") );
- const OUString plt_rdb_( getPlatformString() + OUSTR("_.rdb") );
- m_nativeRDB = m_nativeRDB_RO.equals( plt_rdb ) ? plt_rdb_ : plt_rdb;
- if (oldRDB.get().is())
- {
- if (! cacheDir.transferContent(
+ oldRDB = ::ucbhelper::Content();
+ }
+ // switch native rdb:
+ if (m_nativeRDB_RO.getLength() > 0)
+ {
+ create_ucb_content(
+ &oldRDB, makeURL(getCachePath(), m_nativeRDB_RO),
+ xCmdEnv, false /* no throw */ );
+ }
+ const OUString plt_rdb( getPlatformString() + OUSTR(".rdb") );
+ const OUString plt_rdb_( getPlatformString() + OUSTR("_.rdb") );
+ m_nativeRDB = m_nativeRDB_RO.equals( plt_rdb ) ? plt_rdb_ : plt_rdb;
+ if (oldRDB.get().is())
+ {
+ if (! cacheDir.transferContent(
oldRDB, ::ucbhelper::InsertOperation_COPY,
m_nativeRDB, NameClash::OVERWRITE ))
- throw RuntimeException(
+ throw RuntimeException(
OUSTR("UCB transferContent() failed!"), 0 );
- }
-
- // UNO is bootstrapped, flush for next process start:
- m_unorc_modified = true;
- unorc_flush( Reference<XCommandEnvironment>() );
}
+ // UNO is bootstrapped, flush for next process start:
+ m_unorc_modified = true;
+ unorc_flush( Reference<XCommandEnvironment>() );
+
+
// common rdb for java, native rdb for shared lib components
if (m_commonRDB.getLength() > 0) {
m_xCommonRDB.set(
@@ -433,7 +457,8 @@ void BackendImpl::initServiceRdbFiles()
m_xComponentContext ), UNO_QUERY_THROW );
m_xCommonRDB->open(
makeURL( expandUnoRcUrl(getCachePath()), m_commonRDB ),
- m_readOnly, !m_readOnly );
+// m_readOnly, !m_readOnly );
+ false, true);
}
if (m_nativeRDB.getLength() > 0) {
m_xNativeRDB.set(
@@ -443,7 +468,8 @@ void BackendImpl::initServiceRdbFiles()
m_xComponentContext ), UNO_QUERY_THROW );
m_xNativeRDB->open(
makeURL( expandUnoRcUrl(getCachePath()), m_nativeRDB ),
- m_readOnly, !m_readOnly );
+// m_readOnly, !m_readOnly );
+ false, true);
}
}
@@ -562,9 +588,33 @@ BackendImpl::BackendImpl(
initServiceRdbFiles_RO();
+ OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml"));
+ m_backendDb.reset(
+ new ComponentBackendDb(getComponentContext(), dbFile));
}
}
+void BackendImpl::addDataToDb(
+ OUString const & url, ComponentBackendDb::Data const & data)
+{
+ if (m_backendDb.get())
+ m_backendDb->addEntry(url, data);
+}
+
+void BackendImpl::deleteDataFromDb(OUString const & url)
+{
+ if (m_backendDb.get())
+ m_backendDb->removeEntry(url);
+}
+
+ComponentBackendDb::Data BackendImpl::readDataFromDb(OUString const & url)
+{
+ ComponentBackendDb::Data data;
+ if (m_backendDb.get())
+ data = m_backendDb->getEntry(url);
+ return data;
+}
+
// XPackageRegistry
//______________________________________________________________________________
Sequence< Reference<deployment::XPackageTypeInfo> >
@@ -577,6 +627,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException)
//______________________________________________________________________________
Reference<deployment::XPackage> BackendImpl::bindPackage_(
OUString const & url, OUString const & mediaType_,
+ sal_Bool bRemoved, OUString const & identifier,
Reference<XCommandEnvironment> const & xCmdEnv )
{
OUString mediaType(mediaType_);
@@ -632,9 +683,14 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
{
if (type.EqualsIgnoreCaseAscii("application"))
{
- ::ucbhelper::Content ucbContent( url, xCmdEnv );
- const OUString name( ucbContent.getPropertyValue(
- StrTitle::get() ).get<OUString>() );
+ OUString name;
+ if (!bRemoved)
+ {
+ ::ucbhelper::Content ucbContent( url, xCmdEnv );
+ name = ucbContent.getPropertyValue(
+ StrTitle::get() ).get<OUString>();
+ }
+
if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.uno-component"))
{
// xxx todo: probe and evaluate component xml description
@@ -649,17 +705,20 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
if (value.EqualsIgnoreCaseAscii("native")) {
return new BackendImpl::ComponentPackageImpl(
this, url, name, m_xDynComponentTypeInfo,
- OUSTR("com.sun.star.loader.SharedLibrary") );
+ OUSTR("com.sun.star.loader.SharedLibrary"),
+ bRemoved, identifier);
}
if (value.EqualsIgnoreCaseAscii("Java")) {
return new BackendImpl::ComponentPackageImpl(
this, url, name, m_xJavaComponentTypeInfo,
- OUSTR("com.sun.star.loader.Java2") );
+ OUSTR("com.sun.star.loader.Java2"),
+ bRemoved, identifier);
}
if (value.EqualsIgnoreCaseAscii("Python")) {
return new BackendImpl::ComponentPackageImpl(
this, url, name, m_xPythonComponentTypeInfo,
- OUSTR("com.sun.star.loader.Python") );
+ OUSTR("com.sun.star.loader.Python"),
+ bRemoved, identifier);
}
}
}
@@ -675,12 +734,12 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
{
return new BackendImpl::TypelibraryPackageImpl(
this, url, name, m_xRDBTypelibTypeInfo,
- false /* rdb */ );
+ false /* rdb */, bRemoved, identifier);
}
if (value.EqualsIgnoreCaseAscii("Java")) {
return new BackendImpl::TypelibraryPackageImpl(
this, url, name, m_xJavaTypelibTypeInfo,
- true /* jar */ );
+ true /* jar */, bRemoved, identifier);
}
}
}
@@ -717,16 +776,18 @@ void BackendImpl::unorc_verify_init(
sal_Int32 index = sizeof ("UNO_JAVA_CLASSPATH=") - 1;
do {
OUString token( line.getToken( 0, ' ', index ).trim() );
- if (token.getLength() > 0) {
- // cleanup, check if existing:
+ if (token.getLength() > 0)
+ {
if (create_ucb_content(
0, expandUnoRcTerm(token), xCmdEnv,
- false /* no throw */ )) {
+ false /* no throw */ ))
+ {
+ //The jar file may not exist anymore if a shared or bundled
+ //extension was removed, but it can still be in the unorc
+ //After running XExtensionManager::synchronize, the unorc is
+ //cleaned up
m_jar_typelibs.push_back( token );
}
- else
- OSL_ENSURE(
- 0, "### invalid UNO_JAVA_CLASSPATH entry!" );
}
}
while (index >= 0);
@@ -736,17 +797,20 @@ void BackendImpl::unorc_verify_init(
sal_Int32 index = sizeof ("UNO_TYPES=") - 1;
do {
OUString token( line.getToken( 0, ' ', index ).trim() );
- if (token.getLength() > 0) {
+ if (token.getLength() > 0)
+ {
if (token[ 0 ] == '?')
token = token.copy( 1 );
- // cleanup, check if existing:
- if (create_ucb_content(
- 0, expandUnoRcTerm(token),
- xCmdEnv, false /* no throw */ )) {
- m_rdb_typelibs.push_back( token );
- }
- else
- OSL_ENSURE( 0, "### invalid UNO_TYPES entry!" );
+ if (create_ucb_content(
+ 0, expandUnoRcTerm(token), xCmdEnv,
+ false /* no throw */ ))
+ {
+ //The RDB file may not exist anymore if a shared or bundled
+ //extension was removed, but it can still be in the unorc.
+ //After running XExtensionManager::synchronize, the unorc is
+ //cleaned up
+ m_rdb_typelibs.push_back( token );
+ }
}
}
while (index >= 0);
@@ -785,18 +849,11 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv )
return;
::rtl::OStringBuffer buf;
- // UNO_USER_PACKAGES_CACHE, UNO_SHARED_PACKAGES_CACHE have to be resolved
- // locally:
- if (m_eContext == CONTEXT_USER) {
- buf.append( RTL_CONSTASCII_STRINGPARAM(
- "UNO_USER_PACKAGES_CACHE=$ORIGIN/../..") );
- }
- else if (m_eContext == CONTEXT_SHARED) {
- buf.append( RTL_CONSTASCII_STRINGPARAM(
- "UNO_SHARED_PACKAGES_CACHE=$ORIGIN/../..") );
- }
- else
- OSL_ASSERT(0);
+
+ buf.append(RTL_CONSTASCII_STRINGPARAM("ORIGIN="));
+ OUString sOrigin = dp_misc::makeRcTerm(m_cachePath);
+ ::rtl::OString osOrigin = ::rtl::OUStringToOString(sOrigin, RTL_TEXTENCODING_UTF8);
+ buf.append(osOrigin);
buf.append(LF);
if (! m_jar_typelibs.empty())
@@ -852,6 +909,9 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv )
// write native rc:
::rtl::OStringBuffer buf2;
+ buf2.append(RTL_CONSTASCII_STRINGPARAM("ORIGIN="));
+ buf2.append(osOrigin);
+ buf2.append(LF);
buf2.append( RTL_CONSTASCII_STRINGPARAM("UNO_SERVICES=?$ORIGIN/") );
buf2.append( ::rtl::OUStringToOString(
sNativeRDB, RTL_TEXTENCODING_ASCII_US ) );
@@ -882,28 +942,11 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv )
m_unorc_modified = false;
}
-//------------------------------------------------------------------------------
-inline OUString makeRcTerm( OUString const & url )
-{
- OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "vnd.sun.star.expand:") ) );
- if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) {
- // cut protocol:
- OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) );
- // decode uric class chars:
- rcterm = ::rtl::Uri::decode(
- rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
- return rcterm;
- }
- else
- return url;
-}
-
//______________________________________________________________________________
bool BackendImpl::addToUnoRc( bool jarFile, OUString const & url_,
Reference<XCommandEnvironment> const & xCmdEnv )
{
- const OUString rcterm( makeRcTerm(url_) );
+ const OUString rcterm( dp_misc::makeRcTerm(url_) );
const ::osl::MutexGuard guard( getMutex() );
unorc_verify_init( xCmdEnv );
t_stringlist & rSet = getTypelibs(jarFile);
@@ -923,7 +966,7 @@ bool BackendImpl::removeFromUnoRc(
bool jarFile, OUString const & url_,
Reference<XCommandEnvironment> const & xCmdEnv )
{
- const OUString rcterm( makeRcTerm(url_) );
+ const OUString rcterm( dp_misc::makeRcTerm(url_) );
const ::osl::MutexGuard guard( getMutex() );
unorc_verify_init( xCmdEnv );
getTypelibs(jarFile).remove( rcterm );
@@ -937,7 +980,7 @@ bool BackendImpl::removeFromUnoRc(
bool BackendImpl::hasInUnoRc(
bool jarFile, OUString const & url_ )
{
- const OUString rcterm( makeRcTerm(url_) );
+ const OUString rcterm( dp_misc::makeRcTerm(url_) );
const ::osl::MutexGuard guard( getMutex() );
t_stringlist const & rSet = getTypelibs(jarFile);
return ::std::find( rSet.begin(), rSet.end(), rcterm ) != rSet.end();
@@ -1174,6 +1217,7 @@ BackendImpl::ComponentPackageImpl::isRegistered_(
void BackendImpl::ComponentPackageImpl::processPackage_(
::osl::ResettableMutexGuard &,
bool doRegisterPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const & abortChannel,
Reference<XCommandEnvironment> const & xCmdEnv )
{
@@ -1183,16 +1227,25 @@ void BackendImpl::ComponentPackageImpl::processPackage_(
const bool java = m_loader.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.Java2") );
const OUString url( getURL() );
- bool isJavaTypelib = java &&
- !jarManifestHeaderPresent( url, OUSTR("UNO-Type-Path"), xCmdEnv );
+ bool isJavaTypelib;
+ if (m_bRemoved)
+ isJavaTypelib = m_registeredComponentsDb.javaTypeLibrary;
+ else
+ isJavaTypelib = java &&
+ !jarManifestHeaderPresent( url, OUSTR("UNO-Type-Path"), xCmdEnv );
+ ComponentBackendDb::Data data;
+ data.javaTypeLibrary = isJavaTypelib;
if (doRegisterPackage)
{
- if (! m_xRemoteContext.is()) {
- m_xRemoteContext.set(
+ Reference <uno::XComponentContext> context(that->getComponentContext());
+ if (! startup)
+ {
+ context.set(
that->getObject( url ), UNO_QUERY );
- if (! m_xRemoteContext.is()) {
- m_xRemoteContext.set(
+
+ if (! context.is()) {
+ context.set(
that->insertObject( url, raise_uno_process(
that->getComponentContext(),
abortChannel ) ),
@@ -1202,147 +1255,170 @@ void BackendImpl::ComponentPackageImpl::processPackage_(
const Reference<registry::XSimpleRegistry> xServicesRDB( getRDB() );
const Reference<registry::XImplementationRegistration> xImplReg(
- m_xRemoteContext->getServiceManager()->createInstanceWithContext(
+ context->getServiceManager()->createInstanceWithContext(
OUSTR("com.sun.star.registry.ImplementationRegistration"),
- m_xRemoteContext ), UNO_QUERY_THROW );
+ context ), UNO_QUERY_THROW );
xImplReg->registerImplementation( m_loader, url, xServicesRDB );
//only write to unorc if registration was successful.
//It may fail if there is no suitable java.
if (isJavaTypelib)
+ {
that->addToUnoRc( java, url, xCmdEnv );
+ data.javaTypeLibrary = true;
+ }
t_stringlist implNames;
t_stringpairvec singletons;
- const Reference<loader::XImplementationLoader> xLoader(
- getComponentInfo( &implNames, &singletons, m_xRemoteContext ) );
-
- // factories live insertion:
- const Reference<container::XSet> xSet(
- that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW );
- for ( t_stringlist::const_iterator iPos( implNames.begin() );
- iPos != implNames.end(); ++iPos )
+ const Reference<loader::XImplementationLoader> xLoader(
+ getComponentInfo( &implNames, &singletons, context ) );
+ data.implementationNames = implNames;
+ data.singletons = singletons;
+
+ if (!startup)
{
- checkAborted( abortChannel );
- OUString const & implName = *iPos;
- // activate factory:
- const Reference<XInterface> xFactory(
- xLoader->activate(
- implName, OUString(), url,
- xServicesRDB->getRootKey()->openKey(
- OUSTR("/IMPLEMENTATIONS/") + implName ) ) );
- try {
- xSet->insert( Any(xFactory) );
- } // ignore if factory has already been inserted:
- catch (container::ElementExistException &) {
- OSL_ENSURE( 0, "### factory already registered?" );
+ // factories live insertion:
+ const Reference<container::XSet> xSet(
+ that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW );
+ for ( t_stringlist::const_iterator iPos( implNames.begin() );
+ iPos != implNames.end(); ++iPos )
+ {
+ checkAborted( abortChannel );
+ OUString const & implName = *iPos;
+ // activate factory:
+ const Reference<XInterface> xFactory(
+ xLoader->activate(
+ implName, OUString(), url,
+ xServicesRDB->getRootKey()->openKey(
+ OUSTR("/IMPLEMENTATIONS/") + implName ) ) );
+ try {
+ xSet->insert( Any(xFactory) );
+ } // ignore if factory has already been inserted:
+ catch (container::ElementExistException &) {
+ OSL_ENSURE( 0, "### factory already registered?" );
+ }
}
- }
- if (! singletons.empty())
- {
- // singletons live insertion:
- const Reference<container::XNameContainer> xRootContext(
- that->getComponentContext()->getValueByName(
- OUSTR("_root") ), UNO_QUERY );
- if (xRootContext.is())
+ if (! singletons.empty())
{
- for ( t_stringpairvec::const_iterator iPos(
- singletons.begin() );
- iPos != singletons.end(); ++iPos )
+ // singletons live insertion:
+ const Reference<container::XNameContainer> xRootContext(
+ that->getComponentContext()->getValueByName(
+ OUSTR("_root") ), UNO_QUERY );
+ if (xRootContext.is())
{
- ::std::pair<OUString, OUString> const & sp = *iPos;
- const OUString name( OUSTR("/singletons/") + sp.first );
- // assure no arguments:
- try {
- xRootContext->removeByName( name + OUSTR("/arguments"));
- } catch (container::NoSuchElementException &) {}
- // used service:
- try {
- xRootContext->insertByName(
- name + OUSTR("/service"), Any(sp.second) );
- } catch (container::ElementExistException &) {
- xRootContext->replaceByName(
- name + OUSTR("/service"), Any(sp.second) );
- }
- // singleton entry:
- try {
- xRootContext->insertByName( name, Any() );
- } catch (container::ElementExistException & exc) {
- (void) exc; // avoid warnings
- OSL_ENSURE(
- 0, OUStringToOString(
- exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
- xRootContext->replaceByName( name, Any() );
+ for ( t_stringpairvec::const_iterator iPos(
+ singletons.begin() );
+ iPos != singletons.end(); ++iPos )
+ {
+ ::std::pair<OUString, OUString> const & sp = *iPos;
+ const OUString name( OUSTR("/singletons/") + sp.first );
+ // assure no arguments:
+ try {
+ xRootContext->removeByName( name + OUSTR("/arguments"));
+ } catch (container::NoSuchElementException &) {}
+ // used service:
+ try {
+ xRootContext->insertByName(
+ name + OUSTR("/service"), Any(sp.second) );
+ } catch (container::ElementExistException &) {
+ xRootContext->replaceByName(
+ name + OUSTR("/service"), Any(sp.second) );
+ }
+ // singleton entry:
+ try {
+ xRootContext->insertByName( name, Any() );
+ } catch (container::ElementExistException & exc) {
+ (void) exc; // avoid warnings
+ OSL_ENSURE(
+ 0, OUStringToOString(
+ exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ xRootContext->replaceByName( name, Any() );
+ }
}
}
}
}
m_registered = REG_REGISTERED;
+ getMyBackend()->addDataToDb(url, data);
}
else // revokePackage()
{
// set to VOID during revocation process:
m_registered = REG_VOID;
- Reference<XComponentContext> xContext;
- if (m_xRemoteContext.is()) // has been activated in this process
- xContext = m_xRemoteContext;
- else // has been deployed in former times
+ //get the remote context. If it does not exist then use the local one
+ Reference<XComponentContext> xContext(
+ that->getObject( url ), UNO_QUERY );
+ bool bRemoteContext = false;
+ if (!xContext.is())
xContext = that->getComponentContext();
+ else
+ bRemoteContext = true;
t_stringlist implNames;
t_stringpairvec singletons;
- getComponentInfo( &implNames, &singletons, xContext );
-
- // factories live removal:
- const Reference<container::XSet> xSet(
- that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW );
- for ( t_stringlist::const_iterator iPos( implNames.begin() );
- iPos != implNames.end(); ++iPos )
+ if (m_bRemoved)
{
- OUString const & implName = *iPos;
- try {
- xSet->remove( Any(implName) );
- } // ignore if factory has not been live deployed:
- catch (container::NoSuchElementException &) {
- }
+ implNames = m_registeredComponentsDb.implementationNames;
+ singletons = m_registeredComponentsDb.singletons;
+ }
+ else
+ {
+ getComponentInfo( &implNames, &singletons, xContext );
}
- if (! singletons.empty())
+ if (!startup)
{
- // singletons live removal:
- const Reference<container::XNameContainer> xRootContext(
- that->getComponentContext()->getValueByName(
- OUSTR("_root") ), UNO_QUERY );
- if (xRootContext.is())
+ // factories live removal:
+ const Reference<container::XSet> xSet(
+ that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW );
+ for ( t_stringlist::const_iterator iPos( implNames.begin() );
+ iPos != implNames.end(); ++iPos )
+ {
+ OUString const & implName = *iPos;
+ try {
+ xSet->remove( Any(implName) );
+ } // ignore if factory has not been live deployed:
+ catch (container::NoSuchElementException &) {
+ }
+ }
+
+ if (! singletons.empty())
{
- for ( t_stringpairvec::const_iterator iPos(
- singletons.begin() );
- iPos != singletons.end(); ++iPos )
+ // singletons live removal:
+ const Reference<container::XNameContainer> xRootContext(
+ that->getComponentContext()->getValueByName(
+ OUSTR("_root") ), UNO_QUERY );
+ if (xRootContext.is())
{
- ::std::pair<OUString, OUString> const & sp = *iPos;
- const OUString name( OUSTR("/singletons/") + sp.first );
- // arguments:
- try {
- xRootContext->removeByName( name + OUSTR("/arguments"));
- }
- catch (container::NoSuchElementException &) {}
- // used service:
- try {
- xRootContext->removeByName( name + OUSTR("/service") );
- }
- catch (container::NoSuchElementException &) {}
- // singleton entry:
- try {
- xRootContext->removeByName( name );
- }
- catch (container::NoSuchElementException & exc) {
- (void) exc; // avoid warnings
- OSL_ENSURE(
- 0, OUStringToOString(
- exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ for ( t_stringpairvec::const_iterator iPos(
+ singletons.begin() );
+ iPos != singletons.end(); ++iPos )
+ {
+ ::std::pair<OUString, OUString> const & sp = *iPos;
+ const OUString name( OUSTR("/singletons/") + sp.first );
+ // arguments:
+ try {
+ xRootContext->removeByName( name + OUSTR("/arguments"));
+ }
+ catch (container::NoSuchElementException &) {}
+ // used service:
+ try {
+ xRootContext->removeByName( name + OUSTR("/service") );
+ }
+ catch (container::NoSuchElementException &) {}
+ // singleton entry:
+ try {
+ xRootContext->removeByName( name );
+ }
+ catch (container::NoSuchElementException & exc) {
+ (void) exc; // avoid warnings
+ OSL_ENSURE(
+ 0, OUStringToOString(
+ exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
}
}
}
@@ -1358,16 +1434,25 @@ void BackendImpl::ComponentPackageImpl::processPackage_(
if (isJavaTypelib)
that->removeFromUnoRc( java, url, xCmdEnv );
- if (m_xRemoteContext.is()) {
+ if (bRemoteContext)
that->releaseObject( url );
- m_xRemoteContext.clear();
- }
m_registered = REG_NOT_REGISTERED;
+ getMyBackend()->deleteDataFromDb(url);
}
}
//##############################################################################
+BackendImpl::TypelibraryPackageImpl::TypelibraryPackageImpl(
+ ::rtl::Reference<PackageRegistryBackend> const & myBackend,
+ OUString const & url, OUString const & name,
+ Reference<deployment::XPackageTypeInfo> const & xPackageType,
+ bool jarFile, bool bRemoved, OUString const & identifier)
+ : Package( myBackend, url, name, name /* display-name */,
+ xPackageType, bRemoved, identifier),
+ m_jarFile( jarFile )
+{
+}
// Package
BackendImpl * BackendImpl::TypelibraryPackageImpl::getMyBackend() const
@@ -1403,6 +1488,7 @@ BackendImpl::TypelibraryPackageImpl::isRegistered_(
void BackendImpl::TypelibraryPackageImpl::processPackage_(
::osl::ResettableMutexGuard &,
bool doRegisterPackage,
+ bool /*startup*/,
::rtl::Reference<AbortChannel> const &,
Reference<XCommandEnvironment> const & xCmdEnv )
{
@@ -1490,7 +1576,7 @@ namespace sdecl = comphelper::service_decl;
sdecl::class_<BackendImpl, sdecl::with_args<true> > serviceBI;
extern sdecl::ServiceDecl const serviceDecl(
serviceBI,
- "com.sun.star.comp.deployment.component.PackageRegistryBackend",
+ IMPLEMENTATION_NAME,
BACKEND_SERVICE_NAME );
} // namespace component
diff --git a/desktop/source/deployment/registry/component/makefile.mk b/desktop/source/deployment/registry/component/makefile.mk
index 4c4016f9bf6c..b7ee5c203cd5 100644
--- a/desktop/source/deployment/registry/component/makefile.mk
+++ b/desktop/source/deployment/registry/component/makefile.mk
@@ -40,7 +40,8 @@ SRC1FILES = \
INCPRE += ..$/..$/inc
SLOFILES = \
- $(SLO)$/dp_component.obj
+ $(SLO)$/dp_component.obj \
+ $(SLO)$/dp_compbackenddb.obj
.INCLUDE : ..$/..$/target.pmk
.INCLUDE : target.mk
diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
index 6cf6d4ff7818..9ea6e8227340 100644
--- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx
+++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
@@ -35,7 +35,6 @@
#include "dp_backend.h"
#include "dp_persmap.h"
#include "dp_ucb.h"
-#include "dp_xml.h"
#include "rtl/string.hxx"
#include "rtl/ustrbuf.hxx"
#include "rtl/uri.hxx"
@@ -55,6 +54,7 @@
#include <list>
#include <memory>
+#include "dp_configurationbackenddb.hxx"
using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -86,6 +86,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
virtual void processPackage_(
::osl::ResettableMutexGuard & guard,
bool registerPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const & abortChannel,
Reference<XCommandEnvironment> const & xCmdEnv );
@@ -94,9 +95,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
::rtl::Reference<PackageRegistryBackend> const & myBackend,
OUString const & url, OUString const & name,
Reference<deployment::XPackageTypeInfo> const & xPackageType,
- bool isSchema )
+ bool isSchema, bool bRemoved, OUString const & identifier)
: Package( myBackend, url, name, name /* display-name */,
- xPackageType ),
+ xPackageType, bRemoved, identifier),
m_isSchema( isSchema )
{}
};
@@ -110,10 +111,12 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
bool m_configmgrini_inited;
bool m_configmgrini_modified;
+ std::auto_ptr<ConfigurationBackendDb> m_backendDb;
// PackageRegistryBackend
virtual Reference<deployment::XPackage> bindPackage_(
- OUString const & url, OUString const & mediaType,
+ OUString const & url, OUString const & mediaType, sal_Bool bRemoved,
+ OUString const & identifier,
Reference<XCommandEnvironment> const & xCmdEnv );
::std::auto_ptr<PersistentMap> m_registeredPackages;
@@ -133,7 +136,11 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
Reference<XCommandEnvironment> const & xCmdEnv );
bool removeFromConfigmgrIni( bool isSchema, OUString const & url,
Reference<XCommandEnvironment> const & xCmdEnv );
- bool hasInConfigmgrIni( bool isSchema, OUString const & url );
+
+ void addDataToDb(OUString const & url, ConfigurationBackendDb::Data const & data);
+ ::boost::optional<ConfigurationBackendDb::Data> readDataFromDb(OUString const & url);
+ void deleteDataFromDb(OUString const & url);
+ ::std::list<OUString> getAllIniEntries();
public:
BackendImpl( Sequence<Any> const & args,
@@ -191,18 +198,64 @@ BackendImpl::BackendImpl(
const Reference<XCommandEnvironment> xCmdEnv;
- if (transientMode()) {
+ if (transientMode())
+ {
//TODO
}
- else {
+ else
+ {
+ OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml"));
+ m_backendDb.reset(
+ new ConfigurationBackendDb(getComponentContext(), dbFile));
+ //clean up data folders which are no longer used.
+ //This must not be done in the same process where the help files
+ //are still registers. Only after revoking and restarting OOo the folders
+ //can be removed. This works now, because the extension manager is a singleton
+ //and the backends are only create once per process.
+ ::std::list<OUString> folders = m_backendDb->getAllDataUrls();
+ deleteUnusedFolders(OUString(), folders);
+
+
configmgrini_verify_init( xCmdEnv );
m_registeredPackages.reset(
new PersistentMap(
makeURL( getCachePath(), OUSTR("registered_packages.db") ),
- m_readOnly ) );
- }
+ false ) );
+ }
}
+void BackendImpl::addDataToDb(
+ OUString const & url, ConfigurationBackendDb::Data const & data)
+{
+ if (m_backendDb.get())
+ m_backendDb->addEntry(url, data);
+}
+
+::boost::optional<ConfigurationBackendDb::Data> BackendImpl::readDataFromDb(
+ OUString const & url)
+{
+ ::boost::optional<ConfigurationBackendDb::Data> data;
+ if (m_backendDb.get())
+ data = m_backendDb->getEntry(url);
+ return data;
+}
+
+void BackendImpl::deleteDataFromDb(OUString const & url)
+{
+ if (m_backendDb.get())
+ m_backendDb->removeEntry(url);
+}
+
+::std::list<OUString> BackendImpl::getAllIniEntries()
+{
+ if (m_backendDb.get())
+ return m_backendDb->getAllIniEntries();
+ else
+ return ::std::list<OUString>();
+}
+
+
+
// XPackageRegistry
//______________________________________________________________________________
Sequence< Reference<deployment::XPackageTypeInfo> >
@@ -215,6 +268,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException)
//______________________________________________________________________________
Reference<deployment::XPackage> BackendImpl::bindPackage_(
OUString const & url, OUString const & mediaType_,
+ sal_Bool bRemoved, OUString const & identifier,
Reference<XCommandEnvironment> const & xCmdEnv )
{
OUString mediaType( mediaType_ );
@@ -249,20 +303,27 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
{
if (type.EqualsIgnoreCaseAscii("application"))
{
+ OUString name;
+ if (!bRemoved)
+ {
+ ::ucbhelper::Content ucbContent( url, xCmdEnv );
+ name = ucbContent.getPropertyValue(
+ StrTitle::get() ).get<OUString>();
+ }
+
::ucbhelper::Content ucbContent( url, xCmdEnv );
if (subType.EqualsIgnoreCaseAscii(
- "vnd.sun.star.configuration-data")) {
+ "vnd.sun.star.configuration-data"))
+ {
return new PackageImpl(
- this, url, ucbContent.getPropertyValue(
- StrTitle::get() ).get<OUString>(),
- m_xConfDataTypeInfo, false /* data file */ );
+ this, url, name, m_xConfDataTypeInfo, false /* data file */,
+ bRemoved, identifier);
}
else if (subType.EqualsIgnoreCaseAscii(
"vnd.sun.star.configuration-schema")) {
return new PackageImpl(
- this, url, ucbContent.getPropertyValue(
- StrTitle::get() ).get<OUString>(),
- m_xConfSchemaTypeInfo, true /* schema file */ );
+ this, url, name, m_xConfSchemaTypeInfo, true /* schema file */,
+ bRemoved, identifier);
}
}
}
@@ -302,11 +363,12 @@ void BackendImpl::configmgrini_verify_init(
if (create_ucb_content(
0, expandUnoRcTerm(token), xCmdEnv,
false /* no throw */ )) {
+ //The file may not exist anymore if a shared or bundled
+ //extension was removed, but it can still be in the configmgrini.
+ //After running XExtensionManager::synchronize, the configmgrini is
+ //cleaned up
m_xcs_files.push_back( token );
}
- else
- OSL_ENSURE(
- 0, "### invalid SCHEMA entry!" );
}
}
while (index >= 0);
@@ -323,10 +385,24 @@ void BackendImpl::configmgrini_verify_init(
if (create_ucb_content(
0, expandUnoRcTerm(token),
xCmdEnv, false /* no throw */ )) {
+ //The file may not exist anymore if a shared or bundled
+ //extension was removed, but it can still be in the configmgrini.
+ //After running XExtensionManager::synchronize, the configmgrini is
+ //cleaned up
m_xcu_files.push_back( token );
}
else
- OSL_ENSURE( 0, "### invalid DATA entry!" );
+ {
+ //Check if it was removed. Only when the file contained %origin, so that
+ //a new file was writen in the user installation (e.g. $BUNDLED_EXTENSIONS_USER)
+ //See also ConfigurationBackendDb.iniEntry
+ ::std::list<OUString> iniEntries = getAllIniEntries();
+ if (::std::find(iniEntries.begin(), iniEntries.end(), token)
+ != iniEntries.end())
+ m_xcu_files.push_back( token );
+ else
+ OSL_ENSURE(0, "Extension manager: Invalid configmgr.ini entry.");
+ }
}
}
while (index >= 0);
@@ -347,20 +423,6 @@ void BackendImpl::configmgrini_flush(
return;
::rtl::OStringBuffer buf;
- // UNO_USER_PACKAGES_CACHE, UNO_SHARED_PACKAGES_CACHE have to be resolved
- // locally:
- if (m_eContext == CONTEXT_USER) {
- buf.append( RTL_CONSTASCII_STRINGPARAM(
- "UNO_USER_PACKAGES_CACHE=$ORIGIN/../..") );
- }
- else if (m_eContext == CONTEXT_SHARED) {
- buf.append( RTL_CONSTASCII_STRINGPARAM(
- "UNO_SHARED_PACKAGES_CACHE=$ORIGIN/../..") );
- }
- else
- OSL_ASSERT(0);
- buf.append(LF);
-
if (! m_xcs_files.empty())
{
t_stringlist::const_iterator iPos( m_xcs_files.begin() );
@@ -407,28 +469,11 @@ void BackendImpl::configmgrini_flush(
m_configmgrini_modified = false;
}
-//------------------------------------------------------------------------------
-inline OUString makeRcTerm( OUString const & url )
-{
- OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "vnd.sun.star.expand:") ) );
- if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) {
- // cut protocol:
- OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) );
- // decode uric class chars:
- rcterm = ::rtl::Uri::decode(
- rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
- return rcterm;
- }
- else
- return url;
-}
-
//______________________________________________________________________________
bool BackendImpl::addToConfigmgrIni( bool isSchema, OUString const & url_,
Reference<XCommandEnvironment> const & xCmdEnv )
{
- const OUString rcterm( makeRcTerm(url_) );
+ const OUString rcterm( dp_misc::makeRcTerm(url_) );
const ::osl::MutexGuard guard( getMutex() );
configmgrini_verify_init( xCmdEnv );
t_stringlist & rSet = getFiles(isSchema);
@@ -448,15 +493,18 @@ bool BackendImpl::removeFromConfigmgrIni(
bool isSchema, OUString const & url_,
Reference<XCommandEnvironment> const & xCmdEnv )
{
- const OUString rcterm( makeRcTerm(url_) );
+ const OUString rcterm( dp_misc::makeRcTerm(url_) );
const ::osl::MutexGuard guard( getMutex() );
configmgrini_verify_init( xCmdEnv );
t_stringlist & rSet = getFiles(isSchema);
t_stringlist::iterator i(std::find(rSet.begin(), rSet.end(), rcterm));
- if (i == rSet.end() && !isSchema) { //TODO: see replaceOrigin()
- i = std::find(
- rSet.begin(), rSet.end(),
- rcterm + OUString(RTL_CONSTASCII_USTRINGPARAM(".mod")));
+ if (i == rSet.end() && !isSchema)
+ {
+ //in case the xcu contained %origin% then the configmr.ini contains the
+ //url to the file in the user installation (e.g. $BUNDLED_EXTENSIONS_USER)
+ ::boost::optional<ConfigurationBackendDb::Data> data = readDataFromDb(url_);
+ if (data)
+ i = std::find(rSet.begin(), rSet.end(), data->iniEntry);
}
if (i == rSet.end()) {
return false;
@@ -468,21 +516,6 @@ bool BackendImpl::removeFromConfigmgrIni(
return true;
}
-//______________________________________________________________________________
-bool BackendImpl::hasInConfigmgrIni(
- bool isSchema, OUString const & url_ )
-{
- const OUString rcterm( makeRcTerm(url_) );
- const ::osl::MutexGuard guard( getMutex() );
- t_stringlist const & rSet = getFiles(isSchema);
- return ::std::find( rSet.begin(), rSet.end(), rcterm ) != rSet.end()
- || (!isSchema && //TODO: see replaceOrigin()
- ::std::find(
- rSet.begin(), rSet.end(),
- rcterm + OUString(RTL_CONSTASCII_USTRINGPARAM(".mod"))) !=
- rSet.end());
-}
-
//##############################################################################
// Package
@@ -509,14 +542,18 @@ BackendImpl::PackageImpl::isRegistered_(
Reference<XCommandEnvironment> const & )
{
BackendImpl * that = getMyBackend();
- rtl::OUString url(getURL());
+ const rtl::OUString url(getURL());
+
+ bool bReg = false;
+ if (that->readDataFromDb(getURL()))
+ bReg = true;
+ if (!bReg)
+ //fallback for user extension registered in berkeley DB
+ bReg = that->m_registeredPackages->has(
+ rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8 ));
+
return beans::Optional< beans::Ambiguous<sal_Bool> >(
- true /* IsPresent */,
- beans::Ambiguous<sal_Bool>(
- that->hasInConfigmgrIni( m_isSchema, url ) ||
- that->m_registeredPackages->has(
- rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8 ) ),
- false /* IsAmbiguous */ ) );
+ true, beans::Ambiguous<sal_Bool>( bReg, false ) );
}
//------------------------------------------------------------------------------
@@ -554,7 +591,7 @@ OUString encodeForXml( OUString const & text )
//______________________________________________________________________________
OUString replaceOrigin(
- OUString const & url, Reference< XCommandEnvironment > const & xCmdEnv )
+ OUString const & url, OUString const & destFolder, Reference< XCommandEnvironment > const & xCmdEnv, bool & out_replaced)
{
// looking for %origin%:
::ucbhelper::Content ucb_content( url, xCmdEnv );
@@ -624,10 +661,17 @@ OUString replaceOrigin(
return url;
if (write_pos < filtered.getLength())
filtered.realloc( write_pos );
- rtl::OUString newUrl(url + OUString(RTL_CONSTASCII_USTRINGPARAM(".mod")));
- //TODO: unique name
+ rtl::OUString newUrl(url);
+ if (destFolder.getLength())
+ {
+ //get the file name of the xcu and add it to the url of the temporary folder
+ sal_Int32 i = url.lastIndexOf('/');
+ newUrl = destFolder + url.copy(i);
+ }
+
ucbhelper::Content(newUrl, xCmdEnv).writeStream(
xmlscript::createInputStream(filtered), true);
+ out_replaced = true;
return newUrl;
}
@@ -635,6 +679,7 @@ OUString replaceOrigin(
void BackendImpl::PackageImpl::processPackage_(
::osl::ResettableMutexGuard &,
bool doRegisterPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const &,
Reference<XCommandEnvironment> const & xCmdEnv )
{
@@ -643,21 +688,38 @@ void BackendImpl::PackageImpl::processPackage_(
if (doRegisterPackage)
{
- if (m_isSchema)
+ ConfigurationBackendDb::Data data;
+ if (!m_isSchema)
{
- com::sun::star::configuration::Update::get(
- that->m_xComponentContext)->insertExtensionXcsFile(
- that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url));
+ const OUString sModFolder = that->createFolder(OUString(), xCmdEnv);
+ bool out_replaced = false;
+ url = replaceOrigin(url, sModFolder, xCmdEnv, out_replaced);
+ if (out_replaced)
+ data.dataUrl = sModFolder;
+ else
+ deleteTempFolder(sModFolder);
}
- else
+ //No need for live-deployment for bundled extension, because OOo
+ //restarts after installation
+ if (that->m_eContext != CONTEXT_BUNDLED
+ && !startup)
{
- url = replaceOrigin(url, xCmdEnv);
- com::sun::star::configuration::Update::get(
- that->m_xComponentContext)->insertExtensionXcuFile(
- that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url));
+ if (m_isSchema)
+ {
+ com::sun::star::configuration::Update::get(
+ that->m_xComponentContext)->insertExtensionXcsFile(
+ that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url));
+ }
+ else
+ {
+ com::sun::star::configuration::Update::get(
+ that->m_xComponentContext)->insertExtensionXcuFile(
+ that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url));
+ }
}
-
that->addToConfigmgrIni( m_isSchema, url, xCmdEnv );
+ data.iniEntry = dp_misc::makeRcTerm(url);
+ that->addDataToDb(getURL(), data);
}
else // revoke
{
@@ -667,15 +729,31 @@ void BackendImpl::PackageImpl::processPackage_(
for (t_string2string_map::iterator i(entries.begin());
i != entries.end(); ++i)
{
+ //If the xcu file was installed before the configmgr was chaned
+ //to use the configmgr.ini, one needed to rebuild to whole directory
+ //structur containing the xcu, xcs files from all extensions. Now,
+ //we just add all other xcu/xcs files to the configmgr.ini instead of
+ //rebuilding the directory structure.
rtl::OUString url2(
rtl::OStringToOUString(i->first, RTL_TEXTENCODING_UTF8));
+ ConfigurationBackendDb::Data data;
if (url2 != url) {
- bool schema = i->second.equalsIgnoreAsciiCase(
- "vnd.sun.star.configuration-schema");
- if (!schema) {
- url2 = replaceOrigin(url2, xCmdEnv);
- }
- that->addToConfigmgrIni(schema, url2, xCmdEnv);
+ bool schema = i->second.equalsIgnoreAsciiCase(
+ "vnd.sun.star.configuration-schema");
+ OUString url_replaced(url2);
+ if (!schema)
+ {
+ const OUString sModFolder = that->createFolder(OUString(), xCmdEnv);
+ bool out_replaced = false;
+ url_replaced = replaceOrigin(
+ url2, sModFolder, xCmdEnv, out_replaced);
+ if (out_replaced)
+ data.dataUrl = sModFolder;
+ else
+ deleteTempFolder(sModFolder);
+ }
+ that->addToConfigmgrIni(schema, url_replaced, xCmdEnv);
+ that->addDataToDb(url2, data);
}
that->m_registeredPackages->erase(i->first);
}
@@ -684,6 +762,7 @@ void BackendImpl::PackageImpl::processPackage_(
xCmdEnv ).executeCommand(
OUSTR("delete"), Any( true /* delete physically */ ) );
}
+ that->deleteDataFromDb(getURL());
//TODO: revoking at runtime, possible, sensible?
}
diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx
new file mode 100644
index 000000000000..845ba88cb813
--- /dev/null
+++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * 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: dp_package.cxx,v $
+ * $Revision: 1.34.16.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 "rtl/string.h"
+#include "rtl/bootstrap.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
+#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
+#include "dp_misc.h"
+
+#include "dp_configurationbackenddb.hxx"
+
+
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/configuration-registry/2010"
+#define NS_PREFIX "conf"
+#define ROOT_ELEMENT_NAME "configuration-backend-db"
+#define KEY_ELEMENT_NAME "configuration"
+
+namespace dp_registry {
+namespace backend {
+namespace configuration {
+
+ConfigurationBackendDb::ConfigurationBackendDb(
+ Reference<XComponentContext> const & xContext,
+ ::rtl::OUString const & url):BackendDb(xContext, url)
+{
+
+}
+
+OUString ConfigurationBackendDb::getDbNSName()
+{
+ return OUSTR(EXTENSION_REG_NS);
+}
+
+OUString ConfigurationBackendDb::getNSPrefix()
+{
+ return OUSTR(NS_PREFIX);
+}
+
+OUString ConfigurationBackendDb::getRootElementName()
+{
+ return OUSTR(ROOT_ELEMENT_NAME);
+}
+
+OUString ConfigurationBackendDb::getKeyElementName()
+{
+ return OUSTR(KEY_ELEMENT_NAME);
+}
+
+
+void ConfigurationBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
+{
+ try{
+ Reference<css::xml::dom::XNode> helpNode
+ = writeKeyElement(url);
+
+ writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode);
+ writeSimpleElement(OUSTR("ini-entry"), data.iniEntry, helpNode);
+ save();
+ }
+ catch (css::deployment::DeploymentException& )
+ {
+ throw;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry in configuration backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+
+::boost::optional<ConfigurationBackendDb::Data>
+ConfigurationBackendDb::getEntry(::rtl::OUString const & url)
+{
+ try
+ {
+ ConfigurationBackendDb::Data retData;
+ Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
+ if (aNode.is())
+ {
+ retData.dataUrl = readSimpleElement(OUSTR("data-url"), aNode);
+ retData.iniEntry = readSimpleElement(OUSTR("ini-entry"), aNode);
+ }
+ else
+ {
+ return ::boost::optional<Data>();
+ }
+ return ::boost::optional<Data>(retData);
+ }
+ catch (css::deployment::DeploymentException& )
+ {
+ throw;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in configuration backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+::std::list<OUString> ConfigurationBackendDb::getAllDataUrls()
+{
+ try
+ {
+ ::std::list<OUString> listRet;
+ Reference<css::xml::dom::XDocument> doc = getDocument();
+ Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+
+ Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ const OUString sPrefix = getNSPrefix();
+ OUString sExpression(
+ sPrefix + OUSTR(":configuration/") + sPrefix + OUSTR(":data-url/text()"));
+ Reference<css::xml::dom::XNodeList> nodes =
+ xpathApi->selectNodeList(root, sExpression);
+ if (nodes.is())
+ {
+ sal_Int32 length = nodes->getLength();
+ for (sal_Int32 i = 0; i < length; i++)
+ listRet.push_back(nodes->item(i)->getNodeValue());
+ }
+ return listRet;
+ }
+ catch (css::deployment::DeploymentException& )
+ {
+ throw;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in configuration backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+::std::list<OUString> ConfigurationBackendDb::getAllIniEntries()
+{
+ return getOneChildFromAllEntries(OUSTR("ini-entry"));
+}
+
+
+
+} // namespace configuration
+} // namespace backend
+} // namespace dp_registry
+
diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx
new file mode 100644
index 000000000000..1b6c4f8973a4
--- /dev/null
+++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * 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: dp_backend.h,v $
+ * $Revision: 1.18 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_CONFIGURATIONBACKENDDB_HXX
+#define INCLUDED_DP_CONFIGURATIONBACKENDDB_HXX
+
+#include "rtl/ustring.hxx"
+#include "rtl/string.hxx"
+#include <list>
+#include "boost/optional.hpp"
+#include "dp_backenddb.hxx"
+
+namespace css = ::com::sun::star;
+
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class XComponentContext;
+ }
+}}}
+
+namespace dp_registry {
+namespace backend {
+namespace configuration {
+
+/* The XML file stores the extensions which are currently registered.
+ They will be removed when they are revoked.
+ */
+class ConfigurationBackendDb: public dp_registry::backend::BackendDb
+{
+protected:
+ virtual ::rtl::OUString getDbNSName();
+
+ virtual ::rtl::OUString getNSPrefix();
+
+ virtual ::rtl::OUString getRootElementName();
+
+ virtual ::rtl::OUString getKeyElementName();
+
+public:
+ struct Data
+ {
+ /* the URL to the folder containing the xcu or xcs files which contained
+ %origin%
+ */
+ ::rtl::OUString dataUrl;
+ /* the URL of the xcu or xcs file which is written in to the configmgr.ini
+ */
+ ::rtl::OUString iniEntry;
+ };
+
+public:
+
+ ConfigurationBackendDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url);
+
+ void addEntry(::rtl::OUString const & url, Data const & data);
+
+ ::boost::optional<Data> getEntry(::rtl::OUString const & url);
+ ::std::list< ::rtl::OUString> getAllDataUrls();
+ ::std::list< ::rtl::OUString> getAllIniEntries();
+};
+
+
+
+}
+}
+}
+#endif
+
diff --git a/desktop/source/deployment/registry/configuration/makefile.mk b/desktop/source/deployment/registry/configuration/makefile.mk
index f549b0e7b0f8..9bcbd50d4230 100644
--- a/desktop/source/deployment/registry/configuration/makefile.mk
+++ b/desktop/source/deployment/registry/configuration/makefile.mk
@@ -44,7 +44,8 @@ SRC1FILES = \
dp_configuration.src
SLOFILES = \
- $(SLO)$/dp_configuration.obj
+ $(SLO)$/dp_configuration.obj \
+ $(SLO)$/dp_configurationbackenddb.obj
.INCLUDE : ..$/..$/target.pmk
.INCLUDE : target.mk
diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx
index c06b30be1669..d781ba9e40ef 100644
--- a/desktop/source/deployment/registry/dp_backend.cxx
+++ b/desktop/source/deployment/registry/dp_backend.cxx
@@ -31,12 +31,19 @@
#include "dp_backend.h"
#include "dp_ucb.h"
#include "rtl/uri.hxx"
+#include "rtl/bootstrap.hxx"
+#include "osl/file.hxx"
#include "cppuhelper/exc_hlp.hxx"
#include "comphelper/servicedecl.hxx"
#include "comphelper/unwrapargs.hxx"
#include "ucbhelper/content.hxx"
#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
+#include "com/sun/star/deployment/InvalidRemovedParameterException.hpp"
+#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
+#include "com/sun/star/ucb/IOErrorCode.hpp"
#include "com/sun/star/beans/StringPair.hpp"
+#include "com/sun/star/sdbc/XResultSet.hpp"
+#include "com/sun/star/sdbc/XRow.hpp"
using namespace ::dp_misc;
@@ -88,6 +95,10 @@ PackageRegistryBackend::PackageRegistryBackend(
m_eContext = CONTEXT_USER;
else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") ))
m_eContext = CONTEXT_SHARED;
+ else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") ))
+ m_eContext = CONTEXT_BUNDLED;
+ else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") ))
+ m_eContext = CONTEXT_TMP;
else if (m_context.matchIgnoreAsciiCaseAsciiL(
RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:/") ))
m_eContext = CONTEXT_DOCUMENT;
@@ -127,24 +138,41 @@ void PackageRegistryBackend::disposing()
// XPackageRegistry
//______________________________________________________________________________
Reference<deployment::XPackage> PackageRegistryBackend::bindPackage(
- OUString const & url, OUString const & mediaType,
- Reference<XCommandEnvironment> const & xCmdEnv )
- throw (deployment::DeploymentException, CommandFailedException,
+ OUString const & url, OUString const & mediaType, sal_Bool bRemoved,
+ OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv )
+ throw (deployment::DeploymentException,
+ deployment::InvalidRemovedParameterException,
+ ucb::CommandFailedException,
lang::IllegalArgumentException, RuntimeException)
{
::osl::ResettableMutexGuard guard( getMutex() );
check();
+
t_string2ref::const_iterator const iFind( m_bound.find( url ) );
- if (iFind != m_bound.end()) {
+ if (iFind != m_bound.end())
+ {
Reference<deployment::XPackage> xPackage( iFind->second );
if (xPackage.is())
+ {
+ if (mediaType.getLength() &&
+ mediaType != xPackage->getPackageType()->getMediaType())
+ throw lang::IllegalArgumentException
+ (OUSTR("XPackageRegistry::bindPackage: media type does not match"),
+ static_cast<OWeakObject*>(this), 1);
+ if (xPackage->isRemoved() != bRemoved)
+ throw deployment::InvalidRemovedParameterException(
+ OUSTR("XPackageRegistry::bindPackage: bRemoved parameter does not match"),
+ static_cast<OWeakObject*>(this), xPackage->isRemoved(), xPackage);
return xPackage;
+ }
}
+
guard.clear();
Reference<deployment::XPackage> xNewPackage;
try {
- xNewPackage = bindPackage_( url, mediaType, xCmdEnv );
+ xNewPackage = bindPackage_( url, mediaType, bRemoved,
+ identifier, xCmdEnv );
}
catch (RuntimeException &) {
throw;
@@ -166,6 +194,7 @@ Reference<deployment::XPackage> PackageRegistryBackend::bindPackage(
}
guard.reset();
+
::std::pair< t_string2ref::iterator, bool > insertion(
m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) );
if (insertion.second)
@@ -180,11 +209,105 @@ Reference<deployment::XPackage> PackageRegistryBackend::bindPackage(
return xPackage;
insertion.first->second = xNewPackage;
}
+
guard.clear();
xNewPackage->addEventListener( this ); // listen for disposing events
return xNewPackage;
}
+OUString PackageRegistryBackend::createFolder(
+ OUString const & relUrl,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+{
+ OUString sDataFolder = makeURL(getCachePath(), relUrl);
+ //make sure the folder exist
+ ucbhelper::Content dataContent;
+ ::dp_misc::create_folder(&dataContent, sDataFolder, xCmdEnv);
+
+ OUString sDataFolderURL = dp_misc::expandUnoRcUrl(sDataFolder);
+
+ OUString tempEntry;
+ if (::osl::File::createTempFile(
+ &sDataFolderURL, 0, &tempEntry ) != ::osl::File::E_None)
+ throw RuntimeException(
+ OUSTR("::osl::File::createTempFile() failed!"), 0 );
+ tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 );
+ OUString destFolder= makeURL(sDataFolder, tempEntry) + OUSTR("_");
+ ::ucbhelper::Content destFolderContent;
+ dp_misc::create_folder( &destFolderContent, destFolder, xCmdEnv );
+
+ return destFolder;
+}
+
+void PackageRegistryBackend::deleteTempFolder(
+ OUString const & folderUrl)
+{
+ OSL_ASSERT(folderUrl.getLength()
+ && folderUrl[folderUrl.getLength() - 1] == '_');
+ if (folderUrl.getLength()
+ && folderUrl[folderUrl.getLength() - 1] == '_')
+ {
+ const OUString tempFile = folderUrl.copy(0, folderUrl.getLength() - 1);
+ erase_path( folderUrl, Reference<XCommandEnvironment>(),
+ false /* no throw: ignore errors */ );
+ erase_path( tempFile, Reference<XCommandEnvironment>(),
+ false /* no throw: ignore errors */ );
+ }
+}
+
+void PackageRegistryBackend::deleteUnusedFolders(
+ OUString const & relUrl,
+ ::std::list< OUString> const & usedFolders)
+{
+ try
+ {
+ const OUString sDataFolder = makeURL(getCachePath(), relUrl);
+ ::ucbhelper::Content tempFolder(
+ sDataFolder, Reference<ucb::XCommandEnvironment>());
+ Reference<sdbc::XResultSet> xResultSet(
+ tempFolder.createCursor(
+ Sequence<OUString>( &StrTitle::get(), 1 ),
+ ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
+ // get all temp directories:
+ ::std::vector<OUString> tempEntries;
+
+ char tmp[] = ".tmp";
+
+ while (xResultSet->next())
+ {
+ OUString title(
+ Reference<sdbc::XRow>(
+ xResultSet, UNO_QUERY_THROW )->getString(
+ 1 /* Title */ ) );
+
+ if (title.endsWithAsciiL(tmp, sizeof(tmp) - 1))
+ tempEntries.push_back(
+ makeURLAppendSysPathSegment(sDataFolder, title));
+ }
+
+ for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos )
+ {
+ //usedFolders contains the urls to the folders which have
+ //a trailing underscore
+ const OUString tempFolderName = tempEntries[ pos ] + OUSTR("_");
+
+ if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolderName ) ==
+ usedFolders.end())
+ {
+ deleteTempFolder(tempFolderName);
+ }
+ }
+ }
+ catch (ucb::InteractiveAugmentedIOException& e)
+ {
+ //In case the folder containing all the data folder does not
+ //exist yet, we ignore the exception
+ if (e.Code != ucb::IOErrorCode_NOT_EXISTING)
+ throw e;
+ }
+
+}
+
//##############################################################################
//______________________________________________________________________________
@@ -195,16 +318,30 @@ Package::~Package()
//______________________________________________________________________________
Package::Package( ::rtl::Reference<PackageRegistryBackend> const & myBackend,
OUString const & url,
- OUString const & name,
+ OUString const & rName,
OUString const & displayName,
- Reference<deployment::XPackageTypeInfo> const & xPackageType )
+ Reference<deployment::XPackageTypeInfo> const & xPackageType,
+ bool bRemoved,
+ OUString const & identifier)
: t_PackageBase( getMutex() ),
m_myBackend( myBackend ),
m_url( url ),
- m_name( name ),
+ m_name( rName ),
m_displayName( displayName ),
- m_xPackageType( xPackageType )
+ m_xPackageType( xPackageType ),
+ m_bRemoved(bRemoved),
+ m_identifier(identifier)
{
+ if (m_bRemoved)
+ {
+ //We use the last segment of the URL
+ OSL_ASSERT(m_name.getLength() == 0);
+ OUString name = m_url;
+ rtl::Bootstrap::expandMacros(name);
+ sal_Int32 index = name.lastIndexOf('/');
+ if (index != -1 && index < name.getLength())
+ m_name = name.copy(index + 1);
+ }
}
//______________________________________________________________________________
@@ -294,25 +431,31 @@ sal_Bool Package::isBundle() throw (RuntimeException)
}
//______________________________________________________________________________
-::sal_Bool Package::checkPrerequisites(
+::sal_Int32 Package::checkPrerequisites(
const css::uno::Reference< css::task::XAbortChannel >&,
const css::uno::Reference< css::ucb::XCommandEnvironment >&,
- sal_Bool, ::rtl::OUString const &)
+ sal_Bool)
throw (css::deployment::DeploymentException,
- css::ucb::CommandFailedException,
- css::ucb::CommandAbortedException,
- css::uno::RuntimeException)
+ css::deployment::ExtensionRemovedException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::uno::RuntimeException)
{
- return true;
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+ return 0;
}
//______________________________________________________________________________
::sal_Bool Package::checkDependencies(
const css::uno::Reference< css::ucb::XCommandEnvironment >& )
throw (css::deployment::DeploymentException,
- css::ucb::CommandFailedException,
- css::uno::RuntimeException)
+ css::deployment::ExtensionRemovedException,
+ css::ucb::CommandFailedException,
+ css::uno::RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
return true;
}
@@ -336,12 +479,19 @@ OUString Package::getName() throw (RuntimeException)
beans::Optional<OUString> Package::getIdentifier() throw (RuntimeException)
{
+ if (m_bRemoved)
+ return beans::Optional<OUString>(true, m_identifier);
+
return beans::Optional<OUString>();
}
//______________________________________________________________________________
-OUString Package::getVersion() throw (RuntimeException)
+OUString Package::getVersion() throw (
+ deployment::ExtensionRemovedException,
+ RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
return OUString();
}
@@ -352,33 +502,49 @@ OUString Package::getURL() throw (RuntimeException)
}
//______________________________________________________________________________
-OUString Package::getDisplayName() throw (RuntimeException)
+OUString Package::getDisplayName() throw (
+ deployment::ExtensionRemovedException, RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
return m_displayName;
}
//______________________________________________________________________________
-OUString Package::getDescription() throw (RuntimeException)
+OUString Package::getDescription() throw (
+ deployment::ExtensionRemovedException,RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
return OUString();
}
//______________________________________________________________________________
-Sequence<OUString> Package::getUpdateInformationURLs() throw (RuntimeException)
+Sequence<OUString> Package::getUpdateInformationURLs() throw (
+ deployment::ExtensionRemovedException, RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
return Sequence<OUString>();
}
//______________________________________________________________________________
-css::beans::StringPair Package::getPublisherInfo() throw (RuntimeException)
+css::beans::StringPair Package::getPublisherInfo() throw (
+ deployment::ExtensionRemovedException, RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
css::beans::StringPair aEmptyPair;
return aEmptyPair;
}
//______________________________________________________________________________
-uno::Reference< css::graphic::XGraphic > Package::getIcon( sal_Bool /*bHighContrast*/ ) throw ( RuntimeException )
+uno::Reference< css::graphic::XGraphic > Package::getIcon( sal_Bool /*bHighContrast*/ )
+ throw (deployment::ExtensionRemovedException, RuntimeException )
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+
uno::Reference< css::graphic::XGraphic > aEmpty;
return aEmpty;
}
@@ -394,8 +560,12 @@ Reference<deployment::XPackageTypeInfo> Package::getPackageType()
void Package::exportTo(
OUString const & destFolderURL, OUString const & newTitle,
sal_Int32 nameClashAction, Reference<XCommandEnvironment> const & xCmdEnv )
- throw (CommandFailedException, CommandAbortedException, RuntimeException)
+ throw (deployment::ExtensionRemovedException,
+ CommandFailedException, CommandAbortedException, RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+
::ucbhelper::Content destFolder( destFolderURL, xCmdEnv );
::ucbhelper::Content sourceContent( getURL(), xCmdEnv );
if (! destFolder.transferContent(
@@ -461,6 +631,7 @@ beans::Optional< beans::Ambiguous<sal_Bool> > Package::isRegistered(
//______________________________________________________________________________
void Package::processPackage_impl(
bool doRegisterPackage,
+ bool startup,
Reference<task::XAbortChannel> const & xAbortChannel,
Reference<XCommandEnvironment> const & xCmdEnv )
{
@@ -478,7 +649,8 @@ void Package::processPackage_impl(
(doRegisterPackage ? !option.Value.Value
: option.Value.Value)));
if (action) {
- OUString displayName( getDisplayName() );
+
+ OUString displayName = isRemoved() ? getName() : getDisplayName();
ProgressLevel progress(
xCmdEnv,
(doRegisterPackage
@@ -487,6 +659,7 @@ void Package::processPackage_impl(
+ displayName );
processPackage_( guard,
doRegisterPackage,
+ startup,
AbortChannel::get(xAbortChannel),
xCmdEnv );
}
@@ -524,13 +697,17 @@ void Package::processPackage_impl(
//______________________________________________________________________________
void Package::registerPackage(
+ sal_Bool startup,
Reference<task::XAbortChannel> const & xAbortChannel,
Reference<XCommandEnvironment> const & xCmdEnv )
throw (deployment::DeploymentException,
+ deployment::ExtensionRemovedException,
CommandFailedException, CommandAbortedException,
lang::IllegalArgumentException, RuntimeException)
{
- processPackage_impl( true /* register */, xAbortChannel, xCmdEnv );
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+ processPackage_impl( true /* register */, startup, xAbortChannel, xCmdEnv );
}
//______________________________________________________________________________
@@ -541,7 +718,44 @@ void Package::revokePackage(
CommandFailedException, CommandAbortedException,
lang::IllegalArgumentException, RuntimeException)
{
- processPackage_impl( false /* revoke */, xAbortChannel, xCmdEnv );
+ processPackage_impl( false /* revoke */, false, xAbortChannel, xCmdEnv );
+
+}
+
+PackageRegistryBackend * Package::getMyBackend() const
+{
+ PackageRegistryBackend * pBackend = m_myBackend.get();
+ if (NULL == pBackend)
+ {
+ //May throw a DisposedException
+ check();
+ //We should never get here...
+ throw RuntimeException(
+ OUSTR("Failed to get the BackendImpl"),
+ static_cast<OWeakObject*>(const_cast<Package *>(this)));
+ }
+ return pBackend;
+}
+OUString Package::getRepositoryName()
+ throw (RuntimeException)
+{
+ PackageRegistryBackend * backEnd = getMyBackend();
+ return backEnd->getContext();
+}
+
+beans::Optional< OUString > Package::getRegistrationDataURL()
+ throw (deployment::ExtensionRemovedException,
+ css::uno::RuntimeException)
+{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+ return beans::Optional<OUString>();
+}
+
+sal_Bool Package::isRemoved()
+ throw (RuntimeException)
+{
+ return m_bRemoved;
}
//##############################################################################
@@ -559,13 +773,15 @@ OUString Package::TypeInfo::getMediaType() throw (RuntimeException)
}
//______________________________________________________________________________
-OUString Package::TypeInfo::getDescription() throw (RuntimeException)
+OUString Package::TypeInfo::getDescription()
+ throw (deployment::ExtensionRemovedException, RuntimeException)
{
return getShortDescription();
}
//______________________________________________________________________________
-OUString Package::TypeInfo::getShortDescription() throw (RuntimeException)
+OUString Package::TypeInfo::getShortDescription()
+ throw (deployment::ExtensionRemovedException, RuntimeException)
{
return m_shortDescr;
}
diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx
new file mode 100644
index 000000000000..14b4f2374c5b
--- /dev/null
+++ b/desktop/source/deployment/registry/dp_backenddb.cxx
@@ -0,0 +1,649 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "rtl/string.h"
+#include "rtl/strbuf.hxx"
+#include "rtl/bootstrap.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "osl/file.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
+#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
+#include "com/sun/star/io/XActiveDataSource.hpp"
+#include "com/sun/star/io/XActiveDataControl.hpp"
+#include "dp_ucb.h"
+#include "dp_misc.h"
+#include "ucbhelper/content.hxx"
+#include "xmlscript/xml_helper.hxx"
+#include "dp_backenddb.hxx"
+
+
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+
+namespace dp_registry {
+namespace backend {
+
+BackendDb::BackendDb(
+ Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url):
+ m_xContext(xContext)
+{
+ m_urlDb = dp_misc::expandUnoRcUrl(url);
+}
+
+void BackendDb::save()
+{
+ const Reference<css::io::XActiveDataSource> xDataSource(m_doc,css::uno::UNO_QUERY_THROW);
+ ::rtl::ByteSequence bytes;
+ xDataSource->setOutputStream(::xmlscript::createOutputStream(&bytes));
+ const Reference<css::io::XActiveDataControl> xDataControl(m_doc,css::uno::UNO_QUERY_THROW);
+ xDataControl->start();
+
+ const Reference<css::io::XInputStream> xData(
+ ::xmlscript::createInputStream(bytes));
+ ::ucbhelper::Content ucbDb(m_urlDb, 0);
+ ucbDb.writeStream(xData, true /*replace existing*/);
+}
+
+css::uno::Reference<css::xml::dom::XDocument> BackendDb::getDocument()
+{
+ if (!m_doc.is())
+ {
+ const Reference<css::xml::dom::XDocumentBuilder> xDocBuilder(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ OUSTR("com.sun.star.xml.dom.DocumentBuilder"),
+ m_xContext ), css::uno::UNO_QUERY);
+ if (!xDocBuilder.is())
+ throw css::uno::RuntimeException(
+ OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0);
+
+ ::osl::DirectoryItem item;
+ ::osl::File::RC err = ::osl::DirectoryItem::get(m_urlDb, item);
+ if (err == ::osl::File::E_None)
+ {
+ m_doc = xDocBuilder->parseURI(m_urlDb);
+ }
+ else if (err == ::osl::File::E_NOENT)
+ {
+ //Create a new document and insert some basic stuff
+ m_doc = xDocBuilder->newDocument();
+ const Reference<css::xml::dom::XElement> rootNode =
+ m_doc->createElementNS(getDbNSName(), getNSPrefix() +
+ OUSTR(":") + getRootElementName());
+
+ m_doc->appendChild(Reference<css::xml::dom::XNode>(
+ rootNode, UNO_QUERY_THROW));
+ save();
+ }
+ else
+ throw css::uno::RuntimeException(
+ OUSTR("Extension manager could not access database file:" )
+ + m_urlDb, 0);
+
+ if (!m_doc.is())
+ throw css::uno::RuntimeException(
+ OUSTR("Extension manager could not get root node of data base file: ")
+ + m_urlDb, 0);
+ }
+
+ return m_doc;
+}
+
+Reference<css::xml::xpath::XXPathAPI> BackendDb::getXPathAPI()
+{
+ if (!m_xpathApi.is())
+ {
+ m_xpathApi = Reference< css::xml::xpath::XXPathAPI >(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ OUSTR("com.sun.star.xml.xpath.XPathAPI"),
+ m_xContext), css::uno::UNO_QUERY);
+
+ if (!m_xpathApi.is())
+ throw css::uno::RuntimeException(
+ OUSTR(" Could not create service com.sun.star.xml.xpath.XPathAPI"), 0);
+
+ m_xpathApi->registerNS(
+ getNSPrefix(), getDbNSName());
+ }
+
+ return m_xpathApi;
+}
+
+void BackendDb::removeElement(::rtl::OUString const & sXPathExpression)
+{
+ try
+ {
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+ const Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+ const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ //find the extension element that is to be removed
+ const Reference<css::xml::dom::XNode> aNode =
+ xpathApi->selectSingleNode(root, sXPathExpression);
+
+ if (aNode.is())
+ {
+ root->removeChild(aNode);
+ save();
+ }
+
+#if OSL_DEBUG_LEVEL > 0
+ //There must not be any other entry with the same url
+ const Reference<css::xml::dom::XNode> nextNode =
+ xpathApi->selectSingleNode(root, sXPathExpression);
+ OSL_ASSERT(! nextNode.is());
+#endif
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+void BackendDb::removeEntry(::rtl::OUString const & url)
+{
+ const OUString sKeyElement = getKeyElementName();
+ const OUString sPrefix = getNSPrefix();
+ ::rtl::OUStringBuffer sExpression(500);
+ sExpression.append(sPrefix);
+ sExpression.appendAscii(":");
+ sExpression.append(sKeyElement);
+ sExpression.append(OUSTR("[@url = \""));
+ sExpression.append(url);
+ sExpression.appendAscii("\"]");
+
+ removeElement(sExpression.makeStringAndClear());
+}
+
+Reference<css::xml::dom::XNode> BackendDb::getKeyElement(
+ ::rtl::OUString const & url)
+{
+ try
+ {
+ const OUString sPrefix = getNSPrefix();
+ const OUString sKeyElement = getKeyElementName();
+ ::rtl::OUStringBuffer sExpression(500);
+ sExpression.append(sPrefix);
+ sExpression.appendAscii(":");
+ sExpression.append(sKeyElement);
+ sExpression.append(OUSTR("[@url = \""));
+ sExpression.append(url);
+ sExpression.appendAscii("\"]");
+
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+ const Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+ const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ return xpathApi->selectSingleNode(root, sExpression.makeStringAndClear());
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read key element in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+//Only writes the data if there is at least one entry
+void BackendDb::writeVectorOfPair(
+ ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > const & vecPairs,
+ OUString const & sVectorTagName,
+ OUString const & sPairTagName,
+ OUString const & sFirstTagName,
+ OUString const & sSecondTagName,
+ css::uno::Reference<css::xml::dom::XNode> const & xParent)
+{
+ try{
+ if (vecPairs.size() == 0)
+ return;
+ const OUString sNameSpace = getDbNSName();
+ OSL_ASSERT(sNameSpace.getLength());
+ const OUString sPrefix(getNSPrefix() + OUSTR(":"));
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+ const Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+
+ const Reference<css::xml::dom::XElement> vectorNode(
+ doc->createElementNS(sNameSpace, sPrefix + sVectorTagName));
+
+ xParent->appendChild(
+ Reference<css::xml::dom::XNode>(
+ vectorNode, css::uno::UNO_QUERY_THROW));
+ typedef ::std::vector< ::std::pair< OUString, OUString > >::const_iterator CIT;
+ for (CIT i = vecPairs.begin(); i != vecPairs.end(); i++)
+ {
+ const Reference<css::xml::dom::XElement> pairNode(
+ doc->createElementNS(sNameSpace, sPrefix + sPairTagName));
+
+ vectorNode->appendChild(
+ Reference<css::xml::dom::XNode>(
+ pairNode, css::uno::UNO_QUERY_THROW));
+
+ const Reference<css::xml::dom::XElement> firstNode(
+ doc->createElementNS(sNameSpace, sPrefix + sFirstTagName));
+
+ pairNode->appendChild(
+ Reference<css::xml::dom::XNode>(
+ firstNode, css::uno::UNO_QUERY_THROW));
+
+ const Reference<css::xml::dom::XText> firstTextNode(
+ doc->createTextNode( i->first));
+
+ firstNode->appendChild(
+ Reference<css::xml::dom::XNode>(
+ firstTextNode, css::uno::UNO_QUERY_THROW));
+
+ const Reference<css::xml::dom::XElement> secondNode(
+ doc->createElementNS(sNameSpace, sPrefix + sSecondTagName));
+
+ pairNode->appendChild(
+ Reference<css::xml::dom::XNode>(
+ secondNode, css::uno::UNO_QUERY_THROW));
+
+ const Reference<css::xml::dom::XText> secondTextNode(
+ doc->createTextNode( i->second));
+
+ secondNode->appendChild(
+ Reference<css::xml::dom::XNode>(
+ secondTextNode, css::uno::UNO_QUERY_THROW));
+ }
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+::std::vector< ::std::pair< OUString, OUString > >
+BackendDb::readVectorOfPair(
+ Reference<css::xml::dom::XNode> const & parent,
+ OUString const & sListTagName,
+ OUString const & sPairTagName,
+ OUString const & sFirstTagName,
+ OUString const & sSecondTagName)
+{
+ try
+ {
+ OSL_ASSERT(parent.is());
+ const OUString sPrefix(getNSPrefix() + OUSTR(":"));
+ const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ const OUString sExprPairs(
+ sPrefix + sListTagName + OUSTR("/") + sPrefix + sPairTagName);
+ const Reference<css::xml::dom::XNodeList> listPairs =
+ xpathApi->selectNodeList(parent, sExprPairs);
+
+ ::std::vector< ::std::pair< OUString, OUString > > retVector;
+ sal_Int32 length = listPairs->getLength();
+ for (sal_Int32 i = 0; i < length; i++)
+ {
+ const Reference<css::xml::dom::XNode> aPair = listPairs->item(i);
+ const OUString sExprFirst(sPrefix + sFirstTagName + OUSTR("/text()"));
+ const Reference<css::xml::dom::XNode> first =
+ xpathApi->selectSingleNode(aPair, sExprFirst);
+
+ const OUString sExprSecond(sPrefix + sSecondTagName + OUSTR("/text()"));
+ const Reference<css::xml::dom::XNode> second =
+ xpathApi->selectSingleNode(aPair, sExprSecond);
+ OSL_ASSERT(first.is() && second.is());
+
+ retVector.push_back(::std::make_pair(
+ first->getNodeValue(), second->getNodeValue()));
+ }
+ return retVector;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+//Only writes the data if there is at least one entry
+void BackendDb::writeSimpleList(
+ ::std::list< ::rtl::OUString> const & list,
+ OUString const & sListTagName,
+ OUString const & sMemberTagName,
+ Reference<css::xml::dom::XNode> const & xParent)
+{
+ try
+ {
+ if (list.size() == 0)
+ return;
+ const OUString sNameSpace = getDbNSName();
+ const OUString sPrefix(getNSPrefix() + OUSTR(":"));
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+
+ const Reference<css::xml::dom::XElement> listNode(
+ doc->createElementNS(sNameSpace, sPrefix + sListTagName));
+
+ xParent->appendChild(
+ Reference<css::xml::dom::XNode>(
+ listNode, css::uno::UNO_QUERY_THROW));
+
+ typedef ::std::list<OUString>::const_iterator ITC_ITEMS;
+ for (ITC_ITEMS i = list.begin(); i != list.end(); i++)
+ {
+ const Reference<css::xml::dom::XNode> memberNode(
+ doc->createElementNS(sNameSpace, sPrefix + sMemberTagName), css::uno::UNO_QUERY_THROW);
+
+ listNode->appendChild(memberNode);
+
+ const Reference<css::xml::dom::XNode> textNode(
+ doc->createTextNode( *i), css::uno::UNO_QUERY_THROW);
+
+ memberNode->appendChild(textNode);
+ }
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+//Writes only the element if is has a value.
+//The prefix is automatically added to the element name
+void BackendDb::writeSimpleElement(
+ OUString const & sElementName, OUString const & value,
+ Reference<css::xml::dom::XNode> const & xParent)
+{
+ try
+ {
+ if (value.getLength() == 0)
+ return;
+ const OUString sPrefix = getNSPrefix();
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+ const OUString sNameSpace = getDbNSName();
+ const Reference<css::xml::dom::XNode> dataNode(
+ doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sElementName),
+ UNO_QUERY_THROW);
+ xParent->appendChild(dataNode);
+
+ const Reference<css::xml::dom::XNode> dataValue(
+ doc->createTextNode(value), UNO_QUERY_THROW);
+ dataNode->appendChild(dataValue);
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry(writeSimpleElement) in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+
+}
+
+/** The key elements have an url attribute and are always children of the root
+ element.
+*/
+Reference<css::xml::dom::XNode> BackendDb::writeKeyElement(
+ ::rtl::OUString const & url)
+{
+ try
+ {
+ const OUString sNameSpace = getDbNSName();
+ const OUString sPrefix = getNSPrefix();
+ const OUString sElementName = getKeyElementName();
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+ const Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+
+ //Check if there are an entry with the same url. This can be the case if the
+ //the status of an XPackage is ambiguous. In this case a call to activateExtension
+ //(dp_extensionmanager.cxx), will register the package again. See also
+ //Package::processPackage_impl in dp_backend.cxx.
+ //A package can become
+ //invalid after its successful registration, for example if a second extension with
+ //the same service is installed.
+ const OUString sExpression(
+ sPrefix + OUSTR(":") + sElementName + OUSTR("[@url = \"") + url + OUSTR("\"]"));
+ const Reference<css::xml::dom::XNode> existingNode =
+ getXPathAPI()->selectSingleNode(root, sExpression);
+ if (existingNode.is())
+ {
+ OSL_ASSERT(0);
+ //replace the existing entry.
+ removeEntry(url);
+ }
+
+ const Reference<css::xml::dom::XElement> keyElement(
+ doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sElementName));
+
+ keyElement->setAttribute(OUSTR("url"), url);
+
+ const Reference<css::xml::dom::XNode> keyNode(
+ keyElement, UNO_QUERY_THROW);
+ root->appendChild(keyNode);
+ return keyNode;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write key element in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+OUString BackendDb::readSimpleElement(
+ OUString const & sElementName, Reference<css::xml::dom::XNode> const & xParent)
+{
+ try
+ {
+ const OUString sPrefix = getNSPrefix();
+ const OUString sExpr(sPrefix + OUSTR(":") + sElementName + OUSTR("/text()"));
+ const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ const Reference<css::xml::dom::XNode> val =
+ xpathApi->selectSingleNode(xParent, sExpr);
+ if (val.is())
+ return val->getNodeValue();
+ return OUString();
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data (readSimpleElement) in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+
+::std::list< OUString> BackendDb::readList(
+ Reference<css::xml::dom::XNode> const & parent,
+ OUString const & sListTagName,
+ OUString const & sMemberTagName)
+{
+ try
+ {
+ OSL_ASSERT(parent.is());
+ const OUString sPrefix(getNSPrefix() + OUSTR(":"));
+ const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ const OUString sExprList(
+ sPrefix + sListTagName + OUSTR("/") + sPrefix + sMemberTagName + OUSTR("/text()"));
+ const Reference<css::xml::dom::XNodeList> list =
+ xpathApi->selectNodeList(parent, sExprList);
+
+ ::std::list<OUString > retList;
+ sal_Int32 length = list->getLength();
+ for (sal_Int32 i = 0; i < length; i++)
+ {
+ const Reference<css::xml::dom::XNode> member = list->item(i);
+ retList.push_back(member->getNodeValue());
+ }
+ return retList;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+::std::list<OUString> BackendDb::getOneChildFromAllEntries(
+ OUString const & name)
+{
+ try
+ {
+ ::std::list<OUString> listRet;
+ Reference<css::xml::dom::XDocument> doc = getDocument();
+ Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+
+ Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ const OUString sPrefix = getNSPrefix();
+ const OUString sKeyElement = getKeyElementName();
+ ::rtl::OUStringBuffer buf(512);
+ buf.append(sPrefix);
+ buf.appendAscii(":");
+ buf.append(sKeyElement);
+ buf.appendAscii("/");
+ buf.append(sPrefix);
+ buf.appendAscii(":");
+ buf.append(name);
+ buf.append(OUSTR("/text()"));
+
+ Reference<css::xml::dom::XNodeList> nodes =
+ xpathApi->selectNodeList(root, buf.makeStringAndClear());
+ if (nodes.is())
+ {
+ sal_Int32 length = nodes->getLength();
+ for (sal_Int32 i = 0; i < length; i++)
+ listRet.push_back(nodes->item(i)->getNodeValue());
+ }
+ return listRet;
+ }
+ catch (css::deployment::DeploymentException& )
+ {
+ throw;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+
+
+//================================================================================
+RegisteredDb::RegisteredDb(
+ Reference<XComponentContext> const & xContext,
+ ::rtl::OUString const & url):BackendDb(xContext, url)
+{
+
+}
+
+void RegisteredDb::addEntry(::rtl::OUString const & url)
+{
+ try{
+
+ const OUString sNameSpace = getDbNSName();
+ const OUString sPrefix = getNSPrefix();
+ const OUString sEntry = getKeyElementName();
+
+ Reference<css::xml::dom::XDocument> doc = getDocument();
+ Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+
+#if OSL_DEBUG_LEVEL > 0
+ //There must not be yet an entry with the same url
+ OUString sExpression(
+ sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]"));
+ Reference<css::xml::dom::XNode> _extensionNode =
+ getXPathAPI()->selectSingleNode(root, sExpression);
+ OSL_ASSERT(! _extensionNode.is());
+#endif
+ Reference<css::xml::dom::XElement> helpElement(
+ doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sEntry));
+
+ helpElement->setAttribute(OUSTR("url"), url);
+
+ Reference<css::xml::dom::XNode> helpNode(
+ helpElement, UNO_QUERY_THROW);
+ root->appendChild(helpNode);
+
+ save();
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+bool RegisteredDb::getEntry(::rtl::OUString const & url)
+{
+ try
+ {
+ const OUString sPrefix = getNSPrefix();
+ const OUString sEntry = getKeyElementName();
+ const OUString sExpression(
+ sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]"));
+ Reference<css::xml::dom::XDocument> doc = getDocument();
+ Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+
+ Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ //find the extension element that is to be removed
+ Reference<css::xml::dom::XNode> aNode =
+ xpathApi->selectSingleNode(root, sExpression);
+ if (!aNode.is())
+ {
+ return false;
+ }
+ return true;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+
+} // namespace backend
+} // namespace dp_registry
+
diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx
index c56131a1015c..c5e440a2a825 100644
--- a/desktop/source/deployment/registry/dp_registry.cxx
+++ b/desktop/source/deployment/registry/dp_registry.cxx
@@ -115,6 +115,7 @@ protected:
virtual ~PackageRegistryImpl();
PackageRegistryImpl() : t_helper( getMutex() ) {}
+
public:
static Reference<deployment::XPackageRegistry> create(
OUString const & context,
@@ -126,8 +127,8 @@ public:
// XPackageRegistry
virtual Reference<deployment::XPackage> SAL_CALL bindPackage(
- OUString const & url, OUString const & mediaType,
- Reference<XCommandEnvironment> const & xCmdEnv )
+ OUString const & url, OUString const & mediaType, sal_Bool bRemoved,
+ OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv )
throw (deployment::DeploymentException, CommandFailedException,
lang::IllegalArgumentException, RuntimeException);
virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL
@@ -361,9 +362,24 @@ Reference<deployment::XPackageRegistry> PackageRegistryImpl::create(
// Always register as last, because we want to add extensions also as folders
// and as a default we accept every folder, which was not recognized by the other
// backends.
- that->insertBackend(
+ Reference<deployment::XPackageRegistry> extensionBackend =
::dp_registry::backend::bundle::create(
- that, context, cachePath, readOnly, xComponentContext ) );
+ that, context, cachePath, readOnly, xComponentContext);
+ that->insertBackend(extensionBackend);
+
+ Reference<lang::XServiceInfo> xServiceInfo(
+ extensionBackend, UNO_QUERY_THROW );
+
+ OSL_ASSERT(xServiceInfo.is());
+ OUString registryCachePath(
+ makeURL( cachePath,
+ ::rtl::Uri::encode(
+ xServiceInfo->getImplementationName(),
+ rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8 ) ) );
+ create_folder( 0, registryCachePath, Reference<XCommandEnvironment>());
+
#if OSL_DEBUG_LEVEL > 1
// dump tables:
@@ -443,8 +459,8 @@ void PackageRegistryImpl::update() throw (RuntimeException)
// XPackageRegistry
//______________________________________________________________________________
Reference<deployment::XPackage> PackageRegistryImpl::bindPackage(
- OUString const & url, OUString const & mediaType_,
- Reference<XCommandEnvironment> const & xCmdEnv )
+ OUString const & url, OUString const & mediaType_, sal_Bool bRemoved,
+ OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv )
throw (deployment::DeploymentException, CommandFailedException,
lang::IllegalArgumentException, RuntimeException)
{
@@ -482,7 +498,8 @@ Reference<deployment::XPackage> PackageRegistryImpl::bindPackage(
for ( ; iPos != iEnd; ++iPos )
{
try {
- return (*iPos)->bindPackage( url, mediaType, xCmdEnv );
+ return (*iPos)->bindPackage( url, mediaType, bRemoved,
+ identifier, xCmdEnv );
}
catch (lang::IllegalArgumentException &) {
}
@@ -511,7 +528,8 @@ Reference<deployment::XPackage> PackageRegistryImpl::bindPackage(
getResourceString(RID_STR_UNSUPPORTED_MEDIA_TYPE) + mediaType,
static_cast<OWeakObject *>(this), static_cast<sal_Int16>(-1) );
}
- return iFind->second->bindPackage( url, mediaType, xCmdEnv );
+ return iFind->second->bindPackage( url, mediaType, bRemoved,
+ identifier, xCmdEnv );
}
}
@@ -521,7 +539,6 @@ PackageRegistryImpl::getSupportedPackageTypes() throw (RuntimeException)
{
return comphelper::containerToSequence(m_typesInfos);
}
-
} // anon namespace
//==============================================================================
diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx
index 8c95d5874b4c..968ee7297b0f 100644
--- a/desktop/source/deployment/registry/executable/dp_executable.cxx
+++ b/desktop/source/deployment/registry/executable/dp_executable.cxx
@@ -28,6 +28,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_desktop.hxx"
+#include "dp_misc.h"
#include "dp_backend.h"
#include "dp_ucb.h"
#include "dp_interact.h"
@@ -37,10 +38,12 @@
#include "comphelper/servicedecl.hxx"
#include "svl/inettype.hxx"
#include "cppuhelper/implbase1.hxx"
+#include "dp_executablebackenddb.hxx"
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::ucb;
+using namespace dp_misc;
using ::rtl::OUString;
namespace dp_registry {
@@ -62,19 +65,20 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
virtual void processPackage_(
::osl::ResettableMutexGuard & guard,
bool registerPackage,
+ bool startup,
::rtl::Reference<dp_misc::AbortChannel> const & abortChannel,
Reference<XCommandEnvironment> const & xCmdEnv );
bool getFileAttributes(sal_uInt64& out_Attributes);
bool isUrlTargetInExtension();
-
public:
inline ExecutablePackageImpl(
::rtl::Reference<PackageRegistryBackend> const & myBackend,
OUString const & url, OUString const & name,
- Reference<deployment::XPackageTypeInfo> const & xPackageType)
+ Reference<deployment::XPackageTypeInfo> const & xPackageType,
+ bool bRemoved, OUString const & identifier)
: Package( myBackend, url, name, name /* display-name */,
- xPackageType ) //,
+ xPackageType, bRemoved, identifier)
{}
};
friend class ExecutablePackageImpl;
@@ -84,11 +88,15 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
// PackageRegistryBackend
virtual Reference<deployment::XPackage> bindPackage_(
- OUString const & url, OUString const & mediaType,
- Reference<XCommandEnvironment> const & xCmdEnv );
+ OUString const & url, OUString const & mediaType, sal_Bool bRemoved,
+ OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv );
- Reference<deployment::XPackageTypeInfo> m_xExecutableTypeInfo;
+ void addDataToDb(OUString const & url);
+ bool isRegisteredInDb(OUString const & url);
+ void deleteDataFromDb(OUString const & url);
+ Reference<deployment::XPackageTypeInfo> m_xExecutableTypeInfo;
+ std::auto_ptr<ExecutableBackendDb> m_backendDb;
public:
BackendImpl( Sequence<Any> const & args,
Reference<XComponentContext> const & xComponentContext );
@@ -112,7 +120,32 @@ BackendImpl::BackendImpl(
RID_IMG_COMPONENT,
RID_IMG_COMPONENT_HC ) )
{
+ if (!transientMode())
+ {
+ OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml"));
+ m_backendDb.reset(
+ new ExecutableBackendDb(getComponentContext(), dbFile));
+ }
+}
+void BackendImpl::addDataToDb(OUString const & url)
+{
+ if (m_backendDb.get())
+ m_backendDb->addEntry(url);
+}
+
+bool BackendImpl::isRegisteredInDb(OUString const & url)
+{
+ bool ret = false;
+ if (m_backendDb.get())
+ ret = m_backendDb->getEntry(url);
+ return ret;
+}
+
+void BackendImpl::deleteDataFromDb(OUString const & url)
+{
+ if (m_backendDb.get())
+ m_backendDb->removeEntry(url);
}
// XPackageRegistry
@@ -125,8 +158,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException)
// PackageRegistryBackend
Reference<deployment::XPackage> BackendImpl::bindPackage_(
- OUString const & url, OUString const & mediaType,
- Reference<XCommandEnvironment> const & xCmdEnv )
+ OUString const & url, OUString const & mediaType, sal_Bool bRemoved,
+ OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv )
{
if (mediaType.getLength() == 0)
{
@@ -141,13 +174,18 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
{
if (type.EqualsIgnoreCaseAscii("application"))
{
- ::ucbhelper::Content ucbContent( url, xCmdEnv );
- const OUString name( ucbContent.getPropertyValue(
- dp_misc::StrTitle::get() ).get<OUString>() );
+ OUString name;
+ if (!bRemoved)
+ {
+ ::ucbhelper::Content ucbContent( url, xCmdEnv );
+ name = ucbContent.getPropertyValue(
+ dp_misc::StrTitle::get() ).get<OUString>();
+ }
if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.executable"))
{
return new BackendImpl::ExecutablePackageImpl(
- this, url, name, m_xExecutableTypeInfo);
+ this, url, name, m_xExecutableTypeInfo, bRemoved,
+ identifier);
}
}
}
@@ -179,23 +217,17 @@ BackendImpl::ExecutablePackageImpl::isRegistered_(
::rtl::Reference<dp_misc::AbortChannel> const &,
Reference<XCommandEnvironment> const & )
{
- //We must return Optional.isPresent = true, otherwise
- //processPackage is not called.
- //The user shall not be able to enable/disable the executable. This is not needed since
- //the executable does not affect the office. The best thing is to show no
- //status at all. See also BackendImpl::PackageImpl::isRegistered_ (dp_package.cxx)
- //On Windows there is no executable file attribute. One has to use security API for this.
- //However, on Windows we do not have the problem, that after unzipping the file cannot be
- //executed.
+ bool registered = getMyBackend()->isRegisteredInDb(getURL());
return beans::Optional< beans::Ambiguous<sal_Bool> >(
sal_True /* IsPresent */,
beans::Ambiguous<sal_Bool>(
- sal_True, sal_True /* IsAmbiguous */ ) );
+ registered, sal_False /* IsAmbiguous */ ) );
}
void BackendImpl::ExecutablePackageImpl::processPackage_(
::osl::ResettableMutexGuard &,
bool doRegisterPackage,
+ bool /*startup*/,
::rtl::Reference<dp_misc::AbortChannel> const & abortChannel,
Reference<XCommandEnvironment> const & /*xCmdEnv*/ )
{
@@ -216,19 +248,27 @@ void BackendImpl::ExecutablePackageImpl::processPackage_(
else if (getMyBackend()->m_context.equals(OUSTR("shared")))
attributes |= (osl_File_Attribute_OwnExe | osl_File_Attribute_GrpExe
| osl_File_Attribute_OthExe);
- else
+ else if (!getMyBackend()->m_context.equals(OUSTR("bundled")))
+ //Bundled extension are required to be in the properly
+ //installed. That is an executable must have the right flags
OSL_ASSERT(0);
//This won't have affect on Windows
- if (osl::File::E_None != osl::File::setAttributes(
- dp_misc::expandUnoRcUrl(m_url), attributes))
- OSL_ENSURE(0, "Extension Manager: Could not set executable file attribute.");
+ osl::File::setAttributes(
+ dp_misc::expandUnoRcUrl(m_url), attributes);
}
+ getMyBackend()->addDataToDb(getURL());
+ }
+ else
+ {
+ getMyBackend()->deleteDataFromDb(getURL());
}
}
-//We currently cannot check if this XPackage represents a content of a particular exension
+//We currently cannot check if this XPackage represents a content of a particular extension
//But we can check if we are within $UNO_USER_PACKAGES_CACHE etc.
+//Done for security reasons. For example an extension manifest could contain a path to
+//an executable outside the extension.
bool BackendImpl::ExecutablePackageImpl::isUrlTargetInExtension()
{
bool bSuccess = false;
@@ -237,6 +277,8 @@ bool BackendImpl::ExecutablePackageImpl::isUrlTargetInExtension()
sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$UNO_USER_PACKAGES_CACHE"));
else if (getMyBackend()->m_context.equals(OUSTR("shared")))
sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$UNO_SHARED_PACKAGES_CACHE"));
+ else if (getMyBackend()->m_context.equals(OUSTR("bundled")))
+ sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$BUNDLED_EXTENSIONS"));
else
OSL_ASSERT(0);
//remove file ellipses
diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx
new file mode 100644
index 000000000000..976a6281a2bd
--- /dev/null
+++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * 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: dp_package.cxx,v $
+ * $Revision: 1.34.16.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 "rtl/string.h"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "dp_misc.h"
+#include "dp_executablebackenddb.hxx"
+
+
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/executable-registry/2010"
+#define NS_PREFIX "exe"
+#define ROOT_ELEMENT_NAME "executable-backend-db"
+#define ENTRY_NAME "executable"
+
+namespace dp_registry {
+namespace backend {
+namespace executable {
+
+ExecutableBackendDb::ExecutableBackendDb(
+ Reference<XComponentContext> const & xContext,
+ ::rtl::OUString const & url):RegisteredDb(xContext, url)
+{
+
+}
+
+OUString ExecutableBackendDb::getDbNSName()
+{
+ return OUSTR(EXTENSION_REG_NS);
+}
+
+OUString ExecutableBackendDb::getNSPrefix()
+{
+ return OUSTR(NS_PREFIX);
+}
+
+OUString ExecutableBackendDb::getRootElementName()
+{
+ return OUSTR(ROOT_ELEMENT_NAME);
+}
+
+OUString ExecutableBackendDb::getKeyElementName()
+{
+ return OUSTR(ENTRY_NAME);
+}
+
+
+} // namespace executable
+} // namespace backend
+} // namespace dp_registry
+
diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx
new file mode 100644
index 000000000000..4f17eeda24a6
--- /dev/null
+++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * 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: dp_backend.h,v $
+ * $Revision: 1.18 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_EXECUTABLEBACKENDDB_HXX
+#define INCLUDED_DP_EXECUTABLEBACKENDDB_HXX
+
+#include "rtl/ustring.hxx"
+#include "dp_backenddb.hxx"
+
+namespace css = ::com::sun::star;
+
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class XComponentContext;
+ }
+}}}
+
+namespace dp_registry {
+namespace backend {
+namespace executable {
+
+/* The XML file stores the extensions which are currently registered.
+ They will be removed when they are revoked.
+ The format looks like this:
+
+<?xml version="1.0"?>
+ */
+class ExecutableBackendDb: public dp_registry::backend::RegisteredDb
+{
+protected:
+ virtual ::rtl::OUString getDbNSName();
+
+ virtual ::rtl::OUString getNSPrefix();
+
+ virtual ::rtl::OUString getRootElementName();
+
+ virtual ::rtl::OUString getKeyElementName();
+
+public:
+
+ ExecutableBackendDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url);
+
+};
+
+
+
+}
+}
+}
+#endif
+
diff --git a/desktop/source/deployment/registry/executable/makefile.mk b/desktop/source/deployment/registry/executable/makefile.mk
index 1e57f5ecf3b1..81b2baa44e5d 100644
--- a/desktop/source/deployment/registry/executable/makefile.mk
+++ b/desktop/source/deployment/registry/executable/makefile.mk
@@ -36,7 +36,8 @@ ENABLE_EXCEPTIONS = TRUE
INCPRE += ..$/..$/inc
SLOFILES = \
- $(SLO)$/dp_executable.obj
+ $(SLO)$/dp_executable.obj \
+ $(SLO)$/dp_executablebackenddb.obj
.INCLUDE : ..$/..$/target.pmk
.INCLUDE : target.mk
diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx
index 2b0d91250e4a..bc17a1f7163d 100644
--- a/desktop/source/deployment/registry/help/dp_help.cxx
+++ b/desktop/source/deployment/registry/help/dp_help.cxx
@@ -30,9 +30,11 @@
#include "dp_help.hrc"
#include "dp_backend.h"
+#include "dp_helpbackenddb.hxx"
#include "dp_ucb.h"
#include "rtl/uri.hxx"
#include "osl/file.hxx"
+#include "rtl/bootstrap.hxx"
#include "ucbhelper/content.hxx"
#include "comphelper/servicedecl.hxx"
#include "svl/inettype.hxx"
@@ -44,6 +46,7 @@
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarExpandUrl.hpp>
#include <com/sun/star/script/XInvocation.hpp>
+#include "boost/optional.hpp"
using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -63,6 +66,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
{
BackendImpl * getMyBackend() const;
+// HelpBackendDb::Data m_dbData;
+
// Package
virtual beans::Optional< beans::Ambiguous<sal_Bool> > isRegistered_(
::osl::ResettableMutexGuard & guard,
@@ -71,36 +76,44 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
virtual void processPackage_(
::osl::ResettableMutexGuard & guard,
bool registerPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const & abortChannel,
Reference<XCommandEnvironment> const & xCmdEnv );
public:
- inline PackageImpl(
+ PackageImpl(
::rtl::Reference<PackageRegistryBackend> const & myBackend,
OUString const & url, OUString const & name,
- Reference<deployment::XPackageTypeInfo> const & xPackageType )
- : Package( myBackend, url, name, name, xPackageType )
- {}
+ Reference<deployment::XPackageTypeInfo> const & xPackageType,
+ bool bRemoved, OUString const & identifier);
+
+ //XPackage
+ virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getRegistrationDataURL()
+ throw (deployment::ExtensionRemovedException, css::uno::RuntimeException);
};
friend class PackageImpl;
// PackageRegistryBackend
virtual Reference<deployment::XPackage> bindPackage_(
OUString const & url, OUString const & mediaType,
+ sal_Bool bRemoved, OUString const & identifier,
Reference<XCommandEnvironment> const & xCmdEnv );
- void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage );
+ void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv);
void implCollectXhpFiles( const rtl::OUString& aDir,
std::vector< rtl::OUString >& o_rXhpFileVector );
- rtl::OUString getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr );
- rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage );
- rtl::OUString getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage );
- rtl::OUString expandURL( const rtl::OUString& aURL );
+
+ void addDataToDb(OUString const & url, HelpBackendDb::Data const & data);
+ ::boost::optional<HelpBackendDb::Data> readDataFromDb(OUString const & url);
+ void deleteDataFromDb(OUString const & url);
+
Reference< ucb::XSimpleFileAccess > getFileAccess( void );
Reference< ucb::XSimpleFileAccess > m_xSFA;
const Reference<deployment::XPackageTypeInfo> m_xHelpTypeInfo;
Sequence< Reference<deployment::XPackageTypeInfo> > m_typeInfos;
+ std::auto_ptr<HelpBackendDb> m_backendDb;
public:
BackendImpl( Sequence<Any> const & args,
@@ -124,6 +137,20 @@ BackendImpl::BackendImpl(
m_typeInfos( 1 )
{
m_typeInfos[ 0 ] = m_xHelpTypeInfo;
+ if (!transientMode())
+ {
+ OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml"));
+ m_backendDb.reset(
+ new HelpBackendDb(getComponentContext(), dbFile));
+
+ //clean up data folders which are no longer used.
+ //This must not be done in the same process where the help files
+ //are still registers. Only after revoking and restarting OOo the folders
+ //can be removed. This works now, because the extension manager is a singleton
+ //and the backends are only create once per process.
+ ::std::list<OUString> folders = m_backendDb->getAllDataUrls();
+ deleteUnusedFolders(OUString(), folders);
+ }
}
// XPackageRegistry
@@ -138,6 +165,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException)
//______________________________________________________________________________
Reference<deployment::XPackage> BackendImpl::bindPackage_(
OUString const & url, OUString const & mediaType_,
+ sal_Bool bRemoved, OUString const & identifier,
Reference<XCommandEnvironment> const & xCmdEnv )
{
// we don't support auto detection:
@@ -152,12 +180,20 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
{
if (type.EqualsIgnoreCaseAscii("application"))
{
- ::ucbhelper::Content ucbContent( url, xCmdEnv );
+ OUString name;
+ if (!bRemoved)
+ {
+ ::ucbhelper::Content ucbContent( url, xCmdEnv );
+ name = ucbContent.getPropertyValue(
+ StrTitle::get() ).get<OUString>();
+ }
+
if (subType.EqualsIgnoreCaseAscii(
"vnd.sun.star.help"))
{
- return new PackageImpl( this, url,
- ucbContent.getPropertyValue( StrTitle::get() ).get<OUString>(), m_xHelpTypeInfo );
+ return new PackageImpl(
+ this, url, name, m_xHelpTypeInfo, bRemoved,
+ identifier);
}
}
}
@@ -167,8 +203,45 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
static_cast<sal_Int16>(-1) );
}
+void BackendImpl::addDataToDb(
+ OUString const & url, HelpBackendDb::Data const & data)
+{
+ if (m_backendDb.get())
+ m_backendDb->addEntry(url, data);
+}
+
+::boost::optional<HelpBackendDb::Data> BackendImpl::readDataFromDb(
+ OUString const & url)
+{
+ ::boost::optional<HelpBackendDb::Data> data;
+ if (m_backendDb.get())
+ data = m_backendDb->getEntry(url);
+ return data;
+}
+
+void BackendImpl::deleteDataFromDb(OUString const & url)
+{
+ if (m_backendDb.get())
+ m_backendDb->removeEntry(url);
+}
//##############################################################################
+BackendImpl::PackageImpl::PackageImpl(
+ ::rtl::Reference<PackageRegistryBackend> const & myBackend,
+ OUString const & url, OUString const & name,
+ Reference<deployment::XPackageTypeInfo> const & xPackageType,
+ bool bRemoved, OUString const & identifier)
+ : Package( myBackend, url, name, name, xPackageType, bRemoved,
+ identifier)
+{
+// if (bRemoved)
+// {
+// ::boost::optional<HelpBackendDb::Data> opt =
+// getMyBackend()->readDataFromDb(url);
+// if (opt)
+// m_dbData = *opt;
+// }
+}
// Package
BackendImpl * BackendImpl::PackageImpl::getMyBackend() const
@@ -194,11 +267,10 @@ BackendImpl::PackageImpl::isRegistered_(
Reference<XCommandEnvironment> const & )
{
BackendImpl * that = getMyBackend();
- Reference< deployment::XPackage > xThisPackage( this );
- rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage );
- Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess();
- bool bReg = xSFA->exists( aRegisteredFlagFile );
+ bool bReg = false;
+ if (that->readDataFromDb(getURL()))
+ bReg = true;
return beans::Optional< beans::Ambiguous<sal_Bool> >( true, beans::Ambiguous<sal_Bool>( bReg, false ) );
}
@@ -207,6 +279,7 @@ BackendImpl::PackageImpl::isRegistered_(
void BackendImpl::PackageImpl::processPackage_(
::osl::ResettableMutexGuard &,
bool doRegisterPackage,
+ bool /* startup */,
::rtl::Reference<AbortChannel> const & abortChannel,
Reference<XCommandEnvironment> const & xCmdEnv )
{
@@ -216,39 +289,46 @@ void BackendImpl::PackageImpl::processPackage_(
BackendImpl* that = getMyBackend();
Reference< deployment::XPackage > xThisPackage( this );
- that->implProcessHelp( xThisPackage, doRegisterPackage );
+ that->implProcessHelp( xThisPackage, doRegisterPackage, xCmdEnv);
}
+beans::Optional< OUString > BackendImpl::PackageImpl::getRegistrationDataURL()
+ throw (deployment::ExtensionRemovedException,
+ css::uno::RuntimeException)
+{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+
+ ::boost::optional<HelpBackendDb::Data> data =
+ getMyBackend()->readDataFromDb(getURL());
+
+ if (data)
+ return beans::Optional<OUString>(true, data->dataUrl);
+
+ return beans::Optional<OUString>(true, OUString());
+}
+
+
//##############################################################################
static rtl::OUString aSlash( rtl::OUString::createFromAscii( "/" ) );
static rtl::OUString aHelpStr( rtl::OUString::createFromAscii( "help" ) );
+
void BackendImpl::implProcessHelp
- ( Reference< deployment::XPackage > xPackage, bool doRegisterPackage )
+( Reference< deployment::XPackage > xPackage, bool doRegisterPackage,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
{
- if( !xPackage.is() )
- return;
-
- Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess();
-
- rtl::OUString aRegisteredFlagFile = getRegisteredFlagFileURL( xPackage );
- if( !doRegisterPackage )
+ OSL_ASSERT(xPackage.is());
+ if (doRegisterPackage)
{
- if( xSFA->exists( aRegisteredFlagFile ) )
- xSFA->kill( aRegisteredFlagFile );
- return;
- }
-
- bool bCompile = true;
- rtl::OUString aCompiledFlagFile = getCompiledFlagFileURL( xPackage );
- if( xSFA->exists( aCompiledFlagFile ) )
- bCompile = false;
+ HelpBackendDb::Data data;
+ const OUString sHelpFolder = createFolder(OUString(), xCmdEnv);
+ data.dataUrl = sHelpFolder;
- if( bCompile )
- {
+ Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess();
rtl::OUString aHelpURL = xPackage->getURL();
- rtl::OUString aExpandedHelpURL = expandURL( aHelpURL );
+ rtl::OUString aExpandedHelpURL = dp_misc::expandUnoRcUrl( aHelpURL );
rtl::OUString aName = xPackage->getName();
if( !xSFA->isFolder( aExpandedHelpURL ) )
{
@@ -256,7 +336,7 @@ void BackendImpl::implProcessHelp
aErrStr += rtl::OUString::createFromAscii( "No help folder" );
OWeakObject* oWeakThis = static_cast<OWeakObject *>(this);
throw deployment::DeploymentException( rtl::OUString(), oWeakThis,
- makeAny( uno::Exception( aErrStr, oWeakThis ) ) );
+ makeAny( uno::Exception( aErrStr, oWeakThis ) ) );
}
Reference<XComponentContext> const & xContext = getComponentContext();
@@ -267,7 +347,7 @@ void BackendImpl::implProcessHelp
{
xInvocation = Reference< script::XInvocation >(
xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii(
- "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY );
+ "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY );
}
catch (Exception &)
{
@@ -286,34 +366,30 @@ void BackendImpl::implProcessHelp
{
std::vector< rtl::OUString > aXhpFileVector;
- // Delete (old) files in any case to allow compiler to be started every time
- rtl::OUString aLangWithPureNameURL( aLangURL );
- aLangWithPureNameURL += aSlash;
- aLangWithPureNameURL += aHelpStr;
- rtl::OUString aDbFile( aLangWithPureNameURL );
- aDbFile += rtl::OUString::createFromAscii( ".db" );
- if( xSFA->exists( aDbFile ) )
- xSFA->kill( aDbFile );
- rtl::OUString aHtFile( aLangWithPureNameURL );
- aHtFile += rtl::OUString::createFromAscii( ".ht" );
- if( xSFA->exists( aHtFile ) )
- xSFA->kill( aHtFile );
- rtl::OUString aKeyFile( aLangWithPureNameURL );
- aKeyFile += rtl::OUString::createFromAscii( ".key" );
- if( xSFA->exists( aKeyFile ) )
- xSFA->kill( aKeyFile );
-
// calculate jar file URL
- rtl::OUString aJarFile( aLangURL );
- aJarFile += aSlash;
- aJarFile += aHelpStr;
- aJarFile += rtl::OUString::createFromAscii( ".jar" );
- // remove in any case to clean up
- if( xSFA->exists( aJarFile ) )
- xSFA->kill( aJarFile );
-
- rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( aJarFile,
- rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 );
+ sal_Int32 indexStartSegment = aLangURL.lastIndexOf('/');
+ // for example "/en"
+ OUString langFolderURLSegment(
+ aLangURL.copy(
+ indexStartSegment + 1, aLangURL.getLength() - indexStartSegment - 1));
+
+ //create the folder in the "temporary folder"
+ ::ucbhelper::Content langFolderContent;
+ const OUString langFolderDest = makeURL(sHelpFolder, langFolderURLSegment);
+ const OUString langFolderDestExpanded = ::dp_misc::expandUnoRcUrl(langFolderDest);
+ ::dp_misc::create_folder(
+ &langFolderContent,
+ langFolderDest, xCmdEnv);
+
+ rtl::OUString aJarFile(
+ makeURL(sHelpFolder, langFolderURLSegment + aSlash + aHelpStr +
+ OUSTR(".jar")));
+ aJarFile = ::dp_misc::expandUnoRcUrl(aJarFile);
+
+ rtl::OUString aEncodedJarFilePath = rtl::Uri::encode(
+ aJarFile, rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8 );
rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.pkg://" );
aDestBasePath += aEncodedJarFilePath;
aDestBasePath += rtl::OUString::createFromAscii( "/" );
@@ -353,8 +429,10 @@ void BackendImpl::implProcessHelp
::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL );
HelpProcessingErrorInfo aErrorInfo;
- bool bSuccess = compileExtensionHelp( aOfficeHelpPathFileURL, aHelpStr, aLangURL,
- nXhpFileCount, pXhpFiles, aErrorInfo );
+ bool bSuccess = compileExtensionHelp(
+ aOfficeHelpPathFileURL, aHelpStr, aLangURL,
+ nXhpFileCount, pXhpFiles,
+ langFolderDestExpanded, aErrorInfo );
if( bSuccess && xInvocation.is() )
{
@@ -375,13 +453,14 @@ void BackendImpl::implProcessHelp
aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) );
rtl::OUString aSystemPath;
- osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath );
+ osl::FileBase::getSystemPathFromFileURL(
+ langFolderDestExpanded, aSystemPath );
aParamsSeq[5] = uno::makeAny( aSystemPath );
Sequence< sal_Int16 > aOutParamIndex;
Sequence< uno::Any > aOutParam;
uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ),
- aParamsSeq, aOutParamIndex, aOutParam );
+ aParamsSeq, aOutParamIndex, aOutParam );
}
if( !bSuccess )
@@ -389,10 +468,10 @@ void BackendImpl::implProcessHelp
USHORT nErrStrId = 0;
switch( aErrorInfo.m_eErrorClass )
{
- case HELPPROCESSING_GENERAL_ERROR:
- case HELPPROCESSING_INTERNAL_ERROR: nErrStrId = RID_STR_HELPPROCESSING_GENERAL_ERROR; break;
- case HELPPROCESSING_XMLPARSING_ERROR: nErrStrId = RID_STR_HELPPROCESSING_XMLPARSING_ERROR; break;
- default: ;
+ case HELPPROCESSING_GENERAL_ERROR:
+ case HELPPROCESSING_INTERNAL_ERROR: nErrStrId = RID_STR_HELPPROCESSING_GENERAL_ERROR; break;
+ case HELPPROCESSING_XMLPARSING_ERROR: nErrStrId = RID_STR_HELPPROCESSING_XMLPARSING_ERROR; break;
+ default: ;
};
rtl::OUString aErrStr;
@@ -423,7 +502,7 @@ void BackendImpl::implProcessHelp
aErrStr += rtl::OUString::createFromAscii( " in " );
rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile,
- rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
+ rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
aErrStr += aDecodedFile;
if( aErrorInfo.m_nXMLParsingLine != -1 )
{
@@ -435,96 +514,21 @@ void BackendImpl::implProcessHelp
OWeakObject* oWeakThis = static_cast<OWeakObject *>(this);
throw deployment::DeploymentException( rtl::OUString(), oWeakThis,
- makeAny( uno::Exception( aErrStr, oWeakThis ) ) );
+ makeAny( uno::Exception( aErrStr, oWeakThis ) ) );
}
}
}
- // Write compiled flag file (this code is only reached in case of success)
- Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aCompiledFlagFile );
- if( xOutputStream.is() )
- xOutputStream->closeOutput();
-
- } // if( bCompile )
-
- // Write registered flag file (this code is only reached in case of success)
- if( !xSFA->exists( aRegisteredFlagFile ) )
+ //Writing the data entry replaces writing the flag file. If we got to this
+ //point the registration was successful.
+ addDataToDb(xPackage->getURL(), data);
+ }
+ else
{
- Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile );
- if( xOutputStream.is() )
- xOutputStream->closeOutput();
+ deleteDataFromDb(xPackage->getURL());
}
}
-rtl::OUString BackendImpl::getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr )
-{
- rtl::OUString aRetURL;
- if( !xPackage.is() )
- return aRetURL;
- rtl::OUString aHelpURL = xPackage->getURL();
- aRetURL = expandURL( aHelpURL );
- aRetURL += rtl::OUString::createFromAscii( pFlagStr );
- return aRetURL;
-}
-
-rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage )
-{
- return getFlagFileURL( xPackage, "/RegisteredFlag" );
-}
-
-rtl::OUString BackendImpl::getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage )
-{
- return getFlagFileURL( xPackage, "/CompiledFlag" );
-}
-
-rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL )
-{
- static Reference< util::XMacroExpander > xMacroExpander;
- static Reference< uri::XUriReferenceFactory > xFac;
-
- if( !xMacroExpander.is() || !xFac.is() )
- {
- Reference<XComponentContext> const & xContext = getComponentContext();
- if( xContext.is() )
- {
- xFac = Reference< uri::XUriReferenceFactory >(
- xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii(
- "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY );
- }
- if( !xFac.is() )
- {
- throw RuntimeException(
- ::rtl::OUString::createFromAscii(
- "dp_registry::backend::help::BackendImpl::expandURL(), "
- "could not instatiate UriReferenceFactory." ),
- Reference< XInterface >() );
- }
-
- xMacroExpander = Reference< util::XMacroExpander >(
- xContext->getValueByName(
- ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ),
- UNO_QUERY_THROW );
- }
-
- rtl::OUString aRetURL = aURL;
- if( xMacroExpander.is() )
- {
- Reference< uri::XUriReference > uriRef;
- for (;;)
- {
- uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY );
- if ( uriRef.is() )
- {
- Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY );
- if( !sxUri.is() )
- break;
-
- aRetURL = sxUri->expand( xMacroExpander );
- }
- }
- }
- return aRetURL;
-}
void BackendImpl::implCollectXhpFiles( const rtl::OUString& aDir,
std::vector< rtl::OUString >& o_rXhpFileVector )
diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx
new file mode 100644
index 000000000000..3bf67e0c050b
--- /dev/null
+++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * 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: dp_package.cxx,v $
+ * $Revision: 1.34.16.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 "rtl/string.h"
+#include "rtl/bootstrap.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
+#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
+#include "dp_misc.h"
+
+#include "dp_helpbackenddb.hxx"
+
+
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/help-registry/2010"
+#define NS_PREFIX "help"
+#define ROOT_ELEMENT_NAME "help-backend-db"
+#define KEY_ELEMENT_NAME "help"
+
+namespace dp_registry {
+namespace backend {
+namespace help {
+
+HelpBackendDb::HelpBackendDb(
+ Reference<XComponentContext> const & xContext,
+ ::rtl::OUString const & url):BackendDb(xContext, url)
+{
+
+}
+
+OUString HelpBackendDb::getDbNSName()
+{
+ return OUSTR(EXTENSION_REG_NS);
+}
+
+OUString HelpBackendDb::getNSPrefix()
+{
+ return OUSTR(NS_PREFIX);
+}
+
+OUString HelpBackendDb::getRootElementName()
+{
+ return OUSTR(ROOT_ELEMENT_NAME);
+}
+
+OUString HelpBackendDb::getKeyElementName()
+{
+ return OUSTR(KEY_ELEMENT_NAME);
+}
+
+
+void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
+{
+ try{
+ Reference<css::xml::dom::XNode> helpNode
+ = writeKeyElement(url);
+
+ writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode);
+ save();
+ }
+ catch (css::deployment::DeploymentException& )
+ {
+ throw;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry in help backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+
+::boost::optional<HelpBackendDb::Data>
+HelpBackendDb::getEntry(::rtl::OUString const & url)
+{
+ try
+ {
+ HelpBackendDb::Data retData;
+ Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
+ if (aNode.is())
+ {
+ retData.dataUrl = readSimpleElement(OUSTR("data-url"), aNode);
+ }
+ else
+ {
+ return ::boost::optional<Data>();
+ }
+ return ::boost::optional<Data>(retData);
+ }
+ catch (css::deployment::DeploymentException& )
+ {
+ throw;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in help backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+::std::list<OUString> HelpBackendDb::getAllDataUrls()
+{
+ try
+ {
+ ::std::list<OUString> listRet;
+ Reference<css::xml::dom::XDocument> doc = getDocument();
+ Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+
+ Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ const OUString sPrefix = getNSPrefix();
+ OUString sExpression(
+ sPrefix + OUSTR(":help/") + sPrefix + OUSTR(":data-url/text()"));
+ Reference<css::xml::dom::XNodeList> nodes =
+ xpathApi->selectNodeList(root, sExpression);
+ if (nodes.is())
+ {
+ sal_Int32 length = nodes->getLength();
+ for (sal_Int32 i = 0; i < length; i++)
+ listRet.push_back(nodes->item(i)->getNodeValue());
+ }
+ return listRet;
+ }
+ catch (css::deployment::DeploymentException& )
+ {
+ throw;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in help backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+
+} // namespace help
+} // namespace backend
+} // namespace dp_registry
+
diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx
new file mode 100644
index 000000000000..edf7dfdfc284
--- /dev/null
+++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * 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: dp_backend.h,v $
+ * $Revision: 1.18 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_HELPBACKENDDB_HXX
+#define INCLUDED_DP_HELPBACKENDDB_HXX
+
+#include "rtl/ustring.hxx"
+#include <list>
+#include "boost/optional.hpp"
+#include "dp_backenddb.hxx"
+
+namespace css = ::com::sun::star;
+
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class XComponentContext;
+ }
+}}}
+
+namespace dp_registry {
+namespace backend {
+namespace help {
+
+/* The XML file stores the extensions which are currently registered.
+ They will be removed when they are revoked.
+ */
+class HelpBackendDb: public dp_registry::backend::BackendDb
+{
+protected:
+ virtual ::rtl::OUString getDbNSName();
+
+ virtual ::rtl::OUString getNSPrefix();
+
+ virtual ::rtl::OUString getRootElementName();
+
+ virtual ::rtl::OUString getKeyElementName();
+
+public:
+ struct Data
+ {
+ /* the URL to the folder containing the compiled help files, etc.
+ */
+ ::rtl::OUString dataUrl;
+
+ };
+
+public:
+
+ HelpBackendDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url);
+
+ void addEntry(::rtl::OUString const & url, Data const & data);
+
+ ::boost::optional<Data> getEntry(::rtl::OUString const & url);
+ ::std::list< ::rtl::OUString> getAllDataUrls();
+
+};
+
+
+
+}
+}
+}
+#endif
+
diff --git a/desktop/source/deployment/registry/help/makefile.mk b/desktop/source/deployment/registry/help/makefile.mk
index ba904bb7f28a..d4934f71a46f 100644
--- a/desktop/source/deployment/registry/help/makefile.mk
+++ b/desktop/source/deployment/registry/help/makefile.mk
@@ -44,7 +44,8 @@ SRC1FILES = \
dp_help.src
SLOFILES = \
- $(SLO)$/dp_help.obj
+ $(SLO)$/dp_help.obj \
+ $(SLO)$/dp_helpbackenddb.obj
.INCLUDE : ..$/..$/target.pmk
.INCLUDE : target.mk
diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h
index fe52c8ffc7e3..3d3bf7cf912c 100644
--- a/desktop/source/deployment/registry/inc/dp_backend.h
+++ b/desktop/source/deployment/registry/inc/dp_backend.h
@@ -40,8 +40,10 @@
#include "com/sun/star/lang/XEventListener.hpp"
#include "com/sun/star/deployment/XPackageRegistry.hpp"
#include "com/sun/star/deployment/XPackageManager.hpp"
+#include "com/sun/star/deployment/InvalidRemovedParameterException.hpp"
#include <memory>
#include <hash_map>
+#include <list>
#include "dp_registry.hrc"
namespace dp_registry
@@ -62,8 +64,10 @@ typedef ::cppu::WeakComponentImplHelper1<
//==============================================================================
class Package : protected ::dp_misc::MutexHolder, public t_PackageBase
{
+ PackageRegistryBackend * getMyBackend() const;
void processPackage_impl(
bool registerPackage,
+ bool startup,
css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
@@ -73,6 +77,9 @@ protected:
::rtl::OUString m_name;
::rtl::OUString m_displayName;
const css::uno::Reference<css::deployment::XPackageTypeInfo> m_xPackageType;
+ const bool m_bRemoved;
+ //Only set if m_bRemoved = true;
+ const ::rtl::OUString m_identifier;
void check() const;
void fireModified();
@@ -91,6 +98,7 @@ protected:
virtual void processPackage_(
::osl::ResettableMutexGuard & guard,
bool registerPackage,
+ bool startup,
::rtl::Reference< ::dp_misc::AbortChannel > const & abortChannel,
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
= 0;
@@ -101,7 +109,9 @@ protected:
::rtl::OUString const & name,
::rtl::OUString const & displayName,
css::uno::Reference<css::deployment::XPackageTypeInfo> const &
- xPackageType );
+ xPackageType,
+ bool bRemoved,
+ ::rtl::OUString const & identifier);
public:
@@ -126,9 +136,11 @@ public:
virtual ::rtl::OUString SAL_CALL getMediaType()
throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getDescription()
- throw (css::uno::RuntimeException);
+ throw (css::deployment::ExtensionRemovedException,
+ css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getShortDescription()
- throw (css::uno::RuntimeException);
+ throw (css::deployment::ExtensionRemovedException,
+ css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getFileFilter()
throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getIcon( sal_Bool highContrast,
@@ -165,25 +177,29 @@ public:
css::ucb::CommandAbortedException,
css::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL checkPrerequisites(
+ virtual ::sal_Int32 SAL_CALL checkPrerequisites(
const css::uno::Reference< css::task::XAbortChannel >& xAbortChannel,
const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv,
- sal_Bool bInstalled, ::rtl::OUString const & aContextName)
+ sal_Bool noLicenseChecking)
throw (css::deployment::DeploymentException,
- css::ucb::CommandFailedException,
- css::ucb::CommandAbortedException,
- css::uno::RuntimeException);
+ css::deployment::ExtensionRemovedException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL checkDependencies(
const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv )
throw (css::deployment::DeploymentException,
- css::ucb::CommandFailedException,
- css::uno::RuntimeException);
+ css::deployment::ExtensionRemovedException,
+ css::ucb::CommandFailedException,
+ css::uno::RuntimeException);
virtual void SAL_CALL registerPackage(
+ sal_Bool startup,
css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
throw (css::deployment::DeploymentException,
+ css::deployment::ExtensionRemovedException,
css::ucb::CommandFailedException,
css::ucb::CommandAbortedException,
css::lang::IllegalArgumentException, css::uno::RuntimeException);
@@ -211,19 +227,27 @@ public:
virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getIdentifier()
throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getVersion()
- throw (css::uno::RuntimeException);
+ throw (css::deployment::ExtensionRemovedException,
+ css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getURL()
throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getDisplayName()
- throw (css::uno::RuntimeException);
+ throw (css::deployment::ExtensionRemovedException,
+ css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getDescription()
- throw (css::uno::RuntimeException);
+ throw (css::deployment::ExtensionRemovedException,
+ css::uno::RuntimeException);
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL
- getUpdateInformationURLs() throw (css::uno::RuntimeException);
-
- virtual css::beans::StringPair SAL_CALL getPublisherInfo() throw (css::uno::RuntimeException);
- virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getIcon( sal_Bool bHighContrast ) throw (css::uno::RuntimeException);
-
+ getUpdateInformationURLs()
+ throw (css::deployment::ExtensionRemovedException,
+ css::uno::RuntimeException);
+ virtual css::beans::StringPair SAL_CALL getPublisherInfo()
+ throw (css::deployment::ExtensionRemovedException,
+ css::uno::RuntimeException);
+ virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL
+ getIcon( sal_Bool bHighContrast )
+ throw (css::deployment::ExtensionRemovedException,
+ css::uno::RuntimeException);
virtual css::uno::Reference<css::deployment::XPackageTypeInfo> SAL_CALL
getPackageType() throw (css::uno::RuntimeException);
virtual void SAL_CALL exportTo(
@@ -231,8 +255,17 @@ public:
::rtl::OUString const & newTitle,
sal_Int32 nameClashAction,
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
- throw (css::ucb::CommandFailedException,
+ throw (css::deployment::ExtensionRemovedException,
+ css::ucb::CommandFailedException,
css::ucb::CommandAbortedException, css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getRepositoryName()
+ throw (css::uno::RuntimeException);
+ virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getRegistrationDataURL()
+ throw (css::deployment::ExtensionRemovedException,
+ css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isRemoved()
+ throw (css::uno::RuntimeException);
+
};
typedef ::cppu::WeakComponentImplHelper2<
@@ -243,7 +276,6 @@ typedef ::cppu::WeakComponentImplHelper2<
class PackageRegistryBackend
: protected ::dp_misc::MutexHolder, public t_BackendBase
{
- ::rtl::OUString m_cachePath;
//The map held originally WeakReferences. The map entries are removed in the disposing
//function, which is called when the XPackages are destructed or they are
//explicitely disposed. The latter happens, for example, when a extension is
@@ -257,13 +289,14 @@ class PackageRegistryBackend
t_string2ref m_bound;
protected:
+ ::rtl::OUString m_cachePath;
css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
::rtl::OUString m_context;
// currently only for library containers:
enum context {
CONTEXT_UNKNOWN,
- CONTEXT_USER, CONTEXT_SHARED,
+ CONTEXT_USER, CONTEXT_SHARED,CONTEXT_BUNDLED, CONTEXT_TMP,
CONTEXT_DOCUMENT
} m_eContext;
bool m_readOnly;
@@ -276,6 +309,7 @@ protected:
// @@@ to be implemented by specific backend:
virtual css::uno::Reference<css::deployment::XPackage> bindPackage_(
::rtl::OUString const & url, ::rtl::OUString const & mediaType,
+ sal_Bool bRemoved, ::rtl::OUString const & identifier,
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
= 0;
@@ -287,6 +321,28 @@ protected:
css::uno::Sequence<css::uno::Any> const & args,
css::uno::Reference<css::uno::XComponentContext> const & xContext );
+ /* creates a folder with a unique name.
+ If url is empty then it is created in the the backend folder, otherwise
+ at a location relative to that folder specified by url.
+ */
+ ::rtl::OUString createFolder(
+ ::rtl::OUString const & relUrl,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+ /* deletes folders and files.
+
+ All folder all files which end with ".tmp" or ".tmp_" and which are
+ not used are deleted.
+ */
+ void deleteUnusedFolders(
+ ::rtl::OUString const & relUrl,
+ ::std::list< ::rtl::OUString> const & usedFolders);
+ /* deletes one folder with a "temporary" name and the corresponding
+ tmp file, which was used to derive the folder name.
+ */
+ static void deleteTempFolder(
+ ::rtl::OUString const & folderUrl);
+
+
public:
struct StrRegisteringPackage : public ::dp_misc::StaticResourceString<
StrRegisteringPackage, RID_STR_REGISTERING_PACKAGE> {};
@@ -299,6 +355,8 @@ public:
inline ::rtl::OUString const & getCachePath() const { return m_cachePath; }
inline bool transientMode() const { return m_cachePath.getLength() == 0; }
+ inline ::rtl::OUString getContext() const {return m_context; }
+
// XEventListener
virtual void SAL_CALL disposing( css::lang::EventObject const & evt )
throw (css::uno::RuntimeException);
@@ -306,13 +364,12 @@ public:
// XPackageRegistry
virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL bindPackage(
::rtl::OUString const & url, ::rtl::OUString const & mediaType,
+ sal_Bool bRemoved, ::rtl::OUString const & identifier,
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
throw (css::deployment::DeploymentException,
+ css::deployment::InvalidRemovedParameterException,
css::ucb::CommandFailedException,
css::lang::IllegalArgumentException, css::uno::RuntimeException);
-// virtual css::uno::Sequence<
-// css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL
-// getSupportedPackageTypes() throw (css::uno::RuntimeException);
};
}
diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx
new file mode 100644
index 000000000000..a0e477979f8c
--- /dev/null
+++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_BACKENDDB_HXX
+#define INCLUDED_DP_BACKENDDB_HXX
+
+#include "rtl/ustring.hxx"
+#include <list>
+#include <vector>
+
+namespace css = ::com::sun::star;
+
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class XComponentContext;
+ }
+ namespace xml { namespace dom {
+ class XDocument;
+ class XNode;
+ }}
+ namespace xml { namespace xpath {
+ class XXPathAPI;
+ }}
+}}}
+
+namespace dp_registry {
+namespace backend {
+
+class BackendDb
+{
+private:
+
+ css::uno::Reference<css::xml::dom::XDocument> m_doc;
+ css::uno::Reference<css::xml::xpath::XXPathAPI> m_xpathApi;
+
+ BackendDb(BackendDb const &);
+ BackendDb & operator = (BackendDb const &);
+
+protected:
+ const css::uno::Reference<css::uno::XComponentContext> m_xContext;
+ ::rtl::OUString m_urlDb;
+
+protected:
+
+ /* caller must make sure that only one thread accesses the function
+ */
+ css::uno::Reference<css::xml::dom::XDocument> getDocument();
+
+ /* the namespace prefix is "reg" (without quotes)
+ */
+ css::uno::Reference<css::xml::xpath::XXPathAPI> getXPathAPI();
+ void save();
+ void removeElement(::rtl::OUString const & sXPathExpression);
+
+ css::uno::Reference<css::xml::dom::XNode> getKeyElement(
+ ::rtl::OUString const & url);
+
+ void writeSimpleList(
+ ::std::list< ::rtl::OUString> const & list,
+ ::rtl::OUString const & sListTagName,
+ ::rtl::OUString const & sMemberTagName,
+ css::uno::Reference<css::xml::dom::XNode> const & xParent);
+
+ void writeVectorOfPair(
+ ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > const & vecPairs,
+ ::rtl::OUString const & sVectorTagName,
+ ::rtl::OUString const & sPairTagName,
+ ::rtl::OUString const & sFirstTagName,
+ ::rtl::OUString const & sSecondTagName,
+ css::uno::Reference<css::xml::dom::XNode> const & xParent);
+
+ void writeSimpleElement(
+ ::rtl::OUString const & sElementName, ::rtl::OUString const & value,
+ css::uno::Reference<css::xml::dom::XNode> const & xParent);
+
+ css::uno::Reference<css::xml::dom::XNode> writeKeyElement(
+ ::rtl::OUString const & url);
+
+ ::rtl::OUString readSimpleElement(
+ ::rtl::OUString const & sElementName,
+ css::uno::Reference<css::xml::dom::XNode> const & xParent);
+
+ ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > >
+ readVectorOfPair(
+ css::uno::Reference<css::xml::dom::XNode> const & parent,
+ ::rtl::OUString const & sListTagName,
+ ::rtl::OUString const & sPairTagName,
+ ::rtl::OUString const & sFirstTagName,
+ ::rtl::OUString const & sSecondTagName);
+
+ ::std::list< ::rtl::OUString> readList(
+ css::uno::Reference<css::xml::dom::XNode> const & parent,
+ ::rtl::OUString const & sListTagName,
+ ::rtl::OUString const & sMemberTagName);
+
+ /* returns the values of one particulary child element of all key elements.
+ */
+ ::std::list< ::rtl::OUString> getOneChildFromAllEntries(
+ ::rtl::OUString const & sElementName);
+
+
+ /* returns the namespace which is to be written as xmlns attribute
+ into the root element.
+ */
+ virtual ::rtl::OUString getDbNSName()=0;
+ /* return the namespace prefix which is to be registered with the XPath API.
+
+ The prefix can then be used in XPath expressions.
+ */
+ virtual ::rtl::OUString getNSPrefix()=0;
+ /* returns the name of the root element without any namespace prefix.
+ */
+ virtual ::rtl::OUString getRootElementName()=0;
+ /* returns the name of xml element for each entry
+ */
+ virtual ::rtl::OUString getKeyElementName()=0;
+
+
+
+public:
+ BackendDb(css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url);
+ virtual ~BackendDb() {};
+
+ void removeEntry(::rtl::OUString const & url);
+};
+
+class RegisteredDb: public BackendDb
+{
+
+public:
+ RegisteredDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url);
+ virtual ~RegisteredDb() {};
+
+
+ virtual void addEntry(::rtl::OUString const & url);
+ virtual bool getEntry(::rtl::OUString const & url);
+
+};
+
+
+}
+}
+#endif
+
diff --git a/desktop/source/deployment/registry/makefile.mk b/desktop/source/deployment/registry/makefile.mk
index de0e943654d9..e45cec272ca7 100644
--- a/desktop/source/deployment/registry/makefile.mk
+++ b/desktop/source/deployment/registry/makefile.mk
@@ -41,7 +41,8 @@ INCPRE += inc
SLOFILES = \
$(SLO)$/dp_backend.obj \
- $(SLO)$/dp_registry.obj
+ $(SLO)$/dp_registry.obj \
+ $(SLO)$/dp_backenddb.obj
.INCLUDE : ..$/target.pmk
.INCLUDE : target.mk
diff --git a/desktop/source/deployment/registry/package/dp_description.cxx b/desktop/source/deployment/registry/package/dp_description.cxx
deleted file mode 100644
index 7c05bfd90a5b..000000000000
--- a/desktop/source/deployment/registry/package/dp_description.cxx
+++ /dev/null
@@ -1,205 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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 "dp_description.hxx"
-
-#include "cppuhelper/exc_hlp.hxx"
-#include "ucbhelper/content.hxx"
-#include "com/sun/star/deployment/DeploymentException.hpp"
-#include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
-#include "com/sun/star/uno/XComponentContext.hpp"
-#include "com/sun/star/ucb/CommandFailedException.hpp"
-#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
-#include "com/sun/star/ucb/IOErrorCode.hpp"
-
-#include "com/sun/star/beans/PropertyValue.hpp"
-
-
-#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
-
-namespace css = com::sun::star;
-namespace cssu = com::sun::star::uno;
-
-namespace dp_registry {
-namespace backend {
-namespace bundle {
-
-ExtensionDescription::ExtensionDescription(
- const cssu::Reference<cssu::XComponentContext>& xContext,
- const ::rtl::OUString& installDir,
- const cssu::Reference< css::ucb::XCommandEnvironment >& xCmdEnv)
-{
- try {
- m_sExtensionRootUrl = installDir;
- //may throw ::com::sun::star::ucb::ContentCreationException
- //If there is no description.xml then ucb will start an interaction which
- //brings up a dialog.We want to prevent this. Therefore we wrap the xCmdEnv
- //and filter the respective exception out.
- ::rtl::OUString sDescriptionUri(installDir + OUSTR("/description.xml"));
- cssu::Reference<css::ucb::XCommandEnvironment> xFilter =
- static_cast<css::ucb::XCommandEnvironment*>(
- new FileDoesNotExistFilter(xCmdEnv));
- ::ucbhelper::Content descContent(sDescriptionUri, xFilter);
-
- //throws an com::sun::star::uno::Exception if the file is not available
- cssu::Reference<css::io::XInputStream> xIn;
- try
- { //throws com.sun.star.ucb.InteractiveAugmentedIOException
- xIn = descContent.openStream();
- }
- catch (cssu::Exception& )
- {
- if ( ! static_cast<FileDoesNotExistFilter*>(xFilter.get())->exist())
- throw NoDescriptionException();
- throw;
- }
- if (!xIn.is())
- {
- throw cssu::Exception(
- OUSTR("Could not get XInputStream for description.xml of extension ") +
- sDescriptionUri, 0);
- }
-
- //get root node of description.xml
- cssu::Reference<css::xml::dom::XDocumentBuilder> xDocBuilder(
- xContext->getServiceManager()->createInstanceWithContext(
- OUSTR("com.sun.star.xml.dom.DocumentBuilder"),
- xContext ), cssu::UNO_QUERY);
- if (!xDocBuilder.is())
- throw css::uno::Exception(OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0);
-
- if (xDocBuilder->isNamespaceAware() == sal_False)
- {
- throw cssu::Exception(
- OUSTR("Service com.sun.star.xml.dom.DocumentBuilder is not namespace aware."), 0);
- }
-
- cssu::Reference<css::xml::dom::XDocument> xDoc = xDocBuilder->parse(xIn);
- if (!xDoc.is())
- {
- throw cssu::Exception(sDescriptionUri + OUSTR(" contains data which cannot be parsed. "), 0);
- }
-
- //check for proper root element and namespace
- cssu::Reference<css::xml::dom::XElement> xRoot = xDoc->getDocumentElement();
- if (!xRoot.is())
- {
- throw cssu::Exception(
- sDescriptionUri + OUSTR(" contains no root element."), 0);
- }
-
- if ( ! xRoot->getTagName().equals(OUSTR("description")))
- {
- throw cssu::Exception(
- sDescriptionUri + OUSTR(" does not contain the root element <description>."), 0);
- }
-
- m_xRoot = cssu::Reference<css::xml::dom::XNode>(
- xRoot, cssu::UNO_QUERY_THROW);
- ::rtl::OUString nsDescription = xRoot->getNamespaceURI();
-
- //check if this namespace is supported
- if ( ! nsDescription.equals(OUSTR("http://openoffice.org/extensions/description/2006")))
- {
- throw cssu::Exception(sDescriptionUri + OUSTR(" contains a root element with an unsupported namespace. "), 0);
- }
- } catch (css::uno::RuntimeException &) {
- throw;
- } catch (css::deployment::DeploymentException &) {
- throw;
- } catch (css::uno::Exception & e) {
- css::uno::Any a(cppu::getCaughtException());
- throw css::deployment::DeploymentException(
- e.Message, css::uno::Reference< css::uno::XInterface >(), a);
- }
-}
-
-ExtensionDescription::~ExtensionDescription()
-{
-}
-
-//======================================================================
-FileDoesNotExistFilter::FileDoesNotExistFilter(
- const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv):
- m_bExist(true), m_xCommandEnv(xCmdEnv)
-{}
-
-FileDoesNotExistFilter::~FileDoesNotExistFilter()
-{
-};
-
-bool FileDoesNotExistFilter::exist()
-{
- return m_bExist;
-}
- // XCommandEnvironment
-cssu::Reference<css::task::XInteractionHandler >
- FileDoesNotExistFilter::getInteractionHandler() throw (css::uno::RuntimeException)
-{
- return static_cast<css::task::XInteractionHandler*>(this);
-}
-
-cssu::Reference<css::ucb::XProgressHandler >
- FileDoesNotExistFilter::getProgressHandler() throw (css::uno::RuntimeException)
-{
- return m_xCommandEnv.is()
- ? m_xCommandEnv->getProgressHandler()
- : cssu::Reference<css::ucb::XProgressHandler>();
-}
-
-// XInteractionHandler
-//If the interaction was caused by a non-existing file which is specified in the ctor
-//of FileDoesNotExistFilter, then we do nothing
-void FileDoesNotExistFilter::handle(
- cssu::Reference<css::task::XInteractionRequest > const & xRequest )
- throw (css::uno::RuntimeException)
-{
- cssu::Any request( xRequest->getRequest() );
-
- css::ucb::InteractiveAugmentedIOException ioexc;
- if ((request>>= ioexc) && ioexc.Code == css::ucb::IOErrorCode_NOT_EXISTING )
- {
- m_bExist = false;
- return;
- }
- css::uno::Reference<css::task::XInteractionHandler> xInteraction;
- if (m_xCommandEnv.is()) {
- xInteraction = m_xCommandEnv->getInteractionHandler();
- }
- if (xInteraction.is()) {
- xInteraction->handle(xRequest);
- }
-}
-
-
-} // namespace bundle
-} // namespace backend
-} // namespace dp_registry
-
diff --git a/desktop/source/deployment/registry/package/dp_description.hxx b/desktop/source/deployment/registry/package/dp_description.hxx
deleted file mode 100644
index eb74c454af75..000000000000
--- a/desktop/source/deployment/registry/package/dp_description.hxx
+++ /dev/null
@@ -1,125 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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.
- *
- ************************************************************************/
-
-#if !defined INCLUDED_DESKTOP_EXTENSION_DESCRIPTION_HXX
-#define INCLUDED_DESKTOP_EXTENSION_DESCRIPTION_HXX
-
-
-
-#include "com/sun/star/uno/Reference.hxx"
-
-#include "com/sun/star/ucb/XCommandEnvironment.hpp"
-#include "com/sun/star/uno/XComponentContext.hpp"
-#include "com/sun/star/xml/dom/XNode.hpp"
-#include "com/sun/star/task/XInteractionHandler.hpp"
-#include "cppuhelper/implbase2.hxx"
-
-
-namespace css = ::com::sun::star;
-
-namespace dp_registry {
-namespace backend {
-namespace bundle {
-
-/**The class uses the UCB to access the description.xml file in an
- extension. The UCB must have been initialized already. It also
- requires that the extension has already be unzipped to a particular
- location.
- */
-class ExtensionDescription
-{
-public:
- /**throws an exception if the description.xml is not
- available, cannot be read, does not contain the expected data,
- or any other error occured. Therefore it shoult only be used with
- new extensions.
-
- Throws com::sun::star::uno::RuntimeException,
- com::sun::star::deployment::DeploymentException,
- dp_registry::backend::bundle::NoDescriptionException.
- */
- ExtensionDescription(
- const css::uno::Reference<css::uno::XComponentContext>& xContext,
- const ::rtl::OUString& installDir,
- const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv);
-
- ~ExtensionDescription();
-
- css::uno::Reference<css::xml::dom::XNode> getRootElement() const
- {
- return m_xRoot;
- }
-
- ::rtl::OUString getExtensionRootUrl() const
- {
- return m_sExtensionRootUrl;
- }
-
-
-private:
- css::uno::Reference<css::xml::dom::XNode> m_xRoot;
- ::rtl::OUString m_sExtensionRootUrl;
-};
-
-class NoDescriptionException
-{
-};
-
-class FileDoesNotExistFilter
- : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment,
- css::task::XInteractionHandler >
-
-{
- //css::uno::Reference<css::task::XInteractionHandler> m_xHandler;
- bool m_bExist;
- css::uno::Reference< css::ucb::XCommandEnvironment > m_xCommandEnv;
-
-public:
- virtual ~FileDoesNotExistFilter();
- FileDoesNotExistFilter(
- const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv);
-
- bool exist();
- // XCommandEnvironment
- virtual css::uno::Reference<css::task::XInteractionHandler > SAL_CALL
- getInteractionHandler() throw (css::uno::RuntimeException);
- virtual css::uno::Reference<css::ucb::XProgressHandler >
- SAL_CALL getProgressHandler() throw (css::uno::RuntimeException);
-
- // XInteractionHandler
- virtual void SAL_CALL handle(
- css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
- throw (css::uno::RuntimeException);
-};
-
-
-} // namespace bundle
-} // namespace backend
-} // namespace dp_registry
-
-
-#endif // INCLUDED_DESKTOP_LICENSE_INTERACT_HXX
diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx
new file mode 100644
index 000000000000..2e92a907f8fb
--- /dev/null
+++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "rtl/string.h"
+#include "rtl/bootstrap.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
+#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
+#include "dp_misc.h"
+
+#include "dp_extbackenddb.hxx"
+
+
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010"
+#define NS_PREFIX "ext"
+#define ROOT_ELEMENT_NAME "extension-backend-db"
+#define KEY_ELEMENT_NAME "extension"
+
+namespace dp_registry {
+namespace backend {
+namespace bundle {
+
+ExtensionBackendDb::ExtensionBackendDb(
+ Reference<XComponentContext> const & xContext,
+ ::rtl::OUString const & url):BackendDb(xContext, url)
+{
+
+}
+
+OUString ExtensionBackendDb::getDbNSName()
+{
+ return OUSTR(EXTENSION_REG_NS);
+}
+
+OUString ExtensionBackendDb::getNSPrefix()
+{
+ return OUSTR(NS_PREFIX);
+}
+
+OUString ExtensionBackendDb::getRootElementName()
+{
+ return OUSTR(ROOT_ELEMENT_NAME);
+}
+
+OUString ExtensionBackendDb::getKeyElementName()
+{
+ return OUSTR(KEY_ELEMENT_NAME);
+}
+
+void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
+{
+ try{
+ Reference<css::xml::dom::XNode> extensionNodeNode = writeKeyElement(url);
+ writeVectorOfPair(
+ data.items,
+ OUSTR("extension-items"),
+ OUSTR("item"),
+ OUSTR("url"),
+ OUSTR("media-type"),
+ extensionNodeNode);
+ save();
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & url)
+{
+ try
+ {
+ ExtensionBackendDb::Data retData;
+ Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
+
+ if (aNode.is())
+ {
+ retData.items =
+ readVectorOfPair(
+ aNode,
+ OUSTR("extension-items"),
+ OUSTR("item"),
+ OUSTR("url"),
+ OUSTR("media-type"));
+ }
+ return retData;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+} // namespace bundle
+} // namespace backend
+} // namespace dp_registry
+
diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx
new file mode 100644
index 000000000000..d09fd0891a32
--- /dev/null
+++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+
+#if ! defined INCLUDED_DP_EXTBACKENDDB_HXX
+#define INCLUDED_DP_EXTBACKENDDB_HXX
+
+#include "rtl/ustring.hxx"
+#include "rtl/string.hxx"
+#include <vector>
+#include "dp_backenddb.hxx"
+
+namespace css = ::com::sun::star;
+
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class XComponentContext;
+ }
+ namespace xml { namespace dom {
+ class XDocument;
+ class XNode;
+ }}
+ namespace xml { namespace xpath {
+ class XXPathAPI;
+ }}
+}}}
+
+namespace dp_registry {
+namespace backend {
+namespace bundle {
+
+/* The XML file stores the extensions which are currently registered.
+ They will be removed when they are revoked.
+ */
+class ExtensionBackendDb: public dp_registry::backend::BackendDb
+{
+protected:
+ virtual ::rtl::OUString getDbNSName();
+ virtual ::rtl::OUString getNSPrefix();
+ virtual ::rtl::OUString getRootElementName();
+ virtual ::rtl::OUString getKeyElementName();
+
+public:
+ struct Data
+ {
+ /* every element consists of a pair of the url to the item (jar,rdb, etc)
+ and the media type
+ */
+ ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString> > items;
+ typedef ::std::vector<
+ ::std::pair< ::rtl::OUString, ::rtl::OUString> >::const_iterator ITC_ITEMS;
+
+ };
+
+public:
+
+ ExtensionBackendDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url);
+
+ void addEntry(::rtl::OUString const & url, Data const & data);
+
+ Data getEntry(::rtl::OUString const & url);
+
+};
+
+
+
+}
+}
+}
+#endif
+
diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx
index b0b4a918c7a3..2ad6478b665c 100644
--- a/desktop/source/deployment/registry/package/dp_package.cxx
+++ b/desktop/source/deployment/registry/package/dp_package.cxx
@@ -34,7 +34,6 @@
#include "dp_interact.h"
#include "dp_dependencies.hxx"
#include "dp_platform.hxx"
-#include "dp_description.hxx"
#include "dp_descriptioninfoset.hxx"
#include "dp_identifier.hxx"
#include "rtl/uri.hxx"
@@ -65,8 +64,8 @@
#include "com/sun/star/packages/manifest/XManifestWriter.hpp"
#include "com/sun/star/deployment/DependencyException.hpp"
#include "com/sun/star/deployment/LicenseException.hpp"
-#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp"
#include "com/sun/star/deployment/PlatformException.hpp"
+#include "com/sun/star/deployment/Prerequisites.hpp"
#include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
#include "com/sun/star/deployment/XPackageManager.hpp"
@@ -74,13 +73,13 @@
#include <vector>
#include <stdio.h>
-
+#include "dp_extbackenddb.hxx"
using namespace ::dp_misc;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::ucb;
+
namespace css = ::com::sun::star;
-namespace cssu = ::com::sun::star::uno;
+
using ::rtl::OUString;
namespace dp_registry {
@@ -106,44 +105,48 @@ class BackendImpl : public ImplBaseT
Sequence< Reference<deployment::XPackage> > m_bundle;
Sequence< Reference<deployment::XPackage> > * m_pBundle;
+ ExtensionBackendDb::Data m_dbData;
+
Reference<deployment::XPackage> bindBundleItem(
OUString const & url, OUString const & mediaType,
- Reference<XCommandEnvironment> const & xCmdEnv,
+ sal_Bool bRemoved, //that is, useing data base information
+ OUString const & identifier,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv,
bool notifyDetectionError = true );
typedef ::std::vector< Reference<deployment::XPackage> > t_packagevec;
void scanBundle(
t_packagevec & bundle,
::rtl::Reference<AbortChannel> const & abortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv );
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv );
void scanLegacyBundle(
t_packagevec & bundle,
OUString const & url,
::rtl::Reference<AbortChannel> const & abortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv,
bool skip_registration = false );
-
+ ::std::vector<Reference<deployment::XPackage> > getPackagesFromDb(
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv);
bool checkPlatform(
- css::uno::Reference< css::ucb::XCommandEnvironment > const & environment);
+ Reference<ucb::XCommandEnvironment > const & environment);
bool checkDependencies(
- css::uno::Reference< css::ucb::XCommandEnvironment > const &
+ Reference<ucb::XCommandEnvironment > const &
environment,
- ExtensionDescription const & description);
+ DescriptionInfoset const & description);
// throws css::uno::RuntimeException,
// css::deployment::DeploymentException
::sal_Bool checkLicense(
- css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv,
- ExtensionDescription const& description, bool bInstalled,
- OUString const & aContextName )
- throw (css::deployment::DeploymentException,
- css::ucb::CommandFailedException,
- css::ucb::CommandAbortedException,
- css::uno::RuntimeException);
+ Reference< ucb::XCommandEnvironment > const & xCmdEnv,
+ DescriptionInfoset const & description, bool bNoLicenseChecking)
+ throw (deployment::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ RuntimeException);
// @throws DeploymentException
OUString getTextFromURL(
- const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv,
+ const Reference< ucb::XCommandEnvironment >& xCmdEnv,
const OUString& licenseUrl);
DescriptionInfoset getDescriptionInfoset();
@@ -152,12 +155,13 @@ class BackendImpl : public ImplBaseT
virtual beans::Optional< beans::Ambiguous<sal_Bool> > isRegistered_(
::osl::ResettableMutexGuard & guard,
::rtl::Reference<AbortChannel> const & abortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv );
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv );
virtual void processPackage_(
::osl::ResettableMutexGuard & guard,
bool registerPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const & abortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv );
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv );
virtual void SAL_CALL disposing();
@@ -169,57 +173,68 @@ class BackendImpl : public ImplBaseT
OUString const & url,
OUString const & name,
Reference<deployment::XPackageTypeInfo> const & xPackageType,
- bool legacyBundle )
- : Package( myBackend, url, name, name /* display-name */,
- xPackageType ),
- m_url_expanded( expandUnoRcUrl( url ) ),
- m_legacyBundle( legacyBundle ),
- m_pBundle( 0 )
- {}
+ bool legacyBundle,
+ bool bRemoved,
+ OUString const & identifier);
// XPackage
virtual sal_Bool SAL_CALL isBundle() throw (RuntimeException);
+
virtual Sequence< Reference<deployment::XPackage> > SAL_CALL getBundle(
Reference<task::XAbortChannel> const & xAbortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv )
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
throw (deployment::DeploymentException,
- CommandFailedException, CommandAbortedException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
lang::IllegalArgumentException, RuntimeException);
- virtual OUString SAL_CALL getDescription() throw (RuntimeException);
+ virtual OUString SAL_CALL getDescription()
+ throw (deployment::ExtensionRemovedException, RuntimeException);
+
virtual void SAL_CALL exportTo(
OUString const & destFolderURL, OUString const & newTitle,
sal_Int32 nameClashAction,
- Reference<XCommandEnvironment> const & xCmdEnv )
- throw (CommandFailedException, CommandAbortedException,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deployment::ExtensionRemovedException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
RuntimeException);
- virtual ::sal_Bool SAL_CALL checkPrerequisites(
- const css::uno::Reference< css::task::XAbortChannel >& xAbortChannel,
- const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv,
- ::sal_Bool bInstalled, OUString const & aContextName)
- throw (css::deployment::DeploymentException,
- css::ucb::CommandFailedException,
- css::ucb::CommandAbortedException,
- css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL checkPrerequisites(
+ const Reference< task::XAbortChannel >& xAbortChannel,
+ const Reference< ucb::XCommandEnvironment >& xCmdEnv,
+ ::sal_Bool noLicenseChecking)
+ throw (deployment::ExtensionRemovedException,
+ deployment::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ RuntimeException);
virtual ::sal_Bool SAL_CALL checkDependencies(
- const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv )
- throw (css::deployment::DeploymentException,
- css::ucb::CommandFailedException,
- css::uno::RuntimeException);
+ const Reference< ucb::XCommandEnvironment >& xCmdEnv )
+ throw (deployment::DeploymentException,
+ deployment::ExtensionRemovedException,
+ ucb::CommandFailedException,
+ RuntimeException);
virtual beans::Optional<OUString> SAL_CALL getIdentifier()
throw (RuntimeException);
- virtual OUString SAL_CALL getVersion() throw (RuntimeException);
+ virtual OUString SAL_CALL getVersion()
+ throw (deployment::ExtensionRemovedException, RuntimeException);
virtual Sequence<OUString> SAL_CALL getUpdateInformationURLs()
- throw (RuntimeException);
+ throw (deployment::ExtensionRemovedException, RuntimeException);
- virtual css::beans::StringPair SAL_CALL getPublisherInfo() throw (css::uno::RuntimeException);
+ virtual beans::StringPair SAL_CALL getPublisherInfo()
+ throw (deployment::ExtensionRemovedException, RuntimeException);
- virtual OUString SAL_CALL getDisplayName() throw (RuntimeException);
- virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getIcon( ::sal_Bool bHighContrast ) throw (css::uno::RuntimeException);
+ virtual OUString SAL_CALL getDisplayName()
+ throw (deployment::ExtensionRemovedException, RuntimeException);
+
+ virtual Reference< graphic::XGraphic > SAL_CALL
+ getIcon( ::sal_Bool bHighContrast )
+ throw (deployment::ExtensionRemovedException,
+ RuntimeException);
};
friend class PackageImpl;
@@ -228,10 +243,17 @@ class BackendImpl : public ImplBaseT
const Reference<deployment::XPackageTypeInfo> m_xLegacyBundleTypeInfo;
Sequence< Reference<deployment::XPackageTypeInfo> > m_typeInfos;
+ std::auto_ptr<ExtensionBackendDb> m_backendDb;
+
+ void addDataToDb(OUString const & url, ExtensionBackendDb::Data const & data);
+ ExtensionBackendDb::Data readDataFromDb(OUString const & url);
+ void deleteDataFromDb(OUString const & url);
+
// PackageRegistryBackend
virtual Reference<deployment::XPackage> bindPackage_(
OUString const & url, OUString const & mediaType,
- Reference<XCommandEnvironment> const & xCmdEnv );
+ sal_Bool bRemoved, OUString const & identifier,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv );
virtual void SAL_CALL disposing();
@@ -291,6 +313,14 @@ BackendImpl::BackendImpl(
{
m_typeInfos[ 0 ] = m_xBundleTypeInfo;
m_typeInfos[ 1 ] = m_xLegacyBundleTypeInfo;
+
+ if (!transientMode())
+ {
+ OUString dbFile = makeURL(getCachePath(), getImplementationName());
+ dbFile = makeURL(dbFile, OUSTR("backenddb.xml"));
+ m_backendDb.reset(
+ new ExtensionBackendDb(getComponentContext(), dbFile));
+ }
}
//______________________________________________________________________________
@@ -333,7 +363,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException)
//______________________________________________________________________________
Reference<deployment::XPackage> BackendImpl::bindPackage_(
OUString const & url, OUString const & mediaType_,
- Reference<XCommandEnvironment> const & xCmdEnv )
+ sal_Bool bRemoved, OUString const & identifier,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
{
OUString mediaType( mediaType_ );
if (mediaType.getLength() == 0)
@@ -347,7 +378,7 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
//Every .oxt, uno.pkg file must contain a META-INF folder
::ucbhelper::Content metaInfContent;
if (create_ucb_content(
- &metaInfContent, makeURL( url, OUSTR("META-INF/manifest.xml") ),
+ &metaInfContent, makeURL( url, OUSTR("META-INF") ),
xCmdEnv, false /* no throw */ ))
{
mediaType = OUSTR("application/vnd.sun.star.package-bundle");
@@ -381,19 +412,26 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
{
if (type.EqualsIgnoreCaseAscii("application"))
{
- ::ucbhelper::Content ucbContent( url, xCmdEnv );
+
+ //In case a XPackage is created for a removed extension, we cannot
+ //obtain the name
+ OUString name;
+ if (!bRemoved)
+ {
+ ::ucbhelper::Content ucbContent( url, xCmdEnv );
+ name = ucbContent.getPropertyValue(
+ StrTitle::get() ).get<OUString>();
+ }
if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.package-bundle")) {
return new PackageImpl(
- this, url, ucbContent.getPropertyValue(
- StrTitle::get() ).get<OUString>(),
- m_xBundleTypeInfo, false );
+ this, url, name, m_xBundleTypeInfo, false, bRemoved,
+ identifier);
}
else if (subType.EqualsIgnoreCaseAscii(
"vnd.sun.star.legacy-package-bundle")) {
return new PackageImpl(
- this, url, ucbContent.getPropertyValue(
- StrTitle::get() ).get<OUString>(),
- m_xLegacyBundleTypeInfo, true );
+ this, url, name, m_xLegacyBundleTypeInfo, true, bRemoved,
+ identifier);
}
}
}
@@ -403,8 +441,47 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
static_cast<sal_Int16>(-1) );
}
+void BackendImpl::addDataToDb(
+ OUString const & url, ExtensionBackendDb::Data const & data)
+{
+ if (m_backendDb.get())
+ m_backendDb->addEntry(url, data);
+}
+
+ExtensionBackendDb::Data BackendImpl::readDataFromDb(
+ OUString const & url)
+{
+ ExtensionBackendDb::Data data;
+ if (m_backendDb.get())
+ data = m_backendDb->getEntry(url);
+ return data;
+}
+
+void BackendImpl::deleteDataFromDb(OUString const & url)
+{
+ if (m_backendDb.get())
+ m_backendDb->removeEntry(url);
+}
+
+
//##############################################################################
+BackendImpl::PackageImpl::PackageImpl(
+ ::rtl::Reference<PackageRegistryBackend> const & myBackend,
+ OUString const & url,
+ OUString const & name,
+ Reference<deployment::XPackageTypeInfo> const & xPackageType,
+ bool legacyBundle, bool bRemoved, OUString const & identifier)
+ : Package( myBackend, url, name, name /* display-name */,
+ xPackageType, bRemoved, identifier),
+ m_url_expanded( expandUnoRcUrl( url ) ),
+ m_legacyBundle( legacyBundle ),
+ m_pBundle( 0 )
+{
+ if (bRemoved)
+ m_dbData = getMyBackend()->readDataFromDb(url);
+}
+
BackendImpl * BackendImpl::PackageImpl::getMyBackend() const
{
BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get());
@@ -437,22 +514,23 @@ beans::Optional< beans::Ambiguous<sal_Bool> >
BackendImpl::PackageImpl::isRegistered_(
::osl::ResettableMutexGuard &,
::rtl::Reference<AbortChannel> const & abortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv )
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
{
+ //In case the object was created for a removed extension (m_bRemoved = true)
+ //but the extension is not registered, then bundle will be empty. Then
+ //the return value will be Optional<...>.IsPresent= false. Althoug this is
+ //not true, this does not matter. Then registerPackage or revokePackage
+ //would never be called for the items. But since the extension is removed
+ //and not registered anyway, this does not matter.
const Sequence< Reference<deployment::XPackage> > bundle(
getBundle( abortChannel.get(), xCmdEnv ) );
+
bool reg = false;
bool present = false;
bool ambig = false;
for ( sal_Int32 pos = bundle.getLength(); pos--; )
{
Reference<deployment::XPackage> const & xPackage = bundle[ pos ];
- //disregard executable (application/vnd.sun.star.executable)
- //it will not be disabled/enabled.
- OUString sType = xPackage->getPackageType()->getMediaType();
- if (sType.equals(OUSTR("application/vnd.sun.star.executable")))
- continue;
-
Reference<task::XAbortChannel> xSubAbortChannel(
xPackage->createAbortChannel() );
AbortChannel::Chain chain( abortChannel, xSubAbortChannel );
@@ -510,23 +588,7 @@ OUString BackendImpl::PackageImpl::getTextFromURL(
DescriptionInfoset BackendImpl::PackageImpl::getDescriptionInfoset()
{
- css::uno::Reference< css::xml::dom::XNode > root;
- try {
- root =
- ExtensionDescription(
- getMyBackend()->getComponentContext(), m_url_expanded,
- css::uno::Reference< css::ucb::XCommandEnvironment >()).
- getRootElement();
- } catch (NoDescriptionException &) {
- } catch (css::deployment::DeploymentException & e) {
- throw RuntimeException(
- (OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.deployment.DeploymentException: ")) +
- e.Message),
- static_cast< OWeakObject * >(this));
- }
- return DescriptionInfoset(getMyBackend()->getComponentContext(), root);
+ return dp_misc::getDescriptionInfoset(m_url_expanded);
}
bool BackendImpl::PackageImpl::checkPlatform(
@@ -561,14 +623,11 @@ bool BackendImpl::PackageImpl::checkPlatform(
bool BackendImpl::PackageImpl::checkDependencies(
css::uno::Reference< css::ucb::XCommandEnvironment > const & environment,
- ExtensionDescription const & description)
+ DescriptionInfoset const & description)
{
css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >
- unsatisfied(
- dp_misc::Dependencies::check(
- DescriptionInfoset(
- getMyBackend()->getComponentContext(),
- description.getRootElement())));
+ unsatisfied(dp_misc::Dependencies::check(description));
+
if (unsatisfied.getLength() == 0) {
return true;
} else {
@@ -590,7 +649,7 @@ bool BackendImpl::PackageImpl::checkDependencies(
::sal_Bool BackendImpl::PackageImpl::checkLicense(
css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv,
- ExtensionDescription const & desc, bool bInstalled, OUString const & aContextName)
+ DescriptionInfoset const & info, bool alreadyInstalled)
throw (css::deployment::DeploymentException,
css::ucb::CommandFailedException,
css::ucb::CommandAbortedException,
@@ -598,7 +657,6 @@ bool BackendImpl::PackageImpl::checkDependencies(
{
try
{
- DescriptionInfoset info = getDescriptionInfoset();
::boost::optional<SimpleLicenseAttributes> simplLicAttr
= info.getSimpleLicenseAttributes();
if (! simplLicAttr)
@@ -610,7 +668,7 @@ bool BackendImpl::PackageImpl::checkDependencies(
if (sLic.getLength() == 0)
throw css::deployment::DeploymentException(
OUSTR("Could not obtain path to license. Possible error in description.xml"), 0, Any());
- OUString sHref = desc.getExtensionRootUrl() + OUSTR("/") + sLic;
+ OUString sHref = m_url_expanded + OUSTR("/") + sLic;
OUString sLicense = getTextFromURL(xCmdEnv, sHref);
////determine who has to agree to the license
//check correct value for attribute
@@ -618,41 +676,21 @@ bool BackendImpl::PackageImpl::checkDependencies(
throw css::deployment::DeploymentException(
OUSTR("Could not obtain attribute simple-lincense@accept-by or it has no valid value"), 0, Any());
- //If if @accept-by="user" then every user needs to accept the license before it can be installed.
- //Therefore we must prevent the installation as shared extension unless suppress-if-required="true"
- OSL_ASSERT(aContextName.getLength());
- if (simplLicAttr->acceptBy.equals(OUSTR("user")) && aContextName.equals(OUSTR("shared")))
- {
- css::deployment::LicenseIndividualAgreementException
- exc = css::deployment::LicenseIndividualAgreementException(
- OUString(), 0, m_name, simplLicAttr->suppressIfRequired);
-
- bool approve = false;
- bool abort = false;
- if (! interactContinuation(
- Any(exc), task::XInteractionApprove::static_type(), xCmdEnv, &approve, &abort ))
- throw css::deployment::DeploymentException(
- OUSTR("Could not interact with user."), 0, Any());
- if (abort == true)
- return false;
-
- //If the unopkg --suppress-license was used and simplLicAttr->suppressIfRequired == true,
- //then the user implicitely accepts the license
- }
//Only use interaction if there is no version of this extension already installed
//and the suppress-on-update flag is not set for the new extension
- // bInstalled | bSuppressOnUpdate | show license
+ // alreadyInstalled | bSuppressOnUpdate | show license
//----------------------------------------
// 0 | 0 | 1
// 0 | 1 | 1
// 1 | 0 | 1
// 1 | 1 | 0
- if ( !(bInstalled && simplLicAttr->suppressOnUpdate))
+ if ( !(alreadyInstalled && simplLicAttr->suppressOnUpdate))
{
css::deployment::LicenseException licExc(
- OUString(), 0, m_name, sLicense, simplLicAttr->suppressIfRequired);
+ OUString(), 0, getDisplayName(), sLicense,
+ simplLicAttr->acceptBy);
bool approve = false;
bool abort = false;
if (! interactContinuation(
@@ -684,69 +722,88 @@ bool BackendImpl::PackageImpl::checkDependencies(
}
}
-::sal_Bool BackendImpl::PackageImpl::checkPrerequisites(
+::sal_Int32 BackendImpl::PackageImpl::checkPrerequisites(
const css::uno::Reference< css::task::XAbortChannel >&,
const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv,
- sal_Bool bInstalled, OUString const & aContextName)
+ sal_Bool alreadyInstalled)
throw (css::deployment::DeploymentException,
- css::ucb::CommandFailedException,
- css::ucb::CommandAbortedException,
- css::uno::RuntimeException)
+ css::deployment::ExtensionRemovedException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::uno::RuntimeException)
{
- std::auto_ptr<ExtensionDescription> spDescription;
- try {
- spDescription.reset(
- new ExtensionDescription(
- getMyBackend()->getComponentContext(),
- m_url_expanded,
- xCmdEnv));
- } catch (NoDescriptionException& ) {
- return sal_True;
- }
- return checkPlatform(xCmdEnv)
- && checkDependencies(xCmdEnv, *spDescription)
- && checkLicense(xCmdEnv, *spDescription, bInstalled, aContextName);
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+ DescriptionInfoset info = getDescriptionInfoset();
+ if (!info.hasDescription())
+ return 0;
+
+ //always return LICENSE as long as the user did not accept the license
+ //so that XExtensonManager::checkPrerequisitesAndEnable will again
+ //check the license
+ if (!checkPlatform(xCmdEnv))
+ return deployment::Prerequisites::PLATFORM |
+ deployment::Prerequisites::LICENSE;
+ else if(!checkDependencies(xCmdEnv, info))
+ return deployment::Prerequisites::DEPENDENCIES |
+ deployment::Prerequisites::LICENSE;
+ else if(!checkLicense(xCmdEnv, info, alreadyInstalled))
+ return deployment::Prerequisites::LICENSE;
+ else
+ return 0;
}
::sal_Bool BackendImpl::PackageImpl::checkDependencies(
const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv )
- throw (css::deployment::DeploymentException,
- css::ucb::CommandFailedException,
- css::uno::RuntimeException)
+ throw (deployment::DeploymentException,
+ deployment::ExtensionRemovedException,
+ ucb::CommandFailedException,
+ RuntimeException)
{
- std::auto_ptr<ExtensionDescription> spDescription;
- try {
- spDescription.reset(
- new ExtensionDescription( getMyBackend()->getComponentContext(), m_url_expanded, xCmdEnv ));
- } catch (NoDescriptionException& ) {
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+ DescriptionInfoset info = getDescriptionInfoset();
+ if (!info.hasDescription())
return sal_True;
- }
- return checkDependencies(xCmdEnv, *spDescription);
+
+ return checkDependencies(xCmdEnv, info);
}
beans::Optional<OUString> BackendImpl::PackageImpl::getIdentifier()
throw (RuntimeException)
{
+ OUString identifier;
+ if (m_bRemoved)
+ identifier = m_identifier;
+ else
+ identifier = dp_misc::generateIdentifier(
+ getDescriptionInfoset().getIdentifier(), m_name);
+
return beans::Optional<OUString>(
- true,
- dp_misc::generateIdentifier(
- getDescriptionInfoset().getIdentifier(), m_name));
+ true, identifier);
}
-OUString BackendImpl::PackageImpl::getVersion() throw (RuntimeException)
+OUString BackendImpl::PackageImpl::getVersion()
+ throw (deployment::ExtensionRemovedException, RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
return getDescriptionInfoset().getVersion();
}
Sequence<OUString> BackendImpl::PackageImpl::getUpdateInformationURLs()
- throw (RuntimeException)
+ throw (deployment::ExtensionRemovedException, RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
return getDescriptionInfoset().getUpdateInformationUrls();
}
beans::StringPair BackendImpl::PackageImpl::getPublisherInfo()
- throw (RuntimeException)
+ throw (deployment::ExtensionRemovedException, RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
::std::pair< OUString, OUString > aInfo = getDescriptionInfoset().getLocalizedPublisherNameAndURL();
beans::StringPair aStrPair( aInfo.first, aInfo.second );
return aStrPair;
@@ -754,8 +811,11 @@ beans::StringPair BackendImpl::PackageImpl::getPublisherInfo()
//______________________________________________________________________________
uno::Reference< graphic::XGraphic > BackendImpl::PackageImpl::getIcon( sal_Bool bHighContrast )
- throw ( RuntimeException )
+ throw (deployment::ExtensionRemovedException, RuntimeException )
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+
uno::Reference< graphic::XGraphic > xGraphic;
OUString aIconURL = getDescriptionInfoset().getIconURL( bHighContrast );
@@ -785,14 +845,16 @@ uno::Reference< graphic::XGraphic > BackendImpl::PackageImpl::getIcon( sal_Bool
void BackendImpl::PackageImpl::processPackage_(
::osl::ResettableMutexGuard &,
bool doRegisterPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const & abortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv )
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
{
const Sequence< Reference<deployment::XPackage> > bundle(
getBundle( abortChannel.get(), xCmdEnv ) );
if (doRegisterPackage)
{
+ ExtensionBackendDb::Data data;
const sal_Int32 len = bundle.getLength();
for ( sal_Int32 pos = 0; pos < len; ++pos )
{
@@ -802,12 +864,12 @@ void BackendImpl::PackageImpl::processPackage_(
xPackage->createAbortChannel() );
AbortChannel::Chain chain( abortChannel, xSubAbortChannel );
try {
- xPackage->registerPackage( xSubAbortChannel, xCmdEnv );
+ xPackage->registerPackage( startup, xSubAbortChannel, xCmdEnv );
}
catch (RuntimeException &) {
throw;
}
- catch (CommandAbortedException &) {
+ catch (ucb::CommandAbortedException &) {
throw;
}
catch (Exception &) {
@@ -845,7 +907,7 @@ void BackendImpl::PackageImpl::processPackage_(
catch (RuntimeException &) {
throw;
}
- catch (CommandAbortedException &) {
+ catch (ucb::CommandAbortedException &) {
throw;
}
catch (Exception &) {
@@ -862,7 +924,7 @@ void BackendImpl::PackageImpl::processPackage_(
deployment::DeploymentException dpExc;
if (exc >>= dpExc) {
- throw CommandFailedException(
+ throw ucb::CommandFailedException(
dpExc.Message, dpExc.Context, dpExc.Cause );
}
else {
@@ -870,7 +932,11 @@ void BackendImpl::PackageImpl::processPackage_(
::cppu::throwException(exc);
}
}
+ data.items.push_back(
+ ::std::make_pair(xPackage->getURL(),
+ xPackage->getPackageType()->getMediaType()));
}
+ getMyBackend()->addDataToDb(getURL(), data);
}
else
{
@@ -888,7 +954,7 @@ void BackendImpl::PackageImpl::processPackage_(
catch (RuntimeException &) {
throw;
}
- catch (CommandAbortedException &) {
+ catch (ucb::CommandAbortedException &) {
throw;
}
catch (Exception &) {
@@ -914,12 +980,17 @@ void BackendImpl::PackageImpl::processPackage_(
// selected
}
}
+ getMyBackend()->deleteDataFromDb(getURL());
}
}
//______________________________________________________________________________
-OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException)
+OUString BackendImpl::PackageImpl::getDescription()
+ throw (deployment::ExtensionRemovedException, RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+
const OUString sRelativeURL(getDescriptionInfoset().getLocalizedDescriptionURL());
OUString sDescription;
if (sRelativeURL.getLength())
@@ -940,9 +1011,14 @@ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException)
//______________________________________________________________________________
void BackendImpl::PackageImpl::exportTo(
OUString const & destFolderURL, OUString const & newTitle,
- sal_Int32 nameClashAction, Reference<XCommandEnvironment> const & xCmdEnv )
- throw (CommandFailedException, CommandAbortedException, RuntimeException)
+ sal_Int32 nameClashAction, Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (ucb::CommandFailedException,
+ deployment::ExtensionRemovedException,
+ ucb::CommandAbortedException, RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+
::ucbhelper::Content sourceContent( m_url_expanded, xCmdEnv );
OUString title(newTitle);
if (title.getLength() == 0)
@@ -952,25 +1028,25 @@ void BackendImpl::PackageImpl::exportTo(
rtl_UriEncodeIgnoreEscapes,
RTL_TEXTENCODING_UTF8 ) ) );
- if (nameClashAction == NameClash::ASK)
+ if (nameClashAction == ucb::NameClash::ASK)
{
if (create_ucb_content(
0, destURL, xCmdEnv, false /* no throw */ )) {
bool replace = false, abort = false;
if (! interactContinuation(
- Any( NameClashResolveRequest(
+ Any( ucb::NameClashResolveRequest(
OUSTR("file already exists: ") + title,
static_cast<OWeakObject *>(this),
task::InteractionClassification_QUERY,
destFolderURL, title, OUString() ) ),
- XInteractionReplaceExistingData::static_type(), xCmdEnv,
+ ucb::XInteractionReplaceExistingData::static_type(), xCmdEnv,
&replace, &abort ) || !replace) {
return;
}
}
}
- else if (nameClashAction != NameClash::OVERWRITE) {
- throw CommandFailedException(
+ else if (nameClashAction != ucb::NameClash::OVERWRITE) {
+ throw ucb::CommandFailedException(
OUSTR("unsupported nameClashAction!"),
static_cast<OWeakObject *>(this), Any() );
}
@@ -996,11 +1072,11 @@ void BackendImpl::PackageImpl::exportTo(
while (xResultSet->next())
{
::ucbhelper::Content subContent(
- Reference<XContentAccess>(
+ Reference<ucb::XContentAccess>(
xResultSet, UNO_QUERY_THROW )->queryContent(), xCmdEnv );
if (! destFolderContent.transferContent(
subContent, ::ucbhelper::InsertOperation_COPY,
- OUString(), NameClash::OVERWRITE ))
+ OUString(), ucb::NameClash::OVERWRITE ))
throw RuntimeException( OUSTR("UCB transferContent() failed!"),
static_cast<OWeakObject *>(this) );
progress.update( Any() ); // animating progress bar
@@ -1108,7 +1184,7 @@ void BackendImpl::PackageImpl::exportTo(
if (! metainfFolderContent.transferContent(
manifestContent, ::ucbhelper::InsertOperation_COPY,
- OUString(), NameClash::OVERWRITE ))
+ OUString(), ucb::NameClash::OVERWRITE ))
throw RuntimeException( OUSTR("UCB transferContent() failed!"),
static_cast<OWeakObject *>(this) );
}
@@ -1117,7 +1193,7 @@ void BackendImpl::PackageImpl::exportTo(
try {
destFolderContent.executeCommand( OUSTR("flush"), Any() );
}
- catch (UnsupportedCommandException &) {
+ catch (ucb::UnsupportedCommandException &) {
}
}
@@ -1130,67 +1206,76 @@ sal_Bool BackendImpl::PackageImpl::isBundle() throw (RuntimeException)
//______________________________________________________________________________
Sequence< Reference<deployment::XPackage> > BackendImpl::PackageImpl::getBundle(
Reference<task::XAbortChannel> const & xAbortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv )
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
throw (deployment::DeploymentException,
- CommandFailedException, CommandAbortedException,
+ ucb::CommandFailedException, ucb::CommandAbortedException,
lang::IllegalArgumentException, RuntimeException)
{
Sequence< Reference<deployment::XPackage> > * pBundle = m_pBundle;
if (pBundle == 0)
{
t_packagevec bundle;
- try {
- if (m_legacyBundle)
- {
- // .zip legacy packages allow script.xlb, dialog.xlb in bundle
- // root folder:
- OUString mediaType;
- // probe for script.xlb:
- if (create_ucb_content(
- 0, makeURL( m_url_expanded, OUSTR("script.xlb") ),
- xCmdEnv, false /* no throw */ )) {
- mediaType = OUSTR("application/vnd.sun.star.basic-library");
+ if (m_bRemoved)
+ {
+ bundle = getPackagesFromDb(xCmdEnv);
+ }
+ else
+ {
+ try {
+ if (m_legacyBundle)
+ {
+ // .zip legacy packages allow script.xlb, dialog.xlb in bundle
+ // root folder:
+ OUString mediaType;
+ // probe for script.xlb:
+ if (create_ucb_content(
+ 0, makeURL( m_url_expanded, OUSTR("script.xlb") ),
+ xCmdEnv, false /* no throw */ )) {
+ mediaType = OUSTR("application/vnd.sun.star.basic-library");
+ }
+ // probe for dialog.xlb:
+ else if (create_ucb_content(
+ 0, makeURL( m_url_expanded, OUSTR("dialog.xlb") ),
+ xCmdEnv, false /* no throw */ ))
+ mediaType = OUSTR("application/vnd.sun.star."
+ "dialog-library");
+
+ if (mediaType.getLength() > 0) {
+ const Reference<deployment::XPackage> xPackage(
+ bindBundleItem( getURL(), mediaType, false, OUString(),
+ xCmdEnv ) );
+ if (xPackage.is())
+ bundle.push_back( xPackage );
+ // continue scanning:
+ }
+ scanLegacyBundle( bundle, getURL(),
+ AbortChannel::get(xAbortChannel), xCmdEnv );
}
- // probe for dialog.xlb:
- else if (create_ucb_content(
- 0, makeURL( m_url_expanded, OUSTR("dialog.xlb") ),
- xCmdEnv, false /* no throw */ ))
- mediaType = OUSTR("application/vnd.sun.star."
- "dialog-library");
-
- if (mediaType.getLength() > 0) {
- const Reference<deployment::XPackage> xPackage(
- bindBundleItem( getURL(), mediaType, xCmdEnv ) );
- if (xPackage.is())
- bundle.push_back( xPackage );
- // continue scanning:
+ else
+ {
+ // .oxt:
+ scanBundle( bundle, AbortChannel::get(xAbortChannel), xCmdEnv );
}
- scanLegacyBundle( bundle, getURL(),
- AbortChannel::get(xAbortChannel), xCmdEnv );
+
}
- else
- {
- // .oxt:
- scanBundle( bundle, AbortChannel::get(xAbortChannel), xCmdEnv );
+ catch (RuntimeException &) {
+ throw;
+ }
+ catch (ucb::CommandFailedException &) {
+ throw;
+ }
+ catch (ucb::CommandAbortedException &) {
+ throw;
+ }
+ catch (deployment::DeploymentException &) {
+ throw;
+ }
+ catch (Exception &) {
+ Any exc( ::cppu::getCaughtException() );
+ throw deployment::DeploymentException(
+ OUSTR("error scanning bundle: ") + getURL(),
+ static_cast<OWeakObject *>(this), exc );
}
- }
- catch (RuntimeException &) {
- throw;
- }
- catch (CommandFailedException &) {
- throw;
- }
- catch (CommandAbortedException &) {
- throw;
- }
- catch (deployment::DeploymentException &) {
- throw;
- }
- catch (Exception &) {
- Any exc( ::cppu::getCaughtException() );
- throw deployment::DeploymentException(
- OUSTR("error scanning bundle: ") + getURL(),
- static_cast<OWeakObject *>(this), exc );
}
// sort: schema before config data, typelibs before components:
@@ -1257,7 +1342,8 @@ inline bool isBundle_( OUString const & mediaType )
//______________________________________________________________________________
Reference<deployment::XPackage> BackendImpl::PackageImpl::bindBundleItem(
OUString const & url, OUString const & mediaType,
- Reference<XCommandEnvironment> const & xCmdEnv,
+ sal_Bool bRemoved, OUString const & identifier,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv,
bool notifyDetectionError )
{
// ignore any nested bundles:
@@ -1267,13 +1353,13 @@ Reference<deployment::XPackage> BackendImpl::PackageImpl::bindBundleItem(
Reference<deployment::XPackage>xPackage;
try {
xPackage.set( getMyBackend()->m_xRootRegistry->bindPackage(
- url, mediaType, xCmdEnv ) );
+ url, mediaType, bRemoved, identifier, xCmdEnv ) );
OSL_ASSERT( xPackage.is() );
}
catch (RuntimeException &) {
throw;
}
- catch (CommandFailedException &) {
+ catch (ucb::CommandFailedException &) {
// ignore already handled error
}
catch (Exception &) {
@@ -1306,7 +1392,7 @@ Reference<deployment::XPackage> BackendImpl::PackageImpl::bindBundleItem(
void BackendImpl::PackageImpl::scanBundle(
t_packagevec & bundle,
::rtl::Reference<AbortChannel> const & abortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv )
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
{
OSL_ASSERT( !m_legacyBundle );
@@ -1403,7 +1489,7 @@ void BackendImpl::PackageImpl::scanBundle(
if (bundle.end() == std::find_if(bundle.begin(), bundle.end(), XPackage_eq(url)))
{
const Reference<deployment::XPackage> xPackage(
- bindBundleItem( url, mediaType, xCmdEnv ) );
+ bindBundleItem( url, mediaType, false, OUString(), xCmdEnv ) );
if (xPackage.is())
bundle.push_back( xPackage );
}
@@ -1442,7 +1528,7 @@ void BackendImpl::PackageImpl::scanLegacyBundle(
t_packagevec & bundle,
OUString const & url,
::rtl::Reference<AbortChannel> const & abortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv,
bool skip_registration )
{
::ucbhelper::Content ucbContent( url, xCmdEnv );
@@ -1478,8 +1564,8 @@ void BackendImpl::PackageImpl::scanLegacyBundle(
OUString mediaType;
const Reference<deployment::XPackage> xPackage(
- bindBundleItem( path, OUString() /* detect */, xCmdEnv,
- false /* ignore detection errors */ ) );
+ bindBundleItem( path, OUString() /* detect */, false, OUString(),
+ xCmdEnv, false /* ignore detection errors */ ) );
if (xPackage.is()) {
const Reference<deployment::XPackageTypeInfo> xPackageType(
xPackage->getPackageType() );
@@ -1514,8 +1600,12 @@ void BackendImpl::PackageImpl::scanLegacyBundle(
}
}
-OUString BackendImpl::PackageImpl::getDisplayName() throw (RuntimeException)
+OUString BackendImpl::PackageImpl::getDisplayName()
+ throw (deployment::ExtensionRemovedException, RuntimeException)
{
+ if (m_bRemoved)
+ throw deployment::ExtensionRemovedException();
+
OUString sName = getDescriptionInfoset().getLocalizedDisplayName();
if (sName.getLength() == 0)
return m_displayName;
@@ -1523,6 +1613,24 @@ OUString BackendImpl::PackageImpl::getDisplayName() throw (RuntimeException)
return sName;
}
+::std::vector<Reference<deployment::XPackage> >
+BackendImpl::PackageImpl::getPackagesFromDb(
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+{
+ ::std::vector<Reference<deployment::XPackage> > retVector;
+
+ typedef ::std::vector< ::std::pair<OUString, OUString> >::const_iterator ITC;
+ for (ITC i = m_dbData.items.begin(); i != m_dbData.items.end(); i++)
+ {
+ Reference<deployment::XPackage> xExtension =
+ bindBundleItem(i->first, i->second, true, m_identifier, xCmdEnv);
+ OSL_ASSERT(xExtension.is());
+ retVector.push_back(xExtension);
+ }
+
+ return retVector;
+}
+
} // anon namespace
//==============================================================================
diff --git a/desktop/source/deployment/registry/package/makefile.mk b/desktop/source/deployment/registry/package/makefile.mk
index ccadc2070301..203ce176d289 100644
--- a/desktop/source/deployment/registry/package/makefile.mk
+++ b/desktop/source/deployment/registry/package/makefile.mk
@@ -41,7 +41,7 @@ INCPRE += ..$/..$/inc
SLOFILES = \
$(SLO)$/dp_package.obj \
- $(SLO)$/dp_description.obj
+ $(SLO)$/dp_extbackenddb.obj
.INCLUDE : ..$/..$/target.pmk
.INCLUDE : target.mk
diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx
index 4af0cbb84130..edeae256cbaf 100644
--- a/desktop/source/deployment/registry/script/dp_script.cxx
+++ b/desktop/source/deployment/registry/script/dp_script.cxx
@@ -39,12 +39,12 @@
#include "comphelper/servicedecl.hxx"
#include "svl/inettype.hxx"
#include "com/sun/star/util/XUpdatable.hpp"
-#include "com/sun/star/script/XLibraryContainer.hpp"
+#include "com/sun/star/script/XLibraryContainer3.hpp"
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
-#include <com/sun/star/uri/XVndSunStarExpandUrl.hpp>
#include <memory>
+#include "dp_scriptbackenddb.hxx"
using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -80,6 +80,7 @@ class BackendImpl : public t_helper
virtual void processPackage_(
::osl::ResettableMutexGuard & guard,
bool registerPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const & abortChannel,
Reference<XCommandEnvironment> const & xCmdEnv );
@@ -88,24 +89,30 @@ class BackendImpl : public t_helper
::rtl::Reference<BackendImpl> const & myBackend,
OUString const & url,
Reference<XCommandEnvironment> const &xCmdEnv,
- OUString const & scriptURL, OUString const & dialogURL );
+ OUString const & scriptURL, OUString const & dialogURL,
+ bool bRemoved, OUString const & identifier);
};
friend class PackageImpl;
// PackageRegistryBackend
virtual Reference<deployment::XPackage> bindPackage_(
OUString const & url, OUString const & mediaType,
+ sal_Bool bRemoved, OUString const & identifier,
Reference<XCommandEnvironment> const & xCmdEnv );
- rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage );
- rtl::OUString expandURL( const rtl::OUString& aURL );
- Reference< ucb::XSimpleFileAccess > getFileAccess( void );
- Reference< ucb::XSimpleFileAccess > m_xSFA;
+ void addDataToDb(OUString const & url);
+ void deleteDataFromDb(OUString const & url);
+ bool isRegisteredInDb(OUString const & url);
+
+
+
+// Reference< ucb::XSimpleFileAccess > getFileAccess( void );
+// Reference< ucb::XSimpleFileAccess > m_xSFA;
const Reference<deployment::XPackageTypeInfo> m_xBasicLibTypeInfo;
const Reference<deployment::XPackageTypeInfo> m_xDialogLibTypeInfo;
Sequence< Reference<deployment::XPackageTypeInfo> > m_typeInfos;
-
+ std::auto_ptr<ScriptBackendDb> m_backendDb;
public:
BackendImpl( Sequence<Any> const & args,
Reference<XComponentContext> const & xComponentContext );
@@ -123,11 +130,12 @@ BackendImpl::PackageImpl::PackageImpl(
::rtl::Reference<BackendImpl> const & myBackend,
OUString const & url,
Reference<XCommandEnvironment> const &xCmdEnv,
- OUString const & scriptURL, OUString const & dialogURL )
+ OUString const & scriptURL, OUString const & dialogURL, bool bRemoved,
+ OUString const & identifier)
: Package( myBackend.get(), url,
OUString(), OUString(), // will be late-initialized
scriptURL.getLength() > 0 ? myBackend->m_xBasicLibTypeInfo
- : myBackend->m_xDialogLibTypeInfo ),
+ : myBackend->m_xDialogLibTypeInfo, bRemoved, identifier),
m_scriptURL( scriptURL ),
m_dialogURL( dialogURL )
{
@@ -168,6 +176,33 @@ BackendImpl::BackendImpl(
m_typeInfos[ 1 ] = m_xDialogLibTypeInfo;
OSL_ASSERT( ! transientMode() );
+
+ if (!transientMode())
+ {
+ OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml"));
+ m_backendDb.reset(
+ new ScriptBackendDb(getComponentContext(), dbFile));
+ }
+
+}
+void BackendImpl::addDataToDb(OUString const & url)
+{
+ if (m_backendDb.get())
+ m_backendDb->addEntry(url);
+}
+
+bool BackendImpl::isRegisteredInDb(OUString const & url)
+{
+ bool registered = false;
+ if (m_backendDb.get())
+ registered = m_backendDb->getEntry(url);
+ return registered;
+}
+
+void BackendImpl::deleteDataFromDb(OUString const & url)
+{
+ if (m_backendDb.get())
+ m_backendDb->removeEntry(url);
}
// XUpdatable
@@ -189,6 +224,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException)
//______________________________________________________________________________
Reference<deployment::XPackage> BackendImpl::bindPackage_(
OUString const & url, OUString const & mediaType_,
+ sal_Bool bRemoved, OUString const & identifier,
Reference<XCommandEnvironment> const & xCmdEnv )
{
OUString mediaType( mediaType_ );
@@ -222,22 +258,31 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
{
if (type.EqualsIgnoreCaseAscii("application"))
{
+ OUString dialogURL( makeURL( url, OUSTR("dialog.xlb") ) );
+ if (! create_ucb_content(
+ 0, dialogURL, xCmdEnv, false /* no throw */ )) {
+ dialogURL = OUString();
+ }
+
if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.basic-library"))
{
- OUString dialogURL( makeURL( url, OUSTR("dialog.xlb") ) );
+ OUString scriptURL( makeURL( url, OUSTR("script.xlb")));
if (! create_ucb_content(
- 0, dialogURL, xCmdEnv, false /* no throw */ )) {
- dialogURL = OUString();
+ 0, scriptURL, xCmdEnv, false /* no throw */ )) {
+ scriptURL = OUString();
}
- return new PackageImpl( this, url, xCmdEnv,
- makeURL( url, OUSTR("script.xlb") ),
- dialogURL );
+
+ return new PackageImpl(
+ this, url, xCmdEnv, scriptURL,
+ dialogURL, bRemoved, identifier);
}
else if (subType.EqualsIgnoreCaseAscii(
"vnd.sun.star.dialog-library")) {
- return new PackageImpl( this, url, xCmdEnv,
- OUString() /* no script lib */,
- makeURL( url, OUSTR("dialog.xlb") ) );
+ return new PackageImpl(
+ this, url, xCmdEnv,
+ OUString() /* no script lib */,
+ dialogURL,
+ bRemoved, identifier);
}
}
}
@@ -247,90 +292,6 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
static_cast<sal_Int16>(-1) );
}
-rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage )
-{
- rtl::OUString aRetURL;
- if( !xPackage.is() )
- return aRetURL;
- rtl::OUString aHelpURL = xPackage->getURL();
- aRetURL = expandURL( aHelpURL );
- aRetURL += rtl::OUString::createFromAscii( "/RegisteredFlag" );
- return aRetURL;
-}
-
-rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL )
-{
- static Reference< util::XMacroExpander > xMacroExpander;
- static Reference< uri::XUriReferenceFactory > xFac;
-
- if( !xMacroExpander.is() || !xFac.is() )
- {
- Reference<XComponentContext> const & xContext = getComponentContext();
- if( xContext.is() )
- {
- xFac = Reference< uri::XUriReferenceFactory >(
- xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii(
- "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY );
- }
- if( !xFac.is() )
- {
- throw RuntimeException(
- ::rtl::OUString::createFromAscii(
- "dp_registry::backend::help::BackendImpl::expandURL(), "
- "could not instatiate UriReferenceFactory." ),
- Reference< XInterface >() );
- }
-
- xMacroExpander = Reference< util::XMacroExpander >(
- xContext->getValueByName(
- ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ),
- UNO_QUERY_THROW );
- }
-
- rtl::OUString aRetURL = aURL;
- if( xMacroExpander.is() )
- {
- Reference< uri::XUriReference > uriRef;
- for (;;)
- {
- uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY );
- if ( uriRef.is() )
- {
- Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY );
- if( !sxUri.is() )
- break;
-
- aRetURL = sxUri->expand( xMacroExpander );
- }
- }
- }
- return aRetURL;
-}
-
-Reference< ucb::XSimpleFileAccess > BackendImpl::getFileAccess( void )
-{
- if( !m_xSFA.is() )
- {
- Reference<XComponentContext> const & xContext = getComponentContext();
- if( xContext.is() )
- {
- m_xSFA = Reference< ucb::XSimpleFileAccess >(
- xContext->getServiceManager()->createInstanceWithContext(
- rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ),
- xContext ), UNO_QUERY );
- }
- if( !m_xSFA.is() )
- {
- throw RuntimeException(
- ::rtl::OUString::createFromAscii(
- "dp_registry::backend::help::BackendImpl::getFileAccess(), "
- "could not instatiate SimpleFileAccess." ),
- Reference< XInterface >() );
- }
- }
- return m_xSFA;
-}
-
//##############################################################################
// Package
@@ -359,20 +320,18 @@ BackendImpl::PackageImpl::isRegistered_(
BackendImpl * that = getMyBackend();
Reference< deployment::XPackage > xThisPackage( this );
- rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage );
-
- Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess();
- bool bReg = xSFA->exists( aRegisteredFlagFile );
+ bool registered = that->isRegisteredInDb(getURL());
return beans::Optional< beans::Ambiguous<sal_Bool> >(
true /* IsPresent */,
- beans::Ambiguous<sal_Bool>( bReg, false /* IsAmbiguous */ ) );
+ beans::Ambiguous<sal_Bool>( registered, false /* IsAmbiguous */ ) );
}
//______________________________________________________________________________
void BackendImpl::PackageImpl::processPackage_(
::osl::ResettableMutexGuard &,
bool doRegisterPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const &,
Reference<XCommandEnvironment> const & xCmdEnv )
{
@@ -381,15 +340,13 @@ void BackendImpl::PackageImpl::processPackage_(
BackendImpl * that = getMyBackend();
Reference< deployment::XPackage > xThisPackage( this );
- rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage );
- Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess();
Reference<XComponentContext> const & xComponentContext = that->getComponentContext();
bool bScript = (m_scriptURL.getLength() > 0);
- Reference<css::script::XLibraryContainer> xScriptLibs;
+ Reference<css::script::XLibraryContainer3> xScriptLibs;
bool bDialog = (m_dialogURL.getLength() > 0);
- Reference<css::script::XLibraryContainer> xDialogLibs;
+ Reference<css::script::XLibraryContainer3> xDialogLibs;
bool bRunning = office_is_running();
if( bRunning )
@@ -410,52 +367,121 @@ void BackendImpl::PackageImpl::processPackage_(
xComponentContext ), UNO_QUERY_THROW );
}
}
-
+ bool bRegistered = getMyBackend()->isRegisteredInDb(getURL());
if( !doRegisterPackage )
{
- if( xSFA->exists( aRegisteredFlagFile ) )
+ //We cannot just call removeLibrary(name) because this could remove a
+ //script which was added by an extension in a different repository. For
+ //example, extension foo is contained in the bundled repository and then
+ //the user adds it it to the user repository. The extension manager will
+ //then register the new script and revoke the script from the bundled
+ //extension. removeLibrary(name) would now remove the script from the
+ //user repository. That is, the script of the newly added user extension does
+ //not work anymore. Therefore we must check if the currently active
+ //script comes in fact from the currently processed extension.
+
+ if (bRegistered)
{
- xSFA->kill( aRegisteredFlagFile );
-
- if( bScript && xScriptLibs.is() && xScriptLibs->hasByName( m_name ) )
- xScriptLibs->removeLibrary( m_name );
+ //we also prevent and live deployment at startup
+ if (!isRemoved() && !startup)
+ {
+ if (bScript && xScriptLibs.is() && xScriptLibs->hasByName(m_name))
+ {
+ const OUString sScriptUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name);
+ if (sScriptUrl.equals(m_scriptURL))
+ xScriptLibs->removeLibrary(m_name);
+ }
- if( bDialog && xDialogLibs.is() && xDialogLibs->hasByName( m_dialogName ) )
- xDialogLibs->removeLibrary( m_dialogName );
+ if (bDialog && xDialogLibs.is() && xDialogLibs->hasByName(m_dialogName))
+ {
+ const OUString sDialogUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName);
+ if (sDialogUrl.equals(m_dialogURL))
+ xDialogLibs->removeLibrary(m_dialogName);
+ }
+ }
+ getMyBackend()->deleteDataFromDb(getURL());
+ return;
}
- return;
}
-
- if( xSFA->exists( aRegisteredFlagFile ) )
+ if (bRegistered)
return; // Already registered
// Update LibraryContainer
bool bScriptSuccess = false;
const bool bReadOnly = false;
- if( bScript && xScriptLibs.is() && !xScriptLibs->hasByName( m_name ) )
- {
- xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly );
- bScriptSuccess = xScriptLibs->hasByName( m_name );
- }
bool bDialogSuccess = false;
- if( bDialog && xDialogLibs.is() && !xDialogLibs->hasByName( m_dialogName ) )
+ if (!startup)
{
- xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly );
- bDialogSuccess = xDialogLibs->hasByName( m_dialogName );
- }
+ //If there is a bundled extension, and the user installes the same extension
+ //then the script from the bundled extension must be removed. If this does not work
+ //then live deployment does not work for scripts.
+ if (bScript && xScriptLibs.is())
+ {
+ bool bCanAdd = true;
+ if (xScriptLibs->hasByName(m_name))
+ {
+ const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name);
+ //We assume here that library names in extensions are unique, which may not be the case
+ //ToDo: If the script exist in another extension, then both extensions must have the
+ //same id
+ if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"))
+ || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE"))
+ || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS")))
+ {
+ xScriptLibs->removeLibrary(m_name);
+ bCanAdd = true;
+ }
+ else
+ {
+ bCanAdd = false;
+ }
+ }
+
+ if (bCanAdd)
+ {
+ xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly );
+ bScriptSuccess = xScriptLibs->hasByName( m_name );
+ }
+ }
+
+
+ if (bDialog && xDialogLibs.is())
+ {
+ bool bCanAdd = true;
+ if (xDialogLibs->hasByName(m_dialogName))
+ {
+ const OUString sOriginalUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName);
+ //We assume here that library names in extensions are unique, which may not be the case
+ //ToDo: If the script exist in another extension, then both extensions must have the
+ //same id
+ if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"))
+ || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE"))
+ || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS")))
+ {
+ xDialogLibs->removeLibrary(m_dialogName);
+ bCanAdd = true;
+ }
+ else
+ {
+ bCanAdd = false;
+ }
+ }
+ if (bCanAdd)
+ {
+ xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly );
+ bDialogSuccess = xDialogLibs->hasByName(m_dialogName);
+ }
+ }
+ }
bool bSuccess = bScript || bDialog; // Something must have happened
- if( bRunning )
+ if( bRunning && !startup)
if( (bScript && !bScriptSuccess) || (bDialog && !bDialogSuccess) )
bSuccess = false;
- if( bSuccess && !xSFA->exists( aRegisteredFlagFile ) )
- {
- Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile );
- if( xOutputStream.is() )
- xOutputStream->closeOutput();
- }
+ if (bSuccess)
+ getMyBackend()->addDataToDb(getURL());
}
} // anon namespace
diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx
new file mode 100644
index 000000000000..ce0d3029084d
--- /dev/null
+++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * 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: dp_package.cxx,v $
+ * $Revision: 1.34.16.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 "rtl/string.h"
+#include "cppuhelper/exc_hlp.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/xml/dom/XDocument.hpp"
+#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
+#include "dp_misc.h"
+#include "dp_scriptbackenddb.hxx"
+
+
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/script-registry/2010"
+#define NS_PREFIX "script"
+#define ROOT_ELEMENT_NAME "script-backend-db"
+#define KEY_ELEMENT_NAME "script"
+
+namespace dp_registry {
+namespace backend {
+namespace script {
+
+ScriptBackendDb::ScriptBackendDb(
+ Reference<XComponentContext> const & xContext,
+ ::rtl::OUString const & url):RegisteredDb(xContext, url)
+{
+
+}
+
+OUString ScriptBackendDb::getDbNSName()
+{
+ return OUSTR(EXTENSION_REG_NS);
+}
+
+OUString ScriptBackendDb::getNSPrefix()
+{
+ return OUSTR(NS_PREFIX);
+}
+
+OUString ScriptBackendDb::getRootElementName()
+{
+ return OUSTR(ROOT_ELEMENT_NAME);
+}
+
+OUString ScriptBackendDb::getKeyElementName()
+{
+ return OUSTR(KEY_ELEMENT_NAME);
+}
+
+
+
+} // namespace executable
+} // namespace backend
+} // namespace dp_registry
+
diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx
new file mode 100644
index 000000000000..9d227f8b64b8
--- /dev/null
+++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * 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: dp_backend.h,v $
+ * $Revision: 1.18 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_SCRIPTBACKENDDB_HXX
+#define INCLUDED_DP_SCRIPTBACKENDDB_HXX
+
+#include "rtl/ustring.hxx"
+#include "dp_backenddb.hxx"
+#include "boost/optional.hpp"
+namespace css = ::com::sun::star;
+
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class XComponentContext;
+ }
+}}}
+
+namespace dp_registry {
+namespace backend {
+namespace script {
+
+/* The XML file stores the extensions which are currently registered.
+ They will be removed when they are revoked.
+ */
+class ScriptBackendDb: public dp_registry::backend::RegisteredDb
+{
+protected:
+ virtual ::rtl::OUString getDbNSName();
+
+ virtual ::rtl::OUString getNSPrefix();
+
+ virtual ::rtl::OUString getRootElementName();
+
+ virtual ::rtl::OUString getKeyElementName();
+
+
+public:
+
+ ScriptBackendDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url);
+};
+
+
+
+}
+}
+}
+#endif
+
diff --git a/desktop/source/deployment/registry/script/makefile.mk b/desktop/source/deployment/registry/script/makefile.mk
index ae159914a548..708def358021 100644
--- a/desktop/source/deployment/registry/script/makefile.mk
+++ b/desktop/source/deployment/registry/script/makefile.mk
@@ -41,7 +41,8 @@ INCPRE += ..$/..$/inc
SLOFILES = \
$(SLO)$/dp_script.obj \
- $(SLO)$/dp_lib_container.obj
+ $(SLO)$/dp_lib_container.obj \
+ $(SLO)$/dp_scriptbackenddb.obj
.INCLUDE : ..$/..$/target.pmk
.INCLUDE : target.mk
diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx
index 52ced6908bd8..8a4ee1b45fbc 100644
--- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx
+++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx
@@ -77,12 +77,15 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
virtual void processPackage_(
::osl::ResettableMutexGuard & guard,
bool registerPackage,
+ bool startup,
::rtl::Reference<AbortChannel> const & abortChannel,
Reference<XCommandEnvironment> const & xCmdEnv );
public:
- PackageImpl( ::rtl::Reference<BackendImpl> const & myBackend,
- OUString const & url, OUString const & libType );
+ PackageImpl(
+ ::rtl::Reference<BackendImpl> const & myBackend,
+ OUString const & url, OUString const & libType, bool bRemoved,
+ OUString const & identifier);
// XPackage
virtual OUString SAL_CALL getDescription() throw (RuntimeException);
};
@@ -91,6 +94,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
// PackageRegistryBackend
virtual Reference<deployment::XPackage> bindPackage_(
OUString const & url, OUString const & mediaType,
+ sal_Bool bRemoved, OUString const & identifier,
Reference<XCommandEnvironment> const & xCmdEnv );
const Reference<deployment::XPackageTypeInfo> m_xTypeInfo;
@@ -131,9 +135,10 @@ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException)
//______________________________________________________________________________
BackendImpl::PackageImpl::PackageImpl(
::rtl::Reference<BackendImpl> const & myBackend,
- OUString const & url, OUString const & libType )
+ OUString const & url, OUString const & libType, bool bRemoved,
+ OUString const & identifier)
: Package( myBackend.get(), url, OUString(), OUString(),
- myBackend->m_xTypeInfo ),
+ myBackend->m_xTypeInfo, bRemoved, identifier),
m_descr(libType)
{
initPackageHandler();
@@ -217,8 +222,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException)
// PackageRegistryBackend
//______________________________________________________________________________
Reference<deployment::XPackage> BackendImpl::bindPackage_(
- OUString const & url, OUString const & mediaType_,
- Reference<XCommandEnvironment> const & xCmdEnv )
+ OUString const & url, OUString const & mediaType_, sal_Bool bRemoved,
+ OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv )
{
OUString mediaType( mediaType_ );
if (mediaType.getLength() == 0)
@@ -294,7 +299,7 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
dp_misc::TRACE(OUSTR(" BackEnd detected lang = ") + lang + OUSTR("\n"));
dp_misc::TRACE(OUSTR(" for url ") + sParcelDescURL + OUSTR("\n") );
dp_misc::TRACE("******************************\n");
- return new PackageImpl( this, url, sfwkLibType );
+ return new PackageImpl( this, url, sfwkLibType, bRemoved, identifier);
}
}
}
@@ -322,6 +327,10 @@ void BackendImpl::PackageImpl:: initPackageHandler()
{
aContext <<= OUSTR("share");
}
+ else if ( that->m_eContext == CONTEXT_BUNDLED )
+ {
+ aContext <<= OUSTR("bundled");
+ }
else
{
OSL_ASSERT( 0 );
@@ -363,6 +372,7 @@ BackendImpl::PackageImpl::isRegistered_(
void BackendImpl::PackageImpl::processPackage_(
::osl::ResettableMutexGuard &,
bool doRegisterPackage,
+ bool /* startup */,
::rtl::Reference<AbortChannel> const &,
Reference<XCommandEnvironment> const & )
{
diff --git a/desktop/source/deployment/unopkg/unopkg.src b/desktop/source/deployment/unopkg/unopkg.src
index 79c578628676..dc204e265ec6 100644
--- a/desktop/source/deployment/unopkg/unopkg.src
+++ b/desktop/source/deployment/unopkg/unopkg.src
@@ -27,15 +27,10 @@
#include "deployment.hrc"
-String RID_STR_UNOPKG_NO_SHARED_ALLOWED
-{
- Text [ en-US ] = "The option \"--shared\" cannot be used to install the extension \'%NAME\', "
- "because every user has to agree to the license agreement of the extension. The extension will not be installed.";
-};
String RID_STR_UNOPKG_ACCEPT_LIC_1
{
- Text [ en-US ] = "Extension License Agreement:";
+ Text [ en-US ] = "Extension Software License Agreement of $NAME:";
};
String RID_STR_UNOPKG_ACCEPT_LIC_2
diff --git a/desktop/source/inc/exithelper.hxx b/desktop/source/inc/exithelper.hxx
index 2e6d7e774d98..e2604ce49b68 100644
--- a/desktop/source/inc/exithelper.hxx
+++ b/desktop/source/inc/exithelper.hxx
@@ -58,6 +58,8 @@ class ExitHelper
E_FATAL_ERROR = 333, // Only the low 8 bits are significant 333 % 256 = 77
/// user force automatic restart after crash
E_CRASH_WITH_RESTART = 79,
+ /// the office restarts itself
+ E_NORMAL_RESTART = 81
};
};
diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx
index c219a839b99a..314537836921 100644..100755
--- a/desktop/source/migration/migration.cxx
+++ b/desktop/source/migration/migration.cxx
@@ -413,7 +413,7 @@ static void insertSorted(migrations_available& rAvailableMigrations, supported_m
{
rAvailableMigrations.insert(pIter, aSupportedMigration );
bInserted = true;
- break;
+ break; // i111193: insert invalidates iterator!
}
++pIter;
}
diff --git a/desktop/source/migration/services/cexports.cxx b/desktop/source/migration/services/cexports.cxx
index c1971e9d4d00..cf9a9ab30b0c 100644
--- a/desktop/source/migration/services/cexports.cxx
+++ b/desktop/source/migration/services/cexports.cxx
@@ -31,7 +31,7 @@
#include "cppuhelper/implementationentry.hxx"
#include "basicmigration.hxx"
#include "wordbookmigration.hxx"
-#include "extensionmigration.hxx"
+//#include "extensionmigration.hxx"
extern "C"
{
@@ -48,11 +48,11 @@ extern "C"
migration::WordbookMigration_getSupportedServiceNames, ::cppu::createSingleComponentFactory,
0, 0
},
- {
- migration::ExtensionMigration_create, migration::ExtensionMigration_getImplementationName,
- migration::ExtensionMigration_getSupportedServiceNames, ::cppu::createSingleComponentFactory,
- 0, 0
- },
+// {
+// migration::ExtensionMigration_create, migration::ExtensionMigration_getImplementationName,
+// migration::ExtensionMigration_getSupportedServiceNames, ::cppu::createSingleComponentFactory,
+// 0, 0
+// },
{ 0, 0, 0, 0, 0, 0 }
};
diff --git a/desktop/source/migration/services/extensionmigration.cxx b/desktop/source/migration/services/extensionmigration.cxx
deleted file mode 100755
index a926f17c0c19..000000000000
--- a/desktop/source/migration/services/extensionmigration.cxx
+++ /dev/null
@@ -1,540 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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 "extensionmigration.hxx"
-#include <tools/urlobj.hxx>
-#include <unotools/bootstrap.hxx>
-#include <unotools/ucbstreamhelper.hxx>
-#include <ucbhelper/content.hxx>
-#include <com/sun/star/ucb/XCommandInfo.hpp>
-#include <com/sun/star/ucb/TransferInfo.hpp>
-#include <com/sun/star/ucb/NameClash.hpp>
-#include "comphelper/processfactory.hxx"
-#include "com/sun/star/deployment/XPackageManagerFactory.hpp"
-#include "com/sun/star/ucb/XCommandEnvironment.hpp"
-#include "com/sun/star/xml/sax/XParser.hpp"
-#include "rtl/instance.hxx"
-#include "osl/file.hxx"
-#include "osl/thread.h"
-
-#include "xmlscript/xmllib_imexp.hxx"
-#include "../../deployment/inc/dp_ucb.h"
-
-#ifdef SYSTEM_DB
-#include <db.h>
-#else
-#include <berkeleydb/db.h>
-#endif
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-
-namespace {
-
- struct LibDescriptor :
- public rtl::StaticWithInit<const ::xmlscript::LibDescriptorArray, LibDescriptor> {
- const ::xmlscript::LibDescriptorArray operator () () {
-
-
- return ::xmlscript::LibDescriptorArray();
- }
-};
-}
-//.........................................................................
-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 sBasicType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.basic-library"));
- static ::rtl::OUString sDialogType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.dialog-library"));
-
- 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 ExtensionMigration_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.Extensions" ) );
- pImplName = &aImplName;
- }
- }
- return *pImplName;
- }
-
- // -----------------------------------------------------------------------------
-
- Sequence< ::rtl::OUString > ExtensionMigration_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
- // =============================================================================
-
- ExtensionMigration::ExtensionMigration(Reference< XComponentContext > const & ctx) :
- m_ctx(ctx)
- {
- }
-
- // -----------------------------------------------------------------------------
-
- ExtensionMigration::~ExtensionMigration()
- {
- }
-
- ::osl::FileBase::RC ExtensionMigration::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 ExtensionMigration::prepareBasicLibs()
- {
- prepareBasicLibs(m_sSourceDir + ::rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("/user/basic/script.xlc")), m_scriptElements);
- prepareBasicLibs(m_sSourceDir + ::rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("/user/basic/dialog.xlc")), m_dialogElements);
- }
-
- void ExtensionMigration::prepareBasicLibs(const ::rtl::OUString & sURL,
- ::xmlscript::LibDescriptorArray & out_elements)
- {
-
- ::ucbhelper::Content ucb_content;
- if (dp_misc::create_ucb_content( &ucb_content, sURL,
- uno::Reference< ucb::XCommandEnvironment>(), false /* no throw */ ))
- {
- uno::Reference<xml::sax::XParser> xParser(
- m_ctx->getServiceManager()->createInstanceWithContext(
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser")),
- m_ctx ), UNO_QUERY_THROW );
-
- xParser->setDocumentHandler( ::xmlscript::importLibraryContainer( &out_elements ) );
- xml::sax::InputSource source;
- source.aInputStream = ucb_content.openStream();
- source.sSystemId = ucb_content.getURL();
- xParser->parseStream( source );
- }
- //else
- //The file need not exists
- }
- /* Checks if basic package is enabled in StarOffice 8. This is the case when the dialog.xlc or
- the script.xlc in the user installation contains an entry for this package.
- The passed package MUST be a basic package.
- */
- bool ExtensionMigration::isBasicPackageEnabled( const uno::Reference< deployment::XPackage > & xPkg)
- {
- ::rtl::OUString sScriptURL = xPkg->getURL();
- if ( sScriptURL[ sScriptURL.getLength()-1 ] != '/' )
- sScriptURL += ::rtl::OUString::createFromAscii("/");
- sScriptURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("script.xlb") );
-
- bool bEntryFound = false;
- for ( sal_Int32 nPos = m_scriptElements.mnLibCount; nPos--; )
- {
- ::xmlscript::LibDescriptor const & descr =
- m_scriptElements.mpLibs[ nPos ];
-
- if (descr.aStorageURL.equals(sScriptURL))
- {
- bEntryFound = true;
- break;
- }
- }
-
- ::rtl::OUString sDialogURL = xPkg->getURL();
- if ( sDialogURL[ sDialogURL.getLength()-1 ] != '/' )
- sDialogURL += ::rtl::OUString::createFromAscii("/");
- sScriptURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("dialog.xlb") );
-
- if (!bEntryFound)
- {
- for ( sal_Int32 nPos = m_dialogElements.mnLibCount; nPos--; )
- {
- ::xmlscript::LibDescriptor const & descr =
- m_dialogElements.mpLibs[ nPos ];
-
- if (descr.aStorageURL.equals(sDialogURL))
- {
- bEntryFound = true;
- break;
- }
- }
- }
- return bEntryFound;
- }
- /* This function only registers basic and dialog packages.
- */
- void ExtensionMigration::registerBasicPackage( const uno::Reference< deployment::XPackage > & xPkg)
- {
- const ::rtl::OUString sMediaType = xPkg->getPackageType()->getMediaType();
- if ( (sMediaType.equals(sBasicType) || sMediaType.equals(sDialogType))
- && isBasicPackageEnabled(xPkg))
- {
- xPkg->registerPackage(uno::Reference< task::XAbortChannel >(),
- uno::Reference< ucb::XCommandEnvironment> ());
- }
- }
-
- bool ExtensionMigration::processExtensions( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir )
- {
- if (!copy(sSourceDir, sTargetDir))
- return false;
-
- // Find all basic and script packages and reregister them
- uno::Reference< deployment::XPackageManagerFactory > xPMF;
- if (! ( m_ctx->getValueByName( ::rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.deployment.thePackageManagerFactory")))
- >>= xPMF))
- throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "ExtensionsMigration: could not get thePackageManagerFactory")), 0);
-
- const uno::Reference< deployment::XPackageManager > xPackageMgr =
- xPMF->getPackageManager(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")));
-
- if (!xPackageMgr.is())
- throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "ExtensionsMigration: could not get XPackageManager")), 0);
-
- const uno::Sequence< uno::Reference< deployment::XPackage > > allPackages =
- xPackageMgr->getDeployedPackages(
- uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ());
-
- for (int i = 0; i < allPackages.getLength(); i ++)
- {
- const uno::Reference< deployment::XPackage > aPackage = allPackages[i];
- if ( aPackage->isBundle() )
- {
- const uno::Sequence< uno::Reference < deployment::XPackage > > seqPkg =
- aPackage->getBundle(
- uno::Reference< task::XAbortChannel >(),
- uno::Reference< ucb::XCommandEnvironment> ());
-
- for ( int k = 0; k < seqPkg.getLength(); k++ )
- registerBasicPackage(seqPkg[k]);
-
- for (int l = 0; l < seqPkg.getLength(); l++)
- {
- const ::rtl::OUString sMediaType = seqPkg[l]->getPackageType()->getMediaType();
- beans::Optional<beans::Ambiguous<sal_Bool> > opt =
- seqPkg[l]->isRegistered(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ());
- bool bRegistered = opt.IsPresent && opt.Value.IsAmbiguous == sal_False && opt.Value.Value == sal_True ? true : false;
-
- if ( bRegistered && !sMediaType.equals(sBasicType) && !sMediaType.equals(sDialogType) )
- {
- seqPkg[l]->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ());
- seqPkg[l]->registerPackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ());
- }
- }
- }
- else
- {
- registerBasicPackage(aPackage);
- {
- aPackage->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ());
- aPackage->registerPackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ());
- }
- }
- }
-
-
- return true;
-
- }
-
-bool ExtensionMigration::isCompatibleBerkleyDb(const ::rtl::OUString& sSourceDir)
-{
- try
- {
- ::rtl::OUString sDb(sSourceDir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "/uno_packages.db")));
- //check if the db exist at all. If not then the call to db_create would create
- //the file.
- ::osl::File f(sDb);
- if (::osl::File::E_None != f.open(OpenFlag_Read))
- {
- f.close();
- return false;
- }
- f.close();
-
- //create a system path
- ::rtl::OUString sSysPath;
- if (::osl::File::getSystemPathFromFileURL(sDb, sSysPath ) != ::osl::File::E_None)
- return false;
-
- ::rtl::OString cstr_sysPath(
- ::rtl::OUStringToOString( sSysPath, osl_getThreadTextEncoding() ) );
- char const * pcstr_sysPath = cstr_sysPath.getStr();
-
- //Open the db. If it works then we assume that the file was written with a
- //compatible version of Berkeley Db
- DB* pDB = NULL;
- //using DB_RDONLY will return an "Invalid argument" error.
- //DB_CREATE: only creates the file if it does not exist.
- //An existing db is not modified.
- if (0 != db_create(& pDB, 0, DB_CREATE))
- return false;
-
- if (0 != pDB->open(pDB, 0, pcstr_sysPath , 0, DB_HASH, DB_RDONLY, 0664 /* fs mode */))
- return false;
-
- pDB->close(pDB, 0);
- }
- catch (uno::Exception& )
- {
- return false;
- }
-
- return true;
-}
-
-bool ExtensionMigration::copy( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir )
-{
- bool bRet = false;
- if (! isCompatibleBerkleyDb(sSourceDir))
- return 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 ExtensionMigration::getImplementationName() throw (RuntimeException)
- {
- return ExtensionMigration_getImplementationName();
- }
-
- // -----------------------------------------------------------------------------
-
- sal_Bool ExtensionMigration::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 > ExtensionMigration::getSupportedServiceNames() throw (RuntimeException)
- {
- return ExtensionMigration_getSupportedServiceNames();
- }
-
- // -----------------------------------------------------------------------------
- // XInitialization
- // -----------------------------------------------------------------------------
-
- void ExtensionMigration::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!" );
- }
- break;
- }
- }
- prepareBasicLibs();
- }
-
- 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 ExtensionMigration::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 ExtensionMigration::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 sTargetDir(m_sTargetDir), sSourceDir( m_sSourceDir );
- sTargetDir += sExtensionSubDir;
- sSourceDir += sExtensionSubDir;
- sSourceDir += sSubDirName;
- sTargetDir += sSubDirName;
- processExtensions( sSourceDir, sTargetDir );
-
- // copy all user config settings in user/registry/data (except user/registry/data/org)
- sSourceDir = m_sSourceDir;
- sSourceDir += sConfigDir;
- sTargetDir = m_sTargetDir;
- sTargetDir += sConfigDir;
- copyConfig( sSourceDir, sTargetDir );
-
- // copy all user config settings in user/registry/data/org (except user/registry/data/org/openoffice)
- sSourceDir = m_sSourceDir;
- sSourceDir += sOrgDir;
- sTargetDir = m_sTargetDir;
- sTargetDir += sOrgDir;
- copyConfig( sSourceDir, sTargetDir );
- }
-
- return Any();
- }
-
- // =============================================================================
- // component operations
- // =============================================================================
-
- Reference< XInterface > SAL_CALL ExtensionMigration_create(
- Reference< XComponentContext > const & ctx )
- SAL_THROW( () )
- {
- return static_cast< lang::XTypeProvider * >( new ExtensionMigration(
- ctx) );
- }
-
- // -----------------------------------------------------------------------------
-
-//.........................................................................
-} // namespace migration
-//.........................................................................
diff --git a/desktop/source/migration/services/extensionmigration.hxx b/desktop/source/migration/services/extensionmigration.hxx
deleted file mode 100755
index 70f6a4c44c9b..000000000000
--- a/desktop/source/migration/services/extensionmigration.hxx
+++ /dev/null
@@ -1,130 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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_EXTENSIONMIGRATION_HXX_
-#define _DESKTOP_EXTENSIONMIGRATION_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 <cppuhelper/implbase3.hxx>
-#include <osl/mutex.hxx>
-#include <osl/file.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 ExtensionMigration_getImplementationName();
- ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ExtensionMigration_getSupportedServiceNames();
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ExtensionMigration_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 ExtensionMigration : public ExtensionMigration_BASE
- {
- private:
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_ctx;
- ::osl::Mutex m_aMutex;
- ::rtl::OUString m_sSourceDir;
- ::rtl::OUString m_sTargetDir;
-
- ::xmlscript::LibDescriptorArray m_scriptElements;
- ::xmlscript::LibDescriptorArray m_dialogElements;
-
- ::osl::FileBase::RC checkAndCreateDirectory( INetURLObject& rDirURL );
- void copyConfig( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir );
- bool isCompatibleBerkleyDb(const ::rtl::OUString& sSourceDir);
- bool copy( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir );
- bool processExtensions( const ::rtl::OUString& sSourceDir,
- const ::rtl::OUString& sTargetDir );
- /* fills m_scriptElements and m_dialogElements
- */
- void prepareBasicLibs();
- void prepareBasicLibs(const ::rtl::OUString & sURL,
- ::xmlscript::LibDescriptorArray & out_elements);
- bool isBasicPackageEnabled( const ::com::sun::star::uno::Reference<
- ::com::sun::star::deployment::XPackage > & xPkg);
- void registerBasicPackage(
- const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & xPkg);
-
- public:
- ExtensionMigration(::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > const & ctx);
- virtual ~ExtensionMigration();
-
- // 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);
- };
-
-//.........................................................................
-} // namespace migration
-//.........................................................................
-
-#endif // _DESKTOP_AUTOCORRMIGRATION_HXX_
diff --git a/desktop/source/migration/services/makefile.mk b/desktop/source/migration/services/makefile.mk
index 55ecff6bc06f..2f3eb9308ebd 100644
--- a/desktop/source/migration/services/makefile.mk
+++ b/desktop/source/migration/services/makefile.mk
@@ -51,7 +51,6 @@ SLOFILES= \
$(SLO)$/cexports.obj \
$(SLO)$/basicmigration.obj \
$(SLO)$/wordbookmigration.obj \
- $(SLO)$/extensionmigration.obj \
$(SLO)$/autocorrmigration.obj \
$(SLO)$/oo3extensionmigration.obj \
$(SLO)$/cexportsoo3.obj
@@ -61,7 +60,6 @@ SHL1OBJS= \
$(SLO)$/cexports.obj \
$(SLO)$/basicmigration.obj \
$(SLO)$/wordbookmigration.obj \
- $(SLO)$/extensionmigration.obj \
$(SLO)$/autocorrmigration.obj
SHL1TARGET=$(TARGET)
diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx
index b7da88b85013..2e3a8d1d518c 100644
--- a/desktop/source/migration/services/oo3extensionmigration.cxx
+++ b/desktop/source/migration/services/oo3extensionmigration.cxx
@@ -43,8 +43,6 @@
#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>
@@ -52,6 +50,8 @@
#include <com/sun/star/ucb/NameClash.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/xml/xpath/XXPathAPI.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/deployment/ExtensionManager.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -332,18 +332,17 @@ bool OO3ExtensionMigration::scanDescriptionXml( const ::rtl::OUString& sDescript
bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir )
{
- if ( !m_xPackageManager.is() )
+ if ( !m_xExtensionManager.is() )
{
try
{
- m_xPackageManager = deployment::thePackageManagerFactory::get( m_ctx )->getPackageManager(
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "user" )) );
+ m_xExtensionManager = deployment::ExtensionManager::get( m_ctx );
}
catch ( ucb::CommandFailedException & ){}
catch ( uno::RuntimeException & ) {}
}
- if ( m_xPackageManager.is() )
+ if ( m_xExtensionManager.is() )
{
try
{
@@ -353,7 +352,9 @@ bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir
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 );
+ m_xExtensionManager->addExtension(
+ sSourceDir, uno::Sequence<beans::NamedValue>(),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), xAbortChannel, xCmdEnv );
if ( xPackage.is() )
return true;
diff --git a/desktop/source/migration/services/oo3extensionmigration.hxx b/desktop/source/migration/services/oo3extensionmigration.hxx
index fb7e69c2b87f..03995652888c 100644
--- a/desktop/source/migration/services/oo3extensionmigration.hxx
+++ b/desktop/source/migration/services/oo3extensionmigration.hxx
@@ -37,7 +37,7 @@
#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 <com/sun/star/deployment/XExtensionManager.hpp>
#include <osl/mutex.hxx>
#include <osl/file.hxx>
@@ -83,7 +83,7 @@ namespace migration
::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;
+ ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager;
::osl::Mutex m_aMutex;
::rtl::OUString m_sSourceDir;
::rtl::OUString m_sTargetDir;
diff --git a/desktop/source/offacc/acceptor.cxx b/desktop/source/offacc/acceptor.cxx
index 4eee12f5949a..4e100fd99665 100644
--- a/desktop/source/offacc/acceptor.cxx
+++ b/desktop/source/offacc/acceptor.cxx
@@ -67,6 +67,7 @@ Acceptor::Acceptor( const Reference< XMultiServiceFactory >& rFactory )
, m_aConnectString()
, m_aProtocol()
, m_bInit(sal_False)
+ , m_bDying(false)
{
m_rSMgr = rFactory;
m_rAcceptor = Reference< XAcceptor > (m_rSMgr->createInstance(
@@ -88,6 +89,9 @@ Acceptor::~Acceptor()
osl::MutexGuard g(m_aMutex);
t = m_thread;
}
+ //prevent locking if the thread is still waiting
+ m_bDying = true;
+ m_cEnable.set();
osl_joinWithThread(t);
{
// Make the final state of m_bridges visible to this thread (since
@@ -117,6 +121,8 @@ void SAL_CALL Acceptor::run()
RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109)"\
"Acceptor::run waiting for office to come up");
m_cEnable.wait();
+ if (m_bDying) //see destructor
+ break;
RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109)"\
"Acceptor::run now enabled and continuing");
diff --git a/desktop/source/offacc/acceptor.hxx b/desktop/source/offacc/acceptor.hxx
index 1693dd8b75d0..87f50db032dd 100644
--- a/desktop/source/offacc/acceptor.hxx
+++ b/desktop/source/offacc/acceptor.hxx
@@ -83,6 +83,7 @@ private:
OUString m_aProtocol;
sal_Bool m_bInit;
+ bool m_bDying;
public:
Acceptor( const Reference< XMultiServiceFactory >& aFactory );
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
index 2acd4f79a781..a9a0c8271373 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
@@ -35,13 +35,16 @@
#include "tools/extendapplicationenvironment.hxx"
#include "rtl/ustrbuf.hxx"
#include "rtl/uri.hxx"
+#include "rtl/bootstrap.hxx"
#include "osl/thread.h"
#include "osl/process.h"
#include "osl/conditn.hxx"
#include "cppuhelper/implbase1.hxx"
#include "cppuhelper/exc_hlp.hxx"
#include "comphelper/anytostring.hxx"
-#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
+#include "comphelper/sequence.hxx"
+#include "com/sun/star/deployment/ExtensionManager.hpp"
+
#include "com/sun/star/deployment/ui/PackageManagerDialog.hpp"
#include "com/sun/star/ui/dialogs/XExecutableDialog.hpp"
#include "com/sun/star/lang/DisposedException.hpp"
@@ -59,10 +62,24 @@ using ::rtl::OUString;
namespace css = ::com::sun::star;
namespace {
+struct ExtensionName
+{
+ OUString m_str;
+ ExtensionName( OUString const & str ) : m_str( str ) {}
+ bool operator () ( Reference<deployment::XPackage> const & e ) const
+ {
+ if (m_str.equals(dp_misc::getIdentifier(e))
+ || m_str.equals(e->getName()))
+ return true;
+ return false;
+ }
+};
+
//------------------------------------------------------------------------------
const char s_usingText [] =
"\n"
"using: " APP_NAME " add <options> extension-path...\n"
+" " APP_NAME " validate <options> extension-identifier...\n"
" " APP_NAME " remove <options> extension-identifier...\n"
" " APP_NAME " list <options> extension-identifier...\n"
" " APP_NAME " reinstall <options>\n"
@@ -72,6 +89,8 @@ const char s_usingText [] =
"\n"
"sub-commands:\n"
" add add extension\n"
+" validate checks the prerequisites of an installed extension and"
+" registers it if possible\n"
" remove remove extensions by identifier\n"
" reinstall expert feature: reinstall all deployed extensions\n"
" list list information about deployed extensions\n"
@@ -89,6 +108,8 @@ const char s_usingText [] =
" deployment context;\n"
" run only when no concurrent Office\n"
" process(es) are running!\n"
+" --bundled expert feature: operate on bundled extensions. Only\n"
+" works with list, validate, reinstall;\n"
" --deployment-context expert feature: explicit deployment context\n"
" <context>\n"
"\n"
@@ -149,12 +170,13 @@ void DialogClosedListenerImpl::dialogClosed(
// installed with OOo 2.2 or later could not normally be found via its file
// name.
Reference<deployment::XPackage> findPackage(
- Reference<deployment::XPackageManager> const & manager,
+ OUString const & repository,
+ Reference<deployment::XExtensionManager> const & manager,
Reference<ucb::XCommandEnvironment > const & environment,
OUString const & idOrFileName )
{
Sequence< Reference<deployment::XPackage> > ps(
- manager->getDeployedPackages(
+ manager->getDeployedExtensions(repository,
Reference<task::XAbortChannel>(), environment ) );
for ( sal_Int32 i = 0; i < ps.getLength(); ++i )
if ( dp_misc::getIdentifier( ps[i] ) == idOrFileName )
@@ -214,7 +236,7 @@ extern "C" int unopkg_main()
bool subcmd_add = false;
bool subcmd_gui = false;
OUString logFile;
- OUString deploymentContext;
+ OUString repository;
OUString cmdArg;
::std::vector<OUString> cmdPackages;
@@ -250,7 +272,7 @@ extern "C" int unopkg_main()
return 0;
}
else if (isOption( info_version, &nPos )) {
- dp_misc::writeConsole("\n"APP_NAME" Version 3.0\n");
+ dp_misc::writeConsole("\n"APP_NAME" Version 3.3\n");
return 0;
}
//consume all bootstrap variables which may occur before the subcommannd
@@ -279,7 +301,7 @@ extern "C" int unopkg_main()
!readOption( &option_force, info_force, &nPos ) &&
!readOption( &option_bundled, info_bundled, &nPos ) &&
!readOption( &option_suppressLicense, info_suppressLicense, &nPos ) &&
- !readArgument( &deploymentContext, info_context, &nPos ) &&
+ !readArgument( &repository, info_context, &nPos ) &&
!isBootstrapVariable(&nPos))
{
osl_getCommandArg( nPos, &cmdArg.pData );
@@ -312,25 +334,18 @@ extern "C" int unopkg_main()
}
}
- //make sure the bundled option was provided together with shared
- if (option_bundled && !option_shared)
+ if (repository.getLength() == 0)
{
- dp_misc::writeConsoleError(
- "\nERROR: option --bundled can only be used together with --shared!");
- return 1;
- }
-
-
- xComponentContext = getUNO(
- disposeGuard, option_verbose, option_shared, subcmd_gui,
- xLocalComponentContext );
-
- if (deploymentContext.getLength() == 0) {
- deploymentContext = option_shared ? OUSTR("shared") : OUSTR("user");
+ if (option_shared)
+ repository = OUSTR("shared");
+ else if (option_bundled)
+ repository = OUSTR("bundled");
+ else
+ repository = OUSTR("user");
}
else
{
- if (deploymentContext.equalsAsciiL(
+ if (repository.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM("shared") )) {
option_shared = true;
}
@@ -343,15 +358,44 @@ extern "C" int unopkg_main()
}
}
- Reference<deployment::XPackageManagerFactory> xPackageManagerFactory(
- deployment::thePackageManagerFactory::get( xComponentContext ) );
- Reference<deployment::XPackageManager> xPackageManager(
- xPackageManagerFactory->getPackageManager( deploymentContext ) );
+ if (subCommand.equals(OUSTR("reinstall")))
+ {
+ //We must prevent that services and types are loaded by UNO,
+ //otherwise we cannot delete the registry data folder.
+ OUString extensionUnorc;
+ if (repository.equals(OUSTR("user")))
+ extensionUnorc = OUSTR("$UNO_USER_PACKAGES_CACHE/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc");
+ else if (repository.equals(OUSTR("shared")))
+ extensionUnorc = OUSTR("$SHARED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc");
+ else if (repository.equals(OUSTR("bundled")))
+ extensionUnorc = OUSTR("$BUNDLED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc");
+ else
+ OSL_ASSERT(0);
+
+ ::rtl::Bootstrap::expandMacros(extensionUnorc);
+ oslFileError e = osl_removeFile(extensionUnorc.pData);
+ if (e != osl_File_E_None && e != osl_File_E_NOENT)
+ throw Exception(OUSTR("Could not delete ") + extensionUnorc, 0);
+ }
+
+ xComponentContext = getUNO(
+ disposeGuard, option_verbose, option_shared, subcmd_gui,
+ xLocalComponentContext );
+
+ Reference<deployment::XExtensionManager> xExtensionManager(
+ deployment::ExtensionManager::get( xComponentContext ) );
Reference< ::com::sun::star::ucb::XCommandEnvironment > xCmdEnv(
createCmdEnv( xComponentContext, logFile,
- option_force, option_verbose, option_bundled,
- option_suppressLicense) );
+ option_force, option_verbose) );
+
+ //synchronize bundled/shared extensions
+ //Do not synchronize when command is "reinstall". This could add types and services to UNO and
+ //prevent the deletion of the registry data folder
+ //synching is done in XExtensionManager.reinstall
+ if (!subcmd_gui && ! subCommand.equals(OUSTR("reinstall"))
+ && ! dp_misc::office_is_running())
+ dp_misc::syncRepositories(xCmdEnv);
if (subcmd_add ||
subCommand.equalsAsciiL(
@@ -362,35 +406,32 @@ extern "C" int unopkg_main()
OUString const & cmdPackage = cmdPackages[ pos ];
if (subcmd_add)
{
- Reference<deployment::XPackage> xPackage(
- xPackageManager->addPackage(
- cmdPackage, OUString() /* to be detected */,
- Reference<task::XAbortChannel>(), xCmdEnv ) );
- OSL_ASSERT( xPackage.is() );
+ beans::NamedValue nvSuppress(
+ OUSTR("SUPPRESS_LICENSE"), option_suppressLicense ?
+ makeAny(OUSTR("1")):makeAny(OUSTR("0")));
+ xExtensionManager->addExtension(
+ cmdPackage, Sequence<beans::NamedValue>(&nvSuppress, 1),
+ repository, Reference<task::XAbortChannel>(), xCmdEnv);
}
else
{
try
{
- xPackageManager->removePackage(
- cmdPackage, cmdPackage,
+ xExtensionManager->removeExtension(
+ cmdPackage, cmdPackage, repository,
Reference<task::XAbortChannel>(), xCmdEnv );
}
catch (lang::IllegalArgumentException &)
{
Reference<deployment::XPackage> p(
- findPackage(
- xPackageManager, xCmdEnv, cmdPackage ) );
- //Todo. temporary preventing exception in bundled case.
- //In case of a bundled extension, remove would be called as a result of
- //uninstalling a rpm. Then we do not want to show an error when the
- //extension does not exist, because the package will be uninstalled anyway
- //and the error would only confuse people.
- if ( !p.is() && !option_bundled)
+ findPackage(repository,
+ xExtensionManager, xCmdEnv, cmdPackage ) );
+ if ( !p.is())
throw;
else if (p.is())
- xPackageManager->removePackage(
+ xExtensionManager->removeExtension(
::dp_misc::getIdentifier(p), p->getName(),
+ repository,
Reference<task::XAbortChannel>(), xCmdEnv );
}
}
@@ -399,37 +440,136 @@ extern "C" int unopkg_main()
else if (subCommand.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM("reinstall") ))
{
- xPackageManager->reinstallDeployedPackages(
- Reference<task::XAbortChannel>(), xCmdEnv );
+ xExtensionManager->reinstallDeployedExtensions(
+ repository, Reference<task::XAbortChannel>(), xCmdEnv);
}
else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("list") ))
{
- Sequence< Reference<deployment::XPackage> > packages;
+ ::std::vector<Reference<deployment::XPackage> > vecExtUnaccepted;
+ ::comphelper::sequenceToContainer(vecExtUnaccepted,
+ xExtensionManager->getExtensionsWithUnacceptedLicenses(
+ repository, xCmdEnv));
+
+ //This vector tells what XPackage in allExtensions has an
+ //unaccepted license.
+ std::vector<bool> vecUnaccepted;
+ std::vector<Reference<deployment::XPackage> > allExtensions;
if (cmdPackages.empty())
{
- packages = xPackageManager->getDeployedPackages(
- Reference<task::XAbortChannel>(), xCmdEnv );
+ Sequence< Reference<deployment::XPackage> >
+ packages = xExtensionManager->getDeployedExtensions(
+ repository, Reference<task::XAbortChannel>(), xCmdEnv );
+
+ ::std::vector<Reference<deployment::XPackage> > vec_packages;
+ ::comphelper::sequenceToContainer(vec_packages, packages);
+
+ //First copy the extensions with the unaccepted license
+ //to vector allExtensions.
+ allExtensions.resize(vecExtUnaccepted.size() + vec_packages.size());
+
+ ::std::vector<Reference<deployment::XPackage> >::iterator i_all_ext =
+ ::std::copy(vecExtUnaccepted.begin(), vecExtUnaccepted.end(),
+ allExtensions.begin());
+ //Now copy those we got from getDeployedExtensions
+ ::std::copy(vec_packages.begin(), vec_packages.end(), i_all_ext);
+
+ //Now prepare the vector which tells what extension has an
+ //unaccepted license
+ vecUnaccepted.resize(vecExtUnaccepted.size() + vec_packages.size());
+ ::std::vector<bool>::iterator i_unaccepted =
+ ::std::fill_n(vecUnaccepted.begin(),
+ vecExtUnaccepted.size(), true);
+ ::std::fill_n(i_unaccepted, vec_packages.size(), false);
+
dp_misc::writeConsole(
- OUSTR("all deployed ") + deploymentContext + OUSTR(" packages:\n"));
+ OUSTR("All deployed ") + repository + OUSTR(" extensions:\n\n"));
}
else
{
- packages.realloc( cmdPackages.size() );
+ //The user provided the names (ids or file names) of the extensions
+ //which shall be listed
for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos )
+ {
+ Reference<deployment::XPackage> extension;
try
{
- packages[ pos ] = xPackageManager->getDeployedPackage(
- cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv );
+ extension = xExtensionManager->getDeployedExtension(
+ repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv );
}
catch (lang::IllegalArgumentException &)
{
- packages[ pos ] = findPackage(
- xPackageManager, xCmdEnv, cmdPackages[ pos ] );
- if ( !packages[ pos ].is() )
- throw;
+ extension = findPackage(repository,
+ xExtensionManager, xCmdEnv, cmdPackages[ pos ] );
+ }
+
+ //Now look if the requested extension has an unaccepted license
+ bool bUnacceptedLic = false;
+ if (!extension.is())
+ {
+ ::std::vector<Reference<deployment::XPackage> >::const_iterator
+ i = ::std::find_if(
+ vecExtUnaccepted.begin(),
+ vecExtUnaccepted.end(), ExtensionName(cmdPackages[pos]));
+ if (i != vecExtUnaccepted.end())
+ {
+ extension = *i;
+ bUnacceptedLic = true;
+ }
+ }
+
+ if (extension.is())
+ {
+ allExtensions.push_back(extension);
+ vecUnaccepted.push_back(bUnacceptedLic);
+ }
+
+ else
+ throw lang::IllegalArgumentException(
+ OUSTR("There is no such extension deployed: ") +
+ cmdPackages[pos],0,-1);
+ }
+
+ }
+
+ printf_packages(allExtensions, vecUnaccepted, xCmdEnv );
+ }
+ else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("validate") ))
+ {
+ ::std::vector<Reference<deployment::XPackage> > vecExtUnaccepted;
+ ::comphelper::sequenceToContainer(
+ vecExtUnaccepted, xExtensionManager->getExtensionsWithUnacceptedLicenses(
+ repository, xCmdEnv));
+
+ for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos )
+ {
+ Reference<deployment::XPackage> extension;
+ try
+ {
+ extension = xExtensionManager->getDeployedExtension(
+ repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv );
+ }
+ catch (lang::IllegalArgumentException &)
+ {
+ extension = findPackage(
+ repository, xExtensionManager, xCmdEnv, cmdPackages[ pos ] );
+ }
+
+ if (!extension.is())
+ {
+ ::std::vector<Reference<deployment::XPackage> >::const_iterator
+ i = ::std::find_if(
+ vecExtUnaccepted.begin(),
+ vecExtUnaccepted.end(), ExtensionName(cmdPackages[pos]));
+ if (i != vecExtUnaccepted.end())
+ {
+ extension = *i;
}
+ }
+
+ if (extension.is())
+ xExtensionManager->checkPrerequisitesAndEnable(
+ extension, Reference<task::XAbortChannel>(), xCmdEnv);
}
- printf_packages( packages, xCmdEnv );
}
else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("gui") ))
{
diff --git a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx
index e4a503d98732..69a973b90a42 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx
@@ -49,7 +49,7 @@
#include "com/sun/star/deployment/PlatformException.hpp"
#include "com/sun/star/i18n/XCollator.hpp"
#include "com/sun/star/i18n/CollatorOptions.hpp"
-#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp"
+
#include <stdio.h>
#include "deployment.hrc"
#include "dp_version.hxx"
@@ -85,13 +85,12 @@ class CommandEnvironmentImpl
sal_Int32 m_logLevel;
bool m_option_force_overwrite;
bool m_option_verbose;
- bool m_option_bundled;
- bool m_option_suppressLicense;
Reference< XComponentContext > m_xComponentContext;
Reference< XProgressHandler > m_xLogFile;
void update_( Any const & Status ) throw (RuntimeException);
- void printLicense(const OUString& sLicense, bool & accept, bool & decline);
+ void printLicense(const OUString & sName,const OUString& sLicense,
+ bool & accept, bool & decline);
public:
virtual ~CommandEnvironmentImpl();
@@ -99,9 +98,7 @@ public:
Reference<XComponentContext> const & xComponentContext,
OUString const & log_file,
bool option_force_overwrite,
- bool option_verbose,
- bool option_bundled,
- bool option_suppressLicense);
+ bool option_verbose);
// XCommandEnvironment
virtual Reference< task::XInteractionHandler > SAL_CALL
@@ -120,19 +117,16 @@ public:
virtual void SAL_CALL pop() throw (RuntimeException);
};
+
//______________________________________________________________________________
CommandEnvironmentImpl::CommandEnvironmentImpl(
Reference<XComponentContext> const & xComponentContext,
OUString const & log_file,
bool option_force_overwrite,
- bool option_verbose,
- bool option_bundled,
- bool option_suppressLicense)
+ bool option_verbose)
: m_logLevel(0),
m_option_force_overwrite( option_force_overwrite ),
m_option_verbose( option_verbose ),
- m_option_bundled( option_bundled),
- m_option_suppressLicense( option_suppressLicense),
m_xComponentContext(xComponentContext)
{
if (log_file.getLength() > 0) {
@@ -162,10 +156,13 @@ CommandEnvironmentImpl::~CommandEnvironmentImpl()
}
//May throw exceptions
-void CommandEnvironmentImpl::printLicense(const OUString& sLicense, bool & accept, bool &decline)
+void CommandEnvironmentImpl::printLicense(
+ const OUString & sName, const OUString& sLicense, bool & accept, bool &decline)
{
ResMgr * pResMgr = DeploymentResMgr::get();
- OUString s1 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_1, *pResMgr));
+ String s1tmp(ResId(RID_STR_UNOPKG_ACCEPT_LIC_1, *pResMgr));
+ s1tmp.SearchAndReplaceAllAscii( "$NAME", sName );
+ OUString s1(s1tmp);
OUString s2 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_2, *pResMgr));
OUString s3 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_3, *pResMgr));
OUString s4 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_4, *pResMgr));
@@ -246,7 +243,6 @@ void CommandEnvironmentImpl::handle(
lang::WrappedTargetException wtExc;
deployment::LicenseException licExc;
deployment::InstallException instExc;
- deployment::LicenseIndividualAgreementException licAgreementExc;
deployment::PlatformException platExc;
deployment::VersionException verExc;
@@ -281,27 +277,9 @@ void CommandEnvironmentImpl::handle(
update_( wtExc.TargetException );
}
}
- else if (request >>= licAgreementExc)
- {
- if (m_option_suppressLicense && licAgreementExc.SuppressIfRequired)
- {
- approve = true;
- }
- else
- {
- String sResMsg( ResId( RID_STR_UNOPKG_NO_SHARED_ALLOWED, *DeploymentResMgr::get() ) );
- sResMsg.SearchAndReplaceAllAscii( "%NAME", licAgreementExc.ExtensionName );
- dp_misc::writeConsole(OUSTR("\n") + sResMsg + OUSTR("\n\n"));
- abort = true;
- }
- }
else if (request >>= licExc)
{
- bLicenseException = true;
- if (m_option_suppressLicense && licExc.SuppressIfRequired)
- approve = true;
- else
- printLicense(licExc.Text, approve, abort);
+ printLicense(licExc.ExtensionName, licExc.Text, approve, abort);
}
else if (request >>= instExc)
{
@@ -320,7 +298,7 @@ void CommandEnvironmentImpl::handle(
deployment::VersionException nc_exc;
if (request >>= nc_exc) {
approve = m_option_force_overwrite ||
- (::dp_misc::comparePackageVersions(nc_exc.New, nc_exc.Deployed)
+ (::dp_misc::compareVersions(nc_exc.NewVersion, nc_exc.Deployed->getVersion())
== ::dp_misc::GREATER);
abort = !approve;
}
@@ -436,6 +414,7 @@ void CommandEnvironmentImpl::pop() throw (RuntimeException)
m_xLogFile->pop();
}
+
} // anon namespace
namespace unopkg {
@@ -445,14 +424,10 @@ Reference< XCommandEnvironment > createCmdEnv(
Reference< XComponentContext > const & xContext,
OUString const & logFile,
bool option_force_overwrite,
- bool option_verbose,
- bool option_bundled,
- bool option_suppressLicense)
+ bool option_verbose)
{
return new CommandEnvironmentImpl(
- xContext, logFile, option_force_overwrite, option_verbose, option_bundled,
- option_suppressLicense);
+ xContext, logFile, option_force_overwrite, option_verbose);
}
-
} // unopkg
diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
index b25176e1dcee..3272810afee2 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
@@ -48,6 +48,7 @@
#include "unotools/configmgr.hxx"
#include "com/sun/star/lang/XMultiServiceFactory.hpp"
#include "cppuhelper/bootstrap.hxx"
+#include "comphelper/sequence.hxx"
#include <stdio.h>
using ::rtl::OUString;
@@ -317,7 +318,10 @@ void printf_package(
xPackage->getBundle( Reference<task::XAbortChannel>(), xCmdEnv ) );
printf_space( level + 1 );
dp_misc::writeConsole("bundled Packages: {\n");
- printf_packages( seq, xCmdEnv, level + 2 );
+ ::std::vector<Reference<deployment::XPackage> >vec_bundle;
+ ::comphelper::sequenceToContainer(vec_bundle, seq);
+ printf_packages( vec_bundle, ::std::vector<bool>(vec_bundle.size()),
+ xCmdEnv, level + 2 );
printf_space( level + 1 );
dp_misc::writeConsole("}\n");
}
@@ -325,23 +329,45 @@ void printf_package(
} // anon namespace
+void printf_unaccepted_licenses(
+ Reference<deployment::XPackage> const & ext)
+{
+ OUString id(
+ dp_misc::getIdentifier(ext) );
+ printf_line( OUSTR("Identifier"), id, 0 );
+ printf_space(1);
+ dp_misc::writeConsole(OUSTR("License not accepted\n\n"));
+}
+
//==============================================================================
void printf_packages(
- Sequence< Reference<deployment::XPackage> > const & seq,
+ ::std::vector< Reference<deployment::XPackage> > const & allExtensions,
+ ::std::vector<bool> const & vecUnaccepted,
Reference<XCommandEnvironment> const & xCmdEnv, sal_Int32 level )
{
- sal_Int32 len = seq.getLength();
- Reference< deployment::XPackage > const * p = seq.getConstArray();
- if (len == 0) {
+ OSL_ASSERT(allExtensions.size() == vecUnaccepted.size());
+
+ if (allExtensions.size() == 0)
+ {
printf_space( level );
dp_misc::writeConsole("<none>\n");
}
- else {
- for ( sal_Int32 pos = 0; pos < len; ++pos )
- printf_package( p[ pos ], xCmdEnv, level );
+ else
+ {
+ typedef ::std::vector< Reference<deployment::XPackage> >::const_iterator I_EXT;
+ int index = 0;
+ for (I_EXT i = allExtensions.begin(); i != allExtensions.end(); i++, index++)
+ {
+ if (vecUnaccepted[index])
+ printf_unaccepted_licenses(*i);
+ else
+ printf_package( *i, xCmdEnv, level );
+ dp_misc::writeConsole(OUSTR("\n"));
+ }
}
}
+
//##############################################################################
namespace {
diff --git a/desktop/source/pkgchk/unopkg/unopkg_shared.h b/desktop/source/pkgchk/unopkg/unopkg_shared.h
index 6e9d30cf0d42..43f77513b10c 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_shared.h
+++ b/desktop/source/pkgchk/unopkg/unopkg_shared.h
@@ -162,14 +162,12 @@ css::uno::Reference<css::ucb::XCommandEnvironment> createCmdEnv(
css::uno::Reference<css::uno::XComponentContext> const & xContext,
::rtl::OUString const & logFile,
bool option_force_overwrite,
- bool option_verbose,
- bool option_bundled,
- bool option_suppressLicense);
-
+ bool option_verbose);
//==============================================================================
void printf_packages(
- css::uno::Sequence<
- css::uno::Reference<css::deployment::XPackage> > const & seq,
+ ::std::vector<
+ css::uno::Reference<css::deployment::XPackage> > const & allExtensions,
+ ::std::vector<bool> const & vecUnaccepted,
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
sal_Int32 level = 0 );
diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx
index 5fee3028b4f6..381a98ce008f 100644
--- a/desktop/source/splash/splash.cxx
+++ b/desktop/source/splash/splash.cxx
@@ -135,14 +135,21 @@ void SAL_CALL SplashScreen::reset()
}
}
-void SAL_CALL SplashScreen::setText(const OUString&)
+void SAL_CALL SplashScreen::setText(const OUString& rText)
throw (RuntimeException)
{
- if (_bVisible && !_bProgressEnd) {
- if ( _eBitmapMode == BM_FULLSCREEN )
- ShowFullScreenMode( TRUE );
- Show();
- Flush();
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ if ( _sProgressText != rText )
+ {
+ _sProgressText = rText;
+
+ if (_bVisible && !_bProgressEnd)
+ {
+ if ( _eBitmapMode == BM_FULLSCREEN )
+ ShowFullScreenMode( TRUE );
+ Show();
+ updateStatus();
+ }
}
}
@@ -647,7 +654,7 @@ void SplashScreen::Paint( const Rectangle&)
}
if( (bNativeOK = DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
- CTRL_STATE_ENABLED, aValue, rtl::OUString() )) != FALSE )
+ CTRL_STATE_ENABLED, aValue, _sProgressText )) != FALSE )
{
return;
}
@@ -668,10 +675,8 @@ void SplashScreen::Paint( const Rectangle&)
_vdev.DrawRect(Rectangle(_tlx, _tly, _tlx+_barwidth, _tly+_barheight));
_vdev.SetFillColor( _cProgressBarColor );
_vdev.SetLineColor();
- Rectangle aRect(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace);
- _vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace,
- _tlx+_barspace+length, _tly+_barheight-_barspace));
-
+ _vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace));
+ _vdev.DrawText( Rectangle(_tlx, _tly+_barheight+5, _tlx+_barwidth, _tly+_barheight+5+20), _sProgressText, TEXT_DRAW_CENTER );
}
Size aSize = GetOutputSizePixel();
Size bSize = _vdev.GetOutputSizePixel();
diff --git a/desktop/source/splash/splash.hxx b/desktop/source/splash/splash.hxx
index 99677aa107f1..8480ed3df9ae 100644
--- a/desktop/source/splash/splash.hxx
+++ b/desktop/source/splash/splash.hxx
@@ -91,6 +91,7 @@ private:
Color _cProgressBarColor;
bool _bNativeProgress;
OUString _sAppName;
+ OUString _sProgressText;
std::vector< FullScreenProgressRatioValue > _sFullScreenProgressRatioValues;
sal_Int32 _iMax;