Active Topics

 


Reply
Thread Tools
Posts: 1,425 | Thanked: 983 times | Joined on May 2010 @ Hong Kong
#11
LOL, you got a real fast phone app! I don't have that problem.

Let me see if there's a way to delay the ring...
 
Posts: 1,425 | Thanked: 983 times | Joined on May 2010 @ Hong Kong
#12
Strange....while I've tested the script under all loading condition, it can still pickup the correct ringtone to play. I can't seem to reproduce the race condition you've experienced.

Let me check the dbus documentation again.
 
Posts: 1,425 | Thanked: 983 times | Joined on May 2010 @ Hong Kong
#13
Though I still couldn't reproduce Matan's race condition, but may be running a compiled version would help. Anyway.

I made a slight modification to the script, including call-blocking function. I know there's already pycallblocker around for use, but I think some people would like it to be incorporated into one.

I'm still working on pelago's suggestion on using contact list and making UI(my weakest part), but for the time being just edit the script if you need to use it. ^^

Code:
#! /usr/bin/env python2.5
#
# callergroup - Assign Ringtone By Caller-Group for N900 v0.0.2
# By 9000 @ maemo.org/phonehk.com 14-May-2010
#
# ATTENTION: Use the script at your own risk. You're responsible for any damage that'd cause by using this script.
# LIMITATION: Lots. Like lacking fancy UI,  insufficient format support (WAV only), etc. 
# FEATURE: 1) Assign different ringtones to caller-groups you defined. 2) Block calls
# CHANGELOG: 18-May-2010: Add blocking function
#
# Usage: 
# 1) Move your default ringtone to /home/user/.local/share/sounds/callergroup/ , I choose Gradient.acc.wav in this example
# mkdir -p /home/user/.local/share/sounds/callergroup/
# mv /home/user/.local/share/sounds/Gradient.acc.wav /home/user/.local/share/sounds/callergroup/.
#
# 2) Symlink your default ringtone back to /home/user/.local/share/sounds/ , Gradient.aac.wav in this example
# ln -sf /home/user/.local/share/sounds/callergroup/Gradient.aac.wav /home/user/.local/share/sounds/Gradient.aac.wav
#
# 3) Copy any wav files you'd like to set for the groups. I use ringtone_for_group_X.wav in this example
# cp /media/mmc1/ringtone/*.wav /home/user/.local/share/sounds/callergroup/. (just an example)
#
# 4) Customize the telephone number and ringtone file name in the CUSTOMIZATION section below
#
# 5) Run the script
# /usr/bin/python ./callergroup.py
# 


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+'...'

# Caller group found:
	if callernumber in group_info:
		assigned_group = group_info[callernumber]
		group_ring = group_ringtones[assigned_group]
		print 'Caller belongs to Group:'+assigned_group+', ringtone assigned:'+group_ring+'.wav'
		bus = dbus.SessionBus()
		profiled = bus.get_object('com.nokia.profiled', '/com/nokia/profiled')
		proxy = dbus.Interface(profiled, 'com.nokia.profiled')
		system_ring = os.path.basename(proxy.get_value('general','ringing.alert.tone'))
		os.system('ln -sf /home/user/.local/share/sounds/callergroup/'+group_ring+'.wav /home/user/.local/share/sounds/'+system_ring+'.wav')

# Call blocking:
	elif callernumber in blocklist:
		print 'Caller from '+callernumber+' blocked'
		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()

# Default:
	else:
		print 'Caller has no assigned group'
		bus = dbus.SessionBus()
		profiled = bus.get_object('com.nokia.profiled', '/com/nokia/profiled')
		proxy = dbus.Interface(profiled, 'com.nokia.profiled')
		system_ring = os.path.basename(proxy.get_value('general','ringing.alert.tone'))
		os.system('ln -sf /home/user/.local/share/sounds/callergroup/'+system_ring+'.wav /home/user/.local/share/sounds/'+system_ring+'.wav')

# ---CUSTOMIZATION--- #

# The telephone numbers to block
blocklist = ["11709394","53540997"]

# Change the name of the ringtones for the corresponding groups
group_ringtones = {	'GroupA':'ringtone_for_group_a',
			'GroupB':'ringtone_for_group_b',
			'GroupC':'ringtone_for_group_c',
			}

# Associate the telephone numbers to the groups
group_info = {	'77777777':'GroupA',
		'88888888':'GroupB',
		'12345678':'GroupB',
		'87654321':'GroupC',
		}

# ---END OF CUSTOMIZATION--- #  

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()
Source Reference:
http://maemocentral.com/2010/02/22/h...s-on-the-n900/
http://www.maemoers.com/archiver/tid-2364.html
Attached Files
File Type: zip callergroup.zip (1.4 KB, 353 views)

Last edited by 9000; 2010-05-24 at 15:53.
 

The Following 7 Users Say Thank You to 9000 For This Useful Post:
Posts: 267 | Thanked: 183 times | Joined on Jan 2010 @ Campinas, SP, Brazil
#14
Bump this thread! Has anyone tried it with PR1.2? I hope this script rapidly evolves to a 'ringtone by contact group' app!
__________________
My nickname on freenode is ptl, that is, the consonants of my nickname here. Kind of a long story.
 
Posts: 200 | Thanked: 15 times | Joined on Dec 2009 @ São Paulo - Brasil
#15
Originally Posted by Patola View Post
Bump this thread! Has anyone tried it with PR1.2? I hope this script rapidly evolves to a 'ringtone by contact group' app!
Me too!!! Pleeeeeeeeeeease!!!
 
Posts: 1,425 | Thanked: 983 times | Joined on May 2010 @ Hong Kong
#16
I used PR1.2 from start so I guess it'd work for your PR1.2 as well.

Just that if you've real fast CPU (or real slow phone app) there's race condition as described by other posters above.

I wish I had time to improve the script. Any suggestion is welcome. ^^

Last edited by 9000; 2010-06-11 at 02:32.
 
Posts: 24 | Thanked: 10 times | Joined on Jun 2010
#17
i suggest you use a variable to record the default ringtone info.
becase use DBUS object to detect info should be slow.
sorry for my poor english.
 

The Following User Says Thank You to colakang For This Useful Post:
Posts: 1,425 | Thanked: 983 times | Joined on May 2010 @ Hong Kong
#18
Originally Posted by colakang View Post
i suggest you use a variable to record the default ringtone info.
becase use DBUS object to detect info should be slow.
sorry for my poor english.
Thanks! Actually I'd rather put it on hold rather than race with it....suggestion to hold the phone call is also welcome. ^^
 
Posts: 195 | Thanked: 102 times | Joined on Feb 2010 @ Vancouver, Canada
#19
mp3 ringtones (and alarm tones) have crackling sounds with the n900 anyways, haven't you guys noticed this problem?

https://bugs.maemo.org/show_bug.cgi?id=6784
 
Posts: 1,425 | Thanked: 983 times | Joined on May 2010 @ Hong Kong
#20
No.

You may open a new thread for this. Specify clearly the firmware version you're using would help.
 
Reply


 
Forum Jump


All times are GMT. The time now is 16:30.