def __init__(self): # Initialize the GUI # edje.frametime_set(FRAMETIME) self.evas_canvas = EvasCanvas(FULLSCREEN) self.screens = {} # Register our own callbacks PyneoController.register_callback("gsm_phone_ringing", self.on_ringing) PyneoController.register_callback("gsm_phone_call_start", self.on_call_start) PyneoController.register_callback("gsm_phone_call_end", self.on_call_end) PyneoController.register_callback("show_gps_status_screen", self.on_gps_status_screen) PyneoController.register_callback("show_gps_map_screen", self.on_gps_map_screen) PyneoController.register_callback("show_dialer_screen", self.on_call_end) PyneoController.register_callback("show_lock_screen", self.on_lock_screen) PyneoController.register_callback("show_audio_screen", self.on_audio_screen) PyneoController.register_callback("show_screen", self.on_show_screen) # Initialize the D-Bus interface to pyneo dbus_ml = DBusEcoreMainLoop() self.system_bus = SystemBus(mainloop=dbus_ml) PyneoController.init() PyneoController.path_check(DB_PATH) PyneoController.db_check() DatabaseController.init() self.init_screen(DIALER_SCREEN_NAME, DialerScreen) PyneoController.show_dialer_screen() PyneoController.brightness_change(0) ecore.timer_add(1, self.load_screens)
def check_new_sms(class_, newmap): class_.notify.PlayTone('sms') res = dedbusmap(newmap) for n in res: sm = object_by_url(n) content = dedbusmap(sm.GetContent(dbus_interface=DIN_ENTRY, timeout=200)) DatabaseController.insert_new_sms('REC UNREAD', content['from_msisdn'], content['text'].encode('utf-8'), content['time']) print '--- NEW SMS:', content['from_msisdn'], content['time'], content['text'].encode('utf-8')
def first_check_new_sms(class_): try: res = class_.gsm_sms.ListAll(dbus_interface=DIN_STORAGE) for n in res: sm = object_by_url(n) content = dedbusmap(sm.GetContent(dbus_interface=DIN_ENTRY)) DatabaseController.insert_new_sms('REC UNREAD', content['from_msisdn'], content['text'].encode('utf-8'), content['time']) except: print '--- NULL new sms'
def on_gsm_wireless_status(class_, status_map): status = dedbusmap(status_map) print 'GSM NET Status: %s'%status if 'stat' in status: nw_status = status['stat'] if nw_status == 0: class_.notify_callbacks("gsm_unregistered") elif nw_status in (1, 5): class_.notify_callbacks("gsm_registered") elif nw_status == 2: class_.notify_callbacks("gsm_registering") elif nw_status == 3: class_.notify_callbacks("gsm_reg_denied") elif nw_status == 4: raise NotImplementedError("GSM registration has unknown state") for text in ['rssi', 'oper', 'lac', 'ci', 'mcc']: if text in status: class_.gsm_net_status[text] = status[text] if text == 'rssi': class_.notify_callbacks("gsm_signal_strength_change", status['rssi']) if text == 'oper': class_.notify_callbacks("gsm_operator_change", status['oper']) if text == 'mcc': results = DatabaseController.get_country_code(str(status['mcc'])) class_.gsm_net_status['cc'] = results[0][1] class_.gsm_net_status['country'] = results[0][0] class_.notify_callbacks("gsm_details", class_.gsm_net_status)
def CallEnd(newmap): class_.notify.StopTone('ring') class_.sys.Vibrate(0, 0, 0, dbus_interface=DIN_SYSTEM) class_.notify_callbacks("gsm_phone_call_end") class_.set_state_file('stereoout') newmap = dedbusmap(newmap) print '---', 'CallEnd' if class_.call: class_.call = None while class_.callsigs: class_.callsigs.pop().remove() DatabaseController.insert_history(class_.call_type, newmap['number']) if class_.call_type == 'missed': PyneoController.set_missed_call_icon('true') cp = ConfigParser(INI_PATH) cp.get_section_config('status').set('missed_calls', 'true') cp.save() class_.dialer_text_set("") class_.call_type = None class_.gsm_wireless.GetStatus(dbus_interface=DIN_WIRELESS)