aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep/0045_muc
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-12-16 01:34:28 +0100
committerfiaxh <git@lightrise.org>2019-12-16 01:41:04 +0100
commit890b91ce4d968f838b46686295883500eba55c78 (patch)
tree62983c8fb2fe49e0cbab66cef944121e1f074ef3 /xmpp-vala/src/module/xep/0045_muc
parent21c01dcdcb3ba7f7d5c6fcd18c5fd2117f050e5e (diff)
downloaddino-890b91ce4d968f838b46686295883500eba55c78.tar.gz
dino-890b91ce4d968f838b46686295883500eba55c78.zip
Only send new room config if something was changed
fixes #675
Diffstat (limited to 'xmpp-vala/src/module/xep/0045_muc')
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/module.vala31
1 files changed, 16 insertions, 15 deletions
diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala
index 8ce0e20e..3ff28b2b 100644
--- a/xmpp-vala/src/module/xep/0045_muc/module.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/module.vala
@@ -177,22 +177,23 @@ public class Module : XmppStreamModule {
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
}
- public delegate void OnConfigFormResult(XmppStream stream, Jid jid, DataForms.DataForm data_form);
- public void get_config_form(XmppStream stream, Jid jid, owned OnConfigFormResult listener) {
+ public async DataForms.DataForm? get_config_form(XmppStream stream, Jid jid) {
Iq.Stanza get_iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_OWNER).add_self_xmlns()) { to=jid };
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, get_iq, (stream, form_iq) => {
- StanzaNode? x_node = form_iq.stanza.get_deep_subnode(NS_URI_OWNER + ":query", DataForms.NS_URI + ":x");
- if (x_node != null) {
- DataForms.DataForm data_form = DataForms.DataForm.create_from_node(stream, x_node, (stream, node) => {
- StanzaNode stanza_node = new StanzaNode.build("query", NS_URI_OWNER);
- stanza_node.add_self_xmlns().put_node(node);
- Iq.Stanza set_iq = new Iq.Stanza.set(stanza_node);
- set_iq.to = form_iq.from;
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, set_iq);
- });
- listener(stream, form_iq.from, data_form);
- }
- });
+ Iq.Stanza result_iq = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, get_iq);
+
+ StanzaNode? x_node = result_iq.stanza.get_deep_subnode(NS_URI_OWNER + ":query", DataForms.NS_URI + ":x");
+ if (x_node != null) {
+ DataForms.DataForm data_form = DataForms.DataForm.create_from_node(x_node);
+ return data_form;
+ }
+ return null;
+ }
+
+ public void set_config_form(XmppStream stream, Jid jid, DataForms.DataForm data_form) {
+ StanzaNode stanza_node = new StanzaNode.build("query", NS_URI_OWNER);
+ stanza_node.add_self_xmlns().put_node(data_form.get_submit_node());
+ Iq.Stanza set_iq = new Iq.Stanza.set(stanza_node) { to=jid };
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, set_iq);
}
public override void attach(XmppStream stream) {