Skip to content

Commit

Permalink
Add UUID to app list response
Browse files Browse the repository at this point in the history
  • Loading branch information
ClassicOldSong committed Sep 22, 2024
1 parent 92f27fd commit 102c7b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 13 additions & 11 deletions src/nvhttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions src/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>("uuid"s);
if (input_uuid && !input_uuid.value().empty()) {
new_app_uuid = input_uuid.value();
Expand Down Expand Up @@ -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)));
}
}
}
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 102c7b2

Please sign in to comment.