5
0
mirror of https://github.com/cwinfo/envayasms.git synced 2024-11-12 19:30:26 +00:00
envayasms/src/org/envaya/kalsms/IncomingMessage.java

62 lines
1.6 KiB
Java
Raw Normal View History

2011-09-13 21:55:26 +00:00
package org.envaya.kalsms;
import android.content.Intent;
import android.net.Uri;
import android.telephony.SmsMessage;
import org.apache.http.message.BasicNameValuePair;
public class IncomingMessage extends QueuedMessage {
public String from;
public String message;
public long timestampMillis;
2011-09-13 21:55:26 +00:00
public IncomingMessage(App app, SmsMessage sms) {
super(app);
this.from = sms.getOriginatingAddress();
this.message = sms.getMessageBody();
this.timestampMillis = sms.getTimestampMillis();
2011-09-13 21:55:26 +00:00
}
public IncomingMessage(App app, String from, String message, long timestampMillis) {
super(app);
this.from = from;
this.message = message;
this.timestampMillis = timestampMillis;
}
2011-09-13 21:55:26 +00:00
public String getMessageBody()
{
return message;
2011-09-13 21:55:26 +00:00
}
public String getFrom()
{
return from;
2011-09-13 21:55:26 +00:00
}
public String getId()
{
return from + ":" + message + ":" + timestampMillis;
2011-09-13 21:55:26 +00:00
}
public void retryNow() {
app.log("Retrying forwarding SMS from " + from);
2011-09-13 21:55:26 +00:00
tryForwardToServer();
}
public void tryForwardToServer() {
new ForwarderTask(this,
new BasicNameValuePair("from", getFrom()),
new BasicNameValuePair("message", getMessageBody())
).execute();
}
protected Intent getRetryIntent() {
Intent intent = new Intent(app.context, IncomingMessageRetry.class);
intent.setData(Uri.parse("kalsms://incoming/" + this.getId()));
return intent;
}
}