blob: 23913b0b305c0913d34bf83455884f94d46e1920 [file] [log] [blame]
Patrick Williams127b8ab2020-05-21 15:24:19 -05001#include <sdbusplus/bus.hpp>
2
Patrick Williamse36cf852017-07-03 14:50:21 -05003#include <cstdint>
Patrick Venture95269db2018-08-31 09:19:17 -07004#include <iostream>
Patrick Williamse36cf852017-07-03 14:50:21 -05005
6/** An example dbus client application.
7 * Calls org.freedesktop.login1's ListUsers interface to find all active
8 * users in the system and displays their username.
9 */
10
11int main()
12{
13 using namespace sdbusplus;
14
Vernon Mauery8ca60252018-11-08 14:55:34 -080015 auto b = bus::new_default_system();
Andrew Geissler072da3e2018-01-18 07:21:42 -080016 auto m =
17 b.new_method_call("org.freedesktop.login1", "/org/freedesktop/login1",
18 "org.freedesktop.login1.Manager", "ListUsers");
Patrick Williamse36cf852017-07-03 14:50:21 -050019 auto reply = b.call(m);
20
21 std::vector<std::tuple<uint32_t, std::string, message::object_path>> users;
22 reply.read(users);
23
Andrew Geissler072da3e2018-01-18 07:21:42 -080024 for (auto& user : users)
Patrick Williamse36cf852017-07-03 14:50:21 -050025 {
26 std::cout << std::get<std::string>(user) << "\n";
27 }
28
29 return 0;
30}