Update: This article is outdated, you can download a pre-packaged Callblocker package based on the code on this page from the Maemo Garage – https://garage.maemo.org/projects/callblocker/ . You can the deb file from the project page and install it on your N900.
Something which I really missed on the N900 was a good call blocking software. After being hounded day after day by credit card sales people and people trying to give me low interest loans, I had to find a way to get this done. A bit of hunting on the web and picking up a little bit of Python, I hacked a working solution to this problem. It’s not a perfect solution, and is a hack job, but it should do till someone writes up a good application to handle unwanted callers.
Step 1: Install Dependencies on your phone
Before we go to the call block script, you’ll need to install a few apps on your phone. First you’ll need to gain root access to your phone, so head over to your App Manager and install rootsh. If you can’t find it in your app manager, head over to this URL and download rootsh – maemo.org/downloads/product/Maemo5/rootsh/
If you haven’t installed a Python application in your phone, you’ll have to install the Python runtimes on your device. If you haven’t installed the extras-devel repositories, check for the Maemo 5 instructions here – pymaemo.garage.maemo.org/installation_device.html. Once you have that repository installed on your phone, search and install maemo-python-device-env to install python.
Step 2: Download and move the Script to your phone
Once that’s installed, download this zip file and extract the python script from the file and save this file your device under Nokia N900/ as callblock.py .
[ad#ga-480-break]
Step 3: Create the Block list with numbers you’d like to block
Before running this script, you’ll need to create a text file with the numbers you need to block. Add as many numbers you’d like to block on a new line. The file contents should like like below:
+918067337555
+918067348300
+918066167590
Save this file as BlockedCallers.txt in the same location you saved the call block script. Please enter the numbers in the format you see when you get the calls, so you needn’t enter it exactly as I’ve put it up.
Step 4: Run the script on your phone
Now to start the call block script, head over to the terminal, get into the root mode by entering the following:
root
and then start the callblock application and background it:
python /home/user/MyDocs/callblock.py &
Make sure you type the command as is, with the capitalizations in MyDocs typed in, or the command will fail.
Now you’ve got the script running on your phone in the background and you can close the Terminal window. Your phone will block any calls with the numbers you’ve saved in the BlockedCallers.txt file. Anytime you want to change the numbers, you’ll have to edit the BlockedCallers.txt text file and add numbers into it. You’ll have to restart the script to get the latest edits to your block numbers active.
Also when ever you restart the phone, you’ll have to follow the last steps to restart the call block application. So remember when you restart the phone, make sure you go to the terminal and enter the following two lines into it:
root
python /home/user/MyDocs/callblock.py &
I’ve been trying to figure out how to auto-start this script, but I haven’t been successful at that yet. I’ll update you as soon as I figure that one out.
If you have more tips on how to improve this script, or know how to autostart the script when the phone boots up, let us know by commenting on this post.
Links:
Click to download the script file: Here’s the zip file with the callblock script. Download it and extract callblock.py from the zip file. Edit the number to block in the file by opening it up in a text editor and move the saved file over to your device.
Link to Python Doc (and sources) I went though and borrowed to build this example:
PyMaemo/Phone call and SMS examples
Image Credit: via hoyasmeg on flickr
Disclaimer: We are providing this script as it, without much support. I’ve tested this for a few days on my phone and it worked as expected without any issues. We’re not responsible for any problems you may face using this script.
Awesome work sir!
Awesome work sir!
Something I miss is the contrary, auto answer.
been trying with python api but get permission denied calling .Answer()
didn’t you try it with dbus?
Nope, didn’t try that out yet.
hi vinu thomas this is barath
in my n900 catblock is not working. when i try to uninstall it i couldnt. please help me how to solve it. i am not well versed in computing. so please let me know the procedure in simpler way.
All you need to do to uninstall is to remove the files which you placed on the phone and do a quick restart of the phone.
The easiest way to install it to get the deb files which one of the developers created, and install that on the phone. Check for more information here – http://talk.maemo.org/showthread.php?t=46333
There is a script to auto answer – check out the thread http://talk.maemo.org/showthread.php?t=64444
Something I miss is the contrary, auto answer.
been trying with python api but get permission denied calling .Answer()
didn’t you try it with dbus?
Nope, didn’t try that out yet.
Great stuff! :D
It would be even better to read those numbers from a simple text file, so that one doesn’t need to mess with the script each time he wants to add a new number… considering Python is whitespace-sensitive, it’s very easy to break a script. Also, I don’t see the point in looping through the list on each call :)
I’d make it something like this (let’s hope this comment system respects whitespace…):
#! /usr/bin/python
import os
import gobject, dbus
from dbus.mainloop.glib import DBusGMainLoop
blocklistFile = ‘/home/user/MyDocs/BlockedCallers.txt’
def handle_call(obj_path, callernumber):
global blocklist
if callernumber in blocklist:
print ‘I have to block %s’ %callernumber
bus = dbus.SystemBus()
callobject = bus.get_object(‘com.nokia.csd.Call’, ‘/com/nokia/csd/call/1’)
smsiface = dbus.Interface(callobject, ‘com.nokia.csd.Call.Instance’)
smsiface.Release()
blocklist = []
if os.path.exists(blocklistFile):
try:
blFile = open(blocklistFile,’rb’)
blocklist = [num.strip() for num in blFile.readlines()]
blFile.close()
except Exception:
print “Blocklist missing, should be at ” + blocklistFile
DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
bus.add_signal_receiver(handle_call, path=’/com/nokia/csd/call’, dbus_interface=’com.nokia.csd.Call’, signal_name=’Coming’)
gobject.MainLoop().run()
Great stuff! :D
It would be even better to read those numbers from a simple text file, so that one doesn’t need to mess with the script each time he wants to add a new number… considering Python is whitespace-sensitive, it’s very easy to break a script. Also, I don’t see the point in looping through the list on each call :)
I’d make it something like this (let’s hope this comment system respects whitespace…):
#! /usr/bin/python
import os
import gobject, dbus
from dbus.mainloop.glib import DBusGMainLoop
blocklistFile = ‘/home/user/MyDocs/BlockedCallers.txt’
def handle_call(obj_path, callernumber):
global blocklist
if callernumber in blocklist:
print ‘I have to block %s’ %callernumber
bus = dbus.SystemBus()
callobject = bus.get_object(‘com.nokia.csd.Call’, ‘/com/nokia/csd/call/1’)
smsiface = dbus.Interface(callobject, ‘com.nokia.csd.Call.Instance’)
smsiface.Release()
blocklist = []
if os.path.exists(blocklistFile):
try:
blFile = open(blocklistFile,’rb’)
blocklist = [num.strip() for num in blFile.readlines()]
blFile.close()
except Exception:
print “Blocklist missing, should be at ” + blocklistFile
DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
bus.add_signal_receiver(handle_call, path=’/com/nokia/csd/call’, dbus_interface=’com.nokia.csd.Call’, signal_name=’Coming’)
gobject.MainLoop().run()
@Giacomo Thanks for the improved script. the comment system stripped out the whitespaces. I’ll update the artice with your improved script.
@Giacomo Thanks for the improved script. the comment system stripped out the whitespaces. I’ll update the artice with your improved script.
Anyone try to do this with sms’s ?
to blacklist sms and copy it to some .txt file or other sms folder?
Any battery issues with running this script ?
thanks
Anyone try to do this with sms’s ?
to blacklist sms and copy it to some .txt file or other sms folder?
Any battery issues with running this script ?
thanks
what happens to the callers of the blocked calls? do they get a busy ringtone or get diverted to voicemail?
They get a busy tone if you don’t have voicemail divert setup.
what happens to the callers of the blocked calls? do they get a busy ringtone or get diverted to voicemail?
They get a busy tone if you don’t have voicemail divert setup.
It works! Although one thing is annoying: it still shows a call missed dialog – it would be nice if this could be ignored as well!
It works! Although one thing is annoying: it still shows a call missed dialog – it would be nice if this could be ignored as well!
any one can help me i have done all the step to block call when i will do final step to run application
root
python /home/user/MyDocs/callblock.py &
nothing is doing no application is starting i am still in x-terminal application
Once you run python /home/user/MyDocs/callblock.py & in the terminal, the application is already running in the background. Any calls from numbers you had listed in the text file will automatically be blocked.
any one can help me i have done all the step to block call when i will do final step to run application
root
python /home/user/MyDocs/callblock.py &
nothing is doing no application is starting i am still in x-terminal application
Once you run python /home/user/MyDocs/callblock.py & in the terminal, the application is already running in the background. Any calls from numbers you had listed in the text file will automatically be blocked.
Regarding automation, you maybe able to use SES (like cron and @reboot). See here: http://maemo.org/packages/package_instance/view/fremantle_extras-devel_free_armel/ses/0.2.2-1/
Thanks will try that out.
Regarding automation, you maybe able to use SES (like cron and @reboot). See here: http://maemo.org/packages/package_instance/view/fremantle_extras-devel_free_armel/ses/0.2.2-1/
Thanks will try that out.
how can I block anonyous calls?
how can I block anonyous calls?
The script works with only one problem, how do I remove the block for a number. I tried editing the BlockedCallers.txt file and even rebooting the phone but this does not solve the problem
@George, Which version of the script did you use, the older one or the new one posted above?
If you installed the older version, the numbers to block are in the callblock.py itself. So you’ll have to remove it from there.
If you are using the newer one, try this:
1. Shutdown the phone.
2. Start it up
3. See if the call block has been removed. It should at this point, since the callblock script is not yet active.
4. Start the call block script now and see if the number you removed is still blocked. If it is, send me a copy of the script you are using to vinuthomas(at)mynokiaworld.com
The script works with only one problem, how do I remove the block for a number. I tried editing the BlockedCallers.txt file and even rebooting the phone but this does not solve the problem
@George, Which version of the script did you use, the older one or the new one posted above?
If you installed the older version, the numbers to block are in the callblock.py itself. So you’ll have to remove it from there.
If you are using the newer one, try this:
1. Shutdown the phone.
2. Start it up
3. See if the call block has been removed. It should at this point, since the callblock script is not yet active.
4. Start the call block script now and see if the number you removed is still blocked. If it is, send me a copy of the script you are using to vinuthomas(at)mynokiaworld.com
If I figure out how to autostart the script, I could write a proper interface for it and put it up on garage.maemo.org. Is it ok for you ?
Yes, please do. That would be great if you could put that up. Makes things easier for all of us :)
It’s 99% ready and will go up on https://garage.maemo.org/projects/callblocker/ later today or tomorrow. I’ve written a proper GUI to edit the blacklist and enable/disable the blocklist on the fly. The only thing I’m missing is a way of dynamically reload the blocklist, at the moment it requires a reboot.
It’s up :) I’ve built a debian package that needs real testing, as I’ve done all the work in the scratchbox emulator until now.
The reloading issue was solved with a basic dbus service, so now adding / deleting numbers should be reflected on-the-fly, which I think is cool :)
I’ve got a few more features in mind (block specific contacts from addressbook etc)…
Tried download the deb files for the project and I was getting 0 byte files from the server. I tried to download from: https://garage.maemo.org/frs/?group_id=1404&release_id=3360
Mmmh, something went wrong with the upload in Google Chromium (?), I’ve just re-done it in Firefox, re-downloaded the file, and now the package seems fine.
The callblock functionality doesn’t seem to work on my phone with the build I downloaded. I can add and remove numbers but the calls don’t get blocked for some reason.
I’ve tried exiting the app and starting it again, and stil doesn’t block it.
I’ve added a bug on the tracker site regarding this.
If I figure out how to autostart the script, I could write a proper interface for it and put it up on garage.maemo.org. Is it ok for you ?
Yes, please do. That would be great if you could put that up. Makes things easier for all of us :)
It’s 99% ready and will go up on https://garage.maemo.org/projects/callblocker/ later today or tomorrow. I’ve written a proper GUI to edit the blacklist and enable/disable the blocklist on the fly. The only thing I’m missing is a way of dynamically reload the blocklist, at the moment it requires a reboot.
It’s up :) I’ve built a debian package that needs real testing, as I’ve done all the work in the scratchbox emulator until now.
The reloading issue was solved with a basic dbus service, so now adding / deleting numbers should be reflected on-the-fly, which I think is cool :)
I’ve got a few more features in mind (block specific contacts from addressbook etc)…
Tried download the deb files for the project and I was getting 0 byte files from the server. I tried to download from: https://garage.maemo.org/frs/?group_id=1404&release_id=3360
Mmmh, something went wrong with the upload in Google Chromium (?), I’ve just re-done it in Firefox, re-downloaded the file, and now the package seems fine.
The callblock functionality doesn’t seem to work on my phone with the build I downloaded. I can add and remove numbers but the calls don’t get blocked for some reason.
I’ve tried exiting the app and starting it again, and stil doesn’t block it.
I’ve added a bug on the tracker site regarding this.
hi,
first off kudos for the code =)
does anyone have an idea if it would be possible to block unknown numbers? simply i was to block all callers from phones that don’t release their call ID.
thanks
MrL
@MrL @Nicolas Will let you know when I figure that out.
@Giacomo any way to block calls without a number?
I don’t know :) but I put the request in the tracker and I’ll give it a go ( https://garage.maemo.org/tracker/index.php?func=detail&aid=5300&group_id=1404&atid=5183 ). To anyone reading this: please use the tracker at https://garage.maemo.org/tracker/?group_id=1404 to log feature requests and bugs.
When you receive a call from “Unknown number”, the parameter callernumber is actually an empty string. So, in order to block the calls from “Unknown number” you can check whether the length of callernumber is 0. I made this small change in the script and works just fine.
hi,
first off kudos for the code =)
does anyone have an idea if it would be possible to block unknown numbers? simply i was to block all callers from phones that don’t release their call ID.
thanks
MrL
@MrL @Nicolas Will let you know when I figure that out.
@Giacomo any way to block calls without a number?
I don’t know :) but I put the request in the tracker and I’ll give it a go ( https://garage.maemo.org/tracker/index.php?func=detail&aid=5300&group_id=1404&atid=5183 ). To anyone reading this: please use the tracker at https://garage.maemo.org/tracker/?group_id=1404 to log feature requests and bugs.
Allow only contacts number would be great feature, also some widget checking if the script is running or not… sometimes i reboot and i forget to run it… Great code, great work guys… thanks !!!
Allow only contacts number would be great feature, also some widget checking if the script is running or not… sometimes i reboot and i forget to run it… Great code, great work guys… thanks !!!
does this block messages too from the numbers?
If you want to start this automaticly.. Create file /etc/event.d/callblocker with next lines:
start on started hildon-desktop
stop on starting shutdown
console none
service
script
/etc/init.d/callblocker start
end script
And then file /etc/init.d/callblocker what have lines:
#! /bin/sh
#
# callBlocker callBlocker is caller blocker utility
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/python
NAME= CallBlocker
DESC=”advanced call blocker utility”
startdaemon () {
start-stop-daemon –start –quiet “[email protected]” –pidfile /var/run/$NAME.pid –exec ${DAEMON} — /home/user/MyDocs/callblock.py&
}
stopdaemon () {
start-stop-daemon –stop –quiet “[email protected]” –pidfile /var/run/$NAME.pid –exec ${DAEMON}
}
test -x $DAEMON || exit 0
set -e
case “$1” in
start)
echo -n “Starting $DESC: “
startdaemon
echo “${NAME}.”
;;
stop)
echo -n “Stopping $DESC: “
stopdaemon –oknodo
echo “${NAME}.”
;;
restart)
echo -n “Restarting $DESC: “
stopdaemon || true
sleep 1
startdaemon
echo “${NAME}.”
;;
# restart-if-running)
# echo -n “Stopping $DESC if it is running: “
# if start-stop-daemon –stop –quiet –pidfile /var/run/$NAME.pid –exec ${DAEMON} ; then
# echo “${NAME}.”
# echo -n “Restarting $DESC: “
# startdaemon
# echo “${NAME}.”
# else
# echo “(not running).”
# fi
# ;;
*)
N=/etc/init.d/$NAME
echo “Usage: $N {start|stop|restart}” >&2
exit 1
;;
esac
exit 0
Thanks Jussi. That really helped.
Hi Jussi, thanks heaps for the upstart script. Though i can manually run callblocker event upstart script by running “start callblocker”, but i am unable to get it running automatically on boot. I do have placed the 2 callblocker files in init.d and event.d resp. the py script is actually again named as callblocker.py. but i guess as long as this filename is update appropriately in the init.d start script, it should be fine right? initctl shows the presence of the callblocker. am not sure if there is anything to do about this Upstart thing. Please help.
Hello! I’m having some trouble on final step…
when I type
python /home/user/MyDocs/callblock.py &
my N900 give me:
==================
/home/user/ # python: can’t open file ‘/home/user/MyDocs/callblock.py’: [Errno 2] No such file or directory
==================
Sorry if this is dumb question, but I copied these files in many folders inside my N900 and it still doesn’t work…
thanks in advance
It looks like the file is copied to the wrong place. In any case, to make things easier for you you can download the packaged deb file from https://garage.maemo.org/frs/?group_id=1404&release_id=3364 and install it on your phone. That should get you this functionality.
Hello…
Incoming calls works fine… but how to block *outgoing* calls to one number? … or to short list of numbers?
Don’t you have something as simple as just download and it will start working? This is for dumb like me, who does not understand anything in programming
Hi you!can you show me the way to install rootsh in my nokia C5,pls!
rootsh is for the N900 and you can’t install it on the C5. Why do you want to install rootsh on the C5 ?
Hello, how do I block unknown incoming call? which character set txt?
sorry for my english …
UP!!!!!!!!!!!!!!!
plizz help !!!
How block unknown call ???????
to simbian have more soft to block calls and unknown call (option) !!!
whot simbols i need screen in BlockedCallers.txt ???
There’s new piece of software in extras-devel repository called ‘catblock’ – call and text blocker for maemo / n900. Actually in early development stage, but it works :)
Try changing the script adding “NOT” (if callernumber not in blocklist) and it start works as… Whitelist..:-)
I like this article! Will come again next time for sure, thank again
I got 2 problems, maybe some1 will be kind enough to respond and helps us out
1. Where is actually situated MyDocs
2. On qwerty keyboard isn`t any “&”, how can we get it?
All the best