2008-10-01 21:50:48 +00:00
|
|
|
#!/usr/bin/env python2.5
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
__author__ = "Soeren Apel (abraxa@dar-clan.de), Frank Gau (fgau@gau-net.de), Thomas Gstaedner (thomas (a) gstaedtner (.) net)"
|
|
|
|
__version__ = "prototype"
|
|
|
|
__copyright__ = "Copyright (c) 2008"
|
|
|
|
__license__ = "GPL3"
|
|
|
|
|
|
|
|
from epydial import *
|
|
|
|
|
|
|
|
class GsmStatusScreen(EdjeGroup):
|
|
|
|
def __init__(self, screen_manager):
|
|
|
|
EdjeGroup.__init__(self, screen_manager, GSM_STATUS_SCREEN_NAME)
|
|
|
|
|
|
|
|
def register_pyneo_callbacks(self):
|
|
|
|
PyneoController.register_callback("power_status_gsm", self.on_power_status_gsm)
|
2008-12-08 15:21:53 +00:00
|
|
|
PyneoController.register_callback("device_status", self.on_device_status)
|
|
|
|
PyneoController.register_callback("gsm_details", self.on_gsm_details)
|
|
|
|
PyneoController.register_callback("scan_operator", self.on_scan_operator)
|
2008-10-26 13:57:38 +00:00
|
|
|
PyneoController.register_callback("brightness_change", self.on_brightness_change)
|
|
|
|
|
2008-12-08 15:21:53 +00:00
|
|
|
def on_scan_operator(self, status):
|
|
|
|
operator = 'scan operator:<br>'
|
|
|
|
for n, v in status.items():
|
|
|
|
operator += v['oper'] + '<br>'
|
|
|
|
print 'provider', n, ':', v['oper']
|
|
|
|
self.part_text_set("scan_operator_caption", operator)
|
|
|
|
|
2008-10-26 13:57:38 +00:00
|
|
|
def on_brightness_change(self, status):
|
2008-12-08 15:21:53 +00:00
|
|
|
self.part_text_set("description_brightness", "brightness %s"%status+"%")
|
|
|
|
|
|
|
|
def on_device_status(self, status):
|
|
|
|
self.part_text_set("device_caption", \
|
|
|
|
"imei: %s<br>model: %s<br>revision: %s<br>manufacturer: %s" \
|
|
|
|
%(status['imei'], status['model'], status['revision'], status['manufacturer']))
|
2008-10-02 13:34:27 +00:00
|
|
|
|
2008-12-08 15:21:53 +00:00
|
|
|
def on_gsm_details(self, status):
|
|
|
|
global oper, lac, ci, rssi, mcc, cc, country
|
|
|
|
if status.has_key('oper'):
|
|
|
|
oper = status['oper']
|
|
|
|
if status.has_key('lac'):
|
|
|
|
lac = status['lac']
|
|
|
|
if status.has_key('ci'):
|
|
|
|
ci = status['ci']
|
|
|
|
if status.has_key('rssi'):
|
|
|
|
rssi = status['rssi']
|
|
|
|
if status.has_key('mcc'):
|
|
|
|
mcc = status['mcc']
|
|
|
|
connection = connect(DB_FILE_PATH)
|
|
|
|
cursor = connection.cursor()
|
|
|
|
cursor.execute("SELECT * FROM mcc WHERE mcc='" + str(mcc) + "'")
|
|
|
|
for row in cursor:
|
|
|
|
country = row[0]
|
|
|
|
cc = row[1]
|
|
|
|
self.part_text_set("gsm_details_caption", \
|
|
|
|
"operator: %s<br>lac/ci: %s/%s<br>rssi: %s<br>mcc/cc/country: %s/%s/%s" \
|
|
|
|
%(oper, lac, ci, rssi, mcc, cc, country))
|
2008-10-01 21:50:48 +00:00
|
|
|
|
|
|
|
def on_power_status_gsm(self, status):
|
|
|
|
if status: p_status = "on"
|
|
|
|
else: p_status = "off"
|
|
|
|
print '--- gsm device is ', p_status
|
|
|
|
self.part_text_set("button_11_caption", p_status)
|
2008-10-08 17:07:45 +00:00
|
|
|
self.part_text_set("pwr_caption", "gsm device is %s"%p_status)
|
2008-10-01 21:50:48 +00:00
|
|
|
|
2008-11-03 18:34:09 +00:00
|
|
|
@edje.decorators.signal_callback("mouse,up,1", "*")
|
2008-10-01 21:50:48 +00:00
|
|
|
def on_edje_signal_dialer_status_triggered(self, emission, source):
|
|
|
|
status = self.part_text_get("button_11_caption")
|
2008-12-08 15:21:53 +00:00
|
|
|
if source == "headline":
|
|
|
|
PyneoController.scan_operator()
|
2008-11-03 18:34:09 +00:00
|
|
|
if source == "button_12":
|
2008-10-01 21:50:48 +00:00
|
|
|
PyneoController.show_dialer_screen()
|
2008-10-26 13:57:38 +00:00
|
|
|
elif source == "on" and status == "on":
|
|
|
|
PyneoController.power_down_gsm()
|
2008-10-01 21:50:48 +00:00
|
|
|
elif source == "on" and status == "off":
|
|
|
|
PyneoController.power_up_gsm()
|
2009-02-12 18:24:28 +00:00
|
|
|
print 'source: ', source
|