Asynchronicity of TPL breaks the way pending messages are ACK.
Submitted by Cosimo Alfarano
Link to original bug (#610994)
Description
With Empathy log blockig APIs pending messages are ACK as soon as a window/tab is focused.
The blocking API flow is:
Msg recvd -> Build message window -> ACK (calling empathy_chat_messages_read())
The "Build message window" was blocking so the end of the function (empathy_chat.c:chat_constructed) meant the window was ready to be shown and the messages could be ACK.
Situation pre fix: When TPL is enabled, chat_constructed calls an async API, returning immediatly. This fools empathy_window which calls empathy_chat_messages_read() to ACK the messages, without waiting for the async call to finish. The async call might finish after the ACK, resulting in the lost of the pending queue which was ACK before being shown properly.
To avoid it, with Guillaume, we decided to add a flag in EmpathyChatPriv, retrieving_backlog, which is set by the async call and read by empathy_chat_messages_read(). If true empathy_chat_messages_read() will not ACK the queue.
The async call chain, at its end, will call empathy_chat_messages_read() after setting the flag TRUE, to ACK the messages.