From faffc6c568f00097c4e508d9bb85b4be171fdeca Mon Sep 17 00:00:00 2001 From: Jesse Young Date: Tue, 27 Sep 2011 20:23:36 -0700 Subject: [PATCH] don't request delivery reports but leave option open in future; fix bug with encoding of apostrophe by php library --- AndroidManifest.xml | 4 +-- server/php/EnvayaSMS.php | 6 ++-- src/org/envaya/sms/App.java | 3 +- src/org/envaya/sms/OutgoingMessage.java | 2 ++ .../sms/receiver/OutgoingSmsReceiver.java | 29 ++++++++++++------- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e4bb042..024db0f 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="10" + android:versionName="2.0-beta8"> diff --git a/server/php/EnvayaSMS.php b/server/php/EnvayaSMS.php index 301d484..921a501 100755 --- a/server/php/EnvayaSMS.php +++ b/server/php/EnvayaSMS.php @@ -22,7 +22,7 @@ class EnvayaSMS static function escape($val) { - return htmlspecialchars($val, ENT_QUOTES, 'UTF-8'); + return htmlspecialchars($val, ENT_COMPAT | ENT_XML1, 'UTF-8'); } private static $request; @@ -123,8 +123,8 @@ class EnvayaSMS_Request echo ""; foreach ($messages as $message) { - $id = isset($message->id) ? " id='".EnvayaSMS::escape($message->id)."'" : ""; - $to = isset($message->to) ? " to='".EnvayaSMS::escape($message->to)."'" : ""; + $id = isset($message->id) ? " id=\"".EnvayaSMS::escape($message->id)."\"" : ""; + $to = isset($message->to) ? " to=\"".EnvayaSMS::escape($message->to)."\"" : ""; echo "".EnvayaSMS::escape($message->message).""; } echo ""; diff --git a/src/org/envaya/sms/App.java b/src/org/envaya/sms/App.java index e9aa26a..7e73254 100755 --- a/src/org/envaya/sms/App.java +++ b/src/org/envaya/sms/App.java @@ -68,12 +68,13 @@ public final class App extends Application { public static final String OUTGOING_SMS_INTENT_SUFFIX = ".OUTGOING_SMS"; public static final String OUTGOING_SMS_EXTRA_TO = "to"; public static final String OUTGOING_SMS_EXTRA_BODY = "body"; + public static final String OUTGOING_SMS_EXTRA_DELIVERY_REPORT = "delivery"; public static final int OUTGOING_SMS_UNHANDLED = Activity.RESULT_FIRST_USER; // intent for MessageStatusNotifier to receive status updates for outgoing SMS // (even if sent by an expansion pack) public static final String MESSAGE_STATUS_INTENT = "org.envaya.sms.MESSAGE_STATUS"; - public static final String MESSAGE_DELIVERY_INTENT = "org.envaya.sms.MESSAGE_DELIVERY"; + public static final String MESSAGE_DELIVERY_INTENT = "org.envaya.sms.MESSAGE_DELIVERY"; public static final String STATUS_EXTRA_INDEX = "status"; public static final String STATUS_EXTRA_NUM_PARTS = "num_parts"; diff --git a/src/org/envaya/sms/OutgoingMessage.java b/src/org/envaya/sms/OutgoingMessage.java index 5ad7468..1d014f7 100755 --- a/src/org/envaya/sms/OutgoingMessage.java +++ b/src/org/envaya/sms/OutgoingMessage.java @@ -4,6 +4,7 @@ package org.envaya.sms; import org.envaya.sms.receiver.OutgoingMessageRetry; import android.content.Intent; import android.net.Uri; +import android.os.Bundle; import android.telephony.SmsManager; import java.util.ArrayList; @@ -105,6 +106,7 @@ public class OutgoingMessage extends QueuedMessage { } Intent intent = new Intent(packageName + App.OUTGOING_SMS_INTENT_SUFFIX, this.getUri()); + intent.putExtra(App.OUTGOING_SMS_EXTRA_DELIVERY_REPORT, false); intent.putExtra(App.OUTGOING_SMS_EXTRA_TO, getTo()); intent.putExtra(App.OUTGOING_SMS_EXTRA_BODY, bodyParts); diff --git a/src/org/envaya/sms/receiver/OutgoingSmsReceiver.java b/src/org/envaya/sms/receiver/OutgoingSmsReceiver.java index 873e8cf..25b04a2 100755 --- a/src/org/envaya/sms/receiver/OutgoingSmsReceiver.java +++ b/src/org/envaya/sms/receiver/OutgoingSmsReceiver.java @@ -16,11 +16,17 @@ public class OutgoingSmsReceiver extends BroadcastReceiver { Bundle extras = intent.getExtras(); String to = extras.getString(App.OUTGOING_SMS_EXTRA_TO); ArrayList bodyParts = extras.getStringArrayList(App.OUTGOING_SMS_EXTRA_BODY); + boolean deliveryReport = extras.getBoolean(App.OUTGOING_SMS_EXTRA_DELIVERY_REPORT, false); SmsManager smgr = SmsManager.getDefault(); ArrayList sentIntents = new ArrayList(); - ArrayList deliveryIntents = new ArrayList(); + ArrayList deliveryIntents = null; + + if (deliveryReport) + { + deliveryIntents = new ArrayList(); + } int numParts = bodyParts.size(); @@ -36,15 +42,18 @@ public class OutgoingSmsReceiver extends BroadcastReceiver { statusIntent, PendingIntent.FLAG_ONE_SHOT)); - Intent deliveryIntent = new Intent(App.MESSAGE_DELIVERY_INTENT, intent.getData()); - deliveryIntent.putExtra(App.STATUS_EXTRA_INDEX, i); - deliveryIntent.putExtra(App.STATUS_EXTRA_NUM_PARTS, numParts); - - deliveryIntents.add(PendingIntent.getBroadcast( - context, - 0, - deliveryIntent, - PendingIntent.FLAG_ONE_SHOT)); + if (deliveryReport) + { + Intent deliveryIntent = new Intent(App.MESSAGE_DELIVERY_INTENT, intent.getData()); + deliveryIntent.putExtra(App.STATUS_EXTRA_INDEX, i); + deliveryIntent.putExtra(App.STATUS_EXTRA_NUM_PARTS, numParts); + + deliveryIntents.add(PendingIntent.getBroadcast( + context, + 0, + deliveryIntent, + PendingIntent.FLAG_ONE_SHOT)); + } } smgr.sendMultipartTextMessage(to, null, bodyParts, sentIntents, deliveryIntents);