Make PyneoControl.gsm_dial() work as expected

Add PyneoControl.gsm_hangup()



git-svn-id: http://www.neo1973-germany.de/svn@121 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
Abraxa 2008-09-02 23:33:27 +00:00
parent ce0260dbc1
commit 6f254d30e6

View file

@ -129,6 +129,7 @@ class PyneoController(object):
_gsm_timer = None
_keyring_timer = None
_callbacks = {}
_calls = {}
gsm = None
gsm_wireless = None
@ -235,12 +236,27 @@ class PyneoController(object):
@classmethod
def gsm_dial(class_, number):
os.system('alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state restore')
name = class_.gsm_wireless.Initiate(number, dbus_interface=DIN_VOICE_CALL_INITIATOR, timeout=200)
class_.notify_callbacks("gsm_dialing")
time.sleep(20)
name = class_.gsm_wireless.Initiate(number, dbus_interface=DIN_VOICE_CALL_INITIATOR, timeout=200)
call = object_by_url(name)
call.Hangup(dbus_interface=DIN_CALL)
# Initialize "active call" counter
class_._calls[call] = 1
class_.notify_callbacks("gsm_dialing")
@classmethod
def gsm_hangup(class_, number):
# Find call with highest "active call" counter - it'll be the one currently active
call = None
highest = 0
for (call_obj, counter) in class_._calls.items():
if counter > highest:
highest = counter
call = call_obj
if call: call.Hangup(dbus_interface=DIN_CALL)
@classmethod
def on_gsm_wireless_status(class_, status_map):
@ -248,7 +264,7 @@ class PyneoController(object):
class_.gsm_net_status = status
print "GSM NET Status: " + str(status)
if status.has_key('stat'):
if status.has_key('stat'):
nw_status = status['stat']
if nw_status == 0: