example: add client API example
Create a small application which calls org.freedesktop.login1
to display a list of the active users.
Change-Id: I8d7879d98f6b89a9315aa0c71b928c50490dfedb
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/example/list-users.cpp b/example/list-users.cpp
new file mode 100644
index 0000000..245bf63
--- /dev/null
+++ b/example/list-users.cpp
@@ -0,0 +1,30 @@
+#include <sdbusplus/bus.hpp>
+#include <iostream>
+#include <cstdint>
+
+/** An example dbus client application.
+ * Calls org.freedesktop.login1's ListUsers interface to find all active
+ * users in the system and displays their username.
+ */
+
+int main()
+{
+ using namespace sdbusplus;
+
+ auto b = bus::new_system();
+ auto m = b.new_method_call("org.freedesktop.login1",
+ "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager",
+ "ListUsers");
+ auto reply = b.call(m);
+
+ std::vector<std::tuple<uint32_t, std::string, message::object_path>> users;
+ reply.read(users);
+
+ for(auto& user : users)
+ {
+ std::cout << std::get<std::string>(user) << "\n";
+ }
+
+ return 0;
+}