diff options
author | Samuel Hand <samuel.hand@openmailbox.org> | 2018-08-05 01:26:36 +0100 |
---|---|---|
committer | Samuel Hand <samuel.hand@openmailbox.org> | 2018-08-05 01:26:36 +0100 |
commit | 0bfab9d1d97d07679da4a2a1db5903782a74ae49 (patch) | |
tree | 25eac692887bc6602ae7597d3216e787f8ebc70d /xmpp-vala/src/module | |
parent | ed3b36d0de50966de907766ac0fd6bc7713f0374 (diff) | |
download | dino-0bfab9d1d97d07679da4a2a1db5903782a74ae49.tar.gz dino-0bfab9d1d97d07679da4a2a1db5903782a74ae49.zip |
Fix bug where OMEMO not avaiable with a newly added contact
Diffstat (limited to 'xmpp-vala/src/module')
-rw-r--r-- | xmpp-vala/src/module/presence/flag.vala | 2 | ||||
-rw-r--r-- | xmpp-vala/src/module/presence/module.vala | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/xmpp-vala/src/module/presence/flag.vala b/xmpp-vala/src/module/presence/flag.vala index bb3562a4..77bc0b5f 100644 --- a/xmpp-vala/src/module/presence/flag.vala +++ b/xmpp-vala/src/module/presence/flag.vala @@ -57,4 +57,4 @@ public class Flag : XmppStreamFlag { } } -}
\ No newline at end of file +} diff --git a/xmpp-vala/src/module/presence/module.vala b/xmpp-vala/src/module/presence/module.vala index 12b40245..2188d89d 100644 --- a/xmpp-vala/src/module/presence/module.vala +++ b/xmpp-vala/src/module/presence/module.vala @@ -1,3 +1,5 @@ +using Gee; + namespace Xmpp.Presence { private const string NS_URI = "jabber:client"; @@ -13,9 +15,13 @@ namespace Xmpp.Presence { public signal void received_subscription_request(XmppStream stream, Jid jid); public signal void received_subscription_approval(XmppStream stream, Jid jid); public signal void received_unsubscription(XmppStream stream, Jid jid); + public signal void mutual_subscription(XmppStream stream, Jid jid); public bool available_resource = true; + private Gee.List<Jid> subscriptions = new ArrayList<Jid>(Jid.equals_bare_func); + private Gee.List<Jid> subscribers = new ArrayList<Jid>(Jid.equals_bare_func); + public void request_subscription(XmppStream stream, Jid bare_jid) { Presence.Stanza presence = new Presence.Stanza(); presence.to = bare_jid; @@ -28,6 +34,8 @@ namespace Xmpp.Presence { presence.to = bare_jid; presence.type_ = Presence.Stanza.TYPE_SUBSCRIBED; send_presence(stream, presence); + subscribers.add(bare_jid); + if (subscriptions.contains(bare_jid)) mutual_subscription(stream, bare_jid); } public void deny_subscription(XmppStream stream, Jid bare_jid) { @@ -39,6 +47,7 @@ namespace Xmpp.Presence { presence.to = bare_jid; presence.type_ = Presence.Stanza.TYPE_UNSUBSCRIBED; send_presence(stream, presence); + subscribers.remove(bare_jid); } public void unsubscribe(XmppStream stream, Jid bare_jid) { @@ -46,6 +55,7 @@ namespace Xmpp.Presence { presence.to = bare_jid; presence.type_ = Presence.Stanza.TYPE_UNSUBSCRIBE; send_presence(stream, presence); + subscriptions.remove(bare_jid); } public void send_presence(XmppStream stream, Presence.Stanza presence) { @@ -82,10 +92,16 @@ namespace Xmpp.Presence { break; case Presence.Stanza.TYPE_SUBSCRIBED: received_subscription_approval(stream, presence.from); + subscriptions.add(presence.from); + if (subscribers.contains(presence.from)) mutual_subscription(stream, presence.from); break; case Presence.Stanza.TYPE_UNSUBSCRIBE: stream.get_flag(Flag.IDENTITY).remove_presence(presence.from); received_unsubscription(stream, presence.from); + subscribers.remove(presence.from); + break; + case Presence.Stanza.TYPE_UNSUBSCRIBED: + subscriptions.remove(presence.from); break; } } |