From 102c7b266e07bd668905b4406d9cf71b804588fc Mon Sep 17 00:00:00 2001 From: Yukino Song Date: Mon, 23 Sep 2024 05:25:24 +0800 Subject: [PATCH] Add UUID to app list response --- src/crypto.h | 2 +- src/nvhttp.cpp | 24 +++++++++++++----------- src/process.cpp | 7 ++++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/crypto.h b/src/crypto.h index 9e21f526..69595a9f 100644 --- a/src/crypto.h +++ b/src/crypto.h @@ -45,7 +45,7 @@ namespace crypto { input_touch = _input << 1, // Allow touch input input_pen = _input << 2, // Allow pen input input_mouse = _input << 3, // Allow mouse input - input_kbd = _input << 4, // Allow keyboard input + input_kbd = _input << 4, // Allow keyboard input _all_inputs = input_controller | input_touch | input_pen | input_mouse | input_kbd, _operation = _input << 8, // Operation permission group diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index 11fdbc67..4fcd35f7 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -957,25 +957,27 @@ namespace nvhttp { auto named_cert_p = get_verified_cert(request); if (!!(named_cert_p->perm & PERM::_all_actions)) { - for (auto &proc : proc::proc.get_apps()) { - pt::ptree app; + for (auto &app : proc::proc.get_apps()) { + pt::ptree app_node; - app.put("IsHdrSupported"s, video::active_hevc_mode == 3 ? 1 : 0); - app.put("AppTitle"s, proc.name); - app.put("ID", proc.id); + app_node.put("IsHdrSupported"s, video::active_hevc_mode == 3 ? 1 : 0); + app_node.put("AppTitle"s, app.name); + app_node.put("UUID", app.uuid); + app_node.put("ID", app.id); - apps.push_back(std::make_pair("App", std::move(app))); + apps.push_back(std::make_pair("App", std::move(app_node))); } } else { BOOST_LOG(debug) << "Permission ListApp denied for [" << named_cert_p->name << "] (" << (uint32_t)named_cert_p->perm << ")"; - pt::ptree app; + pt::ptree app_node; - app.put("IsHdrSupported"s, 0); - app.put("AppTitle"s, "Permission Denied"); - app.put("ID", "1145141919810"); + app_node.put("IsHdrSupported"s, 0); + app_node.put("AppTitle"s, "Permission Denied"); + app_node.put("UUID", ""); + app_node.put("ID", "114514"); - apps.push_back(std::make_pair("App", std::move(app))); + apps.push_back(std::make_pair("App", std::move(app_node))); return; } diff --git a/src/process.cpp b/src/process.cpp index fadb0680..72188842 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -802,7 +802,6 @@ namespace proc { std::string new_app_uuid; if (inputTree_p) { - auto inputTree = *inputTree_p; auto input_uuid = inputTree_p->get_optional("uuid"s); if (input_uuid && !input_uuid.value().empty()) { new_app_uuid = input_uuid.value(); @@ -834,13 +833,13 @@ namespace proc { kv.second.erase("uuid"); kv.second.put("uuid", uuid_util::uuid_t::generate().string()); kv.second.erase("launching"); - newApps.push_back(std::make_pair("", kv.second)); + newApps.push_back(std::make_pair("", std::move(kv.second))); } else { if (!new_app_uuid.empty() && app_uuid.value() == new_app_uuid) { newApps.push_back(std::make_pair("", *inputTree_p)); new_app_uuid.clear(); } else { - newApps.push_back(std::make_pair("", kv.second)); + newApps.push_back(std::make_pair("", std::move(kv.second))); } } } @@ -881,8 +880,10 @@ namespace proc { if (!app_uuid) { // We need an upgrade to the app list try { + BOOST_LOG(info) << "Migrating app list..."; migrate_apps(&tree, nullptr); pt::write_json(file_name, tree); + BOOST_LOG(info) << "Migration complete."; return parse(file_name); } catch (std::exception &e) { BOOST_LOG(warning) << "Error happened wilie migrating the app list: "sv << e.what();