Bug 23238 - Add acking hooks to TpMessageMixin/TpTextMixin
Summary: Add acking hooks to TpMessageMixin/TpTextMixin
Status: RESOLVED WONTFIX
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-glib (show other bugs)
Version: unspecified
Hardware: All All
: low enhancement
Assignee: Eitan Isaacson
QA Contact: Telepathy bugs list
URL: http://git.collabora.co.uk/?p=user/ei...
Whiteboard: review-, needs test
Keywords: patch
Depends on:
Blocks:
 
Reported: 2009-08-10 08:25 UTC by Mikhail Zabaluev
Modified: 2010-11-23 05:24 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Mikhail Zabaluev 2009-08-10 08:25:22 UTC
As of telepathy-glib 0.7.33, it's inconvenient to implement any protocol-specific actions upon acknowledgement of incoming messages in text channels. There should be:
1. A hook to call when one pending message is acknowledged;
2. A data pointer to associate with a pending (or any?) message, available to the said hook.
Comment 1 Eitan Isaacson 2010-10-15 09:17:33 UTC
Hi,

Is this the kind of API are in need of? Am I missing anything?

/**
 * TpMessageMixinAcknowledgeHook:
 * @object: An instance of the implementation that uses this mixin
 * @message: The acknowledged message.
 *
 * Signature of a virtual method which may be implemented to notify a CM
 * of a message that was acknowledged.
 */

/**
 * tp_message_mixin_implement_acknowledge_hook:
 * @object: An instance of the implementation that uses this mixin
 * @acknowledge_hook: A hook function with the signature of
 *  #TpMessageMixinAcknowledgeHook
 *
 * Set a hook function for each message that is acknowledged, just before it is
 * removed from the pending queue.
 *
 * @since 0.13.2
 */
Comment 2 Eitan Isaacson 2010-10-15 11:06:44 UTC
Besides review, we need to hear from Mikhail that this is the feature he needs. Also, I didn't add a regression test for tp_message_mixin_implement_acknowledge_hook, only for tp_text_mixin_implement_acknowledge_hook as the TpMessageMixin instance is harder to access in the current tests.
Comment 3 Artem Garmash 2010-10-18 04:28:55 UTC
It looks good to me, at least now it's possible to do something (e.g. mark as read) in a CM on message acknowledge. I'm not sure how the second part is important to have, a CM could easily have mapping between internal objects and TpMessages or pending message IDs.
Comment 4 Simon McVittie 2010-10-18 04:45:29 UTC
(Please set the patch keyword if you want things reviewed.)

I don't think it's worth adding this to TpTextMixin: the first step for anyone wanting to do new things with TpTextMixin should be "port to TpMessageMixin".

tp_message_mixin_take_received returns the pending message ID: the acknowledgement hook ought to have that pending message ID as a parameter.

In the Messages world, we emit PendingMessagesRemoved(au: Pending_Message_IDs), which in the dbus-glib world is actually a pending-messages-removed GObject signal on the Channel object, whose parameter is a GArray of guint.

I wonder whether it would be sufficient to have CM implementors just connect to that signal, and maintain a hash table of { pending message ID => internal object representing the message }?

If we keep the acknowledgement-hook support in its current form, the TpMessageMixin version needs tests, since it's the version that will be important in future. Two easy ways to do this spring to mind:

- have the Echo2 example emit a signal from its acknowledgement hook, and catch that signal in the test

- subclass the Echo2 example's channel, and set an acknowledgement hook in the subclass's class_init

One way to have "user data" like Mikhail suggested would be to add guint tp_message_mixin_take_received_full (GObject *object, TpMessage *message, gpointer user_data, GDestroyNotify destroy), where @destroy is called after the message has been acknowledged. In simple cases you wouldn't necessarily even need the acknowledgement hook.
Comment 5 Eitan Isaacson 2010-10-18 10:35:05 UTC
(In reply to comment #4)
> (Please set the patch keyword if you want things reviewed.)
> 

This isn't ready for review yet, I will add the keyword when it is :)

> I don't think it's worth adding this to TpTextMixin: the first step for anyone
> wanting to do new things with TpTextMixin should be "port to TpMessageMixin".
> 
> tp_message_mixin_take_received returns the pending message ID: the
> acknowledgement hook ought to have that pending message ID as a parameter.
> 

It is in the TpMessage struct, but I just realized it is opaque.

> In the Messages world, we emit PendingMessagesRemoved(au: Pending_Message_IDs),
> which in the dbus-glib world is actually a pending-messages-removed GObject
> signal on the Channel object, whose parameter is a GArray of guint.
> 
> I wonder whether it would be sufficient to have CM implementors just connect to
> that signal, and maintain a hash table of { pending message ID => internal
> object representing the message }?

That makes a lot of sense! Artem, what do you think?

> 
> If we keep the acknowledgement-hook support in its current form, the
> TpMessageMixin version needs tests, since it's the version that will be
> important in future. Two easy ways to do this spring to mind:
> 
> - have the Echo2 example emit a signal from its acknowledgement hook, and catch
> that signal in the test
> 
> - subclass the Echo2 example's channel, and set an acknowledgement hook in the
> subclass's class_init

Good ideas, I'll use those if we have something to test (if the signal is not enough).

> 
> One way to have "user data" like Mikhail suggested would be to add guint
> tp_message_mixin_take_received_full (GObject *object, TpMessage *message,
> gpointer user_data, GDestroyNotify destroy), where @destroy is called after the
> message has been acknowledged. In simple cases you wouldn't necessarily even
> need the acknowledgement hook.

Since we have unique IDs, I don't think user data is essential. Keeping a mapping is easy enough, probably not worth complicating our API for that. But I could be convinced otherwise.
Comment 6 Eitan Isaacson 2010-10-20 08:29:16 UTC
(In reply to comment #3)
> It looks good to me, at least now it's possible to do something (e.g. mark as
> read) in a CM on message acknowledge. I'm not sure how the second part is
> important to have, a CM could easily have mapping between internal objects and
> TpMessages or pending message IDs.

Artem, what are your thoughts on this. Is using the pending-messages-removed signal good enough here?
Comment 7 Artem Garmash 2010-10-20 08:47:36 UTC
> Artem, what are your thoughts on this. Is using the pending-messages-removed
> signal good enough here?

Sure, should be enough, we did not know about the signal.
Comment 8 Simon McVittie 2010-11-18 06:44:51 UTC
(In reply to comment #7)
> > Artem, what are your thoughts on this. Is using the pending-messages-removed
> > signal good enough here?
> 
> Sure, should be enough, we did not know about the signal.

Shall we WONTFIX this, then?
Comment 9 Mikhail Zabaluev 2010-11-23 05:09:32 UTC
(In reply to comment #8)
> > Sure, should be enough, we did not know about the signal.
> 
> Shall we WONTFIX this, then?

This is one of the acceptable resolutions :)
Comment 10 Simon McVittie 2010-11-23 05:24:04 UTC
WONTFIX, not needed. Please reopen (or open another bug) if you discover you need this for some reason.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.