* from GetSimInfo we can take imsi
* from last 6 letters get MCC
* from MCC get country code with GetCountryCodeForMccMnc
* then try to convert country code to country name with
  GetAllCountries, be aware it's using space instead '_'
  and sometimes different names (ie for St. Helen).
* and finally look for country name in /etc/phoneprefix

* with ogsmd we got country name as one field in GetSimInfo

* phoneprefix will be merged to fsotdld later and
  /org/freesmartphone/Data/World will provide api to get prefixes for
  MCC directly (but it will take some time, so pushing this ugly version
  for now).
---
 shr_settings_modules/shr_phoneutils.py |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/shr_settings_modules/shr_phoneutils.py 
b/shr_settings_modules/shr_phoneutils.py
index 99ca78a..fa76a35 100644
--- a/shr_settings_modules/shr_phoneutils.py
+++ b/shr_settings_modules/shr_phoneutils.py
@@ -165,10 +165,25 @@ class Phoneutils(module.AbstractModule):
                return self.Validate()
 
        def simInfoArrived(self, siminfo):
-               try:   
-                       if siminfo['country'] in self.countries:
-                               self.cc, self.ip, self.np = 
self.countries[siminfo['country']]
-                       else:  
+               try:
+                       country = None
+                       if 'country' in siminfo.keys():
+                               # country is in -> ogsmd
+                               country = siminfo['country']
+                       else:
+                               # country is not in -> fsogsmd
+                               mcc = siminfo['imsi'][:6]
+                               data_world_obj = self.dbus.get_object( 
'org.freesmartphone.odatad', '/org/freesmartphone/Data/World' )
+                               data_world_iface = 
dbus.Interface(data_world_obj, 'org.freesmartphone.Data.World')
+                               country_code = 
data_world_iface.GetCountryCodeForMccMnc(mcc)
+                               country_codes = 
data_world_iface.GetAllCountries()
+                               for item in country_codes:
+                                       if item[0] == country_code:
+                                               country = item[1].replace(" ", 
"_")
+                       if country in self.countries:
+                               self.cc, self.ip, self.np = 
self.countries[country]
+                               print self.cc;
+                       elif 'dial_prefix' in siminfo.keys():
                                prefix = siminfo['dial_prefix']
                                prefix.replace('+','')
                                self.cc, self.ip, self.np = 
self.countries[self.prefixes[prefix]]
-- 
1.7.0.4

_______________________________________________
Shr-devel mailing list
[email protected]
http://lists.shr-project.org/mailman/listinfo/shr-devel

Reply via email to