diff options
author | Murray Cumming <murrayc@murrayc.com> | 2011-04-02 15:28:07 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2011-04-02 15:28:07 +0200 |
commit | 15288eecbacb6aa545886eeb3d5a34c62441fcc2 (patch) | |
tree | 5d52c9bc02ab8c166b008a48aa26881d75b62a2f /gio/src/dbusintrospection.ccg | |
parent | f62a4d722632fdc83c9c68add45f7c4cdcf5d115 (diff) | |
download | glibmm-15288eecbacb6aa545886eeb3d5a34c62441fcc2.tar.gz |
Gio::DBus::NodeInfo::lookup_interface(): Add a method overload with no name.
* gio/src/dbusintrospection.[hg|ccg]: Add a lookup_interface() method overload
that just returns the first interface, avoiding the need to specify the name
when there is only one interface. The C API will not do this itself:
See bug #646417.
* examples/dbus/peer.cc:
* examples/dbus/server.cc:
* examples/dbus/session_bus_service.cc: Use the new method to simplify the
code slightly.
Diffstat (limited to 'gio/src/dbusintrospection.ccg')
-rw-r--r-- | gio/src/dbusintrospection.ccg | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gio/src/dbusintrospection.ccg b/gio/src/dbusintrospection.ccg index 4ea7e166..77638e39 100644 --- a/gio/src/dbusintrospection.ccg +++ b/gio/src/dbusintrospection.ccg @@ -20,4 +20,32 @@ namespace Gio { +namespace DBus +{ + +//We hand-code this because g_dbus_node_info_lookup_interface() doesn't +//do this when it takes a NULL. +//See bug https://bugzilla.gnome.org/show_bug.cgi?id=646417 +Glib::RefPtr<InterfaceInfo> NodeInfo::lookup_interface() +{ + Glib::RefPtr<InterfaceInfo> retvalue; + + if(!gobj() || !(gobj()->interfaces)) + return retvalue; + + retvalue = Glib::wrap(gobj()->interfaces[0]); + + if(retvalue) + retvalue->reference(); //The function does not do a ref for us. + + return retvalue; +} + +Glib::RefPtr<const InterfaceInfo> NodeInfo::lookup_interface() const +{ + return const_cast<NodeInfo*>(this)->lookup_interface(); +} + +} //namespace DBus + } // namespace Gio |