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

configmgr/dconf: Simplify Fleet Commander write-back mode

* Get rid of different dconf trees for reading and writing again; the one single
  tree is /org/libreoffice/registry/.

* Trigger the special write-back mode when a file
  $SYSUSERCONFIG/libreoffice/dconfwrite is present; then, ignore the default
  user:!... entry in CONFIGURATION_LAYERS (i.e., don't use the
  UserInstallation's registrymodifications.xcu) and instead write changes back
  to the dconf tree.

Change-Id: I6b4d7251851da3fe7abbc9dcb080d57b278de96b
üst 1b5766f7
...@@ -537,9 +537,9 @@ Components::Components( ...@@ -537,9 +537,9 @@ Components::Components(
} else if (type == "dconf") { } else if (type == "dconf") {
if (url == "!") { if (url == "!") {
modificationTarget_ = ModificationTarget::Dconf; modificationTarget_ = ModificationTarget::Dconf;
dconf::readLayer(data_, Data::NO_LAYER, false); dconf::readLayer(data_, Data::NO_LAYER);
} else if (url == "*") { } else if (url == "*") {
dconf::readLayer(data_, layer, true); dconf::readLayer(data_, layer);
} else { } else {
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
"CONFIGURATION_LAYERS: unknown \"dconf\" kind \"" + url "CONFIGURATION_LAYERS: unknown \"dconf\" kind \"" + url
...@@ -579,11 +579,30 @@ Components::Components( ...@@ -579,11 +579,30 @@ Components::Components(
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
"CONFIGURATION_LAYERS: empty \"user\" URL"); "CONFIGURATION_LAYERS: empty \"user\" URL");
} }
bool ignore = false;
#if ENABLE_DCONF
if (write) { if (write) {
modificationTarget_ = ModificationTarget::File; OUString token(
modificationFileUrl_ = url; expand("${SYSUSERCONFIG}/libreoffice/dconfwrite"));
osl::DirectoryItem it;
osl::FileBase::RC e = osl::DirectoryItem::get(token, it);
ignore = e == osl::FileBase::E_None;
SAL_INFO(
"configmgr",
"dconf write (<" << token << "> " << +e << "): "
<< int(ignore));
if (ignore) {
modificationTarget_ = ModificationTarget::Dconf;
}
}
#endif
if (!ignore) {
if (write) {
modificationTarget_ = ModificationTarget::File;
modificationFileUrl_ = url;
}
parseModificationLayer(write ? Data::NO_LAYER : layer, url);
} }
parseModificationLayer(write ? Data::NO_LAYER : layer, url);
++layer; //TODO: overflow ++layer; //TODO: overflow
} else { } else {
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
......
...@@ -39,8 +39,7 @@ extern "C" { ...@@ -39,8 +39,7 @@ extern "C" {
// //
// * The node hierarchy (starting at component nodes with names like // * The node hierarchy (starting at component nodes with names like
// "org.openoffice.Setup") maps to dconf paths underneath // "org.openoffice.Setup") maps to dconf paths underneath
// "/org/libreoffice/registry/system/" resp. // "/org/libreoffice/registry/".
// "/org/libreoffice/registry/user/".
// //
// * Component, group, set, and localized property nodes map to dconf dirs, // * Component, group, set, and localized property nodes map to dconf dirs,
// while property and localized value nodes map to dconf keys. // while property and localized value nodes map to dconf keys.
...@@ -217,9 +216,8 @@ private: ...@@ -217,9 +216,8 @@ private:
DConfChangeset * changeset_; DConfChangeset * changeset_;
}; };
OString getRoot(bool system) { OString getRoot() {
return "/org/libreoffice/registry/" return "/org/libreoffice/registry";
+ (system ? OStringLiteral("system") : OStringLiteral("user"));
} }
bool decode(OUString * string, bool slash) { bool decode(OUString * string, bool slash) {
...@@ -1550,7 +1548,7 @@ bool addModifications( ...@@ -1550,7 +1548,7 @@ bool addModifications(
} }
void readLayer(Data & data, int layer, bool system) { void readLayer(Data & data, int layer) {
GObjectHolder<DConfClient> client(dconf_client_new()); GObjectHolder<DConfClient> client(dconf_client_new());
if (client.get() == nullptr) { if (client.get() == nullptr) {
SAL_WARN("configmgr.dconf", "dconf_client_new failed"); SAL_WARN("configmgr.dconf", "dconf_client_new failed");
...@@ -1558,7 +1556,7 @@ void readLayer(Data & data, int layer, bool system) { ...@@ -1558,7 +1556,7 @@ void readLayer(Data & data, int layer, bool system) {
} }
readDir( readDir(
data, layer, rtl::Reference<Node>(), data.getComponents(), client, data, layer, rtl::Reference<Node>(), data.getComponents(), client,
getRoot(system) + "/"); getRoot() + "/");
} }
void writeModifications(Components & components, Data & data) { void writeModifications(Components & components, Data & data) {
...@@ -1573,7 +1571,7 @@ void writeModifications(Components & components, Data & data) { ...@@ -1573,7 +1571,7 @@ void writeModifications(Components & components, Data & data) {
} }
for (auto const & i: data.modifications.getRoot().children) { for (auto const & i: data.modifications.getRoot().children) {
if (!addModifications( if (!addModifications(
components, cs, getRoot(false), rtl::Reference<Node>(), i.first, components, cs, getRoot(), rtl::Reference<Node>(), i.first,
data.getComponents().findNode(Data::NO_LAYER, i.first), data.getComponents().findNode(Data::NO_LAYER, i.first),
i.second)) i.second))
{ {
......
...@@ -19,7 +19,7 @@ namespace configmgr { ...@@ -19,7 +19,7 @@ namespace configmgr {
namespace configmgr { namespace dconf { namespace configmgr { namespace dconf {
void readLayer(Data & data, int layer, bool system); void readLayer(Data & data, int layer);
void writeModifications(Components & components, Data & data); void writeModifications(Components & components, Data & data);
......
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