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

51 lines
1.2 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;
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-18 01:38:16 +00:00
public IncomingMessage(App app, String from)
{
super(app);
this.from = from;
2011-09-18 01:38:16 +00:00
}
public abstract String getDisplayType();
public boolean isForwardable()
{
if (app.isTestMode() && !app.isTestPhoneNumber(from))
{
return false;
}
/*
* 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()
{
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() {
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
}