diff options
author | fiaxh <git@mx.ax.lt> | 2017-06-11 13:59:24 +0200 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-06-11 13:59:24 +0200 |
commit | e63d59eb3450471b33a22efda6df8871818209b1 (patch) | |
tree | 11660e951bf049318f6c0eae8a60fcfbff4c029e /xmpp-vala/src/module/xep/0045_muc | |
parent | 205bd444a5ba9d119952ecddbf815f50174da8c7 (diff) | |
download | dino-e63d59eb3450471b33a22efda6df8871818209b1.tar.gz dino-e63d59eb3450471b33a22efda6df8871818209b1.zip |
Muc Invite + Kick
Diffstat (limited to 'xmpp-vala/src/module/xep/0045_muc')
-rw-r--r-- | xmpp-vala/src/module/xep/0045_muc/module.vala | 27 |
1 files changed, 27 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 c098fd14..f649fdbe 100644 --- a/xmpp-vala/src/module/xep/0045_muc/module.vala +++ b/xmpp-vala/src/module/xep/0045_muc/module.vala @@ -103,10 +103,37 @@ public class Module : XmppStreamModule { stream.get_module(Presence.Module.IDENTITY).send_presence(stream, presence); } + public void invite(XmppStream stream, string to_muc, string jid) { + Message.Stanza message = new Message.Stanza(); + message.to = to_muc; + StanzaNode invite_node = new StanzaNode.build("x", NS_URI_USER).add_self_xmlns() + .put_node(new StanzaNode.build("invite", NS_URI_USER).put_attribute("to", jid)); + message.stanza.put_node(invite_node); + stream.get_module(Message.Module.IDENTITY).send_message(stream, message); + } + public void kick(XmppStream stream, string jid, string nick) { change_role(stream, jid, nick, "none"); } + /* XEP 0046: "A user cannot be kicked by a moderator with a lower affiliation." (XEP 0045 8.2) */ + public bool kick_possible(XmppStream stream, string occupant) { + string muc_jid = get_bare_jid(occupant); + Flag flag = stream.get_flag(Flag.IDENTITY); + string own_nick = flag.get_muc_nick(muc_jid); + Affiliation my_affiliation = flag.get_affiliation(muc_jid, muc_jid + "/" + own_nick); + Affiliation other_affiliation = flag.get_affiliation(muc_jid, occupant); + switch (my_affiliation) { + case Affiliation.MEMBER: + if (other_affiliation == Affiliation.ADMIN || other_affiliation == Affiliation.OWNER) return false; + break; + case Affiliation.ADMIN: + if (other_affiliation == Affiliation.OWNER) return false; + break; + } + return true; + } + [CCode (has_target = false)] public delegate void OnConfigFormResult(XmppStream stream, string jid, DataForms.DataForm data_form, Object? store); public void get_config_form(XmppStream stream, string jid, OnConfigFormResult listener, Object? store) { Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_OWNER).add_self_xmlns()) { to=jid }; |