From a660f853c1962b03fb834383661f1b7fc8c408f7 Mon Sep 17 00:00:00 2001 From: thierrytiti Date: Wed, 20 May 2015 12:12:08 +0200 Subject: [PATCH] XEP-0352: Client State Indication XEP-0352 support added to Auto Away Mode --- converse.js | 20 +++++++++++++++++++- docs/CHANGES.rst | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/converse.js b/converse.js index 367b37a98..c816ca58b 100644 --- a/converse.js +++ b/converse.js @@ -354,17 +354,29 @@ // Module-level functions // ---------------------- - this.autoAwayReset=function(){ + this.autoAwayReset=function(){ if (converse._idleCounter > 0) { converse._idleCounter = 0; if (converse._autoAway>0) { converse._autoAway=0; + if (converse.HAS_CSI) { + converse.connection.send($build("active", {xmlns: 'urn:xmpp:csi:0'})); + } converse.xmppstatus.setStatus('online'); } } }; this.registerAutoAwayHandler = function (){ + + if (converse.auto_away>0 || converse.auto_xa>0){ + + if (converse.features.findWhere({'var': 'urn:xmpp:csi'})) { + // The server supports XEP-0352 Client State Indication + converse.HAS_CSI=true; + }else { + converse.HAS_CSI=false; + } if (converse.auto_xa>0 && converse.auto_xa0 && converse._autoAway!=1 && converse._idleCounter > converse.auto_away && converse._idleCounter <= converse.auto_xa){ + if (converse.HAS_CSI) { + converse.connection.send($build("inactive", {xmlns: 'urn:xmpp:csi:0'})); + } converse._autoAway=1; converse.xmppstatus.setStatus('away'); } else if (converse.auto_xa>0 && converse._autoAway!=2 && converse._idleCounter > converse.auto_xa){ + if (converse.HAS_CSI) { + converse.connection.send($build("inactive", {xmlns: 'urn:xmpp:csi:0'})); + } converse._autoAway=2; converse.xmppstatus.setStatus('xa'); } diff --git a/docs/CHANGES.rst b/docs/CHANGES.rst index 8c1154557..5b263e1ba 100644 --- a/docs/CHANGES.rst +++ b/docs/CHANGES.rst @@ -8,7 +8,7 @@ Changelog * Bugfix. Manual login doesn't work when only websocket_url is set and not bosh_service_url. [jcbrand] * Bugfix. clearSessions during unload event would throw an error when not logged in. [gbonvehi] * #389 Allow login panel placeholders and roster item 'Name' translations. [gbonvehi] -* Add automatic Away mode [thierrytiti] +* Add automatic Away mode and XEP-0352 support [thierrytiti] 0.9.3 (2015-05-01) ------------------