Esempio n. 1
0
    def on_save_toolbutton_clicked(self, widget):
        numbers = self.view.get_numbers()
        text = self.view.get_text()

        if not numbers:
            title = _("Invalid number")
            msg = _("You must provide a valid number")
            dialogs.show_error_dialog(title, msg)
            self.view["contacts_entry"].grab_focus()
            return

        if text == "":
            title = _("No text to save")
            msg = _("Are you sure you want to store a blank message?")
            if not dialogs.show_warning_request_cancel_ok(title, msg):
                # user cancelled it
                self.view["text_textview"].grab_focus()
                return

        self.messages = [Message(num, text) for num in numbers]
        for sms in self.messages:
            self.model.device.Save(
                sms.to_dict(),
                dbus_interface=SMS_INTFACE,
                reply_handler=self.on_sms_saved_cb,
                error_handler=self.on_sms_saved_eb,
            )
Esempio n. 2
0
    def on_send_toolbutton_clicked(self, widget):
        numbers = self.view.get_numbers()
        text = self.view.get_text()

        if not numbers:
            title = _("Invalid number")
            msg = _("You must provide a valid number")
            dialogs.show_error_dialog(title, msg)
            self.view["contacts_entry"].grab_focus()
            return

        if text == "":
            title = _("No text to send")
            msg = _("Are you sure you want to send a blank message?")
            if not dialogs.show_warning_request_cancel_ok(title, msg):
                # user cancelled it
                self.view["text_textview"].grab_focus()
                return

        if self.mode == STORAGE and not self.has_changed:
            # sending from storage
            sms = self.selected["objs"][0]
            self.model.device.SendFromStorage(
                sms.index,
                dbus_interface=SMS_INTFACE,
                reply_handler=self.on_sms_sent_cb,
                error_handler=self.on_sms_sent_eb,
            )
        else:
            self.state = SENDING
            for number in numbers:
                self.model.device.Send(
                    dict(number=number, text=text),
                    dbus_interface=SMS_INTFACE,
                    reply_handler=self.on_sms_sent_cb,
                    error_handler=self.on_sms_sent_eb,
                )
            self.state = IDLE