×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Detecting incoming call

    I want to use an incoming call as event. For example: i have running my script in background and when I recive a call my script do something, for example mute volume.

    I find this: CallStatus module wich returns value 0 to 9 (0 = callNone , 1= callVoice, 2 = callFax, 3 = callData, 4 = callAlerting, 5 = callRinging, 6 = callAlternating, 7 = callDialling, 8 = callAnswering, 9 = callDisconnecting ). Making an infitite loop waiting call.

    I know that there is a thelephone module in standar pys60 that has incoming_call() function but I don't know hot to use it.

    THANKS!!!!

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Detecting incoming call

    If you want to trigger an action when a call is received, I suggest you do this:
    -If you are waiting for a call that needs to be answered, use telephone.call_state(callback_function) to wait for a change in the phone's status, and if that change is that the call is connected, perform the action.
    -The same applies for a call that isn't necessarily answered, just that the new state isn't "connected", it's "ringing".

    Examples will help you understand better.

    For the answered incoming call:
    Code:
    import telephone, e32, appuifw, logs
    
    def quit():a.signal()
    appuifw.app.exit_key_handler=quit
    
    def handle_incoming_call(state):print "incoming call answered"
    
    def cb(state):
    	if(state[0]==telephone.EStatusConnected):
    		if(float(logs.calls(mode='in')[0]["time"])>float(logs.calls(mode='out')[0]["time"])):handle_incoming_call(state)
    
    '''You have to check the logs in order to see if the most recent call was incoming or outgoing
    as EStatusConnected is for both'''
    
    telephone.call_state(cb)
    
    a=e32.Ao_lock()
    a.wait()
    For the ringing incoming call:
    Code:
    import telephone, e32, appuifw, logs
    
    def quit():a.signal()
    appuifw.app.exit_key_handler=quit
    
    def handle_incoming_call(state):print "incoming call ringing"
    
    def cb(state):
    	if(state[0]==telephone.EStatusRinging):handle_incoming_call(state)
    
    telephone.call_state(cb)
    
    a=e32.Ao_lock()
    a.wait()
    Last edited by bogdan.galiceanu; 2008-05-30 at 20:02. Reason: Typo

  3. #3
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Re: Detecting incoming call

    Ok it works perfect

    But I only nedd one more thing. When I detect a call incoming I want to mute the phone. I think simulate a keypress (rigth selection wich mute sound) I've found keypress module but needs to be signed.

    Other option is get down volume and get up when call finish.

    Any other Idea? Thank you again.

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Detecting incoming call

    You could do the simulation of the key, or you could use Cyke64's xprofile module to change the current profile to Silent, and once the call is over, you can change it back to General (or whatever profile was active). Here's a thread with more information.

    Hope that helps

  5. #5
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Re: Detecting incoming call

    Ok, but an I change profile while I'am reciving a call? I think no, but I'm not sure.

    Thanks
    Last edited by manugarrote; 2008-05-31 at 16:28.

  6. #6
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Re: Detecting incoming call

    I take your code, insert my "imports" and changed this "def handle_incoming_call(state):" for run my code, but programs doen't work. Could you take a look my code?

    Dowload here. My code + detct incoming call (doen't work):
    http://www.mediafire.com/?dneyy2tyeyb

    Only mi code. (It works all time, I want it only works since a call is coming):
    http://www.mediafire.com/?ye329xnvo0z

    THANK YOU!!!

  7. #7
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Detecting incoming call

    It would be better if you could tell us what exactly the problem is (by that I mean do you get errors, or just nothing happens?) and where it occurs, if you can find out.

    I noticed you didn't import audio in the version you said doesn't work. Also, and this is not a problem right now but you should fix it, your quit functions are different. I suggest you make it like this:
    Code:
    def quit():
       global running
       running=0
       a.signal()

  8. #8
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Re: Detecting incoming call

    Audio module is not required I forget remove it from MID9.py file.

    The probles is that nothing happends. I execute my program, nothing happends (it's ok because only sould happends things reciving call), i call my phone but now, when sould launch my code, nothing happends. I don't know if it's because my coden isn't launched or if now my cado don't works.

    Thanks

  9. #9
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,800

    Re: Detecting incoming call

    Quote Originally Posted by manugarrote View Post
    Audio module is not required I forget remove it from MID9.py file.

    The probles is that nothing happends. I execute my program, nothing happends (it's ok because only sould happends things reciving call), i call my phone but now, when sould launch my code, nothing happends. I don't know if it's because my coden isn't launched or if now my cado don't works.

    Thanks
    I can't make out from your code what exactly you want to achieve with it. I guess you want to make the ring silent when there is an incoming call,

    So doesn't the below code work for you?

    Code:
    import telephone, e32, appuifw, logs
    
    from key_codes import * 
    import keypress
    
    def quit():
    a.signal()
    appuifw.app.exit_key_handler=quit
    
    def handle_incoming_call(state):
    	keypress.simulate_key(EKeyRightSoftkey,EKeyRightSoftkey)  
    
    def cb(state):
    	if(state[0]==telephone.EStatusRinging):handle_incoming_call(state)
    
    telephone.call_state(cb)
    
    a=e32.Ao_lock()
    a.wait()
    Best Regards,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  10. #10
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Re: Detecting incoming call

    Yes I want to do this. But my code detects movement over frontal cámera, an if movement is detected silent phone. So I want that when phone is ringing activate my program with detecs if there is movement, if movement is detected ring is silent.

    My code works, but I want it to be activated only during a call.

    Thanks.

Similar Threads

  1. Replies: 1
    Last Post: 2007-08-07, 11:00
  2. Replies: 2
    Last Post: 2007-05-11, 23:11
  3. how to simulate incoming call event in Emulator?? egent !!
    By wjcrr in forum Series 40 & S60 Platform Feedback Archive
    Replies: 0
    Last Post: 2007-05-11, 03:58
  4. Active Objects & Incoming Call Problem
    By jguzman in forum Symbian
    Replies: 5
    Last Post: 2007-03-21, 22:01
  5. Replies: 3
    Last Post: 2006-12-14, 06:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×