summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorGurmeen Bindra <gurmeen.bindra@isode.com>2013-06-26 13:12:27 (GMT)
committerGurmeen Bindra <gurmeen.bindra@isode.com>2013-06-27 13:27:43 (GMT)
commit1006276e3c78c2098d8efd5dedff0ee87e0e006f (patch)
treeb3ad876f3d5bd815f45e3263f3011aede8ee3767 /src/com
parent7d7ecdbb01daa051472bf40e269b78c4faf7b34e (diff)
downloadstroke-1006276e3c78c2098d8efd5dedff0ee87e0e006f.zip
stroke-1006276e3c78c2098d8efd5dedff0ee87e0e006f.tar.bz2
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 <kevin.smith@isode.com>
Diffstat (limited to 'src/com')
-rw-r--r--src/com/isode/stroke/elements/Last.java10
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/LastParser.java6
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/LastSerializer.java7
3 files changed, 13 insertions, 10 deletions
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<Last> {
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<Last> {
@Override
protected String serializePayload(Last last) {
- return "<query xmlns='jabber:iq:last' seconds='" + Integer.toString(last.getSeconds()) + "'/>";
+ if(last.getSeconds() == null) {
+ return "<query xmlns='jabber:iq:last'/>";
+ }
+ return "<query xmlns='jabber:iq:last' seconds='" + Long.toString(last.getSeconds()) + "'/>";
}
}