Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 1 | #include <algorithm> |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 2 | #include <sdbusplus/server.hpp> |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 3 | #include <sdbusplus/exception.hpp> |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 4 | #include <xyz/openbmc_project/Inventory/Manager/server.hpp> |
| 5 | |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 6 | |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 7 | namespace sdbusplus |
| 8 | { |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 9 | namespace xyz |
| 10 | { |
| 11 | namespace openbmc_project |
| 12 | { |
| 13 | namespace Inventory |
| 14 | { |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 15 | namespace server |
| 16 | { |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 17 | |
| 18 | Manager::Manager(bus::bus& bus, const char* path) |
| 19 | : _xyz_openbmc_project_Inventory_Manager_interface( |
| 20 | bus, path, _interface, _vtable, this) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | |
| 25 | int Manager::_callback_Notify( |
| 26 | sd_bus_message* msg, void* context, sd_bus_error* error) |
| 27 | { |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 28 | using sdbusplus::server::binding::details::convertForMessage; |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 29 | |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 30 | try |
| 31 | { |
| 32 | auto m = message::message(msg); |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 33 | |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 34 | sdbusplus::message::object_path path{}; |
| 35 | std::map<std::string, std::map<std::string, sdbusplus::message::variant<int64_t, std::string>>> object{}; |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 36 | |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 37 | m.read(path, object); |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 38 | |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 39 | auto o = static_cast<Manager*>(context); |
| 40 | o->notify(path, object); |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 41 | |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 42 | auto reply = m.new_method_return(); |
| 43 | // No data to append on reply. |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 44 | |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 45 | 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 Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | namespace details |
| 57 | { |
| 58 | namespace Manager |
| 59 | { |
| 60 | static const auto _param_Notify = |
| 61 | utility::tuple_to_array(message::types::type_id< |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 62 | sdbusplus::message::object_path, std::map<std::string, std::map<std::string, sdbusplus::message::variant<int64_t, std::string>>>>()); |
| 63 | static const auto _return_Notify = |
| 64 | utility::tuple_to_array(std::make_tuple('\0')); |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | |
| 68 | |
| 69 | |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 70 | |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 71 | const vtable::vtable_t Manager::_vtable[] = { |
| 72 | vtable::start(), |
| 73 | |
| 74 | vtable::method("Notify", |
| 75 | details::Manager::_param_Notify |
| 76 | .data(), |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 77 | details::Manager::_return_Notify |
| 78 | .data(), |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 79 | _callback_Notify), |
| 80 | vtable::end() |
| 81 | }; |
| 82 | |
Brad Bishop | 9aa5e2f | 2017-01-15 19:45:40 -0500 | [diff] [blame] | 83 | } // namespace server |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 84 | } // namespace Inventory |
| 85 | } // namespace openbmc_project |
| 86 | } // namespace xyz |
Brad Bishop | adc4566 | 2016-10-28 20:00:57 -0500 | [diff] [blame] | 87 | } // namespace sdbusplus |
| 88 | |