Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ ignore = bitmessagekivy
[pylint.messages_control]
disable =
invalid-name,bare-except,broad-except,relative-import,
superfluous-parens,bad-option-value,fixme
superfluous-parens,bad-option-value,fixme,missing-docstring,
too-many-locals,too-few-public-methods,too-many-statements,
too-many-instance-attributes,too-many-public-methods
# invalid-name: needs fixing during a large, project-wide refactor
# bare-except,broad-except: Need fixing once thorough testing is easier
# bad-option-value is for backward compatibility between python 2 and 3
Expand All @@ -42,7 +44,9 @@ ignore = bitmessagekivy
[MESSAGES CONTROL]
disable =
invalid-name,bare-except,broad-except,relative-import,
superfluous-parens,bad-option-value,fixme
superfluous-parens,bad-option-value,fixme,missing-docstring,
too-many-locals,too-few-public-methods,too-many-statements,
too-many-instance-attributes,too-many-public-methods

[DESIGN]
max-args = 8
Expand Down
1 change: 0 additions & 1 deletion src/bitmessagecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def apiInit(apiEnabled):
def apiData():
"""TBC"""

global keysName
global keysPath
global usrPrompt

Expand Down
104 changes: 60 additions & 44 deletions src/bitmessageqt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
PyQt based UI for bitmessage, the main module
"""
# pylint: disable=import-error,too-many-lines,no-member
# pylint: disable=too-many-branches,too-many-nested-blocks
# pylint: disable=too-many-return-statements
# pylint: disable=too-many-boolean-expressions
import hashlib
import locale
import os
Expand Down Expand Up @@ -760,6 +763,11 @@ def __init__(self, parent=None):

self.unreadCount = 0

self.currentTrayIconFileName = ""
self.actionQuiet = None
self.actionShow = None
self.tray = None

# Set the icon sizes for the identicons
identicon_size = 3 * 7
self.ui.tableWidgetInbox.setIconSize(QtCore.QSize(identicon_size, identicon_size))
Expand Down Expand Up @@ -843,7 +851,7 @@ def __init__(self, parent=None):

self.initSettings()
self.resetNamecoinConnection()
self.sqlInit()
MyForm.sqlInit()
self.indicatorInit()
self.notifierInit()
self.updateStartOnLogon()
Expand Down Expand Up @@ -1107,7 +1115,8 @@ def propagateUnreadCount(self, folder=None, widget=None):
if newCount != folderItem.unreadCount:
folderItem.setUnreadCount(newCount)

def addMessageListItem(self, tableWidget, items):
@staticmethod
def addMessageListItem(tableWidget, items):
sortingEnabled = tableWidget.isSortingEnabled()
if sortingEnabled:
tableWidget.setSortingEnabled(False)
Expand All @@ -1117,8 +1126,9 @@ def addMessageListItem(self, tableWidget, items):
if sortingEnabled:
tableWidget.setSortingEnabled(True)

@staticmethod
def addMessageListItemSent(
self, tableWidget, toAddress, fromAddress, subject,
tableWidget, toAddress, fromAddress, subject,
status, ackdata, lastactiontime
):
acct = accountClass(fromAddress) or BMAccount(fromAddress)
Expand Down Expand Up @@ -1191,12 +1201,13 @@ def addMessageListItemSent(
str(subject), text_type(acct.subject, 'utf-8', 'replace')),
MessageList_TimeWidget(
statusText, False, lastactiontime, ackdata)]
self.addMessageListItem(tableWidget, items)
MyForm.addMessageListItem(tableWidget, items)

return acct

@staticmethod
def addMessageListItemInbox(
self, tableWidget, toAddress, fromAddress, subject,
tableWidget, toAddress, fromAddress, subject,
msgid, received, read
):
if toAddress == str_broadcast_subscribers:
Expand All @@ -1218,12 +1229,12 @@ def addMessageListItemInbox(
MessageList_TimeWidget(
l10n.formatTimestamp(received), not read, received, msgid)
]
self.addMessageListItem(tableWidget, items)
MyForm.addMessageListItem(tableWidget, items)

return acct

# Load Sent items from database
def loadSent(self, tableWidget, account, where="", what=""):
"""Load Sent items from database"""
if tableWidget == self.ui.tableWidgetInboxSubscriptions:
tableWidget.setColumnHidden(0, True)
tableWidget.setColumnHidden(1, False)
Expand All @@ -1241,7 +1252,7 @@ def loadSent(self, tableWidget, account, where="", what=""):
xAddress, account, "sent", where, what, False)

for row in queryreturn:
self.addMessageListItemSent(tableWidget, *row)
MyForm.addMessageListItemSent(tableWidget, *row)

tableWidget.horizontalHeader().setSortIndicator(
3, QtCore.Qt.DescendingOrder)
Expand All @@ -1250,11 +1261,11 @@ def loadSent(self, tableWidget, account, where="", what=""):
_translate("MainWindow", "Sent"))
tableWidget.setUpdatesEnabled(True)

# Load messages from database file
def loadMessagelist(
self, tableWidget, account, folder="inbox", where="", what="",
unreadOnly=False
):
"""Load messages from database file"""
tableWidget.setUpdatesEnabled(False)
tableWidget.setSortingEnabled(False)
tableWidget.setRowCount(0)
Expand Down Expand Up @@ -1282,7 +1293,7 @@ def loadMessagelist(

for row in queryreturn:
toAddress, fromAddress, subject, _, msgid, received, read = row
self.addMessageListItemInbox(
MyForm.addMessageListItemInbox(
tableWidget, toAddress, fromAddress, subject,
msgid, received, read)

Expand Down Expand Up @@ -1359,8 +1370,9 @@ def appIndicatorInit(self, _app):
self.tray.setContextMenu(m)
self.tray.show()

# returns the number of unread messages and subscriptions
def getUnread(self):
@staticmethod
def getUnread():
"""returns the number of unread messages and subscriptions"""
counters = [0, 0]

queryreturn = sqlQuery('''
Expand Down Expand Up @@ -1443,8 +1455,9 @@ def _choose_ext(basename):

self._player(soundFilename)

# Adapters and converters for QT <-> sqlite
def sqlInit(self):
@staticmethod
def sqlInit():
"""Adapters and converters for QT <-> sqlite"""
register_adapter(QtCore.QByteArray, str)

def indicatorInit(self):
Expand Down Expand Up @@ -1813,15 +1826,16 @@ def setStatusIcon(self, color):
def initTrayIcon(self, iconFileName, _app):
self.currentTrayIconFileName = iconFileName
self.tray = QtGui.QSystemTrayIcon(
self.calcTrayIcon(iconFileName,
self.findInboxUnreadCount()),
MyForm.calcTrayIcon(iconFileName,
self.findInboxUnreadCount()),
_app)

def setTrayIconFile(self, iconFileName):
self.currentTrayIconFileName = iconFileName
self.drawTrayIcon(iconFileName, self.findInboxUnreadCount())

def calcTrayIcon(self, iconFileName, inboxUnreadCount):
@staticmethod
def calcTrayIcon(iconFileName, inboxUnreadCount):
pixmap = QtGui.QPixmap(":/newPrefix/images/" + iconFileName)
if inboxUnreadCount > 0:
# choose font and calculate font parameters
Expand Down Expand Up @@ -1854,7 +1868,8 @@ def calcTrayIcon(self, iconFileName, inboxUnreadCount):
return QtGui.QIcon(pixmap)

def drawTrayIcon(self, iconFileName, inboxUnreadCount):
self.tray.setIcon(self.calcTrayIcon(iconFileName, inboxUnreadCount))
self.tray.setIcon(MyForm.calcTrayIcon(iconFileName,
inboxUnreadCount))

def changedInboxUnread(self, row=None):
self.drawTrayIcon(
Expand Down Expand Up @@ -1985,14 +2000,14 @@ def rerenderMessagelistToLabels(self):
def rerenderAddressBook(self):
def addRow(address, label, row_type):
self.ui.tableWidgetAddressBook.insertRow(0)
newItem = Ui_AddressBookWidgetItemLabel(address,
text_type(label, 'utf-8'),
row_type)
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem = Ui_AddressBookWidgetItemAddress(address,
text_type(label, 'utf-8'),
row_type)
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
newItemL = Ui_AddressBookWidgetItemLabel(address,
text_type(label, 'utf-8'),
row_type)
self.ui.tableWidgetAddressBook.setItem(0, 0, newItemL)
newItemA = Ui_AddressBookWidgetItemAddress(address,
text_type(label, 'utf-8'),
row_type)
self.ui.tableWidgetAddressBook.setItem(0, 1, newItemA)

oldRows = {}
for i in range(self.ui.tableWidgetAddressBook.rowCount()):
Expand Down Expand Up @@ -2964,8 +2979,9 @@ def on_action_InboxMarkUnread(self):
# tableWidget.clearSelection() manages to mark the message
# as read again.

# Format predefined text on message reply.
def quoted_text(self, message):
@staticmethod
def quoted_text(message):
"""Format predefined text on message reply."""
if not config.safeGetBoolean('bitmessagesettings', 'replybelow'):
return '\n\n------------------------------------------------------\n' + message

Expand Down Expand Up @@ -3112,7 +3128,7 @@ def on_action_InboxReply(self, reply_type=None):

self.setSendFromComboBox(toAddressAtCurrentInboxRow)

quotedText = self.quoted_text(
quotedText = MyForm.quoted_text(
text_type(messageAtCurrentInboxRow, 'utf-8', 'replace'))
widget['message'].setPlainText(quotedText)
if acct.subject[0:3] in ('Re:', 'RE:'):
Expand Down Expand Up @@ -3978,12 +3994,12 @@ def on_context_menuInbox(self, point):
popMenuInbox.addAction(self.actionReply)
popMenuInbox.addAction(self.actionAddSenderToAddressBook)
# pylint: disable=no-member
self.actionClipboardMessagelist = self.ui.inboxContextMenuToolbar.addAction(
actionClipboardMessagelist = self.ui.inboxContextMenuToolbar.addAction(
_translate("MainWindow", "Copy subject to clipboard")
if tableWidget.currentColumn() == 2 else
_translate("MainWindow", "Copy address to clipboard"),
self.on_action_ClipboardMessagelist)
popMenuInbox.addAction(self.actionClipboardMessagelist)
popMenuInbox.addAction(actionClipboardMessagelist)
# pylint: disable=no-member
self._contact_selected = tableWidget.item(currentRow, 1)
# preloaded gui.menu plugins with prefix 'address'
Expand Down Expand Up @@ -4229,7 +4245,7 @@ class BitmessageQtApplication(QtGui.QApplication):
"""

# Unique identifier for this application
uuid = '6ec0149b-96e1-4be1-93ab-1465fb3ebf7c'
UUID = '6ec0149b-96e1-4be1-93ab-1465fb3ebf7c'

@staticmethod
def get_windowstyle():
Expand All @@ -4241,7 +4257,6 @@ def get_windowstyle():

def __init__(self, *argv):
super(BitmessageQtApplication, self).__init__(*argv)
id = BitmessageQtApplication.uuid

QtCore.QCoreApplication.setOrganizationName("PyBitmessage")
QtCore.QCoreApplication.setOrganizationDomain("bitmessage.org")
Expand All @@ -4259,14 +4274,14 @@ def __init__(self, *argv):
self.is_running = False

socket = QLocalSocket()
socket.connectToServer(id)
socket.connectToServer(self.UUID)
self.is_running = socket.waitForConnected()

# Cleanup past crashed servers
if not self.is_running:
if socket.error() == QLocalSocket.ConnectionRefusedError:
socket.disconnectFromServer()
QLocalServer.removeServer(id)
QLocalServer.removeServer(self.UUID)

socket.abort()

Expand All @@ -4278,35 +4293,36 @@ def __init__(self, *argv):
# Nope, create a local server with this id and assign on_new_connection
# for whenever a second instance tries to run focus the application.
self.server = QLocalServer()
self.server.listen(id)
self.server.newConnection.connect(self.on_new_connection)
self.server.listen(self.UUID)
self.server.newConnection.connect(MyForm.on_new_connection)

self.setStyleSheet("QStatusBar::item { border: 0px solid black }")

def __del__(self):
if self.server:
self.server.close()

def on_new_connection(self):
@staticmethod
def on_new_connection():
if myapp:
myapp.appIndicatorShow()


def init():
global app
global app # pylint: disable=global-statement
if not app:
app = BitmessageQtApplication(sys.argv)
return app


def run():
global myapp
app = init()
myapp = MyForm()
global myapp # pylint: disable=global-statement
_app = init()
myapp = MyForm() # pylint: disable=redefined-outer-name

myapp.appIndicatorInit(app)

if myapp._firstrun:
if myapp._firstrun: # pylint: disable=protected-access
myapp.showConnectDialog() # ask the user if we may connect

# only show after wizards and connect dialogs have completed
Expand All @@ -4315,4 +4331,4 @@ def run():
QtCore.QTimer.singleShot(
30000, lambda: myapp.setStatusIcon(state.statusIconColor))

app.exec_()
_app.exec_()
16 changes: 8 additions & 8 deletions src/bitmessageqt/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ def getSortedSubscriptions(count=False):
return ret


def accountClass(address):
def accountClass(address): # pylint: disable=too-many-return-statements
"""Return a BMAccount for the address"""
if not config.has_section(address):
# .. todo:: This BROADCAST section makes no sense
if address == str_broadcast_subscribers:
subscription = BroadcastAccount(address)
if subscription.type != AccountMixin.BROADCAST:
subscriptionB = BroadcastAccount(address)
if subscriptionB.type != AccountMixin.BROADCAST:
return None
else:
subscription = SubscriptionAccount(address)
if subscription.type != AccountMixin.SUBSCRIPTION:
# e.g. deleted chan
return NoAccount(address)
return subscriptionB
subscription = SubscriptionAccount(address)
if subscription.type != AccountMixin.SUBSCRIPTION:
# e.g. deleted chan
return NoAccount(address)
return subscription
try:
gateway = config.get(address, "gateway")
Expand Down
1 change: 1 addition & 0 deletions src/bitmessageqt/bitmessage_icons_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
# WARNING! All changes made in this file will be lost!

# pylint: disable=too-many-lines
from PyQt4 import QtCore # pylint: disable=import-error

qt_resource_data = "\
Expand Down
1 change: 1 addition & 0 deletions src/bitmessageqt/foldertree.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ def setLabel(self, label=None):
AccountMixin.NORMAL,
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
try:
# pylint: disable=redefined-variable-type
newLabel = unicode(
config.get(self.address, 'label'),
'utf-8', 'ignore')
Expand Down
Loading
Loading