From e834488d2996b718884a5fda6ed4fac6a4903689 Mon Sep 17 00:00:00 2001 From: Jesse Young Date: Sun, 18 Sep 2011 15:29:30 -0700 Subject: [PATCH] avoid exceeding Android limit of 100 outgoing SMS/app/hour; allow effectively increasing limit via expansion packs; revert Sms -> sms in XML response --- AndroidManifest.xml | 30 ++- CONTRIBUTORS | 5 + LICENSE.txt => LICENSE | 26 ++- NOTICE | 189 ++++++++++++++++++ README.txt => README | 5 +- index.html | 77 ------- server/php/KalSMS.php | 14 +- src/org/envaya/kalsms/App.java | 142 ++++++++++++- src/org/envaya/kalsms/MmsObserver.java | 1 - src/org/envaya/kalsms/OutgoingMessage.java | 31 +-- .../ExpansionPackInstallReceiver.java | 22 ++ .../kalsms/receiver/OutgoingSmsReceiver.java | 31 +++ src/org/envaya/kalsms/task/HttpTask.java | 2 +- src/org/envaya/kalsms/ui/Help.java | 19 +- 14 files changed, 461 insertions(+), 133 deletions(-) create mode 100755 CONTRIBUTORS rename LICENSE.txt => LICENSE (54%) create mode 100755 NOTICE rename README.txt => README (98%) delete mode 100644 index.html create mode 100755 src/org/envaya/kalsms/receiver/ExpansionPackInstallReceiver.java create mode 100755 src/org/envaya/kalsms/receiver/OutgoingSmsReceiver.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 246e776..eee08d6 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -4,9 +4,10 @@ android:versionCode="1" android:versionName="1.0"> + + - @@ -39,7 +40,18 @@ - + + + + + + + + + + + + @@ -49,15 +61,25 @@ - + + + + + + + + + + - + + \ No newline at end of file diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100755 index 0000000..71f9cc1 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1,5 @@ +Current Maintainer: + Jesse Young + +Initial Developer: + Nir Yariv diff --git a/LICENSE.txt b/LICENSE similarity index 54% rename from LICENSE.txt rename to LICENSE index 4e7eef4..699688d 100644 --- a/LICENSE.txt +++ b/LICENSE @@ -1,4 +1,10 @@ -Copyright (C) 2011 by Nir Yariv + +Except for the parts noted otherwise (see Third-Party Libraries section below), +KalSMS' source code is licensed under the MIT license: + +----- + +Copyright (C) 2011 by Nir Yariv, Jesse Young Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -17,3 +23,21 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +===================== +Third-Party Libraries +===================== + +libs/httpmime-4.1.2.jar is (c) Apache Software Foundation + released under Apache License, Version 2.0 + +org.envaya.kalsms.Base64Coder is (c) 2003-2010 Christian d'Heureuse, + released under MIT License (and others) + +org.envaya.kalsms.ui.InertCheckBox and org.envaya.kalsms.ui.CheckableRelativeLayout + is (c) Cédric Caron, released presumably into the public domain at + http://www.marvinlabs.com/2010/10/custom-listview-ability-check-items/ + +org.envaya.kalsms.App.chooseOutgoingSmsPackage includes code from Android, + Copyright 2005-2008 The Android Open Source Project + See NOTICE \ No newline at end of file diff --git a/NOTICE b/NOTICE new file mode 100755 index 0000000..c07a95d --- /dev/null +++ b/NOTICE @@ -0,0 +1,189 @@ + ========================================================================= + == NOTICE file corresponding to the section 4 d of == + == the Apache License, Version 2.0, == + == in this case for the Android-specific code. == + ========================================================================= + +This product includes software developed as part of +The Android Open Source Project (http://source.android.com). + + ============================= + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + \ No newline at end of file diff --git a/README.txt b/README similarity index 98% rename from README.txt rename to README index f5db992..5ca599d 100755 --- a/README.txt +++ b/README @@ -13,7 +13,7 @@ Contents About KalSMS ============ -KalSMS is an Android app that acts as a SMS/MMS gateway. +KalSMS is an Android app that acts as a SMS and MMS gateway. For more information, see http://youngj.github.com/KalSMS/ ======== @@ -23,6 +23,8 @@ Features * Can be deployed almost anywhere in the world * Designed to allow non-technical users to do all setup/maintenance of deployed phones +* Can send outgoing SMS in excess of Android's limit of 100 messages + per app per hour by installing expansion packs * Many different phones running KalSMS can be connected to a single server (each phone could forward messages for a different mobile network) * Authenticates with password shared between phone and server @@ -253,4 +255,3 @@ License ======= The code is released under the MIT license; see LICENSE.txt - \ No newline at end of file diff --git a/index.html b/index.html deleted file mode 100644 index a690959..0000000 --- a/index.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - youngj/KalSMS @ GitHub - - - - - - Fork me on GitHub - -
- -
- - - - -
- -

KalSMS - by youngj

- -
- SImple SMS gateway running on Android -
- -

Authors

-

Nir Yariv (niryariv@gmail.com)
Jesse Young (youngj@envaya.org)

-

Contact

-

Jesse Young (adunar@gmail.com)

- - -

Download

-

- You can download this project in either - zip or - tar formats. -

-

You can also clone the project with Git - by running: -

$ git clone git://github.com/youngj/KalSMS
-

- - - -
- - - - diff --git a/server/php/KalSMS.php b/server/php/KalSMS.php index 5a68294..38785a1 100755 --- a/server/php/KalSMS.php +++ b/server/php/KalSMS.php @@ -138,12 +138,12 @@ class KalSMS_Action_Incoming extends KalSMS_Action { ob_start(); echo "\n"; - echo ""; + echo ""; foreach ($messages as $message) { - echo "".KalSMS::escape($message->message).""; + echo "".KalSMS::escape($message->message).""; } - echo ""; + echo ""; return ob_get_clean(); } } @@ -160,13 +160,13 @@ class KalSMS_Action_Outgoing extends KalSMS_Action { ob_start(); echo "\n"; - echo ""; + echo ""; foreach ($messages as $message) { - echo "". - KalSMS::escape($message->message).""; + echo "". + KalSMS::escape($message->message).""; } - echo ""; + echo ""; return ob_get_clean(); } } diff --git a/src/org/envaya/kalsms/App.java b/src/org/envaya/kalsms/App.java index 651019e..d3dfa2a 100755 --- a/src/org/envaya/kalsms/App.java +++ b/src/org/envaya/kalsms/App.java @@ -1,16 +1,15 @@ package org.envaya.kalsms; -import org.envaya.kalsms.task.PollerTask; -import org.envaya.kalsms.task.HttpTask; -import org.envaya.kalsms.receiver.OutgoingMessagePoller; import android.app.Activity; import android.app.AlarmManager; import android.app.Application; import android.app.PendingIntent; +import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; +import android.os.Bundle; import android.os.SystemClock; import android.preference.PreferenceManager; import android.telephony.SmsManager; @@ -18,10 +17,15 @@ import android.text.Html; import android.text.SpannableStringBuilder; import android.util.Log; import java.text.DateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.apache.http.message.BasicNameValuePair; +import org.envaya.kalsms.receiver.OutgoingMessagePoller; +import org.envaya.kalsms.task.HttpTask; +import org.envaya.kalsms.task.PollerTask; public final class App extends Application { @@ -37,9 +41,24 @@ public final class App extends Application { public static final String MESSAGE_TYPE_SMS = "sms"; public static final String LOG_NAME = "KALSMS"; - public static final String LOG_INTENT = "org.envaya.kalsms.LOG"; - public static final int MAX_DISPLAYED_LOG = 15000; + // intent to signal to Main activity (if open) that log has changed + public static final String LOG_INTENT = "org.envaya.kalsms.LOG"; + + public static final String QUERY_EXPANSION_PACKS_INTENT = "org.envaya.kalsms.QUERY_EXPANSION_PACKS"; + public static final String QUERY_EXPANSION_PACKS_EXTRA_PACKAGES = "packages"; + + // Interface for sending outgoing messages to expansion packs + 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 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.kalsms.MESSAGE_STATUS"; + + public static final int MAX_DISPLAYED_LOG = 4000; public static final int LOG_TIMESTAMP_INTERVAL = 60000; // Each QueuedMessage is identified within our internal Map by its Uri. @@ -48,7 +67,13 @@ public final class App extends Application { public static final Uri CONTENT_URI = Uri.parse("content://org.envaya.kalsms"); public static final Uri INCOMING_URI = Uri.withAppendedPath(CONTENT_URI, "incoming"); public static final Uri OUTGOING_URI = Uri.withAppendedPath(CONTENT_URI, "outgoing"); - + + // max per-app outgoing SMS rate used by com.android.internal.telephony.SMSDispatcher + // with a slightly longer check period to account for variance in the time difference + // between when we prepare messages and when SMSDispatcher receives them + public static int OUTGOING_SMS_CHECK_PERIOD = 3605000; // one hour plus 5 sec (in ms) + public static int OUTGOING_SMS_MAX_COUNT = 100; + private Map incomingMessages = new HashMap(); private Map outgoingMessages = new HashMap(); @@ -57,6 +82,11 @@ public final class App extends Application { private SpannableStringBuilder displayedLog = new SpannableStringBuilder(); private long lastLogTime; + private List outgoingMessagePackages = new ArrayList(); + private int outgoingMessageCount = -1; + private HashMap> outgoingTimestamps + = new HashMap>(); + private MmsUtils mmsUtils; @Override @@ -67,6 +97,10 @@ public final class App extends Application { settings = PreferenceManager.getDefaultSharedPreferences(this); mmsUtils = new MmsUtils(this); + outgoingMessagePackages.add(getPackageName()); + + updateExpansionPacks(); + log(Html.fromHtml( isEnabled() ? "SMS gateway running." : "SMS gateway disabled.")); @@ -77,8 +111,102 @@ public final class App extends Application { mmsObserver.register(); setOutgoingMessageAlarm(); + } + + public synchronized String chooseOutgoingSmsPackage() + { + outgoingMessageCount++; + + int numPackages = outgoingMessagePackages.size(); + + // round robin selection of packages that are under max sending rate + for (int i = 0; i < numPackages; i++) + { + int packageIndex = (outgoingMessageCount + i) % numPackages; + String packageName = outgoingMessagePackages.get(packageIndex); + + // implement rate-limiting algorithm from + // com.android.internal.telephony.SMSDispatcher.SmsCounter + + if (!outgoingTimestamps.containsKey(packageName)) { + outgoingTimestamps.put(packageName, new ArrayList()); + } + + ArrayList sent = outgoingTimestamps.get(packageName); + Long ct = System.currentTimeMillis(); + + //log(packageName + " SMS send size=" + sent.size()); + + // remove old timestamps + while (sent.size() > 0 && (ct - sent.get(0)) > OUTGOING_SMS_CHECK_PERIOD ) + { + sent.remove(0); + } + + if ( (sent.size() + 1) <= OUTGOING_SMS_MAX_COUNT) + { + sent.add(ct); + return packageName; + } + } + + log("Can't send outgoing SMS: maximum limit of " + + getOutgoingMessageLimit() + " in 1 hour reached"); + log("To increase this limit, install an expansion pack."); + + return null; } + private synchronized void setExpansionPacks(List packages) + { + int prevLimit = getOutgoingMessageLimit(); + + if (packages == null) + { + packages = new ArrayList(); + } + + packages.add(getPackageName()); + + outgoingMessagePackages = packages; + + int newLimit = getOutgoingMessageLimit(); + + if (prevLimit != newLimit) + { + log("Outgoing SMS limit: " + newLimit + " messages/hour"); + } + } + + public int getOutgoingMessageLimit() + { + return outgoingMessagePackages.size() * OUTGOING_SMS_MAX_COUNT; + } + + public void updateExpansionPacks() + { + ArrayList packages = new ArrayList(); + Bundle extras = new Bundle(); + extras.putStringArrayList(App.QUERY_EXPANSION_PACKS_EXTRA_PACKAGES, packages); + + sendOrderedBroadcast( + new Intent(App.QUERY_EXPANSION_PACKS_INTENT), + "android.permission.SEND_SMS", + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent resultIntent) { + + setExpansionPacks(this.getResultExtras(false) + .getStringArrayList(App.QUERY_EXPANSION_PACKS_EXTRA_PACKAGES)); + + } + }, + null, + Activity.RESULT_OK, + null, + extras); + } + public void checkOutgoingMessages() { String serverUrl = getServerUrl(); @@ -266,7 +394,7 @@ public final class App extends Application { public synchronized void sendOutgoingMessage(OutgoingMessage sms) { Uri uri = sms.getUri(); if (outgoingMessages.containsKey(uri)) { - log(sms.getLogName() + " already sent, skipping"); + log("Duplicate outgoing " + sms.getLogName() + ", skipping"); return; } diff --git a/src/org/envaya/kalsms/MmsObserver.java b/src/org/envaya/kalsms/MmsObserver.java index 713647d..5f73c05 100755 --- a/src/org/envaya/kalsms/MmsObserver.java +++ b/src/org/envaya/kalsms/MmsObserver.java @@ -26,7 +26,6 @@ final class MmsObserver extends ContentObserver { */ app.getContentResolver().registerContentObserver( MmsUtils.OBSERVER_URI, true, this); - app.log("MMS content observer registered"); MmsUtils mmsUtils = app.getMmsUtils(); diff --git a/src/org/envaya/kalsms/OutgoingMessage.java b/src/org/envaya/kalsms/OutgoingMessage.java index 98c5e4f..52d7d1a 100755 --- a/src/org/envaya/kalsms/OutgoingMessage.java +++ b/src/org/envaya/kalsms/OutgoingMessage.java @@ -1,12 +1,12 @@ package org.envaya.kalsms; +import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.Context; import org.envaya.kalsms.receiver.OutgoingMessageRetry; -import org.envaya.kalsms.receiver.MessageStatusNotifier; -import android.app.PendingIntent; import android.content.Intent; import android.net.Uri; -import android.telephony.SmsManager; public class OutgoingMessage extends QueuedMessage { @@ -87,18 +87,19 @@ public class OutgoingMessage extends QueuedMessage { public void trySend() { - SmsManager smgr = SmsManager.getDefault(); - - Intent intent = new Intent(app, MessageStatusNotifier.class); - intent.setData(this.getUri()); - - PendingIntent sentIntent = PendingIntent.getBroadcast( - app, - 0, - intent, - PendingIntent.FLAG_ONE_SHOT); - - smgr.sendTextMessage(getTo(), null, getMessageBody(), sentIntent, null); + String packageName = app.chooseOutgoingSmsPackage(); + + if (packageName == null) + { + // todo... schedule retry + return; + } + + Intent intent = new Intent(packageName + App.OUTGOING_SMS_INTENT_SUFFIX, this.getUri()); + intent.putExtra(App.OUTGOING_SMS_EXTRA_TO, getTo()); + intent.putExtra(App.OUTGOING_SMS_EXTRA_BODY, getMessageBody()); + + app.sendBroadcast(intent, "android.permission.SEND_SMS"); } protected Intent getRetryIntent() { diff --git a/src/org/envaya/kalsms/receiver/ExpansionPackInstallReceiver.java b/src/org/envaya/kalsms/receiver/ExpansionPackInstallReceiver.java new file mode 100755 index 0000000..09c9a60 --- /dev/null +++ b/src/org/envaya/kalsms/receiver/ExpansionPackInstallReceiver.java @@ -0,0 +1,22 @@ +package org.envaya.kalsms.receiver; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import org.envaya.kalsms.App; + +public class ExpansionPackInstallReceiver extends BroadcastReceiver +{ + @Override + public void onReceive(Context context, Intent intent) + { + App app = (App) context.getApplicationContext(); + + String packageName = intent.getData().getSchemeSpecificPart(); + + if (packageName != null && packageName.startsWith(context.getPackageName() + ".pack")) + { + app.updateExpansionPacks(); + } + } +} \ No newline at end of file diff --git a/src/org/envaya/kalsms/receiver/OutgoingSmsReceiver.java b/src/org/envaya/kalsms/receiver/OutgoingSmsReceiver.java new file mode 100755 index 0000000..c0c58fc --- /dev/null +++ b/src/org/envaya/kalsms/receiver/OutgoingSmsReceiver.java @@ -0,0 +1,31 @@ +package org.envaya.kalsms.receiver; + +import android.app.PendingIntent; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.telephony.SmsManager; +import org.envaya.kalsms.App; + +public class OutgoingSmsReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) + { + Bundle extras = intent.getExtras(); + String to = extras.getString(App.OUTGOING_SMS_EXTRA_TO); + String body = extras.getString(App.OUTGOING_SMS_EXTRA_BODY); + + SmsManager smgr = SmsManager.getDefault(); + + Intent statusIntent = new Intent(App.MESSAGE_STATUS_INTENT, intent.getData()); + + PendingIntent sentIntent = PendingIntent.getBroadcast( + context, + 0, + statusIntent, + PendingIntent.FLAG_ONE_SHOT); + + smgr.sendTextMessage(to, null, body, sentIntent, null); + } +} diff --git a/src/org/envaya/kalsms/task/HttpTask.java b/src/org/envaya/kalsms/task/HttpTask.java index acb50a3..eaf7e6a 100755 --- a/src/org/envaya/kalsms/task/HttpTask.java +++ b/src/org/envaya/kalsms/task/HttpTask.java @@ -190,7 +190,7 @@ public class HttpTask extends AsyncTask { DocumentBuilder xmlBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document xml = xmlBuilder.parse(responseStream); - NodeList smsNodes = xml.getElementsByTagName("Sms"); + NodeList smsNodes = xml.getElementsByTagName("sms"); for (int i = 0; i < smsNodes.getLength(); i++) { Element smsElement = (Element) smsNodes.item(i); diff --git a/src/org/envaya/kalsms/ui/Help.java b/src/org/envaya/kalsms/ui/Help.java index a0336b1..9f2da9a 100755 --- a/src/org/envaya/kalsms/ui/Help.java +++ b/src/org/envaya/kalsms/ui/Help.java @@ -1,7 +1,3 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package org.envaya.kalsms.ui; import android.app.Activity; @@ -11,13 +7,8 @@ import android.view.Menu; import android.widget.TextView; import org.envaya.kalsms.R; -/** - * - * @author Jesse - */ public class Help extends Activity { - /** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); @@ -29,8 +20,7 @@ public class Help extends Activity { String html = "KalSMS is a SMS gateway.

" + "It forwards all incoming SMS messages received by this phone to a server on the internet, " + "and also sends outgoing SMS messages from that server to other phones.

" - + "(See https://github.com/youngj/KalSMS/wiki " - + "for information about setting up a server.)

" + + "(See https://kalsms.net for information about setting up a server.)

" + "The Settings screen allows you configure KalSMS to work with a particular server, " + "by entering the server URL, your phone number, " + "and the password assigned to your phone on the server.

" @@ -39,11 +29,4 @@ public class Help extends Activity { help.setText(Html.fromHtml(html)); } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - this.finish(); - - return(true); - } }