Top |
This mixin can be added to a channel GObject class to implement the groups interface in a general way.
To use the group mixin, include a TpGroupMixinClass somewhere in your
class structure and a TpGroupMixin somewhere in your instance structure,
and call tp_group_mixin_class_init()
from your class_init function,
tp_group_mixin_init()
from your init function or constructor, and
tp_group_mixin_finalize()
from your dispose or finalize function.
To use the group mixin as the implementation of
TpSvcChannelInterfaceGroup1, call
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP1,
tp_group_mixin_iface_init)
in the fourth argument to
G_DEFINE_TYPE_WITH_CODE
.
Since 0.5.13 you can also implement the group interface by forwarding all
group operations to the group mixin of an associated object (mainly useful
for old Tubes channels). To do this, call tp_external_group_mixin_init()
in the constructor after the associated object has been set,
tp_external_group_mixin_finalize()
in the dispose or finalize function, and
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP1,
tp_external_group_mixin_iface_init)
in the fourth argument to
G_DEFINE_TYPE_WITH_CODE
.
Since 0.7.10 you can also implement the properties of Group channels,
by calling tp_group_mixin_init_dbus_properties()
or
tp_external_group_mixin_init_dbus_properties()
(as appropriate).
#define TP_HAS_GROUP_MIXIN_CLASS(cls) (TP_GROUP_MIXIN_CLASS_OFFSET (cls) != 0)
Since 0.13.9
gboolean (*TpGroupMixinAddMemberFunc) (GObject *obj
,TpHandle handle
,const gchar *message
,GError **error
);
Signature of the callback used to add a member to the group. This should perform the necessary operations in the underlying IM protocol to cause the member to be added.
obj |
An object implementing the group interface with this mixin |
|
handle |
The handle of the contact to be added |
|
message |
A message to be sent if the protocol supports it |
|
error |
Used to return a Telepathy D-Bus error if |
gboolean (*TpGroupMixinRemMemberFunc) (GObject *obj
,TpHandle handle
,const gchar *message
,GError **error
);
Signature of the callback used to remove a member from the group. This should perform the necessary operations in the underlying IM protocol to cause the member to be removed.
obj |
An object implementing the group interface with this mixin |
|
handle |
The handle of the contact to be removed |
|
message |
A message to be sent if the protocol supports it |
|
error |
Used to return a Telepathy D-Bus error if |
gboolean (*TpGroupMixinRemMemberWithReasonFunc) (GObject *obj
,TpHandle handle
,const gchar *message
,guint reason
,GError **error
);
Signature of the callback used to remove a member from the group. This should perform the necessary operations in the underlying IM protocol to cause the member to be removed.
Set this with tp_group_mixin_class_set_remove_with_reason_func()
, .
obj |
An object implementing the group interface with this mixin |
|
handle |
The handle of the contact to be removed |
|
message |
A message to be sent if the protocol supports it |
|
reason |
A TpChannelGroupChangeReason indicating the reason |
|
error |
Used to return a Telepathy D-Bus error if |
void tp_group_mixin_class_init (GObjectClass *obj_cls
,glong offset
,TpGroupMixinAddMemberFunc add_func
,TpGroupMixinRemMemberFunc rem_func
);
Configure the mixin for use with the given class.
obj_cls |
The class of an object implementing the group interface using this mixin |
|
offset |
The offset of the TpGroupMixinClass structure within the class structure |
|
add_func |
A callback to be used to add contacts to this group |
|
rem_func |
A callback to be used to remove contacts from this group.
This must be |
void
tp_group_mixin_class_allow_self_removal
(GObjectClass *obj_cls
);
Configure the mixin to allow attempts to remove the SelfHandle from this
Group, even if the group flags would otherwise disallow this. The
channel's TpGroupMixinRemMemberFunc or
TpGroupMixinRemMemberWithReasonFunc will be called as usual for such
attempts, and may make them fail with TP_ERROR_PERMISSION_DENIED
if
required.
This function should be called from the GObject class_init
callback,
after calling tp_group_mixin_class_init()
.
(Recent telepathy-spec changes make it valid to try to remove the self-handle at all times, regardless of group flags. However, if this was implemented automatically in TpGroupMixin, this would risk crashing connection manager implementations that assume that TpGroupMixin will enforce the group flags strictly. As a result, connection managers should call this function to indicate to the TpGroupMixin that it may call their removal callback with the self-handle regardless of flag settings.)
Since 0.7.27
void tp_group_mixin_class_set_remove_with_reason_func (GObjectClass *cls
,TpGroupMixinRemMemberWithReasonFunc func
);
Set a callback to be used to implement RemoveMembers()
and
RemoveMembersWithReason()
. If this function is called during class
initialization, the given callback will be used instead of the remove
callback passed to tp_group_mixin_class_init()
(which must be NULL
in this case).
cls |
The class of an object implementing the group interface using this mixin |
|
func |
A callback to be used to remove contacts from this group with a specified reason. |
Since 0.5.13
void tp_group_mixin_init (GObject *obj
,glong offset
,TpHandleRepoIface *handle_repo
,TpHandle self_handle
);
Initialize the mixin.
Since 0.99.1 obj
must be a TpBaseChannel subclass.
void
tp_group_mixin_finalize (GObject *obj
);
Unreference handles and free resources used by this mixin.
gboolean tp_group_mixin_get_self_handle (GObject *obj
,guint *ret
,GError **error
);
Set the guint pointed to by ret to the local user's handle in this group, or to 0 if the local user is not present in this group.
gboolean tp_group_mixin_get_group_flags (GObject *obj
,guint *ret
,GError **error
);
Set the guint pointed to by ret to this group's flags, to be interpreted according to TpChannelGroupFlags.
gboolean tp_group_mixin_add_members (GObject *obj
,const GArray *contacts
,const gchar *message
,GError **error
);
Request that the given contacts be added to the group as if in response to user action. If the group's flags prohibit this, raise PermissionDenied. If any of the handles is invalid, raise InvalidHandle. Otherwise attempt to add the contacts by calling the callbacks provided by the channel implementation.
obj |
An object implementing the group interface using this mixin |
|
contacts |
A GArray of guint representing contacts |
|
message |
A message associated with the addition request, if supported |
|
error |
Used to return an error if |
gboolean tp_group_mixin_remove_members (GObject *obj
,const GArray *contacts
,const gchar *message
,guint reason
,GError **error
);
Request that the given contacts be removed from the group as if in response to user action. If the group's flags prohibit this, raise PermissionDenied. If any of the handles is invalid, raise InvalidHandle. If any of the handles is absent from the group, raise NotAvailable. Otherwise attempt to remove the contacts by calling the callbacks provided by the channel implementation.
obj |
An object implementing the group interface using this mixin |
|
contacts |
A GArray of guint representing contacts |
|
message |
A message to be sent to those contacts, if supported |
|
reason |
||
error |
Used to return an error if |
void tp_group_mixin_change_flags (GObject *obj
,TpChannelGroupFlags add
,TpChannelGroupFlags del
);
Request a change to be made to the flags. If any flags were actually set or cleared, emits the GroupFlagsChanged signal with the changes.
It is an error to set any of the same bits in both add
and del
.
Changed in 0.7.7: the signal is not emitted if adding add
and
removing del
had no effect on the existing group flags.
gboolean tp_group_mixin_change_members (GObject *obj
,const TpIntset *add
,const TpIntset *del
,const TpIntset *add_local_pending
,const TpIntset *add_remote_pending
,GVariant *details
);
Change the sets of members as given by the arguments, and emit the MembersChanged signal if the changes were not a no-op.
This function must be called in response to events on the underlying IM protocol, and must not be called in direct response to user input; it does not respect the permissions flags, but changes the group directly.
If any two of add, del, add_local_pending and add_remote_pending have a non-empty intersection, the result is undefined. Don't do that.
Each of the TpIntset arguments may be NULL
, which is treated as
equivalent to an empty set.
details may contain, among other entries, the well-known
keys (and corresponding type, wrapped in a variant) defined by the
Group.MembersChanged signal's specification; these include "actor"
(a handle as G_VARIANT_TYPE_UINT32
), "change-reason" (an element of
TpChannelGroupChangeReason as G_VARIANT_TYPE_UINT32
),
"message" (G_VARIANT_TYPE_STRING
),
"error" (G_VARIANT_TYPE_STRING
), "debug-message" (G_VARIANT_TYPE_STRING
).
If it is a floating reference, ownership is taken; if it is NULL
,
it is treated as an empty map.
obj |
An object implementing the group interface using this mixin |
|
add |
A set of contact handles to be added to the members (if not already present) and removed from local pending and remote pending (if present) |
|
del |
A set of contact handles to be removed from members, local pending or remote pending, wherever they are present |
|
add_local_pending |
A set of contact handles to be added to local pending, and removed from members and remote pending |
|
add_remote_pending |
A set of contact handles to be added to remote pending, and removed from members and local pending |
|
details |
a |
[allow-none] |
TRUE
if the group was changed and the MembersChanged
signals were emitted; FALSE
if nothing actually changed and the signals
were suppressed.
Since 0.7.21
void tp_group_mixin_add_handle_owner (GObject *obj
,TpHandle local_handle
,TpHandle owner_handle
);
Note that the given local handle is an alias within this group for the given globally-valid handle. It will be returned from subsequent GetHandleOwner queries where appropriate.
Changed in 0.7.10: The owner_handle
may be 0. To comply with telepathy-spec
0.17.6, before adding any channel-specific handle to the members,
local-pending members or remote-pending members, you must call either
this function or tp_group_mixin_add_handle_owners()
.
void tp_group_mixin_iface_init (gpointer g_iface
,gpointer iface_data
);
Fill in the vtable entries needed to implement the group interface using this mixin. This function should usually be called via G_IMPLEMENT_INTERFACE.
void tp_group_mixin_add_handle_owners (GObject *obj
,GHashTable *local_to_owner_handle
);
Note that the given local handles are aliases within this group for the given globally-valid handles.
To comply with telepathy-spec 0.17.6, before adding any channel-specific
handle to the members, local-pending members or remote-pending members, you
must call either this function or tp_group_mixin_add_handle_owner()
.
obj |
A GObject implementing the group interface with this mixin |
|
local_to_owner_handle |
A map from contact handles valid within this group (which may not be 0) to either contact handles valid globally, or 0 if the owner of the corresponding key is unknown; all handles are stored using GUINT_TO_POINTER |
Since 0.7.10
void tp_group_mixin_get_dbus_property (GObject *object
,GQuark interface
,GQuark name
,GValue *value
,gpointer unused
);
An implementation of TpDBusPropertiesMixinGetter which assumes that the
object
has the group mixin. It can only be used for the Group interface.
object |
An object with this mixin |
|
interface |
||
name |
A quark representing the D-Bus property name, either "GroupFlags", "HandleOwners", "LocalPendingMembers", "Members", "RemotePendingMembers" or "SelfHandle" |
|
value |
A GValue pre-initialized to the right type, into which to put the value |
|
unused |
Ignored |
Since 0.7.10
void
tp_group_mixin_init_dbus_properties (GObjectClass *cls
);
Set up TpDBusPropertiesMixinClass to use this mixin's implementation of the Group interface's properties.
This uses tp_group_mixin_get_dbus_property()
as the property getter and
sets up a list of the supported properties for it. Having called this, you
should add TP_CHANNEL_GROUP_FLAG_PROPERTIES to any channels of this class
with tp_group_mixin_change_flags()
to indicate that the DBus properties are
available.
Since 0.7.10
void tp_group_mixin_change_self_handle (GObject *obj
,TpHandle new_self_handle
);
Change the self-handle for this group to the given value.
void tp_external_group_mixin_iface_init (gpointer g_iface
,gpointer iface_data
);
Fill in the vtable entries needed to implement the group interface using the group mixin of another object. This function should usually be called via G_IMPLEMENT_INTERFACE.
Since 0.5.13
void tp_external_group_mixin_init (GObject *obj
,GObject *obj_with_mixin
);
Fill in the qdata needed to implement the group interface using the group mixin of another object. This function should usually be called in the instance constructor.
obj |
An object implementing the groups interface using an external group mixin |
|
obj_with_mixin |
A GObject with the group mixin |
Since 0.5.13
void
tp_external_group_mixin_finalize (GObject *obj
);
Remove the external group mixin. This function should usually be called in the dispose or finalize function.
Since 0.5.13
void
tp_external_group_mixin_init_dbus_properties
(GObjectClass *cls
);
Set up TpDBusPropertiesMixinClass to use this mixin's implementation of the Group interface's properties.
This uses tp_group_mixin_get_dbus_property()
as the property getter and
sets up a list of the supported properties for it. Having called this, you
should add TP_CHANNEL_GROUP_FLAG_PROPERTIES to channels containing the
mixin used by this class with tp_group_mixin_change_flags()
to indicate that
the DBus properties are available.
Since 0.7.10
void tp_external_group_mixin_get_dbus_property (GObject *object
,GQuark interface
,GQuark name
,GValue *value
,gpointer unused
);
An implementation of TpDBusPropertiesMixinGetter which assumes that the
object
has the external group mixin. It can only be used for the Group
interface.
object |
An object with this mixin |
|
interface |
||
name |
A quark representing the D-Bus property name, either "GroupFlags", "HandleOwners", "LocalPendingMembers", "Members", "RemotePendingMembers" or "SelfHandle" |
|
value |
A GValue pre-initialized to the right type, into which to put the value |
|
unused |
Ignored |
Since 0.7.10
struct TpGroupMixin { TpHandleRepoIface *handle_repo; TpHandle self_handle; TpChannelGroupFlags group_flags; TpHandleSet *members; TpHandleSet *local_pending; TpHandleSet *remote_pending; TpGroupMixinPrivate *priv; };
Structure representing the group mixin as used in a particular class. To be placed in the implementation's instance structure.
All fields should be considered read-only.
TpHandleRepoIface * |
The connection's contact handle repository |
|
TpHandle |
The local user's handle within this group, or 0 if none.
Set using |
|
TpChannelGroupFlags |
This group's flags. Set using |
|
TpHandleSet * |
The members of the group. Alter using
|
|
TpHandleSet * |
Members awaiting the local user's approval to join the
group. Alter using |
|
TpHandleSet * |
Members awaiting remote (e.g. remote user or server)
approval to join the group. Alter using |
|
Pointer to opaque private data |
struct TpGroupMixinClass { TpGroupMixinAddMemberFunc add_member; TpGroupMixinRemMemberFunc remove_member; TpGroupMixinClassPrivate *priv; };
Structure representing the group mixin as used in a particular class. To be placed in the implementation's class structure.
Initialize this with tp_group_mixin_class_init()
.
All fields should be considered read-only.
TpGroupMixinAddMemberFunc |
The add-member function that was passed to
|
|
TpGroupMixinRemMemberFunc |
The remove-member function that was passed to
|
|
Pointer to opaque private data |