Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new pull request #3

Open
wants to merge 70 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
4130593
polling
niryariv Jan 15, 2011
aee1061
initial import of polling code
niryariv Jan 15, 2011
8e31033
new icon
niryariv Jan 15, 2011
ec1dc62
simplify polling UI to use fixed, 15 min intervals
niryariv Jan 15, 2011
2089450
cleanup home screen text
niryariv Jan 16, 2011
3ed1958
add a poll=true parameter
niryariv Jan 16, 2011
448eafe
Move post-parse sms sending to TargetUrlRequest
niryariv Jan 18, 2011
9473ab1
use POST in http requests; use different url for outgoing sms; poll f…
Sep 11, 2011
fc6cda4
do http requests in AsyncTask so they don't freeze the UI thread; imp…
Sep 12, 2011
8f15a8c
add menu with options to test server connection, or edit settings
Sep 12, 2011
d5b9734
fix null pointer exception; remove dependency on Base64 for android 1…
Sep 12, 2011
cb8d95e
PHP server library with example implementation; add 'check now' butto…
Sep 12, 2011
aff22e5
use string status codes instead of integers
Sep 13, 2011
0a0f50a
fix comments for php server example
Sep 13, 2011
da334a0
remove test action to simplify server implementation; add icons from …
Sep 13, 2011
307f354
add help screen
Sep 13, 2011
2911111
keep messages waiting to be sent in memory; if forwarding fails (in e…
Sep 13, 2011
d29e7b2
start alarm to poll for outgoing messages when phone boots; add optio…
Sep 13, 2011
e4cea3b
use alarm to schedule retries; fix bug where sms notfications were dr…
Sep 13, 2011
bead453
set phone number and api version as regular post fields instead of cu…
Sep 13, 2011
e535266
instead of deleting messages from inbox, prevent them from getting th…
Sep 13, 2011
e79fe7c
refactoring
Sep 13, 2011
61d24b2
add setting to enable/disable sms gateway
Sep 13, 2011
41141fa
add menu option to forward existing messages from inbox (delivered wh…
Sep 14, 2011
0071efd
improve ForwardInbox with help from http://www.marvinlabs.com/2010/10…
Sep 14, 2011
2f22c29
github generated gh-pages branch
youngj Sep 15, 2011
e78598c
refactor App to subclass Application; retain log messages in App clas…
Sep 15, 2011
46710c2
organize code into subpackages
Sep 16, 2011
60d4941
launching Main activity on boot is no longer necessary
Sep 16, 2011
d994b10
support for incoming MMS
Sep 18, 2011
72a893e
Merge branch 'gh-pages' of github.com:youngj/KalSMS
Sep 18, 2011
7bc88cf
updated readme
Sep 18, 2011
e834488
avoid exceeding Android limit of 100 outgoing SMS/app/hour; allow eff…
Sep 18, 2011
d720412
most README content moved to http://youngj.github.com/KalSMS/
Sep 19, 2011
430aeca
enable user to change wifi sleep policy on kalsms settings page for c…
Sep 19, 2011
3357de7
assume http:// scheme for server URLs
Sep 19, 2011
eb80837
add test mode to allow testing KalSMS on a phone that is also being u…
Sep 19, 2011
a793a5f
use http connection pooling to improve performance (especially over ssl)
Sep 20, 2011
9a574b3
add foreground service to keep App in memory (otherwise rate-limiting…
Sep 20, 2011
9440fdb
android's ForegroundService example code is surprisingly buggy
Sep 20, 2011
4b0010f
display version number
Sep 20, 2011
687400f
use kalsms version code in http requests
Sep 20, 2011
b6a372d
avoid forwarding sms from network; unregister mms observer when kalsm…
Sep 21, 2011
dbf3536
update url in readme
Sep 21, 2011
73bc3c9
MMS fixes: prevent httpclient from using transfer-encoding: chunked s…
Sep 22, 2011
7df89cd
rename to EnvayaSMS; add icon
Sep 22, 2011
1cf69e8
update links
Sep 23, 2011
6384942
handle sending and receiving multipart sms messages > 160 chars
Sep 24, 2011
986b50f
fix bug where outgoing sms would be cut off if they contain xml entities
Sep 25, 2011
bf14f23
fix encoding problem for post requests, make test a separate action
Sep 27, 2011
03d5f55
update php server library and example
Sep 27, 2011
faffc6c
don't request delivery reports but leave option open in future; fix b…
Sep 28, 2011
3108512
keep backlogged outgoing messages in priority queue; allow server to …
Sep 28, 2011
1081f57
automatic failover between wifi/mobile if server cannot be reached; s…
Sep 29, 2011
d7f803e
add PendingMessages activity for viewing/retrying/deleting pending me…
Oct 1, 2011
cf1deec
queue incoming messages like outgoing messages
Oct 1, 2011
dedfdb5
improve performance of displaying log in Main activity
Oct 1, 2011
79ec4c1
add note about local.properties and sdk.dir to README
Oct 4, 2011
af1f8af
add html page for simulating EnvayaSMS requests
Oct 9, 2011
f253f54
update license and readme files for request simulator
Oct 9, 2011
2889bf9
send new log messages to server on each HTTP request; notify server o…
Oct 10, 2011
f430ddb
set http user-agent header
Nov 13, 2011
22f8c26
add settings screen for ignored phone numbers; allow user to specify …
Nov 26, 2011
c18a28b
enable long polling - increase socket timeout, start only one PollerT…
Nov 30, 2011
6f19970
increment version to 2.0.4
Nov 30, 2011
d93ff76
update httpserver submodule to latest version
youngj Mar 15, 2012
f53ccc3
add support for incoming call notifications; fix intermittent NullPoi…
youngj Mar 16, 2012
239ee1f
version 3.0 - real-time AMQP connections; change server API format f…
youngj Apr 4, 2012
9d65fc1
remove stray references to telerivet
youngj Apr 4, 2012
69a05ac
remove code added for debugging
youngj Apr 4, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename to EnvayaSMS; add icon
Jesse Young committed Sep 22, 2011
commit 7df89cd5d0894805958c64d1e24ea7cb5afa2515
20 changes: 10 additions & 10 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.envaya.kalsms"
android:versionCode="3"
android:versionName="2.0-beta 3">
package="org.envaya.sms"
android:versionCode="6"
android:versionName="2.0-beta 4">

<uses-sdk android:minSdkVersion="4" />

@@ -16,7 +16,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />

<application android:name="org.envaya.kalsms.App"
<application android:name="org.envaya.sms.App"
android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".ui.Main" android:label="@string/app_name">
<intent-filter>
@@ -25,16 +25,16 @@
</intent-filter>
</activity>

<activity android:name=".ui.Help" android:label="KalSMS : Help">
<activity android:name=".ui.Help" android:label="EnvayaSMS : Help">
</activity>

<activity android:name=".ui.TestPhoneNumbers" android:label="KalSMS : Test Phone Numbers">
<activity android:name=".ui.TestPhoneNumbers" android:label="EnvayaSMS : Test Phone Numbers">
</activity>

<activity android:name=".ui.ForwardInbox" android:label="KalSMS : Forward Inbox">
<activity android:name=".ui.ForwardInbox" android:label="EnvayaSMS : Forward Inbox">
</activity>

<activity android:name=".ui.Prefs" android:label="KalSMS : Settings">
<activity android:name=".ui.Prefs" android:label="EnvayaSMS : Settings">
</activity>

<receiver android:name=".receiver.SmsReceiver">
@@ -45,14 +45,14 @@

<receiver android:name=".receiver.OutgoingSmsReceiver">
<intent-filter>
<action android:name="org.envaya.kalsms.OUTGOING_SMS" />
<action android:name="org.envaya.sms.OUTGOING_SMS" />
<data android:scheme="content" />
</intent-filter>
</receiver>

<receiver android:name=".receiver.MessageStatusNotifier" android:exported="true">
<intent-filter>
<action android:name="org.envaya.kalsms.MESSAGE_STATUS" />
<action android:name="org.envaya.sms.MESSAGE_STATUS" />
<data android:scheme="content" />
</intent-filter>
</receiver>
12 changes: 6 additions & 6 deletions LICENSE
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Except for the parts noted otherwise (see Third-Party Libraries section below),
KalSMS' source code is licensed under the MIT license:
EnvayaSMS' source code is licensed under the MIT license:

-----

@@ -31,14 +31,14 @@ 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,
org.envaya.sms.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
org.envaya.sms.ui.InertCheckBox and org.envaya.sms.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 and
org.envaya.kalsms.ForegroundService include code from Android,
org.envaya.sms.App.chooseOutgoingSmsPackage and
org.envaya.sms.ForegroundService include code from Android,
Copyright 2005-2009 The Android Open Source Project
See NOTICE
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KalSMS is an Android app that acts as a SMS and MMS gateway.
EnvayaSMS is an Android app that acts as a SMS and MMS gateway.

For more information and installation instructions,
see http://kalsms.net/
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="KalSMS" default="help">
<project name="EnvayaSMS" default="help">

<!-- The local.properties file is created and updated by the 'android'
tool.
Binary file modified res/drawable-hdpi/icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-ldpi/icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-mdpi/icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions res/layout/inbox_item.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<org.envaya.kalsms.ui.CheckableRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<org.envaya.sms.ui.CheckableRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#cccccc">
<org.envaya.kalsms.ui.InertCheckBox android:id="@+id/inbox_checkbox"
<org.envaya.sms.ui.InertCheckBox android:id="@+id/inbox_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
@@ -31,4 +31,4 @@
android:focusable="false"
android:paddingBottom="6sp"
android:textSize="14sp"></TextView>
</org.envaya.kalsms.ui.CheckableRelativeLayout>
</org.envaya.sms.ui.CheckableRelativeLayout>
6 changes: 3 additions & 3 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">KalSMS</string>
<string name="app_name">EnvayaSMS</string>
<string name="settings">Settings</string>
<string name="test">Test Connection</string>
<string name="check_now">Check Messages</string>
<string name="help">Help</string>
<string name="retry_now">Retry</string>
<string name="forward_inbox">Fwd Inbox...</string>
<string name='service_started'>New SMS will be forwarded to server</string>
<string name='test_senders'>When running KalSMS in Test Mode,
KalSMS will only forward SMS messages from the phone numbers
<string name='test_senders'>When running EnvayaSMS in Test Mode,
EnvayaSMS will only forward SMS messages from the phone numbers
listed below. (Incoming SMS messages from other phone numbers will be saved
in the normal Messaging inbox, and outgoing messages will be ignored.)</string>
</resources>
12 changes: 6 additions & 6 deletions res/xml/prefs.xml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

<CheckBoxPreference
android:key="enabled"
android:title="Enable KalSMS"
android:title="Enable EnvayaSMS"
android:defaultValue='false'
android:summaryOn="All new SMS will be forwarded between phone and server"
android:summaryOff="New SMS will not be forwarded between phone and server"
@@ -57,20 +57,20 @@
<CheckBoxPreference
android:key="test_mode"
android:title="Test mode"
android:summaryOff="Test mode is off (KalSMS forwards all SMS)"
android:summaryOn="Test mode is on (KalSMS only forwards SMS to/from specific phones)"
android:summaryOff="Test mode is off (EnvayaSMS forwards all SMS)"
android:summaryOn="Test mode is on (EnvayaSMS only forwards SMS to/from specific phones)"
></CheckBoxPreference>

<PreferenceScreen
android:key="test_numbers"
android:title="Sender phones"
android:dependency="test_mode"
android:summary="Configure the phone numbers that KalSMS will handle"
android:summary="Configure the phone numbers that EnvayaSMS will handle"
>
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="org.envaya.kalsms"
android:targetClass="org.envaya.kalsms.ui.TestPhoneNumbers" />
android:targetPackage="org.envaya.sms"
android:targetClass="org.envaya.sms.ui.TestPhoneNumbers" />
</PreferenceScreen>

</PreferenceScreen>
125 changes: 68 additions & 57 deletions server/php/KalSMS.php → server/php/EnvayaSMS.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

/*
* PHP server library for KalSMS
* PHP server library for EnvayaSMS
*
* For example usage see example/www/index.php
*/

class KalSMS
class EnvayaSMS
{
const ACTION_INCOMING = 'incoming';
const ACTION_OUTGOING = 'outgoing';
@@ -17,57 +17,67 @@ class KalSMS
const STATUS_SENT = 'sent';

const MESSAGE_TYPE_SMS = 'sms';
const MESSAGE_TYPE_MMS = 'mms';

static function new_from_request()
{
$version = @$_POST['version'];

// If API version changes, could return different KalSMS instance
// to support multiple phone versions

return new KalSMS();
}
const MESSAGE_TYPE_MMS = 'mms';

static function escape($val)
{
return htmlspecialchars($val, ENT_QUOTES, 'UTF-8');
}
}

private static $request;

static function get_request()
{
if (!isset(static::$request))
{
$version = @$_POST['version'];

// If API version changes, could return
// different EnvayaSMS_Request instance
// to support multiple phone versions

static::$request = new EnvayaSMS_Request();
}
return static::$request;
}
}

class EnvayaSMS_Request
{
private $request_action;

function get_request_action()
function get_action()
{
if (!$this->request_action)
{
$this->request_action = $this->_get_request_action();
$this->request_action = $this->_get_action();
}
return $this->request_action;
}

private function _get_request_action()
private function _get_action()
{
switch (@$_POST['action'])
{
case static::ACTION_INCOMING:
return new KalSMS_Action_Incoming($this);
case static::ACTION_OUTGOING:
return new KalSMS_Action_Outgoing($this);
case static::ACTION_SEND_STATUS:
return new KalSMS_Action_SendStatus($this);
case EnvayaSMS::ACTION_INCOMING:
return new EnvayaSMS_Action_Incoming($this);
case EnvayaSMS::ACTION_OUTGOING:
return new EnvayaSMS_Action_Outgoing($this);
case EnvayaSMS::ACTION_SEND_STATUS:
return new EnvayaSMS_Action_SendStatus($this);
default:
return new KalSMS_Action($this);
return new EnvayaSMS_Action($this);
}
}

function get_request_phone_number()
function get_phone_number()
{
return @$_POST['phone_number'];
}

function is_validated_request($correct_password)
function is_validated($correct_password)
{
$signature = @$_SERVER['HTTP_X_KALSMS_SIGNATURE'];
$signature = @$_SERVER['HTTP_X_REQUEST_SIGNATURE'];
if (!$signature)
{
return false;
@@ -100,34 +110,34 @@ function compute_signature($url, $data, $password)
}
}

class KalSMS_OutgoingMessage
class EnvayaSMS_OutgoingMessage
{
public $id = ''; // ID generated by server
public $to; // destination phone number
public $message; // content of SMS message
}

class KalSMS_Action
class EnvayaSMS_Action
{
public $type;
public $kalsms;
public $request;

function __construct($kalsms)
function __construct($request)
{
$this->kalsms = $kalsms;
$this->request = $request;
}
}

class KalSMS_Action_Test extends KalSMS_Action
class EnvayaSMS_Action_Test extends EnvayaSMS_Action
{
function __construct($kalsms)
function __construct($request)
{
parent::__construct($kalsms);
$this->type = KalSMS::ACTION_TEST;
parent::__construct($request);
$this->type = EnvayaSMS::ACTION_TEST;
}
}

class KalSMS_MMS_Part
class EnvayaSMS_MMS_Part
{
public $form_name; // name of form field with MMS part content
public $cid; // MMS Content-ID
@@ -152,27 +162,27 @@ function __construct($args)
}
}

class KalSMS_Action_Incoming extends KalSMS_Action
class EnvayaSMS_Action_Incoming extends EnvayaSMS_Action
{
public $from; // Sender phone number
public $message; // The message body of the SMS, or the content of the text/plain part of the MMS.
public $message_type; // KalSMS::MESSAGE_TYPE_MMS or KalSMS::MESSAGE_TYPE_SMS
public $mms_parts; // array of KalSMS_MMS_Part instances
public $message_type; // EnvayaSMS::MESSAGE_TYPE_MMS or EnvayaSMS::MESSAGE_TYPE_SMS
public $mms_parts; // array of EnvayaSMS_MMS_Part instances

function __construct($kalsms)
function __construct($request)
{
parent::__construct($kalsms);
$this->type = KalSMS::ACTION_INCOMING;
parent::__construct($request);
$this->type = EnvayaSMS::ACTION_INCOMING;
$this->from = $_POST['from'];
$this->message = $_POST['message'];
$this->message_type = $_POST['message_type'];

if ($this->message_type == KalSMS::MESSAGE_TYPE_MMS)
if ($this->message_type == EnvayaSMS::MESSAGE_TYPE_MMS)
{
$this->mms_parts = array();
foreach (json_decode($_POST['mms_parts'], true) as $mms_part)
{
$this->mms_parts[] = new KalSMS_MMS_Part($mms_part);
$this->mms_parts[] = new EnvayaSMS_MMS_Part($mms_part);
}
}
}
@@ -184,19 +194,19 @@ function get_response_xml($messages)
echo "<messages>";
foreach ($messages as $message)
{
echo "<sms id='".KalSMS::escape($message->id)."'>".KalSMS::escape($message->message)."</sms>";
echo "<sms id='".EnvayaSMS::escape($message->id)."'>".EnvayaSMS::escape($message->message)."</sms>";
}
echo "</messages>";
return ob_get_clean();
}
}

class KalSMS_Action_Outgoing extends KalSMS_Action
class EnvayaSMS_Action_Outgoing extends EnvayaSMS_Action
{
function __construct($kalsms)
function __construct($request)
{
parent::__construct($kalsms);
$this->type = KalSMS::ACTION_OUTGOING;
parent::__construct($request);
$this->type = EnvayaSMS::ACTION_OUTGOING;
}

function get_response_xml($messages)
@@ -206,22 +216,23 @@ function get_response_xml($messages)
echo "<messages>";
foreach ($messages as $message)
{
echo "<sms id='".KalSMS::escape($message->id)."' to='".KalSMS::escape($message->to)."'>".
KalSMS::escape($message->message)."</sms>";
echo "<sms id='".EnvayaSMS::escape($message->id)."' to='".EnvayaSMS::escape($message->to)."'>".
EnvayaSMS::escape($message->message)."</sms>";
}
echo "</messages>";
return ob_get_clean();
}
}

class KalSMS_Action_SendStatus extends KalSMS_Action
class EnvayaSMS_Action_SendStatus extends EnvayaSMS_Action
{
public $status; // KalSMS::STATUS_* values
public $id; // server ID previously used in KalSMS_OutgoingMessage
public $status; // EnvayaSMS::STATUS_* values
public $id; // server ID previously used in EnvayaSMS_OutgoingMessage

function __construct($type)
function __construct($request)
{
$this->type = KalSMS::ACTION_SEND_STATUS;
parent::__construct($request);
$this->type = EnvayaSMS::ACTION_SEND_STATUS;
$this->status = $_POST['status'];
$this->id = $_POST['id'];
}
13 changes: 6 additions & 7 deletions server/php/README.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
PHP server library for EnvayaSMS, with example implementation

PHP server library for KalSMS, with example implementation

The KalSMS.php library is intended to be used as part of a PHP application
The EnvayaSMS.php library is intended to be used as part of a PHP application
running on an HTTP server that receives incoming SMS messages from, and sends
outgoing SMS messages to, an Android phone running KalSMS.
outgoing SMS messages to, an Android phone running EnvayaSMS.

To run the example implementation, the example/www/ directory should be made available
via a web server running PHP (e.g. Apache). You can also use the included standalone
PHP web server, by running the following commands:
git submodule init
php server.php

example/config.php contains the list of phone numbers and passwords for phones running KalSMS.
example/config.php contains the list of phone numbers and passwords for phones running EnvayaSMS.

On a phone running KalSMS, go to Menu -> Settings and enter:
On a phone running EnvayaSMS, go to Menu -> Settings and enter:
* Server URL: The URL to example/www/index.php.
If you're using server.php, this will be http://<your_ip_address>:8002/
* Your phone number: One of the phone numbers listed in example/config.php
@@ -22,4 +21,4 @@ On a phone running KalSMS, go to Menu -> Settings and enter:
To send an outgoing SMS, use
php example/send_sms.php

See KalSMS.php and example/www/index.php
See EnvayaSMS.php and example/www/index.php
3 changes: 2 additions & 1 deletion server/php/example/send_sms.php
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@
/*
* Command line script to simulate sending an outgoing SMS from the server.
*
* The message will be queued on the server until the next time KalSMS checks for outgoing messages.
* The message will be queued on the server until the next time
* EnvayaSMS checks for outgoing messages.
*/

require_once __DIR__."/config.php";
20 changes: 10 additions & 10 deletions server/php/example/www/index.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<?php

require_once dirname(__DIR__)."/config.php";
require_once dirname(dirname(__DIR__))."/KalSMS.php";
require_once dirname(dirname(__DIR__))."/EnvayaSMS.php";

ini_set('display_errors','0');

// this example implementation uses the filesystem to store outgoing SMS messages,
// but presumably a production implementation would use another storage method

$kalsms = KalSMS::new_from_request();
$request = EnvayaSMS::get_request();

$phone_number = $kalsms->get_request_phone_number();
$phone_number = $request->get_phone_number();

$password = @$PASSWORDS[$phone_number];

if (!isset($password) || !$kalsms->is_validated_request($password))
if (!isset($password) || !$request->is_validated($password))
{
header("HTTP/1.1 403 Forbidden");
error_log("Invalid request signature");
echo "Invalid request signature";
return;
}

$action = $kalsms->get_request_action();
$action = $request->get_action();

switch ($action->type)
{
case KalSMS::ACTION_INCOMING:
case EnvayaSMS::ACTION_INCOMING:
error_log("Received SMS from {$action->from}");

$reply = new KalSMS_OutgoingMessage();
$reply = new EnvayaSMS_OutgoingMessage();
$reply->message = "You said: {$action->message}";

error_log("Sending reply: {$reply->message}");
@@ -38,7 +38,7 @@
echo $action->get_response_xml(array($reply));
return;

case KalSMS::ACTION_OUTGOING:
case EnvayaSMS::ACTION_OUTGOING:
$messages = array();

$dir = opendir($OUTGOING_DIR_NAME);
@@ -49,7 +49,7 @@
$data = json_decode(file_get_contents("$OUTGOING_DIR_NAME/$file"), true);
if ($data && @$data['from'] == $phone_number)
{
$sms = new KalSMS_OutgoingMessage();
$sms = new EnvayaSMS_OutgoingMessage();
$sms->id = $data['id'];
$sms->to = $data['to'];
$sms->from = $data['from'];
@@ -64,7 +64,7 @@
echo $action->get_response_xml($messages);
return;

case KalSMS::ACTION_SEND_STATUS:
case EnvayaSMS::ACTION_SEND_STATUS:

$id = $action->id;

22 changes: 11 additions & 11 deletions src/org/envaya/kalsms/App.java → src/org/envaya/sms/App.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.envaya.kalsms;
package org.envaya.sms;

import android.app.Activity;
import android.app.AlarmManager;
@@ -36,9 +36,9 @@
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.envaya.kalsms.receiver.OutgoingMessagePoller;
import org.envaya.kalsms.task.HttpTask;
import org.envaya.kalsms.task.PollerTask;
import org.envaya.sms.receiver.OutgoingMessagePoller;
import org.envaya.sms.task.HttpTask;
import org.envaya.sms.task.PollerTask;
import org.json.JSONArray;
import org.json.JSONException;

@@ -55,12 +55,12 @@ public final class App extends Application {
public static final String MESSAGE_TYPE_MMS = "mms";
public static final String MESSAGE_TYPE_SMS = "sms";

public static final String LOG_NAME = "KALSMS";
public static final String LOG_NAME = "EnvayaSMS";

// 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 LOG_INTENT = "org.envaya.sms.LOG";

public static final String QUERY_EXPANSION_PACKS_INTENT = "org.envaya.kalsms.QUERY_EXPANSION_PACKS";
public static final String QUERY_EXPANSION_PACKS_INTENT = "org.envaya.sms.QUERY_EXPANSION_PACKS";
public static final String QUERY_EXPANSION_PACKS_EXTRA_PACKAGES = "packages";

// Interface for sending outgoing messages to expansion packs
@@ -71,15 +71,15 @@ public final class App extends Application {

// 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 String MESSAGE_STATUS_INTENT = "org.envaya.sms.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.
// Currently QueuedMessage instances are only available within KalSMS,
// Currently QueuedMessage instances are only available within EnvayaSMS,
// (but they could be made available to other applications later via a ContentProvider)
public static final Uri CONTENT_URI = Uri.parse("content://org.envaya.kalsms");
public static final Uri CONTENT_URI = Uri.parse("content://org.envaya.sms");
public static final Uri INCOMING_URI = Uri.withAppendedPath(CONTENT_URI, "incoming");
public static final Uri OUTGOING_URI = Uri.withAppendedPath(CONTENT_URI, "outgoing");

@@ -99,7 +99,7 @@ public final class App extends Application {

private PackageInfo packageInfo;

// list of package names (e.g. org.envaya.kalsms, or org.envaya.kalsms.packXX)
// list of package names (e.g. org.envaya.sms, or org.envaya.sms.packXX)
// for this package and all expansion packs
private List<String> outgoingMessagePackages = new ArrayList<String>();

Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
//
// Please contact the author if you need another license.
// This module is provided "as is", without warranties of any kind.
package org.envaya.kalsms;
package org.envaya.sms;

/**
* A Base64 encoder/decoder.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.envaya.kalsms;
package org.envaya.sms;

import android.app.IntentService;
import android.content.Intent;
@@ -39,7 +39,7 @@ protected void onHandleIntent(Intent intent)
{
app.log("New MMS id=" + mms.getId() + " in inbox");
// prevent forwarding MMS messages that existed in inbox
// before KalSMS started, or re-forwarding MMS multiple
// before EnvayaSMS started, or re-forwarding MMS multiple
// times if we don't delete them.
mmsUtils.markOldMms(mms);

Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.envaya.kalsms;
package org.envaya.sms;

import android.app.Notification;
import android.app.NotificationManager;
@@ -26,7 +26,8 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.envaya.kalsms.ui.Main;
import org.envaya.sms.R;
import org.envaya.sms.ui.Main;

/*
* Service running in foreground to make sure App instance stays
@@ -162,7 +163,7 @@ void handleCommand(Intent intent)
new Intent(this, Main.class), 0);

notification.setLatestEventInfo(this,
"KalSMS running",
"EnvayaSMS running",
text, contentIntent);

startForegroundCompat(R.string.service_started, notification);
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.envaya.kalsms;
package org.envaya.sms;

import android.content.Intent;
import android.net.Uri;
import org.envaya.kalsms.receiver.IncomingMessageRetry;
import org.envaya.sms.receiver.IncomingMessageRetry;

public abstract class IncomingMessage extends QueuedMessage {

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.envaya.kalsms;
package org.envaya.sms;

import android.net.Uri;
import java.io.IOException;
@@ -12,7 +12,7 @@
import org.apache.http.entity.mime.content.ByteArrayBody;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.message.BasicNameValuePair;
import org.envaya.kalsms.task.ForwarderTask;
import org.envaya.sms.task.ForwarderTask;

public class IncomingMms extends IncomingMessage {
List<MmsPart> parts;
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

package org.envaya.kalsms;
package org.envaya.sms;

import android.net.Uri;
import android.telephony.SmsMessage;
import org.apache.http.message.BasicNameValuePair;
import org.envaya.kalsms.task.ForwarderTask;
import org.envaya.sms.task.ForwarderTask;


public class IncomingSms extends IncomingMessage {
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.envaya.kalsms;
package org.envaya.sms;

import android.content.Intent;
import android.database.ContentObserver;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.envaya.kalsms;
package org.envaya.sms;

import android.net.Uri;
import java.io.File;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.envaya.kalsms;
package org.envaya.sms;

import android.content.ContentResolver;
import android.database.Cursor;
@@ -146,7 +146,7 @@ public synchronized boolean deleteFromInbox(IncomingMms mms)
// remove id from set because Messaging app reuses ids
// of deleted messages.
// TODO: handle reuse of IDs deleted directly through Messaging
// app while KalSMS is running
// app while EnvayaSMS is running
seenMmsIds.remove(id);
}
else
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

package org.envaya.kalsms;
package org.envaya.sms;

import org.envaya.kalsms.receiver.OutgoingMessageRetry;
import org.envaya.sms.receiver.OutgoingMessageRetry;
import android.content.Intent;
import android.net.Uri;

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.envaya.kalsms;
package org.envaya.sms;

import android.app.AlarmManager;
import android.app.PendingIntent;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.envaya.kalsms.receiver;
package org.envaya.sms.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.envaya.kalsms.receiver;
package org.envaya.sms.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.envaya.kalsms.App;
import org.envaya.sms.App;

public class ExpansionPackInstallReceiver extends BroadcastReceiver
{
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

package org.envaya.kalsms.receiver;
package org.envaya.sms.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.envaya.kalsms.App;
import org.envaya.sms.App;

public class IncomingMessageRetry extends BroadcastReceiver
{
Original file line number Diff line number Diff line change
@@ -2,13 +2,13 @@
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.envaya.kalsms.receiver;
package org.envaya.sms.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import org.envaya.kalsms.App;
import org.envaya.sms.App;

public class MessageStatusNotifier extends BroadcastReceiver {

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.envaya.kalsms.receiver;
package org.envaya.sms.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.envaya.kalsms.App;
import org.envaya.sms.App;

public class OutgoingMessagePoller extends BroadcastReceiver {

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

package org.envaya.kalsms.receiver;
package org.envaya.sms.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.envaya.kalsms.App;
import org.envaya.sms.App;

public class OutgoingMessageRetry extends BroadcastReceiver
{
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.envaya.kalsms.receiver;
package org.envaya.sms.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;
import org.envaya.sms.App;

public class OutgoingSmsReceiver extends BroadcastReceiver {
@Override
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.envaya.kalsms.receiver;
package org.envaya.sms.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
@@ -7,9 +7,9 @@
import android.telephony.SmsMessage;
import java.util.ArrayList;
import java.util.List;
import org.envaya.kalsms.App;
import org.envaya.kalsms.IncomingMessage;
import org.envaya.kalsms.IncomingSms;
import org.envaya.sms.App;
import org.envaya.sms.IncomingMessage;
import org.envaya.sms.IncomingSms;


public class SmsReceiver extends BroadcastReceiver {
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.envaya.kalsms.task;
package org.envaya.sms.task;

import org.apache.http.HttpResponse;
import org.apache.http.message.BasicNameValuePair;
import org.envaya.kalsms.App;
import org.envaya.kalsms.IncomingMessage;
import org.envaya.kalsms.OutgoingMessage;
import org.envaya.sms.App;
import org.envaya.sms.IncomingMessage;
import org.envaya.sms.OutgoingMessage;

public class ForwarderTask extends HttpTask {

Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.envaya.kalsms.task;
package org.envaya.sms.task;

import android.os.AsyncTask;
import java.io.IOException;
@@ -31,9 +31,9 @@
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.envaya.kalsms.App;
import org.envaya.kalsms.Base64Coder;
import org.envaya.kalsms.OutgoingMessage;
import org.envaya.sms.App;
import org.envaya.sms.Base64Coder;
import org.envaya.sms.OutgoingMessage;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -136,7 +136,7 @@ protected HttpResponse doInBackground(String... ignored) {

String signature = getSignature();

post.setHeader("X-Kalsms-Signature", signature);
post.setHeader("X-Request-Signature", signature);

HttpResponse response = client.execute(post);

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

package org.envaya.kalsms.task;
package org.envaya.sms.task;

import org.apache.http.HttpResponse;
import org.apache.http.message.BasicNameValuePair;
import org.envaya.kalsms.App;
import org.envaya.kalsms.OutgoingMessage;
import org.envaya.sms.App;
import org.envaya.sms.OutgoingMessage;

public class PollerTask extends HttpTask {

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.envaya.kalsms.ui;
package org.envaya.sms.ui;

// from http://www.marvinlabs.com/2010/10/custom-listview-ability-check-items/
// package fr.marvinlabs.widget;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.envaya.kalsms.ui;
package org.envaya.sms.ui;

import android.app.ListActivity;
import android.database.Cursor;
@@ -9,10 +9,10 @@
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import org.envaya.kalsms.App;
import org.envaya.kalsms.IncomingMessage;
import org.envaya.kalsms.IncomingSms;
import org.envaya.kalsms.R;
import org.envaya.sms.App;
import org.envaya.sms.IncomingMessage;
import org.envaya.sms.IncomingSms;
import org.envaya.sms.R;


public class ForwardInbox extends ListActivity {
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.envaya.kalsms.ui;
package org.envaya.sms.ui;

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;
import org.envaya.kalsms.App;
import org.envaya.kalsms.R;
import org.envaya.sms.App;
import org.envaya.sms.R;

public class Help extends Activity {

@@ -19,12 +19,12 @@ public void onCreate(Bundle icicle) {

App app = (App)getApplication();

String html = "<b>KalSMS " + app.getPackageInfo().versionName + "</b><br /><br />"
+ "KalSMS is a SMS gateway.<br /><br /> "
String html = "<b>EnvayaSMS " + app.getPackageInfo().versionName + "</b><br /><br />"
+ "EnvayaSMS is a SMS gateway.<br /><br /> "
+ "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.<br /><br />"
+ "(See https://kalsms.net for more information.)<br /><br />"
+ "The Settings screen allows you configure KalSMS to work with a particular server, "
+ "The Settings screen allows you configure EnvayaSMS to work with a particular server, "
+ "by entering the server URL, your phone number, "
+ "and the password assigned to your phone on the server.<br /><br />"
+ "Menu icons cc/by www.androidicons.com<br /><br />";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.envaya.kalsms.ui;
package org.envaya.sms.ui;

// from http://www.marvinlabs.com/2010/10/custom-listview-ability-check-items/
// package fr.marvinlabs.widget;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.envaya.kalsms.ui;
package org.envaya.sms.ui;

import org.envaya.kalsms.task.HttpTask;
import org.envaya.sms.task.HttpTask;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -18,10 +18,10 @@
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.message.BasicNameValuePair;
import org.envaya.kalsms.App;
import org.envaya.kalsms.IncomingMms;
import org.envaya.kalsms.MmsUtils;
import org.envaya.kalsms.R;
import org.envaya.sms.App;
import org.envaya.sms.IncomingMms;
import org.envaya.sms.MmsUtils;
import org.envaya.sms.R;

public class Main extends Activity {

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.envaya.kalsms.ui;
package org.envaya.sms.ui;

import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
@@ -11,8 +11,8 @@
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.view.Menu;
import org.envaya.kalsms.App;
import org.envaya.kalsms.R;
import org.envaya.sms.App;
import org.envaya.sms.R;

public class Prefs extends PreferenceActivity implements OnSharedPreferenceChangeListener {

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.envaya.kalsms.ui;
package org.envaya.sms.ui;

import android.app.AlertDialog;
import android.app.ListActivity;
@@ -13,8 +13,8 @@
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import org.envaya.kalsms.App;
import org.envaya.kalsms.R;
import org.envaya.sms.App;
import org.envaya.sms.R;

public class TestPhoneNumbers extends ListActivity {