def submit_voucher(self, voucher):
        payt_available = self.model.get_sim_conf('payt_available', None)
        if payt_available == False: # Not a PAYT SIM
            show_warning_dialog(_("PAYT submit voucher"),
                                _("SIM is not on a PAYT plan"))
            return

        def submit_cb(error):
            if not error:
                logger.info("PAYT SIM submit voucher success")
                # ok we established his voucher code is good, let's cause the
                # system to update the UI with his new credit. To do that we
                # need to fire off another request
                self.get_current_sim_credit()
                self.model.payt_submit_busy = False
                self.view.clear_voucher_entry_view()
            else:
                logger.error("PAYT SIM submit voucher failed")
                self.model.payt_submit_busy = False
                show_warning_dialog(_("PAYT submit voucher"),
                    _("PAYT submit voucher failed\n\'%s\'") % error)

        ussd = get_payt_submit_voucher_info(self.model.imsi)
        if ussd:
            self.model.payt_submit_busy = True
            self._submit_voucher_by_ussd(ussd, voucher, submit_cb)
        # elif have payt SMS submit voucher info:
        #    self._submit_voucher_by_sms()
        else:
            show_warning_dialog(_("PAYT submit voucher"),
                                _("No PAYT submit voucher method available"))
示例#2
0
    def submit_voucher(self, voucher):
        payt_available = self.model.get_sim_conf('payt_available', None)
        if payt_available == False:  # Not a PAYT SIM
            show_warning_dialog(_("PAYT submit voucher"),
                                _("SIM is not on a PAYT plan"))
            return

        def submit_cb(error):
            if not error:
                logger.info("PAYT SIM submit voucher success")
                # ok we established his voucher code is good, let's cause the
                # system to update the UI with his new credit. To do that we
                # need to fire off another request
                self.get_current_sim_credit()
                self.model.payt_submit_busy = False
                self.view.clear_voucher_entry_view()
            else:
                logger.error("PAYT SIM submit voucher failed")
                self.model.payt_submit_busy = False
                show_warning_dialog(
                    _("PAYT submit voucher"),
                    _("PAYT submit voucher failed\n\'%s\'") % error)

        ussd = get_payt_submit_voucher_info(self.model.imsi)
        if ussd:
            self.model.payt_submit_busy = True
            self._submit_voucher_by_ussd(ussd, voucher, submit_cb)
        # elif have payt SMS submit voucher info:
        #    self._submit_voucher_by_sms()
        else:
            show_warning_dialog(_("PAYT submit voucher"),
                                _("No PAYT submit voucher method available"))
    def on_search_find_button_clicked(self, widget):
        pattern = self.view['search_entry'].get_text()

        treeview = self.parent_ctrl.view['contacts_treeview']
        model = treeview.get_model()

        contacts = model.find_contacts(pattern)
        if not contacts:
            dialogs.show_warning_dialog(
                _('No contact found'),
                _('No contact with the name %s found') % pattern)
            return

        # get the path
        path = [
            str(i) for i, row in enumerate(model)
            if row[TV_CNT_OBJ] in contacts
        ]
        # unselect
        sel = treeview.get_selection()
        sel.unselect_all()
        for elem in path:
            # and set the new selection
            sel.select_path(elem)

        self.view.hide()
        def enable_pin_eb(e):
            title = _("Incorrect PIN")
            details = _("""
<small>The PIN you've just entered is
incorrect. Bear in mind that after
three failed PINs you'll be asked
for the PUK code</small>
""")
            show_warning_dialog(title, details)
            self.errback(self.enable)
            self.model.unregister_observer(self)
            self.view.hide()
示例#5
0
        def enable_pin_eb(e):
            title = _("Incorrect PIN")
            details = _("""
<small>The PIN you've just entered is
incorrect. Bear in mind that after
three failed PINs you'll be asked
for the PUK code</small>
""")
            show_warning_dialog(title, details)
            self.errback(self.enable)
            self.model.unregister_observer(self)
            self.view.hide()
 def submit_cb(error):
     if not error:
         logger.info("PAYT SIM submit voucher success")
         # ok we established his voucher code is good, let's cause the
         # system to update the UI with his new credit. To do that we
         # need to fire off another request
         self.get_current_sim_credit()
         self.model.payt_submit_busy = False
         self.view.clear_voucher_entry_view()
     else:
         logger.error("PAYT SIM submit voucher failed")
         self.model.payt_submit_busy = False
         show_warning_dialog(_("PAYT submit voucher"),
             _("PAYT submit voucher failed\n\'%s\'") % error)
示例#7
0
 def submit_cb(error):
     if not error:
         logger.info("PAYT SIM submit voucher success")
         # ok we established his voucher code is good, let's cause the
         # system to update the UI with his new credit. To do that we
         # need to fire off another request
         self.get_current_sim_credit()
         self.model.payt_submit_busy = False
         self.view.clear_voucher_entry_view()
     else:
         logger.error("PAYT SIM submit voucher failed")
         self.model.payt_submit_busy = False
         show_warning_dialog(
             _("PAYT submit voucher"),
             _("PAYT submit voucher failed\n\'%s\'") % error)
示例#8
0
    def get_current_sim_credit(self):
        # my job is to obtain the current credit value. I take care of setting
        # both value and time as a credit amount is only valid at the time you
        # check. I store the values in Gconf and set a flag indicating whether
        # this SIM is prepay capable
        payt_available = self.model.get_sim_conf('payt_available', None)
        if payt_available == False:  # Not a PAYT SIM
            show_warning_dialog(_("PAYT credit check"),
                                _("SIM is not on a PAYT plan"))
            return

        def credit_cb(credit):
            if credit:
                utc = time()
                now = datetime.fromtimestamp(utc, self.tz)
                logger.info("PAYT SIM credit: %s on %s" %
                            (credit, now.strftime("%c")))

                self.model.payt_credit_balance = credit
                self.model.set_sim_conf('payt_credit_balance', credit)

                self.model.payt_credit_date = now
                self.model.set_sim_conf('payt_credit_date', utc)
            else:
                self.model.payt_credit_balance = _("Not available")
                self.model.payt_credit_date = None

            # Record SIM as PAYT or not
            if not isinstance(payt_available, bool):
                self.model.payt_available = (credit is not None)
                self.model.set_sim_conf('payt_available',
                                        self.model.payt_available)

            self.model.payt_credit_busy = False

        ussd = get_payt_credit_check_info(self.model.imsi)
        if ussd:
            self.model.payt_credit_busy = True
            self._get_current_sim_credit_by_ussd(ussd, credit_cb)
        # elif have payt SMS credit check info:
        #    self._get_current_sim_credit_by_sms()
        else:
            show_warning_dialog(_("PAYT credit check"),
                                _("No PAYT credit check method available"))
    def get_current_sim_credit(self):
        # my job is to obtain the current credit value. I take care of setting
        # both value and time as a credit amount is only valid at the time you
        # check. I store the values in Gconf and set a flag indicating whether
        # this SIM is prepay capable
        payt_available = self.model.get_sim_conf('payt_available', None)
        if payt_available == False: # Not a PAYT SIM
            show_warning_dialog(_("PAYT credit check"),
                                _("SIM is not on a PAYT plan"))
            return

        def credit_cb(credit):
            if credit:
                utc = time()
                now = datetime.fromtimestamp(utc, self.tz)
                logger.info("PAYT SIM credit: %s on %s" %
                                (credit, now.strftime("%c")))

                self.model.payt_credit_balance = credit
                self.model.set_sim_conf('payt_credit_balance', credit)

                self.model.payt_credit_date = now
                self.model.set_sim_conf('payt_credit_date', utc)
            else:
                self.model.payt_credit_balance = _("Not available")
                self.model.payt_credit_date = None

            # Record SIM as PAYT or not
            if not isinstance(payt_available, bool):
                self.model.payt_available = (credit is not None)
                self.model.set_sim_conf('payt_available',
                                        self.model.payt_available)

            self.model.payt_credit_busy = False

        ussd = get_payt_credit_check_info(self.model.imsi)
        if ussd:
            self.model.payt_credit_busy = True
            self._get_current_sim_credit_by_ussd(ussd, credit_cb)
        # elif have payt SMS credit check info:
        #    self._get_current_sim_credit_by_sms()
        else:
            show_warning_dialog(_("PAYT credit check"),
                                _("No PAYT credit check method available"))
        def show_icon_cb(checkbutton):
            if checkbutton.get_active():
                if not tray_available():
                    # block the handler so the set_active method doesnt
                    # executes this callback again
                    checkbutton.handler_block(self._hid2)
                    checkbutton.set_active(False)
                    # restore handler
                    checkbutton.handler_unblock(self._hid2)
                    message = _("Missing dependency")
                    details = _("""
To use this feature you need either pygtk >= 2.10 or the egg.trayicon module
""")
                    show_warning_dialog(message, details)
                    return True
                else:
                    self.view.setup_user_close_window_minimize_enable(True)
            else:
                self.view.setup_user_close_window_minimize_enable(False)
        def show_icon_cb(checkbutton):
            if checkbutton.get_active():
                if not tray_available():
                    # block the handler so the set_active method doesnt
                    # executes this callback again
                    checkbutton.handler_block(self._hid2)
                    checkbutton.set_active(False)
                    # restore handler
                    checkbutton.handler_unblock(self._hid2)
                    message = _("Missing dependency")
                    details = _("""
To use this feature you need either pygtk >= 2.10 or the egg.trayicon module
""")
                    show_warning_dialog(message, details)
                    return True
                else:
                    self.view.setup_user_close_window_minimize_enable(True)
            else:
                self.view.setup_user_close_window_minimize_enable(False)
    def on_search_find_button_clicked(self, widget):
        pattern = self.view["search_entry"].get_text()

        treeview = self.parent_ctrl.view["contacts_treeview"]
        model = treeview.get_model()

        contacts = model.find_contacts(pattern)
        if not contacts:
            dialogs.show_warning_dialog(_("No contact found"), _("No contact with the name %s found") % pattern)
            return

        # get the path
        path = [str(i) for i, row in enumerate(model) if row[3] in contacts]
        # unselect
        sel = treeview.get_selection()
        sel.unselect_all()
        for elem in path:
            # and set the new selection
            sel.select_path(elem)
        def keyringtoggled_cb(checkbutton):
            """
            Callback for the gnomekeyring_checkbutton::toggled signal

            we are gonna try to import gnomekeyring beforehand, if we
            get an ImportError we will inform the user about what she
            should do
            """
            if checkbutton.get_active():
                try:
                    import gnomekeyring
                except ImportError:
                    # block the handler so the set_active method doesnt execute
                    # this callback again
                    checkbutton.handler_block(self._hid1)
                    checkbutton.set_active(False)
                    # restore handler
                    checkbutton.handler_unblock(self._hid1)
                    message = _("Missing dependency")
                    details = _(
"""To use this feature you need the gnomekeyring module""")
                    show_warning_dialog(message, details)
                    return True
        def keyringtoggled_cb(checkbutton):
            """
            Callback for the gnomekeyring_checkbutton::toggled signal

            we are gonna try to import gnomekeyring beforehand, if we
            get an ImportError we will inform the user about what she
            should do
            """
            if checkbutton.get_active():
                try:
                    import gnomekeyring
                except ImportError:
                    # block the handler so the set_active method doesnt execute
                    # this callback again
                    checkbutton.handler_block(self._hid1)
                    checkbutton.set_active(False)
                    # restore handler
                    checkbutton.handler_unblock(self._hid1)
                    message = _("Missing dependency")
                    details = _(
                        """To use this feature you need the gnomekeyring module"""
                    )
                    show_warning_dialog(message, details)
                    return True