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

Support modification write-back to other than registrymodifications.xcu

...to eventually support writing to dconf (see TODO).

Even when writing somewhere else, it may still be useful to read from the
current "user:" location, so a new convention was introduced to
CONFIGURATION_LAYERS types that support write-back:

- A leading "!" indicates that the layer is indeed used for write-back (probably
in addition to reading from it).  For backwards compatibility (when users use
own settings of CONFIGURATION_LAYERS, instead of depending on the value in the
shipped fundamental ini-file), no prefix on the "user:" is now interpreted the
same as a "!" prefix.

- A leading "*" indicates that the layer is not used for write-back (but only
for reading from it).

Change-Id: I399cc7bfe927db50586834f9630c184aaa2153f2
üst aefb3d97
...@@ -279,13 +279,22 @@ void Components::addModification(Path const & path) { ...@@ -279,13 +279,22 @@ void Components::addModification(Path const & path) {
void Components::writeModifications() { void Components::writeModifications() {
if (!(data_.modifications.empty() || modificationFileUrl_.isEmpty() if (!data_.modifications.empty()) {
|| writeThread_.is())) switch (modificationTarget_) {
{ case ModificationTarget::None:
break;
case ModificationTarget::File:
if (!writeThread_.is()) {
writeThread_ = new WriteThread( writeThread_ = new WriteThread(
&writeThread_, *this, modificationFileUrl_, data_); &writeThread_, *this, modificationFileUrl_, data_);
writeThread_->launch(); writeThread_->launch();
} }
break;
case ModificationTarget::Dconf:
//TODO
break;
}
}
} }
void Components::flushModifications() { void Components::flushModifications() {
...@@ -455,7 +464,8 @@ css::beans::Optional< css::uno::Any > Components::getExternalValue( ...@@ -455,7 +464,8 @@ 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), sharedExtensionLayer_(-1), userExtensionLayer_(-1) context_(context), sharedExtensionLayer_(-1), userExtensionLayer_(-1),
modificationTarget_(ModificationTarget::None)
{ {
assert(context.is()); assert(context.is());
lock_ = lock(); lock_ = lock();
...@@ -468,9 +478,10 @@ Components::Components( ...@@ -468,9 +478,10 @@ Components::Components(
if (i == conf.getLength()) { if (i == conf.getLength()) {
break; break;
} }
if (!modificationFileUrl_.isEmpty()) { if (modificationTarget_ != ModificationTarget::None) {
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
"CONFIGURATION_LAYERS: \"user\" followed by further layers"); "CONFIGURATION_LAYERS: modification target layer followed by"
" further layers");
} }
sal_Int32 c = i; sal_Int32 c = i;
for (;; ++c) { for (;; ++c) {
...@@ -522,11 +533,15 @@ Components::Components( ...@@ -522,11 +533,15 @@ Components::Components(
++layer; //TODO: overflow ++layer; //TODO: overflow
#if ENABLE_DCONF #if ENABLE_DCONF
} else if (type == "dconf") { } else if (type == "dconf") {
if (!url.isEmpty()) { if (url == "!") {
modificationTarget_ = ModificationTarget::Dconf;
} else if (url == "*") {
readDconfLayer(data_, layer);
} else {
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
"CONFIGURATION_LAYERS: non-empty \"dconf\" URL"); "CONFIGURATION_LAYERS: unknown \"dconf\" kind \"" + url
+ "\"");
} }
readDconfLayer(data_, layer);
++layer; //TODO: overflow ++layer; //TODO: overflow
#endif #endif
#if defined WNT #if defined WNT
...@@ -549,12 +564,24 @@ Components::Components( ...@@ -549,12 +564,24 @@ Components::Components(
++layer; //TODO: overflow ++layer; //TODO: overflow
#endif #endif
} else if (type == "user") { } else if (type == "user") {
bool write;
if (url.startsWith("!", &url)) {
write = true;
} else if (url.startsWith("*", &url)) {
write = false;
} else {
write = true; // for backwards compatibility
}
if (url.isEmpty()) { if (url.isEmpty()) {
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
"CONFIGURATION_LAYERS: empty \"user\" URL"); "CONFIGURATION_LAYERS: empty \"user\" URL");
} }
if (write) {
modificationTarget_ = ModificationTarget::File;
modificationFileUrl_ = url; modificationFileUrl_ = url;
parseModificationLayer(url); }
parseModificationLayer(write ? Data::NO_LAYER : layer, url);
++layer; //TODO: overflow
} else { } else {
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
"CONFIGURATION_LAYERS: unknown layer type \"" + type + "\""); "CONFIGURATION_LAYERS: unknown layer type \"" + type + "\"");
...@@ -789,9 +816,9 @@ void Components::parseResLayer(int layer, OUString const & url) { ...@@ -789,9 +816,9 @@ void Components::parseResLayer(int layer, OUString const & url) {
parseFiles(layer, ".xcu", &parseXcuFile, resUrl, false); parseFiles(layer, ".xcu", &parseXcuFile, resUrl, false);
} }
void Components::parseModificationLayer(OUString const & url) { void Components::parseModificationLayer(int layer, OUString const & url) {
try { try {
parseFileLeniently(&parseXcuFile, url, Data::NO_LAYER, 0, 0, 0); parseFileLeniently(&parseXcuFile, url, layer, 0, 0, 0);
} catch (css::container::NoSuchElementException &) { } catch (css::container::NoSuchElementException &) {
SAL_INFO( SAL_INFO(
"configmgr", "user registrymodifications.xcu does not (yet) exist"); "configmgr", "user registrymodifications.xcu does not (yet) exist");
...@@ -799,7 +826,7 @@ void Components::parseModificationLayer(OUString const & url) { ...@@ -799,7 +826,7 @@ void Components::parseModificationLayer(OUString const & url) {
// longer relevant, probably OOo 4; also see hack for xsi namespace in // longer relevant, probably OOo 4; also see hack for xsi namespace in
// xmlreader::XmlReader::registerNamespaceIri): // xmlreader::XmlReader::registerNamespaceIri):
parseFiles( parseFiles(
Data::NO_LAYER, ".xcu", &parseXcuFile, layer, ".xcu", &parseXcuFile,
expand( expand(
"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap")
":UserInstallation}/user/registry/data"), ":UserInstallation}/user/registry/data"),
......
...@@ -139,7 +139,7 @@ private: ...@@ -139,7 +139,7 @@ private:
void parseResLayer(int layer, OUString const & url); void parseResLayer(int layer, OUString const & url);
void parseModificationLayer(OUString const & url); void parseModificationLayer(int layer, OUString const & url);
int getExtensionLayer(bool shared); int getExtensionLayer(bool shared);
...@@ -153,6 +153,8 @@ private: ...@@ -153,6 +153,8 @@ private:
class WriteThread; class WriteThread;
enum class ModificationTarget { None, File, Dconf };
css::uno::Reference< css::uno::XComponentContext > css::uno::Reference< css::uno::XComponentContext >
context_; context_;
Data data_; Data data_;
...@@ -161,6 +163,7 @@ private: ...@@ -161,6 +163,7 @@ private:
rtl::Reference< WriteThread > writeThread_; rtl::Reference< WriteThread > writeThread_;
int sharedExtensionLayer_; int sharedExtensionLayer_;
int userExtensionLayer_; int userExtensionLayer_;
ModificationTarget modificationTarget_;
OUString modificationFileUrl_; OUString modificationFileUrl_;
std::shared_ptr<osl::Mutex> lock_; std::shared_ptr<osl::Mutex> lock_;
}; };
......
...@@ -52,7 +52,7 @@ $(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_ ...@@ -52,7 +52,7 @@ $(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_
&& echo 'BRAND_BASE_DIR=$${ORIGIN}/..' \ && echo 'BRAND_BASE_DIR=$${ORIGIN}/..' \
&& echo 'BRAND_INI_DIR=$${ORIGIN}' \ && echo 'BRAND_INI_DIR=$${ORIGIN}' \
&& echo 'BRAND_SHARE_SUBDIR=$(LIBO_SHARE_FOLDER)' \ && echo 'BRAND_SHARE_SUBDIR=$(LIBO_SHARE_FOLDER)' \
&& echo 'CONFIGURATION_LAYERS=xcsxcu:$${BRAND_BASE_DIR}/$(LIBO_SHARE_FOLDER)/registry res:$${BRAND_BASE_DIR}/$(LIBO_SHARE_FOLDER)/registry $(if $(ENABLE_DCONF),dconf: )$(if $(filter WNT,$(OS)),winreg:LOCAL_MACHINE )bundledext:$${$${BRAND_BASE_DIR}/$(LIBO_ETC_FOLDER)/$(call gb_Helper_get_rcfile,louno):BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini sharedext:$${$${BRAND_BASE_DIR}/$(LIBO_ETC_FOLDER)/$(call gb_Helper_get_rcfile,louno):SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini userext:$${$${BRAND_BASE_DIR}/$(LIBO_ETC_FOLDER)/$(call gb_Helper_get_rcfile,louno):UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini $(if $(filter WNT,$(OS)),winreg:CURRENT_USER )user:$${$$BRAND_BASE_DIR/$(LIBO_ETC_FOLDER)/$(call gb_Helper_get_rcfile,bootstrap):UserInstallation}/user/registrymodifications.xcu' \ && echo 'CONFIGURATION_LAYERS=xcsxcu:$${BRAND_BASE_DIR}/$(LIBO_SHARE_FOLDER)/registry res:$${BRAND_BASE_DIR}/$(LIBO_SHARE_FOLDER)/registry $(if $(ENABLE_DCONF),dconf:* )$(if $(filter WNT,$(OS)),winreg:LOCAL_MACHINE )bundledext:$${$${BRAND_BASE_DIR}/$(LIBO_ETC_FOLDER)/$(call gb_Helper_get_rcfile,louno):BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini sharedext:$${$${BRAND_BASE_DIR}/$(LIBO_ETC_FOLDER)/$(call gb_Helper_get_rcfile,louno):SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini userext:$${$${BRAND_BASE_DIR}/$(LIBO_ETC_FOLDER)/$(call gb_Helper_get_rcfile,louno):UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini $(if $(filter WNT,$(OS)),winreg:CURRENT_USER )user:!$${$$BRAND_BASE_DIR/$(LIBO_ETC_FOLDER)/$(call gb_Helper_get_rcfile,bootstrap):UserInstallation}/user/registrymodifications.xcu' \
&& echo 'LO_JAVA_DIR=$${BRAND_BASE_DIR}/$(LIBO_SHARE_JAVA_FOLDER)' \ && echo 'LO_JAVA_DIR=$${BRAND_BASE_DIR}/$(LIBO_SHARE_JAVA_FOLDER)' \
&& echo 'LO_LIB_DIR=$${BRAND_BASE_DIR}/$(LIBO_LIB_FOLDER)' \ && echo 'LO_LIB_DIR=$${BRAND_BASE_DIR}/$(LIBO_LIB_FOLDER)' \
&& echo 'BAK_EXTENSIONS=$${$$ORIGIN/$(call gb_Helper_get_rcfile,louno):TMP_EXTENSIONS}' \ && echo 'BAK_EXTENSIONS=$${$$ORIGIN/$(call gb_Helper_get_rcfile,louno):TMP_EXTENSIONS}' \
......
...@@ -1119,7 +1119,7 @@ ProfileItem gid_Brand_Profileitem_Fundamental_Ure_Bin_Dir ...@@ -1119,7 +1119,7 @@ ProfileItem gid_Brand_Profileitem_Fundamental_Ure_Bin_Dir
End End
#if ENABLE_DCONF #if ENABLE_DCONF
#define CONFIGURATION_LAYERS_DCONF " dconf:" #define CONFIGURATION_LAYERS_DCONF " dconf:*"
#else #else
#define CONFIGURATION_LAYERS_DCONF #define CONFIGURATION_LAYERS_DCONF
#endif #endif
...@@ -1135,7 +1135,7 @@ ProfileItem gid_Brand_Profileitem_Fundamental_Configuration_Layers ...@@ -1135,7 +1135,7 @@ ProfileItem gid_Brand_Profileitem_Fundamental_Configuration_Layers
ModuleID = gid_Module_Root_Brand; ModuleID = gid_Module_Root_Brand;
Section = "Bootstrap"; Section = "Bootstrap";
Key = "CONFIGURATION_LAYERS"; Key = "CONFIGURATION_LAYERS";
Value = "xcsxcu:${BRAND_BASE_DIR}/" LIBO_SHARE_FOLDER "/registry res:${BRAND_BASE_DIR}/" LIBO_SHARE_FOLDER "/registry" CONFIGURATION_LAYERS_DCONF CONFIGURATION_LAYERS_WINREG " bundledext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/" PROFILENAME(louno) ":BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini sharedext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/" PROFILENAME(louno) ":SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini userext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/" PROFILENAME(louno) ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini " CONFIGURATION_LAYERS_WINUSERREG " user:${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" PROFILENAME(bootstrap) ":UserInstallation}/user/registrymodifications.xcu"; Value = "xcsxcu:${BRAND_BASE_DIR}/" LIBO_SHARE_FOLDER "/registry res:${BRAND_BASE_DIR}/" LIBO_SHARE_FOLDER "/registry" CONFIGURATION_LAYERS_DCONF CONFIGURATION_LAYERS_WINREG " bundledext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/" PROFILENAME(louno) ":BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini sharedext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/" PROFILENAME(louno) ":SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini userext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/" PROFILENAME(louno) ":UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini " CONFIGURATION_LAYERS_WINUSERREG " user:!${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" PROFILENAME(bootstrap) ":UserInstallation}/user/registrymodifications.xcu";
End End
#undef CONFIGURATION_LAYERS_DCONF #undef CONFIGURATION_LAYERS_DCONF
#undef CONFIGURATION_LAYERS_WINREG #undef CONFIGURATION_LAYERS_WINREG
......
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