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 {
|
|
|
|
|
2011-09-14 01:26:17 +00:00
|
|
|
public String from;
|
|
|
|
public String message;
|
2011-09-14 19:26:14 +00:00
|
|
|
public long timestampMillis;
|
2011-09-13 21:55:26 +00:00
|
|
|
|
|
|
|
public IncomingMessage(App app, SmsMessage sms) {
|
|
|
|
super(app);
|
2011-09-14 01:26:17 +00:00
|
|
|
this.from = sms.getOriginatingAddress();
|
|
|
|
this.message = sms.getMessageBody();
|
|
|
|
this.timestampMillis = sms.getTimestampMillis();
|
2011-09-13 21:55:26 +00:00
|
|
|
}
|
2011-09-14 01:26:17 +00:00
|
|
|
|
2011-09-14 19:26:14 +00:00
|
|
|
public IncomingMessage(App app, String from, String message, long timestampMillis) {
|
2011-09-14 01:26:17 +00:00
|
|
|
super(app);
|
|
|
|
this.from = from;
|
|
|
|
this.message = message;
|
2011-09-14 19:26:14 +00:00
|
|
|
this.timestampMillis = timestampMillis;
|
2011-09-14 01:26:17 +00:00
|
|
|
}
|
2011-09-13 21:55:26 +00:00
|
|
|
|
|
|
|
public String getMessageBody()
|
|
|
|
{
|
2011-09-14 01:26:17 +00:00
|
|
|
return message;
|
2011-09-13 21:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getFrom()
|
|
|
|
{
|
2011-09-14 01:26:17 +00:00
|
|
|
return from;
|
2011-09-13 21:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getId()
|
|
|
|
{
|
2011-09-14 01:26:17 +00:00
|
|
|
return from + ":" + message + ":" + timestampMillis;
|
2011-09-13 21:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void retryNow() {
|
2011-09-14 01:26:17 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|