From 3eb9aa0fa79ea9fcebb5f702f81c2e54aafdc8cc Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 23 Apr 2017 13:50:32 +0200 Subject: Sync MUC join/part behaviour with autojoin flag in bookmarks --- xmpp-vala/src/module/xep/0048_bookmarks/conference.vala | 9 ++++++++- xmpp-vala/src/module/xep/0048_bookmarks/module.vala | 12 +++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'xmpp-vala/src/module/xep') diff --git a/xmpp-vala/src/module/xep/0048_bookmarks/conference.vala b/xmpp-vala/src/module/xep/0048_bookmarks/conference.vala index 21072c3f..6964f83d 100644 --- a/xmpp-vala/src/module/xep/0048_bookmarks/conference.vala +++ b/xmpp-vala/src/module/xep/0048_bookmarks/conference.vala @@ -28,7 +28,10 @@ public class Conference : Object { public string? name { get { return stanza_node.get_attribute(ATTRIBUTE_NAME); } - set { stanza_node.set_attribute(ATTRIBUTE_NAME, value); } + set { + if (value == null) return; // TODO actually remove + stanza_node.set_attribute(ATTRIBUTE_NAME, value); + } } public string? nick { @@ -58,6 +61,10 @@ public class Conference : Object { } set { StanzaNode? password_node = stanza_node.get_subnode(NODE_PASSWORD); + if (value == null) { + if (password_node != null) stanza_node.sub_nodes.remove(password_node); + return; + } if (password_node == null) { password_node = new StanzaNode.build(NODE_PASSWORD); stanza_node.put_node(password_node); diff --git a/xmpp-vala/src/module/xep/0048_bookmarks/module.vala b/xmpp-vala/src/module/xep/0048_bookmarks/module.vala index 0e0d9489..bf5bd612 100644 --- a/xmpp-vala/src/module/xep/0048_bookmarks/module.vala +++ b/xmpp-vala/src/module/xep/0048_bookmarks/module.vala @@ -8,25 +8,27 @@ private const string NS_URI = "storage:bookmarks"; public class Module : XmppStreamModule { public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0048_bookmarks_module"); - public signal void conferences_updated(XmppStream stream, ArrayList conferences); + public signal void received_conferences(XmppStream stream, Gee.List conferences); - [CCode (has_target = false)] public delegate void OnResult(XmppStream stream, ArrayList conferences, Object? reference); + [CCode (has_target = false)] public delegate void OnResult(XmppStream stream, Gee.List conferences, Object? storage); public void get_conferences(XmppStream stream, OnResult listener, Object? store) { StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns(); stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node, (stream, node, o) => { Tuple tuple = o as Tuple; OnResult on_result = tuple.a; - on_result(stream, get_conferences_from_stanza(node), tuple.b); + Gee.List conferences = get_conferences_from_stanza(node); + stream.get_module(Module.IDENTITY).received_conferences(stream, conferences); + on_result(stream, conferences, tuple.b); }, Tuple.create(listener, store)); } - public void set_conferences(XmppStream stream, ArrayList conferences) { + public void set_conferences(XmppStream stream, Gee.List conferences) { StanzaNode storage_node = (new StanzaNode.build("storage", NS_URI)).add_self_xmlns(); foreach (Conference conference in conferences) { storage_node.put_node(conference.stanza_node); } stream.get_module(PrivateXmlStorage.Module.IDENTITY).store(stream, storage_node, (stream, o) => { - stream.get_module(Module.IDENTITY).conferences_updated(stream, o as ArrayList); + stream.get_module(Module.IDENTITY).received_conferences(stream, o as ArrayList); }, conferences); } -- cgit v1.2.3-70-g09d2