Patrick Williams | e36cf85 | 2017-07-03 14:50:21 -0500 | [diff] [blame] | 1 | #include <sdbusplus/bus.hpp> |
| 2 | #include <iostream> |
| 3 | #include <cstdint> |
| 4 | |
| 5 | /** An example dbus client application. |
| 6 | * Calls org.freedesktop.login1's ListUsers interface to find all active |
| 7 | * users in the system and displays their username. |
| 8 | */ |
| 9 | |
| 10 | int main() |
| 11 | { |
| 12 | using namespace sdbusplus; |
| 13 | |
| 14 | auto b = bus::new_system(); |
| 15 | auto m = b.new_method_call("org.freedesktop.login1", |
| 16 | "/org/freedesktop/login1", |
| 17 | "org.freedesktop.login1.Manager", |
| 18 | "ListUsers"); |
| 19 | auto reply = b.call(m); |
| 20 | |
| 21 | std::vector<std::tuple<uint32_t, std::string, message::object_path>> users; |
| 22 | reply.read(users); |
| 23 | |
| 24 | for(auto& user : users) |
| 25 | { |
| 26 | std::cout << std::get<std::string>(user) << "\n"; |
| 27 | } |
| 28 | |
| 29 | return 0; |
| 30 | } |