[pkg-fso-commits] [SCM] freesmartphone.org demo GUI branch, master, updated. milestone2-25-gf72c138
Jan Luebbe
jluebbe at debian.org
Tue Sep 2 10:26:31 UTC 2008
The following commit has been merged in the master branch:
commit d491d203ed24bbea19aefbb484a6955c0cdf88ca
Author: Jan Luebbe <jluebbe at debian.org>
Date: Thu Aug 28 17:55:19 2008 +0200
implement better handling for the gsm registration
diff --git a/data/themes/zhone.edc b/data/themes/zhone.edc
index aa68995..adf419b 100644
--- a/data/themes/zhone.edc
+++ b/data/themes/zhone.edc
@@ -24,10 +24,15 @@ fonts {
images {
image: "background.png" COMP;
image: "button_contacts.png" COMP;
+ image: "button_contacts_inactive.png" COMP;
image: "button_phone.png" COMP;
+ image: "button_phone_inactive.png" COMP;
image: "button_sms.png" COMP;
+ image: "button_sms_inactive.png" COMP;
image: "button_location.png" COMP;
+ image: "button_location_inactive.png" COMP;
image: "button_configuration.png" COMP;
+ image: "button_configuration_inactive.png" COMP;
image: "button_main_background.png" COMP;
image: "button_main_background_active.png" COMP;
image: "button_background.png" COMP;
@@ -113,6 +118,20 @@ styles {
action: STATE_SET "default" 0.0; \
target: part_name; \
}
+
+#define ACTIVATE_ICON(part_name) \
+ program { \
+ name: "activate_"part_name; \
+ signal: "activate_"part_name; \
+ action: STATE_SET "default" 0.0; \
+ target: part_name; \
+ } \
+ program { \
+ name: "deactivate_"part_name; \
+ signal: "deactivate_"part_name; \
+ action: STATE_SET "inactive" 0.0; \
+ target: part_name; \
+ }
#define SELECTABLE(part_name) \
program { \
@@ -1226,6 +1245,13 @@ collections {
normal: "button_"part_name".png"; \
} \
} \
+ description { \
+ state: "inactive" 0.0; \
+ inherit: "default" 0.0; \
+ image { \
+ normal: "button_"part_name"_inactive.png"; \
+ } \
+ } \
}
ICON("phone", 0, 0);
ICON("contacts", 0, 1);
@@ -1235,10 +1261,15 @@ collections {
}
programs {
ACTIVATE("target_phone");
+ ACTIVATE_ICON("target_icon_phone");
ACTIVATE("target_contacts");
+ ACTIVATE_ICON("target_icon_contacts");
ACTIVATE("target_sms");
+ ACTIVATE_ICON("target_icon_sms");
ACTIVATE("target_location");
+ ACTIVATE_ICON("target_icon_location");
ACTIVATE("target_configuration");
+ ACTIVATE_ICON("target_icon_configuration");
TRANSITION();
}
diff --git a/src/zhone b/src/zhone
index e0d595e..7f6861b 100755
--- a/src/zhone
+++ b/src/zhone
@@ -97,29 +97,29 @@ class pyphone_main(edje_group):
#----------------------------------------------------------------------------#
def __init__(self, main):
edje_group.__init__(self, main, "main")
+ self.targets = {
+ "phone": False,
+ "contacts": False,
+ "sms": False,
+ "location": False,
+ "configuration": True,
+ }
+ self.update()
+
+ def update( self ):
+ for key, value in self.targets.items():
+ if value:
+ self.signal_emit( "activate_target_icon_%s" % key, "" )
+ else:
+ self.signal_emit( "deactivate_target_icon_%s" % key, "" )
@edje.decorators.signal_callback("mouse,clicked,1", "target_*")
def on_edje_signal_button_pressed(self, emission, source):
target = source.split('_', 1)[1]
+ if not self.targets[target]:
+ return
if target == "phone" and not self.main.groups["call"].status in ["idle" , "release"]:
target = "call"
- if target == "phone":
- if ( dbus_object.gsm_device_obj is not None ) and dbus_object.gsm_network_iface.GetStatus()["registration"] == 'unregistered':
- try:
- dbus_object.gsm_device_iface.SetAntennaPower(True)
- dbus_object.gsm_network_iface.Register()
- except DBusException, e:
- # TODO handle this better
- logger.exception( "can't power on antenna and register" )
- try:
- authstatus = dbus_object.gsm_sim_iface.GetAuthStatus()
- if authstatus == "SIM PUK":
- target = "puk"
- elif authstatus == "SIM PIN":
- target = "pin"
- except DBusException, e:
- logger.exception( "can't get auth status!?" )
-
self.main.transition_to(target)
#----------------------------------------------------------------------------#
@@ -400,6 +400,8 @@ class pyphone_sms(edje_group):
self.messagebook = result
self.ready = True
self.updateList()
+ self.main.groups["main"].targets["sms"] = True
+ self.main.groups["main"].update()
def cbMessagebookError( self, e ):
logger.warning( "error while retrieving messagebook" )
@@ -684,6 +686,8 @@ class pyphone_contacts(edje_group):
self.phonebook.sort( key = lambda x: x[1].lower() )
self.ready = True
self.updateList()
+ self.main.groups["main"].targets["contacts"] = True
+ self.main.groups["main"].update()
def cbPhonebookError( self, e ):
logger.error( "error while retrieving phonebook %s" % e )
@@ -1583,6 +1587,125 @@ class pyphone_error( edje_group ):
self.signal_emit( "invisible", "" )
#----------------------------------------------------------------------------#
+class GSMAgent( object ):
+#----------------------------------------------------------------------------#
+ def __init__( self, main ):
+ self.main = main
+ self.state = "Waiting for DBus"
+ self.onState = []
+
+ def setState( self, state ):
+ logger.debug( state )
+ self.state = state
+ for cb in self.onState:
+ cb( state )
+
+ def cbDBusReady( self ):
+ """
+ This is called to start the authentication process
+ """
+ self.setState( "Enabling GSM" )
+ dbus_object.gsm_device_iface.SetAntennaPower(
+ True,
+ reply_handler=self.cbAntennaPowerReply,
+ error_handler=self.cbAntennaPowerError
+ )
+
+ def cbAntennaPowerReply( self ):
+ self.setState( "Reading authentication status" )
+ dbus_object.gsm_sim_iface.GetAuthStatus(
+ reply_handler=self.cbAuthStatusReply,
+ error_handler=self.cbAuthStatusError
+ )
+
+ def cbAntennaPowerError( self, e ):
+ self.setState( "Failed to enable GSM" )
+ logger.exception( e )
+
+ def cbAuthStatusReply( self, authstatus ):
+ if authstatus == "READY":
+ self.setState( "Registering to network" )
+ dbus_object.gsm_network_iface.Register(
+ reply_handler=self.cbRegisterReply,
+ error_handler=self.cbRegisterError
+ )
+ elif authstatus == "SIM PIN":
+ self.setState( "Waiting for PIN" )
+ self.main.groups["pin_edit"].setup(
+ "main",
+ "", # number
+ "Enter PIN", # title
+ None, # reference
+ self.cbPINDone
+ )
+ elif authstatus == "SIM PUK":
+ self.setState( "Waiting for PUK" )
+ self.main.groups["pin_edit"].setup(
+ "main",
+ "", # number
+ "Enter PUK", # title
+ None, # reference
+ self.cbPUKDone
+ )
+ else:
+ logger.exception( "Unkown authentication status %s" % authstatus )
+
+ def cbAuthStatusError( self, e ):
+ self.setState( "Failed to read authentication status" )
+ logger.exception( e )
+
+ def cbPINDone( self, pin, *args ):
+ self.setState( "Sending PIN" )
+ dbus_object.gsm_sim_iface.SendAuthCode(
+ pin,
+ reply_handler=self.cbAuthCodeReply,
+ error_handler=self.cbAuthCodeError
+ )
+
+ def cbAuthCodeReply( self ):
+ self.cbAuthStatusReply( "READY" )
+
+ def cbAuthCodeError( self ):
+ # retry
+ self.cbAntennaPowerReply()
+
+ def cbPUKDone( self, puk, *args ):
+ self.main.groups["pin_edit"].setup(
+ "main",
+ "", # number
+ "Enter new PIN", # title
+ puk, # reference
+ self.cbNewPINDone
+ )
+
+ def cbNewPINDone( self, pin, puk ):
+ self.setState( "Sending PUK and new PIN" )
+ dbus_object.gsm_sim_iface.Unlock(
+ pin, puk,
+ reply_handler=self.cbUnlockReply,
+ error_handler=self.cbUnlockError
+ )
+
+ def cbUnlockReply( self ):
+ self.cbAuthStatusReply( "READY" )
+
+ def cbUnlockError( self ):
+ # retry
+ self.cbAntennaPowerReply()
+
+ def cbRegisterReply( self ):
+ self.setState( "Registered to network" )
+ self.main.groups["main"].targets["phone"] = True
+ self.main.groups["main"].update()
+ if dbus_object.gsm_sim_iface.GetSimReady():
+ self.main.groups["contacts"].prepare()
+ self.main.groups["sms"].prepare()
+
+ def cbRegisterError( self, e ):
+ self.setState( "Failed to register to network" )
+ logger.exception( e )
+
+#----------------------------------------------------------------------------#
class GUI(object):
#----------------------------------------------------------------------------#
def __init__( self, options, args ):
@@ -1597,6 +1720,10 @@ class GUI(object):
size = options.geometry
)
+ self.agents = {}
+
+ self.agents["gsm"] = GSMAgent( self )
+
self.groups = {}
self.groups["swallow"] = edje_group(self, "swallow")
@@ -1673,23 +1800,7 @@ class GUI(object):
logger.debug( "dbus_objectInitOK!" )
if dbus_object.gsm_device_obj is not None:
- try:
- dbus_object.gsm_device_iface.SetAntennaPower(True)
- dbus_object.gsm_network_iface.Register()
- if dbus_object.gsm_sim_iface.GetSimReady():
- self.groups["contacts"].prepare()
- self.groups["sms"].prepare()
- except DBusException, e:
- # TODO handle this better
- logger.exception( "can't set antenna power and register" )
- try:
- authstatus = dbus_object.gsm_sim_iface.GetAuthStatus()
- if authstatus == "SIM PUK":
- self.transition_to("puk")
- elif authstatus == "SIM PIN":
- self.transition_to("pin")
- except DBusException, e:
- logger.exception( "can't get auth status" )
+ self.agents["gsm"].cbDBusReady()
if dbus_object.device_power_iface is not None:
# Update Battery charge as soon as we have DBus
@@ -1725,10 +1836,11 @@ class GUI(object):
policy = dbus_object.usage_iface.GetResourcePolicy( resourcename )
if policy == 'enabled':
items[-1] = "+" + items[-1]
- continue
elif policy == 'disabled':
items[-1] = "-" + items[-1]
- continue
+ if resourcename == "GPS":
+ self.groups["main"].targets["location"] = True
+ self.groups["main"].update()
self.groups["swallow"].part_text_set( "label_top_right", u" ".join( items ) )
def update_network( self, **args):
--
freesmartphone.org demo GUI
More information about the pkg-fso-commits
mailing list