5
0
mirror of https://github.com/cwinfo/envayasms.git synced 2024-11-09 10:20:25 +00:00

use string status codes instead of integers

This commit is contained in:
Jesse Young 2011-09-12 17:37:37 -07:00
parent cb8d95ebd5
commit aff22e51d8
4 changed files with 31 additions and 20 deletions

View File

@ -13,9 +13,9 @@ class KalSMS
const ACTION_SEND_STATUS = 'send_status';
const ACTION_TEST = 'test';
const STATUS_QUEUED = 1;
const STATUS_FAILED = 2;
const STATUS_SENT = 3;
const STATUS_QUEUED = 'queued';
const STATUS_FAILED = 'failed';
const STATUS_SENT = 'sent';
static function new_from_request()
{
@ -29,7 +29,18 @@ class KalSMS
return htmlspecialchars($val, ENT_QUOTES, 'UTF-8');
}
private $request_action;
function get_request_action()
{
if (!$this->request_action)
{
$this->request_action = $this->_get_request_action();
}
return $this->request_action;
}
private function _get_request_action()
{
switch (@$_POST['action'])
{
@ -171,7 +182,7 @@ class KalSMS_Action_SendStatus extends KalSMS_Action
function __construct($type)
{
$this->type = KalSMS::ACTION_SEND_STATUS;
$this->status = (int)$_POST['status'];
$this->status = $_POST['status'];
$this->id = $_POST['id'];
}
}

View File

@ -0,0 +1 @@
*.json

View File

@ -31,9 +31,9 @@ public class App {
public static final String ACTION_SEND_STATUS = "send_status";
public static final String ACTION_TEST = "test";
public static final int STATUS_QUEUED = 1;
public static final int STATUS_FAILED = 2;
public static final int STATUS_SENT = 3;
public static final String STATUS_QUEUED = "queued";
public static final String STATUS_FAILED = "failed";
public static final String STATUS_SENT = "sent";
public static final String LOG_NAME = "KALSMS";
public static final String LOG_INTENT = "org.envaya.kalsms.LOG";

View File

@ -15,20 +15,20 @@ public class MessageStatusNotifier extends BroadcastReceiver {
private App app;
public void notifyStatus(String serverId, int status, String errorMessage)
public void notifyStatus(String serverId, String status, String errorMessage)
{
String logMessage;
switch (status)
if (status.equals(App.STATUS_SENT))
{
case App.STATUS_SENT:
logMessage = "sent successfully";
break;
case App.STATUS_FAILED:
}
else if (status.equals(App.STATUS_FAILED))
{
logMessage = "could not be sent (" + errorMessage + ")";
break;
default:
}
else
{
logMessage = "queued";
break;
}
String smsDesc = serverId == null ? "SMS reply" : ("SMS id=" + serverId);
@ -37,9 +37,8 @@ public class MessageStatusNotifier extends BroadcastReceiver {
app.log("Notifying server " + smsDesc + " " + logMessage);
new HttpTask(app).execute(
new BasicNameValuePair("from", app.getPhoneNumber()),
new BasicNameValuePair("id", serverId),
new BasicNameValuePair("status", "" + status),
new BasicNameValuePair("status", status),
new BasicNameValuePair("error", errorMessage),
new BasicNameValuePair("action", App.ACTION_SEND_STATUS)
);