summaryrefslogtreecommitdiff
path: root/desktop/source/deployment/registry/executable/dp_executable.cxx
diff options
context:
space:
mode:
authorJoachim Lingner <jl@openoffice.org>2010-04-23 11:43:48 +0200
committerJoachim Lingner <jl@openoffice.org>2010-04-23 11:43:48 +0200
commit9bfe25036358e6befdb2e9ddcbc1084f6a3d8c7f (patch)
treea91d6581a47af9684467bf7c0eb39e1551095fd7 /desktop/source/deployment/registry/executable/dp_executable.cxx
parentc2d9d80b487dd0d7353b22eee44bee3b84fc7838 (diff)
jl152 import 263450 from native0jl:#i77196# XExtensionManager.isReadOnlyRepositor, fixed removing xcu exceptions, executable backend
Diffstat (limited to 'desktop/source/deployment/registry/executable/dp_executable.cxx')
-rw-r--r--desktop/source/deployment/registry/executable/dp_executable.cxx61
1 files changed, 48 insertions, 13 deletions
diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx
index ac83302f9fb4..c72a97d88891 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 {
@@ -68,7 +71,6 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
bool getFileAttributes(sal_uInt64& out_Attributes);
bool isUrlTargetInExtension();
-
public:
inline ExecutablePackageImpl(
::rtl::Reference<PackageRegistryBackend> const & myBackend,
@@ -89,8 +91,12 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
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 );
@@ -114,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
@@ -186,18 +217,11 @@ 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_(
@@ -224,7 +248,9 @@ 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
@@ -232,11 +258,18 @@ void BackendImpl::ExecutablePackageImpl::processPackage_(
dp_misc::expandUnoRcUrl(m_url), attributes))
OSL_ENSURE(0, "Extension Manager: Could not set executable file attribute.");
}
+ 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;
@@ -245,6 +278,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