summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2011-04-02 15:28:07 +0200
committerMurray Cumming <murrayc@murrayc.com>2011-04-02 15:28:07 +0200
commit15288eecbacb6aa545886eeb3d5a34c62441fcc2 (patch)
tree5d52c9bc02ab8c166b008a48aa26881d75b62a2f
parentf62a4d722632fdc83c9c68add45f7c4cdcf5d115 (diff)
downloadglibmm-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.
-rw-r--r--ChangeLog13
-rw-r--r--examples/dbus/peer.cc2
-rw-r--r--examples/dbus/server.cc2
-rw-r--r--examples/dbus/session_bus_service.cc2
-rw-r--r--gio/src/dbusintrospection.ccg28
-rw-r--r--gio/src/dbusintrospection.hg6
6 files changed, 50 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index dc274f78..c317fd22 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 5d80d701..1f17e40c 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 b8956d1f..da62ac2d 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 80cd4ba4..21b53c91 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 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
diff --git a/gio/src/dbusintrospection.hg b/gio/src/dbusintrospection.hg
index b125fe42..442cfb8d 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)
};