[glibmm] DBus: Add an initial client example accessing a user's bus.
- From: José Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] DBus: Add an initial client example accessing a user's bus.
- Date: Wed, 8 Dec 2010 05:54:58 +0000 (UTC)
commit 1908e2c8070183f6c94f4ed51ce75f8097650ba7
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Wed Dec 8 00:51:33 2010 -0500
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.
ChangeLog | 7 +++++++
examples/Makefile.am | 6 ++++++
examples/dbus/client.cc | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 22b1b7b..a035704 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-12-08 José Alburquerque <jaalburqu svn gnome org>
+ 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.
+
+2010-12-08 José Alburquerque <jaalburqu svn gnome org>
+
Add Gio::DBusConnection::get_sync() methods.
* gio/src/dbusconnection.hg: Wrap get_sync() methods (cancellable and
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 97967f9..9db5d2e 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 0000000..96d4158
--- /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;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]