Remove unneeded edje_cc comment at end of file
Make spaces between classes two lines long Add PyneoInterface singleton class Rename global TITLE constant to APP_TITLE Add initial callback structure, preparing GUI integration git-svn-id: http://www.neo1973-germany.de/svn@115 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
parent
fe4d2bb963
commit
8f99c6edd8
1 changed files with 139 additions and 61 deletions
|
@ -9,7 +9,7 @@ WIDTH = 480
|
||||||
HEIGHT = 640
|
HEIGHT = 640
|
||||||
FRAMETIME = 1.0 / 20
|
FRAMETIME = 1.0 / 20
|
||||||
FULLSCREEN = True
|
FULLSCREEN = True
|
||||||
TITLE = "epydial"
|
APP_TITLE = "epydial"
|
||||||
WM_INFO = ("epydial", "epydial")
|
WM_INFO = ("epydial", "epydial")
|
||||||
|
|
||||||
EDJE_FILE_PATH = "data/themes/default/"
|
EDJE_FILE_PATH = "data/themes/default/"
|
||||||
|
@ -35,6 +35,7 @@ from pyneo.sys_support import pr_set_name
|
||||||
|
|
||||||
from ConfigParser import SafeConfigParser
|
from ConfigParser import SafeConfigParser
|
||||||
|
|
||||||
|
|
||||||
class EdjeGroup(edje.Edje):
|
class EdjeGroup(edje.Edje):
|
||||||
def __init__(self, group_manager, group):
|
def __init__(self, group_manager, group):
|
||||||
|
|
||||||
|
@ -54,74 +55,30 @@ class EdjeGroup(edje.Edje):
|
||||||
|
|
||||||
self.size = group_manager.get_evas().size
|
self.size = group_manager.get_evas().size
|
||||||
|
|
||||||
|
|
||||||
class InCallScreen(EdjeGroup):
|
class InCallScreen(EdjeGroup):
|
||||||
def __init__(self, screen_manager):
|
def __init__(self, screen_manager):
|
||||||
EdjeGroup.__init__(self, screen_manager, INCALL_SCREEN_NAME)
|
EdjeGroup.__init__(self, screen_manager, INCALL_SCREEN_NAME)
|
||||||
|
|
||||||
|
def on_dbus_initialized(self):
|
||||||
|
print "Dbus is ready, says InCallScreen"
|
||||||
|
|
||||||
|
|
||||||
class MainScreen(EdjeGroup):
|
class MainScreen(EdjeGroup):
|
||||||
|
text = None
|
||||||
|
|
||||||
def __init__(self, screen_manager):
|
def __init__(self, screen_manager):
|
||||||
EdjeGroup.__init__(self, screen_manager, MAIN_SCREEN_NAME)
|
EdjeGroup.__init__(self, screen_manager, MAIN_SCREEN_NAME)
|
||||||
self.text = []
|
self.text = []
|
||||||
|
|
||||||
dbus_ml = e_dbus.DBusEcoreMainLoop()
|
def on_dbus_initialized(self):
|
||||||
self.system_bus = SystemBus(mainloop=dbus_ml)
|
print "Dbus is ready, says MainScreen"
|
||||||
|
|
||||||
ecore.timer_add(5, self.init_dbus)
|
def on_sim_pin_required(self):
|
||||||
|
print "SIM REQUIRED"
|
||||||
|
|
||||||
def init_dbus(self):
|
def on_gsm_ready(self):
|
||||||
try:
|
print "GSM READY"
|
||||||
self.gsm = object_by_url('dbus:///org/pyneo/GsmDevice')
|
|
||||||
self.wireless = object_by_url('dbus:///org/pyneo/gsmdevice/Network')
|
|
||||||
self.keyring = object_by_url('dbus:///org/pyneo/GsmDevice')
|
|
||||||
except Exception, e:
|
|
||||||
print e
|
|
||||||
#if not self.dbus_timer:
|
|
||||||
# self.dbus_timer = ecore.timer_add(2, self.init_dbus)
|
|
||||||
# We had an error, keep the timer running
|
|
||||||
#return True
|
|
||||||
|
|
||||||
# No error, all went well
|
|
||||||
#if self.dbus_timer: self.dbus_timer.stop()
|
|
||||||
# D-Bus is ready, let's init GSM
|
|
||||||
self.gsm_on()
|
|
||||||
|
|
||||||
def gsm_on(self):
|
|
||||||
try:
|
|
||||||
if self.gsm.GetPower('sample', dbus_interface=DIN_POWERED, ):
|
|
||||||
print '---', 'gsm device is already on'
|
|
||||||
else:
|
|
||||||
self.gsm.SetPower('sample', True, dbus_interface=DIN_POWERED, )
|
|
||||||
print '---', 'switching device on'
|
|
||||||
except Exception, e:
|
|
||||||
print e
|
|
||||||
#if not self.gsm_timer:
|
|
||||||
# self.gsm_timer = ecore.timer_add(5, self.gsm_on)
|
|
||||||
# We had an error, keep the timer running
|
|
||||||
#return True
|
|
||||||
# No error
|
|
||||||
#if self.gsm_timer: self.gsm_timer.stop()
|
|
||||||
# GSM ready, let's ask SIM PIN
|
|
||||||
self.sim_pin()
|
|
||||||
|
|
||||||
def sim_pin(self):
|
|
||||||
self.res = dedbusmap(self.keyring.GetOpened(dbus_interface=DIN_KEYRING))
|
|
||||||
if self.res['code'] != 'READY':
|
|
||||||
print '---', 'opening keyring'
|
|
||||||
self.part_text_set("numberdisplay_text", "Enter " + self.res['code'])
|
|
||||||
self.res = dedbusmap(self.keyring.GetOpened(dbus_interface=DIN_KEYRING))
|
|
||||||
else:
|
|
||||||
print '---', 'already authorized'
|
|
||||||
self.nw_register()
|
|
||||||
|
|
||||||
def nw_register(self):
|
|
||||||
self.nw_res = dedbusmap(self.wireless.GetStatus(dbus_interface=DIN_WIRELESS))
|
|
||||||
if not self.nw_res['stat'] in (1, 5, ):
|
|
||||||
print '---', 'registering to gsm network'
|
|
||||||
self.wireless.Register(dbus_interface=DIN_WIRELESS)
|
|
||||||
self.nw_res = dedbusmap(self.wireless.GetStatus(dbus_interface=DIN_WIRELESS))
|
|
||||||
else:
|
|
||||||
self.part_text_set("numberdisplay_text", "please dial")
|
|
||||||
print '---', 'already registered'
|
|
||||||
|
|
||||||
@edje.decorators.signal_callback("dialer_send", "*")
|
@edje.decorators.signal_callback("dialer_send", "*")
|
||||||
def on_edje_signal_numberkey_triggered(self, emission, source):
|
def on_edje_signal_numberkey_triggered(self, emission, source):
|
||||||
|
@ -160,8 +117,106 @@ class MainScreen(EdjeGroup):
|
||||||
call = object_by_url(name)
|
call = object_by_url(name)
|
||||||
call.Hangup(dbus_interface=DIN_CALL)
|
call.Hangup(dbus_interface=DIN_CALL)
|
||||||
|
|
||||||
|
|
||||||
|
class PyneoInterface(object):
|
||||||
|
_dbus_timer = None
|
||||||
|
_gsm_timer = None
|
||||||
|
_init_callbacks = None
|
||||||
|
_sim_pin_callback = None
|
||||||
|
_gsm_ready_callback = None
|
||||||
|
gsm = None
|
||||||
|
gsm_net = None
|
||||||
|
keyring = None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def register_init_callback(class_, callback):
|
||||||
|
try:
|
||||||
|
class_._init_callbacks.append(callback)
|
||||||
|
except AttributeError:
|
||||||
|
class_._init_callbacks = [callback]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def register_sim_pin_callback(class_, callback):
|
||||||
|
class_._sim_pin_callback = callback
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def register_gsm_ready_callback(class_, callback):
|
||||||
|
class_._gsm_ready_callback = callback
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def init(class_):
|
||||||
|
try:
|
||||||
|
class_.gsm = object_by_url('dbus:///org/pyneo/GsmDevice')
|
||||||
|
class_.gsm_net = object_by_url('dbus:///org/pyneo/gsmdevice/Network')
|
||||||
|
class_.keyring = object_by_url('dbus:///org/pyneo/GsmDevice')
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
print "XXXXXXX1 " + str(e)
|
||||||
|
if not class_._dbus_timer:
|
||||||
|
class_._dbus_timer = ecore.timer_add(5, class_.init)
|
||||||
|
|
||||||
|
# We had an error, keep the timer running if we were called by ecore
|
||||||
|
return True
|
||||||
|
|
||||||
|
# No error, all went well
|
||||||
|
if class_._dbus_timer: class_._dbus_timer.stop()
|
||||||
|
|
||||||
|
# Register our own D-Bus callbacks
|
||||||
|
class_.gsm.connect_to_signal("Status", class_.on_gsm_net_status, dbus_interface=DIN_NETWORK)
|
||||||
|
|
||||||
|
# Notify all screens that the interfaces are here so that they can connect their signal callbacks
|
||||||
|
for callback in class_._init_callbacks:
|
||||||
|
callback()
|
||||||
|
|
||||||
|
# D-Bus is ready, let's power up GSM
|
||||||
|
class_.power_up_gsm()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def power_up_gsm(class_):
|
||||||
|
try:
|
||||||
|
if class_.gsm.GetPower(APP_TITLE, dbus_interface=DIN_POWERED, ):
|
||||||
|
print '---', 'gsm device is already on'
|
||||||
|
else:
|
||||||
|
class_.gsm.SetPower(APP_TITLE, True, dbus_interface=DIN_POWERED, )
|
||||||
|
print '---', 'switching device on'
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
print "XXXXXXX2 " + str(e)
|
||||||
|
if not class_._gsm_timer:
|
||||||
|
class_._gsm_timer = ecore.timer_add(5, class_.power_up_gsm)
|
||||||
|
|
||||||
|
#We had an error, keep the timer running if we were called by ecore
|
||||||
|
return True
|
||||||
|
|
||||||
|
# No error
|
||||||
|
if class_._gsm_timer: class_._gsm_timer.stop()
|
||||||
|
|
||||||
|
# Inquire status and act appropriately
|
||||||
|
gsm_status = dedbusmap(class_.gsm_net.GetStatus(dbus_interface=DIN_WIRELESS))
|
||||||
|
|
||||||
|
try:
|
||||||
|
if gsm_status["stat"] == 0: class_._sim_pin_callback()
|
||||||
|
except AttributeError:
|
||||||
|
raise NotImplementedError("No one here to handle SIM PIN entry!")
|
||||||
|
|
||||||
|
try:
|
||||||
|
if gsm_status["stat"] in (1, 5): class_._gsm_ready_callback()
|
||||||
|
except AttributeError:
|
||||||
|
raise NotImplementedError("No one here to handle GSM ready status!")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def on_gsm_net_status(class_, status_map):
|
||||||
|
status_map = dedbusmap(status_map)
|
||||||
|
print "Status: " + str(status_map)
|
||||||
|
|
||||||
|
|
||||||
class Dialer(object):
|
class Dialer(object):
|
||||||
|
screens = None
|
||||||
|
evas_canvas = None
|
||||||
|
system_bus = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
# Initialize the GUI
|
||||||
edje.frametime_set(FRAMETIME)
|
edje.frametime_set(FRAMETIME)
|
||||||
self.evas_canvas = EvasCanvas(FULLSCREEN, "x11-16")
|
self.evas_canvas = EvasCanvas(FULLSCREEN, "x11-16")
|
||||||
|
|
||||||
|
@ -174,10 +229,33 @@ class Dialer(object):
|
||||||
|
|
||||||
self.show_screen(MAIN_SCREEN_NAME)
|
self.show_screen(MAIN_SCREEN_NAME)
|
||||||
|
|
||||||
|
# Initialize the D-Bus interface to pyneo
|
||||||
|
dbus_ml = e_dbus.DBusEcoreMainLoop()
|
||||||
|
self.system_bus = SystemBus(mainloop=dbus_ml)
|
||||||
|
PyneoInterface.init()
|
||||||
|
|
||||||
|
|
||||||
def init_screen(self, screen_name, instance):
|
def init_screen(self, screen_name, instance):
|
||||||
self.screens[screen_name] = instance
|
self.screens[screen_name] = instance
|
||||||
self.evas_canvas.evas_obj.data[screen_name] = instance
|
self.evas_canvas.evas_obj.data[screen_name] = instance
|
||||||
|
|
||||||
|
# Attempt to register the screen's callbacks
|
||||||
|
try:
|
||||||
|
PyneoInterface.register_init_callback(instance.on_dbus_initialized)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
PyneoInterface.register_sim_pin_callback(instance.on_sim_pin_required)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
PyneoInterface.register_gsm_ready_callback(instance.on_gsm_ready)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def show_screen(self, screen_name):
|
def show_screen(self, screen_name):
|
||||||
for (name, screen) in self.screens.items():
|
for (name, screen) in self.screens.items():
|
||||||
if name == screen_name:
|
if name == screen_name:
|
||||||
|
@ -188,6 +266,7 @@ class Dialer(object):
|
||||||
def get_evas(self):
|
def get_evas(self):
|
||||||
return self.evas_canvas.evas_obj.evas
|
return self.evas_canvas.evas_obj.evas
|
||||||
|
|
||||||
|
|
||||||
class EvasCanvas(object):
|
class EvasCanvas(object):
|
||||||
def __init__(self, fullscreen, engine_name):
|
def __init__(self, fullscreen, engine_name):
|
||||||
if engine_name == "x11":
|
if engine_name == "x11":
|
||||||
|
@ -203,7 +282,7 @@ class EvasCanvas(object):
|
||||||
self.evas_obj.callback_delete_request = self.on_delete_request
|
self.evas_obj.callback_delete_request = self.on_delete_request
|
||||||
self.evas_obj.callback_resize = self.on_resize
|
self.evas_obj.callback_resize = self.on_resize
|
||||||
|
|
||||||
self.evas_obj.title = TITLE
|
self.evas_obj.title = APP_TITLE
|
||||||
self.evas_obj.name_class = WM_INFO
|
self.evas_obj.name_class = WM_INFO
|
||||||
self.evas_obj.fullscreen = fullscreen
|
self.evas_obj.fullscreen = fullscreen
|
||||||
# self.evas_obj.size = str(WIDTH) + 'x' + str(HEIGHT)
|
# self.evas_obj.size = str(WIDTH) + 'x' + str(HEIGHT)
|
||||||
|
@ -218,6 +297,7 @@ class EvasCanvas(object):
|
||||||
def on_delete_request(self, evas_obj):
|
def on_delete_request(self, evas_obj):
|
||||||
ecore.main_loop_quit()
|
ecore.main_loop_quit()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Dialer()
|
Dialer()
|
||||||
ecore.main_loop_begin()
|
ecore.main_loop_begin()
|
||||||
|
@ -227,7 +307,5 @@ export LDFLAGS="$LDFLAGS -L/opt/e17/lib"
|
||||||
export PKG_CONFIG_PATH="/opt/e17/lib/pkgconfig:$PKG_CONFIG_PATH"
|
export PKG_CONFIG_PATH="/opt/e17/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||||
export PATH="$PATH:/opt/e17/bin"
|
export PATH="$PATH:/opt/e17/bin"
|
||||||
export PYTHONPATH="/home/fgau/usr/lib/python2.5/site-packages"
|
export PYTHONPATH="/home/fgau/usr/lib/python2.5/site-packages"
|
||||||
|
|
||||||
edje_cc -v -id ../images -fd ../fonts *edc
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue