Applets: Replace uses of JsonObject::get_deprecated()/get_ptr()

This commit is contained in:
Sam Atkins 2022-12-21 16:22:02 +00:00 committed by Tim Flynn
parent 87f1a0e957
commit 0716b2afdc
2 changed files with 15 additions and 15 deletions

View file

@ -127,10 +127,10 @@ private:
int connected_adapters = 0;
json.value().as_array().for_each([&adapter_info, &connected_adapters](auto& value) {
auto& if_object = value.as_object();
auto ip_address = if_object.get_deprecated("ipv4_address"sv).as_string_or("no IP");
auto ifname = if_object.get_deprecated("name"sv).to_deprecated_string();
auto link_up = if_object.get_deprecated("link_up"sv).as_bool();
auto link_speed = if_object.get_deprecated("link_speed"sv).to_i32();
auto ip_address = if_object.get_deprecated_string("ipv4_address"sv).value_or("no IP");
auto ifname = if_object.get_deprecated_string("name"sv).value();
auto link_up = if_object.get_bool("link_up"sv).value();
auto link_speed = if_object.get_i32("link_speed"sv).value();
if (ifname == "loop")
return;

View file

@ -167,8 +167,8 @@ private:
return false;
auto const& obj = json.value().as_object();
total = obj.get_deprecated("total_time"sv).to_u64();
idle = obj.get_deprecated("idle_time"sv).to_u64();
total = obj.get_u64("total_time"sv).value_or(0);
idle = obj.get_u64("idle_time"sv).value_or(0);
return true;
}
@ -179,11 +179,11 @@ private:
return false;
auto const& obj = json.value().as_object();
unsigned kmalloc_allocated = obj.get_deprecated("kmalloc_allocated"sv).to_u32();
unsigned kmalloc_available = obj.get_deprecated("kmalloc_available"sv).to_u32();
auto physical_allocated = obj.get_deprecated("physical_allocated"sv).to_u64();
auto physical_committed = obj.get_deprecated("physical_committed"sv).to_u64();
auto physical_uncommitted = obj.get_deprecated("physical_uncommitted"sv).to_u64();
unsigned kmalloc_allocated = obj.get_u32("kmalloc_allocated"sv).value_or(0);
unsigned kmalloc_available = obj.get_u32("kmalloc_available"sv).value_or(0);
auto physical_allocated = obj.get_u64("physical_allocated"sv).value_or(0);
auto physical_committed = obj.get_u64("physical_committed"sv).value_or(0);
auto physical_uncommitted = obj.get_u64("physical_uncommitted"sv).value_or(0);
unsigned kmalloc_bytes_total = kmalloc_allocated + kmalloc_available;
unsigned kmalloc_pages_total = (kmalloc_bytes_total + PAGE_SIZE - 1) / PAGE_SIZE;
u64 total_userphysical_and_swappable_pages = kmalloc_pages_total + physical_allocated + physical_committed + physical_uncommitted;
@ -203,13 +203,13 @@ private:
auto const& array = json.value().as_array();
for (auto const& adapter_value : array.values()) {
auto const& adapter_obj = adapter_value.as_object();
if (!adapter_obj.has_string("ipv4_address"sv) || !adapter_obj.get_deprecated("link_up"sv).as_bool())
if (!adapter_obj.has_string("ipv4_address"sv) || !adapter_obj.get_bool("link_up"sv).value())
continue;
tx += adapter_obj.get_deprecated("bytes_in"sv).to_u64();
rx += adapter_obj.get_deprecated("bytes_out"sv).to_u64();
tx += adapter_obj.get_u64("bytes_in"sv).value_or(0);
rx += adapter_obj.get_u64("bytes_out"sv).value_or(0);
// Link speed data is given in megabits, but we want all return values to be in bytes.
link_speed += adapter_obj.get_deprecated("link_speed"sv).to_u64() * 8'000'000;
link_speed += adapter_obj.get_u64("link_speed"sv).value_or(0) * 8'000'000;
}
link_speed /= 8;
return tx != 0;