aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2018-02-28 21:02:39 +0100
committerfiaxh <git@mx.ax.lt>2018-03-06 21:55:31 +0100
commit0968da1ff76e7443c2590f4182087bb501d9c8f5 (patch)
tree9c85aaf44bb53386ddb4fc50de8addfe9bf0f3ae /xmpp-vala/src/module
parenta8ee61b34c4c6c73cda94ac5f60529e892b3666b (diff)
downloaddino-0968da1ff76e7443c2590f4182087bb501d9c8f5.tar.gz
dino-0968da1ff76e7443c2590f4182087bb501d9c8f5.zip
Only notify on last MAM message, only if not read
fixes #293
Diffstat (limited to 'xmpp-vala/src/module')
-rw-r--r--xmpp-vala/src/module/xep/0313_message_archive_management.vala10
1 files changed, 6 insertions, 4 deletions
diff --git a/xmpp-vala/src/module/xep/0313_message_archive_management.vala b/xmpp-vala/src/module/xep/0313_message_archive_management.vala
index 343a5fbd..00f8f99b 100644
--- a/xmpp-vala/src/module/xep/0313_message_archive_management.vala
+++ b/xmpp-vala/src/module/xep/0313_message_archive_management.vala
@@ -14,7 +14,8 @@ public class Module : XmppStreamModule {
private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener();
- public void query_archive(XmppStream stream, string? jid, DateTime? start, DateTime? end) {
+ public delegate void OnFinished(XmppStream stream);
+ public void query_archive(XmppStream stream, string? jid, DateTime? start, DateTime? end, owned OnFinished? on_finished = null) {
if (stream.get_flag(Flag.IDENTITY) == null) return;
DataForms.DataForm data_form = new DataForms.DataForm();
@@ -38,7 +39,7 @@ public class Module : XmppStreamModule {
}
StanzaNode query_node = new StanzaNode.build("query", NS_VER(stream)).add_self_xmlns().put_node(data_form.get_submit_node());
Iq.Stanza iq = new Iq.Stanza.set(query_node);
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, page_through_results);
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => { page_through_results(stream, iq, on_finished); });
}
public override void attach(XmppStream stream) {
@@ -53,10 +54,11 @@ public class Module : XmppStreamModule {
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- private static void page_through_results(XmppStream stream, Iq.Stanza iq) {
+ private static void page_through_results(XmppStream stream, Iq.Stanza iq, owned OnFinished? on_finished = null) {
string? last = iq.stanza.get_deep_string_content(NS_VER(stream) + ":fin", "http://jabber.org/protocol/rsm" + ":set", "last");
if (last == null) {
stream.get_flag(Flag.IDENTITY).cought_up = true;
+ if (on_finished != null) on_finished(stream);
return;
}
@@ -67,7 +69,7 @@ public class Module : XmppStreamModule {
)
)
);
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, paging_iq, page_through_results);
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, paging_iq, (stream, iq) => { page_through_results(stream, iq, on_finished); });
}
private void query_availability(XmppStream stream) {