aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-06-11 13:59:24 +0200
committerfiaxh <git@mx.ax.lt>2017-06-11 13:59:24 +0200
commite63d59eb3450471b33a22efda6df8871818209b1 (patch)
tree11660e951bf049318f6c0eae8a60fcfbff4c029e /xmpp-vala/src/module/xep
parent205bd444a5ba9d119952ecddbf815f50174da8c7 (diff)
downloaddino-e63d59eb3450471b33a22efda6df8871818209b1.tar.gz
dino-e63d59eb3450471b33a22efda6df8871818209b1.zip
Muc Invite + Kick
Diffstat (limited to 'xmpp-vala/src/module/xep')
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/module.vala27
-rw-r--r--xmpp-vala/src/module/xep/0049_private_xml_storage.vala4
-rw-r--r--xmpp-vala/src/module/xep/0060_pubsub.vala2
-rw-r--r--xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala20
-rw-r--r--xmpp-vala/src/module/xep/0280_message_carbons.vala1
-rw-r--r--xmpp-vala/src/module/xep/0333_chat_markers.vala4
6 files changed, 41 insertions, 17 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 };
diff --git a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
index b843f63b..fc8f5b4c 100644
--- a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
+++ b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
@@ -35,12 +35,12 @@ namespace Xmpp.Xep.PrivateXmlStorage {
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- private static void on_store_response(XmppStream stream, Iq.Stanza iq, Object o) {
+ private static void on_store_response(XmppStream stream, Iq.Stanza iq, Object? o) {
Tuple<OnSuccess, Object> tuple = o as Tuple<OnSuccess, Object>;
tuple.a(stream, tuple.b);
}
- private static void on_retrieve_response(XmppStream stream, Iq.Stanza iq, Object o) {
+ private static void on_retrieve_response(XmppStream stream, Iq.Stanza iq, Object? o) {
Tuple<OnResponse, Object> tuple = o as Tuple<OnResponse, Object>;
tuple.a(stream, iq.stanza.get_subnode("query", NS_URI), tuple.b);
}
diff --git a/xmpp-vala/src/module/xep/0060_pubsub.vala b/xmpp-vala/src/module/xep/0060_pubsub.vala
index 84b7fe9a..8ba66995 100644
--- a/xmpp-vala/src/module/xep/0060_pubsub.vala
+++ b/xmpp-vala/src/module/xep/0060_pubsub.vala
@@ -63,7 +63,7 @@ namespace Xmpp.Xep.Pubsub {
}
}
- private static void on_received_request_response(XmppStream stream, Iq.Stanza iq, Object o) {
+ private static void on_received_request_response(XmppStream stream, Iq.Stanza iq, Object? o) {
Tuple<OnResult, Object?> tuple = o as Tuple<OnResult, Object?>;
OnResult on_result = tuple.a;
StanzaNode event_node = iq.stanza.get_subnode("pubsub", NS_URI);
diff --git a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
index 80eea852..423bc3fe 100644
--- a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
+++ b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
@@ -8,6 +8,17 @@ namespace Xmpp.Xep.MessageDeliveryReceipts {
public signal void receipt_received(XmppStream stream, string jid, string id);
+ public void send_received(XmppStream stream, string from, string message_id) {
+ Message.Stanza received_message = new Message.Stanza();
+ received_message.to = from;
+ received_message.stanza.put_node(new StanzaNode.build("received", NS_URI).add_self_xmlns().put_attribute("id", message_id));
+ stream.get_module(Message.Module.IDENTITY).send_message(stream, received_message);
+ }
+
+ public static bool requests_receipt(Message.Stanza message) {
+ return message.stanza.get_subnode("request", NS_URI) != null;
+ }
+
public override void attach(XmppStream stream) {
ServiceDiscovery.Module.require(stream);
Message.Module.require(stream);
@@ -33,18 +44,9 @@ namespace Xmpp.Xep.MessageDeliveryReceipts {
StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI);
if (received_node != null) {
receipt_received(stream, message.from, received_node.get_attribute("id", NS_URI));
- } else if (message.stanza.get_subnode("request", NS_URI) != null) {
- send_received(stream, message);
}
}
- private void send_received(XmppStream stream, Message.Stanza message) {
- Message.Stanza received_message = new Message.Stanza();
- received_message.to = message.from;
- received_message.stanza.put_node(new StanzaNode.build("received", NS_URI).add_self_xmlns().put_attribute("id", message.id));
- stream.get_module(Message.Module.IDENTITY).send_message(stream, received_message);
- }
-
private void pre_send_message(XmppStream stream, Message.Stanza message) {
StanzaNode? received_node = message.stanza.get_subnode("received", NS_URI);
if (received_node != null) return;
diff --git a/xmpp-vala/src/module/xep/0280_message_carbons.vala b/xmpp-vala/src/module/xep/0280_message_carbons.vala
index 58805a96..318e4421 100644
--- a/xmpp-vala/src/module/xep/0280_message_carbons.vala
+++ b/xmpp-vala/src/module/xep/0280_message_carbons.vala
@@ -48,7 +48,6 @@ namespace Xmpp.Xep.MessageCarbons {
if (forwarded_node != null) {
StanzaNode? message_node = forwarded_node.get_subnode("message", Message.NS_URI);
string? from_attribute = message_node.get_attribute("from", Message.NS_URI);
- // The security model assumed by this document is that all of the resources for a single user are in the same trust boundary.
// Any forwarded copies received by a Carbons-enabled client MUST be from that user's bare JID; any copies that do not meet this requirement MUST be ignored.
if (from_attribute != null && from_attribute == get_bare_jid(stream.get_flag(Bind.Flag.IDENTITY).my_jid)) {
if (received_node != null) {
diff --git a/xmpp-vala/src/module/xep/0333_chat_markers.vala b/xmpp-vala/src/module/xep/0333_chat_markers.vala
index e6bab2c6..11817a22 100644
--- a/xmpp-vala/src/module/xep/0333_chat_markers.vala
+++ b/xmpp-vala/src/module/xep/0333_chat_markers.vala
@@ -53,10 +53,6 @@ public class Module : XmppStreamModule {
private void on_received_message(XmppStream stream, Message.Stanza message) {
if (message.type_ != Message.Stanza.TYPE_CHAT) return;
- if (requests_marking(message)) {
- send_marker(stream, message.from, message.id, message.type_, MARKER_RECEIVED);
- return;
- }
Gee.List<StanzaNode> nodes = message.stanza.get_all_subnodes();
foreach (StanzaNode node in nodes) {
if (node.ns_uri == NS_URI && node.name in MARKERS) {