rpms/dbus-glib/devel dbus-glib-0.74-export-getall.patch, NONE, 1.1 dbus-glib.spec, 1.23, 1.24
David Zeuthen (davidz)
fedora-extras-commits at redhat.com
Fri Apr 4 19:36:46 UTC 2008
Author: davidz
Update of /cvs/pkgs/rpms/dbus-glib/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv5476
Modified Files:
dbus-glib.spec
Added Files:
dbus-glib-0.74-export-getall.patch
Log Message:
* Fri Apr 4 2008 David Zeuthen <davidz at redhat.com> - 0.74-5
- Add an already upstreamed patch to export the GetAll() method on
the org.freedesktop.DBus.Properties interface
dbus-glib-0.74-export-getall.patch:
--- NEW FILE dbus-glib-0.74-export-getall.patch ---
From: David Zeuthen <davidz at redhat.com>
Date: Sat, 15 Mar 2008 20:51:48 +0000 (-0400)
Subject: Export the recently added GetAll() method on org.fd.DBus.Properties
X-Git-Url: http://gitweb.freedesktop.org/?p=dbus/dbus-glib.git;a=commitdiff;h=09b0fc5818812d0167243bae9fd52cdaf67f0af0
Export the recently added GetAll() method on org.fd.DBus.Properties
Because round-trip city is a bad place.
---
--- a/dbus/dbus-gobject.c
+++ b/dbus/dbus-gobject.c
@@ -612,7 +612,7 @@ handle_introspect (DBusConnection *conne
g_string_append (xml, " </method>\n");
g_string_append (xml, " </interface>\n");
- /* We support get/set properties */
+ /* We support get/set/getall properties */
g_string_append_printf (xml, " <interface name=\"%s\">\n", DBUS_INTERFACE_PROPERTIES);
g_string_append (xml, " <method name=\"Get\">\n");
g_string_append_printf (xml, " <arg name=\"interface\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
@@ -624,6 +624,17 @@ handle_introspect (DBusConnection *conne
g_string_append_printf (xml, " <arg name=\"propname\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
g_string_append_printf (xml, " <arg name=\"value\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_VARIANT_AS_STRING);
g_string_append (xml, " </method>\n");
+ g_string_append (xml, " <method name=\"GetAll\">\n");
+ g_string_append_printf (xml, " <arg name=\"interface\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
+ g_string_append_printf (xml, " <arg name=\"props\" direction=\"out\" type=\"%s\"/>\n",
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING
+ );
+
+ g_string_append (xml, " </method>\n");
g_string_append (xml, " </interface>\n");
introspect_interfaces (object, xml);
@@ -752,6 +763,113 @@ get_object_property (DBusConnection *con
return ret;
}
+static DBusMessage*
+get_all_object_properties (DBusConnection *connection,
+ DBusMessage *message,
+ const DBusGObjectInfo *object_info,
+ GObject *object)
+{
+ DBusMessage *ret;
+ DBusMessageIter iter_ret;
+ DBusMessageIter iter_dict;
+ DBusMessageIter iter_dict_entry;
+ DBusMessageIter iter_dict_value;
+ const char *p;
+
+ ret = dbus_message_new_method_return (message);
+ if (ret == NULL)
+ goto oom;
+
+ dbus_message_iter_init_append (ret, &iter_ret);
+
+ if (!dbus_message_iter_open_container (&iter_ret,
+ DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+ &iter_dict))
+ goto oom;
+
+ p = object_info->exported_properties;
+ while (p != NULL && *p != '\0')
+ {
+ const char *prop_ifname;
+ const char *prop_name;
+ GParamSpec *pspec;
+ GType value_gtype;
+ GValue value = {0, };
+ gchar *variant_sig;
+
+ prop_ifname = p;
+
+ while (*p != '\0')
+ p++;
+ p++;
+ if (*p == '\0') {
+ g_warning ("malformed exported_properties in object_info");
+ break;
+ }
+ prop_name = p;
+ while (*p != '\0')
+ p++;
+ p++;
+
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), prop_name);
+ if (pspec == NULL)
+ {
+ g_warning ("introspection data references non-existing property %s", prop_name);
+ continue;
+ }
+
+ g_value_init (&value, pspec->value_type);
+ g_object_get_property (object, pspec->name, &value);
+
+ variant_sig = _dbus_gvalue_to_signature (&value);
+ if (variant_sig == NULL)
+ {
+ value_gtype = G_VALUE_TYPE (&value);
+ g_warning ("Cannot marshal type \"%s\" in variant", g_type_name (value_gtype));
+ g_value_unset (&value);
+ continue;
+ }
+
+ if (!dbus_message_iter_open_container (&iter_dict,
+ DBUS_TYPE_DICT_ENTRY,
+ NULL,
+ &iter_dict_entry))
+ goto oom;
+ if (!dbus_message_iter_append_basic (&iter_dict_entry, DBUS_TYPE_STRING, &prop_name))
+ goto oom;
+
+ if (!dbus_message_iter_open_container (&iter_dict_entry,
+ DBUS_TYPE_VARIANT,
+ variant_sig,
+ &iter_dict_value))
+ goto oom;
+
+ if (!_dbus_gvalue_marshal (&iter_dict_value, &value))
+ goto oom;
+
+ if (!dbus_message_iter_close_container (&iter_dict_entry,
+ &iter_dict_value))
+ goto oom;
+ if (!dbus_message_iter_close_container (&iter_dict, &iter_dict_entry))
+ goto oom;
+
+ g_value_unset (&value);
+ g_free (variant_sig);
+ }
+
+ if (!dbus_message_iter_close_container (&iter_ret, &iter_dict))
+ goto oom;
+
+ return ret;
+
+ oom:
+ g_error ("out of memory");
+}
+
static gboolean
lookup_object_and_method (GObject *object,
DBusMessage *message,
@@ -1278,12 +1396,14 @@ gobject_message_function (DBusConnection
GObject *object;
gboolean setter;
gboolean getter;
+ gboolean getall;
char *s;
const char *wincaps_propname;
/* const char *wincaps_propiface; */
DBusMessageIter iter;
const DBusGMethodInfo *method;
const DBusGObjectInfo *object_info;
+ DBusMessage *ret;
object = G_OBJECT (user_data);
@@ -1291,8 +1411,9 @@ gobject_message_function (DBusConnection
DBUS_INTERFACE_INTROSPECTABLE,
"Introspect"))
return handle_introspect (connection, message, object);
-
+
/* Try the metainfo, which lets us invoke methods */
+ object_info = NULL;
if (lookup_object_and_method (object, message, &object_info, &method))
return invoke_object_method (object, object_info, method, connection, message);
@@ -1301,6 +1422,7 @@ gobject_message_function (DBusConnection
*/
getter = FALSE;
setter = FALSE;
+ getall = FALSE;
if (dbus_message_is_method_call (message,
DBUS_INTERFACE_PROPERTIES,
"Get"))
@@ -1309,10 +1431,16 @@ gobject_message_function (DBusConnection
DBUS_INTERFACE_PROPERTIES,
"Set"))
setter = TRUE;
+ else if (dbus_message_is_method_call (message,
+ DBUS_INTERFACE_PROPERTIES,
+ "GetAll"))
+ getall = TRUE;
- if (!(setter || getter))
+ if (!(setter || getter || getall))
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ ret = NULL;
+
dbus_message_iter_init (message, &iter);
if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
@@ -1326,59 +1454,65 @@ gobject_message_function (DBusConnection
/* dbus_message_iter_get_basic (&iter, &wincaps_propiface); */
dbus_message_iter_next (&iter);
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
+ if (getall)
{
- g_warning ("Property get or set does not have a property name string as second arg\n");
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ if (object_info != NULL)
+ ret = get_all_object_properties (connection, message, object_info, object);
+ else
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- dbus_message_iter_get_basic (&iter, &wincaps_propname);
- dbus_message_iter_next (&iter);
-
- s = _dbus_gutils_wincaps_to_uscore (wincaps_propname);
+ else if (getter || setter)
+ {
+ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
+ {
+ g_warning ("Property get or set does not have a property name string as second arg\n");
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+ dbus_message_iter_get_basic (&iter, &wincaps_propname);
+ dbus_message_iter_next (&iter);
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
- s);
+ s = _dbus_gutils_wincaps_to_uscore (wincaps_propname);
- g_free (s);
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
+ s);
- if (pspec != NULL)
- {
- DBusMessage *ret;
+ g_free (s);
- if (setter)
+ if (pspec != NULL)
{
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_VARIANT)
+ if (setter)
{
- g_warning ("Property set does not have a variant value as third arg\n");
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_VARIANT)
+ {
+ g_warning ("Property set does not have a variant value as third arg\n");
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ ret = set_object_property (connection, message, &iter,
+ object, pspec);
+ dbus_message_iter_next (&iter);
+ }
+ else if (getter)
+ {
+ ret = get_object_property (connection, message,
+ object, pspec);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ ret = NULL;
}
-
- ret = set_object_property (connection, message, &iter,
- object, pspec);
- dbus_message_iter_next (&iter);
- }
- else if (getter)
- {
- ret = get_object_property (connection, message,
- object, pspec);
- }
- else
- {
- g_assert_not_reached ();
- ret = NULL;
}
+ }
- g_assert (ret != NULL);
-
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_INVALID)
- g_warning ("Property get or set had too many arguments\n");
+ g_assert (ret != NULL);
- dbus_connection_send (connection, ret, NULL);
- dbus_message_unref (ret);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
+ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_INVALID)
+ g_warning ("Property get, set or set all had too many arguments\n");
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ dbus_connection_send (connection, ret, NULL);
+ dbus_message_unref (ret);
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static const DBusObjectPathVTable gobject_dbus_vtable = {
Index: dbus-glib.spec
===================================================================
RCS file: /cvs/pkgs/rpms/dbus-glib/devel/dbus-glib.spec,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- dbus-glib.spec 19 Mar 2008 16:10:41 -0000 1.23
+++ dbus-glib.spec 4 Apr 2008 19:35:07 -0000 1.24
@@ -8,7 +8,7 @@
Summary: GLib bindings for D-Bus
Name: dbus-glib
Version: 0.74
-Release: 4%{?dist}
+Release: 5%{?dist}
URL: http://www.freedesktop.org/software/dbus/
Source0: http://dbus.freedesktop.org/releases/dbus-glib/%{name}-%{version}.tar.gz
Source1: dbus-bus-introspect.xml
@@ -16,6 +16,7 @@
Patch1: dbus-glib-proxy-signals-once.patch
# https://bugs.freedesktop.org/show_bug.cgi?id=14429
Patch2: dbus-glib-0.73-ignore-namespaces-and-children.patch
+Patch3: dbus-glib-0.74-export-getall.patch
License: AFL/GPL
Group: System Environment/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -64,6 +65,7 @@
%patch0 -p1 -b .broken-xml
%patch1 -p1 -b .proxy-signals-once
%patch2 -p1 -b .ignore-namespaces
+%patch3 -p1 -b .export-getall
%build
@@ -119,6 +121,10 @@
%endif
%changelog
+* Fri Apr 4 2008 David Zeuthen <davidz at redhat.com> - 0.74-5
+- Add an already upstreamed patch to export the GetAll() method on
+ the org.freedesktop.DBus.Properties interface
+
* Wed Mar 19 2008 Dan Williams <dcbw at redhat.com> - 0.74-4
- Ignore children of namespaced nodes too
More information about the fedora-extras-commits
mailing list