Active Topics

 


Reply
Thread Tools
Posts: 6 | Thanked: 2 times | Joined on Jun 2010 @ Sweden
#1
Please give me some feedback on my code, hope you have some useful tips, first time i using python :-)

Why:
I wanted to know who was calling even if i didn't have them in my abook.

So far:
I got a python script, that lisen for incoming calls on dbus.

When it gets a number it ask my webserver for the name of that number (my server ask a few swedish sites for the name of the number) and return the name to python

Python then makes a Notification whit the name.

Left to do:
* Id like this to be run in background somehow, having it in a terminal work nice for debuging, but i prefer somthing less visible later.
* The notification is showing a icon, a paper whit a red X, id like to repalce this icon.
* When i click the notification, somthing should happen, but i don't know what id like it to yet.

Code:
Code:
#! /usr/bin/env python2.5
# -*- coding: utf-8 -*-

import gobject, dbus
import time
import os
from dbus.mainloop.glib import DBusGMainLoop

def handle_call(obj_path, callernumber):
	global blocklist
	print 'Calling from '+callernumber+'...'
	import urllib
	webFile = urllib.urlopen('http://nummer.tejpweb.se/nummer/?nummer='+callernumber)
	name = webFile.read()
	print name + ' is calling.'
	import pynotify
	pynotify.init( name )
	n = pynotify.Notification(name, "Call from " + name)
	n.set_urgency(pynotify.URGENCY_CRITICAL)
	n.show()

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()
 

The Following User Says Thank You to puggan For This Useful Post:
Posts: 4 | Thanked: 1 time | Joined on Jun 2010
#2
Hi,

I'm looking forward following the thread hopefully learning a bit of python.. I made some similar efforts myself a couple of weeks ago.

picked up some code from the python callblocker script.
and parsed eniro.se. then i got stuck on using urllib as I'm a newbie py




Rgrds,
oakbeach
 
ToJa92's Avatar
Posts: 1,091 | Thanked: 323 times | Joined on Feb 2010 @ ~
#3
Wow, this could prove useful since I also live in Sweden
I'll be monitoring this thread.
 
Posts: 6 | Thanked: 2 times | Joined on Jun 2010 @ Sweden
#4
Originally Posted by ToJa92 View Post
Wow, this could prove useful since I also live in Sweden
I'll be monitoring this thread.
at my server Im using hitta,se and vemringde.se as source, and a cache on my server, your welcome to use my server as source to.

hope i can learn some of what lirtex was doing on the same subject:
http://talk.maemo.org/showthread.php?t=56088

Originally Posted by lirtex View Post
What I did so far:
  1. Created a daemon that detects incoming calls.
  2. The daemon then checks if the incoming call number exists in the phone contacts.
  3. If it isn't -- it gets the number identification from the net (using libcurl).
Id like to use 1 and 2 above in my project to.
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#5
Originally Posted by puggan View Post
* The notification is showing a icon, a paper whit a red X, id like to repalce this icon.
* When i click the notification, somthing should happen, but i don't know what id like it to yet.
Code:
#! /usr/bin/env python2.5
# -*- coding: utf-8 -*-

import os
import sys
import gobject, dbus
import pynotify
from dbus.mainloop.glib import DBusGMainLoop

def cb (Notification=None, action=None, Data=None):
	pass

DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
pynotify.init(os.path.splitext(os.path.basename(sys.argv[0]))[0])
n = pynotify.Notification("Mail, mother****er!", "Call from Beelzebub", "general_clock")
n.set_hint_string("dbus-callback-default", "com.nokia.osso_browser /com/nokia/osso_browser com.nokia.osso_browser open_new_window string:\"callto://666\"")
n.add_action("default", "call", cb)
n.show()
Alas, Hildon Desktop is incredibly stupid and will only call services registered on the Session bus, so I had go through the browser.
 
Posts: 958 | Thanked: 483 times | Joined on May 2010
#6
on a related note, does anyone know how to capture dbus events and have it trigger a shell script? this could be easily done on N900. is there a similar directory where i can install a shell script that gets called during dbus events?
 
Reply

Tags
caller, d-bus, online, python


 
Forum Jump


All times are GMT. The time now is 20:22.