aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep/0045_muc
diff options
context:
space:
mode:
authorAnmol <godofwaranmol@gmail.com>2020-04-22 23:34:03 +0530
committerGitHub <noreply@github.com>2020-04-22 20:04:03 +0200
commit2631a9bdbaf9a40f329f05c55c6e2ea38efeb10c (patch)
treedfe6b0b3a390457b1c7d125b81a5c1d10019281c /xmpp-vala/src/module/xep/0045_muc
parent51a23728694a3f1312cc9396fc093ca178457c3c (diff)
downloaddino-2631a9bdbaf9a40f329f05c55c6e2ea38efeb10c.tar.gz
dino-2631a9bdbaf9a40f329f05c55c6e2ea38efeb10c.zip
voice handling in moderated groups (#788)
Diffstat (limited to 'xmpp-vala/src/module/xep/0045_muc')
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/module.vala53
1 files changed, 53 insertions, 0 deletions
diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala
index 1b16f8a1..3a15a19d 100644
--- a/xmpp-vala/src/module/xep/0045_muc/module.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/module.vala
@@ -6,6 +6,7 @@ private const string NS_URI = "http://jabber.org/protocol/muc";
private const string NS_URI_ADMIN = NS_URI + "#admin";
private const string NS_URI_OWNER = NS_URI + "#owner";
private const string NS_URI_USER = NS_URI + "#user";
+private const string NS_URI_REQUEST = NS_URI + "#request";
public enum MucEnterError {
NONE,
@@ -68,6 +69,7 @@ public class Module : XmppStreamModule {
public signal void received_occupant_role(XmppStream stream, Jid jid, Role? role);
public signal void subject_set(XmppStream stream, string? subject, Jid jid);
public signal void invite_received(XmppStream stream, Jid room_jid, Jid from_jid, string? password, string? reason);
+ public signal void voice_request_received(XmppStream stream, Jid room_jid, Jid from_jid, string? nick, string? role, string? label);
public signal void room_info_updated(XmppStream stream, Jid muc_jid);
public signal void self_removed_from_room(XmppStream stream, Jid jid, StatusCode code);
@@ -154,6 +156,25 @@ public class Module : XmppStreamModule {
stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, message);
}
+ public void request_voice(XmppStream stream, Jid to_muc) {
+ MessageStanza message = new MessageStanza() { to=to_muc };
+
+ DataForms.DataForm submit_node = new DataForms.DataForm();
+ submit_node.get_submit_node();
+
+ DataForms.DataForm.Field field_node = new DataForms.DataForm.Field() { var="FORM_TYPE" };
+ field_node.set_value_string(NS_URI_REQUEST);
+
+ DataForms.DataForm.ListSingleField single_field = new DataForms.DataForm.ListSingleField(new StanzaNode.build("field", DataForms.NS_URI)) { var="muc#role", label="Requested role", value="participant" };
+
+ submit_node.add_field(field_node);
+ submit_node.add_field(single_field);
+
+ message.stanza.put_node(submit_node.stanza_node);
+
+ stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, message);
+ }
+
public void kick(XmppStream stream, Jid jid, string nick) {
change_role(stream, jid, nick, "none");
}
@@ -530,6 +551,38 @@ public class ReceivedPipelineListener : StanzaListener<MessageStanza> {
}
}
}
+
+ StanzaNode? x_field_node = message.stanza.get_subnode("x", DataForms.NS_URI);
+ if (x_field_node != null){
+ Gee.List<StanzaNode>? fields = x_field_node.get_subnodes("field", DataForms.NS_URI);
+ Jid? from_jid = null;
+ string? nick = null;
+ string? role = null;
+ string? label = null;
+
+ if (fields.size!=0){
+ foreach (var field_node in fields){
+ string? var_ = field_node.get_attribute("var");
+ if (var_ == "muc#jid"){
+ StanzaNode? value_node = field_node.get_subnode("value", DataForms.NS_URI);
+ if (value_node != null) from_jid = new Jid(value_node.get_string_content());
+ }
+ else if (var_ == "muc#roomnick"){
+ StanzaNode? value_node = field_node.get_subnode("value", DataForms.NS_URI);
+ if (value_node != null) nick = value_node.get_string_content();
+ }
+ else if (var_ == "muc#role"){
+ StanzaNode? value_node = field_node.get_subnode("value", DataForms.NS_URI);
+ if (value_node != null) role = value_node.get_string_content();
+ }
+ else if (var_ == "muc#request_allow"){
+ label = field_node.get_attribute("label");
+ }
+ }
+ outer.voice_request_received(stream, message.from, from_jid, nick, role, label);
+ return true;
+ }
+ }
}
return false;
}