×
Namespaces

Variants
Actions

Archived:Delete Spam SMS using PySymbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.


Article Metadata
Article
Created: girishpadia (04 Mar 2011)
Last edited: hamishwillee (08 May 2013)

Contents

Introduction

Have you receive any SMS at midnight while you are in deep sleep? Have you receive any SMS while you are important meeting and you lose your concentration? Are you receiving SMSes which are no use at all for you? Are you receiving SMS with the irritating contents in it? If any of the above question’s answer is YES then you are suffering of the SPAM SMSes. Please see the below contents about SMS spam from the popular site “Wikipedia”

“Fighting SMS spam is complicated by several factors, including the lower rate of SMS spam (compared to more abused services such as Internet email) has allowed many users and service providers to ignore the issue, and the limited availability of mobile phone spam-filtering software”

The SMS spam rate is lower but it may increase as the mobile user increases throughout the world. It is useless to wait from the network service provider to take necessary action on this issue when we have lots of programming weapons in our mobile to fight against the SMS SPAM. One can come out with more dedicated work and continuous efforts on this issue. I have made a small effort here to avoid SMS spam using a simple python program. Let’s see what’s there inside.

How the program works

The program is very simple. I have given two options for SMS spam removal. One is to add a Name/Number into the SPAM list and another is to run SPAM SMS. As soon as the name/number you add in the SPAM list, the name/number is saved into a text file in the mobile storage device. The text file will be created automatically if not exists. Now run the second option to start SPAM SMS. It will monitor every incoming SMS, will check the address of sender, compare it with each value in the text file and if it doesn’t match with any values in the text file then it will be welcomed into inbox. But, if the sender is in our spammer list, it will be punishment by deleting the SMS. Before deleting the SMS, a log is created showing which spam SMSes are deleted so that you can review it whenever you wish.

Requirement

You need to install PySymbian in your mobile in order to run the program. There are several articles available about how to download and install it. Once you do this create a simple text file “vote.txt” on the path shown in the program. Create four lines in the program with initial values as 0.

Tested on device

This python program is tested on Nokia 5230.

Various options available

I have used simple text file reading or writing the spam SMS list. However one can use e32db or e32dbm to make it more structured.

Python Code

#import necessary libraries
import appuifw,inbox,e32,messaging,time
 
spammar=""
# setting the application title
appuifw.app.title = u"SPAM SMS Blocker"
 
mylist = [u"Add a SPAM Number/Name",u"Start SPAM Blocker",u"Exit"]
 
 
def message_received(msg_id):
global spammer
box=inbox.Inbox()
 
msg=box.sms_messages()
time.sleep(0.5)
print box.address(msg[0])
spam_adddress = box.address(msg_id)
 
f=open('e:\data\python\spammer.txt','r') #opens a file into read/write mode
#data=f.readline()
#print data
# print "Msg Received from ",box.address(msg_id)
while True:
data= f.readline()
if data.strip() == spam_adddress.strip():
fs=file(u"e:\\data\\python\\spam_log.txt","a+")
print >> fs,"Spam Message deleted from : ",spam_adddress
box.delete(msg_id)
 
while True:
 
index = appuifw.popup_menu(mylist,u"Select")
if index==2:
break
if index==0:
spammer = appuifw.query(u"Type SPAM Number/Name:", "text")
f=open('e:\data\python\spammer.txt','a+') #opens a file into read/write mode
print >> f,spammer
f.close()
if index==1:
box = inbox.Inbox()
box.bind(message_received)
appuifw.app.exit_key_handler = quit
print "SPAM SMS Filter is ON"
 
app_lock = e32.Ao_lock()
app_lock.wait()

Post Condition

Adding spam number from menu

Delspam1.jpg Delspam2.jpg

SPAM filter is ON

After spam filter is on script will automatically delete the SMS received from the spammer saved in our spam list.

Delspam3.jpg






Sample log file of SPAM delete SMS

Delspam4.jpg

This page was last modified on 8 May 2013, at 05:15.
51 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×