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
TpSvcChannelInterfaceGroup, call
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP,
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 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_GROUP,
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.
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.
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.
[skip]
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.)
[skip]
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).
[skip]
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.
[skip]
void
tp_group_mixin_finalize (GObject *obj
);
Unreference handles and free resources used by this mixin.
[skip]
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.
[skip]
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.
[skip]
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.
[skip]
gboolean tp_group_mixin_remove_members (GObject *obj
,const GArray *contacts
,const gchar *message
,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.
[skip]
gboolean tp_group_mixin_remove_members_with_reason (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.
[skip]
gboolean tp_group_mixin_get_members (GObject *obj
,GArray **ret
,GError **error
);
Get the group's current members
[skip]
gboolean tp_group_mixin_get_local_pending_members (GObject *obj
,GArray **ret
,GError **error
);
Get the group's local-pending members.
[skip]
gboolean tp_group_mixin_get_local_pending_members_with_info (GObject *obj
,GPtrArray **ret
,GError **error
);
Get the group's local-pending members and information about their requests to join the channel.
[skip]
obj |
An object implementing the group interface using this mixin |
|
ret |
Used to return a newly-allocated GPtrArray of D-Bus structures each containing the handle of a local-pending contact, the handle of a contact responsible for adding them to the group (or 0), the reason code and a related message (e.g. their request to join the group) |
|
error |
Unused |
gboolean tp_group_mixin_get_remote_pending_members (GObject *obj
,GArray **ret
,GError **error
);
Get the group's remote-pending members.
[skip]
gboolean tp_group_mixin_get_all_members (GObject *obj
,GArray **members
,GArray **local_pending
,GArray **remote_pending
,GError **error
);
Get the group's current and pending members.
[skip]
obj |
An object implementing the group interface using this mixin |
|
members |
Used to return a newly-allocated GArray of guint representing the handles of the group's members |
|
local_pending |
Used to return a newly-allocated GArray of guint representing the handles of the group's local pending members |
|
remote_pending |
Used to return a newly-allocated GArray of guint representing the handles of the group's remote pending members |
|
error |
Unused |
gboolean tp_group_mixin_get_handle_owners (GObject *obj
,const GArray *handles
,GArray **ret
,GError **error
);
If the mixin has the flag TP_CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES
,
return the global owners of the given local handles, or 0 where
unavailable.
[skip]
obj |
An object implementing the group interface with this mixin |
|
handles |
An array of guint representing locally valid handles |
|
ret |
Used to return an array of guint representing globally valid
handles, or 0 where unavailable, if |
|
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.
[skip]
gboolean tp_group_mixin_change_members (GObject *obj
,const gchar *message
,const TpIntset *add
,const TpIntset *del
,const TpIntset *add_local_pending
,const TpIntset *add_remote_pending
,TpHandle actor
,TpChannelGroupChangeReason reason
);
Change the sets of members as given by the arguments, and emit the MembersChanged and MembersChangedDetailed signals 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.
[skip]
obj |
An object implementing the group interface using this mixin |
|
message |
A message to be sent to the affected contacts if possible;
|
|
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 |
|
actor |
The handle of the contact responsible for this change |
|
reason |
The reason for this change |
gboolean tp_group_mixin_change_members_detailed (GObject *obj
,const TpIntset *add
,const TpIntset *del
,const TpIntset *add_local_pending
,const TpIntset *add_remote_pending
,const GHashTable *details
);
Change the sets of members as given by the arguments, and emit the MembersChanged and MembersChangedDetailed signals 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 GValue) defined by the Group.MembersChangedDetailed signal's specification; these include "actor" (a handle as G_TYPE_UINT), "change-reason" (an element of TpChannelGroupChangeReason as G_TYPE_UINT), "message" (G_TYPE_STRING), "error" (G_TYPE_STRING), "debug-message" (G_TYPE_STRING).
If all of the information in details could be passed to
tp_group_mixin_change_members()
then calling this function instead provides
no benefit. Calling this function without setting
TP_CHANNEL_GROUP_FLAG_MEMBERS_CHANGED_DETAILED with
tp_group_mixin_change_members()
first is not very useful, as clients will
not know to listen for MembersChangedDetailed and thus will miss the
details.
[skip]
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 map from strings to GValues detailing the change |
TRUE
if the group was changed and the MembersChanged(Detailed)
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()
.
[skip]
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.
[skip]
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()
.
[skip]
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.
[skip]
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.
[skip]
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.
[skip]
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.
[skip]
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.
[skip]
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.
[skip]
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.
[skip]
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.
[skip]
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 |