Adds new API error codes for black-/white-list manipulation.
Refactors loadBlackWhiteList into more generic rerenderBlackWhiteList
This commit is contained in:
parent
afb21ca307
commit
e93d23d2e0
14
src/api.py
14
src/api.py
|
@ -763,9 +763,9 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
# black-/white-list.
|
# black-/white-list.
|
||||||
queryreturn = sqlQuery('''select * from '''+table+''' where address=?''', address)
|
queryreturn = sqlQuery('''select * from '''+table+''' where address=?''', address)
|
||||||
if queryreturn != []:
|
if queryreturn != []:
|
||||||
raise APIError(16, 'You have already black-/white-listed that address.')
|
raise APIError(28, 'You have already black-/white-listed that address.')
|
||||||
sqlExecute('''INSERT INTO '''+table+''' VALUES (?,?,?)''',label, address, True)
|
sqlExecute('''INSERT INTO '''+table+''' VALUES (?,?,?)''',label, address, True)
|
||||||
shared.UISignalQueue.put(('rerenderBlacklist', ''))
|
shared.UISignalQueue.put(('rerenderBlackWhiteList', ''))
|
||||||
return 'Added black-/white-list entry.'
|
return 'Added black-/white-list entry.'
|
||||||
|
|
||||||
elif method == 'removeAddressFromBlackWhiteList':
|
elif method == 'removeAddressFromBlackWhiteList':
|
||||||
|
@ -780,8 +780,14 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
else:
|
else:
|
||||||
table = 'whitelist'
|
table = 'whitelist'
|
||||||
|
|
||||||
sqlExecute('''DELETE FROM blacklist WHERE address=?''', address)
|
# First we must check to see if the address is already in the
|
||||||
shared.UISignalQueue.put(('rerenderBlacklist', ''))
|
# black-/white-list.
|
||||||
|
queryreturn = sqlQuery('''select * from '''+table+''' where address=?''', address)
|
||||||
|
if queryreturn == []:
|
||||||
|
raise APIError(29, 'That entry does not exist in the black-/white-list.')
|
||||||
|
|
||||||
|
sqlExecute('''DELETE FROM '''+table+''' WHERE address=?''', address)
|
||||||
|
shared.UISignalQueue.put(('rerenderBlackWhiteList', ''))
|
||||||
return 'Deleted black-/white-list entry if it existed.'
|
return 'Deleted black-/white-list entry if it existed.'
|
||||||
|
|
||||||
elif method == 'deleteSubscription':
|
elif method == 'deleteSubscription':
|
||||||
|
|
|
@ -551,13 +551,10 @@ class MyForm(QtGui.QMainWindow):
|
||||||
"returnPressed()"), self.sentSearchLineEditPressed)
|
"returnPressed()"), self.sentSearchLineEditPressed)
|
||||||
|
|
||||||
# Initialize the Blacklist or Whitelist
|
# Initialize the Blacklist or Whitelist
|
||||||
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white':
|
||||||
self.loadBlackWhiteList()
|
|
||||||
else:
|
|
||||||
self.ui.tabWidget.setTabText(6, 'Whitelist')
|
self.ui.tabWidget.setTabText(6, 'Whitelist')
|
||||||
self.ui.radioButtonWhitelist.click()
|
self.ui.radioButtonWhitelist.click()
|
||||||
self.loadBlackWhiteList()
|
self.rerenderBlackWhiteList()
|
||||||
self.rerenderBlacklist()
|
|
||||||
|
|
||||||
QtCore.QObject.connect(self.ui.tableWidgetYourIdentities, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.ui.tableWidgetYourIdentities, QtCore.SIGNAL(
|
||||||
"itemChanged(QTableWidgetItem *)"), self.tableWidgetYourIdentitiesItemChanged)
|
"itemChanged(QTableWidgetItem *)"), self.tableWidgetYourIdentitiesItemChanged)
|
||||||
|
@ -623,7 +620,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
"rerenderSubscriptions()"), self.rerenderSubscriptions)
|
"rerenderSubscriptions()"), self.rerenderSubscriptions)
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
"rerenderBlacklist()"), self.rerenderBlacklist)
|
"rerenderBlackWhiteList()"), self.rerenderBlackWhiteList)
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
"removeInboxRowByMsgid(PyQt_PyObject)"), self.removeInboxRowByMsgid)
|
"removeInboxRowByMsgid(PyQt_PyObject)"), self.removeInboxRowByMsgid)
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
|
@ -1835,9 +1832,13 @@ class MyForm(QtGui.QMainWindow):
|
||||||
newItem.setTextColor(QtGui.QColor(128, 128, 128))
|
newItem.setTextColor(QtGui.QColor(128, 128, 128))
|
||||||
self.ui.tableWidgetSubscriptions.setItem(0, 1, newItem)
|
self.ui.tableWidgetSubscriptions.setItem(0, 1, newItem)
|
||||||
|
|
||||||
def rerenderBlacklist(self):
|
def rerenderBlackWhiteList(self):
|
||||||
self.ui.tableWidgetBlacklist.setRowCount(0)
|
self.ui.tableWidgetBlacklist.setRowCount(0)
|
||||||
queryreturn = sqlQuery('SELECT label, address, enabled FROM blacklist')
|
listType = shared.config.get('bitmessagesettings', 'blackwhitelist')
|
||||||
|
if listType == 'black':
|
||||||
|
queryreturn = sqlQuery('''SELECT label, address, enabled FROM blacklist''')
|
||||||
|
else:
|
||||||
|
queryreturn = sqlQuery('''SELECT label, address, enabled FROM whitelist''')
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
label, address, enabled = row
|
label, address, enabled = row
|
||||||
self.ui.tableWidgetBlacklist.insertRow(0)
|
self.ui.tableWidgetBlacklist.insertRow(0)
|
||||||
|
@ -2251,28 +2252,6 @@ class MyForm(QtGui.QMainWindow):
|
||||||
shared.objectProcessorQueueSize += len(payload)
|
shared.objectProcessorQueueSize += len(payload)
|
||||||
shared.objectProcessorQueue.put((objectType,payload))
|
shared.objectProcessorQueue.put((objectType,payload))
|
||||||
|
|
||||||
def loadBlackWhiteList(self):
|
|
||||||
# Initialize the Blacklist or Whitelist table
|
|
||||||
listType = shared.config.get('bitmessagesettings', 'blackwhitelist')
|
|
||||||
if listType == 'black':
|
|
||||||
queryreturn = sqlQuery('''SELECT label, address, enabled FROM blacklist''')
|
|
||||||
else:
|
|
||||||
queryreturn = sqlQuery('''SELECT label, address, enabled FROM whitelist''')
|
|
||||||
for row in queryreturn:
|
|
||||||
label, address, enabled = row
|
|
||||||
self.ui.tableWidgetBlacklist.insertRow(0)
|
|
||||||
newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
|
|
||||||
if not enabled:
|
|
||||||
newItem.setTextColor(QtGui.QColor(128, 128, 128))
|
|
||||||
newItem.setIcon(avatarize(address))
|
|
||||||
self.ui.tableWidgetBlacklist.setItem(0, 0, newItem)
|
|
||||||
newItem = QtGui.QTableWidgetItem(address)
|
|
||||||
newItem.setFlags(
|
|
||||||
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
|
||||||
if not enabled:
|
|
||||||
newItem.setTextColor(QtGui.QColor(128, 128, 128))
|
|
||||||
self.ui.tableWidgetBlacklist.setItem(0, 1, newItem)
|
|
||||||
|
|
||||||
def click_pushButtonStatusIcon(self):
|
def click_pushButtonStatusIcon(self):
|
||||||
print 'click_pushButtonStatusIcon'
|
print 'click_pushButtonStatusIcon'
|
||||||
self.iconGlossaryInstance = iconGlossaryDialog(self)
|
self.iconGlossaryInstance = iconGlossaryDialog(self)
|
||||||
|
@ -2505,7 +2484,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
shared.config.write(configfile)
|
shared.config.write(configfile)
|
||||||
# self.ui.tableWidgetBlacklist.clearContents()
|
# self.ui.tableWidgetBlacklist.clearContents()
|
||||||
self.ui.tableWidgetBlacklist.setRowCount(0)
|
self.ui.tableWidgetBlacklist.setRowCount(0)
|
||||||
self.loadBlackWhiteList()
|
self.rerenderBlackWhiteList()
|
||||||
self.ui.tabWidget.setTabText(6, 'Blacklist')
|
self.ui.tabWidget.setTabText(6, 'Blacklist')
|
||||||
|
|
||||||
def click_radioButtonWhitelist(self):
|
def click_radioButtonWhitelist(self):
|
||||||
|
@ -2515,7 +2494,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
shared.config.write(configfile)
|
shared.config.write(configfile)
|
||||||
# self.ui.tableWidgetBlacklist.clearContents()
|
# self.ui.tableWidgetBlacklist.clearContents()
|
||||||
self.ui.tableWidgetBlacklist.setRowCount(0)
|
self.ui.tableWidgetBlacklist.setRowCount(0)
|
||||||
self.loadBlackWhiteList()
|
self.rerenderBlackWhiteList()
|
||||||
self.ui.tabWidget.setTabText(6, 'Whitelist')
|
self.ui.tabWidget.setTabText(6, 'Whitelist')
|
||||||
|
|
||||||
def click_pushButtonAddBlacklist(self):
|
def click_pushButtonAddBlacklist(self):
|
||||||
|
@ -3204,7 +3183,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
self.rerenderInboxToLabels()
|
self.rerenderInboxToLabels()
|
||||||
self.rerenderSentFromLabels()
|
self.rerenderSentFromLabels()
|
||||||
self.rerenderSentToLabels()
|
self.rerenderSentToLabels()
|
||||||
self.rerenderBlacklist()
|
self.rerenderBlackWhiteList()
|
||||||
|
|
||||||
def on_context_menuYourIdentities(self, point):
|
def on_context_menuYourIdentities(self, point):
|
||||||
self.popMenu.exec_(
|
self.popMenu.exec_(
|
||||||
|
@ -3860,8 +3839,8 @@ class UISignaler(QThread):
|
||||||
self.emit(SIGNAL("rerenderAddressBook()"))
|
self.emit(SIGNAL("rerenderAddressBook()"))
|
||||||
elif command == 'rerenderSubscriptions':
|
elif command == 'rerenderSubscriptions':
|
||||||
self.emit(SIGNAL("rerenderSubscriptions()"))
|
self.emit(SIGNAL("rerenderSubscriptions()"))
|
||||||
elif command == 'rerenderBlacklist':
|
elif command == 'rerenderBlackWhiteList':
|
||||||
self.emit(SIGNAL("rerenderBlacklist()"))
|
self.emit(SIGNAL("rerenderBlackWhiteList()"))
|
||||||
elif command == 'removeInboxRowByMsgid':
|
elif command == 'removeInboxRowByMsgid':
|
||||||
self.emit(SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"), data)
|
self.emit(SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"), data)
|
||||||
elif command == 'alert':
|
elif command == 'alert':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user