Skip to content

Commit

Permalink
wsd: presets: pass xcu as json array instead of json object
Browse files Browse the repository at this point in the history
- this is done to make the json format consistent
- json format after this change
```json
{
  "autotext": [
    {
      "stamp": "\"780e98110c\"",
      "uri": "https://localhost:9980/wopi/settings/home/rashesh/work/collabora/online/master//test/data/presets/user/autotextuser.bau"
    }
  ],
  "browsersetting": [
    {
      "stamp": "\"780e98110c\"",
      "uri": "https://localhost:9980/wopi/settings/home/rashesh/work/collabora/online/master/test/data/presets/user/browsersetting.json"
    }
  ],
  "kind": "user",
  "wordbook": [
    {
      "stamp": "\"780e98110c\"",
      "uri": "https://localhost:9980/wopi/settings/home/rashesh/work/collabora/online/master//test/data/presets/user/dictionaryuser.dic"
    }
  ],
  "xcu": [
    {
      "stamp": "\"780e98110c\"",
      "uri": "https://localhost:9980/wopi/settings/home/rashesh/work/collabora/online/master//test/data/presets/user/configuser.xcu"
    }
  ]
}
```

Signed-off-by: Rashesh <[email protected]>
Change-Id: I37058c647eea6f6d17ef76cde99c79a73273ea53
  • Loading branch information
Rash419 committed Jan 27, 2025
1 parent 916dd52 commit 624b0fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
28 changes: 6 additions & 22 deletions wsd/DocumentBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1569,8 +1569,11 @@ class PresetsInstallTask

Poco::Path destDir(_presetsPath, groupName);
Poco::File(destDir).createDirectories();
std::string fileName =
Poco::Path(destDir.toString(), Uri::getFilenameWithExtFromURL(uri)).toString();
std::string fileName;
if (groupName == "xcu")
fileName = Poco::Path(destDir.toString(), "config.xcu").toString();
else
fileName = Poco::Path(destDir.toString(), Uri::getFilenameWithExtFromURL(uri)).toString();

queries.emplace_back(uri, stamp, fileName);
}
Expand All @@ -1595,25 +1598,6 @@ class PresetsInstallTask
queries.emplace_back(uri, stamp, "browsersetting.json");
}

void addXcu(Poco::JSON::Object::Ptr settings, std::vector<CacheQuery>& queries)
{
if (!settings->has("xcu"))
return;

auto xcu = settings->get("xcu").extract<Poco::JSON::Object::Ptr>();
if (xcu.isNull())
return;

const std::string uri = JsonUtil::getJSONValue<std::string>(xcu, "uri");
const std::string stamp = JsonUtil::getJSONValue<std::string>(xcu, "stamp");

Poco::Path destDir(_presetsPath, "xcu");
Poco::File(destDir).createDirectories();
std::string fileName = Poco::Path(destDir, "config.xcu").toString();

queries.emplace_back(uri, stamp, fileName);
}

public:
PresetsInstallTask(SocketPoll& poll, const std::string& configId,
const std::string& presetsPath,
Expand Down Expand Up @@ -1649,7 +1633,7 @@ class PresetsInstallTask
addBrowserSetting(settings, presets);
addGroup(settings, "autotext", presets);
addGroup(settings, "wordbook", presets);
addXcu(settings, presets);
addGroup(settings, "xcu", presets);
}

Cache::supplyConfigFiles(_configId, presets);
Expand Down
4 changes: 3 additions & 1 deletion wsd/FileServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ bool FileServerRequestHandler::isAdminLoggedIn(const HTTPRequest& request, http:

Poco::JSON::Array::Ptr configAutoTexts = new Poco::JSON::Array();
Poco::JSON::Array::Ptr configDictionaries = new Poco::JSON::Array();
Poco::JSON::Array::Ptr configXcu = new Poco::JSON::Array();
for (const auto& item : items)
{
Poco::JSON::Object::Ptr configEntry = new Poco::JSON::Object();
Expand All @@ -596,10 +597,11 @@ bool FileServerRequestHandler::isAdminLoggedIn(const HTTPRequest& request, http:
else if (item.first == "wordbook")
configDictionaries->add(configEntry);
else if (item.first == "xcu")
configInfo->set("xcu", configEntry);
configXcu->add(configEntry);
}
configInfo->set("autotext", configAutoTexts);
configInfo->set("wordbook", configDictionaries);
configInfo->set("xcu", configXcu);

if (serveBrowserSetttings)
{
Expand Down

0 comments on commit 624b0fb

Please sign in to comment.