summaryrefslogtreecommitdiff
path: root/examples/dbus
diff options
context:
space:
mode:
authorJosé Alburquerque <jaalburqu@svn.gnome.org>2010-12-08 00:51:33 -0500
committerJosé Alburquerque <jaalburqu@svn.gnome.org>2010-12-08 00:53:56 -0500
commit1908e2c8070183f6c94f4ed51ce75f8097650ba7 (patch)
tree638b1bf4a1ffcbbfaef1efd87c57508ec9755b5e /examples/dbus
parentea38b33e5856ac0310fab95ca26c5feffc9d207e (diff)
downloadglibmm-1908e2c8070183f6c94f4ed51ce75f8097650ba7.tar.gz
DBus: Add an initial client example accessing a user's bus.
* examples/dbus/client.cc: Initial example opening a connection to the user's bus and then printing its unique name.
Diffstat (limited to 'examples/dbus')
-rw-r--r--examples/dbus/client.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/dbus/client.cc b/examples/dbus/client.cc
new file mode 100644
index 00000000..96d41586
--- /dev/null
+++ b/examples/dbus/client.cc
@@ -0,0 +1,34 @@
+/* Copyright (C) 2010 The giomm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <giomm.h>
+#include <iostream>
+
+int main(int, char**)
+{
+ std::locale::global(std::locale(""));
+ Gio::init();
+
+ // Get the user session bus connection.
+ Glib::RefPtr<Gio::DBusConnection> connection =
+ Gio::DBusConnection::get_sync(Gio::BUS_TYPE_SESSION);
+
+ // Print out the unique name of the user session bus.
+ std::cout << connection->get_unique_name() << std::endl;
+
+ return 0;
+}