diff options
Diffstat (limited to 'desktop/source/deployment/registry/executable')
4 files changed, 233 insertions, 27 deletions
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 |