blob: 787b65fa43db07d990a74e59f1affe6ff830b490 [file] [log] [blame]
Brad Bishop9aa5e2f2017-01-15 19:45:40 -05001#include <algorithm>
Brad Bishopadc45662016-10-28 20:00:57 -05002#include <sdbusplus/server.hpp>
Brad Bishop9aa5e2f2017-01-15 19:45:40 -05003#include <sdbusplus/exception.hpp>
Brad Bishopadc45662016-10-28 20:00:57 -05004#include <xyz/openbmc_project/Inventory/Manager/server.hpp>
5
Brad Bishop9aa5e2f2017-01-15 19:45:40 -05006
Brad Bishopadc45662016-10-28 20:00:57 -05007namespace sdbusplus
8{
Brad Bishopadc45662016-10-28 20:00:57 -05009namespace xyz
10{
11namespace openbmc_project
12{
13namespace Inventory
14{
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050015namespace server
16{
Brad Bishopadc45662016-10-28 20:00:57 -050017
18Manager::Manager(bus::bus& bus, const char* path)
19 : _xyz_openbmc_project_Inventory_Manager_interface(
20 bus, path, _interface, _vtable, this)
21{
22}
23
24
25int Manager::_callback_Notify(
26 sd_bus_message* msg, void* context, sd_bus_error* error)
27{
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050028 using sdbusplus::server::binding::details::convertForMessage;
Brad Bishopadc45662016-10-28 20:00:57 -050029
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050030 try
31 {
32 auto m = message::message(msg);
Brad Bishopadc45662016-10-28 20:00:57 -050033
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050034 sdbusplus::message::object_path path{};
35 std::map<std::string, std::map<std::string, sdbusplus::message::variant<int64_t, std::string>>> object{};
Brad Bishopadc45662016-10-28 20:00:57 -050036
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050037 m.read(path, object);
Brad Bishopadc45662016-10-28 20:00:57 -050038
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050039 auto o = static_cast<Manager*>(context);
40 o->notify(path, object);
Brad Bishopadc45662016-10-28 20:00:57 -050041
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050042 auto reply = m.new_method_return();
43 // No data to append on reply.
Brad Bishopadc45662016-10-28 20:00:57 -050044
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050045 reply.method_return();
46 }
47 catch(sdbusplus::internal_exception_t& e)
48 {
49 sd_bus_error_set_const(error, e.name(), e.description());
50 return -EINVAL;
51 }
52
53 return true;
Brad Bishopadc45662016-10-28 20:00:57 -050054}
55
56namespace details
57{
58namespace Manager
59{
60static const auto _param_Notify =
61 utility::tuple_to_array(message::types::type_id<
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050062 sdbusplus::message::object_path, std::map<std::string, std::map<std::string, sdbusplus::message::variant<int64_t, std::string>>>>());
63static const auto _return_Notify =
64 utility::tuple_to_array(std::make_tuple('\0'));
Brad Bishopadc45662016-10-28 20:00:57 -050065}
66}
67
68
69
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050070
Brad Bishopadc45662016-10-28 20:00:57 -050071const vtable::vtable_t Manager::_vtable[] = {
72 vtable::start(),
73
74 vtable::method("Notify",
75 details::Manager::_param_Notify
76 .data(),
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050077 details::Manager::_return_Notify
78 .data(),
Brad Bishopadc45662016-10-28 20:00:57 -050079 _callback_Notify),
80 vtable::end()
81};
82
Brad Bishop9aa5e2f2017-01-15 19:45:40 -050083} // namespace server
Brad Bishopadc45662016-10-28 20:00:57 -050084} // namespace Inventory
85} // namespace openbmc_project
86} // namespace xyz
Brad Bishopadc45662016-10-28 20:00:57 -050087} // namespace sdbusplus
88