Kaydet (Commit) a334403e authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Cleaned up configmgr initialization.

Added CONFIGURATION_LAYERS bootstrap variable.
Removed OOO_CONFIG_REGISTRY[_EXTRA]_DIR bootstrap variables.
üst 983360d3
...@@ -304,12 +304,12 @@ bool Components::hasModifications() const ...@@ -304,12 +304,12 @@ bool Components::hasModifications() const
void Components::writeModifications() { void Components::writeModifications() {
if (!hasModifications()) if (!hasModifications() || modificationFileUrl_.isEmpty())
return; return;
if (!writeThread_.is()) { if (!writeThread_.is()) {
writeThread_ = new WriteThread( writeThread_ = new WriteThread(
&writeThread_, *this, getModificationFileUrl(), data_); &writeThread_, *this, modificationFileUrl_, data_);
writeThread_->create(); writeThread_->create();
} }
} }
...@@ -329,8 +329,9 @@ void Components::flushModifications() { ...@@ -329,8 +329,9 @@ void Components::flushModifications() {
void Components::insertExtensionXcsFile( void Components::insertExtensionXcsFile(
bool shared, rtl::OUString const & fileUri) bool shared, rtl::OUString const & fileUri)
{ {
int layer = getExtensionLayer(shared);
try { try {
parseXcsFile(fileUri, shared ? 9 : 13, data_, 0, 0, 0); parseXcsFile(fileUri, layer, data_, 0, 0, 0);
} catch (css::container::NoSuchElementException & e) { } catch (css::container::NoSuchElementException & e) {
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
(rtl::OUString( (rtl::OUString(
...@@ -345,7 +346,7 @@ void Components::insertExtensionXcuFile( ...@@ -345,7 +346,7 @@ void Components::insertExtensionXcuFile(
bool shared, rtl::OUString const & fileUri, Modifications * modifications) bool shared, rtl::OUString const & fileUri, Modifications * modifications)
{ {
OSL_ASSERT(modifications != 0); OSL_ASSERT(modifications != 0);
int layer = shared ? 10 : 14; int layer = getExtensionLayer(shared) + 1;
Additions * adds = data_.addExtensionXcuAdditions(fileUri, layer); Additions * adds = data_.addExtensionXcuAdditions(fileUri, layer);
try { try {
parseXcuFile(fileUri, layer, data_, 0, modifications, adds); parseXcuFile(fileUri, layer, data_, 0, modifications, adds);
...@@ -506,96 +507,108 @@ css::beans::Optional< css::uno::Any > Components::getExternalValue( ...@@ -506,96 +507,108 @@ css::beans::Optional< css::uno::Any > Components::getExternalValue(
Components::Components( Components::Components(
css::uno::Reference< css::uno::XComponentContext > const & context): css::uno::Reference< css::uno::XComponentContext > const & context):
context_(context) context_(context), sharedExtensionLayer_(-1), userExtensionLayer_(-1)
{ {
lock_ = lock();
OSL_ASSERT(context.is()); OSL_ASSERT(context.is());
lock_ = lock();
// Check if we are being used for in-tree unit tests ... rtl::OUString conf(
rtl::OUString aUnitTestDir; expand(
if (rtl::Bootstrap::get( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("OOO_CONFIG_REGISTRY_DIR") ), aUnitTestDir))
{
parseXcsXcuLayer( 0, aUnitTestDir );
// next is required for the (somewhat strange) filter configuration
parseModuleLayer( 2, aUnitTestDir + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/spool")));
// allow a directory to be specified to allow extra configuration to be stored
// for example to place a registrymodifications.xcu to override some configuration
rtl::OUString extra;
if (rtl::Bootstrap::get(
rtl::OUString( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( RTL_CONSTASCII_USTRINGPARAM("${CONFIGURATION_LAYERS}"))));
"OOO_CONFIG_REGISTRY_EXTRA_DIR")), RTL_LOGFILE_TRACE("configmgr : begin parsing");
extra)) int layer = 0;
{ for (sal_Int32 i = 0;;) {
parseXcsXcuLayer(3, extra); while (i != conf.getLength() && conf[i] == ' ') {
++i;
} }
return; if (i == conf.getLength()) {
break;
} }
if (!modificationFileUrl_.isEmpty()) {
RTL_LOGFILE_TRACE("configmgr : begin parsing"); throw css::uno::RuntimeException(
parseXcsXcuLayer(
0,
expand(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"$BRAND_BASE_DIR/share/registry"))));
parseModuleLayer(
2,
expand(
rtl::OUString( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( RTL_CONSTASCII_USTRINGPARAM(
"$BRAND_BASE_DIR/share/registry/modules")))); "CONFIGURATION_LAYERS: \"user\" followed by further"
parseResLayer( " layers")),
3, css::uno::Reference< css::uno::XInterface >());
expand( }
sal_Int32 c = i;
for (;; ++c) {
if (c == conf.getLength() || conf[c] == ' ') {
throw css::uno::RuntimeException(
rtl::OUString( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( RTL_CONSTASCII_USTRINGPARAM(
"$BRAND_BASE_DIR/share/registry")))); "CONFIGURATION_LAYERS: missing \":\"")),
parseXcsXcuIniLayer( css::uno::Reference< css::uno::XInterface >());
4, }
expand( if (conf[c] == ':') {
break;
}
}
sal_Int32 n = conf.indexOf(' ', c + 1);
if (n == -1) {
n = conf.getLength();
}
rtl::OUString type(conf.copy(i, c - i));
rtl::OUString url(expand(conf.copy(c + 1, n - c - 1)));
if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("xcsxcu"))) {
parseXcsXcuLayer(layer, url);
layer += 2; //TODO: overflow
} else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("bundledext")))
{
parseXcsXcuIniLayer(layer, url, false);
layer += 2; //TODO: overflow
} else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("sharedext"))) {
if (sharedExtensionLayer_ != -1) {
throw css::uno::RuntimeException(
rtl::OUString( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( RTL_CONSTASCII_USTRINGPARAM(
"${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("uno") "CONFIGURATION_LAYERS: multiple \"sharedext\""
":BUNDLED_EXTENSIONS_USER}/registry/" " layers")),
"com.sun.star.comp.deployment.configuration." css::uno::Reference< css::uno::XInterface >());
"PackageRegistryBackend/configmgr.ini"))), }
false); sharedExtensionLayer_ = layer;
parseXcsXcuIniLayer( parseXcsXcuIniLayer(layer, url, true);
6, layer += 2; //TODO: overflow
expand( } else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("userext"))) {
if (userExtensionLayer_ != -1) {
throw css::uno::RuntimeException(
rtl::OUString( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( RTL_CONSTASCII_USTRINGPARAM(
"${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("uno") "CONFIGURATION_LAYERS: multiple \"userext\""
":SHARED_EXTENSIONS_USER}/registry/" " layers")),
"com.sun.star.comp.deployment.configuration." css::uno::Reference< css::uno::XInterface >());
"PackageRegistryBackend/configmgr.ini"))), }
true); userExtensionLayer_ = layer;
parseXcsXcuLayer( parseXcsXcuIniLayer(layer, url, true);
8, layer += 2; //TODO: overflow
expand( } else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("module"))) {
parseModuleLayer(layer, url);
++layer; //TODO: overflow
} else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("res"))) {
parseResLayer(layer, url);
++layer; //TODO: overflow
} else if (type.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("user"))) {
if (url.isEmpty()) {
throw css::uno::RuntimeException(
rtl::OUString( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( RTL_CONSTASCII_USTRINGPARAM(
"${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("uno") "CONFIGURATION_LAYERS: empty \"user\" URL")),
":UNO_USER_PACKAGES_CACHE}/registry/" css::uno::Reference< css::uno::XInterface >());
"com.sun.star.comp.deployment.configuration." }
"PackageRegistryBackend/registry")))); modificationFileUrl_ = url;
// can be dropped once old UserInstallation format can no longer exist parseModificationLayer(url);
// (probably OOo 4) } else {
parseXcsXcuIniLayer( throw css::uno::RuntimeException(
10, (rtl::OUString(
expand(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( RTL_CONSTASCII_USTRINGPARAM(
"${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("uno") "CONFIGURATION_LAYERS: unknown layer type \"")) +
":UNO_USER_PACKAGES_CACHE}/registry/" type +
"com.sun.star.comp.deployment.configuration." rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""))),
"PackageRegistryBackend/configmgr.ini"))), css::uno::Reference< css::uno::XInterface >());
true); }
parseModificationLayer(); i = n;
}
RTL_LOGFILE_TRACE("configmgr : end parsing"); RTL_LOGFILE_TRACE("configmgr : end parsing");
} }
...@@ -858,19 +871,9 @@ void Components::parseResLayer(int layer, rtl::OUString const & url) { ...@@ -858,19 +871,9 @@ void Components::parseResLayer(int layer, rtl::OUString const & url) {
&parseXcuFile, resUrl, false); &parseXcuFile, resUrl, false);
} }
rtl::OUString Components::getModificationFileUrl() const { void Components::parseModificationLayer(rtl::OUString const & url) {
return expand(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("bootstrap")
":UserInstallation}/user/registrymodifications.xcu")));
}
void Components::parseModificationLayer() {
try { try {
parseFileLeniently( parseFileLeniently(&parseXcuFile, url, Data::NO_LAYER, data_, 0, 0, 0);
&parseXcuFile, getModificationFileUrl(), Data::NO_LAYER, data_, 0,
0, 0);
} catch (css::container::NoSuchElementException &) { } catch (css::container::NoSuchElementException &) {
OSL_TRACE( OSL_TRACE(
"configmgr user registrymodifications.xcu does not (yet) exist"); "configmgr user registrymodifications.xcu does not (yet) exist");
...@@ -889,6 +892,18 @@ void Components::parseModificationLayer() { ...@@ -889,6 +892,18 @@ void Components::parseModificationLayer() {
} }
} }
int Components::getExtensionLayer(bool shared) {
int layer = shared ? sharedExtensionLayer_ : userExtensionLayer_;
if (layer == -1) {
throw css::uno::RuntimeException(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"insert extension xcs/xcu file into undefined layer")),
css::uno::Reference< css::uno::XInterface >());
}
return layer;
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -155,9 +155,9 @@ private: ...@@ -155,9 +155,9 @@ private:
void parseResLayer(int layer, rtl::OUString const & url); void parseResLayer(int layer, rtl::OUString const & url);
rtl::OUString getModificationFileUrl() const; void parseModificationLayer(rtl::OUString const & url);
void parseModificationLayer(); int getExtensionLayer(bool shared);
typedef std::set< RootAccess * > WeakRootSet; typedef std::set< RootAccess * > WeakRootSet;
...@@ -176,6 +176,9 @@ private: ...@@ -176,6 +176,9 @@ private:
WeakRootSet roots_; WeakRootSet roots_;
ExternalServices externalServices_; ExternalServices externalServices_;
rtl::Reference< WriteThread > writeThread_; rtl::Reference< WriteThread > writeThread_;
int sharedExtensionLayer_;
int userExtensionLayer_;
rtl::OUString modificationFileUrl_;
boost::shared_ptr<osl::Mutex> lock_; boost::shared_ptr<osl::Mutex> lock_;
}; };
......
...@@ -99,8 +99,9 @@ $(eval $(call gb_CppunitTest_add_service_rdbs,sc_filters_test,\ ...@@ -99,8 +99,9 @@ $(eval $(call gb_CppunitTest_add_service_rdbs,sc_filters_test,\
$(eval $(call gb_CppunitTest_set_args,sc_filters_test,\ $(eval $(call gb_CppunitTest_set_args,sc_filters_test,\
--headless \ --headless \
--protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \
-env:OOO_CONFIG_REGISTRY_DIR=$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) \ "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool)" \
)) ))
# .../spool is required for the (somewhat strange) filter configuration
# we need to # we need to
# a) explicitly depend on library msword because it is not implied by a link # a) explicitly depend on library msword because it is not implied by a link
......
...@@ -99,9 +99,9 @@ $(eval $(call gb_CppunitTest_add_service_rdbs,sc_macros_test,\ ...@@ -99,9 +99,9 @@ $(eval $(call gb_CppunitTest_add_service_rdbs,sc_macros_test,\
$(eval $(call gb_CppunitTest_set_args,sc_macros_test,\ $(eval $(call gb_CppunitTest_set_args,sc_macros_test,\
--headless \ --headless \
--protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \
-env:OOO_CONFIG_REGISTRY_DIR=$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) \ "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/user)" \
-env:OOO_CONFIG_REGISTRY_EXTRA_DIR=$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/user) \
)) ))
# .../spool is required for the (somewhat strange) filter configuration
# we need to # we need to
# a) explicitly depend on library msword because it is not implied by a link # a) explicitly depend on library msword because it is not implied by a link
......
...@@ -927,6 +927,18 @@ ProfileItem gid_Brand_Profileitem_Soffice_Startlang ...@@ -927,6 +927,18 @@ ProfileItem gid_Brand_Profileitem_Soffice_Startlang
End End
#endif #endif
ProfileItem gid_Brand_Profileitem_Soffice_ConfigurationLayers
ProfileID = gid_Brand_Profile_Soffice_Ini;
ModuleID = gid_Module_Root_Brand;
Section = "Bootstrap";
Key = "CONFIGURATION_LAYERS";
Value = "xcsxcu:${BRAND_BASE_DIR}/share/registry module:${BRAND_BASE_DIR}/share/registry/modules res:${BRAND_BASE_DIR}/share/registry bundledext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini sharedext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini xcsxcu:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/registry userext:${${BRAND_BASE_DIR}/program/" PROFILENAME(uno) ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini user:${$BRAND_BASE_DIR/program/" PROFILENAME(bootstrap) ":UserInstallation}/user/registrymodifications.xcu";
// "xcsxcu:${${BRAND_BASE_DIR}/program/"PROFILENAME(uno)
// ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment."
// "configuration.PackageRegistryBackend/registry" can be dropped once
// old UserInstallation format can no longer exist (probably OOo 4)
End
ProfileItem gid_Brand_Profileitem_Version_Buildid ProfileItem gid_Brand_Profileitem_Version_Buildid
ProfileID = gid_Brand_Profile_Version_Ini; ProfileID = gid_Brand_Profile_Version_Ini;
ModuleID = gid_Module_Root_Brand; ModuleID = gid_Module_Root_Brand;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment