2011-09-13 21:55:26 +00:00
|
|
|
package org.envaya.kalsms;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.net.Uri;
|
2011-09-18 01:38:16 +00:00
|
|
|
import org.envaya.kalsms.receiver.IncomingMessageRetry;
|
2011-09-13 21:55:26 +00:00
|
|
|
|
2011-09-18 01:38:16 +00:00
|
|
|
public abstract class IncomingMessage extends QueuedMessage {
|
2011-09-13 21:55:26 +00:00
|
|
|
|
2011-09-18 01:38:16 +00:00
|
|
|
protected String from;
|
2011-09-14 01:26:17 +00:00
|
|
|
|
2011-09-18 01:38:16 +00:00
|
|
|
public IncomingMessage(App app, String from)
|
|
|
|
{
|
2011-09-14 01:26:17 +00:00
|
|
|
super(app);
|
|
|
|
this.from = from;
|
2011-09-18 01:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public abstract String getDisplayType();
|
|
|
|
|
2011-09-15 22:45:44 +00:00
|
|
|
public boolean isForwardable()
|
|
|
|
{
|
2011-09-19 21:58:23 +00:00
|
|
|
if (app.isTestMode() && !app.isTestPhoneNumber(from))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-15 22:45:44 +00:00
|
|
|
/*
|
|
|
|
* don't forward messages from shortcodes
|
|
|
|
* because they're likely to be spam or messages from network
|
|
|
|
*/
|
|
|
|
return from.length() > 5;
|
|
|
|
}
|
|
|
|
|
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 void retryNow() {
|
2011-09-18 01:38:16 +00:00
|
|
|
app.log("Retrying forwarding message from " + from);
|
2011-09-13 21:55:26 +00:00
|
|
|
tryForwardToServer();
|
2011-09-18 01:38:16 +00:00
|
|
|
}
|
|
|
|
|
2011-09-13 21:55:26 +00:00
|
|
|
protected Intent getRetryIntent() {
|
2011-09-15 22:45:44 +00:00
|
|
|
Intent intent = new Intent(app, IncomingMessageRetry.class);
|
2011-09-18 01:38:16 +00:00
|
|
|
intent.setData(this.getUri());
|
2011-09-13 21:55:26 +00:00
|
|
|
return intent;
|
2011-09-18 01:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void tryForwardToServer();
|
2011-09-13 21:55:26 +00:00
|
|
|
}
|