示例#1
0
    def _start_new_chat(self, row):
        if row.new:
            try:
                validate_jid(row.jid)
            except ValueError as error:
                self._show_error_page(error)
                return

        if row.groupchat:
            if not app.account_is_connected(row.account):
                self._show_error_page(
                    _('You can not join a group chat '
                      'unless you are connected.'))
                return

            self.ready_to_destroy = True
            if app.interface.show_groupchat(row.account, row.jid):
                return

            self.ready_to_destroy = False
            self._redirected = False
            self._disco_muc(row.account, row.jid)

        else:
            app.interface.new_chat_from_jid(row.account, row.jid)
            self.ready_to_destroy = True
示例#2
0
    def _validate_jid(self, text):
        if not text:
            self._set_warning_icon(False)
            self._ui.create_button.set_sensitive(False)
            return

        try:
            jid = validate_jid(text)
            if jid.resource:
                raise ValueError

        except ValueError:
            self._set_warning(_('Invalid Address'))
        else:
            self._set_warning_icon(False)
            self._ui.create_button.set_sensitive(True)
示例#3
0
    def _validate_jid(self, address):
        if not address:
            self._show_icon(False)
            return False

        try:
            jid = validate_jid(address, type_='bare')
            if jid.resource:
                raise ValueError
        except ValueError:
            self._show_icon(True)
            self._ui.log_in_address_entry.set_icon_tooltip_text(
                Gtk.EntryIconPosition.SECONDARY, _('Invalid Address'))
            return False

        self._show_icon(False)
        return True
示例#4
0
    def _on_address_edited(self, _renderer, path, new_value):
        iter_ = self._ui.bookmarks_store.get_iter(path)
        if not new_value:
            return

        try:
            jid = validate_jid(new_value)
        except ValueError as error:
            log.warning('Invalid JID: %s (%s)', error, new_value)
            return

        if not jid.is_bare:
            log.warning('Invalid JID: only bare JIDs allowed (%s)', jid)
            return

        self._ui.bookmarks_store.set_value(iter_, Column.ADDRESS, new_value
                                           or None)