mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 02:08:11 +00:00
LibCore: Add a way to set an individual Core::Object property remotely
This commit is contained in:
parent
ca110a6e54
commit
42f2696355
3 changed files with 27 additions and 0 deletions
|
@ -171,8 +171,25 @@ public:
|
||||||
m_inspected_object->decrement_inspector_count({});
|
m_inspected_object->decrement_inspector_count({});
|
||||||
m_inspected_object = object.make_weak_ptr();
|
m_inspected_object = object.make_weak_ptr();
|
||||||
m_inspected_object->increment_inspector_count({});
|
m_inspected_object->increment_inspector_count({});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "SetProperty") {
|
||||||
|
auto address = request.get("address").to_number<uintptr_t>();
|
||||||
|
for (auto& object : Object::all_objects()) {
|
||||||
|
if ((uintptr_t)&object == address) {
|
||||||
|
bool success = object.set_property(request.get("name").to_string(), request.get("value"));
|
||||||
|
JsonObject response;
|
||||||
|
response.set("type", "SetProperty");
|
||||||
|
response.set("success", success);
|
||||||
|
send_response(response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "Disconnect") {
|
if (type == "Disconnect") {
|
||||||
|
|
|
@ -173,6 +173,15 @@ void Object::save_to(JsonObject& json)
|
||||||
json.set("parent", (uintptr_t)parent());
|
json.set("parent", (uintptr_t)parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Object::set_property(const StringView& name, const JsonValue& value)
|
||||||
|
{
|
||||||
|
if (name == "name") {
|
||||||
|
set_name(value.to_string());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Object::is_ancestor_of(const Object& other) const
|
bool Object::is_ancestor_of(const Object& other) const
|
||||||
{
|
{
|
||||||
if (&other == this)
|
if (&other == this)
|
||||||
|
|
|
@ -111,6 +111,7 @@ public:
|
||||||
virtual bool is_window() const { return false; }
|
virtual bool is_window() const { return false; }
|
||||||
|
|
||||||
virtual void save_to(AK::JsonObject&);
|
virtual void save_to(AK::JsonObject&);
|
||||||
|
virtual bool set_property(const StringView& name, const JsonValue& value);
|
||||||
|
|
||||||
static IntrusiveList<Object, &Object::m_all_objects_list_node>& all_objects();
|
static IntrusiveList<Object, &Object::m_all_objects_list_node>& all_objects();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue