diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations/generator')
-rw-r--r-- | src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java | 6 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/generator/IqGenerator.java | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java index bdf26b082..4efec8c37 100644 --- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java @@ -42,6 +42,9 @@ public abstract class AbstractGenerator { private final String[] MESSAGE_CORRECTION_FEATURES = { "urn:xmpp:message-correct:0" }; + private final String[] PRIVACY_SENSITIVE = { + "urn:xmpp:time" //XEP-0202: Entity Time leaks time zone + }; private String mVersion = null; private String mVersionOs = null; @@ -109,6 +112,9 @@ public abstract class AbstractGenerator { if (Config.supportOmemo()) { features.add(AxolotlService.PEP_DEVICE_LIST_NOTIFY); } + if (!mXmppConnectionService.useTorToConnect()) { + features.addAll(Arrays.asList(PRIVACY_SENSITIVE)); + } Collections.sort(features); return features; } diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java index 16af338c6..6b7c3a02f 100644 --- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java @@ -15,6 +15,7 @@ import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.TimeZone; import eu.siacs.conversations.Config; import eu.siacs.conversations.crypto.axolotl.AxolotlService; @@ -62,6 +63,19 @@ public class IqGenerator extends AbstractGenerator { return packet; } + public IqPacket entityTimeResponse(IqPacket request) { + final IqPacket packet = request.generateResponse(IqPacket.TYPE.RESULT); + Element time = packet.addChild("time","urn:xmpp:time"); + final long now = System.currentTimeMillis(); + time.addChild("utc").setContent(getTimestamp(now)); + TimeZone ourTimezone = TimeZone.getDefault(); + long offsetSeconds = ourTimezone.getOffset(now) / 1000; + long offsetMinutes = offsetSeconds % (60 * 60); + long offsetHours = offsetSeconds / (60 * 60); + time.addChild("tzo").setContent(String.format("%02d",offsetHours)+":"+String.format("%02d",offsetMinutes)); + return packet; + } + protected IqPacket publish(final String node, final Element item) { final IqPacket packet = new IqPacket(IqPacket.TYPE.SET); final Element pubsub = packet.addChild("pubsub", |