blob: 4dabd404e6e42659f967baffc4bfd28ee809ee8e [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();
Patrick Williams1a25a102022-09-29 17:18:26 -050016 auto m = b.new_method_call("org.freedesktop.login1",
17 "/org/freedesktop/login1",
18 "org.freedesktop.login1.Manager", "ListUsers");
Patrick Williamse36cf852017-07-03 14:50:21 -050019 auto reply = b.call(m);
20
Patrick Williams9cde21f2022-08-29 10:33:27 -050021 using return_type =
22 std::vector<std::tuple<uint32_t, std::string, message::object_path>>;
23 auto users = reply.unpack<return_type>();
Patrick Williamse36cf852017-07-03 14:50:21 -050024
Andrew Geissler072da3e2018-01-18 07:21:42 -080025 for (auto& user : users)
Patrick Williamse36cf852017-07-03 14:50:21 -050026 {
27 std::cout << std::get<std::string>(user) << "\n";
28 }
29
30 return 0;
31}