Update addressbook on changes

Fixes  #99
- enable/disable new/delete chan/subscription
- also found and fixed a logger crash
This commit is contained in:
mailchuck 2015-11-19 19:17:26 +01:00
parent b5fb485eb2
commit 5b07d8800a
Signed by untrusted user who does not match committer: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -1569,7 +1569,7 @@ class MyForm(settingsmixin.SMainWindow):
shared.apiAddressGeneratorReturnQueue.queue.clear() shared.apiAddressGeneratorReturnQueue.queue.clear()
shared.addressGeneratorQueue.put(('createChan', 4, 1, self.str_chan + ' ' + str(self.newChanDialogInstance.ui.lineEditChanNameCreate.text().toUtf8()), self.newChanDialogInstance.ui.lineEditChanNameCreate.text().toUtf8())) shared.addressGeneratorQueue.put(('createChan', 4, 1, self.str_chan + ' ' + str(self.newChanDialogInstance.ui.lineEditChanNameCreate.text().toUtf8()), self.newChanDialogInstance.ui.lineEditChanNameCreate.text().toUtf8()))
addressGeneratorReturnValue = shared.apiAddressGeneratorReturnQueue.get() addressGeneratorReturnValue = shared.apiAddressGeneratorReturnQueue.get()
logger.debug('addressGeneratorReturnValue ' + addressGeneratorReturnValue) logger.debug('addressGeneratorReturnValue ' + str(addressGeneratorReturnValue))
if len(addressGeneratorReturnValue) == 0: if len(addressGeneratorReturnValue) == 0:
QMessageBox.about(self, _translate("MainWindow", "Address already present"), _translate( QMessageBox.about(self, _translate("MainWindow", "Address already present"), _translate(
"MainWindow", "Could not add chan because it appears to already be one of your identities.")) "MainWindow", "Could not add chan because it appears to already be one of your identities."))
@ -1594,7 +1594,7 @@ class MyForm(settingsmixin.SMainWindow):
shared.apiAddressGeneratorReturnQueue.queue.clear() shared.apiAddressGeneratorReturnQueue.queue.clear()
shared.addressGeneratorQueue.put(('joinChan', addBMIfNotPresent(self.newChanDialogInstance.ui.lineEditChanBitmessageAddress.text()), self.str_chan + ' ' + str(self.newChanDialogInstance.ui.lineEditChanNameJoin.text().toUtf8()), self.newChanDialogInstance.ui.lineEditChanNameJoin.text().toUtf8())) shared.addressGeneratorQueue.put(('joinChan', addBMIfNotPresent(self.newChanDialogInstance.ui.lineEditChanBitmessageAddress.text()), self.str_chan + ' ' + str(self.newChanDialogInstance.ui.lineEditChanNameJoin.text().toUtf8()), self.newChanDialogInstance.ui.lineEditChanNameJoin.text().toUtf8()))
addressGeneratorReturnValue = shared.apiAddressGeneratorReturnQueue.get() addressGeneratorReturnValue = shared.apiAddressGeneratorReturnQueue.get()
logger.debug('addressGeneratorReturnValue ' + addressGeneratorReturnValue) logger.debug('addressGeneratorReturnValue ' + str(addressGeneratorReturnValue))
if addressGeneratorReturnValue == 'chan name does not match address': if addressGeneratorReturnValue == 'chan name does not match address':
QMessageBox.about(self, _translate("MainWindow", "Address does not match chan name"), _translate( QMessageBox.about(self, _translate("MainWindow", "Address does not match chan name"), _translate(
"MainWindow", "Although the Bitmessage address you entered was valid, it doesn\'t match the chan name.")) "MainWindow", "Although the Bitmessage address you entered was valid, it doesn\'t match the chan name."))
@ -1607,6 +1607,7 @@ class MyForm(settingsmixin.SMainWindow):
QMessageBox.about(self, _translate("MainWindow", "Success"), _translate( QMessageBox.about(self, _translate("MainWindow", "Success"), _translate(
"MainWindow", "Successfully joined chan. ")) "MainWindow", "Successfully joined chan. "))
self.ui.tabWidget.setCurrentIndex(3) self.ui.tabWidget.setCurrentIndex(3)
self.rerenderAddressBook()
def showConnectDialog(self): def showConnectDialog(self):
self.connectDialogInstance = connectDialog(self) self.connectDialogInstance = connectDialog(self)
@ -2069,7 +2070,7 @@ class MyForm(settingsmixin.SMainWindow):
addresses = getSortedAccounts() addresses = getSortedAccounts()
for address in addresses: for address in addresses:
account = accountClass(address) account = accountClass(address)
if (account.type == 'chan'): if (account.type == 'chan' and shared.safeConfigGetBoolean(address, 'enabled')):
addRow(address, account.getLabel(), 'chan') addRow(address, account.getLabel(), 'chan')
# normal accounts # normal accounts
@ -2500,7 +2501,7 @@ class MyForm(settingsmixin.SMainWindow):
sqlExecute('''INSERT INTO subscriptions VALUES (?,?,?)''',str(label),address,True) sqlExecute('''INSERT INTO subscriptions VALUES (?,?,?)''',str(label),address,True)
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
self.rerenderAddressBook()
self.rerenderTabTreeSubscriptions() self.rerenderTabTreeSubscriptions()
def click_pushButtonAddSubscription(self): def click_pushButtonAddSubscription(self):
@ -3384,6 +3385,7 @@ class MyForm(settingsmixin.SMainWindow):
address) address)
self.rerenderTabTreeSubscriptions() self.rerenderTabTreeSubscriptions()
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
self.rerenderAddressBook()
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
def on_action_SubscriptionsClipboard(self): def on_action_SubscriptionsClipboard(self):
@ -3398,6 +3400,7 @@ class MyForm(settingsmixin.SMainWindow):
address) address)
account = self.getCurrentItem() account = self.getCurrentItem()
account.setEnabled(True) account.setEnabled(True)
self.rerenderAddressBook()
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
def on_action_SubscriptionsDisable(self): def on_action_SubscriptionsDisable(self):
@ -3407,6 +3410,7 @@ class MyForm(settingsmixin.SMainWindow):
address) address)
account = self.getCurrentItem() account = self.getCurrentItem()
account.setEnabled(False) account.setEnabled(False)
self.rerenderAddressBook()
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
def on_context_menuSubscriptions(self, point): def on_context_menuSubscriptions(self, point):
@ -3666,6 +3670,7 @@ class MyForm(settingsmixin.SMainWindow):
return return
shared.writeKeysFile() shared.writeKeysFile()
shared.reloadMyAddressHashes() shared.reloadMyAddressHashes()
self.rerenderAddressBook()
if account.type == "normal": if account.type == "normal":
self.rerenderTabTreeMessages() self.rerenderTabTreeMessages()
elif account.type == "chan": elif account.type == "chan":
@ -3681,6 +3686,7 @@ class MyForm(settingsmixin.SMainWindow):
shared.config.set(address, 'enabled', 'true') shared.config.set(address, 'enabled', 'true')
shared.writeKeysFile() shared.writeKeysFile()
shared.reloadMyAddressHashes() shared.reloadMyAddressHashes()
self.rerenderAddressBook()
def on_action_Disable(self): def on_action_Disable(self):
address = self.getCurrentAccount() address = self.getCurrentAccount()
@ -3692,6 +3698,7 @@ class MyForm(settingsmixin.SMainWindow):
shared.config.set(str(address), 'enabled', 'false') shared.config.set(str(address), 'enabled', 'false')
shared.writeKeysFile() shared.writeKeysFile()
shared.reloadMyAddressHashes() shared.reloadMyAddressHashes()
self.rerenderAddressBook()
def on_action_Clipboard(self): def on_action_Clipboard(self):
address = self.getCurrentAccount() address = self.getCurrentAccount()