コード例 #1
0
ファイル: __init__.py プロジェクト: vmx/paroli
    def run(self, parent=None, standalone=False):

        ##set edje_file
        self.edje_file = join(dirname(__file__), 'telephony.edj')

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

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

        ##connect to tichy's ussd service
        self.ussd_service = 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 WaitFirst(Wait(self.window, 'delete_request'),
                                  Wait(self.window, 'back'),
                                  Wait(self.window.window, 'closing'),
                                  Wait(self.edje_obj, 'back'))
        logger.info('Tele closing')

        if i != 2:
            self.window.delete()
コード例 #2
0
    def run(self, setting, parent, layout):
        self.edje_file = join(dirname(__file__), 'settings.edj')

        layout.elm_obj.hide()
        self.window = ElementaryListSubwindow(parent, self.edje_file,
                                              "numbersetting", "entry",
                                              layout.elm_obj)

        self.edje_obj = self.window.main_layout

        self.edje_obj.edje.signal_emit(str(setting.value), "set_text")

        i, args = yield WaitFirst(Wait(self.window.main_layout, 'save'),
                                  Wait(self.window.main_layout, 'back'),
                                  Wait(parent, 'back'))

        if i == 0:  ##save clicked
            self.edje_obj.edje.signal_emit("save-notice", "*")
            text = str(self.edje_obj.edje.part_text_get("num_field-text"))
            text = text.strip()
            setting.set(text).start()

        self.edje_obj.edje.visible_set(False)
        self.edje_obj.edje.delete()
        layout.elm_obj.show()
コード例 #3
0
def retry_on_sim_busy(method, *args):
    """Attempt a dbus call the the framework and retry if we get a sim
    busy error

    Every time we get a SIM busy error, we wait for the ReadyStatus
    signal, or 5 seconds, and we try again.

    If it fails 5 times, we give up and raise an Exception.
    """
    def is_busy_error(ex):
        """Check if an exception is due to a SIM busy error"""
        # There is a little hack to handle cases when the framework
        # fails to send the SIM.NotReady error.
        name = ex.get_dbus_name()
        msg = ex.get_dbus_message()
        return name == 'org.freesmartphone.GSM.SIM.NotReady' or \
            msg.endswith('SIM busy')

    bus = dbus.SystemBus(mainloop=tichy.mainloop.dbus_loop)
    gsm = bus.get_object('org.freesmartphone.ogsmd',
                         '/org/freesmartphone/GSM/Device',
                         follow_name_owner_changes=True)
    gsm_sim = dbus.Interface(gsm, 'org.freesmartphone.GSM.SIM')

    for i in range(5):
        try:
            ret = yield WaitDBus(method, *args)
            yield ret
        except dbus.exceptions.DBusException, ex:
            if not is_busy_error(ex):  # This is an other error
                raise
            logger.info("sim busy, retry in 5 seconds")
            yield WaitFirst(Sleep(5), WaitDBusSignal(gsm_sim, 'ReadyStatus'))
            continue
コード例 #4
0
    def motion_task(self, pos):
        """This is the tasklet we use when we are in a motion"""
        child = self.children[0]
        click_pos = pos[self.axis] - child.pos[self.axis]

        # First we wait to move more than move_distance before we
        # actually move the child
        while True:
            e, args = yield WaitFirst(Wait(self, 'mouse-up'),
                                      Wait(self, 'mouse-motion'))
            pos = args[0]
            if e == 0:
                child.mouse_up(pos)
                return
            if e == 1:
                dist = click_pos + child.pos[self.axis] - pos[self.axis]
                if abs(dist) > self.move_distance():
                    break

        # OK now we are in motion mode
        child.mouse_down_cancel()
        # child.store_surface = True
        last_dist = None
        while True:
            e, args = yield WaitFirst(Wait(self, 'mouse-up'),
                                      Wait(self, 'mouse-motion'))
            pos = args[0]
            if e == 0:
                break
            if e == 1:
                # We use a step of 8
                dist = (pos[self.axis] - self.click_pos) / 8 * 8
                if dist == last_dist:
                    continue
                last_dist = dist
                child.pos = child.pos.set(self.axis, dist)
                # We ensure that we don't go too far
                if child.pos[self.axis] + child.size[self.axis] < \
                        self.size[self.axis]:
                    child.pos = child.pos.set(
                        self.axis,
                        self.size[self.axis] - child.size[self.axis])
                if child.pos[self.axis] > 0:
                    child.pos = child.pos.set(self.axis, 0)
                self.emit('scrolled')

        child.store_surface = False
コード例 #5
0
    def run(self, parent, standalone=False):

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

        ##get message service and list of all messages
        self.contact_service = 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 = Service.get('Messages')

        self.messages = self.msgs_service.messages

        self.window = ElementaryListWindow(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 = ElementaryList(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 WaitFirst(Wait(self.window, 'delete_request'),
                                  Wait(self.window, 'back'),
                                  Wait(self.window.window, 'closing'))
        logger.info('Messages closing')

        if i != 2:
            self.contacts.disconnect(self.oid)
            self.window.delete()
            del self.item_list
コード例 #6
0
ファイル: wifi.py プロジェクト: vmx/paroli
    def init(self):
        logger.info('wifi service init')
        try:
            self.config_service = Service.get("Config")
            yield self.config_service.wait_initialized()
            self.usage_service = Service.get('Usage')
            yield self.usage_service.wait_initialized()
            yield self.usage_service.request_resource('Wifi')
            bus = dbus.SystemBus(mainloop=mainloop.dbus_loop)

            ## power related
            power_obj = bus.get_object('org.freesmartphone.odeviced', 
                                       '/org/freesmartphone/Device/PowerControl/WiFi')
            self.power_iface = dbus.Interface(power_obj, 
                                              'org.freesmartphone.Device.PowerControl')
            try_num = 0
            obj = None
            ## devicing
            for i in range(5):
                    try:
                        obj = bus.get_object("org.moblin.connman", "/")
                        logger.info("moblin success")
                    except:
                        logger.info("moblin failed")
                        yield WaitFirst(Sleep(1))
                        continue
                    else:
                        break
                        #raise Exception("moblin not starting")
            if obj:
                self.devicing_iface = dbus.Interface(
                                           obj, 
                                           "org.moblin.connman.Manager")
                self.status_setting = tichy.settings.ToggleSetting(
                                            'wifi', 'power', 
                                            Text, value=self.get_power(), 
                                            setter=self.power, 
                                            options=['active','inactive'])
                self.NetworkList = List()
                self.ListLabel = [('title','name'),('subtitle','info')]
                self.scan_setting = tichy.settings.ListSetting('wifi', 
                                                               'scan', 
                                                               Text, 
                                                               value="Networks", 
                                                               setter=self.run_scan, 
                                                               options=['Networks'], 
                                                               model=self.NetworkList, 
                                                               ListLabel=self.ListLabel)
                if self.get_power():
                    self.get_device()
                self.devicing_iface.connect_to_signal('PropertyChanged', 
                                                      self.property_changed)
                self.connect("closing", self.closing)
            else: 
                logger.error("Moblin failed. Is Connman/moblin installed?")
        except Exception, e:
            logger.exception("can't use wifi service : %s", e)
            raise
コード例 #7
0
    def run(self, setting, parent, layout):
        self.edje_file = join(dirname(__file__), 'settings.edj')

        layout.elm_obj.hide()
        self.window = ElementaryListSubwindow(parent, self.edje_file,
                                              "stringsetting", "entry",
                                              layout.elm_obj)
        self.edje_obj = self.window.main_layout

        if setting != None:
            self.edje_obj.edje.signal_emit(str(setting.name), "set_text")

        textbox = Entry(parent.window.elm_obj)

        if setting != None:
            textbox.entry_set(setting.value)

        textbox.size_hint_weight_set(1.0, 1.0)

        self.edje_obj.elm_obj.content_set("entry", textbox)

        textbox.editable_set(True)

        textbox.focus()

        textbox.show()

        i, args = yield WaitFirst(Wait(self.edje_obj, 'save'),
                                  Wait(self.edje_obj, 'back'),
                                  Wait(parent, 'back'))

        if i == 0:  ##save clicked
            text = str(textbox.entry_get()).replace("<br>", "")
            text = text.strip()
            if setting != None:
                self.edje_obj.edje.signal_emit("save-notice", "*")
                self.edje_obj.elm_obj.visible_set(False)
                self.edje_obj.delete()
                layout.elm_obj.show()
                setting.set(text).start()
                parent.window.elm_obj.keyboard_mode_set(
                    gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
            else:
                self.edje_obj.elm_obj.visible_set(False)
                #if setting != None:
                self.edje_obj.delete()
                layout.elm_obj.show()
                parent.window.elm_obj.keyboard_mode_set(
                    gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
                yield text
        else:
            self.edje_obj.elm_obj.visible_set(False)
            self.edje_obj.delete()
            layout.elm_obj.show()

        parent.window.elm_obj.keyboard_mode_set(
            gui.ecore.x.ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
コード例 #8
0
 def motion_task(self, pos):
     while True:
         e, args = yield WaitFirst(Wait(self, 'mouse-up'),
                                   Wait(self, 'mouse-motion'))
         if e == 0:
             break
         pos = args[0]
         # we need to compute the angle between the original click
         # pos and the new pos But in fact I am too lazy so I will
         # use an approximation TODO: make it faster by using a
         # step value
         self.angle = (self.click_angle + \
                           (pos - self.click_pos).x / float(self.radius))
コード例 #9
0
    def run(self, parent=None, standalone=False):
        ##the edje file
        self.edje_file = join(dirname(__file__), 'settings.edj')

        ##import a parameter which tells the app about paroli's window's size
        self.standalone = config.getboolean('standalone', 'activated', False)

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

        self.groups = List()

        for i in Setting.groups:
            t = Text(i)
            self.groups.append(Text(i))

        def comp(m1, m2):
            return cmp(str(m2).lower(), str(m1).lower())

        self.list_label = [('title', 'value')]
        self.item_list = ElementaryList(self.groups, self.window,
                                        self.edje_file, "item",
                                        self.list_label, comp)

        self.item_list.add_callback("*", "sublist", self._show_sublist)

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

        parent.emit("unblock")

        i, args = yield WaitFirst(Wait(self.window, 'delete_request'),
                                  Wait(self.window, 'back'),
                                  Wait(self.window.window, 'closing'))
        ##we write a logger message that the application is closing
        logger.info('Settings closing')

        ##we delete the window object (the class would also delete all children object)
        if i != 2:
            self.item_list._remove_cb()
            self.window.delete()
コード例 #10
0
    def run(self, parent, edje_file, group, layout, *args, **kargs):

        layout.elm_obj.hide()

        self.parent = parent

        self.window = ElementaryListSubwindow(parent, edje_file, "main",
                                              "list")
        self.edje_obj = self.window.main_layout

        self.edje_obj.edje.signal_emit("sublist_mode", "*")

        self.settings = List()
        self.cb_list = List()

        for i in Setting.groups[group]:
            o = Setting.groups[group][i]
            self.settings.append(o)

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

        self.list_label = [('title', 'name'), ('subtitle', 'value')]
        self.item_list = ElementaryList(self.settings, self.window, edje_file,
                                        "item", self.list_label, comp)

        for i in self.settings:
            if hasattr(i, 'options'):
                oid = i.options.connect('updated', self.item_list._redraw_view)
                self.cb_list.append([i.options, oid])

        self.item_list.add_callback("*", "sublist", self.action)

        yield WaitFirst(Wait(self.window, 'delete_request'),
                        Wait(self.edje_obj, 'back'))

        for i in self.cb_list:
            i[0].disconnect(i[1])

        self.edje_obj.elm_obj.visible_set(False)
        self.edje_obj.delete()
        parent.restore_orig()
        layout.elm_obj.show()
コード例 #11
0
ファイル: __init__.py プロジェクト: vmx/paroli
    def run(self,
            window,
            text="",
            name=None,
            input_method=None,
            variable=None):

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

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

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

        self.edje_obj = self.main.main_layout.edje

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

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

        i, args = yield WaitFirst(Wait(self.main, 'value_received'),
                                  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:
            mainloop.quit()
コード例 #12
0
ファイル: __init__.py プロジェクト: vmx/paroli
    def run(self, parent=None, standalone=False):

        ##set edje_file
        self.edje_file = join(dirname(__file__), 'calculator.edj')

        ## edje_file, group, x=1.0, y=1.0, topbar=False, onclick=None
        self.window = ElementaryLayoutWindow(self.edje_file, "main", None,
                                             None, False)
        self.edje_obj = self.window.main_layout

        ## close the Calculator 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 WaitFirst(Wait(self.window, 'delete_request'),
                                  Wait(self.window, 'back'),
                                  Wait(self.window.window, 'closing'),
                                  Wait(self.edje_obj, 'back'))
        logger.info('Calculator closing')

        if i != 2:
            self.window.delete()
コード例 #13
0
ファイル: __init__.py プロジェクト: vmx/paroli
    def run(self, parent=None, standalone=False):
        #logger.info('launcher launching')
        self.ready = 0
        self.standalone = config.getboolean('standalone', 'activated', False)
        self.advanced = config.getboolean('advanced-mode', 'activated', False)

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

        self.edje_file = join(dirname(__file__), 'launcher.edj')

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

        self.edje_obj = self.window.main_layout
        if hasattr(self.window.topbar, "tb"):
            self.window.topbar.tb.elm_obj.edje_get().signal_emit(
                "hide_clock", "*")

        self.window.window.elm_obj.resize(480, 640 - 64)
        self.active_app = None

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

        box = ElementaryBox(self.window.window.elm_obj)
        self.app_objs = {}
        apps.sort(key=lambda x: x.name)  # sort apps alphabetically.
        for app in apps:
            logger.info("register launcher %s", app.name)
            link_obj = ElementaryLayout(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)
            self.app_objs[app.name] = [
                link_obj,
                attr,
            ]

        box.elm_obj.show()
        self.edje_obj.elm_obj.content_set("link-box", box.elm_obj)
        self.storage = 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 = Service.get('Messages')
        if not self.msg.ready:
            self.msg.connect('ready', self.unblock_screen)
        else:
            self.unblock_screen()

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

        self.button = 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 = Service.get('Prefs')
        self.audio_service = Service.get('Audio')

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

        self.ready = 1

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

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

        self.dialog = 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")
        logger.debug("keep_alive %s", keep_alive)

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

        if not self.window.window.elm_obj.is_deleted():
            self.window.delete()  # Don't forget to close the window
コード例 #14
0
    def run(self,
            setting,
            parent,
            model,
            list_label,
            layout,
            group="item",
            save_button=False,
            *args,
            **kargs):
        layout.elm_obj.hide()

        self.parent = parent
        self.setting = setting

        self.edje_file = join(dirname(__file__), 'settings.edj')

        self.window = ElementaryListSubwindow(parent, self.edje_file, "main",
                                              "list")

        self.edje_obj = self.window.main_layout

        self.edje_obj.edje.signal_emit("sublist_mode", "*")

        if save_button:
            self.edje_obj.edje.signal_emit("save_button", "*")

        self.ItemList = model
        self.cb_list = List()

        #for i in Setting.groups[group]:
        #o = Setting.groups[group][i]
        #self.settings.append(o)

        def comp(m1, m2):
            if m1.name == None or m1.name == "":
                return cmp(m2, m1)
            else:
                return cmp(m2.name, m1.name)

        item_group = group or "item"

        self.list_label = list_label
        self.item_list = ElementaryList(self.ItemList, self.window,
                                        self.edje_file, item_group, list_label,
                                        comp)

        for i in self.ItemList:
            if hasattr(i, 'connect'):
                oid = i.connect('updated', self.item_list._redraw_view)
                self.cb_list.append([i, oid])

        self.item_list.add_callback("*", "sublist", self.action)
        self.item_list.add_callback("pressed", "decrease", self.decrease)
        self.item_list.add_callback("pressed", "increase", self.increase)
        self.edje_obj.edje.signal_callback_add("pressed", "save", self.save)

        yield WaitFirst(Wait(self.window, 'delete_request'),
                        Wait(self.edje_obj, 'back'),
                        Wait(self.ItemList, 'save'))

        for i in self.cb_list:
            i[0].disconnect(i[1])

        self.edje_obj.elm_obj.visible_set(False)
        self.edje_obj.delete()
        self.item_list._remove_cb()
        layout.elm_obj.show()
コード例 #15
0
    def run(self, parent, sms, mode, layout=None, *args, **kargs):
        self.dialog = Service.get("Dialog")
        try:
            self.edje_file = join(dirname(__file__), 'messages.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(
                        ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)

                    if number_layout == 0:

                        number_layout = ElementaryLayout(
                            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 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 = ElementaryLayout(parent.window,
                                                   self.edje_file,
                                                   "CreateText")

                    parent.window.elm_obj.keyboard_mode_set(
                        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 = 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 = 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, sms.peer)

                i, args = yield 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(
                            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:
                        logger.debug("breaking")
                        break
                if i == 1:  #send
                    send = 1
                    logger.info("win set False")
                    parent.window.elm_obj.keyboard_mode_set(
                        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(
                    ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)

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

            ret = "done"

            yield ret

        except Exception, e:
            logger.exception('run')
コード例 #16
0
ファイル: __init__.py プロジェクト: vmx/paroli
                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 WaitFirst(Wait(call, 'activated'),
                                      Wait(call, 'released'),
                                      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:
コード例 #17
0
    def run(self, parent=None, standalone=False):
        ##to be standardized
        self.edje_file = join(dirname(__file__), 'inout.edj')

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

        ##get message service and list of all messages
        self.contact_service = 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 = ElementaryListWindow(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 = ElementaryList(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_window = self.window.window

        parent.emit("unblock")

        i, args = yield WaitFirst(Wait(self.window, 'back'),
                                  Wait(self.window, 'delete_request'),
                                  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