2008-08-27 21:26:20 +00:00
|
|
|
#!/usr/bin/env python2.5
|
|
|
|
# -*- coding: utf-8 -*-
|
2008-11-07 15:51:51 +00:00
|
|
|
__author__ = "Soeren Apel (abraxa@dar-clan.de), Frank Gau (fgau@gau-net.de), Thomas Gstaedtner (thomas (a) gstaedtner (.) net)"
|
2008-08-27 21:26:20 +00:00
|
|
|
__version__ = "prototype"
|
|
|
|
__copyright__ = "Copyright (c) 2008"
|
|
|
|
__license__ = "GPL3"
|
|
|
|
|
|
|
|
WIDTH = 480
|
|
|
|
HEIGHT = 640
|
2008-09-05 22:35:35 +00:00
|
|
|
|
2008-08-28 22:22:31 +00:00
|
|
|
FRAMETIME = 1.0 / 20
|
2008-09-05 22:35:35 +00:00
|
|
|
IMAGE_CACHE_SIZE = 6
|
|
|
|
FONT_CACHE_SIZE = 2
|
|
|
|
|
2008-08-28 21:10:06 +00:00
|
|
|
FULLSCREEN = True
|
2008-09-01 09:12:24 +00:00
|
|
|
APP_TITLE = "epydial"
|
2008-08-27 21:26:20 +00:00
|
|
|
WM_INFO = ("epydial", "epydial")
|
2008-08-31 02:00:48 +00:00
|
|
|
|
2008-09-15 17:51:27 +00:00
|
|
|
EDJE_FILE_PATH = "data/themes/blackwhite/"
|
2008-12-08 15:21:53 +00:00
|
|
|
PIX_FILE_PATH = "/media/card/hon/"
|
|
|
|
TRACK_FILE_PATH = "/media/card/track/"
|
|
|
|
DB_FILE_PATH = "data/db/my.sqlite"
|
2008-08-31 02:00:48 +00:00
|
|
|
|
2008-10-01 21:50:48 +00:00
|
|
|
DIALER_SCREEN_NAME = "pyneo/dialer/main"
|
2008-08-31 03:50:33 +00:00
|
|
|
INCALL_SCREEN_NAME = "pyneo/dialer/incall"
|
2008-10-01 21:50:48 +00:00
|
|
|
GSM_STATUS_SCREEN_NAME = "pyneo/gsm/status"
|
2008-09-19 16:18:23 +00:00
|
|
|
GPS_STATUS_SCREEN_NAME = "pyneo/gps/status"
|
2008-10-12 15:20:57 +00:00
|
|
|
HON_SCREEN_NAME = "pyneo/hon/screen"
|
2008-11-07 15:51:51 +00:00
|
|
|
CALC_SCREEN_NAME = "pyneo/calc/screen"
|
2008-12-08 15:21:53 +00:00
|
|
|
PIX_SCREEN_NAME = "pyneo/pix/screen"
|
|
|
|
CONTACTS_SCREEN_NAME = "pyneo/contacts/screen"
|
2008-12-10 18:58:28 +00:00
|
|
|
SMS_SCREEN_NAME = "pyneo/sms/screen"
|
2008-12-23 17:21:25 +00:00
|
|
|
SMS_DETAIL_SCREEN_NAME = "pyneo/sms/detail"
|
2008-12-29 18:14:49 +00:00
|
|
|
WEATHER_SCREEN_NAME = "pyneo/weather/screen"
|
2008-08-27 21:26:20 +00:00
|
|
|
|
2008-08-28 21:45:58 +00:00
|
|
|
from datetime import datetime
|
|
|
|
from dbus import SystemBus
|
2008-08-27 21:26:20 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2008-08-28 21:45:58 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
import e_dbus
|
2008-08-27 21:26:20 +00:00
|
|
|
import ecore
|
|
|
|
import ecore.evas
|
|
|
|
import edje.decorators
|
|
|
|
import edje
|
2008-08-28 21:45:58 +00:00
|
|
|
import evas.decorators
|
2008-12-28 15:59:21 +00:00
|
|
|
from time import sleep
|
2008-08-28 21:45:58 +00:00
|
|
|
|
2008-08-27 21:26:20 +00:00
|
|
|
from pyneo.dbus_support import *
|
|
|
|
from pyneo.sys_support import pr_set_name
|
|
|
|
|
|
|
|
from ConfigParser import SafeConfigParser
|
2008-12-08 15:21:53 +00:00
|
|
|
from sqlite3 import connect
|
2008-08-27 21:26:20 +00:00
|
|
|
|
2008-12-08 15:21:53 +00:00
|
|
|
#import cairo
|
2008-09-01 09:12:24 +00:00
|
|
|
|
2008-08-29 00:05:18 +00:00
|
|
|
class EdjeGroup(edje.Edje):
|
2008-08-31 04:15:56 +00:00
|
|
|
def __init__(self, group_manager, group):
|
2008-08-28 21:29:33 +00:00
|
|
|
|
2008-08-31 02:00:48 +00:00
|
|
|
# Theme file name is formed as follows:
|
|
|
|
# Last two group name parts, combined by underscore
|
|
|
|
# pyneo/dialer/main -> dialer_main.edj
|
|
|
|
group_parts = group.split("/")
|
|
|
|
file_name = EDJE_FILE_PATH + group_parts[-2] + "_" + group_parts[-1] + ".edj"
|
|
|
|
|
|
|
|
if not os.path.exists(file_name):
|
|
|
|
raise IOError("Edje theme file for group %s not found: %s" % (group, file_name))
|
2008-08-28 21:29:33 +00:00
|
|
|
|
2008-08-27 21:26:20 +00:00
|
|
|
try:
|
2008-08-31 04:15:56 +00:00
|
|
|
edje.Edje.__init__(self, group_manager.get_evas(), file=file_name, group=group)
|
2008-08-27 21:26:20 +00:00
|
|
|
except edje.EdjeLoadError, e:
|
2008-08-31 02:00:48 +00:00
|
|
|
raise SystemExit("Error loading %s: %s" % (file_name, e))
|
#!/usr/bin/env python2.5
# -*- coding: utf-8 -*-
__author__ = ""
__version__ = "prototype"
__copyright__ = "Copyright (c) 2008"
__license__ = "GPL3"
WIDTH = 480
HEIGHT = 640
FRAMETIME = 1.0 / 20
FULLSCREEN = True
TITLE = "epydial"
WM_INFO = ("epydial", "epydial")
EDJE_GROUP_NAME = "pyneo/dialer/main"
EDJE_FILE_NAME = "data/themes/dialer.edj"
from datetime import datetime
from dbus import SystemBus
import os
import sys
import time
import e_dbus
import ecore
import ecore.evas
import edje.decorators
import edje
import evas.decorators
from pyneo.dbus_support import *
from pyneo.sys_support import pr_set_name
from ConfigParser import SafeConfigParser
class EdjeGroup(edje.Edje):
def __init__(self, main, group):
self.main = main
if not os.path.exists(EDJE_FILE_NAME):
raise IOError("Edje theme file not found: " + EDJE_FILE_NAME)
try:
edje.Edje.__init__(self, self.main.evas_canvas.evas_obj.evas, file=EDJE_FILE_NAME, group=group)
except edje.EdjeLoadError, e:
raise SystemExit("Error loading %s: %s" % (f, e))
self.size = self.main.evas_canvas.evas_obj.evas.size
class MainScreen(EdjeGroup):
def __init__(self, main):
EdjeGroup.__init__(self, main, EDJE_GROUP_NAME)
self.text = []
dbus_ml = e_dbus.DBusEcoreMainLoop()
self.system_bus = SystemBus(mainloop=dbus_ml)
ecore.timer_add(5, self.init_dbus)
def init_dbus(self):
try:
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", "*")
def on_edje_signal_numberkey_triggered(self, emission, source):
if self.res['code'] != 'READY':
if source in ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "#", "*", ):
self.text.append(source)
print ''.join(self.text)
self.part_text_set("numberdisplay_text", "".join(self.text))
elif source == "backspace":
self.text = self.text[:-1]
print ''.join(self.text)
self.part_text_set("numberdisplay_text", "".join(self.text))
elif source == "dial":
print '---', 'send pin'
self.keyring.Open(''.join(self.text), dbus_interface=DIN_KEYRING, )
self.part_text_set("numberdisplay_text", "register ...")
self.nw_register()
else:
if source in ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "#", "*", ):
self.text.append(source)
print ''.join(self.text)
self.part_text_set("numberdisplay_text", "".join(self.text))
elif source == "backspace":
self.text = self.text[:-1]
print ''.join(self.text)
self.part_text_set("numberdisplay_text", "".join(self.text))
elif source == "dial":
print '---', 'dial number'
self.part_text_set("numberdisplay_text", "calling ...")
os.system('alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state restore')
name = self.wireless.Initiate(''.join(self.text), dbus_interface=DIN_VOICE_CALL_INITIATOR, timeout=200, )
time.sleep(20)
call = object_by_url(name)
call.Hangup(dbus_interface=DIN_CALL)
class TestView(object):
def __init__(self):
edje.frametime_set(FRAMETIME)
self.evas_canvas = EvasCanvas(FULLSCREEN, "x11-16")
self.groups = {}
self.groups[EDJE_GROUP_NAME] = MainScreen(self)
self.evas_canvas.evas_obj.data[EDJE_GROUP_NAME] = self.groups[EDJE_GROUP_NAME]
self.groups[EDJE_GROUP_NAME].show()
self.groups[EDJE_GROUP_NAME].part_text_set("numberdisplay_text", "wait ...")
class EvasCanvas(object):
def __init__(self, fullscreen, engine_name):
if engine_name == "x11":
engine = ecore.evas.SoftwareX11
# elif engine_name == "x11-16":
# if ecore.evas.engine_type_supported_get("software_x11_16"):
# engine = ecore.evas.SoftwareX11_16
else:
print "warning: x11-16 is not supported, falling back to x11"
engine = ecore.evas.SoftwareX11
self.evas_obj = engine(w=WIDTH, h=HEIGHT)
self.evas_obj.callback_delete_request = self.on_delete_request
self.evas_obj.callback_resize = self.on_resize
self.evas_obj.title = TITLE
self.evas_obj.name_class = WM_INFO
self.evas_obj.fullscreen = fullscreen
# self.evas_obj.size = str(WIDTH) + 'x' + str(HEIGHT)
self.evas_obj.show()
def on_resize(self, evas_obj):
x, y, w, h = evas_obj.evas.viewport
size = (w, h)
for key in evas_obj.data.keys():
evas_obj.data[key].size = size
def on_delete_request(self, evas_obj):
ecore.main_loop_quit()
if __name__ == "__main__":
TestView()
ecore.main_loop_begin()
'''
export LDFLAGS="$LDFLAGS -L/opt/e17/lib"
export PKG_CONFIG_PATH="/opt/e17/lib/pkgconfig:$PKG_CONFIG_PATH"
export PATH="$PATH:/opt/e17/bin"
export PYTHONPATH="/home/fgau/usr/lib/python2.5/site-packages"
edje_cc -v -id ../images -fd ../fonts *edc
'''
git-svn-id: http://www.neo1973-germany.de/svn@102 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-08-29 15:36:52 +00:00
|
|
|
|
2008-08-31 04:15:56 +00:00
|
|
|
self.size = group_manager.get_evas().size
|
2008-08-28 21:45:58 +00:00
|
|
|
|
2008-09-01 09:12:24 +00:00
|
|
|
|
2008-09-02 07:59:03 +00:00
|
|
|
class PyneoController(object):
|
2008-09-01 09:12:24 +00:00
|
|
|
_dbus_timer = None
|
|
|
|
_gsm_timer = None
|
2008-09-02 23:26:10 +00:00
|
|
|
_keyring_timer = None
|
2008-09-19 16:18:23 +00:00
|
|
|
_gps_timer = None
|
2008-09-02 23:19:24 +00:00
|
|
|
_callbacks = {}
|
2008-09-02 23:33:27 +00:00
|
|
|
_calls = {}
|
2008-09-02 07:59:03 +00:00
|
|
|
|
2008-09-01 09:12:24 +00:00
|
|
|
gsm = None
|
2008-09-19 16:18:23 +00:00
|
|
|
pwr = None
|
|
|
|
gps = None
|
2008-10-12 15:20:57 +00:00
|
|
|
hon = None
|
2008-09-02 07:59:03 +00:00
|
|
|
gsm_wireless = None
|
|
|
|
gsm_keyring = None
|
2008-12-08 15:21:53 +00:00
|
|
|
gsm_sms = None
|
2008-10-12 15:20:57 +00:00
|
|
|
hon_hotornot = None
|
2008-09-02 07:59:03 +00:00
|
|
|
|
|
|
|
gsm_wireless_status = None
|
|
|
|
gsm_keyring_status = None
|
2008-10-08 17:07:45 +00:00
|
|
|
|
|
|
|
call_type = None
|
2008-10-26 13:57:38 +00:00
|
|
|
|
|
|
|
brightness_value = None
|
2008-09-01 09:12:24 +00:00
|
|
|
|
2008-12-23 17:21:25 +00:00
|
|
|
call = None
|
|
|
|
callsigs = []
|
|
|
|
|
2008-09-01 09:12:24 +00:00
|
|
|
@classmethod
|
2008-09-02 07:59:03 +00:00
|
|
|
def register_callback(class_, event_name, callback):
|
|
|
|
print "In register_callback: ", event_name
|
2008-09-01 09:12:24 +00:00
|
|
|
try:
|
2008-09-02 07:59:03 +00:00
|
|
|
class_._callbacks[event_name].append(callback)
|
|
|
|
|
|
|
|
except KeyError:
|
|
|
|
# _callbacks[callback_name] undefined
|
|
|
|
class_._callbacks[event_name] = [callback]
|
2008-09-01 09:12:24 +00:00
|
|
|
|
|
|
|
@classmethod
|
2008-09-03 06:05:41 +00:00
|
|
|
def notify_callbacks(class_, event_name, *args):
|
2008-09-02 07:59:03 +00:00
|
|
|
try:
|
|
|
|
for cb in class_._callbacks[event_name]:
|
2008-09-03 06:05:41 +00:00
|
|
|
cb(*args)
|
2008-09-02 07:59:03 +00:00
|
|
|
|
|
|
|
except KeyError:
|
|
|
|
pass
|
2008-09-01 09:12:24 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def init(class_):
|
|
|
|
try:
|
|
|
|
class_.gsm = object_by_url('dbus:///org/pyneo/GsmDevice')
|
2008-12-28 15:59:21 +00:00
|
|
|
class_.gsm_wireless = object_by_url(class_.gsm.GetDevice('wireless', dbus_interface=DIN_POWERED))
|
|
|
|
class_.gsm_sms = object_by_url(class_.gsm.GetDevice('shortmessage_storage', dbus_interface=DIN_POWERED))
|
2008-09-15 17:51:27 +00:00
|
|
|
class_.pwr = object_by_url('dbus:///org/pyneo/Power')
|
2008-09-19 16:18:23 +00:00
|
|
|
class_.gps = object_by_url('dbus:///org/pyneo/GpsLocation')
|
2008-10-12 15:20:57 +00:00
|
|
|
class_.hon = object_by_url('dbus:///org/pyneo/HotOrNot')
|
2008-12-28 15:59:21 +00:00
|
|
|
class_.hon_hotornot = object_by_url(class_.hon.GetDevice('hotornot', dbus_interface=DIN_POWERED))
|
2008-10-08 17:07:45 +00:00
|
|
|
class_.call_type = 'nix'
|
2008-10-26 13:57:38 +00:00
|
|
|
class_.brightness_value = 60
|
2008-12-23 17:21:25 +00:00
|
|
|
class_.call = None
|
|
|
|
class_.callsigs = []
|
2008-09-01 09:12:24 +00:00
|
|
|
|
|
|
|
except Exception, e:
|
2008-09-02 23:26:10 +00:00
|
|
|
print "Pyneo error: " + str(e)
|
2008-09-01 09:12:24 +00:00
|
|
|
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
|
|
|
|
|
2008-09-02 07:59:03 +00:00
|
|
|
# No error (anymore)
|
2008-09-01 09:12:24 +00:00
|
|
|
if class_._dbus_timer: class_._dbus_timer.stop()
|
|
|
|
|
2008-12-23 17:21:25 +00:00
|
|
|
# Register our own D-Bus callbacks (device status, new calls, power status, new sms)
|
2008-09-02 07:59:03 +00:00
|
|
|
class_.gsm_wireless.connect_to_signal("Status", class_.on_gsm_wireless_status, dbus_interface=DIN_WIRELESS)
|
2008-12-23 17:21:25 +00:00
|
|
|
class_.gsm_wireless.connect_to_signal('New', class_.check_new_call, dbus_interface=DIN_WIRELESS)
|
2008-10-02 13:34:27 +00:00
|
|
|
class_.pwr.connect_to_signal("Status", class_.on_pwr_status, dbus_interface=DIN_POWERED)
|
2008-12-08 15:21:53 +00:00
|
|
|
class_.gsm_sms.connect_to_signal('New', class_.check_new_sms, dbus_interface=DIN_STORAGE)
|
2008-10-02 13:34:27 +00:00
|
|
|
|
2008-10-08 17:07:45 +00:00
|
|
|
@classmethod
|
|
|
|
def get_pwr_status(class_):
|
2008-10-02 13:34:27 +00:00
|
|
|
status = class_.pwr.GetStatus(dbus_interface=DIN_POWERED)
|
|
|
|
class_.on_pwr_status(status)
|
2008-09-15 17:51:27 +00:00
|
|
|
|
2008-12-08 15:21:53 +00:00
|
|
|
@classmethod
|
|
|
|
def get_device_status(class_):
|
|
|
|
class_.notify_callbacks("device_status", class_.gsm.GetStatus(dbus_interface=DIN_POWERED))
|
|
|
|
|
2008-09-19 16:18:23 +00:00
|
|
|
@classmethod
|
2008-10-01 21:50:48 +00:00
|
|
|
def power_status_gsm(class_):
|
|
|
|
class_.notify_callbacks("power_status_gsm", class_.gsm.GetPower(APP_TITLE, dbus_interface=DIN_POWERED))
|
2008-09-19 16:18:23 +00:00
|
|
|
|
2008-10-12 15:20:57 +00:00
|
|
|
@classmethod
|
|
|
|
def get_hon(class_):
|
2008-12-08 15:21:53 +00:00
|
|
|
class_.notify_callbacks("get_hon", class_.hon_hotornot.GetHotOrNot(dbus_interface=DIN_HOTORNOT))
|
2008-10-12 15:20:57 +00:00
|
|
|
|
2008-10-18 17:12:33 +00:00
|
|
|
@classmethod
|
|
|
|
def vote_hon(class_, vote):
|
|
|
|
class_.hon_hotornot.HotOrNot(vote, dbus_interface=DIN_HOTORNOT)
|
|
|
|
|
2008-12-23 17:21:25 +00:00
|
|
|
@classmethod
|
2008-12-28 20:24:27 +00:00
|
|
|
def show_sms_detail(class_, number, status):
|
|
|
|
class_.notify_callbacks("show_sms_detail", number, status)
|
2008-12-23 17:21:25 +00:00
|
|
|
|
2008-09-01 09:12:24 +00:00
|
|
|
@classmethod
|
|
|
|
def power_up_gsm(class_):
|
|
|
|
try:
|
2008-09-02 07:59:03 +00:00
|
|
|
if class_.gsm.GetPower(APP_TITLE, dbus_interface=DIN_POWERED):
|
2008-09-01 09:12:24 +00:00
|
|
|
print '---', 'gsm device is already on'
|
|
|
|
else:
|
2008-09-02 07:59:03 +00:00
|
|
|
class_.gsm.SetPower(APP_TITLE, True, dbus_interface=DIN_POWERED)
|
2008-09-19 16:18:23 +00:00
|
|
|
print '---', 'switching gsm device on'
|
2008-09-01 09:12:24 +00:00
|
|
|
|
|
|
|
except Exception, e:
|
2008-09-02 23:26:10 +00:00
|
|
|
print "GSM error: " + str(e)
|
2008-09-01 09:12:24 +00:00
|
|
|
if not class_._gsm_timer:
|
|
|
|
class_._gsm_timer = ecore.timer_add(5, class_.power_up_gsm)
|
|
|
|
|
2008-09-02 07:59:03 +00:00
|
|
|
# We had an error, keep the timer running if we were called by ecore
|
2008-09-01 09:12:24 +00:00
|
|
|
return True
|
|
|
|
|
2008-09-02 07:59:03 +00:00
|
|
|
# No error (anymore)
|
2008-09-01 09:12:24 +00:00
|
|
|
if class_._gsm_timer: class_._gsm_timer.stop()
|
2008-10-01 21:50:48 +00:00
|
|
|
|
2008-09-02 23:26:10 +00:00
|
|
|
@classmethod
|
|
|
|
def get_gsm_keyring(class_):
|
|
|
|
try:
|
2008-12-28 15:59:21 +00:00
|
|
|
class_.gsm_keyring = object_by_url(class_.gsm_wireless.GetKeyring(dbus_interface=DIN_AUTHORIZED))
|
2008-09-02 23:26:10 +00:00
|
|
|
|
|
|
|
except Exception, e:
|
|
|
|
print "SIM error: " + str(e)
|
|
|
|
if not class_._keyring_timer:
|
|
|
|
class_._keyring_timer = ecore.timer_add(5, class_.get_gsm_keyring)
|
|
|
|
|
|
|
|
# We had an error, keep the timer running if we were called by ecore
|
|
|
|
return True
|
|
|
|
|
|
|
|
# No error (anymore)
|
|
|
|
if class_._keyring_timer: class_._keyring_timer.stop()
|
|
|
|
|
|
|
|
class_.gsm_keyring.connect_to_signal("Opened", class_.on_gsm_keyring_status, dbus_interface=DIN_KEYRING)
|
|
|
|
|
|
|
|
# Inquire SIM status and act accordingly to the initial state
|
|
|
|
status = class_.gsm_keyring.GetOpened(dbus_interface=DIN_KEYRING)
|
|
|
|
class_.on_gsm_keyring_status(status)
|
2008-10-01 21:50:48 +00:00
|
|
|
|
2008-09-02 07:59:03 +00:00
|
|
|
@classmethod
|
|
|
|
def gsm_sim_locked(class_):
|
|
|
|
return class_.gsm_keyring_status['code'] != 'READY'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def gsm_unlock_sim(class_, key):
|
|
|
|
class_.gsm_keyring.Open(key, dbus_interface=DIN_KEYRING)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def gsm_dial(class_, number):
|
|
|
|
os.system('alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state restore')
|
2008-12-08 15:21:53 +00:00
|
|
|
class_.notify_callbacks("gsm_phone_call_start")
|
2008-09-02 07:59:03 +00:00
|
|
|
name = class_.gsm_wireless.Initiate(number, dbus_interface=DIN_VOICE_CALL_INITIATOR, timeout=200)
|
2008-12-23 17:21:25 +00:00
|
|
|
class_.call = object_by_url(name)
|
2008-09-02 23:33:27 +00:00
|
|
|
|
|
|
|
@classmethod
|
2008-09-03 18:07:49 +00:00
|
|
|
def gsm_hangup(class_):
|
2008-12-08 15:21:53 +00:00
|
|
|
os.system('alsactl -f /usr/share/openmoko/scenarios/stereoout.state restore')
|
|
|
|
class_.call_type = 'nix'
|
2008-12-23 17:21:25 +00:00
|
|
|
class_.call = object_by_url('dbus:///org/pyneo/gsmdevice/Call/1')
|
|
|
|
class_.call.Hangup(dbus_interface=DIN_CALL)
|
2008-10-03 20:35:26 +00:00
|
|
|
|
2008-11-03 18:34:09 +00:00
|
|
|
@classmethod
|
|
|
|
def gsm_accept(class_):
|
2008-12-08 15:21:53 +00:00
|
|
|
os.system('alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state restore')
|
2008-12-23 17:21:25 +00:00
|
|
|
# class_.call = object_by_url('dbus:///org/pyneo/gsmdevice/Call/1')
|
|
|
|
class_.call.Accept(dbus_interface=DIN_CALL)
|
2008-12-08 15:21:53 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def gsm_details(class_):
|
|
|
|
class_.notify_callbacks("gsm_details", class_.gsm_wireless.GetStatus(dbus_interface=DIN_WIRELESS))
|
2008-09-02 07:59:03 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def on_gsm_wireless_status(class_, status_map):
|
|
|
|
status = dedbusmap(status_map)
|
|
|
|
class_.gsm_net_status = status
|
2008-12-08 15:21:53 +00:00
|
|
|
print 'GSM NET Status: %s'%status
|
2008-09-01 09:12:24 +00:00
|
|
|
|
2008-09-02 23:33:27 +00:00
|
|
|
if status.has_key('stat'):
|
2008-09-02 16:57:10 +00:00
|
|
|
nw_status = status['stat']
|
2008-09-02 07:59:03 +00:00
|
|
|
|
2008-09-02 16:57:10 +00:00
|
|
|
if nw_status == 0:
|
|
|
|
class_.notify_callbacks("gsm_unregistered")
|
2008-09-03 06:05:41 +00:00
|
|
|
elif nw_status in (1, 5):
|
2008-09-02 16:57:10 +00:00
|
|
|
class_.notify_callbacks("gsm_registered")
|
2008-09-03 06:05:41 +00:00
|
|
|
elif nw_status == 2:
|
2008-09-02 16:57:10 +00:00
|
|
|
class_.notify_callbacks("gsm_registering")
|
2008-09-03 06:05:41 +00:00
|
|
|
elif nw_status == 3:
|
2008-09-02 16:57:10 +00:00
|
|
|
class_.notify_callbacks("gsm_reg_denied")
|
2008-09-03 06:05:41 +00:00
|
|
|
elif nw_status == 4:
|
2008-09-02 16:57:10 +00:00
|
|
|
raise NotImplementedError("GSM registration has unknown state")
|
2008-09-03 06:05:41 +00:00
|
|
|
|
2008-12-23 17:21:25 +00:00
|
|
|
# if status.has_key('phone_activity_status'):
|
|
|
|
# ph_status = status['phone_activity_status']
|
|
|
|
#
|
|
|
|
# if class_.call_type != 'outgoing':
|
|
|
|
# if ph_status == 0:
|
|
|
|
# class_.notify_callbacks("gsm_phone_call_end")
|
|
|
|
# os.system('alsactl -f /usr/share/openmoko/scenarios/stereoout.state restore')
|
|
|
|
# if ph_status == 3:
|
|
|
|
# class_.notify_callbacks("gsm_phone_ringing")
|
|
|
|
# if ph_status == 4:
|
|
|
|
# class_.notify_callbacks("gsm_phone_call_start")
|
2008-09-03 06:05:41 +00:00
|
|
|
|
|
|
|
if status.has_key('rssi'):
|
|
|
|
class_.notify_callbacks("gsm_signal_strength_change", status['rssi'])
|
2008-09-06 14:45:30 +00:00
|
|
|
|
|
|
|
if status.has_key('oper'):
|
2008-12-10 19:28:04 +00:00
|
|
|
class_.first_check_new_sms()
|
2008-09-06 14:45:30 +00:00
|
|
|
class_.notify_callbacks("gsm_operator_change", status['oper'])
|
2008-09-11 16:08:30 +00:00
|
|
|
|
|
|
|
if status.has_key('number'):
|
|
|
|
class_.notify_callbacks("gsm_number_display", status['number'])
|
2008-09-01 09:12:24 +00:00
|
|
|
|
2008-12-08 15:21:53 +00:00
|
|
|
class_.notify_callbacks("gsm_details", status)
|
|
|
|
|
2008-09-01 09:12:24 +00:00
|
|
|
@classmethod
|
2008-09-02 07:59:03 +00:00
|
|
|
def on_gsm_keyring_status(class_, status_map):
|
|
|
|
status = dedbusmap(status_map)
|
|
|
|
class_.gsm_keyring_status = status
|
|
|
|
print "SIM Status: " + str(status)
|
|
|
|
|
|
|
|
if status["code"] == "READY":
|
|
|
|
class_.notify_callbacks("sim_ready")
|
2008-09-19 16:18:23 +00:00
|
|
|
|
2008-09-02 07:59:03 +00:00
|
|
|
# Try registering on the network
|
2008-10-26 13:57:38 +00:00
|
|
|
res = dedbusmap(class_.gsm_wireless.GetStatus(dbus_interface=DIN_WIRELESS, ))
|
|
|
|
if not res['stat'] in (1, 5, ):
|
|
|
|
print '---', 'registering to gsm network'
|
2008-12-28 15:59:21 +00:00
|
|
|
class_.gsm_wireless.Register(dbus_interface=DIN_WIRELESS)
|
2008-10-26 13:57:38 +00:00
|
|
|
res = dedbusmap(class_.gsm_wireless.GetStatus(dbus_interface=DIN_WIRELESS, ))
|
|
|
|
else:
|
|
|
|
print '---', 'already registered'
|
2008-09-02 07:59:03 +00:00
|
|
|
else:
|
2008-09-03 06:05:41 +00:00
|
|
|
class_.notify_callbacks("sim_key_required", status["code"])
|
2008-09-01 09:12:24 +00:00
|
|
|
|
2008-09-19 16:18:23 +00:00
|
|
|
@classmethod
|
2008-10-01 21:50:48 +00:00
|
|
|
def power_status_gps(class_):
|
|
|
|
class_.notify_callbacks("power_status_gps", class_.gps.GetPower(APP_TITLE, dbus_interface=DIN_POWERED))
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def power_up_gps(class_):
|
|
|
|
print 'power_up_gps'
|
|
|
|
try:
|
|
|
|
if class_.gps.GetPower(APP_TITLE, dbus_interface=DIN_POWERED):
|
|
|
|
print '---', 'gps device is already on'
|
|
|
|
else:
|
|
|
|
class_.gps.SetPower(APP_TITLE, True, dbus_interface=DIN_POWERED)
|
|
|
|
print '---', 'switching gps device on'
|
|
|
|
|
|
|
|
except Exception, e:
|
|
|
|
print "GPS error: " + str(e)
|
|
|
|
if not class_._gps_timer:
|
|
|
|
class_._gps_timer = ecore.timer_add(5, class_.power_up_gps)
|
|
|
|
|
|
|
|
# We had an error, keep the timer running if we were called by ecore
|
|
|
|
return True
|
|
|
|
|
|
|
|
# No error (anymore)
|
|
|
|
if class_._gps_timer: class_._gps_timer.stop()
|
|
|
|
|
|
|
|
# Register our own D-Bus Gps callbacks
|
|
|
|
class_.gps.connect_to_signal("Position", class_.on_gps_position_status, dbus_interface=DIN_LOCATION)
|
|
|
|
|
|
|
|
class_.notify_callbacks("power_status_gps", class_.gps.GetPower(APP_TITLE, dbus_interface=DIN_POWERED))
|
|
|
|
|
|
|
|
status = class_.gps.GetPosition(dbus_interface=DIN_LOCATION)
|
|
|
|
class_.on_gps_position_status(status)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def power_down_gps(class_):
|
|
|
|
class_.gps.SetPower(APP_TITLE, False, dbus_interface=DIN_POWERED)
|
|
|
|
class_.notify_callbacks("power_status_gps", class_.gps.GetPower(APP_TITLE, dbus_interface=DIN_POWERED))
|
2008-09-19 16:18:23 +00:00
|
|
|
|
|
|
|
@classmethod
|
2008-10-01 21:50:48 +00:00
|
|
|
def on_gps_position_status(class_, status_map):
|
|
|
|
status = dedbusmap(status_map)
|
|
|
|
print "GPS Status: " + str(status)
|
|
|
|
|
|
|
|
if status.has_key('fix'):
|
|
|
|
class_.notify_callbacks("gps_position_change", status)
|
|
|
|
|
2008-10-02 13:34:27 +00:00
|
|
|
@classmethod
|
|
|
|
def on_pwr_status(class_, status_map):
|
|
|
|
status = dedbusmap(status_map)
|
|
|
|
print "POWER Status: " + str(status)
|
2008-10-19 10:06:39 +00:00
|
|
|
if status.has_key('battvolt'):
|
2008-10-19 19:49:12 +00:00
|
|
|
class_.notify_callbacks("battvolt_change", status['battvolt'], status['chgmode'])
|
2008-10-02 13:34:27 +00:00
|
|
|
class_.notify_callbacks("pwr_status_change", status)
|
|
|
|
|
2008-10-01 21:50:48 +00:00
|
|
|
@classmethod
|
|
|
|
def show_dialer_screen(class_):
|
2008-12-28 15:59:21 +00:00
|
|
|
# class_.pwr.SetBrightness(class_.brightness_value, dbus_interface=DIN_POWER)
|
|
|
|
# class_.pwr.GetStatus(dbus_interface=DIN_POWERED)
|
2008-10-01 21:50:48 +00:00
|
|
|
class_.notify_callbacks("show_dialer_screen")
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def show_gsm_status_screen(class_):
|
|
|
|
class_.notify_callbacks("show_gsm_status_screen")
|
2008-10-26 13:57:38 +00:00
|
|
|
class_.notify_callbacks("brightness_change", class_.brightness_value)
|
2008-09-19 16:18:23 +00:00
|
|
|
|
|
|
|
@classmethod
|
2008-10-01 21:50:48 +00:00
|
|
|
def show_gps_status_screen(class_):
|
|
|
|
class_.notify_callbacks("show_gps_status_screen")
|
|
|
|
|
2008-10-08 17:07:45 +00:00
|
|
|
@classmethod
|
|
|
|
def show_incall_screen(class_, calling_type):
|
|
|
|
class_.call_type = calling_type
|
|
|
|
print "CALLING_TYPE: ", class_.call_type
|
|
|
|
class_.notify_callbacks("gsm_phone_call_start")
|
|
|
|
|
2008-10-12 15:20:57 +00:00
|
|
|
@classmethod
|
|
|
|
def show_hon_screen(class_):
|
|
|
|
class_.notify_callbacks("show_hon_screen")
|
|
|
|
|
2008-11-07 15:51:51 +00:00
|
|
|
@classmethod
|
|
|
|
def show_calc_screen(class_):
|
|
|
|
class_.notify_callbacks("show_calc_screen")
|
|
|
|
|
2008-12-08 15:21:53 +00:00
|
|
|
@classmethod
|
|
|
|
def show_pix_screen(class_):
|
|
|
|
class_.notify_callbacks("show_pix_screen")
|
|
|
|
|
2008-10-26 13:57:38 +00:00
|
|
|
@classmethod
|
|
|
|
def brightness_change(class_, up_down):
|
2008-11-03 18:34:09 +00:00
|
|
|
if up_down == 'button_right_bg_brightness':
|
2008-10-26 13:57:38 +00:00
|
|
|
class_.brightness_value += 10
|
|
|
|
if class_.brightness_value > 100: class_.brightness_value = 100
|
|
|
|
else:
|
|
|
|
class_.brightness_value -= 10
|
|
|
|
if class_.brightness_value < 0: class_.brightness_value = 0
|
|
|
|
class_.pwr.SetBrightness(class_.brightness_value, dbus_interface=DIN_POWER)
|
|
|
|
class_.notify_callbacks("brightness_change", class_.brightness_value)
|
|
|
|
|
2008-12-08 15:21:53 +00:00
|
|
|
@classmethod
|
|
|
|
def scan_operator(class_):
|
|
|
|
class_.notify_callbacks("scan_operator", dedbusmap(class_.gsm_wireless.Scan(timeout=100.0, dbus_interface=DIN_WIRELESS, )))
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def show_contacts_screen(class_):
|
|
|
|
class_.notify_callbacks("show_contacts_screen")
|
|
|
|
|
2008-12-23 17:21:25 +00:00
|
|
|
@classmethod
|
|
|
|
def check_new_call(class_, newmap):
|
|
|
|
def CallStatus(newmap):
|
|
|
|
newmap = dedbusmap(newmap)
|
|
|
|
print '---', 'CallStatus'
|
|
|
|
# for n, v in newmap.items():
|
|
|
|
# print '\t', n, ':', v
|
|
|
|
|
|
|
|
def CallRing(newmap):
|
|
|
|
newmap = dedbusmap(newmap)
|
|
|
|
class_.notify_callbacks("gsm_phone_ringing")
|
|
|
|
if newmap['number']: class_.notify_callbacks("gsm_number_display", newmap['number'])
|
|
|
|
print '---', 'CallRing'
|
|
|
|
# for n, v in newmap.items():
|
|
|
|
# print '\t', n, ':', v
|
|
|
|
|
|
|
|
def CallEnd(newmap):
|
|
|
|
class_.notify_callbacks("gsm_phone_call_end")
|
|
|
|
os.system('alsactl -f /usr/share/openmoko/scenarios/stereoout.state restore')
|
|
|
|
newmap = dedbusmap(newmap)
|
|
|
|
print '---', 'CallEnd'
|
|
|
|
# for n, v in newmap.items():
|
|
|
|
# print '\t', n, ':', v
|
|
|
|
if class_.call:
|
|
|
|
class_.call = None
|
|
|
|
while class_.callsigs:
|
|
|
|
class_.callsigs.pop().remove()
|
|
|
|
|
|
|
|
newmap = dedbusmap(newmap)
|
|
|
|
print '---', 'CallNew'
|
|
|
|
os.system('alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state restore')
|
|
|
|
for n, v in newmap.items():
|
|
|
|
# print '\t', n, ':', v
|
|
|
|
class_.call = object_by_url(n)
|
|
|
|
class_.callsigs.append(class_.call.connect_to_signal('Ring', CallRing, dbus_interface=DIN_CALL, ))
|
|
|
|
class_.callsigs.append(class_.call.connect_to_signal('Status', CallStatus, dbus_interface=DIN_CALL, ))
|
|
|
|
class_.callsigs.append(class_.call.connect_to_signal('End', CallEnd, dbus_interface=DIN_CALL, ))
|
|
|
|
|
2008-12-08 15:21:53 +00:00
|
|
|
@classmethod
|
|
|
|
def check_new_sms(class_, newmap,):
|
|
|
|
def InsertSms(status, from_msisdn, time, text):
|
|
|
|
connection = connect(DB_FILE_PATH)
|
|
|
|
cursor = connection.cursor()
|
|
|
|
cursor.execute("INSERT INTO sms (status, from_msisdn, time, sms_text) VALUES ('" \
|
|
|
|
+ status + "', '" + from_msisdn + "', '" + time + "', '" + text + "')")
|
|
|
|
connection.commit()
|
|
|
|
|
|
|
|
res = dedbusmap(newmap)
|
|
|
|
for n in res:
|
|
|
|
sm = object_by_url(n)
|
|
|
|
content = dedbusmap(sm.GetContent())
|
|
|
|
InsertSms('REC UNREAD', content['from_msisdn'], content['time'], content['text'].encode('utf-8'))
|
|
|
|
print '--- NEW SMS:', content['from_msisdn'], content['time'], content['text'].encode('utf-8')
|
2008-12-28 15:59:21 +00:00
|
|
|
class_.gsm_sms.DeleteAll(dbus_interface=DIN_STORAGE)
|
2008-12-08 15:21:53 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def first_check_new_sms(class_):
|
|
|
|
def InsertSms(status, from_msisdn, time, text):
|
|
|
|
connection = connect(DB_FILE_PATH)
|
|
|
|
cursor = connection.cursor()
|
|
|
|
cursor.execute("INSERT INTO sms (status, from_msisdn, time, sms_text) VALUES ('" \
|
|
|
|
+ status + "', '" + from_msisdn + "', '" + time + "', '" + text + "')")
|
|
|
|
connection.commit()
|
|
|
|
|
|
|
|
try:
|
2008-12-28 15:59:21 +00:00
|
|
|
res = class_.gsm_sms.ListAll(dbus_interface=DIN_STORAGE)
|
2008-12-08 15:21:53 +00:00
|
|
|
for n in res:
|
|
|
|
sm = object_by_url(n)
|
|
|
|
content = dedbusmap(sm.GetContent())
|
|
|
|
InsertSms('REC UNREAD', content['from_msisdn'], content['time'], content['text'].encode('utf-8'))
|
|
|
|
except:
|
|
|
|
print '--- NULL new sms'
|
2008-12-28 15:59:21 +00:00
|
|
|
class_.gsm_sms.DeleteAll(dbus_interface=DIN_STORAGE)
|
2008-12-08 15:21:53 +00:00
|
|
|
|
2008-12-10 18:58:28 +00:00
|
|
|
@classmethod
|
|
|
|
def show_sms_screen(class_):
|
|
|
|
class_.notify_callbacks("show_sms_screen")
|
|
|
|
|
2008-12-23 17:21:25 +00:00
|
|
|
@classmethod
|
|
|
|
def show_sms_screen_detail(class_):
|
|
|
|
class_.notify_callbacks("show_sms_screen_detail")
|
|
|
|
|
2008-12-29 18:14:49 +00:00
|
|
|
@classmethod
|
|
|
|
def show_weather_screen(class_):
|
|
|
|
class_.notify_callbacks("show_weather_screen")
|
|
|
|
|
2008-12-27 20:53:06 +00:00
|
|
|
@classmethod
|
|
|
|
def vibrate_start(class_):
|
|
|
|
class_.pwr.Vibrate(10, 3, 1, dbus_interface=DIN_POWER)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def vibrate_stop(class_):
|
|
|
|
class_.pwr.Vibrate(0, 0, 0, dbus_interface=DIN_POWER)
|
|
|
|
|
2008-10-01 21:50:48 +00:00
|
|
|
|
|
|
|
from dialer_screen import *
|
|
|
|
from incall_screen import *
|
|
|
|
from gsm_status_screen import *
|
|
|
|
from gps_status_screen import *
|
2008-10-12 15:20:57 +00:00
|
|
|
from hon_screen import *
|
2008-12-08 15:21:53 +00:00
|
|
|
from calc_screen import *
|
|
|
|
from pix_screen import *
|
|
|
|
from contacts_screen import *
|
2008-12-10 18:58:28 +00:00
|
|
|
from sms_screen import *
|
2008-12-28 16:02:07 +00:00
|
|
|
from sms_detail import *
|
2008-12-29 18:14:49 +00:00
|
|
|
from weather_screen import *
|
2008-09-01 09:12:24 +00:00
|
|
|
|
2008-08-31 03:50:33 +00:00
|
|
|
class Dialer(object):
|
2008-09-01 09:12:24 +00:00
|
|
|
screens = None
|
|
|
|
evas_canvas = None
|
|
|
|
system_bus = None
|
|
|
|
|
2008-08-27 21:26:20 +00:00
|
|
|
def __init__(self):
|
2008-09-01 09:12:24 +00:00
|
|
|
# Initialize the GUI
|
2008-08-28 22:22:31 +00:00
|
|
|
edje.frametime_set(FRAMETIME)
|
2008-08-28 23:49:52 +00:00
|
|
|
self.evas_canvas = EvasCanvas(FULLSCREEN, "x11-16")
|
2008-08-27 21:26:20 +00:00
|
|
|
|
2008-08-31 03:50:33 +00:00
|
|
|
self.screens = {}
|
2008-10-08 17:07:45 +00:00
|
|
|
|
2008-09-03 06:05:41 +00:00
|
|
|
# Register our own callbacks
|
2008-09-08 07:11:09 +00:00
|
|
|
PyneoController.register_callback("gsm_phone_ringing", self.on_ringing)
|
2008-09-03 06:05:41 +00:00
|
|
|
PyneoController.register_callback("gsm_phone_call_start", self.on_call_start)
|
2008-09-03 16:26:57 +00:00
|
|
|
PyneoController.register_callback("gsm_phone_call_end", self.on_call_end)
|
2008-10-01 21:50:48 +00:00
|
|
|
PyneoController.register_callback("show_gsm_status_screen", self.on_gsm_status_screen)
|
|
|
|
PyneoController.register_callback("show_gps_status_screen", self.on_gps_status_screen)
|
|
|
|
PyneoController.register_callback("show_dialer_screen", self.on_call_end)
|
2008-10-12 15:20:57 +00:00
|
|
|
PyneoController.register_callback("show_hon_screen", self.on_hon_screen)
|
2008-11-07 15:51:51 +00:00
|
|
|
PyneoController.register_callback("show_calc_screen", self.on_calc_screen)
|
2008-12-08 15:21:53 +00:00
|
|
|
PyneoController.register_callback("show_pix_screen", self.on_pix_screen)
|
|
|
|
PyneoController.register_callback("show_contacts_screen", self.on_contacts_screen)
|
2008-12-10 18:58:28 +00:00
|
|
|
PyneoController.register_callback("show_sms_screen", self.on_sms_screen)
|
2008-12-28 16:02:07 +00:00
|
|
|
PyneoController.register_callback("show_sms_screen_detail", self.on_sms_screen_detail)
|
2008-12-29 18:14:49 +00:00
|
|
|
PyneoController.register_callback("show_weather_screen", self.on_weather_screen)
|
2008-12-08 15:21:53 +00:00
|
|
|
|
2008-10-08 17:07:45 +00:00
|
|
|
# Initialize the D-Bus interface to pyneo
|
|
|
|
dbus_ml = e_dbus.DBusEcoreMainLoop()
|
|
|
|
self.system_bus = SystemBus(mainloop=dbus_ml)
|
|
|
|
PyneoController.init()
|
|
|
|
|
|
|
|
self.init_screen(DIALER_SCREEN_NAME, DialerScreen(self))
|
|
|
|
PyneoController.show_dialer_screen()
|
|
|
|
self.init_screen(INCALL_SCREEN_NAME, InCallScreen(self))
|
|
|
|
self.init_screen(GSM_STATUS_SCREEN_NAME, GsmStatusScreen(self))
|
|
|
|
self.init_screen(GPS_STATUS_SCREEN_NAME, GpsStatusScreen(self))
|
|
|
|
|
|
|
|
PyneoController.power_up_gsm()
|
|
|
|
PyneoController.get_gsm_keyring()
|
2008-08-31 03:50:33 +00:00
|
|
|
|
|
|
|
def init_screen(self, screen_name, instance):
|
|
|
|
self.screens[screen_name] = instance
|
|
|
|
self.evas_canvas.evas_obj.data[screen_name] = instance
|
2008-09-01 09:12:24 +00:00
|
|
|
|
2008-09-02 07:59:03 +00:00
|
|
|
# Attempt to register the screen default callbacks
|
2008-09-01 09:12:24 +00:00
|
|
|
try:
|
2008-09-02 07:59:03 +00:00
|
|
|
instance.register_pyneo_callbacks()
|
2008-09-01 09:12:24 +00:00
|
|
|
except AttributeError:
|
|
|
|
pass
|
2008-08-31 02:00:48 +00:00
|
|
|
|
2008-08-31 03:50:33 +00:00
|
|
|
def show_screen(self, screen_name):
|
|
|
|
for (name, screen) in self.screens.items():
|
|
|
|
if name == screen_name:
|
|
|
|
screen.show()
|
|
|
|
else:
|
|
|
|
screen.hide()
|
2008-08-27 21:26:20 +00:00
|
|
|
|
2008-08-31 04:15:56 +00:00
|
|
|
def get_evas(self):
|
|
|
|
return self.evas_canvas.evas_obj.evas
|
|
|
|
|
2008-09-08 07:11:09 +00:00
|
|
|
def on_ringing(self):
|
|
|
|
self.show_screen(INCALL_SCREEN_NAME)
|
|
|
|
|
2008-09-03 06:05:41 +00:00
|
|
|
def on_call_start(self):
|
|
|
|
self.show_screen(INCALL_SCREEN_NAME)
|
|
|
|
|
|
|
|
def on_call_end(self):
|
2008-10-01 21:50:48 +00:00
|
|
|
self.show_screen(DIALER_SCREEN_NAME)
|
2008-09-03 06:05:41 +00:00
|
|
|
|
2008-10-01 21:50:48 +00:00
|
|
|
def on_gsm_status_screen(self):
|
2008-09-19 16:18:23 +00:00
|
|
|
self.show_screen(GSM_STATUS_SCREEN_NAME)
|
|
|
|
|
2008-10-01 21:50:48 +00:00
|
|
|
def on_gps_status_screen(self):
|
2008-09-19 16:18:23 +00:00
|
|
|
self.show_screen(GPS_STATUS_SCREEN_NAME)
|
|
|
|
|
2008-10-12 15:20:57 +00:00
|
|
|
def on_hon_screen(self):
|
2008-10-18 17:12:33 +00:00
|
|
|
self.init_screen(HON_SCREEN_NAME, HonScreen(self))
|
2008-10-12 15:20:57 +00:00
|
|
|
self.show_screen(HON_SCREEN_NAME)
|
|
|
|
|
2008-11-07 15:51:51 +00:00
|
|
|
def on_calc_screen(self):
|
|
|
|
self.init_screen(CALC_SCREEN_NAME, CalcScreen(self))
|
|
|
|
self.show_screen(CALC_SCREEN_NAME)
|
|
|
|
|
2008-12-08 15:21:53 +00:00
|
|
|
def on_pix_screen(self):
|
|
|
|
self.init_screen(PIX_SCREEN_NAME, PixScreen(self))
|
|
|
|
self.show_screen(PIX_SCREEN_NAME)
|
|
|
|
|
|
|
|
def on_contacts_screen(self):
|
|
|
|
self.init_screen(CONTACTS_SCREEN_NAME, ContactsScreen(self))
|
|
|
|
self.show_screen(CONTACTS_SCREEN_NAME)
|
|
|
|
|
2008-12-10 18:58:28 +00:00
|
|
|
def on_sms_screen(self):
|
|
|
|
self.init_screen(SMS_SCREEN_NAME, SmsScreen(self))
|
|
|
|
self.show_screen(SMS_SCREEN_NAME)
|
|
|
|
|
2008-12-23 17:21:25 +00:00
|
|
|
def on_sms_screen_detail(self):
|
|
|
|
self.init_screen(SMS_DETAIL_SCREEN_NAME, SmsDetail(self))
|
|
|
|
self.show_screen(SMS_DETAIL_SCREEN_NAME)
|
|
|
|
|
2008-12-29 18:14:49 +00:00
|
|
|
def on_weather_screen(self):
|
|
|
|
self.init_screen(WEATHER_SCREEN_NAME, WeatherScreen(self))
|
|
|
|
self.show_screen(WEATHER_SCREEN_NAME)
|
|
|
|
|
2008-09-01 09:12:24 +00:00
|
|
|
|
2008-08-27 21:26:20 +00:00
|
|
|
class EvasCanvas(object):
|
2008-08-28 23:49:52 +00:00
|
|
|
def __init__(self, fullscreen, engine_name):
|
|
|
|
if engine_name == "x11":
|
|
|
|
engine = ecore.evas.SoftwareX11
|
2008-12-10 19:16:01 +00:00
|
|
|
# elif engine_name == "x11-16":
|
|
|
|
# if ecore.evas.engine_type_supported_get("software_x11_16"):
|
|
|
|
# engine = ecore.evas.SoftwareX11_16
|
2008-08-27 21:26:20 +00:00
|
|
|
else:
|
2008-08-28 23:49:52 +00:00
|
|
|
print "warning: x11-16 is not supported, falling back to x11"
|
|
|
|
engine = ecore.evas.SoftwareX11
|
2008-08-28 21:45:58 +00:00
|
|
|
|
2008-08-28 23:49:52 +00:00
|
|
|
self.evas_obj = engine(w=WIDTH, h=HEIGHT)
|
2008-08-27 21:26:20 +00:00
|
|
|
self.evas_obj.callback_delete_request = self.on_delete_request
|
|
|
|
self.evas_obj.callback_resize = self.on_resize
|
2008-08-28 21:45:58 +00:00
|
|
|
|
2008-09-01 09:12:24 +00:00
|
|
|
self.evas_obj.title = APP_TITLE
|
2008-08-27 21:26:20 +00:00
|
|
|
self.evas_obj.name_class = WM_INFO
|
2008-08-28 21:10:06 +00:00
|
|
|
self.evas_obj.fullscreen = fullscreen
|
2008-08-28 23:49:52 +00:00
|
|
|
# self.evas_obj.size = str(WIDTH) + 'x' + str(HEIGHT)
|
2008-09-05 22:35:35 +00:00
|
|
|
self.evas_obj.evas.image_cache_set(IMAGE_CACHE_SIZE*1024*1024)
|
|
|
|
self.evas_obj.evas.font_cache_set(FONT_CACHE_SIZE*1024*1024)
|
2008-08-27 21:26:20 +00:00
|
|
|
self.evas_obj.show()
|
2008-09-15 14:34:19 +00:00
|
|
|
|
2008-08-27 21:26:20 +00:00
|
|
|
def on_resize(self, evas_obj):
|
|
|
|
x, y, w, h = evas_obj.evas.viewport
|
|
|
|
size = (w, h)
|
|
|
|
for key in evas_obj.data.keys():
|
|
|
|
evas_obj.data[key].size = size
|
|
|
|
|
|
|
|
def on_delete_request(self, evas_obj):
|
|
|
|
ecore.main_loop_quit()
|
|
|
|
|
2008-09-01 09:12:24 +00:00
|
|
|
|
2008-08-27 21:26:20 +00:00
|
|
|
if __name__ == "__main__":
|
2008-08-31 03:50:33 +00:00
|
|
|
Dialer()
|
2008-08-27 21:26:20 +00:00
|
|
|
ecore.main_loop_begin()
|
|
|
|
|
2008-08-28 21:45:58 +00:00
|
|
|
'''
|
2008-08-27 21:26:20 +00:00
|
|
|
export LDFLAGS="$LDFLAGS -L/opt/e17/lib"
|
|
|
|
export PKG_CONFIG_PATH="/opt/e17/lib/pkgconfig:$PKG_CONFIG_PATH"
|
|
|
|
export PATH="$PATH:/opt/e17/bin"
|
|
|
|
export PYTHONPATH="/home/fgau/usr/lib/python2.5/site-packages"
|
|
|
|
'''
|
|
|
|
|