--- a/src/com/beem/project/beem/service/Message.java Fri May 07 18:16:41 2010 +0200
+++ b/src/com/beem/project/beem/service/Message.java Thu May 13 23:02:52 2010 +0200
@@ -44,9 +44,12 @@
package com.beem.project.beem.service;
import org.jivesoftware.smack.packet.XMPPError;
+import org.jivesoftware.smackx.packet.DelayInformation;
+import org.jivesoftware.smack.packet.PacketExtension;
import android.os.Parcel;
import android.os.Parcelable;
+import java.util.Date;
/**
* This class represents a instant message.
@@ -86,6 +89,7 @@
private String mTo;
private String mFrom;
private String mThread;
+ private Date mTimestamp;
// TODO ajouter l'erreur
@@ -101,6 +105,7 @@
mSubject = "";
mThread = "";
mFrom = null;
+ mTimestamp = new Date();
}
/**
@@ -151,6 +156,12 @@
mSubject = smackMsg.getSubject();
mThread = smackMsg.getThread();
}
+ PacketExtension pTime = smackMsg.getExtension("delay", "urn:xmpp:delay");
+ if (pTime instanceof DelayInformation) {
+ mTimestamp = ((DelayInformation) pTime).getStamp();
+ } else {
+ mTimestamp = new Date();
+ }
}
/**
@@ -164,6 +175,7 @@
mSubject = in.readString();
mThread = in.readString();
mFrom = in.readString();
+ mTimestamp = new Date(in.readLong());
}
/**
@@ -178,6 +190,7 @@
dest.writeString(mSubject);
dest.writeString(mThread);
dest.writeString(mFrom);
+ dest.writeLong(mTimestamp.getTime());
}
/**
@@ -277,6 +290,24 @@
}
/**
+ * Set the Date of the message.
+ *
+ * @param date date of the message.
+ */
+ public void setTimestamp(Date date) {
+ mTimestamp = date;
+ }
+
+ /**
+ * Get the Date of the message.
+ *
+ * @return if it is a delayed message get the date the message was sended.
+ */
+ public Date getTimestamp() {
+ return mTimestamp;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override