5
0
mirror of https://github.com/cwinfo/envayasms.git synced 2024-12-04 12:35:32 +00:00

don't request delivery reports but leave option open in future; fix bug with encoding of apostrophe by php library

This commit is contained in:
Jesse Young 2011-09-27 20:23:36 -07:00
parent 03d5f556d7
commit faffc6c568
5 changed files with 28 additions and 16 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.envaya.sms"
android:versionCode="9"
android:versionName="2.0-beta7">
android:versionCode="10"
android:versionName="2.0-beta8">
<uses-sdk android:minSdkVersion="4" />

View File

@ -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 "<messages>";
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 "<sms$id$to>".EnvayaSMS::escape($message->message)."</sms>";
}
echo "</messages>";

View File

@ -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";

View File

@ -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);

View File

@ -16,11 +16,17 @@ public class OutgoingSmsReceiver extends BroadcastReceiver {
Bundle extras = intent.getExtras();
String to = extras.getString(App.OUTGOING_SMS_EXTRA_TO);
ArrayList<String> bodyParts = extras.getStringArrayList(App.OUTGOING_SMS_EXTRA_BODY);
boolean deliveryReport = extras.getBoolean(App.OUTGOING_SMS_EXTRA_DELIVERY_REPORT, false);
SmsManager smgr = SmsManager.getDefault();
ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveryIntents = null;
if (deliveryReport)
{
deliveryIntents = new ArrayList<PendingIntent>();
}
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);