summaryrefslogtreecommitdiff
path: root/examples/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dbus')
-rw-r--r--examples/dbus/client_bus_listnames.cc16
-rw-r--r--examples/dbus/server_without_bus.cc8
-rw-r--r--examples/dbus/session_bus_service.cc6
3 files changed, 15 insertions, 15 deletions
diff --git a/examples/dbus/client_bus_listnames.cc b/examples/dbus/client_bus_listnames.cc
index b46fdcf8..7b9adad6 100644
--- a/examples/dbus/client_bus_listnames.cc
+++ b/examples/dbus/client_bus_listnames.cc
@@ -34,7 +34,7 @@ bool on_main_loop_idle()
// method.
void on_dbus_proxy_available(Glib::RefPtr<Gio::AsyncResult>& result)
{
- Glib::RefPtr<Gio::DBus::Proxy> proxy = Gio::DBus::Proxy::create_finish(result);
+ const auto proxy = Gio::DBus::Proxy::create_finish(result);
if(!proxy)
{
@@ -48,20 +48,20 @@ void on_dbus_proxy_available(Glib::RefPtr<Gio::AsyncResult>& result)
{
// The proxy's call method returns a tuple of the value(s) that the method
// call produces so just get the tuple as a VariantContainerBase.
- const Glib::VariantContainerBase result = proxy->call_sync("ListNames");
+ const auto call_result = proxy->call_sync("ListNames");
// Now extract the single item in the variant container which is the
// array of strings (the names).
- Glib::Variant< std::vector<Glib::ustring> > names_variant;
- result.get_child(names_variant);
+ Glib::Variant< std::vector<Glib::ustring>> names_variant;
+ call_result.get_child(names_variant);
// Get the vector of strings.
- std::vector<Glib::ustring> names = names_variant.get();
+ auto names = names_variant.get();
std::cout << "The names on the message bus are:" << std::endl;
- for(unsigned i = 0; i < names.size(); i++)
- std::cout << names[i] << "." << std::endl;
+ for(const auto& i : names)
+ std::cout << i << "." << std::endl;
}
catch(const Glib::Error& error)
{
@@ -81,7 +81,7 @@ int main(int, char**)
loop = Glib::MainLoop::create();
// Get the user session bus connection.
- Glib::RefPtr<Gio::DBus::Connection> connection =
+ auto connection =
Gio::DBus::Connection::get_sync(Gio::DBus::BUS_TYPE_SESSION);
// Check for an unavailable connection.
diff --git a/examples/dbus/server_without_bus.cc b/examples/dbus/server_without_bus.cc
index d50632dc..6002c149 100644
--- a/examples/dbus/server_without_bus.cc
+++ b/examples/dbus/server_without_bus.cc
@@ -68,7 +68,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& /* connect
curr_time.assign_current_time();
const Glib::ustring time_str = curr_time.as_iso8601();
- const Glib::Variant<Glib::ustring> time_var =
+ const auto time_var =
Glib::Variant<Glib::ustring>::create(time_str);
// Create the tuple.
@@ -114,7 +114,7 @@ const Gio::DBus::InterfaceVTable interface_vtable(sigc::ptr_fun(&on_method_call)
bool on_server_new_connection(const Glib::RefPtr<Gio::DBus::Connection>& connection)
{
- Glib::RefPtr<Gio::Credentials> credentials =
+ auto credentials =
connection->get_peer_credentials();
std::string credentials_str;
@@ -166,7 +166,7 @@ int main(int, char**)
std::locale::global(std::locale(""));
Gio::init();
- try
+ try
{
introspection_data = Gio::DBus::NodeInfo::create_for_xml(introspection_xml);
}
@@ -200,7 +200,7 @@ int main(int, char**)
server->signal_new_connection().connect(sigc::ptr_fun(&on_server_new_connection));
//Keep the server running until the process is killed:
- Glib::RefPtr<Glib::MainLoop> loop = Glib::MainLoop::create();
+ auto loop = Glib::MainLoop::create();
loop->run();
return EXIT_SUCCESS;
diff --git a/examples/dbus/session_bus_service.cc b/examples/dbus/session_bus_service.cc
index 0f0bd01d..ed320b8b 100644
--- a/examples/dbus/session_bus_service.cc
+++ b/examples/dbus/session_bus_service.cc
@@ -66,7 +66,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& /* connect
curr_time.assign_current_time();
const Glib::ustring time_str = curr_time.as_iso8601();
- const Glib::Variant<Glib::ustring> time_var =
+ const auto time_var =
Glib::Variant<Glib::ustring>::create(time_str);
// Create the tuple.
@@ -156,14 +156,14 @@ int main(int, char**)
return 1;
}
- const guint id = Gio::DBus::own_name(Gio::DBus::BUS_TYPE_SESSION,
+ const auto id = Gio::DBus::own_name(Gio::DBus::BUS_TYPE_SESSION,
"org.glibmm.DBusExample",
sigc::ptr_fun(&on_bus_acquired),
sigc::ptr_fun(&on_name_acquired),
sigc::ptr_fun(&on_name_lost));
//Keep the service running until the process is killed:
- Glib::RefPtr<Glib::MainLoop> loop = Glib::MainLoop::create();
+ auto loop = Glib::MainLoop::create();
loop->run();
Gio::DBus::unown_name(id);