From 1006276e3c78c2098d8efd5dedff0ee87e0e006f Mon Sep 17 00:00:00 2001 From: Gurmeen Bindra Date: Wed, 26 Jun 2013 14:12:27 +0100 Subject: Change the data type of seconds in IQ:last from int to Long Making it Long allows it to hold an XML-unsignedLong value as well as null values. Before this patch, it was an int and defaulted to 0. This was not right as int is too small to hold number of seconds for last activity time and primitive data types do not allow for null values. Test-information: tested using an XMPP client to query last IQ on MUC rooms Change-Id: I6274403610bd60038fd7c235fad3bc2798f38e19 Reviewer: Kevin Smith diff --git a/src/com/isode/stroke/elements/Last.java b/src/com/isode/stroke/elements/Last.java index 8f12616..b2b2805 100644 --- a/src/com/isode/stroke/elements/Last.java +++ b/src/com/isode/stroke/elements/Last.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Isode Limited, London, England. + * Copyright (c) 2011-2013, Isode Limited, London, England. * All rights reserved. */ /* @@ -10,19 +10,19 @@ package com.isode.stroke.elements; public class Last extends Payload { - int seconds_; + Long seconds_; public Last() {} - public Last(final int seconds) { + public Last(final Long seconds) { setSeconds(seconds); } - public void setSeconds(final int seconds) { + public void setSeconds(final Long seconds) { seconds_ = seconds; } - public int getSeconds() { + public Long getSeconds() { return seconds_; } } diff --git a/src/com/isode/stroke/parser/payloadparsers/LastParser.java b/src/com/isode/stroke/parser/payloadparsers/LastParser.java index d2c2a82..62a7636 100644 --- a/src/com/isode/stroke/parser/payloadparsers/LastParser.java +++ b/src/com/isode/stroke/parser/payloadparsers/LastParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Isode Limited, London, England. + * Copyright (c) 2011-2013, Isode Limited, London, England. * All rights reserved. */ /* @@ -23,10 +23,10 @@ public class LastParser extends GenericPayloadParser { public void handleStartElement(String element, String ns, AttributeMap attributes) { if (level_ == 0) { - int seconds = 0; + Long seconds = null; try { - seconds = Integer.parseInt(attributes.getAttribute("seconds")); + seconds = Long.parseLong(attributes.getAttribute("seconds")); } catch (NumberFormatException ex) { } diff --git a/src/com/isode/stroke/serializer/payloadserializers/LastSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/LastSerializer.java index e78a724..8eff41a 100644 --- a/src/com/isode/stroke/serializer/payloadserializers/LastSerializer.java +++ b/src/com/isode/stroke/serializer/payloadserializers/LastSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Isode Limited, London, England. + * Copyright (c) 2011-2013 Isode Limited, London, England. * All rights reserved. */ /* @@ -19,6 +19,9 @@ public class LastSerializer extends GenericPayloadSerializer { @Override protected String serializePayload(Last last) { - return ""; + if(last.getSeconds() == null) { + return ""; + } + return ""; } } -- cgit v0.10.2-6-g49f6