kit/Kit.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
New commits: commit 85195866749dcfbd533ce75bbc126844efd44aaf Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Mon Jan 30 02:53:38 2017 -0500 wsd: manually generate the viewinfo json string Change-Id: Ia1c1d8752fe134a43be2859db0eb8e87fe5d83f6 Reviewed-on: https://gerrit.libreoffice.org/33684 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/kit/Kit.cpp b/kit/Kit.cpp index b18602e..2d0ebeb 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -1035,24 +1035,23 @@ private: // Double check if list of viewids from core and our list matches, // and create an array of JSON objects containing id and username - Array::Ptr viewInfoArray = new Array(); - int arrayIndex = 0; + std::ostringstream oss; + oss << "viewinfo: ["; for (const auto& viewId : viewIds) { - Object::Ptr viewInfoObj = new Object(); - viewInfoObj->set("id", viewId); + oss << "{\"id\":" << viewId << ","; int color = 0; const auto itView = viewInfoMap.find(viewId); if (itView == viewInfoMap.end()) { LOG_ERR("No username found for viewId [" << viewId << "]."); - viewInfoObj->set("username", "Unknown"); + oss << "\"username\":\"Unknown\","; } else { - viewInfoObj->set("userid", itView->second.userid); + oss << "\"userid\":\"" << itView->second.userid << "\","; const auto username = itView->second.username; - viewInfoObj->set("username", username); + oss << "\"username\":\"" << username << "\","; const auto it = viewColorsMap.find(username); if (it != viewColorsMap.end()) { @@ -1060,13 +1059,12 @@ private: } } - viewInfoObj->set("color", color); - viewInfoArray->set(arrayIndex++, viewInfoObj); + oss << "\"color\":" << color << "},"; } - std::ostringstream ossViewInfo; - viewInfoArray->stringify(ossViewInfo); - const auto msg = "viewinfo: " + ossViewInfo.str(); + oss.seekp(-1, std::ios_base::cur); // Remove last comma. + oss << "]"; + const auto msg = oss.str(); std::unique_lock<std::mutex> lock(_mutex); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits