diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2012-01-27 14:19:49 -0500 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2012-01-31 11:16:36 -0500 |
commit | 57e590754a66ae9d004983bd5124b95b72f6ea38 (patch) | |
tree | b0019753ea5edf1177c1727a9c361b53cab102b0 | |
parent | 0dc7588759bff4b5de47f621d43c326987709f86 (diff) |
Properties Interface: remove
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r-- | docs/reference/telepathy-glib-docs.sgml | 2 | ||||
-rw-r--r-- | docs/reference/telepathy-glib-sections.txt | 86 | ||||
-rw-r--r-- | spec/Makefile.am | 1 | ||||
-rw-r--r-- | spec/Properties_Interface.xml | 196 | ||||
-rw-r--r-- | spec/all.xml | 2 | ||||
-rw-r--r-- | telepathy-glib/Makefile.am | 2 | ||||
-rw-r--r-- | telepathy-glib/generic.xml | 2 | ||||
-rw-r--r-- | telepathy-glib/properties-mixin.c | 1162 | ||||
-rw-r--r-- | telepathy-glib/properties-mixin.h | 270 | ||||
-rw-r--r-- | telepathy-glib/proxy.c | 16 | ||||
-rw-r--r-- | tests/dbus/disconnection.c | 20 | ||||
-rw-r--r-- | tests/dbus/unsupported-interface.c | 101 |
12 files changed, 8 insertions, 1852 deletions
diff --git a/docs/reference/telepathy-glib-docs.sgml b/docs/reference/telepathy-glib-docs.sgml index 48f20b76d..d33f4b9b5 100644 --- a/docs/reference/telepathy-glib-docs.sgml +++ b/docs/reference/telepathy-glib-docs.sgml @@ -17,7 +17,6 @@ <title>General D-Bus support</title> <xi:include href="xml/proxy.xml"/> <xi:include href="xml/proxy-dbus-core.xml"/> - <xi:include href="xml/proxy-tp-properties.xml"/> <xi:include href="xml/dbus.xml"/> <xi:include href="xml/asv.xml"/> <xi:include href="xml/proxy-subclass.xml"/> @@ -134,7 +133,6 @@ <xi:include href="xml/exportable-channel.xml"/> <xi:include href="xml/base-channel.xml"/> <xi:include href="xml/presence-mixin.xml"/> - <xi:include href="xml/properties-mixin.xml"/> <xi:include href="xml/base-room-config.xml"/> <xi:include href="xml/group-mixin.xml"/> <xi:include href="xml/message-mixin.xml"/> diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index c13011af0..f196c2e3e 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -308,8 +308,6 @@ TpSvcDBusIntrospectable TpSvcDBusIntrospectableClass TpSvcDBusProperties TpSvcDBusPropertiesClass -TpSvcPropertiesInterface -TpSvcPropertiesInterfaceClass tp_svc_dbus_introspectable_implement_introspect tp_svc_dbus_introspectable_introspect_impl tp_svc_dbus_introspectable_return_from_introspect @@ -323,17 +321,6 @@ tp_svc_dbus_properties_return_from_get_all tp_svc_dbus_properties_return_from_set tp_svc_dbus_properties_set_impl tp_svc_dbus_properties_emit_properties_changed -tp_svc_properties_interface_get_properties_impl -tp_svc_properties_interface_return_from_get_properties -tp_svc_properties_interface_implement_get_properties -tp_svc_properties_interface_list_properties_impl -tp_svc_properties_interface_return_from_list_properties -tp_svc_properties_interface_implement_list_properties -tp_svc_properties_interface_set_properties_impl -tp_svc_properties_interface_return_from_set_properties -tp_svc_properties_interface_implement_set_properties -tp_svc_properties_interface_emit_properties_changed -tp_svc_properties_interface_emit_property_flags_changed <SUBSECTION Standard> tp_svc_dbus_introspectable_get_type tp_svc_dbus_properties_get_type @@ -1604,57 +1591,6 @@ TP_ANSI_BG_WHITE </SECTION> <SECTION> -<FILE>properties-mixin</FILE> -TpPropertySignature -TpProperty -TpPropertiesContext -TpPropertiesSetFunc -<TITLE>TpPropertiesMixin</TITLE> -<INCLUDE>telepathy-glib/properties-mixin.h</INCLUDE> -TpPropertiesMixin -TpPropertiesMixinClass -tp_properties_mixin_class_init -tp_properties_mixin_init -tp_properties_mixin_finalize -tp_properties_mixin_list_properties -tp_properties_mixin_get_properties -tp_properties_mixin_set_properties -tp_properties_mixin_has_property -tp_properties_context_has -tp_properties_context_has_other_than -tp_properties_context_get -tp_properties_context_get_value_count -tp_properties_context_remove -tp_properties_context_return -tp_properties_context_return_if_done -tp_properties_mixin_change_value -tp_properties_mixin_change_flags -tp_properties_mixin_emit_changed -tp_properties_mixin_emit_flags -tp_properties_mixin_is_readable -tp_properties_mixin_is_writable -tp_properties_mixin_iface_init -TP_TYPE_PROPERTY_INFO_STRUCT -TP_TYPE_PROPERTY_INFO_LIST -TP_TYPE_PROPERTY_VALUE_STRUCT -TP_TYPE_PROPERTY_VALUE_LIST -TP_TYPE_PROPERTY_FLAGS_STRUCT -TP_TYPE_PROPERTY_FLAGS_LIST -<SUBSECTION Private> -TP_PROPERTIES_MIXIN_CLASS_OFFSET_QUARK -TP_PROPERTIES_MIXIN_CLASS_OFFSET -TP_PROPERTIES_MIXIN_OFFSET_QUARK -TP_PROPERTIES_MIXIN_OFFSET -tp_properties_mixin_class_get_offset_quark -tp_properties_mixin_get_offset_quark -TpPropertiesMixinPrivate -TpPropertiesMixinClassPrivate -<SUBSECTION Standard> -TP_PROPERTIES_MIXIN_CLASS -TP_PROPERTIES_MIXIN -</SECTION> - -<SECTION> <FILE>base-room-config</FILE> <INCLUDE>telepathy-glib/base-room-config.h</INCLUDE> <TITLE>TpBaseRoomConfig</TITLE> @@ -2496,8 +2432,6 @@ TP_IFACE_CHANNEL_DISPATCH_OPERATION TP_IFACE_QUARK_CHANNEL_DISPATCH_OPERATION TP_IFACE_CHANNEL_REQUEST TP_IFACE_QUARK_CHANNEL_REQUEST -TP_IFACE_PROPERTIES_INTERFACE -TP_IFACE_QUARK_PROPERTIES_INTERFACE TP_IFACE_CLIENT TP_IFACE_QUARK_CLIENT TP_IFACE_CLIENT_APPROVER @@ -2819,7 +2753,6 @@ tp_iface_quark_connection_interface_presence tp_iface_quark_connection_interface_location tp_iface_quark_connection_manager tp_iface_quark_dbus_daemon -tp_iface_quark_properties_interface tp_iface_quark_protocol tp_iface_quark_protocol_interface_addressing tp_iface_quark_protocol_interface_avatars @@ -2874,25 +2807,6 @@ TpProxyFeaturePrivate </SECTION> <SECTION> -<FILE>proxy-tp-properties</FILE> -<TITLE>proxy-tp-properties</TITLE> -<INCLUDE>telepathy-glib/proxy.h</INCLUDE> -tp_cli_properties_interface_callback_for_get_properties -tp_cli_properties_interface_call_get_properties -tp_cli_properties_interface_run_get_properties -tp_cli_properties_interface_callback_for_list_properties -tp_cli_properties_interface_call_list_properties -tp_cli_properties_interface_run_list_properties -tp_cli_properties_interface_callback_for_set_properties -tp_cli_properties_interface_call_set_properties -tp_cli_properties_interface_run_set_properties -tp_cli_properties_interface_signal_callback_properties_changed -tp_cli_properties_interface_connect_to_properties_changed -tp_cli_properties_interface_signal_callback_property_flags_changed -tp_cli_properties_interface_connect_to_property_flags_changed -</SECTION> - -<SECTION> <FILE>proxy-dbus-core</FILE> <TITLE>proxy-dbus-core</TITLE> <INCLUDE>telepathy-glib/proxy.h</INCLUDE> diff --git a/spec/Makefile.am b/spec/Makefile.am index d0cca4da4..bf960b285 100644 --- a/spec/Makefile.am +++ b/spec/Makefile.am @@ -100,7 +100,6 @@ EXTRA_DIST = \ Connection_Manager.xml \ Connection_Manager_Interface_Account_Storage.xml \ Debug.xml \ - Properties_Interface.xml \ Protocol.xml \ Protocol_Interface_Addressing.xml \ Protocol_Interface_Avatars.xml \ diff --git a/spec/Properties_Interface.xml b/spec/Properties_Interface.xml deleted file mode 100644 index 09ce3b9c2..000000000 --- a/spec/Properties_Interface.xml +++ /dev/null @@ -1,196 +0,0 @@ -<?xml version="1.0" ?> -<node name="/Properties_Interface" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> - <tp:copyright> Copyright (C) 2005-2007 Collabora Limited </tp:copyright> - <tp:copyright> Copyright (C) 2005, 2006 Nokia Corporation </tp:copyright> - <tp:copyright> Copyright (C) 2006 INdT </tp:copyright> - <tp:license xmlns="http://www.w3.org/1999/xhtml"> - <p>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.</p> - -<p>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.</p> - -<p>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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> - </tp:license> - <interface name="org.freedesktop.Telepathy.Properties"> - <tp:deprecated version="0.24.0">All uses of this interface have been - expunged, and it may now be laid to rest.</tp:deprecated> - - <tp:struct name="Property_Spec" array-name="Property_Spec_List"> - <tp:docstring>A struct (property ID, property name, D-Bus signature, - flags) representing a property, as returned by ListProperties on the - Properties interface.</tp:docstring> - <tp:member type="u" name="Property_ID"/> - <tp:member type="s" name="Name"/> - <tp:member type="s" tp:type="DBus_Signature" name="Signature"/> - <tp:member type="u" tp:type="Property_Flags" name="Flags"/> - </tp:struct> - - <tp:struct name="Property_Flags_Change" - array-name="Property_Flags_Change_List"> - <tp:docstring>A struct (property ID, flags) representing a change to - a property's flags, as seen in the PropertyFlagsChanged signal on - the Properties interface.</tp:docstring> - <tp:member type="u" name="Property_ID"/> - <tp:member type="u" name="New_Flags"/> - </tp:struct> - - <tp:simple-type name="Property_ID" type="u" array-name="Property_ID_List"> - <tp:docstring> - An unsigned integer used to represent a Telepathy property. - </tp:docstring> - </tp:simple-type> - - <tp:struct name="Property_Value" array-name="Property_Value_List"> - <tp:docstring>A struct (property ID, value) representing a - property's value, as seen in the PropertiesChanged signal on - the Properties interface, returned by the GetProperties method - and passed to the SetProperties method.</tp:docstring> - <tp:member type="u" tp:type="Property_ID" name="Identifier"/> - <tp:member type="v" name="Value"/> - </tp:struct> - - <method name="GetProperties" tp:name-for-bindings="Get_Properties"> - <tp:docstring> - Returns an array of (identifier, value) pairs containing the current - values of the given properties. - </tp:docstring> - <arg direction="in" name="Properties" type="au" tp:type="Property_ID[]"> - <tp:docstring>An array of property identifiers</tp:docstring> - </arg> - <arg direction="out" type="a(uv)" tp:type="Property_Value[]" - name="Values"> - <!-- XXX: if we're ever breaking API compatibility, make this a{uv} --> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - <p>An array of structs containing:</p> - <ul> - <li>integer identifiers</li> - <li>variant boxed values</li> - </ul> - </tp:docstring> - </arg> - <tp:possible-errors> - <tp:error name="org.freedesktop.Telepathy.Error.Disconnected"/> - <tp:error name="org.freedesktop.Telepathy.Error.InvalidArgument"> - <tp:docstring> - Some property identifier requested is invalid - </tp:docstring> - </tp:error> - <tp:error name="org.freedesktop.Telepathy.Error.PermissionDenied"> - <tp:docstring> - Some property requested does not have the PROPERTY_FLAG_READ flag - </tp:docstring> - </tp:error> - </tp:possible-errors> - </method> - <method name="ListProperties" tp:name-for-bindings="List_Properties"> - <tp:docstring> - Returns a dictionary of the properties available on this channel. - </tp:docstring> - <arg direction="out" type="a(ussu)" tp:type="Property_Spec[]" - name="Available_Properties"> - <!-- XXX: if we're ever breaking API compatibility, make this - a{u(ssu)} ? --> - <tp:docstring> - An array of structs containing: - <ul> - <li>an integer identifier</li> - <li>a string property name</li> - <li>a string representing the D-Bus signature of this property</li> - <li>a bitwise OR of the flags applicable to this property</li> - </ul> - </tp:docstring> - </arg> - </method> - <signal name="PropertiesChanged" tp:name-for-bindings="Properties_Changed"> - <tp:docstring> - Emitted when the value of readable properties has changed. - </tp:docstring> - <arg name="Properties" type="a(uv)" tp:type="Property_Value[]"> - <!-- XXX: if we're ever breaking API compatibility, make this a{uv} --> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - <p>An array of structs containing:</p> - <ul> - <li>integer identifiers</li> - <li>variant boxed values</li> - </ul> - <p>The array should contain only properties whose values have - actually changed.</p> - </tp:docstring> - </arg> - </signal> - <signal name="PropertyFlagsChanged" - tp:name-for-bindings="Property_Flags_Changed"> - <tp:docstring> - Emitted when the flags of some room properties have changed. - </tp:docstring> - <arg name="Properties" type="a(uu)" tp:type="Property_Flags_Change[]"> - <!-- XXX: if we're ever breaking API compatibility, make this a{uu} --> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - <p>An array of structs containing:</p> - <ul> - <li>integer identifiers</li> - <li>a bitwise OR of the current flags</li> - </ul> - <p>The array should contain only properties whose flags have actually - changed.</p> - </tp:docstring> - </arg> - </signal> - <method name="SetProperties" tp:name-for-bindings="Set_Properties"> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - <p>Takes an array of (identifier, value) pairs containing desired - values to set the given properties. In the case of any errors, no - properties will be changed. When the changes have been acknowledged - by the server, the PropertiesChanged signal will be emitted.</p> - - <p>All properties given must have the PROPERTY_FLAG_WRITE flag, or - PermissionDenied will be returned. If any variants are of the wrong - type, NotAvailable will be returned. If any given property identifiers - are invalid, InvalidArgument will be returned.</p> - </tp:docstring> - - <arg direction="in" name="Properties" type="a(uv)" - tp:type="Property_Value[]"> - <!-- XXX: if we're ever breaking API compatibility, make this a{uv} --> - <tp:docstring> - An array mapping integer property identifiers to boxed values - </tp:docstring> - </arg> - <tp:possible-errors> - <tp:error name="org.freedesktop.Telepathy.Error.Disconnected"/> - <tp:error name="org.freedesktop.Telepathy.Error.InvalidArgument"/> - <tp:error name="org.freedesktop.Telepathy.Error.NotAvailable"/> - <tp:error name="org.freedesktop.Telepathy.Error.PermissionDenied"/> - <tp:error name="org.freedesktop.Telepathy.Error.NetworkError"/> - </tp:possible-errors> - </method> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - <p>Interface for channels and other objects, to allow querying and setting - properties. ListProperties returns which properties are valid for - the given channel, including their type, and an integer handle used to - refer to them in GetProperties, SetProperties, and the PropertiesChanged - signal. The values are represented by D-Bus variant types, and are - accompanied by flags indicating whether or not the property is readable or - writable.</p> - - <p>Each property also has a flags value to indicate what methods are - available. This is a bitwise OR of PropertyFlags values.</p> - </tp:docstring> - <tp:flags name="Property_Flags" value-prefix="Property_Flag" type="u"> - <tp:flag suffix="Read" value="1"> - <tp:docstring>The property can be read</tp:docstring> - </tp:flag> - <tp:flag suffix="Write" value="2"> - <tp:docstring>The property can be written</tp:docstring> - </tp:flag> - </tp:flags> - </interface> -</node> -<!-- vim:set sw=2 sts=2 et ft=xml: --> diff --git a/spec/all.xml b/spec/all.xml index dc63fe59d..d5404acd6 100644 --- a/spec/all.xml +++ b/spec/all.xml @@ -294,8 +294,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ <xi:include href="Channel_Handler.xml"/> </tp:section> -<xi:include href="Properties_Interface.xml"/> - <xi:include href="errors.xml"/> <xi:include href="generic-types.xml"/> diff --git a/telepathy-glib/Makefile.am b/telepathy-glib/Makefile.am index baef1543b..3feaf1e3e 100644 --- a/telepathy-glib/Makefile.am +++ b/telepathy-glib/Makefile.am @@ -87,7 +87,6 @@ our_headers = \ message-mixin.h \ observe-channels-context.h \ presence-mixin.h \ - properties-mixin.h \ protocol.h \ proxy.h \ proxy-subclass.h \ @@ -236,7 +235,6 @@ libtelepathy_glib_internal_la_SOURCES = \ observe-channels-context-internal.h \ observe-channels-context.c \ presence-mixin.c \ - properties-mixin.c \ protocol.c \ protocol-internal.h \ proxy.c \ diff --git a/telepathy-glib/generic.xml b/telepathy-glib/generic.xml index 5e50972fc..4fc42b4f0 100644 --- a/telepathy-glib/generic.xml +++ b/telepathy-glib/generic.xml @@ -8,6 +8,4 @@ <xi:include href="dbus-introspectable.xml"/> <xi:include href="dbus-properties.xml"/> -<xi:include href="../spec/Properties_Interface.xml"/> - </tp:spec> diff --git a/telepathy-glib/properties-mixin.c b/telepathy-glib/properties-mixin.c deleted file mode 100644 index 43ef828e8..000000000 --- a/telepathy-glib/properties-mixin.c +++ /dev/null @@ -1,1162 +0,0 @@ -/* - * properties-mixin.c - Source for TpPropertiesMixin - * Copyright (C) 2006-2007 Collabora Ltd. - * Copyright (C) 2006-2007 Nokia Corporation - * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk> - * @author Robert McQueen <robert.mcqueen@collabora.co.uk> - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * SECTION:properties-mixin - * @title: TpPropertiesMixin - * @short_description: a mixin implementation of the Telepathy.Properties - * interface - * @see_also: #TpSvcPropertiesInterface - * - * This mixin can be added to any GObject class to implement the properties - * interface in a general way. - * - * To use the properties mixin, include a #TpPropertiesMixinClass somewhere - * in your class structure and a #TpPropertiesMixin somewhere in your - * instance structure, and call tp_properties_mixin_class_init() from your - * class_init function, tp_properties_mixin_init() from your init function - * or constructor, and tp_properties_mixin_finalize() from your dispose - * or finalize function. - * - * To use the properties mixin as the implementation of - * #TpSvcPropertiesInterface, call - * <literal>G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_PROPERTIES_INTERFACE, - * tp_properties_mixin_iface_init)</literal> in the fourth argument to - * <literal>G_DEFINE_TYPE_WITH_CODE</literal>. - */ - -#include <telepathy-glib/properties-mixin.h> - -#include <dbus/dbus-glib.h> -#include <stdio.h> -#include <string.h> - -#include <telepathy-glib/debug-ansi.h> -#include <telepathy-glib/errors.h> -#include <telepathy-glib/intset.h> -#include <telepathy-glib/util.h> - -#define DEBUG_FLAG TP_DEBUG_PROPERTIES - -#include "debug-internal.h" - -struct _TpPropertiesContext { - TpPropertiesMixinClass *mixin_cls; - TpPropertiesMixin *mixin; - - DBusGMethodInvocation *dbus_ctx; - TpIntset *remaining; - GValue **values; -}; - -struct _TpPropertiesMixinPrivate { - GObject *object; - TpPropertiesContext context; -}; - -/* - * tp_properties_mixin_class_get_offset_quark: - * - * Returns: the quark used for storing mixin offset on a GObjectClass - */ -GQuark -tp_properties_mixin_class_get_offset_quark () -{ - static GQuark offset_quark = 0; - if (!offset_quark) - offset_quark = g_quark_from_static_string ( - "TpPropertiesMixinClassOffsetQuark"); - return offset_quark; -} - -/* - * tp_properties_mixin_get_offset_quark: - * - * Returns: the quark used for storing mixin offset on a GObject - */ -GQuark -tp_properties_mixin_get_offset_quark () -{ - static GQuark offset_quark = 0; - if (!offset_quark) - offset_quark = g_quark_from_static_string ( - "TpPropertiesMixinOffsetQuark"); - return offset_quark; -} - - -/** - * tp_properties_mixin_class_init: - * @obj_cls: The class of an object that has this mixin - * @offset: The offset of the TpPropertiesMixinClass structure in the class - * structure - * @signatures: An array of property signatures - * @num_properties: The number of entries in @signatures - * @set_func: Callback used to set the properties - * - * Initialize the mixin. Should be called from the implementation's - * class_init function like so: - * - * <informalexample><programlisting> - * tp_properties_mixin_class_init ((GObjectClass *) klass, - * G_STRUCT_OFFSET (SomeObjectClass, - * properties_mixin)); - * </programlisting></informalexample> - */ - -void -tp_properties_mixin_class_init (GObjectClass *obj_cls, - glong offset, - const TpPropertySignature *signatures, - guint num_properties, - TpPropertiesSetFunc set_func) -{ - TpPropertiesMixinClass *mixin_cls; - - g_assert (G_IS_OBJECT_CLASS (obj_cls)); - - g_type_set_qdata (G_OBJECT_CLASS_TYPE (obj_cls), - TP_PROPERTIES_MIXIN_CLASS_OFFSET_QUARK, - GINT_TO_POINTER (offset)); - - mixin_cls = TP_PROPERTIES_MIXIN_CLASS (obj_cls); - - mixin_cls->signatures = signatures; - mixin_cls->num_props = num_properties; - - mixin_cls->set_properties = set_func; -} - - -/** - * tp_properties_mixin_init: - * @obj: An object that has this mixin - * @offset: The offset of the TpPropertiesMixin structure in the object - * structure - * - * Initialize the mixin. Should be called from the implementation's - * instance init function like so: - * - * <informalexample><programlisting> - * tp_properties_mixin_init ((GObject *) self, - * G_STRUCT_OFFSET (SomeObject, properties_mixin), - * self->contact_repo); - * </programlisting></informalexample> - */ - -void tp_properties_mixin_init (GObject *obj, glong offset) -{ - TpPropertiesMixinClass *mixin_cls; - TpPropertiesMixin *mixin; - TpPropertiesContext *ctx; - - g_assert (G_IS_OBJECT (obj)); - - g_assert (TP_IS_SVC_PROPERTIES_INTERFACE (obj)); - - g_type_set_qdata (G_OBJECT_TYPE (obj), - TP_PROPERTIES_MIXIN_OFFSET_QUARK, - GINT_TO_POINTER (offset)); - - mixin = TP_PROPERTIES_MIXIN (obj); - mixin_cls = TP_PROPERTIES_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj)); - - mixin->properties = g_new0 (TpProperty, mixin_cls->num_props); - - mixin->priv = g_slice_new0 (TpPropertiesMixinPrivate); - mixin->priv->object = obj; - - ctx = &mixin->priv->context; - ctx->mixin_cls = mixin_cls; - ctx->mixin = mixin; - ctx->values = g_new0 (GValue *, mixin_cls->num_props); -} - -/** - * tp_properties_mixin_finalize: - * @obj: An object that has this mixin - * - * Free memory used by the TpPropertiesMixin. - */ - -void tp_properties_mixin_finalize (GObject *obj) -{ - TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - TpPropertiesContext *ctx = &mixin->priv->context; - guint i; - - for (i = 0; i < mixin_cls->num_props; i++) - { - TpProperty *prop = &mixin->properties[i]; - - if (prop->value) - { - g_value_unset (prop->value); - g_slice_free (GValue, prop->value); - } - - if (ctx->values[i]) - { - g_value_unset (ctx->values[i]); - } - } - - g_free (ctx->values); - - g_slice_free (TpPropertiesMixinPrivate, mixin->priv); - - g_free (mixin->properties); -} - - -/** - * tp_properties_mixin_list_properties: - * @obj: An object with this mixin - * @ret: Output parameter which will be set to a GPtrArray of D-Bus structures - * if %TRUE is returned - * @error: Set to the error if %FALSE is returned - * - * List all available properties and their flags, as in the ListProperties - * D-Bus method. - * - * Returns: %TRUE on success - */ -gboolean -tp_properties_mixin_list_properties (GObject *obj, - GPtrArray **ret, - GError **error) -{ - TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - GType spec_type = TP_STRUCT_TYPE_PROPERTY_SPEC; - guint i; - - *ret = g_ptr_array_sized_new (mixin_cls->num_props); - - for (i = 0; i < mixin_cls->num_props; i++) - { - const TpPropertySignature *sig = &mixin_cls->signatures[i]; - TpProperty *prop = &mixin->properties[i]; - const gchar *dbus_sig; - GValue val = { 0, }; - - switch (sig->type) { - case G_TYPE_BOOLEAN: - dbus_sig = "b"; - break; - case G_TYPE_INT: - dbus_sig = "i"; - break; - case G_TYPE_UINT: - dbus_sig = "u"; - break; - case G_TYPE_STRING: - dbus_sig = "s"; - break; - default: - g_assert_not_reached (); - continue; - }; - - g_value_init (&val, spec_type); - g_value_take_boxed (&val, dbus_g_type_specialized_construct (spec_type)); - - dbus_g_type_struct_set (&val, - 0, i, - 1, sig->name, - 2, dbus_sig, - 3, prop->flags, - G_MAXUINT); - - g_ptr_array_add (*ret, g_value_get_boxed (&val)); - } - - return TRUE; -} - - -/** - * tp_properties_mixin_get_properties: - * @obj: An object with this mixin - * @properties: an array of integer property IDs - * @ret: set to an array of D-Bus structures if %TRUE is returned - * @error: Set to the error if %FALSE is returned - * - * Retrieve the values of the given properties, as in the GetProperties - * D-Bus method. - * - * Returns: %TRUE on success - */ -gboolean -tp_properties_mixin_get_properties (GObject *obj, - const GArray *properties, - GPtrArray **ret, - GError **error) -{ - TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - GType value_type = TP_STRUCT_TYPE_PROPERTY_VALUE; - guint i; - - /* Check input property identifiers */ - for (i = 0; i < properties->len; i++) - { - guint prop_id = g_array_index (properties, guint, i); - - /* Valid? */ - if (prop_id >= mixin_cls->num_props) - { - g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, - "invalid property identifier %d", prop_id); - - return FALSE; - } - - /* Permitted? */ - if (!tp_properties_mixin_is_readable (obj, prop_id)) - { - g_set_error (error, TP_ERRORS, TP_ERROR_PERMISSION_DENIED, - "permission denied for property identifier %d", prop_id); - - return FALSE; - } - } - - /* If we got this far, return the actual values */ - *ret = g_ptr_array_sized_new (properties->len); - - for (i = 0; i < properties->len; i++) - { - guint prop_id = g_array_index (properties, guint, i); - GValue val_struct = { 0, }; - - /* id/value struct */ - g_value_init (&val_struct, value_type); - g_value_take_boxed (&val_struct, - dbus_g_type_specialized_construct (value_type)); - - dbus_g_type_struct_set (&val_struct, - 0, prop_id, - 1, mixin->properties[prop_id].value, - G_MAXUINT); - - g_ptr_array_add (*ret, g_value_get_boxed (&val_struct)); - } - - return TRUE; -} - - -/** - * tp_properties_mixin_set_properties: - * @obj: An object with this mixin - * @properties: An array of D-Bus structures containing property ID and value - * @context: A D-Bus method invocation context for the SetProperties method - * - * Start to change properties in response to user request via D-Bus. - */ -void -tp_properties_mixin_set_properties (GObject *obj, - const GPtrArray *properties, - DBusGMethodInvocation *context) -{ - TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - TpPropertiesContext *ctx = &mixin->priv->context; - GError *error = NULL; - GType value_type = TP_STRUCT_TYPE_PROPERTY_VALUE; - guint i; - - /* Is another SetProperties request already in progress? */ - if (ctx->dbus_ctx) - { - error = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE, - "A SetProperties request is already in progress"); - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - - ctx->dbus_ctx = context; - ctx->remaining = tp_intset_new (); - error = NULL; - - if (properties->len == 0) - { - DEBUG ("immediately returning from SetProperties with 0 properties"); - tp_properties_context_return (ctx, NULL); - return; - } - - /* Check input property identifiers */ - for (i = 0; i < properties->len; i++) - { - GValue val_struct = { 0, }; - guint prop_id; - GValue *prop_val; - - g_value_init (&val_struct, value_type); - g_value_set_static_boxed (&val_struct, - g_ptr_array_index (properties, i)); - - dbus_g_type_struct_get (&val_struct, - 0, &prop_id, - 1, &prop_val, - G_MAXUINT); - - /* Valid? */ - if (prop_id >= mixin_cls->num_props) - { - g_boxed_free (G_TYPE_VALUE, prop_val); - error = g_error_new (TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, - "invalid property identifier %d", prop_id); - goto ERROR; - } - - /* Permitted? */ - if (!tp_properties_mixin_is_writable (obj, prop_id)) - { - g_boxed_free (G_TYPE_VALUE, prop_val); - error = g_error_new (TP_ERRORS, TP_ERROR_PERMISSION_DENIED, - "permission denied for property identifier %d", - prop_id); - goto ERROR; - } - - /* Compatible type? */ - if (!g_value_type_compatible (G_VALUE_TYPE (prop_val), - mixin_cls->signatures[prop_id].type)) - { - g_boxed_free (G_TYPE_VALUE, prop_val); - error = g_error_new (TP_ERRORS, TP_ERROR_NOT_AVAILABLE, - "incompatible value type for property " - "identifier %d", prop_id); - goto ERROR; - } - - /* Store the value in the context */ - tp_intset_add (ctx->remaining, prop_id); - ctx->values[prop_id] = prop_val; - } - - if (mixin_cls->set_properties) - { - if (mixin_cls->set_properties (obj, ctx, &error)) - return; - } - else - { - tp_properties_context_return (ctx, NULL); - return; - } - -ERROR: - tp_properties_context_return (ctx, error); -} - -/** - * tp_properties_mixin_has_property: - * @obj: an object with a properties mixin - * @name: the string name of the property - * @property: either %NULL, or a pointer to a location to receive the property - * index - * - * <!--Returns: says it all; this comment is to keep gtkdoc happy--> - * - * Returns: %TRUE, setting @property, if @obj has a property of that name - */ -gboolean -tp_properties_mixin_has_property (GObject *obj, const gchar *name, - guint *property) -{ - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - guint i; - - for (i = 0; i < mixin_cls->num_props; i++) - { - if (!tp_strdiff (mixin_cls->signatures[i].name, name)) - { - if (property) - *property = i; - - return TRUE; - } - } - - return FALSE; -} - - -/** - * tp_properties_context_has: - * @ctx: the properties context representing a SetProperties call - * @property: the property ID - * - * <!--Returns: says it all; this comment is to keep gtkdoc happy--> - * - * Returns: %TRUE if @ctx indicates that @property still needs to be set on - * the server. - */ -gboolean -tp_properties_context_has (TpPropertiesContext *ctx, guint property) -{ - g_assert (property < ctx->mixin_cls->num_props); - - return (tp_intset_is_member (ctx->remaining, property)); -} - - -/** - * tp_properties_context_has_other_than: - * @ctx: the properties context representing a SetProperties call - * @property: the property ID - * - * <!--Returns: says it all; this comment is to keep gtkdoc happy--> - * - * Returns: %TRUE if @ctx has properties other than @property that still - * need to be set on the server - */ -gboolean -tp_properties_context_has_other_than (TpPropertiesContext *ctx, guint property) -{ - gboolean has = tp_intset_is_member (ctx->remaining, property); - - g_assert (property < ctx->mixin_cls->num_props); - - return (tp_intset_size (ctx->remaining) > (has ? 1 : 0)); -} - - -/** - * tp_properties_context_get: - * @ctx: the properties context representing a SetProperties call - * @property: a property ID - * - * <!--Returns: says it all; this comment is to keep gtkdoc happy--> - * - * Returns: the value to be set on the server for the property @property - * in @ctx (whether it has been set already or not) - */ -const GValue * -tp_properties_context_get (TpPropertiesContext *ctx, guint property) -{ - g_assert (property < ctx->mixin_cls->num_props); - - return ctx->values[property]; -} - - -/** - * tp_properties_context_get_value_count: - * @ctx: the properties context representing a SetProperties call - * - * <!--Returns: says it all; this comment is to keep gtkdoc happy--> - * - * Returns: the number of properties in @ctx which still need to be set on - * the server, or have already been set - */ -guint -tp_properties_context_get_value_count (TpPropertiesContext *ctx) -{ - guint i, n; - - n = 0; - for (i = 0; i < ctx->mixin_cls->num_props; i++) - { - if (ctx->values[i]) - n++; - } - - return n; -} - - -/** - * tp_properties_context_remove: - * @ctx: the properties context representing a SetProperties call - * @property: a property ID - * - * Mark the given property as having been set successfully. - */ -void -tp_properties_context_remove (TpPropertiesContext *ctx, guint property) -{ - g_assert (property < ctx->mixin_cls->num_props); - - tp_intset_remove (ctx->remaining, property); -} - - -/** - * tp_properties_context_return - * @ctx: the properties context representing a SetProperties call - * @error: If %NULL, return successfully; otherwise return this error - * - * Commit the property changes and return from the pending D-Bus call. - */ -void -tp_properties_context_return (TpPropertiesContext *ctx, GError *error) -{ - GObject *obj = ctx->mixin->priv->object; - TpIntset *changed_props_val, *changed_props_flags; - guint i; - - DEBUG ("%s", (error) ? "failure" : "success"); - - changed_props_val = tp_intset_sized_new (ctx->mixin_cls->num_props); - changed_props_flags = tp_intset_sized_new (ctx->mixin_cls->num_props); - - for (i = 0; i < ctx->mixin_cls->num_props; i++) - { - if (ctx->values[i]) - { - if (!error) - { - tp_properties_mixin_change_value (obj, i, ctx->values[i], - changed_props_val); - - tp_properties_mixin_change_flags (obj, i, - TP_PROPERTY_FLAG_READ, 0, changed_props_flags); - } - - g_value_unset (ctx->values[i]); - ctx->values[i] = NULL; - } - } - - if (!error) - { - tp_properties_mixin_emit_changed (obj, changed_props_val); - tp_properties_mixin_emit_flags (obj, changed_props_flags); - tp_intset_destroy (changed_props_val); - tp_intset_destroy (changed_props_flags); - - dbus_g_method_return (ctx->dbus_ctx); - } - else - { - dbus_g_method_return_error (ctx->dbus_ctx, error); - g_error_free (error); - } - - ctx->dbus_ctx = NULL; - tp_intset_destroy (ctx->remaining); - ctx->remaining = NULL; - /* The context itself is not freed - it's a static part of the mixin */ -} - - -/** - * tp_properties_context_return_if_done: - * @ctx: the properties context representing a SetProperties call - * - * Return from the pending D-Bus call if there are no more properties to be - * dealt with. - * - * Returns: %TRUE if we returned from the D-Bus call. - */ -gboolean -tp_properties_context_return_if_done (TpPropertiesContext *ctx) -{ - if (tp_intset_size (ctx->remaining) == 0) - { - tp_properties_context_return (ctx, NULL); - return TRUE; - } - - return FALSE; -} - -#define RPTS_APPEND_FLAG_IF_SET(flag) \ - if (flags & flag) \ - { \ - if (i++ > 0) \ - g_string_append (str, "|"); \ - g_string_append (str, #flag + 17); \ - } - -static gchar * -property_flags_to_string (TpPropertyFlags flags) -{ - gint i = 0; - GString *str; - - str = g_string_new ("["); - - RPTS_APPEND_FLAG_IF_SET (TP_PROPERTY_FLAG_READ); - RPTS_APPEND_FLAG_IF_SET (TP_PROPERTY_FLAG_WRITE); - - g_string_append (str, "]"); - - return g_string_free (str, FALSE); -} - -static gboolean -values_are_equal (const GValue *v1, const GValue *v2) -{ - GType type = G_VALUE_TYPE (v1); - - switch (type) { - case G_TYPE_BOOLEAN: - return (g_value_get_boolean (v1) == g_value_get_boolean (v2)); - - case G_TYPE_STRING: - return !tp_strdiff (g_value_get_string (v1), g_value_get_string (v2)); - - case G_TYPE_UINT: - return (g_value_get_uint (v1) == g_value_get_uint (v2)); - - case G_TYPE_INT: - return (g_value_get_int (v1) == g_value_get_int (v2)); - } - - return FALSE; -} - - -/** - * tp_properties_mixin_change_value: - * @obj: An object with the properties mixin - * @prop_id: A property ID on which to act - * @new_value: Property value - * @props: either %NULL, or a pointer to a TpIntset - * - * Change the value of the given property ID in response to a server state - * change. - * - * If the old and new values match, nothing happens; no signal is emitted and - * @props is ignored. Otherwise, the following applies: - * - * If @props is %NULL the PropertiesChanged signal is emitted for this one - * property. - * - * Otherwise, the property ID is added to the set; the caller is responsible - * for passing the set to tp_properties_mixin_emit_changed() once a batch of - * properties have been changed. - */ -void -tp_properties_mixin_change_value (GObject *obj, - guint prop_id, - const GValue *new_value, - TpIntset *props) -{ - TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - TpProperty *prop; - - g_assert (prop_id < mixin_cls->num_props); - - prop = &mixin->properties[prop_id]; - - if (prop->value) - { - if (values_are_equal (prop->value, new_value)) - return; - } - else - { - prop->value = tp_g_value_slice_new (mixin_cls->signatures[prop_id].type); - } - - g_value_copy (new_value, prop->value); - - if (props) - { - tp_intset_add (props, prop_id); - } - else - { - TpIntset *changed_props = tp_intset_sized_new (prop_id + 1); - - tp_intset_add (changed_props, prop_id); - tp_properties_mixin_emit_changed (obj, changed_props); - tp_intset_destroy (changed_props); - } -} - - -/** - * tp_properties_mixin_change_flags: - * @obj: An object with the properties mixin - * @prop_id: A property ID on which to act - * @add: Property flags to be added via bitwise OR - * @del: Property flags to be removed via bitwise AND - * @props: either %NULL, or a pointer to a TpIntset - * - * Change the flags for the given property ID in response to a server state - * change. - * - * Flags removed by @del override flags added by @add. This should not be - * relied upon. - * - * If @props is %NULL the PropertyFlagsChanged signal is emitted for this - * single property. - * - * Otherwise, the property ID is added to the set; the caller is responsible - * for passing the set to tp_properties_mixin_emit_flags() once a batch of - * properties have been changed. - */ -void -tp_properties_mixin_change_flags (GObject *obj, - guint prop_id, - TpPropertyFlags add, - TpPropertyFlags del, - TpIntset *props) -{ - TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - TpProperty *prop; - guint prev_flags; - - g_assert (prop_id < mixin_cls->num_props); - - prop = &mixin->properties[prop_id]; - - prev_flags = prop->flags; - - prop->flags |= add; - prop->flags &= ~del; - - if (prop->flags == prev_flags) - return; - - if (props) - { - tp_intset_add (props, prop_id); - } - else - { - TpIntset *changed_props = tp_intset_sized_new (prop_id + 1); - - tp_intset_add (changed_props, prop_id); - tp_properties_mixin_emit_flags (obj, changed_props); - tp_intset_destroy (changed_props); - } -} - -/** - * tp_properties_mixin_emit_changed: - * @obj: an object with the properties mixin - * @props: a set of property IDs - * - * Emit the PropertiesChanged signal to indicate that the values of the - * given property IDs have changed; the actual values are automatically - * added using their stored values. - */ -void -tp_properties_mixin_emit_changed (GObject *obj, const TpIntset *props) -{ - TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - GPtrArray *prop_arr; - GValue prop_list = { 0, }; - TpIntsetFastIter iter; - guint len = tp_intset_size (props); - guint prop_id; - - if (len == 0) - { - return; - } - - prop_arr = g_ptr_array_sized_new (len); - - if (DEBUGGING) - printf ("%s: emitting properties changed for propert%s:\n", - G_STRFUNC, (len > 1) ? "ies" : "y"); - - tp_intset_fast_iter_init (&iter, props); - - while (tp_intset_fast_iter_next (&iter, &prop_id)) - { - GValue prop_val = { 0, }; - - g_value_init (&prop_val, TP_STRUCT_TYPE_PROPERTY_VALUE); - g_value_take_boxed (&prop_val, - dbus_g_type_specialized_construct (TP_STRUCT_TYPE_PROPERTY_VALUE)); - - dbus_g_type_struct_set (&prop_val, - 0, prop_id, - 1, mixin->properties[prop_id].value, - G_MAXUINT); - - g_ptr_array_add (prop_arr, g_value_get_boxed (&prop_val)); - - if (DEBUGGING) - printf (" %s\n", mixin_cls->signatures[prop_id].name); - } - - if (DEBUGGING) - { - fflush (stdout); - } - - tp_svc_properties_interface_emit_properties_changed ( - (TpSvcPropertiesInterface *) obj, prop_arr); - - g_value_init (&prop_list, TP_ARRAY_TYPE_PROPERTY_VALUE_LIST); - g_value_take_boxed (&prop_list, prop_arr); - g_value_unset (&prop_list); -} - - -/** - * tp_properties_mixin_emit_flags: - * @obj: an object with the properties mixin - * @props: a set of property IDs - * - * Emit the PropertyFlagsChanged signal to indicate that the flags of the - * given property IDs have changed; the actual flags are automatically - * added using their stored values. - */ -void -tp_properties_mixin_emit_flags (GObject *obj, const TpIntset *props) -{ - TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - GPtrArray *prop_arr; - GValue prop_list = { 0, }; - TpIntsetFastIter iter; - guint len = tp_intset_size (props); - guint prop_id; - - if (len == 0) - { - return; - } - - prop_arr = g_ptr_array_sized_new (len); - - if (DEBUGGING) - printf ("%s: emitting properties flags changed for propert%s:\n", - G_STRFUNC, (len > 1) ? "ies" : "y"); - - tp_intset_fast_iter_init (&iter, props); - - while (tp_intset_fast_iter_next (&iter, &prop_id)) - { - GValue prop_val = { 0, }; - guint prop_flags; - - prop_flags = mixin->properties[prop_id].flags; - - g_value_init (&prop_val, TP_STRUCT_TYPE_PROPERTY_FLAGS_CHANGE); - g_value_take_boxed (&prop_val, - dbus_g_type_specialized_construct - (TP_STRUCT_TYPE_PROPERTY_FLAGS_CHANGE)); - - dbus_g_type_struct_set (&prop_val, - 0, prop_id, - 1, prop_flags, - G_MAXUINT); - - g_ptr_array_add (prop_arr, g_value_get_boxed (&prop_val)); - - if (DEBUGGING) - { - gchar *str_flags = property_flags_to_string (prop_flags); - - printf (" %s's flags now: %s\n", - mixin_cls->signatures[prop_id].name, str_flags); - - g_free (str_flags); - } - } - - if (DEBUGGING) - { - fflush (stdout); - } - - tp_svc_properties_interface_emit_property_flags_changed ( - (TpSvcPropertiesInterface *) obj, prop_arr); - - g_value_init (&prop_list, TP_ARRAY_TYPE_PROPERTY_FLAGS_CHANGE_LIST); - g_value_take_boxed (&prop_list, prop_arr); - g_value_unset (&prop_list); -} - - -/** - * tp_properties_mixin_is_readable: - * @obj: an object with this mixin - * @prop_id: an integer property ID - * - * <!--Returns: says it all; this comment is to keep gtkdoc happy--> - * - * Returns: %TRUE if the given property has the READ flag - */ -gboolean -tp_properties_mixin_is_readable (GObject *obj, guint prop_id) -{ - TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - - if (prop_id >= mixin_cls->num_props) - return FALSE; - - return ((mixin->properties[prop_id].flags & TP_PROPERTY_FLAG_READ) != 0); -} - - -/** - * tp_properties_mixin_is_writable: - * @obj: an object with this mixin - * @prop_id: an integer property ID - * - * <!--Returns: says it all; this comment is to keep gtkdoc happy--> - * - * Returns: %TRUE if the given property has the WRITE flag - */ -gboolean -tp_properties_mixin_is_writable (GObject *obj, guint prop_id) -{ - TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); - TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( - G_OBJECT_GET_CLASS (obj)); - - if (prop_id >= mixin_cls->num_props) - return FALSE; - - return ((mixin->properties[prop_id].flags & TP_PROPERTY_FLAG_WRITE) != 0); -} - - -/* - * get_properties - * - * Implements D-Bus method GetProperties - * on interface org.freedesktop.Telepathy.Properties - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns FALSE. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -static void -get_properties (TpSvcPropertiesInterface *iface, - const GArray *properties, - DBusGMethodInvocation *context) -{ - GPtrArray *ret; - GError *error = NULL; - gboolean ok = tp_properties_mixin_get_properties (G_OBJECT (iface), - properties, &ret, &error); - if (!ok) - { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - tp_svc_properties_interface_return_from_get_properties ( - context, ret); - g_ptr_array_unref (ret); -} - - -/* - * list_properties - * - * Implements D-Bus method ListProperties - * on interface org.freedesktop.Telepathy.Properties - * - * @error: Used to return a pointer to a GError detailing any error - * that occurred, D-Bus will throw the error only if this - * function returns false. - * - * Returns: TRUE if successful, FALSE if an error was thrown. - */ -static void -list_properties (TpSvcPropertiesInterface *iface, - DBusGMethodInvocation *context) -{ - GPtrArray *ret; - GError *error = NULL; - gboolean ok = tp_properties_mixin_list_properties (G_OBJECT (iface), &ret, - &error); - guint i; - - if (!ok) - { - dbus_g_method_return_error (context, error); - g_error_free (error); - } - tp_svc_properties_interface_return_from_list_properties ( - context, ret); - - for (i = 0; i < ret->len; i++) - g_boxed_free (TP_STRUCT_TYPE_PROPERTY_SPEC, ret->pdata[i]); - - g_ptr_array_unref (ret); -} - - -/* - * set_properties - * - * Implements D-Bus method SetProperties - * on interface org.freedesktop.Telepathy.Properties - * - * @context: The D-Bus invocation context to use to return values - * or throw an error. - */ -static void -set_properties (TpSvcPropertiesInterface *iface, - const GPtrArray *properties, - DBusGMethodInvocation *context) -{ - tp_properties_mixin_set_properties (G_OBJECT (iface), properties, context); -} - - -/** - * tp_properties_mixin_iface_init: - * @g_iface: A pointer to the #TpSvcPropertiesInterfaceClass in an object class - * @iface_data: Ignored - * - * Fill in this mixin's method implementations in the given interface vtable. - * This function should usually be called via G_IMPLEMENT_INTERFACE - * inside the G_DEFINE_TYPE_WITH_CODE macro. - */ -void -tp_properties_mixin_iface_init (gpointer g_iface, gpointer iface_data) -{ - TpSvcPropertiesInterfaceClass *klass = g_iface; - -#define IMPLEMENT(x) tp_svc_properties_interface_implement_##x (klass, x) - IMPLEMENT(get_properties); - IMPLEMENT(list_properties); - IMPLEMENT(set_properties); -#undef IMPLEMENT -} diff --git a/telepathy-glib/properties-mixin.h b/telepathy-glib/properties-mixin.h deleted file mode 100644 index e98442b92..000000000 --- a/telepathy-glib/properties-mixin.h +++ /dev/null @@ -1,270 +0,0 @@ -/* - * properties-mixin.h - Header for TpPropertiesMixin - * Copyright (C) 2006 Collabora Ltd. - * Copyright (C) 2006 Nokia Corporation - * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk> - * @author Robert McQueen <robert.mcqueen@collabora.co.uk> - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __TP_PROPERTIES_MIXIN_H__ -#define __TP_PROPERTIES_MIXIN_H__ - -#include <glib-object.h> -#include <dbus/dbus-glib.h> - -#include <telepathy-glib/enums.h> -#include <telepathy-glib/gtypes.h> -#include <telepathy-glib/intset.h> -#include <telepathy-glib/svc-properties-interface.h> -#include <telepathy-glib/util.h> - -G_BEGIN_DECLS - -/** - * TpPropertySignature: - * @name: Name of the property as seen in the Telepathy D-Bus protocol - * @type: GType which the variant value must have. We currently support - * only %G_TYPE_UINT, %G_TYPE_INT, %G_TYPE_STRING, %G_TYPE_BOOLEAN, - * corresponding to D-Bus signatures 'u', 'i', 's', 'b'. - * - * Signature of a property in the Telepathy properties interface. - */ -struct _TpPropertySignature { - gchar *name; - GType type; -}; - -typedef struct _TpPropertySignature TpPropertySignature; - -/** - * TpProperty: - * @value: The value of the property - * @flags: #TpPropertyFlags indicating the property's permissions - * - * Structure representing the current state of a property. - */ -struct _TpProperty { - /* FIXME: if we ever break ABI, make this a (GValue) rather than a - * (GValue *) */ - GValue *value; - guint flags; -}; - -typedef struct _TpProperty TpProperty; - -/** - * TpPropertiesContext: - * - * Opaque pointer representing an incomplete property-setting operation, used - * in the implementation of SetProperties. - */ -typedef struct _TpPropertiesContext TpPropertiesContext; - -/** - * TpPropertiesSetFunc: - * @obj: An object with the properties mixin - * @ctx: A properties context - * @error: Set to the error if %FALSE is returned - * - * A callback used to implement the SetProperties D-Bus method by setting - * properties in the underlying IM protocol. - * - * The callback must either: - * - * * return %FALSE to indicate immediate failure - * * call tp_properties_context_return() with an error to indicate failure - * * call tp_properties_context_remove() to remove each property from the set - * of pending properties, then call tp_properties_context_return_if_done() - * or tp_properties_context_return() when all were set - * - * Returns: %FALSE on immediate failure, %TRUE otherwise - */ -typedef gboolean (*TpPropertiesSetFunc) (GObject *obj, - TpPropertiesContext *ctx, GError **error); - -typedef struct _TpPropertiesMixinClass TpPropertiesMixinClass; -typedef struct _TpPropertiesMixinPrivate TpPropertiesMixinPrivate; -typedef struct _TpPropertiesMixin TpPropertiesMixin; -/* Doesn't yet exist. For future expansion. */ -typedef struct _TpPropertiesMixinClassPrivate TpPropertiesMixinClassPrivate; - -/** - * TpPropertiesMixin: - * @properties: Array of property values, of length klass->num_props. - * Should be considered read-only. - * @priv: Pointer to opaque private data. - * - * Structure to be placed in a GObject-derived structure containing - * instance data for the properties mixin (i.e. the properties). Initialize - * it using tp_properties_mixin_init(). - */ -struct _TpPropertiesMixin { - TpProperty *properties; - - TpPropertiesMixinPrivate *priv; -}; - -/** - * TpPropertiesMixinClass: - * @signatures: Array of property signatures, as provided via - * tp_properties_mixin_class_init(), of length @num_props. - * @num_props: Number of properties supported. - * @set_properties: Properties setting function, as supplied to - * tp_properties_mixin_class_init(). - * @priv: Pointer to opaque private data. - * - * Structure to be placed in a GObjectClass-derived structure containing - * settings for the properties mixin. Initialize it using - * tp_properties_mixin_class_init(). - * - * All fields should be considered read-only. - */ -struct _TpPropertiesMixinClass { - const TpPropertySignature *signatures; - guint num_props; - - TpPropertiesSetFunc set_properties; - - TpPropertiesMixinClassPrivate *priv; -}; - -/* TYPE MACROS */ -#define TP_PROPERTIES_MIXIN_CLASS_OFFSET_QUARK \ - (tp_properties_mixin_class_get_offset_quark ()) -#define TP_PROPERTIES_MIXIN_CLASS_OFFSET(o) \ - tp_mixin_class_get_offset (o, TP_PROPERTIES_MIXIN_CLASS_OFFSET_QUARK) -#define TP_PROPERTIES_MIXIN_CLASS(o) \ - ((TpPropertiesMixinClass *) tp_mixin_offset_cast (o,\ - TP_PROPERTIES_MIXIN_CLASS_OFFSET (o))) - -#define TP_PROPERTIES_MIXIN_OFFSET_QUARK \ - (tp_properties_mixin_get_offset_quark ()) -#define TP_PROPERTIES_MIXIN_OFFSET(o) \ - tp_mixin_instance_get_offset (o, TP_PROPERTIES_MIXIN_OFFSET_QUARK) -#define TP_PROPERTIES_MIXIN(o) \ - ((TpPropertiesMixin *) tp_mixin_offset_cast (o, \ - TP_PROPERTIES_MIXIN_OFFSET (o))) - -/** - * TP_TYPE_PROPERTY_INFO_STRUCT: - * - * The GType of the structures with D-Bus signature '(ussu)' returned by - * ListProperties. - * - * @Deprecated: Since 0.7.0. Use TP_STRUCT_TYPE_PROPERTY_SPEC instead. - */ -#define TP_TYPE_PROPERTY_INFO_STRUCT TP_STRUCT_TYPE_PROPERTY_SPEC - -/** - * TP_TYPE_PROPERTY_INFO_LIST: - * - * The GType of the return from ListProperties (i.e. a GPtrArray - * of structures of type TP_TYPE_PROPERTY_INFO_STRUCT), corresponding to - * D-Bus signature 'a(ussu)'. - * - * @Deprecated: Since 0.7.0. Use TP_ARRAY_TYPE_PROPERTY_SPEC_LIST instead. - */ -#define TP_TYPE_PROPERTY_INFO_LIST TP_ARRAY_TYPE_PROPERTY_SPEC_LIST - -/** - * TP_TYPE_PROPERTY_VALUE_STRUCT: - * - * The GType of the structures with signature '(uv)' returned by - * GetProperties and emitted in PropertiesChanged. - * - * @Deprecated: Since 0.7.0. Use TP_STRUCT_TYPE_PROPERTY_VALUE instead. - */ -#define TP_TYPE_PROPERTY_VALUE_STRUCT TP_STRUCT_TYPE_PROPERTY_VALUE - -/** - * TP_TYPE_PROPERTY_VALUE_LIST - * - * The GType of the return from GetProperties and the parameter to - * PropertiesChanged (i.e. a GPtrArray of structures of type - * TP_TYPE_PROPERTY_VALUE_STRUCT), corresponding to D-Bus signature 'a(uv)'. - * - * @Deprecated: Since 0.7.0. Use TP_ARRAY_TYPE_PROPERTY_VALUE_LIST instead. - */ -#define TP_TYPE_PROPERTY_VALUE_LIST TP_ARRAY_TYPE_PROPERTY_VALUE_LIST - -/** - * TP_TYPE_PROPERTY_FLAGS_STRUCT: - * - * The GType of the structures with D-Bus signature '(uu)' emitted in - * PropertyFlagsChanged. - * - * @Deprecated: Since 0.7.0. Use TP_STRUCT_TYPE_PROPERTY_FLAGS_CHANGE instead. - */ -#define TP_TYPE_PROPERTY_FLAGS_STRUCT TP_STRUCT_TYPE_PROPERTY_FLAGS_CHANGE - -/** - * TP_TYPE_PROPERTY_FLAGS_LIST - * - * The GType of the parameter to PropertyFlagsChanged (i.e. a GPtrArray of - * structures of type TP_TYPE_PROPERTY_FLAGS_STRUCT), corresponding to - * D-Bus signature 'a(uu)'. - * - * @Deprecated: Since 0.7.0. Use TP_ARRAY_TYPE_PROPERTY_FLAGS_CHANGE_LIST - * instead. - */ -#define TP_TYPE_PROPERTY_FLAGS_LIST TP_ARRAY_TYPE_PROPERTY_FLAGS_CHANGE_LIST - -GQuark tp_properties_mixin_class_get_offset_quark (void); -GQuark tp_properties_mixin_get_offset_quark (void); - -void tp_properties_mixin_class_init (GObjectClass *obj_cls, glong offset, - const TpPropertySignature *signatures, guint num_properties, - TpPropertiesSetFunc set_func); - -void tp_properties_mixin_init (GObject *obj, glong offset); -void tp_properties_mixin_finalize (GObject *obj); - -gboolean tp_properties_mixin_list_properties (GObject *obj, GPtrArray **ret, - GError **error); -gboolean tp_properties_mixin_get_properties (GObject *obj, - const GArray *properties, GPtrArray **ret, GError **error); -void tp_properties_mixin_set_properties (GObject *obj, - const GPtrArray *properties, DBusGMethodInvocation *context); - -gboolean tp_properties_mixin_has_property (GObject *obj, const gchar *name, - guint *property); - -gboolean tp_properties_context_has (TpPropertiesContext *ctx, guint property); -gboolean tp_properties_context_has_other_than (TpPropertiesContext *ctx, - guint property); -const GValue *tp_properties_context_get (TpPropertiesContext *ctx, - guint property); -guint tp_properties_context_get_value_count (TpPropertiesContext *ctx); -void tp_properties_context_remove (TpPropertiesContext *ctx, guint property); -void tp_properties_context_return (TpPropertiesContext *ctx, GError *error); -gboolean tp_properties_context_return_if_done (TpPropertiesContext *ctx); - -void tp_properties_mixin_change_value (GObject *obj, guint prop_id, - const GValue *new_value, TpIntset *props); -void tp_properties_mixin_change_flags (GObject *obj, guint prop_id, - TpPropertyFlags add, TpPropertyFlags del, TpIntset *props); -void tp_properties_mixin_emit_changed (GObject *obj, const TpIntset *props); -void tp_properties_mixin_emit_flags (GObject *obj, const TpIntset *props); - -gboolean tp_properties_mixin_is_readable (GObject *obj, guint prop_id); -gboolean tp_properties_mixin_is_writable (GObject *obj, guint prop_id); - -void tp_properties_mixin_iface_init (gpointer g_iface, gpointer iface_data); - -G_END_DECLS - -#endif /* #ifndef __TP_PROPERTIES_MIXIN_H__ */ diff --git a/telepathy-glib/proxy.c b/telepathy-glib/proxy.c index 2697eb2bd..e7166c1c4 100644 --- a/telepathy-glib/proxy.c +++ b/telepathy-glib/proxy.c @@ -145,22 +145,6 @@ tp_dbus_errors_quark (void) */ /** - * SECTION:proxy-tp-properties - * @title: TpProxy Telepathy Properties - * @short_description: The Telepathy Properties interface - * @see_also: #TpProxy - * - * As well as #TpProxy, proxy.h includes auto-generated client wrappers for the - * Telepathy Properties interface, which can be implemented by any type of - * object. - * - * The Telepathy Properties interface should not be confused with the D-Bus - * core Properties interface. - * - * Since: 0.7.1 - */ - -/** * SECTION:proxy-subclass * @title: TpProxy subclasses and mixins * @short_description: Providing extra functionality for a #TpProxy or diff --git a/tests/dbus/disconnection.c b/tests/dbus/disconnection.c index 44d3758e8..fdd4f72ce 100644 --- a/tests/dbus/disconnection.c +++ b/tests/dbus/disconnection.c @@ -73,16 +73,6 @@ requested_name (TpDBusDaemon *proxy, } static void -prop_changed (TpProxy *proxy, - const GPtrArray *properties, - gpointer user_data, - GObject *weak_object) -{ - g_error ("prop_changed called - a signal connection which should have " - "failed has succeeded. Args: proxy=%p user_data=%p", proxy, user_data); -} - -static void dummy_noc (TpDBusDaemon *proxy, const gchar *name, const gchar *old, @@ -198,16 +188,6 @@ main (int argc, destroy_user_data, (GObject *) z, &error_out); g_assert_no_error (error_out); - /* assert that connecting to a signal on an interface we don't have fails */ - freed = FALSE; - tp_cli_properties_interface_connect_to_properties_changed (a, prop_changed, - &freed, set_freed, NULL, &error_out); - MYASSERT (freed, ""); - MYASSERT (error_out != NULL, ""); - MYASSERT (error_out->code == TP_DBUS_ERROR_NO_INTERFACE, ""); - g_error_free (error_out); - error_out = NULL; - /* b gets its signal connection cancelled because stub is * destroyed */ stub = tp_tests_object_new_static_class (tp_tests_stub_object_get_type (), diff --git a/tests/dbus/unsupported-interface.c b/tests/dbus/unsupported-interface.c index 0cd874b0b..ccecd56ed 100644 --- a/tests/dbus/unsupported-interface.c +++ b/tests/dbus/unsupported-interface.c @@ -5,66 +5,6 @@ #include "tests/lib/myassert.h" #include "tests/lib/util.h" -static gboolean had_unsupported = FALSE; -static gboolean had_supported = FALSE; -static GMainLoop *mainloop = NULL; -static gboolean freed_user_data[] = { FALSE, FALSE, FALSE, FALSE }; - -static void -supported_cb (TpDBusDaemon *bus_daemon, - const gchar **names, - const GError *error, - gpointer user_data, - GObject *weak_object) -{ - MYASSERT (user_data != NULL, ""); - MYASSERT (weak_object == NULL, ""); - MYASSERT (names != NULL, ""); - MYASSERT (bus_daemon != NULL, ""); - MYASSERT (error == NULL, ""); - MYASSERT (mainloop != NULL, ""); - - MYASSERT (!had_supported, ""); - had_supported = TRUE; - - if (had_unsupported && had_supported) - g_main_loop_quit (mainloop); -} - -static void -unsupported_cb (TpProxy *proxy, - const GPtrArray *out0, - const GError *error, - gpointer user_data, - GObject *weak_object) -{ - MYASSERT (weak_object == NULL, ""); - MYASSERT (user_data != NULL, ""); - MYASSERT (proxy != NULL, ""); - MYASSERT (out0 == NULL, ""); - MYASSERT (error != NULL, ""); - MYASSERT (mainloop != NULL, ""); - - MYASSERT (!had_unsupported, ""); - had_unsupported = TRUE; - - if (had_unsupported && had_supported) - g_main_loop_quit (mainloop); -} - -static void -do_nothing (void) -{ -} - -static void -free_user_data (gpointer user_data) -{ - gboolean *ptr = user_data; - - *ptr = TRUE; -} - int main (int argc, char **argv) @@ -83,43 +23,18 @@ main (int argc, NULL, NULL), ""); /* ... but this one is not */ - MYASSERT (!tp_cli_properties_interface_run_list_properties (bus_daemon, -1, - NULL, &error, NULL), ""); + MYASSERT (!tp_cli_dbus_properties_run_get_all (bus_daemon, -1, NULL, + NULL, &error, NULL), ""); MYASSERT (error != NULL, ""); g_error_free (error); error = NULL; - /* the same, but with async API */ - - mainloop = g_main_loop_new (NULL, FALSE); - - MYASSERT (tp_cli_dbus_daemon_call_list_names (bus_daemon, -1, supported_cb, - freed_user_data + 0, free_user_data, NULL) != NULL, ""); - MYASSERT (tp_cli_properties_interface_call_list_properties (bus_daemon, -1, - unsupported_cb, freed_user_data + 1, free_user_data, NULL) == NULL, - ""); - - /* the same, but with signals */ - MYASSERT (tp_cli_dbus_daemon_connect_to_name_acquired (bus_daemon, - (tp_cli_dbus_daemon_signal_callback_name_acquired) do_nothing, - freed_user_data + 2, free_user_data, NULL, NULL) != NULL, ""); - MYASSERT (tp_cli_properties_interface_connect_to_property_flags_changed - (bus_daemon, - (tp_cli_properties_interface_signal_callback_property_flags_changed) - do_nothing, - freed_user_data + 3, free_user_data, NULL, &error) == NULL, ""); - MYASSERT (error != NULL, ""); - g_error_free (error); - error = NULL; - - g_main_loop_run (mainloop); - g_main_loop_unref (mainloop); - mainloop = NULL; - - MYASSERT (freed_user_data[0], " (async call, supported)"); - MYASSERT (freed_user_data[1], " (async call, unsupported)"); - MYASSERT (!freed_user_data[2], " (signal connection, supported)"); - MYASSERT (freed_user_data[3], " (signal connection, unsupported)"); + /* Proxies are assumed to have + * org.freedesktop.DBus.{Peer,Ping,Properties,…} so async calls will + * these will not fail to be dispatched even if they are going to + * fail. We can't test using, say, Account methods/signals because + * they have TP_IS_ACCOUNT typechecks which won't pass here. + * Therefore, we don't test the async API or signals here. */ g_object_unref (bus_daemon); |