Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

<cj> Able to post the msg to a specified url

  • Loading branch information...
commit e3656963480531ead724c5360bafac5fae906d51 1 parent 59ee5d2
@chandanjog authored
View
BIN  bin/EzSms-debug-unaligned.apk
Binary file not shown
View
BIN  bin/EzSms-debug.apk
Binary file not shown
View
2  bin/LAST_UPDATE
@@ -1 +1 @@
-2012-03-12T21:23:31+05:30
+2012-03-13T23:19:18+05:30
View
2  bin/build.prop
@@ -1,5 +1,5 @@
#Last build type
-#Mon, 12 Mar 2012 21:23:31 +0530
+#Tue, 13 Mar 2012 23:19:18 +0530
build.last.target=debug
View
47 src/message_receiver.rb
@@ -1,20 +1,44 @@
require 'ruboto/broadcast_receiver'
import "android.util.Log"
import "android.telephony.SmsMessage"
+import "java.util.ArrayList"
+import "java.util.List"
+import "org.apache.http.HttpEntity"
+import "org.apache.http.HttpResponse"
+import "org.apache.http.HttpStatus"
+import "org.apache.http.NameValuePair"
+import "org.apache.http.client.ClientProtocolException"
+import "org.apache.http.client.HttpClient"
+import "org.apache.http.client.entity.UrlEncodedFormEntity"
+import "org.apache.http.client.methods.HttpPost"
+import "org.apache.http.client.methods.HttpGet"
+import "org.apache.http.client.utils.URLEncodedUtils"
+import "org.apache.http.impl.client.DefaultHttpClient"
+import "org.apache.http.message.BasicNameValuePair"
+import "org.apache.http.util.EntityUtils"
# will get called whenever the BroadcastReceiver receives an intent (whenever onReceive is called)
-identifier = "EZSMS"
-targetURL = "localhost:3000"
+$identifier = "EZSMS"
+$target_url = "http://192.168.1.4:3000/response/123/EZSMS"
RubotoBroadcastReceiver.new_with_callbacks do
def on_receive(context, intent)
messages = get_messages_from_intent(intent)
messages.each do |sms|
- Log.v "SMS_BODY", sms.get_display_message_body()
- Log.v "SMS_SENDER", sms.get_display_originating_address()
+
+ msg_body = sms.get_display_message_body()
+ msg_sender = sms.get_display_originating_address()
+ Log.v "SMS_GW", msg_body
+ Log.v "SMS_GW", msg_sender
+ Log.v "SMS_GW", $identifier
+ Log.v "SMS_GW", $target_url
+ Log.v "SMS_GW", msg_body.include?($identifier).to_s
+
+ if(msg_body.include?($identifier))
+ forward_msg(msg_sender, msg_body, $target_url)
+ end
end
- #Log.v "MYAPP", intent.getExtras.to_s
end
def get_messages_from_intent(intent)
@@ -26,5 +50,18 @@ def get_messages_from_intent(intent)
messages
end
+ def forward_msg(sender, body, target_url)
+ Log.v "SMS_GW", "In forward msg"
+ params = ArrayList.new
+ params.add(BasicNameValuePair.new("phone_number",sender))
+ params.add(BasicNameValuePair.new("comment",body))
+ post = HttpPost.new(target_url)
+ post.set_entity(UrlEncodedFormEntity.new(params))
+ client = DefaultHttpClient.new
+
+ response = client.execute(post)
+
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.