# HG changeset patch # User Matthew Wild # Date 1540907993 0 # Node ID b148dd7e78e337f43e67200ab7535bd9558dfebf # Parent dcf466e04f81aca82b2d2ba7a875cae68daf1e88# Parent 69e1838a01c60084b29300fbe33710fd7a6e0b19 Merge 0.11->trunk diff -r dcf466e04f81 -r b148dd7e78e3 CHANGES --- a/CHANGES Mon Oct 29 02:13:09 2018 +0100 +++ b/CHANGES Tue Oct 30 13:59:53 2018 +0000 @@ -22,6 +22,7 @@ - mod\_muc\_mam (XEP-0313 in groupchats) - mod\_vcard\_legacy (XEP-0398) - mod\_vcard4 (XEP-0292) +- mod\_csi, mod\_csi\_simple (XEP-0352) - New experimental network backend "epoll" 0.10.0 diff -r dcf466e04f81 -r b148dd7e78e3 plugins/mod_csi_simple.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/mod_csi_simple.lua Tue Oct 30 13:59:53 2018 +0000 @@ -0,0 +1,100 @@ +-- Copyright (C) 2016-2018 Kim Alvefur +-- +-- This project is MIT/X11 licensed. Please see the +-- COPYING file in the source package for more information. +-- + +module:depends"csi" + +local jid = require "util.jid"; +local st = require "util.stanza"; +local dt = require "util.datetime"; +local new_queue = require "util.queue".new; + +local function new_pump(output, ...) + -- luacheck: ignore 212/self + local q = new_queue(...); + local flush = true; + function q:pause() + flush = false; + end + function q:resume() + flush = true; + return q:flush(); + end + local push = q.push; + function q:push(item) + local ok = push(self, item); + if not ok then + q:flush(); + output(item, self); + elseif flush then + return q:flush(); + end + return true; + end + function q:flush() + local item = self:pop(); + while item do + output(item, self); + item = self:pop(); + end + return true; + end + return q; +end + +local queue_size = module:get_option_number("csi_queue_size", 256); + +module:hook("csi-is-stanza-important", function (event) + local stanza = event.stanza; + local st_name = stanza.name; + if not st_name then return false; end + local st_type = stanza.attr.type; + if st_name == "presence" then + if st_type == nil or st_type == "unavailable" then + return false; + end + return true; + elseif st_name == "message" then + if st_type == "headline" then + return false; + end + local body = stanza:get_child_text("body"); + return body; + end + return true; +end, -1); + +module:hook("csi-client-inactive", function (event) + local session = event.origin; + if session.pump then + session.pump:pause(); + else + local bare_jid = jid.join(session.username, session.host); + local send = session.send; + session._orig_send = send; + local pump = new_pump(session.send, queue_size); + pump:pause(); + session.pump = pump; + function session.send(stanza) + if module:fire_event("csi-stanza-is-important", { stanza = stanza, session = session }) then + pump:flush(); + send(stanza); + else + stanza = st.clone(stanza); + stanza:add_direct_child(st.stanza("delay", {xmlns = "urn:xmpp:delay", from = bare_jid, stamp = dt.datetime()})); + pump:push(stanza); + end + return true; + end + end +end); + +module:hook("csi-client-active", function (event) + local session = event.origin; + if session.pump then + session.pump:resume(); + end +end); + diff -r dcf466e04f81 -r b148dd7e78e3 prosody.cfg.lua.dist --- a/prosody.cfg.lua.dist Mon Oct 29 02:13:09 2018 +0100 +++ b/prosody.cfg.lua.dist Tue Oct 30 13:59:53 2018 +0000 @@ -46,10 +46,11 @@ -- Not essential, but recommended "carbons"; -- Keep multiple clients in sync - "pep"; -- Enables users to publish their mood, activity, playing music and more + "pep"; -- Enables users to publish their avatar, mood, activity, playing music and more "private"; -- Private XML storage (for room bookmarks, etc.) "blocklist"; -- Allow users to block communications with other users - "vcard"; -- Allow users to set vCards + "vcard4"; -- User profiles (stored in PEP) + "vcard_legacy"; -- Conversion between legacy vCard and PEP Avatar, vcard -- Nice to have "version"; -- Replies to server version requests @@ -58,6 +59,7 @@ "ping"; -- Replies to XMPP pings with pongs "register"; -- Allow users to register on this server using a client and change passwords --"mam"; -- Store messages in an archive and allow users to access it + --"csi_simple"; -- Simple Mobile optimizations -- Admin interfaces "admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands @@ -197,6 +199,8 @@ ---Set up a MUC (multi-user chat) room server on conference.example.com: --Component "conference.example.com" "muc" +--- Store MUC messages in an archive and allow users to access it +--modules_enabled = { "muc_mam" } ---Set up an external component (default component port is 5347) -- diff -r dcf466e04f81 -r b148dd7e78e3 spec/scansion/pep_publish_subscribe.scs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spec/scansion/pep_publish_subscribe.scs Tue Oct 30 13:59:53 2018 +0000 @@ -0,0 +1,210 @@ +# PEP publish, subscribe and publish-options + +[Client] Romeo + jid: pep-test-wjebo4kg@localhost + password: password + +[Client] Juliet + jid: pep-test-tqvqu_pv@localhost + password: password + +----- + +Romeo connects + +Romeo sends: + + + + +Romeo receives: + + + + +Romeo receives: + + + + +Romeo sends: + + + + +Romeo receives: + + + + +Juliet connects + +Juliet sends: + + + + +Juliet receives: + + + + +Juliet receives: + + + + +Juliet sends: + + + + +Juliet receives: + + + + +Romeo sends: + + +Romeo sends: + + +Romeo receives: + + +Romeo receives: + + +Juliet receives: + + +Juliet sends: + + +Juliet sends: + + +Juliet receives: + + +Juliet receives: + + +Romeo receives: + + +Romeo sends: + + +Romeo sends: + + +Romeo receives: + + +Juliet receives: + + +Juliet receives: + + +Juliet receives: + + +Juliet sends: + + +Juliet receives: + + +Juliet receives: + + +Romeo receives: + + +Romeo receives: + + +Romeo receives: + + +Juliet sends: + + +Romeo sends: + + +Romeo sends: + + +Romeo sends: + + +Romeo receives: + + +Romeo receives: + + +Romeo receives: + + +Juliet receives: + + +Romeo sends: + + +Romeo receives: + + +Romeo receives: + + +Romeo receives: + + +Romeo sends: + + +Romeo sends: + + +Romeo sends: + + +Juliet receives: + + +Juliet sends: + + +Juliet sends: + Beautiful CedarsThe SpinnersNot Quite Folk4 + +Juliet receives: + + +Juliet sends: + http://jabber.org/protocol/pubsub#publish-optionstruewhitelist + +Juliet receives: + + +Juliet sends: + + +Romeo receives: + Beautiful CedarsThe SpinnersNot Quite Folk4 + +Romeo sends: + + +Romeo receives: + Beautiful CedarsThe SpinnersNot Quite Folk4 + +Juliet disconnects + +Romeo disconnects