def accept(self):
     """Proceed in joining the chan"""
     self.timer.stop()
     self.hide()
     apiAddressGeneratorReturnQueue.queue.clear()
     if self.chanAddress.text().toUtf8() == "":
         addressGeneratorQueue.put(
             ('createChan', 4, 1,
              str_chan + ' ' + str(self.chanPassPhrase.text().toUtf8()),
              self.chanPassPhrase.text().toUtf8(), True))
     else:
         addressGeneratorQueue.put(
             ('joinChan',
              addBMIfNotPresent(self.chanAddress.text().toUtf8()),
              str_chan + ' ' + str(self.chanPassPhrase.text().toUtf8()),
              self.chanPassPhrase.text().toUtf8(), True))
     addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
     if addressGeneratorReturnValue and addressGeneratorReturnValue[
             0] != 'chan name does not match address':
         UISignalQueue.put(
             ('updateStatusBar',
              _translate("newchandialog",
                         "Successfully created / joined chan %1").arg(
                             unicode(self.chanPassPhrase.text()))))
         self.parent.ui.tabWidget.setCurrentIndex(
             self.parent.ui.tabWidget.indexOf(self.parent.ui.chans))
         self.done(QtGui.QDialog.Accepted)
     else:
         UISignalQueue.put(('updateStatusBar',
                            _translate("newchandialog",
                                       "Chan creation / joining failed")))
         self.done(QtGui.QDialog.Rejected)
    def validate(self, s, pos):
        if self.addressObject is None:
            address = None
        else:
            address = str(self.addressObject.text().toUtf8())
            if address == "":
                address = None
        if self.passPhraseObject is None:
            passPhrase = ""
        else:
            passPhrase = str(self.passPhraseObject.text().toUtf8())
            if passPhrase == "":
                passPhrase = None

        # no chan name
        if passPhrase is None:
            self.setError(_translate("AddressValidator", "Chan name/passphrase needed. You didn't enter a chan name."))
            return (QtGui.QValidator.Intermediate, pos)

        if self.addressMandatory or address is not None:
            # check if address already exists:
            if address in getSortedAccounts():
                self.setError(_translate("AddressValidator", "Address already present as one of your identities."))
                return (QtGui.QValidator.Intermediate, pos)

            # version too high
            if decodeAddress(address)[0] == 'versiontoohigh':
                self.setError(_translate("AddressValidator", "Address too new. Although that Bitmessage address might be valid, its version number is too new for us to handle. Perhaps you need to upgrade Bitmessage."))
                return (QtGui.QValidator.Intermediate, pos)
    
            # invalid
            if decodeAddress(address)[0] != 'success':
                self.setError(_translate("AddressValidator", "The Bitmessage address is not valid."))
                return (QtGui.QValidator.Intermediate, pos)

        # this just disables the OK button without changing the feedback text
        # but only if triggered by textEdited, not by clicking the Ok button
        if not self.buttonBox.button(QtGui.QDialogButtonBox.Ok).hasFocus():
            self.setError(None)

        # check through generator
        if address is None:
            addressGeneratorQueue.put(('createChan', 4, 1, str_chan + ' ' + str(passPhrase), passPhrase, False))
        else:
            addressGeneratorQueue.put(('joinChan', addBMIfNotPresent(address), str_chan + ' ' + str(passPhrase), passPhrase, False))

        if self.buttonBox.button(QtGui.QDialogButtonBox.Ok).hasFocus():
            return (self.returnValid(), pos)
        else:
            return (QtGui.QValidator.Intermediate, pos)
    def validate(self, s, pos):
        if self.addressObject is None:
            address = None
        else:
            address = str(self.addressObject.text().toUtf8())
            if address == "":
                address = None
        if self.passPhraseObject is None:
            passPhrase = ""
        else:
            passPhrase = str(self.passPhraseObject.text().toUtf8())
            if passPhrase == "":
                passPhrase = None

        # no chan name
        if passPhrase is None:
            self.setError(_translate("AddressValidator", "Chan name/passphrase needed. You didn't enter a chan name."))
            return (QtGui.QValidator.Intermediate, pos)

        if self.addressMandatory or address is not None:
            # check if address already exists:
            if address in getSortedAccounts():
                self.setError(_translate("AddressValidator", "Address already present as one of your identities."))
                return (QtGui.QValidator.Intermediate, pos)

            # version too high
            if decodeAddress(address)[0] == 'versiontoohigh':
                self.setError(_translate("AddressValidator", "Address too new. Although that Bitmessage address might be valid, its version number is too new for us to handle. Perhaps you need to upgrade Bitmessage."))
                return (QtGui.QValidator.Intermediate, pos)
    
            # invalid
            if decodeAddress(address)[0] != 'success':
                self.setError(_translate("AddressValidator", "The Bitmessage address is not valid."))
                return (QtGui.QValidator.Intermediate, pos)

        # this just disables the OK button without changing the feedback text
        # but only if triggered by textEdited, not by clicking the Ok button
        if not self.buttonBox.button(QtGui.QDialogButtonBox.Ok).hasFocus():
            self.setError(None)

        # check through generator
        if address is None:
            addressGeneratorQueue.put(('createChan', 4, 1, str_chan + ' ' + str(passPhrase), passPhrase, False))
        else:
            addressGeneratorQueue.put(('joinChan', addBMIfNotPresent(address), str_chan + ' ' + str(passPhrase), passPhrase, False))

        if self.buttonBox.button(QtGui.QDialogButtonBox.Ok).hasFocus():
            return (self.returnValid(), pos)
        else:
            return (QtGui.QValidator.Intermediate, pos)
 def accept(self):
     self.timer.stop()
     self.hide()
     apiAddressGeneratorReturnQueue.queue.clear()
     if self.chanAddress.text().toUtf8() == "":
         addressGeneratorQueue.put(('createChan', 4, 1, str_chan + ' ' + str(self.chanPassPhrase.text().toUtf8()), self.chanPassPhrase.text().toUtf8(), True))
     else:
         addressGeneratorQueue.put(('joinChan', addBMIfNotPresent(self.chanAddress.text().toUtf8()), str_chan + ' ' + str(self.chanPassPhrase.text().toUtf8()), self.chanPassPhrase.text().toUtf8(), True))
     addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
     if len(addressGeneratorReturnValue) > 0 and addressGeneratorReturnValue[0] != 'chan name does not match address':
         UISignalQueue.put(('updateStatusBar', _translate("newchandialog", "Successfully created / joined chan %1").arg(unicode(self.chanPassPhrase.text()))))
         self.parent.ui.tabWidget.setCurrentIndex(3)
         self.done(QtGui.QDialog.Accepted)
     else:
         UISignalQueue.put(('updateStatusBar', _translate("newchandialog", "Chan creation / joining failed")))
         self.done(QtGui.QDialog.Rejected)