summaryrefslogtreecommitdiff
path: root/examples
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
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')
-rw-r--r--examples/Makefile.am6
-rw-r--r--examples/dbus/client.cc34
2 files changed, 40 insertions, 0 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 97967f90..9db5d2ee 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -20,6 +20,7 @@ AUTOMAKE_OPTIONS = subdir-objects
check_PROGRAMS = \
child_watch/child_watch \
compose/example \
+ dbus/client \
iochannel_stream/example \
keyfile/example \
markup/parser \
@@ -55,6 +56,7 @@ iochannel_stream_example_SOURCES = \
iochannel_stream/fdstream.h \
iochannel_stream/main.cc
+# glibmm examples
compose_example_SOURCES = compose/main.cc
keyfile_example_SOURCES = keyfile/main.cc
markup_parser_SOURCES = markup/parser.cc
@@ -71,6 +73,10 @@ thread_thread_LDADD = $(thread_ldadd)
thread_threadpool_SOURCES = thread/threadpool.cc
thread_threadpool_LDADD = $(thread_ldadd)
+# giomm examples
+dbus_client_SOURCES = dbus/client.cc
+dbus_client_LDADD = $(giomm_ldadd)
+
network_resolver_SOURCES = network/resolver.cc
network_resolver_LDADD = $(giomm_ldadd)
network_socket_client_SOURCES = network/socket-client.cc
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;
+}