![]() |
![]() |
![]() |
telepathy-glib Reference Manual | ![]() |
---|---|---|---|---|
TpDBusPropertiesMixinTpDBusPropertiesMixin — a mixin implementation of the DBus.Properties interface |
#include <telepathy-glib/dbus_properties-mixin.h> enum TpDBusPropertiesMixinFlags; TpDBusPropertiesMixinIfaceInfo; TpDBusPropertiesMixinPropInfo; void tp_svc_interface_set_dbus_properties_info (GType g_interface, TpDBusPropertiesMixinIfaceInfo *info); TpDBusPropertiesMixinClass; TpDBusPropertiesMixinIfaceImpl; TpDBusPropertiesMixinPropImpl; void (*TpDBusPropertiesMixinGetter) (GObject *object, GQuark interface, GQuark name, GValue *value, gpointer getter_data); void tp_dbus_properties_mixin_getter_gobject_properties (GObject *object, GQuark interface, GQuark name, GValue *value, gpointer getter_data); gboolean (*TpDBusPropertiesMixinSetter) (GObject *object, GQuark interface, GQuark name, const GValue *value, gpointer setter_data, GError **error); gboolean tp_dbus_properties_mixin_setter_gobject_properties (GObject *object, GQuark interface, GQuark name, const GValue *value, gpointer setter_data, GError **error); void tp_dbus_properties_mixin_class_init (GObjectClass *cls, gsize offset); void tp_dbus_properties_mixin_iface_init (gpointer g_iface, gpointer iface_data);
This mixin provides an implementation of the org.freedesktop.DBus.Properties interface. It relies on the auto-generated service-side GInterfaces from telepathy-glib >= 0.7.3, or something similar, to register the abstract properties and their GTypes; classes with the mixin can then register an implementation of the properties.
To register D-Bus properties in a GInterface to be implementable with this
mixin, either use the code-generation tools from telepathy-glib >= 0.7.3,
or call tp_svc_interface_set_properties_info()
from a section of the
base_init function that only runs once.
To use this mixin, include a TpDBusPropertiesMixinClass somewhere
in your class structure, populate it with pointers to statically allocated
(or duplicated and never freed) data, and call
tp_dbus_properties_mixin_class_init()
from your class_init implementation.
To use this mixin as the implementation of TpSvcDBusProperties,
call G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES,
tp_dbus_properties_mixin_iface_init)
in the fourth argument to
G_DEFINE_TYPE_WITH_CODE
.
typedef enum { TP_DBUS_PROPERTIES_MIXIN_FLAG_READ = 1, TP_DBUS_PROPERTIES_MIXIN_FLAG_WRITE = 2 } TpDBusPropertiesMixinFlags;
Bitfield representing allowed access to a property.
The property can be read using Get and GetAll | |
The property can be written using Set |
Since 0.7.3
typedef struct { GQuark dbus_interface; TpDBusPropertiesMixinPropInfo *props; } TpDBusPropertiesMixinIfaceInfo;
Semi-abstract description of an interface. Each service GInterface that
has properties must have one of these attached to it via
tp_svc_interface_set_dbus_properties_info()
in its base_init function;
service GInterfaces that do not have properties may have one of these
with no properties.
This structure must either be statically allocated, or duplicated and never freed, so it always remains valid.
In addition to the documented members, there are two private pointers
for future expansion, which must always be initialized to NULL
.
GQuark |
Quark representing the interface's name |
TpDBusPropertiesMixinPropInfo * |
Array of property descriptions, terminated by one with
name == NULL
|
Since 0.7.3
typedef struct { GQuark name; TpDBusPropertiesMixinFlags flags; gchar *dbus_signature; GType type; } TpDBusPropertiesMixinPropInfo;
Semi-abstract description of a property, as attached to a service GInterface. This structure must either be statically allocated, or duplicated and never freed, so it always remains valid.
In addition to the documented members, there are two private pointers
for future expansion, which must always be initialized to NULL
.
GQuark |
Quark representing the property's name |
TpDBusPropertiesMixinFlags |
Flags representing read/write access to the property |
gchar * |
The D-Bus signature of the property |
GType |
The GType used in a GValue to implement the property |
Since 0.7.3
void tp_svc_interface_set_dbus_properties_info (GType g_interface, TpDBusPropertiesMixinIfaceInfo *info);
Declare that g_interface
implements the given D-Bus interface, with the
given properties. This may only be called once per GInterface, usually from
a section of its base_init function that only runs once.
|
The GType of a service interface |
|
an interface description |
Since 0.7.3
typedef struct { TpDBusPropertiesMixinIfaceImpl *interfaces; } TpDBusPropertiesMixinClass;
Structure representing all of a class's property implementations. One of these structures may be placed in the layout of an object class structure.
In addition to the documented fields, there are 7 pointers reserved for
future use, which must be initialized to NULL
.
TpDBusPropertiesMixinIfaceImpl * |
An array of interface implementations, terminated by one with
name equal to NULL
|
Since 0.7.3
typedef struct { const gchar *name; TpDBusPropertiesMixinGetter getter; TpDBusPropertiesMixinSetter setter; TpDBusPropertiesMixinPropImpl *props; } TpDBusPropertiesMixinIfaceImpl;
Structure representing an implementation of an interface's properties.
In addition to the documented fields, there are three pointers which must
be initialized to NULL
.
This structure must either be statically allocated, or duplicated and never freed, so it always remains valid.
const gchar * |
The name of the interface |
TpDBusPropertiesMixinGetter |
A callback to get the current value of the property, to which
the getter_data from each property implementation will be passed
|
TpDBusPropertiesMixinSetter |
A callback to set a new value for the property, to which
the setter_data from each property implementation will be passed
|
TpDBusPropertiesMixinPropImpl * |
An array of property implementations, terminated by one with
name equal to NULL
|
Since 0.7.3
typedef struct { const gchar *name; gpointer getter_data; gpointer setter_data; } TpDBusPropertiesMixinPropImpl;
Structure representing an implementation of a property.
In addition to the documented fields, there are three pointers which must
be initialized to NULL
.
This structure must either be statically allocated, or duplicated and never freed, so it always remains valid.
const gchar * |
The name of the property as it appears on D-Bus |
gpointer |
Arbitrary user-supplied data for the getter function |
gpointer |
Arbitrary user-supplied data for the setter function |
Since 0.7.3
void (*TpDBusPropertiesMixinGetter) (GObject *object, GQuark interface, GQuark name, GValue *value, gpointer getter_data);
Signature of a callback used to get the value of a property.
For simplicity, in this mixin we don't allow getting a property to fail; implementations must always be prepared to return *something*.
|
The exported object with the properties |
|
A quark representing the D-Bus interface name |
|
A quark representing the D-Bus property name |
|
A GValue pre-initialized to the right type, into which to put the value |
|
The getter_data from the TpDBusPropertiesMixinPropImpl |
void tp_dbus_properties_mixin_getter_gobject_properties (GObject *object, GQuark interface, GQuark name, GValue *value, gpointer getter_data);
An implementation of TpDBusPropertiesMixinGetter which assumes that
the getter_data
is the name of a readable GObject property of an
appropriate type, and uses it for the value of the D-Bus property.
|
The exported object with the properties |
|
A quark representing the D-Bus interface name |
|
A quark representing the D-Bus property name |
|
A GValue pre-initialized to the right type, into which to put the value |
|
The getter_data from the TpDBusPropertiesMixinPropImpl, which must be a string containing the GObject property's name |
gboolean (*TpDBusPropertiesMixinSetter) (GObject *object, GQuark interface, GQuark name, const GValue *value, gpointer setter_data, GError **error);
Signature of a callback used to get the value of a property.
|
The exported object with the properties |
|
A quark representing the D-Bus interface name |
|
A quark representing the D-Bus property name |
|
The new value for the property |
|
The setter_data from the TpDBusPropertiesMixinPropImpl |
|
Used to return an error on failure |
Returns : |
TRUE on success, FALSE (setting error ) on failure
|
gboolean tp_dbus_properties_mixin_setter_gobject_properties (GObject *object, GQuark interface, GQuark name, const GValue *value, gpointer setter_data, GError **error);
An implementation of TpDBusPropertiesMixinSetter which assumes that the
setter_data
is the name of a writable GObject property of an appropriate
type, and sets that property to the given value.
|
The exported object with the properties |
|
A quark representing the D-Bus interface name |
|
A quark representing the D-Bus property name |
|
The new value for the property |
|
The setter_data from the TpDBusPropertiesMixinPropImpl, which must be a string containing the GObject property's name |
|
Not used |
Returns : |
TRUE
|
void tp_dbus_properties_mixin_class_init (GObjectClass *cls, gsize offset);
Initialize the class cls
to use the D-Bus Properties mixin.
The given struct member, of size sizeof(TpDBusPropertiesMixinClass),
will be used to store property implementation information.
Each property and each interface must have been declared as a member of
a GInterface implemented by cls
, using
tp_svc_interface_set_dbus_properties_info()
.
Before calling this function, the array of interfaces must have been placed in the TpDBusPropertiesMixinClass structure.
|
a subclass of GObjectClass |
|
the offset within cls of a TpDBusPropertiesMixinClass structure
|
Since 0.7.3
void tp_dbus_properties_mixin_iface_init (gpointer g_iface, gpointer iface_data);
Declare that the DBus.Properties interface represented by g_iface
is implemented using this mixin.
|
a pointer to a TpSvcDBusPropertiesClass structure |
|
ignored |