[glibmm] Gio::DBus::NodeInfo::lookup_interface(): Add a method overload with no name.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Gio::DBus::NodeInfo::lookup_interface(): Add a method overload with no name.
- Date: Sat, 2 Apr 2011 13:28:19 +0000 (UTC)
commit 15288eecbacb6aa545886eeb3d5a34c62441fcc2
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Apr 2 15:28:07 2011 +0200
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.
ChangeLog | 13 +++++++++++++
examples/dbus/peer.cc | 2 +-
examples/dbus/server.cc | 2 +-
examples/dbus/session_bus_service.cc | 2 +-
gio/src/dbusintrospection.ccg | 28 ++++++++++++++++++++++++++++
gio/src/dbusintrospection.hg | 6 ++++++
6 files changed, 50 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dc274f7..c317fd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2011-04-02 Murray Cumming <murrayc murrayc com>
+ 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.
+
+2011-04-02 Murray Cumming <murrayc murrayc com>
+
Gio::DBus::Connection: Added a register_method() overload with no vtable.
* gio/src/dbusconnection.[hg|ccg]: This makes sense now that the C API's
diff --git a/examples/dbus/peer.cc b/examples/dbus/peer.cc
index 5d80d70..1f17e40 100644
--- a/examples/dbus/peer.cc
+++ b/examples/dbus/peer.cc
@@ -168,7 +168,7 @@ bool on_new_connection(const Glib::RefPtr<Gio::DBus::Connection>& connection)
curr_connection = connection;
const guint reg_id = connection->register_object("/org/glibmm/DBus/TestObject",
- introspection_data->lookup_interface("org.glibmm.DBus.TestPeerInterface"),
+ introspection_data->lookup_interface(),
interface_vtable);
if(reg_id == 0)
diff --git a/examples/dbus/server.cc b/examples/dbus/server.cc
index b8956d1..da62ac2 100644
--- a/examples/dbus/server.cc
+++ b/examples/dbus/server.cc
@@ -185,7 +185,7 @@ bool on_server_new_connection(const Glib::RefPtr<Gio::DBus::Connection>& connect
try
{
connection->register_object("/org/glibmm/DBus/TestObject",
- introspection_data->lookup_interface("org.glibmm.DBus.Clock"),
+ introspection_data->lookup_interface(),
interface_vtable);
}
catch(const Glib::Error& ex)
diff --git a/examples/dbus/session_bus_service.cc b/examples/dbus/session_bus_service.cc
index 80cd4ba..21b53c9 100644
--- a/examples/dbus/session_bus_service.cc
+++ b/examples/dbus/session_bus_service.cc
@@ -155,7 +155,7 @@ void on_bus_acquired(const Glib::RefPtr<Gio::DBus::Connection>& connection, cons
try
{
registered_id = connection->register_object("/org/glibmm/DBus/TestObject",
- introspection_data->lookup_interface("org.glibmm.DBusExample.Clock"),
+ introspection_data->lookup_interface(),
interface_vtable);
}
catch(const Glib::Error& ex)
diff --git a/gio/src/dbusintrospection.ccg b/gio/src/dbusintrospection.ccg
index 4ea7e16..77638e3 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
diff --git a/gio/src/dbusintrospection.hg b/gio/src/dbusintrospection.hg
index b125fe4..442cfb8 100644
--- a/gio/src/dbusintrospection.hg
+++ b/gio/src/dbusintrospection.hg
@@ -132,7 +132,13 @@ public:
_WRAP_METHOD(Glib::RefPtr<InterfaceInfo> lookup_interface(const Glib::ustring& name), g_dbus_node_info_lookup_interface, refreturn)
_WRAP_METHOD(Glib::RefPtr<const InterfaceInfo> lookup_interface(const Glib::ustring& name) const, g_dbus_node_info_lookup_interface, constversion, refreturn)
+
+ //TODO: Documentation:
+ Glib::RefPtr<InterfaceInfo> lookup_interface();
+ //TODO: Documentation:
+ Glib::RefPtr<const InterfaceInfo> lookup_interface() const;
+
//TODO: _WRAP_METHOD(void generate_xml(guint indent, GString* string_builder), g_dbus_node_info_generate_xml)
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]