Beispiel #1
0
    def _get_statusbar_text(self, text):
        if not len(text):
            return ""

        # get the number of messages
        # we use a default number for encoding purposes
        num_sms = len(SmsSubmit("+342453435", text).to_pdu())
        if num_sms == 1:
            max_length = SEVENBIT if is_gsm_text(text) else UCS2
            return "%d/%d" % (len(text), max_length)
        else:
            max_length = SEVENBIT_MP if is_gsm_text(text) else UCS2_MP
            used = len(text) - (max_length * (num_sms - 1))
            return "%d/%d   (%d SMS)" % (used, max_length, num_sms)
Beispiel #2
0
        def convert_response(response):
            index = response[0].group('index')
            if index == '1':
                self.device.set_property(
                                consts.USD_INTFACE, 'State', 'user-response')
            else:
                self.device.set_property(consts.USD_INTFACE, 'State', 'idle')

            resp = response[0].group('resp')
            code = response[0].group('code')

            if code is not None:
                code = int(code)

                if ((code & 0x10) == 0x10):
                    log.err("We don't yet handle ISO 639 encoded USSD"
                            " - please report")
                    raise E.MalformedUssdPduError(resp)

                if ((code & 0xf4) == 0xf4):
                    log.err("We don't yet handle 8 bit encoded USSD"
                            " - please report")
                    raise E.MalformedUssdPduError(resp)

            ret = unpack_msg(resp)
            if is_gsm_text(ret):
                return ret

            try:
                return resp.decode('hex')
            except TypeError:
                raise E.MalformedUssdPduError(resp)
Beispiel #3
0
        def send_request(ussd):
            if not is_gsm_text(ussd):
                raise ValueError

            gsm = ussd.encode("gsm0338")
            ussd_enc = encode_str(compress_7_to_8_bit(gsm))

            cmd = ATCmd('AT+CUSD=1,"%s",15' % ussd_enc, name='send_ussd')
            return self.queue_at_cmd(cmd)
    def _textbuffer_changed(self, textbuffer):
        """Handler for the textbuffer changed signal"""
        text = textbuffer.get_text(textbuffer.get_start_iter(),
                                   textbuffer.get_end_iter())
        if not len(text):
            msg = _('Text message: 0/%d chars') % SEVENBIT_SIZE
        else:
            # get the number of messages
            # we use a default number for encoding purposes
            num_sms = len(SmsSubmit('+342453435', text).to_pdu())
            if num_sms == 1:
                max_length = SEVENBIT_SIZE if is_gsm_text(text) else UCS2_SIZE
                args = dict(num=len(text), total=max_length)
                msg = _('Text message: %(num)d/%(total)d chars') % args
            else:
                max_length = SEVENBIT_MP_SIZE if is_gsm_text(text) else UCS2_MP_SIZE
                used = len(text) - (max_length * (num_sms - 1))
                args = dict(num=used, total=max_length, msgs=num_sms)
                msg = _('Text message: '
                        '%(num)d/%(total)d chars (%(msgs)d SMS)') % args

        self.view.get_top_widget().set_title(msg)
Beispiel #5
0
    def _textbuffer_changed(self, textbuffer):
        """Handler for the textbuffer changed signal"""
        text = textbuffer.get_text(textbuffer.get_start_iter(),
                                   textbuffer.get_end_iter())
        if not len(text):
            msg = _('Text message: 0/%d chars') % SEVENBIT_SIZE
        else:
            # get the number of messages
            # we use a default number for encoding purposes
            num_sms = len(SmsSubmit('+342453435', text).to_pdu())
            if num_sms == 1:
                max_length = SEVENBIT_SIZE if is_gsm_text(text) else UCS2_SIZE
                args = dict(num=len(text), total=max_length)
                msg = _('Text message: %(num)d/%(total)d chars') % args
            else:
                max_length = SEVENBIT_MP_SIZE if is_gsm_text(
                    text) else UCS2_MP_SIZE
                used = len(text) - (max_length * (num_sms - 1))
                args = dict(num=used, total=max_length, msgs=num_sms)
                msg = _('Text message: '
                        '%(num)d/%(total)d chars (%(msgs)d SMS)') % args

        self.view.get_top_widget().set_title(msg)
Beispiel #6
0
        def convert_response(response):
            index = response[0].group('index')
            if index == '1':
                self.device.set_property(
                    consts.USD_INTFACE, 'State', 'user-response')
            else:
                self.device.set_property(consts.USD_INTFACE, 'State', 'idle')

            resp = response[0].group('resp')
            if resp is None:
                return ""   # returning the Empty string is valid

            try:
                ret = unpack_msg(resp).decode("gsm0338")
                if is_gsm_text(ret):
                    return ret
            except UnicodeError:
                pass

            try:
                return resp.decode('hex')
            except TypeError:
                raise MalformedUssdPduError(resp)