![]() |
![]() |
![]() |
telepathy-glib API Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
TpMessageMixinTpMessageMixin — a mixin implementation of the text channel type and the Messages interface |
#include <telepathy-glib/message-mixin.h> struct TpMessageMixin; void (*TpMessageMixinSendImpl) (GObject *object
,TpMessage *message
,TpMessageSendingFlags flags
); void tp_message_mixin_finalize (GObject *obj
); void tp_message_mixin_implement_sending (GObject *object
,TpMessageMixinSendImpl send
,guint n_types
,const TpChannelTextMessageType *types
,TpMessagePartSupportFlags message_part_support_flags
,TpDeliveryReportingSupportFlags delivery_reporting_support_flags
,const gchar * const *supported_content_types
); void tp_message_mixin_init (GObject *obj
,gsize offset
,TpBaseConnection *connection
); void tp_message_mixin_init_dbus_properties (GObjectClass *cls
); void tp_message_mixin_messages_iface_init (gpointer g_iface
,gpointer iface_data
); void tp_message_mixin_get_dbus_property (GObject *object
,GQuark interface
,GQuark name
,GValue *value
,gpointer unused
); void tp_message_mixin_sent (GObject *object
,TpMessage *message
,TpMessageSendingFlags flags
,const gchar *token
,const GError *error
); void tp_message_mixin_set_rescued (GObject *obj
); guint tp_message_mixin_take_received (GObject *object
,TpMessage *message
); gboolean tp_message_mixin_has_pending_messages (GObject *object
,TpHandle *first_sender
); void tp_message_mixin_clear (GObject *obj
); void tp_message_mixin_text_iface_init (gpointer g_iface
,gpointer iface_data
);
This mixin can be added to a channel GObject class to implement the text channel type (with the Messages interface) in a general way. The channel class should also have a TpDBusPropertiesMixinClass.
To use the messages mixin, include a TpMessageMixin somewhere in your
instance structure, and call tp_message_mixin_init()
from your
constructor function, and tp_message_mixin_finalize()
from your dispose
or finalize function. In the class_init function, call
tp_message_mixin_init_dbus_properties()
to hook this mixin into the D-Bus
properties mixin class. Finally, include the following in the fourth
argument of G_DEFINE_TYPE_WITH_CODE()
:
1 2 3 4 |
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_TEXT, tp_message_mixin_text_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_MESSAGES, tp_message_mixin_messages_iface_init); |
To support sending messages, you must call
tp_message_mixin_implement_sending()
in the constructor function. If you do
not, any attempt to send a message will fail with NotImplemented.
struct TpMessageMixin { };
Structure to be included in the instance structure of objects that
use this mixin. Initialize it with tp_message_mixin_init()
.
There are no public fields.
Since 0.7.21
void (*TpMessageMixinSendImpl) (GObject *object
,TpMessage *message
,TpMessageSendingFlags flags
);
Signature of a virtual method which may be implemented to allow messages
to be sent. It must arrange for tp_message_mixin_sent()
to be called when
the message has submitted or when message submission has failed.
|
An instance of the implementation that uses this mixin |
|
An outgoing message |
|
flags with which to send the message |
void tp_message_mixin_finalize (GObject *obj
);
Free resources held by the text mixin.
|
An object with this mixin. |
Since 0.7.21
void tp_message_mixin_implement_sending (GObject *object
,TpMessageMixinSendImpl send
,guint n_types
,const TpChannelTextMessageType *types
,TpMessagePartSupportFlags message_part_support_flags
,TpDeliveryReportingSupportFlags delivery_reporting_support_flags
,const gchar * const *supported_content_types
);
Set the callback used to implement SendMessage, and the types of message
that can be sent. This must be called from the init, constructor or
constructed callback, after tp_message_mixin_init()
, and may only be called
once per object.
|
An instance of the implementation that uses this mixin |
|
An implementation of SendMessage()
|
|
Number of supported message types |
|
n_types supported message types |
|
Flags indicating what message part structures are supported |
|
Flags indicating what kind of delivery reports are supported |
|
The supported content types |
Since 0.7.21
void tp_message_mixin_init (GObject *obj
,gsize offset
,TpBaseConnection *connection
);
Initialize the mixin. Should be called from the implementation's instance init function or constructor like so:
1 2 3 |
tp_message_mixin_init ((GObject *) self, G_STRUCT_OFFSET (SomeObject, message_mixin), self->connection); |
|
An instance of the implementation that uses this mixin |
|
The byte offset of the TpMessageMixin within the object structure |
|
A TpBaseConnection |
Since 0.7.21
void tp_message_mixin_init_dbus_properties
(GObjectClass *cls
);
Set up a TpDBusPropertiesMixinClass to use this mixin's implementation of the Messages interface's properties.
This uses tp_message_mixin_get_dbus_property()
as the property getter
and sets a list of the supported properties for it.
|
The class of an object with this mixin |
void tp_message_mixin_messages_iface_init (gpointer g_iface
,gpointer iface_data
);
Fill in this mixin's Messages method implementations in the given interface vtable.
|
A pointer to the TpSvcChannelInterfaceMessagesClass in an object class |
|
Ignored |
Since 0.7.21
void tp_message_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 messages mixin. It can only be used for the Messages
interface.
|
An object with this mixin |
|
Must be TP_IFACE_QUARK_CHANNEL_INTERFACE_MESSAGES
|
|
A quark representing the D-Bus property name, either "PendingMessages", "SupportedContentTypes" or "MessagePartSupportFlags" |
|
A GValue pre-initialized to the right type, into which to put the value |
|
Ignored |
void tp_message_mixin_sent (GObject *object
,TpMessage *message
,TpMessageSendingFlags flags
,const gchar *token
,const GError *error
);
Indicate to the message mixin that message submission to the IM server has succeeded or failed. This should be called as soon as the CM determines it's theoretically possible to send the message (e.g. the parameters are supported and correct).
After this function is called, message
will have been freed, and must not
be dereferenced.
|
An object implementing the Text and Messages interfaces with this mixin |
|
The outgoing message |
|
The flags used when sending the message, which may be a subset of those passed to the TpMessageMixinSendImpl implementation if not all are supported, or 0 on error. |
|
A token representing the sent message (see the Telepathy D-Bus API
specification), or an empty string if no suitable identifier is available,
or NULL on error |
|
NULL on success, or the error with which message submission failed |
Since 0.7.21
void tp_message_mixin_set_rescued (GObject *obj
);
Mark all pending messages as having been "rescued" from a channel that previously closed.
|
An object with this mixin |
guint tp_message_mixin_take_received (GObject *object
,TpMessage *message
);
Receive a message into the pending messages queue, where it will stay until acknowledged, and emit the Received and ReceivedMessage signals. Also emit the SendError signal if the message is a failed delivery report.
|
a channel with this mixin |
|
the message. Its ownership is claimed by the message mixin, so it must no longer be modified or freed |
Returns : |
the message ID |
Since 0.7.21
gboolean tp_message_mixin_has_pending_messages (GObject *object
,TpHandle *first_sender
);
Return whether the channel obj
has unacknowledged messages. If so, and
first_sender
is not NULL
, the handle of the sender of the first message
is placed in it, without incrementing the handle's reference count.
void tp_message_mixin_clear (GObject *obj
);
Clear the pending message queue, deleting all messages without emitting PendingMessagesRemoved.
|
An object with this mixin |
void tp_message_mixin_text_iface_init (gpointer g_iface
,gpointer iface_data
);
Fill in this mixin's Text method implementations in the given interface vtable.
|
A pointer to the TpSvcChannelTypeTextClass in an object class |
|
Ignored |
Since 0.7.21