Beispiel #1
0
    def run(self, parent, standalone=False):

        ##set edje file to be used
        ##TODO: make one edje file per plugin
        self.edje_file = os.path.join(os.path.dirname(__file__), 'msgs.edj')

        ##get message service and list of all messages
        self.contact_service = tichy.Service.get('Contacts')
        self.contacts = self.contact_service.contacts

        ##sort contact by date
        def comp2(m1, m2):
            return cmp(str(m1.name).lower(), str(m2.name).lower())

        self.contacts.sort(comp2)

        ##get message service and list of all messages
        self.msgs_service = tichy.Service.get('Messages')

        self.messages = self.msgs_service.messages

        self.window = gui.elm_list_window(self.edje_file, "main", "list", None,
                                          None, True)
        self.edje_obj = self.window.main_layout

        ##sort messages by date
        def comp(m1, m2):
            return cmp(m2.timestamp, m1.timestamp)

        self.list_label = [('label', 'peer'), ('label-number', 'text'),
                           ('status', 'status'), ('direction', 'direction')]

        self.item_list = gui.elm_list(self.messages, self.window,
                                      self.edje_file, "item", self.list_label,
                                      comp)

        self.edje_obj.add_callback("*", "messaging", self.create_msg)
        self.item_list.add_callback("*", "messaging", self.adv_msg)
        self.item_list.add_callback("save", "*", self.create_contact)

        ## close the Tele app, with the back button (signal, source, method)
        self.edje_obj.add_callback("back", "edje", self.signal)

        self.oid = self.contacts.connect('inserted',
                                         self.item_list._redraw_view)

        self.item_list.add_callback("details", "*", self.msg_details)

        parent.emit("unblock")

        i, args = yield tichy.WaitFirst(
            tichy.Wait(self.window, 'delete_request'),
            tichy.Wait(self.window, 'back'),
            tichy.Wait(self.window.window, 'closing'))
        logger.info('Messages closing')

        if i != 2:
            self.contacts.disconnect(self.oid)
            self.window.delete()
            del self.item_list
Beispiel #2
0
    def run(self, window, category='main'):
        self.category = category
        main = self.category == 'main'
        frame = self.view(window, title=self.category,
                          back_button=not main)
        # We populate the frame with all the applications
        self.list_view = None
        self._populate(frame)

        def run_lock(action, app, view):
            tichy.Service('ScreenLock').run(view.window)

        lock_item = frame.actor.new_action('Screen Lock')
        # the item does not really toggle back.
        # we will need a one that does 'launched' probably
        lock_item.connect('activated', run_lock)

        # If the design change we repopulate the frame This is a
        # little bit tricky. We use the 'changed' signal from the
        # Service('Design') base object...

        def on_design_changed(s, design):
            self._populate(frame)
        tichy.Service('Design').base.connect('changed', on_design_changed)

        quit_item = frame.actor.new_action('Quit')
        yield tichy.WaitFirst(tichy.Wait(quit_item, 'activated'),
                              tichy.Wait(frame, 'back'))
Beispiel #3
0
    def ask(self, card, level):
        logger.info("ask")
        question = card.q

        logger.info("generate answers set")
        # We also use 3 random value from the dict
        rand_answers = [random.choice(self.full_dic).a for i in range(3)]
        answers = rand_answers + [card.a]
        random.shuffle(answers)

        self.question_text.value = question
        self.choices.clear()

        choices = [Choice(a) for a in answers]

        for c in choices:
            self.choices.append(c)

        logger.info("wait for answer")
        ret = yield tichy.WaitFirst(
            *[tichy.Wait(c, 'selected') for c in choices])
        ret = answers[ret[0]]
        if ret == card.a:
            # Correct answer
            #             yield tichy.Dialog(self.window,
            #                                "Correct", "%s : %s" %
            #                                (card.a, card.comment or ''))
            yield Answer(self.window, card, True)
            yield True
        else:
            # yield tichy.Dialog(self.window, "Wrong Answer", "")
            yield Answer(self.window, card, False)
            yield False
Beispiel #4
0
    def run(self, parent=None, standalone=False):

        ##set edje_file
        self.edje_file = os.path.join(os.path.dirname(__file__), 'tele.edj')

        self.window = gui.elm_layout_window(self.edje_file, "main", None, None,
                                            True)
        self.edje_obj = self.window.main_layout

        ##connect to tichy's contacts service
        self.contact_service = tichy.Service.get('Contacts')

        ##connect to tichy's ussd service
        self.ussd_service = tichy.Service.get('Ussd')
        self.edje_obj.add_callback("num_field_pressed", "*",
                                   self.num_field_action)

        self.edje_obj.add_callback("*", "embryo", self.embryo)
        self.edje_obj.add_callback("*", "call", self.call)

        ## close the Tele app, with the back button
        self.edje_obj.add_callback("back", "edje", self.signal)

        parent.emit("unblock")

        ##wait until main object emits back signal or delete is requested
        i, args = yield tichy.WaitFirst(
            tichy.Wait(self.window, 'delete_request'),
            tichy.Wait(self.window, 'back'),
            tichy.Wait(self.window.window, 'closing'),
            tichy.Wait(self.edje_obj, 'back'))
        logger.info('Tele closing')

        if i != 2:
            self.window.delete()
Beispiel #5
0
    def run(self, parent, standalone=False):

        ##set edje file to be used
        ##TODO: make one edje file per plugin
        self.edje_file = os.path.join(os.path.dirname(__file__),'people.edj')

        ##get contact service and list of all contacts
        self.contact_service = tichy.Service.get('Contacts')
        self.contacts = self.contact_service.contacts

        ##sort contact by name
        def comp(m1, m2):
            return cmp(str(m1.name).lower(), str(m2.name).lower())

        ##generate app-window
        self.window = gui.elm_list_window(self.edje_file, "main", "list", None, None, True)
        self.edje_obj = self.window.main_layout

        self.list_label = [('label','name')]
        self.item_list = gui.elm_list(self.contacts, self.window, self.edje_file, "item", self.list_label, comp, True)
       
        self.item_list.add_callback("contact_details", "*", self.contact_details)
        self.item_list.add_callback("send_all", "fold-back", self.self_test)
        self.item_list.add_callback("create_message", "*", self.create_msg)

        self.edje_obj.add_callback("back-button", "*", self.signal)
        self.edje_obj.add_callback("add_contact", "*", self.create_contact)
        self.edje_obj.add_callback("*", "dict", self.openDict)

        ##wait until main object emits back signal or delete is requested
        
        #self.window.scroller.elm_obj.focus()
        #self.item_list.jump_to_index('q')
        parent.emit("unblock")
        
        yield tichy.WaitFirst(tichy.Wait(self.window, 'delete_request'),tichy.Wait(self.window, 'back'))
        logger.info('People closing')
        #self.main.emit('closed')
        
        self.window.delete()
Beispiel #6
0
    def run(self,
            window,
            text="",
            name=None,
            input_method=None,
            variable=None):

        logger.info("PIN2 called")
        ##set edje_file
        self.edje_file = os.path.join(os.path.dirname(__file__), 'tele.edj')

        self.main = gui.elm_layout_window(self.edje_file, "pin_enter")
        #logger.info("PIN2 main generated")

        if hasattr(self.main.bg_m, "tb"):
            tb = self.main.bg_m.tb.Edje
            tb.signal_emit("hide_clock", "*")
            tb.signal_emit("show_pin_title", "*")

        self.edje_obj = self.main.main_layout.Edje

        if text != "":
            tb.part_text_set("title", text)

        self.edje_obj.signal_callback_add("*", "sending_pin",
                                          self.call_btn_pressed)
        #self.edje_obj.signal_callback_add("*", "embryo", self.embryo)

        i, args = yield tichy.WaitFirst(
            tichy.Wait(self.main, 'value_received'),
            tichy.Wait(self.main.window, 'closing'))

        if i == 0:  #value_received
            number = self.edje_obj.part_text_get("pin-text")
            if variable != None:
                variable.value = number
            self.main.delete()
            yield number
        elif i == 1:
            tichy.mainloop.quit()
Beispiel #7
0
 def run(self, parent, number, name, contact, mode, layout, *args, **kargs):
     try:
         self.edje_file = os.path.join(os.path.dirname(__file__), 'people.edj')
         number_layout = 0
         text_layout = 0
         send = 0
         
         if contact != None:
             name = unicode(contact.name).encode("utf-8")
             number = str(contact.tel)
             layout.elm_obj.hide()
         
         if number == "":
             full = True
         else:
             full = False
         
         while True:
             if full or mode == "number":
                 parent.window.elm_obj.keyboard_mode_set(gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
                 if number_layout == 0:
                     number_layout =  gui.elm_layout(parent.window, self.edje_file, "edit_number")
                     edje_obj = number_layout.elm_obj.edje_get()
                     edje_obj.part_text_set('num_field-text', number)
                     number_layout.elm_obj.show()
                     parent.main_layout.elm_obj.hide()
                 else:
                     number_layout.elm_obj.show()
                 parent.bg.elm_obj.content_set("content-swallow", number_layout.elm_obj)
                 i, args = yield tichy.WaitFirst(Wait(number_layout, 'back'), Wait(number_layout, 'next'))
                 if i == 0: #back
                     print "breaking"
                     break
                 if i == 1: #next
                     number_layout.elm_obj.hide()
                     number = edje_obj.part_text_get('num_field-text') 
                     if mode == "number":
                         send = 1
                         break
             
             if mode != "number":
                 parent.window.elm_obj.keyboard_mode_set(gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_ON)  
                 if text_layout == 0:
                     text_layout = gui.elm_layout(parent.window, self.edje_file, "CreateContact")
                     edje_obj = text_layout.elm_obj.edje_get()
                     text_layout.elm_obj.show()
                     parent.main_layout.elm_obj.hide()
                     textbox = gui.elementary.Entry(parent.window.elm_obj)
                     textbox.single_line_set(True)
                     textbox.color_set(255, 255, 255, 255)
                     textbox.entry_set(name)
                     textbox.size_hint_weight_set(1.0, 1.0)
                     text_layout.elm_obj.content_set('entry', textbox)
                     textbox.editable_set(True)        
                 
                 else:
                     text_layout.elm_obj.show()
                 parent.bg.elm_obj.content_set("content-swallow", text_layout.elm_obj)
                 
                 textbox.focus()
                 textbox.show()
                 
                 i, args = yield tichy.WaitFirst(Wait(text_layout, 'back'), Wait(text_layout, 'save'))
                 
                 if i == 0: #back
                     if full:
                         text_layout.elm_obj.hide()
                         parent.window.elm_obj.keyboard_mode_set(gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
                         continue
                     else:
                         break
                 if i == 1: #save
                     send = 1
                     break
         if send == 1:
             if text_layout:
                 text_layout.elm_obj.edje_get().signal_emit("save-notice","*")
             contacts_service = tichy.Service.get('Contacts')
             if contact not in contacts_service.contacts:
                 name = unicode(textbox.entry_get()).replace("<br>","").encode("utf-8")
                 new_contact = contacts_service.create(name.strip(),tel=str(number))
                 contacts_service.add(new_contact)
                 contacts_service.contacts.emit('inserted')
             else:
                 if mode == "name":
                     name = unicode(textbox.entry_get()).replace("<br>","").encode("utf-8")
                     logger.info("updating name")
                     contact.name = name.strip()
                 elif mode == "number":
                     logger.info("updating number")
                     contact.tel = number
                 layout.elm_obj.show()
         parent.window.elm_obj.keyboard_mode_set(gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
         if number_layout:
             number_layout.delete()
         if text_layout:
             text_layout.delete()
         parent.restore_orig()    
         ret = "done"
         yield ret
     except Exception, e:
         print e
         print Exception
Beispiel #8
0
    def run(self, parent, number, name=None):
        """show the Caller window

        :Parameters:
        
            parent : `tichy.gui.Widget`
                The parent window

            number : str | `tichy.Text` | Call object

                If the number is a string, we consider it to the
                number to call, otherwise we consider it to be a Call
                object that is already active.
        """
        # We open a new window for a call
        #logger.info("Caller run")

        print "caller run"
        print "in caller: ", name
        self.gsm_service = tichy.Service('GSM')

        #print parent
        #print dir(parent)
        main = parent
        #main = parent
        #main.etk_obj.visibility_set(1)
        #main = parent
        main.etk_obj.title_set('Paroli Call')

        self.edje_file = os.path.join(os.path.dirname(__file__),
                                      'paroli-dialer.edj')
        self.edje_obj = gui.edje_gui(main, 'tele', self.edje_file)
        self.edje_obj.edj.signal_callback_add("func_btn", "*", self.func_btn)
        self.edje_obj.edj.signal_callback_add("add_digit", "*", self.add_digit)
        self.edje_obj.edj.signal_callback_add("*", "*", self.gui_signals)
        #self.edje_obj.edj.signal_callback_add("num_field_pressed", "*", self.num_field_pressed)

        #self.window = gui.Window(parent)
        #frame = self.view(self.window, title='Dialer')
        #vbox = gui.Box(frame, axis=1)

        #text = tichy.Text("Initialization")
        #text.view(vbox)

        try:
            # The case when we have an incoming call
            # XXX: we should use an other way to check for a call object !
            if not isinstance(number, (basestring, tichy.Text)):
                call = number
                #print dir(call)
                self.edje_obj.edj.signal_emit('to_incoming_state', "*")
                #self.edje_obj.edj.part_text_set('active-call',call.__id)
                self.edje_obj.edj.part_text_set('num_field-text',
                                                str(call.number))
                self.edje_obj.edj.layer_set(2)
                self.edje_obj.edj.show()

                def make_active(emission, source, param):
                    call.activate()
                    print "making active"

                self.edje_obj.edj.signal_callback_add("activate_call", "*",
                                                      make_active)

            else:  # If not it means we want to initiate the call first
                if name:
                    self.edje_obj.edj.part_text_set('num_field-text',
                                                    str(name))
                else:
                    self.edje_obj.edj.part_text_set('num_field-text',
                                                    str(number))
                self.edje_obj.edj.signal_emit('to_dialing_state', "*")
                self.edje_obj.edj.layer_set(2)
                self.edje_obj.edj.show()
                #try:
                call = self.gsm_service.create_call(number)
                call.initiate()

                #except Exception,e :
                #print e

                def call_release_pre(emission, source, param):
                    try:
                        call.release()
                    except Exception, e:
                        print "exception here in pre state"
                        call.emit('released')

                self.edje_obj.edj.signal_callback_add("release_call", "*",
                                                      call_release_pre)

            i, args = yield tichy.WaitFirst(tichy.Wait(call, 'activated'),
                                            tichy.Wait(call, 'released'))
            if i == 0:  #activated
                print "call activated"
                self.edje_obj.edj.signal_emit('to_active_state', "*")
                self.edje_obj.edj.part_text_set('num_field-text',
                                                str(call.number))

                #print 'should be an active call here: ', self.gsm_service.gsm_call.ListCalls().__contains__('active')
                def call_release(emission, source, param):
                    print "call releasing"
                    try:
                        call.release()
                    except Exception, e:
                        print e
                        print "exception here"
                        call.emit('released')
                        #self.edje_obj.edj.signal_emit('notfound',"*")
                        #yield tichy.Wait(call, 'released')

                self.edje_obj.edj.signal_callback_add("release_call", "*",
                                                      call_release)
                yield tichy.WaitFirst(tichy.Wait(call, 'released'))
Beispiel #9
0
    def run(self, parent=None, standalone=False):
        #logger.info('launcher launching')
        self.ready = 0
        self.standalone = tichy.config.getboolean('standalone', 'activated',
                                                  False)
        self.advanced = tichy.config.getboolean('advanced-mode', 'activated',
                                                False)

        self.settings = tichy.config.getboolean('settings', 'activated', False)

        self.edje_file = os.path.join(os.path.dirname(__file__),
                                      'paroli-launcher.edj')

        self.window = gui.elm_layout_window(self.edje_file, "main", None, None,
                                            True)

        self.edje_obj = self.window.main_layout
        if hasattr(self.window.bg_m, "tb"):

            self.window.bg_m.tb.elm_obj.edje_get().signal_emit(
                "hide_clock", "*")

        self.active_app = None

        if self.advanced == False:
            ##create list of apps from list of registered apps
            apps = ['Paroli-I/O', "Msgs", "Paroli-Dialer", "Paroli-Contacts"]
        else:
            apps = []
            for app in tichy.Application.subclasses:
                if app.category == 'launcher':
                    logger.info("adding - %s to launcher", app.name)
                    apps.append(app)

        box = gui.elm_box(self.window.window.elm_obj)
        self.app_objs = {}
        apps.sort(key=lambda x: x.name)  # sort apps alphabetically.
        for app in apps:
            logger.info("app: %s %s", str(app), type(app))
            link_obj = gui.elm_layout(self.window.window, self.edje_file,
                                      'link')
            link_obj.elm_obj.size_hint_min_set(400, 60)
            box.elm_obj.pack_end(link_obj.elm_obj)
            link_obj.elm_obj.show()
            link_obj.Edje.part_text_set("texter", app.name)
            link_obj.Edje.part_text_set(
                "testing_textblock",
                "<normal>" + app.name + "</normal><small></small>")
            if hasattr(app, 'launcher_info'):
                attr = app.launcher_info
            else:
                attr = 0
            link_obj.elm_obj.show()
            link_obj.add_callback("*", "launch_app", self.launch_app)
            app_obj = [link_obj, attr]
            self.app_objs[app.name] = app_obj

        box.elm_obj.show()
        self.edje_obj.elm_obj.content_set("link-box", box.elm_obj)
        self.storage = tichy.Service.get('TeleCom2')
        self.edje_obj.add_callback("*", "launch_app", self.launch_app)
        self.edje_obj.add_callback("*", "embryo", self.embryo)
        self.edje_obj.add_callback("quit_app", "*", self.quit_app)
        ##current hack
        #self.standalone = True

        self.msg = tichy.Service.get('Messages')
        if self.msg.ready == False:
            self.msg.connect('ready', self.unblock_screen)
        else:
            self.unblock_screen()

        self.busywin = tichy.Service.get('BusyWin')

        self.button = tichy.Service.get('Buttons')
        self.aux_btn_profile_conn = self.button.connect(
            'aux_button_pressed', self.switch_profile)

        if self.settings:
            self.aux_btn_settings_conn = self.button.connect(
                'aux_button_held', self.open_settings)

        self.prefs = tichy.Service.get('Prefs')
        self.audio_service = tichy.Service.get('Audio')

        self.ussd = tichy.Service.get('Ussd')
        self.ussd.connect('incoming', self.incoming_ussd)
        self.systime = tichy.Service.get('SysTime')
        self.alarm = tichy.Service.get('Alarm')

        self.ready = 1

        self.window.connect('block', self.block_edje)
        self.window.connect('unblock', self.unblock_edje)

        yield tichy.WaitFirst(tichy.Wait(self.window, 'backs'),
                              tichy.Wait(self.window.window, 'closing'))

        self.dialog = tichy.Service.get("Dialog")
        keep_alive = yield self.dialog.option_dialog(
            "shutdown",
            "Keep paroli running in the background? Note: if you click no you will not be able to receive calls anymore",
            "YES", "no")
        print "keep_alive", keep_alive

        if keep_alive == "no":
            logger.info("keep alive set to no: %s", str(keep_alive))
            tichy.mainloop.quit()
        else:
            logger.info("keep alive set to %s", str(keep_alive))

        if self.window.window.elm_obj.is_deleted() == False:
            self.window.delete()  # Don't forget to close the window
Beispiel #10
0
    def run(self, parent, sms, mode, layout=None, *args, **kargs):
        self.dialog = tichy.Service.get("Dialog")
        try:
            self.edje_file = os.path.join(os.path.dirname(__file__),
                                          'msgs.edj')
            number_layout = 0
            text_layout = 0
            send = 0
            number = ""
            full = False
            pre_text = None

            self.window = parent

            if layout != None:
                layout.elm_obj.hide()

            if mode != "reply":
                full = True
                number = ""
            else:
                sms.text = ""

            while True:

                if full:

                    parent.window.elm_obj.keyboard_mode_set(
                        gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)

                    if number_layout == 0:

                        number_layout = gui.elm_layout(parent.window,
                                                       self.edje_file,
                                                       "edit_number")

                        edje_obj = number_layout.elm_obj.edje_get()

                        edje_obj.part_text_set('num_field-text', number)

                        number_layout.elm_obj.show()

                        parent.main_layout.elm_obj.hide()

                    else:
                        logger.info("back pressed in text")
                        number_layout.elm_obj.show()
                        edje_obj = number_layout.elm_obj.edje_get()

                    edje_obj.signal_callback_add("num_field_pressed", "*",
                                                 self.num_field_action)
                    self.number_layout = number_layout
                    parent.bg.elm_obj.content_set("content-swallow",
                                                  number_layout.elm_obj)

                    number_layout.connect("too_short", self.error_win,
                                          "number too short")

                    i, args = yield tichy.WaitFirst(
                        Wait(number_layout, 'back'),
                        Wait(number_layout, 'next'))

                    if i == 0:  #back
                        break

                    if i == 1:  #next
                        number_layout.elm_obj.hide()
                        number = edje_obj.part_text_get('num_field-text')
                        sms.peer = number

                if sms.text == "" or mode == "forward":

                    text_layout = gui.elm_layout(parent.window, self.edje_file,
                                                 "CreateText")

                    parent.window.elm_obj.keyboard_mode_set(
                        gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_ON)

                    text_layout.elm_obj.layer_set(99)

                    edje_obj = text_layout.elm_obj.edje_get()

                    text_layout.elm_obj.show()

                    parent.main_layout.elm_obj.hide()

                    parent.bg.elm_obj.content_set("content-swallow",
                                                  text_layout.elm_obj)

                    textbox = gui.elementary.Entry(parent.window.elm_obj)

                    textbox.color_set(255, 255, 255, 255)

                    if pre_text != None:
                        textbox.entry_set(unicode(pre_text).encode("utf-8"))
                    else:
                        textbox.entry_set(unicode(sms.text).encode("utf-8"))

                    self.counter(textbox, "event", text_layout)

                    textbox.size_hint_weight_set(1.0, 1.0)

                    sc = gui.elementary.Scroller(parent.window.elm_obj)
                    sc.content_set(textbox)

                    textbox.line_wrap_set(True)
                    text_layout.elm_obj.content_set('entry', sc)
                    sc.show()

                    textbox.editable_set(True)

                    textbox.focus()
                    textbox.show()

                    textbox.on_key_down_add(self.counter, text_layout)

                    text_layout.connect("send_request", self.send_request,
                                        textbox)

                i, args = yield tichy.WaitFirst(Wait(text_layout, 'back'),
                                                Wait(text_layout, 'send'))
                if i == 0:  #back
                    if full:
                        text_layout.elm_obj.hide()
                        logger.info("win set False")
                        parent.window.elm_obj.keyboard_mode_set(
                            gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
                        pre_text = unicode(
                            textbox.entry_get()).encode("utf-8").replace(
                                "<br>", "")
                        pre_text = pre_text.strip()
                        textbox.on_key_down_del(self.counter)
                        continue
                    else:
                        print "breaking"
                        break
                if i == 1:  #send
                    send = 1
                    logger.info("win set False")
                    parent.window.elm_obj.keyboard_mode_set(
                        gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
                    break

            logger.info("broke loop")
            if send == 1:
                text = unicode(textbox.entry_get()).encode("utf-8").replace(
                    "<br>", "")
                sms.text = text.strip()
                text_layout.elm_obj.edje_get().signal_emit("save-notice", "*")
                yield self.send_sms(sms)

            if number_layout:
                number_layout.delete()

            if text_layout:
                logger.info("deleting text layout")
                text_layout.delete()
                parent.window.elm_obj.keyboard_mode_set(
                    gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)

            if layout != None:
                layout.elm_obj.show()
            else:
                parent.restore_orig()

            ret = "done"

            yield ret

        except Exception, e:
            print e
            print Exception
Beispiel #11
0
                def call_release_pre(emission, source, param):
                    # XXX: we should connect to the error callback

                    logger.info('call_release_pre')
                    self.edje_obj.signal_callback_del("release", "call",
                                                      call_release_pre)
                    call.release().start()
                    self.storage.call = None
                    logger.info('call_release_pre done')

                self.edje_obj.signal_callback_add("release", "call",
                                                  call_release_pre)

            i, args = yield tichy.WaitFirst(
                tichy.Wait(call, 'activated'), tichy.Wait(call, 'released'),
                tichy.Wait(self.main, 'call_error'))
            if i == 0:  #activated
                logger.debug("call activated")

                if self.audio_service.muted == 1:
                    self.audio_service.audio_toggle()

                self.edje_obj.signal_emit('to_active_state', "*")

                def call_release(emission, source, param):
                    logger.info("releasing call")
                    # XXX: we should connect to the error callback
                    self.edje_obj.signal_callback_del("release", "call",
                                                      call_release)
                    try:
Beispiel #12
0
    def run(self, parent=None, standalone=False):
        ##to be standardized
        self.edje_file = os.path.join(os.path.dirname(__file__), 'i-o.edj')

        self.gsm_service = tichy.Service.get('GSM')
        self.callLogs = self.gsm_service.logs

        ##get message service and list of all messages
        self.contact_service = tichy.Service.get('Contacts')
        self.contacts = self.contact_service.contacts

        ##sort contact by date
        def comp2(m1, m2):
            return cmp(str(m1.name).lower(), str(m2.name).lower())

        self.contacts.sort(comp2)

        ##generate app-window
        self.window = gui.elm_list_window(self.edje_file, "main", "list", None,
                                          None, True)
        self.edje_obj = self.window.main_layout

        def comp(m1, m2):
            return cmp(m2.timestamp, m1.timestamp)

        #  We use the Call object to as items in the call log
        self.list_label = [('label', 'number'), ('subtext', 'description')]
        self.item_list = gui.elm_list(self.callLogs, self.window,
                                      self.edje_file, "item", self.list_label,
                                      comp)

        self.edje_obj.add_callback("to_edit_mode", "*", self.to_edit_mode)
        self.edje_obj.add_callback("to_default_mode", "*",
                                   self.to_default_mode)

        ## close the Tele app, with the back button (signal, source, method)
        self.edje_obj.add_callback("back", "edje", self.signal)

        self.oid = self.contacts.connect('inserted',
                                         self.item_list._redraw_view)

        if len(self.callLogs) == 0:
            self.edje_obj.Edje.signal_emit("ListEmpty", "python")
            self.oid2 = self.callLogs.connect('inserted', self.restore_edit)

        self.item_list.add_callback("new_call", "*", self.create_call)
        self.item_list.add_callback("new_msg", "*", self.create_msg)
        self.item_list.add_callback("save_number", "*", self.create_contact)

        self.item_list.Elm_win = self.window.window

        parent.emit("unblock")

        i, args = yield tichy.WaitFirst(
            tichy.Wait(self.window, 'back'),
            tichy.Wait(self.window, 'delete_request'),
            tichy.Wait(self.window.window, 'closing'))

        for i in self.callLogs:
            i.missed = False
            i.check()

        self.callLogs.emit("modified")

        if i != 2:
            self.contacts.disconnect(self.oid)
            self.window.delete()
            del self.item_list