diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py
index 1fa8dde4..bb7c2722 100644
--- a/src/bitmessageqt/__init__.py
+++ b/src/bitmessageqt/__init__.py
@@ -32,7 +32,6 @@ from newaddresswizard import *
from messageview import MessageView
from migrationwizard import *
from foldertree import *
-from addaddressdialog import *
from newsubscriptiondialog import *
from regenerateaddresses import *
from newchandialog import *
@@ -68,6 +67,7 @@ import types
from utils import *
from collections import OrderedDict
from account import *
+from dialogs import AddAddressDialog
def _translate(context, text):
return QtGui.QApplication.translate(context, text)
@@ -141,18 +141,12 @@ class MyForm(settingsmixin.SMainWindow):
"clicked()"), self.click_pushButtonAddAddressBook)
QtCore.QObject.connect(self.ui.pushButtonAddSubscription, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonAddSubscription)
- QtCore.QObject.connect(self.ui.pushButtonAddBlacklist, QtCore.SIGNAL(
- "clicked()"), self.click_pushButtonAddBlacklist)
QtCore.QObject.connect(self.ui.pushButtonTTL, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonTTL)
QtCore.QObject.connect(self.ui.pushButtonSend, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonSend)
QtCore.QObject.connect(self.ui.pushButtonFetchNamecoinID, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonFetchNamecoinID)
- QtCore.QObject.connect(self.ui.radioButtonBlacklist, QtCore.SIGNAL(
- "clicked()"), self.click_radioButtonBlacklist)
- QtCore.QObject.connect(self.ui.radioButtonWhitelist, QtCore.SIGNAL(
- "clicked()"), self.click_radioButtonWhitelist)
QtCore.QObject.connect(self.ui.actionSettings, QtCore.SIGNAL(
"triggered()"), self.click_actionSettings)
QtCore.QObject.connect(self.ui.actionAbout, QtCore.SIGNAL(
@@ -366,46 +360,6 @@ class MyForm(settingsmixin.SMainWindow):
# self.popMenuSent.addAction( self.actionSentClipboard )
# self.popMenuSent.addAction( self.actionTrashSentMessage )
- def init_blacklist_popup_menu(self, connectSignal=True):
- # Popup menu for the Blacklist page
- self.ui.blacklistContextMenuToolbar = QtGui.QToolBar()
- # Actions
- self.actionBlacklistNew = self.ui.blacklistContextMenuToolbar.addAction(
- _translate(
- "MainWindow", "Add new entry"), self.on_action_BlacklistNew)
- self.actionBlacklistDelete = self.ui.blacklistContextMenuToolbar.addAction(
- _translate(
- "MainWindow", "Delete"), self.on_action_BlacklistDelete)
- self.actionBlacklistClipboard = self.ui.blacklistContextMenuToolbar.addAction(
- _translate(
- "MainWindow", "Copy address to clipboard"),
- self.on_action_BlacklistClipboard)
- self.actionBlacklistEnable = self.ui.blacklistContextMenuToolbar.addAction(
- _translate(
- "MainWindow", "Enable"), self.on_action_BlacklistEnable)
- self.actionBlacklistDisable = self.ui.blacklistContextMenuToolbar.addAction(
- _translate(
- "MainWindow", "Disable"), self.on_action_BlacklistDisable)
- self.actionBlacklistSetAvatar = self.ui.blacklistContextMenuToolbar.addAction(
- _translate(
- "MainWindow", "Set avatar..."),
- self.on_action_BlacklistSetAvatar)
- self.ui.tableWidgetBlacklist.setContextMenuPolicy(
- QtCore.Qt.CustomContextMenu)
- if connectSignal:
- self.connect(self.ui.tableWidgetBlacklist, QtCore.SIGNAL(
- 'customContextMenuRequested(const QPoint&)'),
- self.on_context_menuBlacklist)
- self.popMenuBlacklist = QtGui.QMenu(self)
- # self.popMenuBlacklist.addAction( self.actionBlacklistNew )
- self.popMenuBlacklist.addAction(self.actionBlacklistDelete)
- self.popMenuBlacklist.addSeparator()
- self.popMenuBlacklist.addAction(self.actionBlacklistClipboard)
- self.popMenuBlacklist.addSeparator()
- self.popMenuBlacklist.addAction(self.actionBlacklistEnable)
- self.popMenuBlacklist.addAction(self.actionBlacklistDisable)
- self.popMenuBlacklist.addAction(self.actionBlacklistSetAvatar)
-
def rerenderTabTreeSubscriptions(self):
treeWidget = self.ui.treeWidgetSubscriptions
folders = Ui_FolderWidget.folderWeight.keys()
@@ -646,8 +600,7 @@ class MyForm(settingsmixin.SMainWindow):
self.init_subscriptions_popup_menu()
self.init_chan_popup_menu()
self.init_sent_popup_menu()
- self.init_blacklist_popup_menu()
-
+
# Initialize the user's list of addresses on the 'Chan' tab.
self.rerenderTabTreeChans()
@@ -684,12 +637,6 @@ class MyForm(settingsmixin.SMainWindow):
QtCore.QObject.connect(self.ui.inboxSearchLineEditChans, QtCore.SIGNAL(
"textChanged(QString)"), self.inboxSearchLineEditUpdated)
- # Initialize the Blacklist or Whitelist
- if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white':
- self.ui.tabWidget.setTabText(6, 'Whitelist')
- self.ui.radioButtonWhitelist.click()
- self.rerenderBlackWhiteList()
-
# Initialize addressbook
QtCore.QObject.connect(self.ui.tableWidgetAddressBook, QtCore.SIGNAL(
"itemChanged(QTableWidgetItem *)"), self.tableWidgetAddressBookItemChanged)
@@ -716,10 +663,6 @@ class MyForm(settingsmixin.SMainWindow):
QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL(
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
- # Initialize blacklist
- QtCore.QObject.connect(self.ui.tableWidgetBlacklist, QtCore.SIGNAL(
- "itemChanged(QTableWidgetItem *)"), self.tableWidgetBlacklistItemChanged)
-
# Put the colored icon on the status bar
# self.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
self.statusbar = self.statusBar()
@@ -744,7 +687,6 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.treeWidgetYourIdentities.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.ui.treeWidgetSubscriptions.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.ui.tableWidgetAddressBook.setIconSize(QtCore.QSize(identicon_size, identicon_size))
- self.ui.tableWidgetBlacklist.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.UISignalThread = UISignaler.get()
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
@@ -771,8 +713,6 @@ class MyForm(settingsmixin.SMainWindow):
"rerenderAddressBook()"), self.rerenderAddressBook)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"rerenderSubscriptions()"), self.rerenderSubscriptions)
- QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
- "rerenderBlackWhiteList()"), self.rerenderBlackWhiteList)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"removeInboxRowByMsgid(PyQt_PyObject)"), self.removeInboxRowByMsgid)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
@@ -1685,7 +1625,7 @@ class MyForm(settingsmixin.SMainWindow):
self.init_addressbook_popup_menu(False)
self.init_subscriptions_popup_menu(False)
self.init_sent_popup_menu(False)
- self.init_blacklist_popup_menu(False)
+ self.ui.blackwhitelist.init_blacklist_popup_menu(False)
if event.type() == QtCore.QEvent.WindowStateChange:
if self.windowState() & QtCore.Qt.WindowMinimized:
if shared.config.getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform:
@@ -1969,29 +1909,6 @@ class MyForm(settingsmixin.SMainWindow):
def rerenderSubscriptions(self):
self.rerenderTabTreeSubscriptions()
- def rerenderBlackWhiteList(self):
- self.ui.tableWidgetBlacklist.setRowCount(0)
- 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''')
- self.ui.tableWidgetBlacklist.setSortingEnabled(False)
- 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)
- self.ui.tableWidgetBlacklist.setSortingEnabled(True)
def click_pushButtonTTL(self):
QtGui.QMessageBox.information(self, 'Time To Live', _translate(
@@ -2631,64 +2548,6 @@ class MyForm(settingsmixin.SMainWindow):
except:
pass
- def click_radioButtonBlacklist(self):
- if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white':
- shared.config.set('bitmessagesettings', 'blackwhitelist', 'black')
- shared.writeKeysFile()
- # self.ui.tableWidgetBlacklist.clearContents()
- self.ui.tableWidgetBlacklist.setRowCount(0)
- self.rerenderBlackWhiteList()
- self.ui.tabWidget.setTabText(6, 'Blacklist')
-
- def click_radioButtonWhitelist(self):
- if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
- shared.config.set('bitmessagesettings', 'blackwhitelist', 'white')
- shared.writeKeysFile()
- # self.ui.tableWidgetBlacklist.clearContents()
- self.ui.tableWidgetBlacklist.setRowCount(0)
- self.rerenderBlackWhiteList()
- self.ui.tabWidget.setTabText(6, 'Whitelist')
-
- def click_pushButtonAddBlacklist(self):
- self.NewBlacklistDialogInstance = AddAddressDialog(self)
- if self.NewBlacklistDialogInstance.exec_():
- if self.NewBlacklistDialogInstance.ui.labelAddressCheck.text() == _translate("MainWindow", "Address is valid."):
- address = addBMIfNotPresent(str(
- self.NewBlacklistDialogInstance.ui.lineEditAddress.text()))
- # First we must check to see if the address is already in the
- # address book. The user cannot add it again or else it will
- # cause problems when updating and deleting the entry.
- t = (address,)
- if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
- sql = '''select * from blacklist where address=?'''
- else:
- sql = '''select * from whitelist where address=?'''
- queryreturn = sqlQuery(sql,*t)
- if queryreturn == []:
- self.ui.tableWidgetBlacklist.setSortingEnabled(False)
- self.ui.tableWidgetBlacklist.insertRow(0)
- newItem = QtGui.QTableWidgetItem(unicode(
- self.NewBlacklistDialogInstance.ui.newAddressLabel.text().toUtf8(), 'utf-8'))
- newItem.setIcon(avatarize(address))
- self.ui.tableWidgetBlacklist.setItem(0, 0, newItem)
- newItem = QtGui.QTableWidgetItem(address)
- newItem.setFlags(
- QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
- self.ui.tableWidgetBlacklist.setItem(0, 1, newItem)
- self.ui.tableWidgetBlacklist.setSortingEnabled(True)
- t = (str(self.NewBlacklistDialogInstance.ui.newAddressLabel.text().toUtf8()), address, True)
- if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
- sql = '''INSERT INTO blacklist VALUES (?,?,?)'''
- else:
- sql = '''INSERT INTO whitelist VALUES (?,?,?)'''
- sqlExecute(sql, *t)
- else:
- self.statusBar().showMessage(_translate(
- "MainWindow", "Error: You cannot add the same address to your list twice. Perhaps rename the existing one if you want."))
- else:
- self.statusBar().showMessage(_translate(
- "MainWindow", "The address you entered was invalid. Ignoring it."))
-
def on_action_SpecialAddressBehaviorDialog(self):
self.dialog = SpecialAddressBehaviorDialog(self)
# For Modal dialogs
@@ -3062,7 +2921,7 @@ class MyForm(settingsmixin.SMainWindow):
sqlExecute('''INSERT INTO blacklist VALUES (?,?, ?)''',
label,
addressAtCurrentInboxRow, True)
- self.rerenderBlackWhiteList()
+ self.ui.blackwhitelist.rerenderBlackWhiteList()
self.statusBar().showMessage(_translate(
"MainWindow", "Entry added to the blacklist. Edit the label to your liking."))
else:
@@ -3369,69 +3228,6 @@ class MyForm(settingsmixin.SMainWindow):
self.popMenuSubscriptions.exec_(
self.ui.treeWidgetSubscriptions.mapToGlobal(point))
- # Group of functions for the Blacklist dialog box
- def on_action_BlacklistNew(self):
- self.click_pushButtonAddBlacklist()
-
- def on_action_BlacklistDelete(self):
- currentRow = self.ui.tableWidgetBlacklist.currentRow()
- labelAtCurrentRow = self.ui.tableWidgetBlacklist.item(
- currentRow, 0).text().toUtf8()
- addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(
- currentRow, 1).text()
- if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
- sqlExecute(
- '''DELETE FROM blacklist WHERE label=? AND address=?''',
- str(labelAtCurrentRow), str(addressAtCurrentRow))
- else:
- sqlExecute(
- '''DELETE FROM whitelist WHERE label=? AND address=?''',
- str(labelAtCurrentRow), str(addressAtCurrentRow))
- self.ui.tableWidgetBlacklist.removeRow(currentRow)
-
- def on_action_BlacklistClipboard(self):
- currentRow = self.ui.tableWidgetBlacklist.currentRow()
- addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(
- currentRow, 1).text()
- clipboard = QtGui.QApplication.clipboard()
- clipboard.setText(str(addressAtCurrentRow))
-
- def on_context_menuBlacklist(self, point):
- self.popMenuBlacklist.exec_(
- self.ui.tableWidgetBlacklist.mapToGlobal(point))
-
- def on_action_BlacklistEnable(self):
- currentRow = self.ui.tableWidgetBlacklist.currentRow()
- addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(
- currentRow, 1).text()
- self.ui.tableWidgetBlacklist.item(
- currentRow, 0).setTextColor(QApplication.palette().text().color())
- self.ui.tableWidgetBlacklist.item(
- currentRow, 1).setTextColor(QApplication.palette().text().color())
- if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
- sqlExecute(
- '''UPDATE blacklist SET enabled=1 WHERE address=?''',
- str(addressAtCurrentRow))
- else:
- sqlExecute(
- '''UPDATE whitelist SET enabled=1 WHERE address=?''',
- str(addressAtCurrentRow))
-
- def on_action_BlacklistDisable(self):
- currentRow = self.ui.tableWidgetBlacklist.currentRow()
- addressAtCurrentRow = self.ui.tableWidgetBlacklist.item(
- currentRow, 1).text()
- self.ui.tableWidgetBlacklist.item(
- currentRow, 0).setTextColor(QtGui.QColor(128, 128, 128))
- self.ui.tableWidgetBlacklist.item(
- currentRow, 1).setTextColor(QtGui.QColor(128, 128, 128))
- if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
- sqlExecute(
- '''UPDATE blacklist SET enabled=0 WHERE address=?''', str(addressAtCurrentRow))
- else:
- sqlExecute(
- '''UPDATE whitelist SET enabled=0 WHERE address=?''', str(addressAtCurrentRow))
-
def widgetConvert (self, widget):
if widget == self.ui.tableWidgetInbox:
return self.ui.treeWidgetYourIdentities
@@ -3685,9 +3481,6 @@ class MyForm(settingsmixin.SMainWindow):
def on_action_AddressBookSetAvatar(self):
self.on_action_SetAvatar(self.ui.tableWidgetAddressBook)
- def on_action_BlacklistSetAvatar(self):
- self.on_action_SetAvatar(self.ui.tableWidgetBlacklist)
-
def on_action_SetAvatar(self, thisTableWidget):
currentRow = thisTableWidget.currentRow()
addressAtCurrentRow = thisTableWidget.item(
@@ -3758,7 +3551,7 @@ class MyForm(settingsmixin.SMainWindow):
self.rerenderComboBoxSendFromBroadcast()
self.rerenderMessagelistFromLabels()
self.rerenderMessagelistToLabels()
- self.rerenderBlackWhiteList()
+ self.ui.blackwhitelist.rerenderBlackWhiteList()
# generate identicon
return False
@@ -4002,17 +3795,6 @@ class MyForm(settingsmixin.SMainWindow):
self.rerenderComboBoxSendFrom()
self.rerenderComboBoxSendFromBroadcast()
- def tableWidgetBlacklistItemChanged(self, item):
- if item.column() == 0:
- addressitem = self.ui.tableWidgetBlacklist.item(item.row(), 1)
- if isinstance(addressitem, QTableWidgetItem):
- if self.ui.radioButtonBlacklist.isChecked():
- sqlExecute('''UPDATE blacklist SET label=? WHERE address=?''',
- str(item.text()), str(addressitem.text()))
- else:
- sqlExecute('''UPDATE whitelist SET label=? WHERE address=?''',
- str(item.text()), str(addressitem.text()))
-
def updateStatusBar(self, data):
if data != "":
logger.info('Status bar: ' + data)
@@ -4371,43 +4153,6 @@ class EmailGatewayRegistrationDialog(QtGui.QDialog):
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
-class AddAddressDialog(QtGui.QDialog):
-
- def __init__(self, parent):
- QtGui.QWidget.__init__(self, parent)
- self.ui = Ui_AddAddressDialog()
- self.ui.setupUi(self)
- self.parent = parent
- QtCore.QObject.connect(self.ui.lineEditAddress, QtCore.SIGNAL(
- "textChanged(QString)"), self.addressChanged)
-
- def addressChanged(self, QString):
- status, a, b, c = decodeAddress(str(QString))
- if status == 'missingbm':
- self.ui.labelAddressCheck.setText(_translate(
- "MainWindow", "The address should start with ''BM-''"))
- elif status == 'checksumfailed':
- self.ui.labelAddressCheck.setText(_translate(
- "MainWindow", "The address is not typed or copied correctly (the checksum failed)."))
- elif status == 'versiontoohigh':
- self.ui.labelAddressCheck.setText(_translate(
- "MainWindow", "The version number of this address is higher than this software can support. Please upgrade Bitmessage."))
- elif status == 'invalidcharacters':
- self.ui.labelAddressCheck.setText(_translate(
- "MainWindow", "The address contains invalid characters."))
- elif status == 'ripetooshort':
- self.ui.labelAddressCheck.setText(_translate(
- "MainWindow", "Some data encoded in the address is too short."))
- elif status == 'ripetoolong':
- self.ui.labelAddressCheck.setText(_translate(
- "MainWindow", "Some data encoded in the address is too long."))
- elif status == 'varintmalformed':
- self.ui.labelAddressCheck.setText(_translate(
- "MainWindow", "Some data encoded in the address is malformed."))
- elif status == 'success':
- self.ui.labelAddressCheck.setText(
- _translate("MainWindow", "Address is valid."))
-
class NewSubscriptionDialog(QtGui.QDialog):
def __init__(self, parent):
diff --git a/src/bitmessageqt/bitmessageui.py b/src/bitmessageqt/bitmessageui.py
index 63b10e3c..b8547c22 100644
--- a/src/bitmessageqt/bitmessageui.py
+++ b/src/bitmessageqt/bitmessageui.py
@@ -12,6 +12,8 @@ from messageview import MessageView
from messagecompose import MessageCompose
import settingsmixin
from networkstatus import NetworkStatus
+from blacklist import Blacklist
+import shared
try:
_fromUtf8 = QtCore.QString.fromUtf8
@@ -551,43 +553,13 @@ class Ui_MainWindow(object):
icon8 = QtGui.QIcon()
icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/can-icon-16px.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.tabWidget.addTab(self.chans, icon8, _fromUtf8(""))
- self.blackwhitelist = QtGui.QWidget()
- self.blackwhitelist.setObjectName(_fromUtf8("blackwhitelist"))
- self.gridLayout_6 = QtGui.QGridLayout(self.blackwhitelist)
- self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6"))
- self.radioButtonBlacklist = QtGui.QRadioButton(self.blackwhitelist)
- self.radioButtonBlacklist.setChecked(True)
- self.radioButtonBlacklist.setObjectName(_fromUtf8("radioButtonBlacklist"))
- self.gridLayout_6.addWidget(self.radioButtonBlacklist, 0, 0, 1, 2)
- self.radioButtonWhitelist = QtGui.QRadioButton(self.blackwhitelist)
- self.radioButtonWhitelist.setObjectName(_fromUtf8("radioButtonWhitelist"))
- self.gridLayout_6.addWidget(self.radioButtonWhitelist, 1, 0, 1, 2)
- self.pushButtonAddBlacklist = QtGui.QPushButton(self.blackwhitelist)
- self.pushButtonAddBlacklist.setObjectName(_fromUtf8("pushButtonAddBlacklist"))
- self.gridLayout_6.addWidget(self.pushButtonAddBlacklist, 2, 0, 1, 1)
- spacerItem = QtGui.QSpacerItem(689, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
- self.gridLayout_6.addItem(spacerItem, 2, 1, 1, 1)
- self.tableWidgetBlacklist = settingsmixin.STableWidget(self.blackwhitelist)
- self.tableWidgetBlacklist.setAlternatingRowColors(True)
- self.tableWidgetBlacklist.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
- self.tableWidgetBlacklist.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
- self.tableWidgetBlacklist.setObjectName(_fromUtf8("tableWidgetBlacklist"))
- self.tableWidgetBlacklist.setColumnCount(2)
- self.tableWidgetBlacklist.setRowCount(0)
- item = QtGui.QTableWidgetItem()
- self.tableWidgetBlacklist.setHorizontalHeaderItem(0, item)
- item = QtGui.QTableWidgetItem()
- self.tableWidgetBlacklist.setHorizontalHeaderItem(1, item)
- self.tableWidgetBlacklist.horizontalHeader().setCascadingSectionResizes(True)
- self.tableWidgetBlacklist.horizontalHeader().setDefaultSectionSize(400)
- self.tableWidgetBlacklist.horizontalHeader().setHighlightSections(False)
- self.tableWidgetBlacklist.horizontalHeader().setSortIndicatorShown(False)
- self.tableWidgetBlacklist.horizontalHeader().setStretchLastSection(True)
- self.tableWidgetBlacklist.verticalHeader().setVisible(False)
- self.gridLayout_6.addWidget(self.tableWidgetBlacklist, 3, 0, 1, 2)
- icon9 = QtGui.QIcon()
- icon9.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/blacklist.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
- self.tabWidget.addTab(self.blackwhitelist, icon9, _fromUtf8(""))
+ self.blackwhitelist = Blacklist()
+ self.tabWidget.addTab(self.blackwhitelist, QtGui.QIcon(":/newPrefix/images/blacklist.png"), "")
+ # Initialize the Blacklist or Whitelist
+ if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white':
+ self.blackwhitelist.radioButtonWhitelist.click()
+ self.blackwhitelist.rerenderBlackWhiteList()
+
self.networkstatus = NetworkStatus()
self.tabWidget.addTab(self.networkstatus, QtGui.QIcon(":/newPrefix/images/networkstatus.png"), "")
self.gridLayout_10.addWidget(self.tabWidget, 0, 0, 1, 1)
@@ -668,10 +640,6 @@ class Ui_MainWindow(object):
MainWindow.setTabOrder(self.lineEditTo, self.lineEditSubject)
MainWindow.setTabOrder(self.lineEditSubject, self.textEditMessage)
MainWindow.setTabOrder(self.textEditMessage, self.pushButtonAddSubscription)
- MainWindow.setTabOrder(self.pushButtonAddSubscription, self.radioButtonBlacklist)
- MainWindow.setTabOrder(self.radioButtonBlacklist, self.radioButtonWhitelist)
- MainWindow.setTabOrder(self.radioButtonWhitelist, self.pushButtonAddBlacklist)
- MainWindow.setTabOrder(self.pushButtonAddBlacklist, self.tableWidgetBlacklist)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "Bitmessage", None))
@@ -757,15 +725,6 @@ class Ui_MainWindow(object):
item = self.tableWidgetInboxChans.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "Received", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.chans), _translate("MainWindow", "Chans", None))
- self.radioButtonBlacklist.setText(_translate("MainWindow", "Use a Blacklist (Allow all incoming messages except those on the Blacklist)", None))
- self.radioButtonWhitelist.setText(_translate("MainWindow", "Use a Whitelist (Block all incoming messages except those on the Whitelist)", None))
- self.pushButtonAddBlacklist.setText(_translate("MainWindow", "Add new entry", None))
- self.tableWidgetBlacklist.setSortingEnabled(True)
- item = self.tableWidgetBlacklist.horizontalHeaderItem(0)
- item.setText(_translate("MainWindow", "Name or Label", None))
- item = self.tableWidgetBlacklist.horizontalHeaderItem(1)
- item.setText(_translate("MainWindow", "Address", None))
- self.tabWidget.setTabText(self.tabWidget.indexOf(self.blackwhitelist), _translate("MainWindow", "Blacklist", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.networkstatus), _translate("MainWindow", "Network Status", None))
self.menuFile.setTitle(_translate("MainWindow", "File", None))
self.menuSettings.setTitle(_translate("MainWindow", "Settings", None))
diff --git a/src/bitmessageqt/blacklist.py b/src/bitmessageqt/blacklist.py
new file mode 100644
index 00000000..11fdb201
--- /dev/null
+++ b/src/bitmessageqt/blacklist.py
@@ -0,0 +1,241 @@
+from PyQt4 import QtCore, QtGui
+import shared
+from tr import _translate
+import l10n
+from uisignaler import UISignaler
+import widgets
+from addresses import addBMIfNotPresent
+from dialogs import AddAddressDialog
+from helper_sql import sqlExecute, sqlQuery
+from utils import avatarize
+from uisignaler import UISignaler
+
+
+class Blacklist(QtGui.QWidget):
+ def __init__(self, parent=None):
+ super(Blacklist, self).__init__(parent)
+ widgets.load('blacklist.ui', self)
+
+ QtCore.QObject.connect(self.radioButtonBlacklist, QtCore.SIGNAL(
+ "clicked()"), self.click_radioButtonBlacklist)
+ QtCore.QObject.connect(self.radioButtonWhitelist, QtCore.SIGNAL(
+ "clicked()"), self.click_radioButtonWhitelist)
+ QtCore.QObject.connect(self.pushButtonAddBlacklist, QtCore.SIGNAL(
+ "clicked()"), self.click_pushButtonAddBlacklist)
+
+ self.init_blacklist_popup_menu()
+
+ # Initialize blacklist
+ QtCore.QObject.connect(self.tableWidgetBlacklist, QtCore.SIGNAL(
+ "itemChanged(QTableWidgetItem *)"), self.tableWidgetBlacklistItemChanged)
+
+ # Set the icon sizes for the identicons
+ identicon_size = 3*7
+ self.tableWidgetBlacklist.setIconSize(QtCore.QSize(identicon_size, identicon_size))
+
+ self.UISignalThread = UISignaler.get()
+ QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
+ "rerenderBlackWhiteList()"), self.rerenderBlackWhiteList)
+
+ def click_radioButtonBlacklist(self):
+ if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white':
+ shared.config.set('bitmessagesettings', 'blackwhitelist', 'black')
+ shared.writeKeysFile()
+ # self.tableWidgetBlacklist.clearContents()
+ self.tableWidgetBlacklist.setRowCount(0)
+ self.rerenderBlackWhiteList()
+
+ def click_radioButtonWhitelist(self):
+ if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
+ shared.config.set('bitmessagesettings', 'blackwhitelist', 'white')
+ shared.writeKeysFile()
+ # self.tableWidgetBlacklist.clearContents()
+ self.tableWidgetBlacklist.setRowCount(0)
+ self.rerenderBlackWhiteList()
+
+ def click_pushButtonAddBlacklist(self):
+ self.NewBlacklistDialogInstance = AddAddressDialog(self)
+ if self.NewBlacklistDialogInstance.exec_():
+ if self.NewBlacklistDialogInstance.ui.labelAddressCheck.text() == _translate("MainWindow", "Address is valid."):
+ address = addBMIfNotPresent(str(
+ self.NewBlacklistDialogInstance.ui.lineEditAddress.text()))
+ # First we must check to see if the address is already in the
+ # address book. The user cannot add it again or else it will
+ # cause problems when updating and deleting the entry.
+ t = (address,)
+ if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
+ sql = '''select * from blacklist where address=?'''
+ else:
+ sql = '''select * from whitelist where address=?'''
+ queryreturn = sqlQuery(sql,*t)
+ if queryreturn == []:
+ self.tableWidgetBlacklist.setSortingEnabled(False)
+ self.tableWidgetBlacklist.insertRow(0)
+ newItem = QtGui.QTableWidgetItem(unicode(
+ self.NewBlacklistDialogInstance.ui.newAddressLabel.text().toUtf8(), 'utf-8'))
+ newItem.setIcon(avatarize(address))
+ self.tableWidgetBlacklist.setItem(0, 0, newItem)
+ newItem = QtGui.QTableWidgetItem(address)
+ newItem.setFlags(
+ QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
+ self.tableWidgetBlacklist.setItem(0, 1, newItem)
+ self.tableWidgetBlacklist.setSortingEnabled(True)
+ t = (str(self.NewBlacklistDialogInstance.ui.newAddressLabel.text().toUtf8()), address, True)
+ if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
+ sql = '''INSERT INTO blacklist VALUES (?,?,?)'''
+ else:
+ sql = '''INSERT INTO whitelist VALUES (?,?,?)'''
+ sqlExecute(sql, *t)
+ else:
+ self.statusBar().showMessage(_translate(
+ "MainWindow", "Error: You cannot add the same address to your list twice. Perhaps rename the existing one if you want."))
+ else:
+ self.statusBar().showMessage(_translate(
+ "MainWindow", "The address you entered was invalid. Ignoring it."))
+
+ def tableWidgetBlacklistItemChanged(self, item):
+ if item.column() == 0:
+ addressitem = self.tableWidgetBlacklist.item(item.row(), 1)
+ if isinstance(addressitem, QtGui.QTableWidgetItem):
+ if self.radioButtonBlacklist.isChecked():
+ sqlExecute('''UPDATE blacklist SET label=? WHERE address=?''',
+ str(item.text()), str(addressitem.text()))
+ else:
+ sqlExecute('''UPDATE whitelist SET label=? WHERE address=?''',
+ str(item.text()), str(addressitem.text()))
+
+ def init_blacklist_popup_menu(self, connectSignal=True):
+ # Popup menu for the Blacklist page
+ self.blacklistContextMenuToolbar = QtGui.QToolBar()
+ # Actions
+ self.actionBlacklistNew = self.blacklistContextMenuToolbar.addAction(
+ _translate(
+ "MainWindow", "Add new entry"), self.on_action_BlacklistNew)
+ self.actionBlacklistDelete = self.blacklistContextMenuToolbar.addAction(
+ _translate(
+ "MainWindow", "Delete"), self.on_action_BlacklistDelete)
+ self.actionBlacklistClipboard = self.blacklistContextMenuToolbar.addAction(
+ _translate(
+ "MainWindow", "Copy address to clipboard"),
+ self.on_action_BlacklistClipboard)
+ self.actionBlacklistEnable = self.blacklistContextMenuToolbar.addAction(
+ _translate(
+ "MainWindow", "Enable"), self.on_action_BlacklistEnable)
+ self.actionBlacklistDisable = self.blacklistContextMenuToolbar.addAction(
+ _translate(
+ "MainWindow", "Disable"), self.on_action_BlacklistDisable)
+ self.actionBlacklistSetAvatar = self.blacklistContextMenuToolbar.addAction(
+ _translate(
+ "MainWindow", "Set avatar..."),
+ self.on_action_BlacklistSetAvatar)
+ self.tableWidgetBlacklist.setContextMenuPolicy(
+ QtCore.Qt.CustomContextMenu)
+ if connectSignal:
+ self.connect(self.tableWidgetBlacklist, QtCore.SIGNAL(
+ 'customContextMenuRequested(const QPoint&)'),
+ self.on_context_menuBlacklist)
+ self.popMenuBlacklist = QtGui.QMenu(self)
+ # self.popMenuBlacklist.addAction( self.actionBlacklistNew )
+ self.popMenuBlacklist.addAction(self.actionBlacklistDelete)
+ self.popMenuBlacklist.addSeparator()
+ self.popMenuBlacklist.addAction(self.actionBlacklistClipboard)
+ self.popMenuBlacklist.addSeparator()
+ self.popMenuBlacklist.addAction(self.actionBlacklistEnable)
+ self.popMenuBlacklist.addAction(self.actionBlacklistDisable)
+ self.popMenuBlacklist.addAction(self.actionBlacklistSetAvatar)
+
+ def rerenderBlackWhiteList(self):
+ tabs = self.parent().parent()
+ if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
+ tabs.setTabText(tabs.indexOf(self), _translate('blacklist', 'Blacklist'))
+ else:
+ tabs.setTabText(tabs.indexOf(self), _translate('blacklist', 'Whitelist'))
+ self.tableWidgetBlacklist.setRowCount(0)
+ 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''')
+ self.tableWidgetBlacklist.setSortingEnabled(False)
+ for row in queryreturn:
+ label, address, enabled = row
+ self.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.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.tableWidgetBlacklist.setItem(0, 1, newItem)
+ self.tableWidgetBlacklist.setSortingEnabled(True)
+
+ # Group of functions for the Blacklist dialog box
+ def on_action_BlacklistNew(self):
+ self.click_pushButtonAddBlacklist()
+
+ def on_action_BlacklistDelete(self):
+ currentRow = self.tableWidgetBlacklist.currentRow()
+ labelAtCurrentRow = self.tableWidgetBlacklist.item(
+ currentRow, 0).text().toUtf8()
+ addressAtCurrentRow = self.tableWidgetBlacklist.item(
+ currentRow, 1).text()
+ if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
+ sqlExecute(
+ '''DELETE FROM blacklist WHERE label=? AND address=?''',
+ str(labelAtCurrentRow), str(addressAtCurrentRow))
+ else:
+ sqlExecute(
+ '''DELETE FROM whitelist WHERE label=? AND address=?''',
+ str(labelAtCurrentRow), str(addressAtCurrentRow))
+ self.tableWidgetBlacklist.removeRow(currentRow)
+
+ def on_action_BlacklistClipboard(self):
+ currentRow = self.tableWidgetBlacklist.currentRow()
+ addressAtCurrentRow = self.tableWidgetBlacklist.item(
+ currentRow, 1).text()
+ clipboard = QtGui.QApplication.clipboard()
+ clipboard.setText(str(addressAtCurrentRow))
+
+ def on_context_menuBlacklist(self, point):
+ self.popMenuBlacklist.exec_(
+ self.tableWidgetBlacklist.mapToGlobal(point))
+
+ def on_action_BlacklistEnable(self):
+ currentRow = self.tableWidgetBlacklist.currentRow()
+ addressAtCurrentRow = self.tableWidgetBlacklist.item(
+ currentRow, 1).text()
+ self.tableWidgetBlacklist.item(
+ currentRow, 0).setTextColor(QtGui.QApplication.palette().text().color())
+ self.tableWidgetBlacklist.item(
+ currentRow, 1).setTextColor(QtGui.QApplication.palette().text().color())
+ if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
+ sqlExecute(
+ '''UPDATE blacklist SET enabled=1 WHERE address=?''',
+ str(addressAtCurrentRow))
+ else:
+ sqlExecute(
+ '''UPDATE whitelist SET enabled=1 WHERE address=?''',
+ str(addressAtCurrentRow))
+
+ def on_action_BlacklistDisable(self):
+ currentRow = self.tableWidgetBlacklist.currentRow()
+ addressAtCurrentRow = self.tableWidgetBlacklist.item(
+ currentRow, 1).text()
+ self.tableWidgetBlacklist.item(
+ currentRow, 0).setTextColor(QtGui.QColor(128, 128, 128))
+ self.tableWidgetBlacklist.item(
+ currentRow, 1).setTextColor(QtGui.QColor(128, 128, 128))
+ if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
+ sqlExecute(
+ '''UPDATE blacklist SET enabled=0 WHERE address=?''', str(addressAtCurrentRow))
+ else:
+ sqlExecute(
+ '''UPDATE whitelist SET enabled=0 WHERE address=?''', str(addressAtCurrentRow))
+
+ def on_action_BlacklistSetAvatar(self):
+ self.window().on_action_SetAvatar(self.tableWidgetBlacklist)
+
diff --git a/src/bitmessageqt/blacklist.ui b/src/bitmessageqt/blacklist.ui
new file mode 100644
index 00000000..80993fac
--- /dev/null
+++ b/src/bitmessageqt/blacklist.ui
@@ -0,0 +1,108 @@
+
+
+ blacklist
+
+
+
+ 0
+ 0
+ 819
+ 295
+
+
+
+ -
+
+
+ Use a Blacklist (Allow all incoming messages except those on the Blacklist)
+
+
+ true
+
+
+
+ -
+
+
+ Use a Whitelist (Block all incoming messages except those on the Whitelist)
+
+
+
+ -
+
+
+ Add new entry
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 689
+ 20
+
+
+
+
+ -
+
+
+ true
+
+
+ QAbstractItemView::SingleSelection
+
+
+ QAbstractItemView::SelectRows
+
+
+ true
+
+
+ true
+
+
+ 400
+
+
+ false
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+ Name or Label
+
+
+
+
+ Address
+
+
+
+
+
+
+
+
+ STableWidget
+ QTableWidget
+ bitmessageqt/settingsmixin.h
+
+
+
+
+
+
+
diff --git a/src/bitmessageqt/dialogs.py b/src/bitmessageqt/dialogs.py
new file mode 100644
index 00000000..d8133eb1
--- /dev/null
+++ b/src/bitmessageqt/dialogs.py
@@ -0,0 +1,42 @@
+from PyQt4 import QtCore, QtGui
+from addaddressdialog import Ui_AddAddressDialog
+from addresses import decodeAddress
+from tr import _translate
+
+
+class AddAddressDialog(QtGui.QDialog):
+
+ def __init__(self, parent):
+ QtGui.QWidget.__init__(self, parent)
+ self.ui = Ui_AddAddressDialog()
+ self.ui.setupUi(self)
+ self.parent = parent
+ QtCore.QObject.connect(self.ui.lineEditAddress, QtCore.SIGNAL(
+ "textChanged(QString)"), self.addressChanged)
+
+ def addressChanged(self, QString):
+ status, a, b, c = decodeAddress(str(QString))
+ if status == 'missingbm':
+ self.ui.labelAddressCheck.setText(_translate(
+ "MainWindow", "The address should start with ''BM-''"))
+ elif status == 'checksumfailed':
+ self.ui.labelAddressCheck.setText(_translate(
+ "MainWindow", "The address is not typed or copied correctly (the checksum failed)."))
+ elif status == 'versiontoohigh':
+ self.ui.labelAddressCheck.setText(_translate(
+ "MainWindow", "The version number of this address is higher than this software can support. Please upgrade Bitmessage."))
+ elif status == 'invalidcharacters':
+ self.ui.labelAddressCheck.setText(_translate(
+ "MainWindow", "The address contains invalid characters."))
+ elif status == 'ripetooshort':
+ self.ui.labelAddressCheck.setText(_translate(
+ "MainWindow", "Some data encoded in the address is too short."))
+ elif status == 'ripetoolong':
+ self.ui.labelAddressCheck.setText(_translate(
+ "MainWindow", "Some data encoded in the address is too long."))
+ elif status == 'varintmalformed':
+ self.ui.labelAddressCheck.setText(_translate(
+ "MainWindow", "Some data encoded in the address is malformed."))
+ elif status == 'success':
+ self.ui.labelAddressCheck.setText(
+ _translate("MainWindow", "Address is valid."))
diff --git a/src/bitmessageqt/networkstatus.ui b/src/bitmessageqt/networkstatus.ui
index afc8b976..07b0a36a 100644
--- a/src/bitmessageqt/networkstatus.ui
+++ b/src/bitmessageqt/networkstatus.ui
@@ -1,7 +1,7 @@
- NetworkStatus
-
+ networkstatus
+
0