Compare commits

...

2 Commits

Author SHA1 Message Date
Omkar Pakki
deebf2fdd2 Flake changes done 2019-06-27 22:37:11 +05:30
Omkar Pakki
693891672b Basic code clean up 2019-06-26 23:36:36 +05:30
11 changed files with 559 additions and 422 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#! /usr/bin/env python2
"""
Check dependendies and give recommendations about how to satisfy them
@ -12,7 +12,9 @@ Limitations:
import os
import sys
from distutils.errors import CompileError
try:
from setuptools.dist import Distribution
from setuptools.extension import Extension
@ -25,8 +27,7 @@ except ImportError:
EXTRAS_REQUIRE = {}
from importlib import import_module
from src.depends import detectOS, PACKAGES, PACKAGE_MANAGER
from src.depends import detect_os, PACKAGES, PACKAGE_MANAGER
COMPILING = {
@ -72,15 +73,15 @@ def prereqToPackages():
if not detectPrereqs():
return
print("%s %s" % (
PACKAGE_MANAGER[detectOS()], " ".join(
PACKAGES[x][detectOS()] for x in detectPrereqs())))
PACKAGE_MANAGER[detect_os()], " ".join(
PACKAGES[x][detect_os()] for x in detectPrereqs())))
def compilerToPackages():
if not detectOS() in COMPILING:
if not detect_os() in COMPILING:
return
print("%s %s" % (
PACKAGE_MANAGER[detectOS.result], COMPILING[detectOS.result]))
PACKAGE_MANAGER[detect_os.result], COMPILING[detect_os.result]))
def testCompiler():
@ -112,11 +113,11 @@ def testCompiler():
prereqs = detectPrereqs()
compiler = testCompiler()
if (not compiler or prereqs) and detectOS() in PACKAGE_MANAGER:
if (not compiler or prereqs) and detect_os() in PACKAGE_MANAGER:
print(
"It looks like you're using %s. "
"It is highly recommended to use the package manager\n"
"to install the missing dependencies." % detectOS.result)
"to install the missing dependencies." % detect_os.result)
if not compiler:
print(
@ -134,7 +135,7 @@ if prereqs:
print(PACKAGES[package].get('description'))
# Install the system dependencies of optional extras_require components
OPSYS = detectOS()
OPSYS = detect_os()
CMD = PACKAGE_MANAGER[OPSYS] if OPSYS in PACKAGE_MANAGER else 'UNKNOWN_INSTALLER'
for lhs, rhs in EXTRAS_REQUIRE.items():
if OPSYS is None:

View File

@ -95,11 +95,11 @@ if __name__ == "__main__":
long_description=README,
license='MIT',
# TODO: add author info
#author='',
#author_email='',
# author='',
# author_email='',
url='https://bitmessage.org',
# TODO: add keywords
#keywords='',
# keywords='',
install_requires=installRequires,
tests_require=requirements,
extras_require=EXTRAS_REQUIRE,

View File

@ -8,38 +8,38 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
what = None
if folder == "sent":
sqlStatementBase = '''
sql_statement_base = '''
SELECT toaddress, fromaddress, subject, status, ackdata, lastactiontime
FROM sent '''
else:
sqlStatementBase = '''SELECT folder, msgid, toaddress, fromaddress, subject, received, read
sql_statement_base = '''SELECT folder, msgid, toaddress, fromaddress, subject, received, read
FROM inbox '''
sqlStatementParts = []
sql_statement_parts = []
sqlArguments = []
if account is not None:
if xAddress == 'both':
sqlStatementParts.append("(fromaddress = ? OR toaddress = ?)")
sql_statement_parts.append("(fromaddress = ? OR toaddress = ?)")
sqlArguments.append(account)
sqlArguments.append(account)
else:
sqlStatementParts.append(xAddress + " = ? ")
sql_statement_parts.append(xAddress + " = ? ")
sqlArguments.append(account)
if folder is not None:
if folder == "new":
folder = "inbox"
unreadOnly = True
sqlStatementParts.append("folder = ? ")
sql_statement_parts.append("folder = ? ")
sqlArguments.append(folder)
else:
sqlStatementParts.append("folder != ?")
sql_statement_parts.append("folder != ?")
sqlArguments.append("trash")
if what is not None:
sqlStatementParts.append("%s LIKE ?" % (where))
sql_statement_parts.append("%s LIKE ?" % (where))
sqlArguments.append(what)
if unreadOnly:
sqlStatementParts.append("read = 0")
if len(sqlStatementParts) > 0:
sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts)
sql_statement_parts.append("read = 0")
if len(sql_statement_parts) > 0:
sql_statement_base += "WHERE " + " AND ".join(sql_statement_parts)
if folder == "sent":
sqlStatementBase += " ORDER BY lastactiontime"
return sqlQuery(sqlStatementBase, sqlArguments)
sql_statement_base += " ORDER BY lastactiontime"
return sqlQuery(sql_statement_base, sqlArguments)

View File

@ -1,9 +1,9 @@
import kivy_helper_search
import os
import queues
import shutdown
import state
import time
import kivy_helper_search
from kivy.app import App
from kivy.lang import Builder
@ -14,7 +14,6 @@ from kivy.properties import ObjectProperty, StringProperty, ListProperty
from kivy.uix.screenmanager import Screen
from kivy.uix.textinput import TextInput
from kivymd.theming import ThemeManager
from kivymd.toolbar import Toolbar
from bmconfigparser import BMConfigParser
from helper_ackPayload import genAckPayload
from addresses import decodeAddress, addBMIfNotPresent

View File

@ -11,51 +11,53 @@ import sys
import textwrap
import threading
import time
import defaults
import debug
import dialogs
import helper_search
import knownnodes
import l10n
import namecoin
import openclpow
import paths
import settingsmixin
import shared
import shutdown
import sound
import state
import support
import queues
from datetime import datetime, timedelta
from sqlite3 import register_adapter
from PyQt4 import QtCore, QtGui
from PyQt4.QtNetwork import QLocalSocket, QLocalServer
from debug import logger
from tr import _translate
from addresses import decodeAddress, addBMIfNotPresent
import shared
from bitmessageui import Ui_MainWindow
from bmconfigparser import BMConfigParser
import defaults
import namecoin
from messageview import MessageView
from migrationwizard import Ui_MigrationWizard
from foldertree import (
AccountMixin, Ui_FolderWidget, Ui_AddressWidget, Ui_SubscriptionWidget,
MessageList_AddressWidget, MessageList_SubjectWidget,
Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress)
from settings import Ui_settingsDialog
import settingsmixin
import support
import debug
from helper_ackPayload import genAckPayload
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
import helper_search
import l10n
import openclpow
from utils import str_broadcast_subscribers, avatarize
from account import (
getSortedAccounts, getSortedSubscriptions, accountClass, BMAccount,
GatewayAccount, MailchuckAccount, AccountColor)
import dialogs
from bitmessageui import Ui_MainWindow
from bmconfigparser import BMConfigParser
from debug import logger
from foldertree import (
AccountMixin, UiFolderWidget, UiAddressWidget, UiSubscriptionWidget,
MessageListAddressWidget, MessageListSubjectWidget,
UiAddressBookWidgetItemLabel, UiAddressBookWidgetItemAddress)
from helper_ackPayload import genAckPayload
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
from messageview import MessageView
from migrationwizard import Ui_MigrationWizard
from network.stats import pendingDownload, pendingUpload
from uisignaler import UISignaler
import knownnodes
import paths
from proofofwork import getPowType
import queues
import shutdown
import state
from statusbar import BMStatusBar
from network.asyncore_pollchoose import set_rates
import sound
from proofofwork import getPowType
from settings import Ui_settingsDialog
from statusbar import BMStatusBar
from tr import _translate
from uisignaler import UISignaler
from utils import str_broadcast_subscribers, avatarize
try:
@ -84,9 +86,10 @@ def change_translation(newlocale):
qsystranslator = QtCore.QTranslator()
if paths.frozen:
translationpath = os.path.join (paths.codePath(), 'translations', 'qt_' + newlocale)
translationpath = os.path.join(paths.codePath(), 'translations', 'qt_' + newlocale)
else:
translationpath = os.path.join (str(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)), 'qt_' + newlocale)
translationpath = os.path.join(
str(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)), 'qt_' + newlocale)
qsystranslator.load(translationpath)
QtGui.QApplication.installTranslator(qsystranslator)
@ -108,7 +111,7 @@ def change_translation(newlocale):
# TODO: rewrite
def powQueueSize():
def pow_queue_size():
"""Returns the size of queues.workerQueue including current unfinished work"""
queue_len = queues.workerQueue.qsize()
for thread in threading.enumerate():
@ -404,7 +407,7 @@ class MyForm(settingsmixin.SMainWindow):
def rerenderTabTreeSubscriptions(self):
treeWidget = self.ui.treeWidgetSubscriptions
folders = Ui_FolderWidget.folderWeight.keys()
folders = UiFolderWidget.folderWeight.keys()
folders.remove("new")
# sort ascending when creating
@ -440,7 +443,7 @@ class MyForm(settingsmixin.SMainWindow):
while j < widget.childCount():
subwidget = widget.child(j)
try:
subwidget.setUnreadCount(db[toAddress][subwidget.folderName]['count'])
subwidget.set_unread_count(db[toAddress][subwidget.folderName]['count'])
unread += db[toAddress][subwidget.folderName]['count']
db[toAddress].pop(subwidget.folderName, None)
except:
@ -454,9 +457,9 @@ class MyForm(settingsmixin.SMainWindow):
j = 0
for f, c in db[toAddress].iteritems():
try:
subwidget = Ui_FolderWidget(widget, j, toAddress, f, c['count'])
subwidget = UiFolderWidget(widget, j, toAddress, f, c['count'])
except KeyError:
subwidget = Ui_FolderWidget(widget, j, toAddress, f, 0)
subwidget = UiFolderWidget(widget, j, toAddress, f, 0)
j += 1
widget.setUnreadCount(unread)
db.pop(toAddress, None)
@ -464,17 +467,19 @@ class MyForm(settingsmixin.SMainWindow):
i = 0
for toAddress in db:
widget = Ui_SubscriptionWidget(treeWidget, i, toAddress, db[toAddress]["inbox"]['count'], db[toAddress]["inbox"]['label'], db[toAddress]["inbox"]['enabled'])
widget = UiSubscriptionWidget(
treeWidget, i, toAddress, db[toAddress]["inbox"]['count'],
db[toAddress]["inbox"]['label'], db[toAddress]["inbox"]['enabled'])
j = 0
unread = 0
for folder in folders:
try:
subwidget = Ui_FolderWidget(widget, j, toAddress, folder, db[toAddress][folder]['count'])
subwidget = UiFolderWidget(widget, j, toAddress, folder, db[toAddress][folder]['count'])
unread += db[toAddress][folder]['count']
except KeyError:
subwidget = Ui_FolderWidget(widget, j, toAddress, folder, 0)
subwidget = UiFolderWidget(widget, j, toAddress, folder, 0)
j += 1
widget.setUnreadCount(unread)
widget.set_unread_count(unread)
i += 1
treeWidget.setSortingEnabled(True)
@ -491,7 +496,7 @@ class MyForm(settingsmixin.SMainWindow):
treeWidget = self.ui.treeWidgetYourIdentities
elif tab == 'chan':
treeWidget = self.ui.treeWidgetChans
folders = Ui_FolderWidget.folderWeight.keys()
folders = UiFolderWidget.folderWeight.keys()
# sort ascending when creating
if treeWidget.topLevelItemCount() == 0:
@ -524,7 +529,9 @@ class MyForm(settingsmixin.SMainWindow):
# get number of (unread) messages
total = 0
queryreturn = sqlQuery('SELECT toaddress, folder, count(msgid) as cnt FROM inbox WHERE read = 0 GROUP BY toaddress, folder')
queryreturn = sqlQuery(
'SELECT toaddress, folder, count(msgid) as cnt FROM inbox WHERE read = 0 GROUP BY toaddress, folder'
)
for row in queryreturn:
toaddress, folder, cnt = row
total += cnt
@ -559,7 +566,7 @@ class MyForm(settingsmixin.SMainWindow):
while j < widget.childCount():
subwidget = widget.child(j)
try:
subwidget.setUnreadCount(db[toAddress][subwidget.folderName])
subwidget.set_unread_count(db[toAddress][subwidget.folderName])
if subwidget.folderName not in ["new", "trash", "sent"]:
unread += db[toAddress][subwidget.folderName]
db[toAddress].pop(subwidget.folderName, None)
@ -575,7 +582,7 @@ class MyForm(settingsmixin.SMainWindow):
for f, c in db[toAddress].iteritems():
if toAddress is not None and tab == 'messages' and folder == "new":
continue
subwidget = Ui_FolderWidget(widget, j, toAddress, f, c)
subwidget = UiFolderWidget(widget, j, toAddress, f, c)
if subwidget.folderName not in ["new", "trash", "sent"]:
unread += c
j += 1
@ -585,17 +592,17 @@ class MyForm(settingsmixin.SMainWindow):
i = 0
for toAddress in db:
widget = Ui_AddressWidget(treeWidget, i, toAddress, db[toAddress]["inbox"], enabled[toAddress])
widget = UiAddressWidget(treeWidget, i, toAddress, db[toAddress]["inbox"], enabled[toAddress])
j = 0
unread = 0
for folder in folders:
if toAddress is not None and tab == 'messages' and folder == "new":
continue
subwidget = Ui_FolderWidget(widget, j, toAddress, folder, db[toAddress][folder])
subwidget = UiFolderWidget(widget, j, toAddress, folder, db[toAddress][folder])
if subwidget.folderName not in ["new", "trash", "sent"]:
unread += db[toAddress][folder]
j += 1
widget.setUnreadCount(unread)
widget.set_unread_count(unread)
i += 1
treeWidget.setSortingEnabled(True)
@ -612,7 +619,8 @@ class MyForm(settingsmixin.SMainWindow):
addressInKeysFile)
if addressVersionNumber == 1:
displayMsg = _translate(
"MainWindow", "One of your addresses, %1, is an old version 1 address. Version 1 addresses are no longer supported. "
"MainWindow", "One of your addresses, %1, is an old version 1 address. "
"Version 1 addresses are no longer supported. "
+ "May we delete it now?").arg(addressInKeysFile)
reply = QtGui.QMessageBox.question(
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
@ -626,8 +634,9 @@ class MyForm(settingsmixin.SMainWindow):
# Auto-startup for Windows
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
self.settings = QtCore.QSettings(RUN_PATH, QtCore.QSettings.NativeFormat)
self.settings.remove(
"PyBitmessage") # In case the user moves the program and the registry entry is no longer valid, this will delete the old registry entry.
self.settings.remove("PyBitmessage")
# In case the user moves the program and the registry entry is no longer valid,
# this will delete the old registry entry.
if BMConfigParser().getboolean('bitmessagesettings', 'startonlogon'):
self.settings.setValue("PyBitmessage", sys.argv[0])
elif 'darwin' in sys.platform:
@ -693,7 +702,7 @@ class MyForm(settingsmixin.SMainWindow):
"itemChanged(QTableWidgetItem *)"), self.tableWidgetAddressBookItemChanged)
# This is necessary for the completer to work if multiple recipients
QtCore.QObject.connect(self.ui.lineEditTo, QtCore.SIGNAL(
"cursorPositionChanged(int, int)"), self.ui.lineEditTo.completer().onCursorPositionChanged)
"cursorPositionChanged(int, int)"), self.ui.lineEditTo.completer().on_cursor_position_changed)
# show messages from message list
QtCore.QObject.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL(
@ -758,9 +767,11 @@ class MyForm(settingsmixin.SMainWindow):
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewInboxMessage)
"displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
self.displayNewInboxMessage)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewSentMessage)
"displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"
), self.displayNewSentMessage)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"setStatusIcon(PyQt_PyObject)"), self.setStatusIcon)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
@ -838,7 +849,8 @@ class MyForm(settingsmixin.SMainWindow):
font.setBold(True)
else:
numberOfDays = int(round(TTL / (24*60*60)))
self.ui.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%n day(s)", None, QtCore.QCoreApplication.CodecForTr, numberOfDays))
self.ui.labelHumanFriendlyTTLDescription.setText(_translate(
"MainWindow", "%n day(s)", None, QtCore.QCoreApplication.CodecForTr, numberOfDays))
font.setBold(False)
self.ui.labelHumanFriendlyTTLDescription.setStyleSheet(stylesheet)
self.ui.labelHumanFriendlyTTLDescription.setFont(font)
@ -957,7 +969,7 @@ class MyForm(settingsmixin.SMainWindow):
font.setBold(not status)
widget.item(row, 3).setFont(font)
for col in (0, 1, 2):
widget.item(row, col).setUnread(not status)
widget.item(row, col).set_unread(not status)
try:
related.item(rrow, 3).setFont(font)
@ -965,7 +977,7 @@ class MyForm(settingsmixin.SMainWindow):
pass
else:
for col in (0, 1, 2):
related.item(rrow, col).setUnread(not status)
related.item(rrow, col).set_unread(not status)
# Here we need to update unread count for:
# - all widgets if there is no args
@ -1023,7 +1035,7 @@ class MyForm(settingsmixin.SMainWindow):
except KeyError:
newCount = 0
if newCount != addressItem.unreadCount:
addressItem.setUnreadCount(newCount)
addressItem.set_unread_count(newCount)
for j in range(addressItem.childCount()):
folderItem = addressItem.child(j)
folderName = folderItem.folderName
@ -1043,7 +1055,7 @@ class MyForm(settingsmixin.SMainWindow):
except KeyError:
newCount = 0
if newCount != folderItem.unreadCount:
folderItem.setUnreadCount(newCount)
folderItem.set_unread_count(newCount)
def addMessageListItem(self, tableWidget, items):
sortingEnabled = tableWidget.isSortingEnabled()
@ -1062,9 +1074,9 @@ class MyForm(settingsmixin.SMainWindow):
acct.parseMessage(toAddress, fromAddress, subject, "")
items = []
MessageList_AddressWidget(items, str(toAddress), unicode(acct.toLabel, 'utf-8'))
MessageList_AddressWidget(items, str(fromAddress), unicode(acct.fromLabel, 'utf-8'))
MessageList_SubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8', 'replace'))
MessageListAddressWidget(items, str(toAddress), unicode(acct.toLabel, 'utf-8'))
MessageListAddressWidget(items, str(fromAddress), unicode(acct.fromLabel, 'utf-8'))
MessageListSubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8', 'replace'))
if status == 'awaitingpubkey':
statusText = _translate(
@ -1097,10 +1109,14 @@ class MyForm(settingsmixin.SMainWindow):
statusText = _translate("MainWindow", "Broadcast on %1").arg(
l10n.formatTimestamp(lastactiontime))
elif status == 'toodifficult':
statusText = _translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg(
statusText = _translate(
"MainWindow",
"Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg(
l10n.formatTimestamp(lastactiontime))
elif status == 'badkey':
statusText = _translate("MainWindow", "Problem: The recipient\'s encryption key is no good. Could not encrypt message. %1").arg(
statusText = _translate(
"MainWindow",
"Problem: The recipient\'s encryption key is no good. Could not encrypt message. %1").arg(
l10n.formatTimestamp(lastactiontime))
elif status == 'forcepow':
statusText = _translate(
@ -1133,11 +1149,11 @@ class MyForm(settingsmixin.SMainWindow):
items = []
#to
MessageList_AddressWidget(items, toAddress, unicode(acct.toLabel, 'utf-8'), not read)
MessageListAddressWidget(items, toAddress, unicode(acct.toLabel, 'utf-8'), not read)
# from
MessageList_AddressWidget(items, fromAddress, unicode(acct.fromLabel, 'utf-8'), not read)
MessageListAddressWidget(items, fromAddress, unicode(acct.fromLabel, 'utf-8'), not read)
# subject
MessageList_SubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8', 'replace'), not read)
MessageListSubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8', 'replace'), not read)
# time received
time_item = myTableWidgetItem(l10n.formatTimestamp(received))
time_item.setToolTip(l10n.formatTimestamp(received))
@ -1492,35 +1508,53 @@ class MyForm(settingsmixin.SMainWindow):
# the same directory as this program. It is important that you
# back up this file.', QMessageBox.Ok)
reply = QtGui.QMessageBox.information(self, 'keys.dat?', _translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file."), QtGui.QMessageBox.Ok)
"MainWindow",
"You may manage your keys by editing the keys.dat file stored in the same "
"directory as this program. It is important that you back up this file."), QtGui.QMessageBox.Ok)
else:
QtGui.QMessageBox.information(self, 'keys.dat?', _translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file.").arg(state.appdata), QtGui.QMessageBox.Ok)
"MainWindow",
"You may manage your keys by editing the keys.dat file stored in\n %1 \n"
"It is important that you back up this file.").arg(state.appdata), QtGui.QMessageBox.Ok)
elif sys.platform == 'win32' or sys.platform == 'win64':
if state.appdata == '':
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
"MainWindow",
"You may manage your keys by editing the keys.dat file stored in the same directory as this program."
" It is important that you back up this file. Would you like to open the file now? "
"(Be sure to close Bitmessage before making any changes.)"),
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
else:
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(state.appdata), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
"MainWindow",
"You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you "
"back up this file. Would you like to open the file now? "
"(Be sure to close Bitmessage before making any changes.)").arg(state.appdata),
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
shared.openKeysFile()
# menu button 'delete all treshed messages'
def click_actionDeleteAllTrashedMessages(self):
if QtGui.QMessageBox.question(self, _translate("MainWindow", "Delete trash?"), _translate("MainWindow", "Are you sure you want to delete all trashed messages?"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
if QtGui.QMessageBox.question(
self, _translate("MainWindow", "Delete trash?"),
_translate("MainWindow", "Are you sure you want to delete all trashed messages?"),
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
return
sqlStoredProcedure('deleteandvacuume')
self.rerenderTabTreeMessages()
self.rerenderTabTreeSubscriptions()
self.rerenderTabTreeChans()
if self.getCurrentFolder(self.ui.treeWidgetYourIdentities) == "trash":
self.loadMessagelist(self.ui.tableWidgetInbox, self.getCurrentAccount(self.ui.treeWidgetYourIdentities), "trash")
self.loadMessagelist(self.ui.tableWidgetInbox,
self.getCurrentAccount(self.ui.treeWidgetYourIdentities), "trash")
elif self.getCurrentFolder(self.ui.treeWidgetSubscriptions) == "trash":
self.loadMessagelist(self.ui.tableWidgetInboxSubscriptions, self.getCurrentAccount(self.ui.treeWidgetSubscriptions), "trash")
self.loadMessagelist(self.ui.tableWidgetInboxSubscriptions,
self.getCurrentAccount(self.ui.treeWidgetSubscriptions), "trash")
elif self.getCurrentFolder(self.ui.treeWidgetChans) == "trash":
self.loadMessagelist(self.ui.tableWidgetInboxChans, self.getCurrentAccount(self.ui.treeWidgetChans), "trash")
self.loadMessagelist(self.ui.tableWidgetInboxChans,
self.getCurrentAccount(self.ui.treeWidgetChans), "trash")
# menu button 'regenerate deterministic addresses'
def click_actionRegenerateDeterministicAddresses(self):
@ -1650,7 +1684,9 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "Not Connected"))
self.setTrayIconFile("can-icon-24px-red.png")
if color == 'yellow':
if self.statusbar.currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.':
if self.statusbar.currentMessage() == 'Warning: You are currently not connected. ' \
'Bitmessage will do the work necessary to send the ' \
'message but it won\'t send until you connect.':
self.statusbar.clearMessage()
self.pushButtonStatusIcon.setIcon(
QtGui.QIcon(":/newPrefix/images/yellowicon.png"))
@ -1668,7 +1704,9 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "Connected"))
self.setTrayIconFile("can-icon-24px-yellow.png")
if color == 'green':
if self.statusbar.currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.':
if self.statusbar.currentMessage() == 'Warning: You are currently not connected. ' \
'Bitmessage will do the work necessary to send the ' \
'message but it won\'t send until you connect.':
self.statusbar.clearMessage()
self.pushButtonStatusIcon.setIcon(
QtGui.QIcon(":/newPrefix/images/greenicon.png"))
@ -1751,7 +1789,8 @@ class MyForm(settingsmixin.SMainWindow):
treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent":
continue
if treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] and self.getCurrentAccount(treeWidget) != toAddress:
if treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] \
and self.getCurrentAccount(treeWidget) != toAddress:
continue
for i in range(sent.rowCount()):
@ -1760,7 +1799,9 @@ class MyForm(settingsmixin.SMainWindow):
sent.item(i, 3).setToolTip(textToDisplay)
try:
newlinePosition = textToDisplay.indexOf('\n')
except: # If someone misses adding a "_translate" to a string before passing it to this function, this function won't receive a qstring which will cause an exception.
except:
# If someone misses adding a "_translate" to a string before passing it to this function,
# this function won't receive a qstring which will cause an exception.
newlinePosition = 0
if newlinePosition > 1:
sent.item(i, 3).setText(
@ -1786,7 +1827,9 @@ class MyForm(settingsmixin.SMainWindow):
sent.item(i, 3).setToolTip(textToDisplay)
try:
newlinePosition = textToDisplay.indexOf('\n')
except: # If someone misses adding a "_translate" to a string before passing it to this function, this function won't receive a qstring which will cause an exception.
except:
# If someone misses adding a "_translate" to a string before passing it to this function,
# this function won't receive a qstring which will cause an exception.
newlinePosition = 0
if newlinePosition > 1:
sent.item(i, 3).setText(
@ -1833,21 +1876,23 @@ class MyForm(settingsmixin.SMainWindow):
os._exit(0)
def rerenderMessagelistFromLabels(self):
for messagelist in (self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans, self.ui.tableWidgetInboxSubscriptions):
for messagelist in (self.ui.tableWidgetInbox,
self.ui.tableWidgetInboxChans, self.ui.tableWidgetInboxSubscriptions):
for i in range(messagelist.rowCount()):
messagelist.item(i, 1).setLabel()
messagelist.item(i, 1).set_label()
def rerenderMessagelistToLabels(self):
for messagelist in (self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans, self.ui.tableWidgetInboxSubscriptions):
for messagelist in (self.ui.tableWidgetInbox,
self.ui.tableWidgetInboxChans, self.ui.tableWidgetInboxSubscriptions):
for i in range(messagelist.rowCount()):
messagelist.item(i, 0).setLabel()
messagelist.item(i, 0).set_label()
def rerenderAddressBook(self):
def addRow (address, label, type):
self.ui.tableWidgetAddressBook.insertRow(0)
newItem = Ui_AddressBookWidgetItemLabel(address, unicode(label, 'utf-8'), type)
newItem = UiAddressBookWidgetItemLabel(address, unicode(label, 'utf-8'), type)
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem = Ui_AddressBookWidgetItemAddress(address, unicode(label, 'utf-8'), type)
newItem = UiAddressBookWidgetItemAddress(address, unicode(label, 'utf-8'), type)
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
oldRows = {}
@ -1903,7 +1948,8 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", """The TTL, or Time-To-Live is the length of time that the network will hold the message.
The recipient must get it during this time. If your Bitmessage client does not hear an acknowledgement, it
will resend the message automatically. The longer the Time-To-Live, the
more work your computer must do to send the message. A Time-To-Live of four or five days is often appropriate."""), QtGui.QMessageBox.Ok)
more work your computer must do to send the message. A Time-To-Live of four or five days is often appropriate."""),
QtGui.QMessageBox.Ok)
def click_pushButtonClear(self):
self.ui.lineEditSubject.setText("")
@ -1959,8 +2005,9 @@ class MyForm(settingsmixin.SMainWindow):
if sendMessageToPeople: # To send a message to specific people (rather than broadcast)
toAddressesList = [s.strip()
for s in toAddresses.replace(',', ';').split(';')]
toAddressesList = list(set(
toAddressesList)) # remove duplicate addresses. If the user has one address with a BM- and the same address without the BM-, this will not catch it. They'll send the message to the person twice.
toAddressesList = list(set(toAddressesList))
# remove duplicate addresses. If the user has one address with a BM- and the same address without the BM-,
# this will not catch it. They'll send the message to the person twice.
for toAddress in toAddressesList:
if toAddress != '':
# label plus address
@ -1973,14 +2020,19 @@ class MyForm(settingsmixin.SMainWindow):
subject = acct.subject
toAddress = acct.toAddress
else:
if QtGui.QMessageBox.question(self, "Sending an email?", _translate("MainWindow",
"You are trying to send an email instead of a bitmessage. This requires registering with a gateway. Attempt to register?"),
QtGui.QMessageBox.Yes|QtGui.QMessageBox.No) != QtGui.QMessageBox.Yes:
if QtGui.QMessageBox.question(
self, "Sending an email?",
_translate("MainWindow",
"You are trying to send an email instead of a bitmessage. "
"This requires registering with a gateway. Attempt to register?"),
QtGui.QMessageBox.Yes|QtGui.QMessageBox.No) != QtGui.QMessageBox.Yes:
continue
email = acct.getLabel()
if email[-14:] != "@mailchuck.com": #attempt register
if email[-14:] != "@mailchuck.com": #attempt register
# 12 character random email address
email = ''.join(random.SystemRandom().choice(string.ascii_lowercase) for _ in range(12)) + "@mailchuck.com"
email = ''.join(
random.SystemRandom().choice(string.ascii_lowercase) for _ in range(12))
email += "@mailchuck.com"
acct = MailchuckAccount(fromAddress)
acct.register(email)
BMConfigParser().set(fromAddress, 'label', email)
@ -2071,12 +2123,18 @@ class MyForm(settingsmixin.SMainWindow):
toAddress = addBMIfNotPresent(toAddress)
if addressVersionNumber > 4 or addressVersionNumber <= 1:
QtGui.QMessageBox.about(self, _translate("MainWindow", "Address version number"), _translate(
"MainWindow", "Concerning the address %1, Bitmessage cannot understand address version numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(addressVersionNumber)))
QtGui.QMessageBox.about(self, _translate("MainWindow", "Address version number"),
_translate("MainWindow",
"Concerning the address %1, Bitmessage cannot understand address version numbers of %2."
" Perhaps upgrade Bitmessage to the latest version."
).arg(toAddress).arg(str(addressVersionNumber)))
continue
if streamNumber > 1 or streamNumber == 0:
QtGui.QMessageBox.about(self, _translate("MainWindow", "Stream number"), _translate(
"MainWindow", "Concerning the address %1, Bitmessage cannot handle stream numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(streamNumber)))
"MainWindow",
"Concerning the address %1, Bitmessage cannot handle stream numbers of %2."
" Perhaps upgrade Bitmessage to the latest version."
).arg(toAddress).arg(str(streamNumber)))
continue
self.statusbar.clearMessage()
if shared.statusIconColor == 'red':
@ -2220,8 +2278,8 @@ class MyForm(settingsmixin.SMainWindow):
def rerenderComboBoxSendFrom(self):
self.ui.comboBoxSendFrom.clear()
for addressInKeysFile in getSortedAccounts():
isEnabled = BMConfigParser().getboolean(
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
isEnabled = BMConfigParser().getboolean(addressInKeysFile, 'enabled')
# I realize that this is poor programming practice but I don't care. It's easier for others to read.
isMaillinglist = BMConfigParser().safeGetBoolean(addressInKeysFile, 'mailinglist')
if isEnabled and not isMaillinglist:
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
@ -2233,7 +2291,7 @@ class MyForm(settingsmixin.SMainWindow):
address = str(self.ui.comboBoxSendFrom.itemData(
i, QtCore.Qt.UserRole).toString())
self.ui.comboBoxSendFrom.setItemData(
i, AccountColor(address).accountColor(),
i, AccountColor(address).account_color(),
QtCore.Qt.ForegroundRole)
self.ui.comboBoxSendFrom.insertItem(0, '', '')
if(self.ui.comboBoxSendFrom.count() == 2):
@ -2244,8 +2302,8 @@ class MyForm(settingsmixin.SMainWindow):
def rerenderComboBoxSendFromBroadcast(self):
self.ui.comboBoxSendFromBroadcast.clear()
for addressInKeysFile in getSortedAccounts():
isEnabled = BMConfigParser().getboolean(
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
isEnabled = BMConfigParser().getboolean(addressInKeysFile, 'enabled')
# I realize that this is poor programming practice but I don't care. It's easier for others to read.
isChan = BMConfigParser().safeGetBoolean(addressInKeysFile, 'chan')
if isEnabled and not isChan:
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
@ -2256,7 +2314,7 @@ class MyForm(settingsmixin.SMainWindow):
address = str(self.ui.comboBoxSendFromBroadcast.itemData(
i, QtCore.Qt.UserRole).toString())
self.ui.comboBoxSendFromBroadcast.setItemData(
i, AccountColor(address).accountColor(),
i, AccountColor(address).account_color(),
QtCore.Qt.ForegroundRole)
self.ui.comboBoxSendFromBroadcast.insertItem(0, '', '')
if(self.ui.comboBoxSendFromBroadcast.count() == 2):
@ -2279,11 +2337,15 @@ class MyForm(settingsmixin.SMainWindow):
treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent":
continue
if treeWidget == self.ui.treeWidgetYourIdentities and self.getCurrentAccount(treeWidget) not in (fromAddress, None, False):
if treeWidget == self.ui.treeWidgetYourIdentities and \
self.getCurrentAccount(treeWidget) not in (fromAddress, None, False):
continue
elif treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] and self.getCurrentAccount(treeWidget) != toAddress:
elif treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] \
and self.getCurrentAccount(treeWidget) != toAddress:
continue
elif not helper_search.check_match(toAddress, fromAddress, subject, message, self.getCurrentSearchOption(tab), self.getCurrentSearchLine(tab)):
elif not helper_search.check_match(
toAddress, fromAddress, subject, message, self.getCurrentSearchOption(tab),
self.getCurrentSearchLine(tab)):
continue
self.addMessageListItemSent(sent, toAddress, fromAddress, subject, "msgqueued", ackdata, time.time())
@ -2303,12 +2365,20 @@ class MyForm(settingsmixin.SMainWindow):
if tab == 1:
tab = 2
tableWidget = self.widgetConvert(treeWidget)
if not helper_search.check_match(toAddress, fromAddress, subject, message, self.getCurrentSearchOption(tab), self.getCurrentSearchLine(tab)):
if not helper_search.check_match(
toAddress, fromAddress, subject, message, self.getCurrentSearchOption(tab),
self.getCurrentSearchLine(tab)):
continue
if tableWidget == inbox and self.getCurrentAccount(treeWidget) == acct.address and self.getCurrentFolder(treeWidget) in ["inbox", None]:
ret = self.addMessageListItemInbox(inbox, "inbox", inventoryHash, toAddress, fromAddress, subject, time.time(), 0)
elif treeWidget == self.ui.treeWidgetYourIdentities and self.getCurrentAccount(treeWidget) is None and self.getCurrentFolder(treeWidget) in ["inbox", "new", None]:
ret = self.addMessageListItemInbox(tableWidget, "inbox", inventoryHash, toAddress, fromAddress, subject, time.time(), 0)
if tableWidget == inbox and \
self.getCurrentAccount(treeWidget) == acct.address and \
self.getCurrentFolder(treeWidget) in ["inbox", None]:
ret = self.addMessageListItemInbox(
inbox, "inbox", inventoryHash, toAddress, fromAddress, subject, time.time(), 0)
elif treeWidget == self.ui.treeWidgetYourIdentities \
and self.getCurrentAccount(treeWidget) is None and \
self.getCurrentFolder(treeWidget) in ["inbox", "new", None]:
ret = self.addMessageListItemInbox(
tableWidget, "inbox", inventoryHash, toAddress, fromAddress, subject, time.time(), 0)
if ret is None:
acct.parseMessage(toAddress, fromAddress, subject, "")
else:
@ -2323,7 +2393,9 @@ class MyForm(settingsmixin.SMainWindow):
unicode(acct.fromLabel, 'utf-8')),
sound.SOUND_UNKNOWN
)
if self.getCurrentAccount() is not None and ((self.getCurrentFolder(treeWidget) != "inbox" and self.getCurrentFolder(treeWidget) is not None) or self.getCurrentAccount(treeWidget) != acct.address):
if self.getCurrentAccount() is not None and (
(self.getCurrentFolder(treeWidget) != "inbox" and self.getCurrentFolder(treeWidget) is not None) or
self.getCurrentAccount(treeWidget) != acct.address):
# Ubuntu should notify of new message irespective of
# whether it's in current message list or not
self.indicatorUpdate(True, to_label=acct.toLabel)
@ -2449,29 +2521,40 @@ class MyForm(settingsmixin.SMainWindow):
BMConfigParser().set('bitmessagesettings', 'replybelow', str(
self.settingsDialogInstance.ui.checkBoxReplyBelow.isChecked()))
lang = str(self.settingsDialogInstance.ui.languageComboBox.itemData(self.settingsDialogInstance.ui.languageComboBox.currentIndex()).toString())
lang = str(
self.settingsDialogInstance.ui.languageComboBox.itemData(
self.settingsDialogInstance.ui.languageComboBox.currentIndex()).toString())
BMConfigParser().set('bitmessagesettings', 'userlocale', lang)
change_translation(l10n.getTranslationLanguage())
if int(BMConfigParser().get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
if int(BMConfigParser().get('bitmessagesettings', 'port')) != \
int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
if not BMConfigParser().safeGetBoolean('bitmessagesettings', 'dontconnect'):
QtGui.QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
"MainWindow", "You must restart Bitmessage for the port number change to take effect."))
BMConfigParser().set('bitmessagesettings', 'port', str(
self.settingsDialogInstance.ui.lineEditTCPPort.text()))
if self.settingsDialogInstance.ui.checkBoxUPnP.isChecked() != BMConfigParser().safeGetBoolean('bitmessagesettings', 'upnp'):
BMConfigParser().set('bitmessagesettings', 'upnp', str(self.settingsDialogInstance.ui.checkBoxUPnP.isChecked()))
if self.settingsDialogInstance.ui.checkBoxUPnP.isChecked() != BMConfigParser().safeGetBoolean(
'bitmessagesettings', 'upnp'):
BMConfigParser().set('bitmessagesettings', 'upnp',
str(self.settingsDialogInstance.ui.checkBoxUPnP.isChecked()))
if self.settingsDialogInstance.ui.checkBoxUPnP.isChecked():
import upnp
upnpThread = upnp.uPnPThread()
upnpThread.start()
#print 'self.settingsDialogInstance.ui.comboBoxProxyType.currentText()', self.settingsDialogInstance.ui.comboBoxProxyType.currentText()
#print 'self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5]', self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5]
if BMConfigParser().get('bitmessagesettings', 'socksproxytype') == 'none' and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS':
#print 'self.settingsDialogInstance.ui.comboBoxProxyType.currentText()',
# self.settingsDialogInstance.ui.comboBoxProxyType.currentText()
#print 'self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5]',
# self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5]
if BMConfigParser().get('bitmessagesettings', 'socksproxytype') == 'none' \
and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS':
if shared.statusIconColor != 'red':
QtGui.QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
"MainWindow", "Bitmessage will use your proxy from now on but you may want to manually restart Bitmessage now to close existing connections (if any)."))
if BMConfigParser().get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS':
"MainWindow",
"Bitmessage will use your proxy from now on but you may want to manually restart "
"Bitmessage now to close existing connections (if any)."))
if BMConfigParser().get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and \
self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS':
self.statusbar.clearMessage()
state.resetNetworkProtocolAvailability() # just in case we changed something in the network connectivity
if self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS':
@ -2508,7 +2591,7 @@ class MyForm(settingsmixin.SMainWindow):
int(float(self.settingsDialogInstance.ui.lineEditMaxOutboundConnections.text()))))
BMConfigParser().set('bitmessagesettings', 'namecoinrpctype',
self.settingsDialogInstance.getNamecoinType())
self.settingsDialogInstance.get_namecoin_type())
BMConfigParser().set('bitmessagesettings', 'namecoinrpchost', str(
self.settingsDialogInstance.ui.lineEditNamecoinHost.text()))
BMConfigParser().set('bitmessagesettings', 'namecoinrpcport', str(
@ -2522,31 +2605,43 @@ class MyForm(settingsmixin.SMainWindow):
# Demanded difficulty tab
if float(self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) >= 1:
BMConfigParser().set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(int(float(
self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
self.settingsDialogInstance.ui.lineEditTotalDifficulty.text()
) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
if float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) >= 1:
BMConfigParser().set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(int(float(
self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) * defaults.networkDefaultPayloadLengthExtraBytes)))
self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()
) * defaults.networkDefaultPayloadLengthExtraBytes)))
if self.settingsDialogInstance.ui.comboBoxOpenCL.currentText().toUtf8() != BMConfigParser().safeGet("bitmessagesettings", "opencl"):
BMConfigParser().set('bitmessagesettings', 'opencl', str(self.settingsDialogInstance.ui.comboBoxOpenCL.currentText()))
if self.settingsDialogInstance.ui.comboBoxOpenCL.currentText().toUtf8() != BMConfigParser().safeGet(
"bitmessagesettings", "opencl"):
BMConfigParser().set('bitmessagesettings', 'opencl',
str(self.settingsDialogInstance.ui.comboBoxOpenCL.currentText()))
queues.workerQueue.put(('resetPoW', ''))
acceptableDifficultyChanged = False
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0:
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 \
or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0:
if BMConfigParser().get('bitmessagesettings','maxacceptablenoncetrialsperbyte') != str(int(float(
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)):
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()
) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)):
# the user changed the max acceptable total difficulty
acceptableDifficultyChanged = True
BMConfigParser().set('bitmessagesettings', 'maxacceptablenoncetrialsperbyte', str(int(float(
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0:
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()
) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 \
or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0:
if BMConfigParser().get('bitmessagesettings','maxacceptablepayloadlengthextrabytes') != str(int(float(
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * defaults.networkDefaultPayloadLengthExtraBytes)):
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()
) * defaults.networkDefaultPayloadLengthExtraBytes)):
# the user changed the max acceptable small message difficulty
acceptableDifficultyChanged = True
BMConfigParser().set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * defaults.networkDefaultPayloadLengthExtraBytes)))
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()
) * defaults.networkDefaultPayloadLengthExtraBytes)))
if acceptableDifficultyChanged:
# It might now be possible to send msgs which were previously marked as toodifficult.
# Let us change them to 'msgqueued'. The singleWorker will try to send them and will again
@ -2557,7 +2652,9 @@ class MyForm(settingsmixin.SMainWindow):
#start:UI setting to stop trying to send messages after X days/months
# I'm open to changing this UI to something else if someone has a better idea.
if ((self.settingsDialogInstance.ui.lineEditDays.text()=='') and (self.settingsDialogInstance.ui.lineEditMonths.text()=='')):#We need to handle this special case. Bitmessage has its default behavior. The input is blank/blank
if ((self.settingsDialogInstance.ui.lineEditDays.text()=='') and
(self.settingsDialogInstance.ui.lineEditMonths.text()=='')):
# We need to handle this special case. Bitmessage has its default behavior. The input is blank/blank
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', '')
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', '')
shared.maximumLengthOfTimeToBotherResendingMessages = float('inf')
@ -2576,11 +2673,18 @@ class MyForm(settingsmixin.SMainWindow):
if lineEditMonthsIsValidFloat and not lineEditDaysIsValidFloat:
self.settingsDialogInstance.ui.lineEditDays.setText("0")
if lineEditDaysIsValidFloat or lineEditMonthsIsValidFloat:
if (float(self.settingsDialogInstance.ui.lineEditDays.text()) >=0 and float(self.settingsDialogInstance.ui.lineEditMonths.text()) >=0):
shared.maximumLengthOfTimeToBotherResendingMessages = (float(str(self.settingsDialogInstance.ui.lineEditDays.text())) * 24 * 60 * 60) + (float(str(self.settingsDialogInstance.ui.lineEditMonths.text())) * (60 * 60 * 24 *365)/12)
if shared.maximumLengthOfTimeToBotherResendingMessages < 432000: # If the time period is less than 5 hours, we give zero values to all fields. No message will be sent again.
if (float(self.settingsDialogInstance.ui.lineEditDays.text()) >=0 and
float(self.settingsDialogInstance.ui.lineEditMonths.text()) >=0):
shared.maximumLengthOfTimeToBotherResendingMessages = (float(
str(self.settingsDialogInstance.ui.lineEditDays.text())) * 24 * 60 * 60) + (float(
str(self.settingsDialogInstance.ui.lineEditMonths.text())) * (60 * 60 * 24 *365)/12)
if shared.maximumLengthOfTimeToBotherResendingMessages < 432000:
# If the time period is less than 5 hours, we give zero values to all fields.
# No message will be sent again.
QtGui.QMessageBox.about(self, _translate("MainWindow", "Will not resend ever"), _translate(
"MainWindow", "Note that the time limit you entered is less than the amount of time Bitmessage waits for the first resend attempt therefore your messages will never be resent."))
"MainWindow",
"Note that the time limit you entered is less than the amount of time Bitmessage waits "
"for the first resend attempt therefore your messages will never be resent."))
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxdays', '0')
BMConfigParser().set('bitmessagesettings', 'stopresendingafterxmonths', '0')
shared.maximumLengthOfTimeToBotherResendingMessages = 0
@ -2607,7 +2711,9 @@ class MyForm(settingsmixin.SMainWindow):
# startup for linux
pass
if state.appdata != paths.lookupExeFolder() and self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we are NOT using portable mode now but the user selected that we should...
if state.appdata != paths.lookupExeFolder() and \
self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked():
# If we are NOT using portable mode now but the user selected that we should...
# Write the keys.dat file to disk in the new location
sqlStoredProcedure('movemessagstoprog')
with open(paths.lookupExeFolder() + 'keys.dat', 'wb') as configfile:
@ -2625,7 +2731,9 @@ class MyForm(settingsmixin.SMainWindow):
except:
pass
if state.appdata == paths.lookupExeFolder() and not self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we ARE using portable mode now but the user selected that we shouldn't...
if state.appdata == paths.lookupExeFolder() and not \
self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked():
# If we ARE using portable mode now but the user selected that we shouldn't...
state.appdata = paths.lookupAppdataFolder()
if not os.path.exists(state.appdata):
os.makedirs(state.appdata)
@ -2649,7 +2757,7 @@ class MyForm(settingsmixin.SMainWindow):
account_item = self.getCurrentItem()
if not account_item:
return
self.ui.lineEditTo.setText(account_item.accountString())
self.ui.lineEditTo.setText(account_item.account_string())
self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
@ -2710,9 +2818,9 @@ class MyForm(settingsmixin.SMainWindow):
for i in range(0, idCount):
msgids.append(str(tableWidget.item(
i, 3).data(QtCore.Qt.UserRole).toPyObject()))
tableWidget.item(i, 0).setUnread(False)
tableWidget.item(i, 1).setUnread(False)
tableWidget.item(i, 2).setUnread(False)
tableWidget.item(i, 0).set_unread(False)
tableWidget.item(i, 1).set_unread(False)
tableWidget.item(i, 2).set_unread(False)
tableWidget.item(i, 3).setFont(font)
markread = sqlExecuteChunked(
@ -2766,13 +2874,13 @@ class MyForm(settingsmixin.SMainWindow):
waitForSync = False
# C PoW currently doesn't support interrupting and OpenCL is untested
if getPowType() == "python" and (powQueueSize() > 0 or pendingUpload() > 0):
if getPowType() == "python" and (pow_queue_size() > 0 or pendingUpload() > 0):
reply = QtGui.QMessageBox.question(
self, _translate("MainWindow", "Proof of work pending"),
_translate(
"MainWindow",
"%n object(s) pending proof of work", None,
QtCore.QCoreApplication.CodecForTr, powQueueSize()
QtCore.QCoreApplication.CodecForTr, pow_queue_size()
) + ", " +
_translate(
"MainWindow",
@ -2859,10 +2967,10 @@ class MyForm(settingsmixin.SMainWindow):
if waitForPow:
# check if PoW queue empty
maxWorkerQueue = 0
curWorkerQueue = powQueueSize()
curWorkerQueue = pow_queue_size()
while curWorkerQueue > 0:
# worker queue size
curWorkerQueue = powQueueSize()
curWorkerQueue = pow_queue_size()
if curWorkerQueue > maxWorkerQueue:
maxWorkerQueue = curWorkerQueue
if curWorkerQueue > 0:
@ -3140,7 +3248,7 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.lineEditTo.setText(str(acct.fromAddress))
else:
self.ui.lineEditTo.setText(
tableWidget.item(currentInboxRow, column_from).accountString()
tableWidget.item(currentInboxRow, column_from).account_string()
)
# If the previous message was to a chan then we should send our
@ -3155,7 +3263,7 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.lineEditTo.setText(str(toAddressAtCurrentInboxRow))
else:
self.ui.lineEditTo.setText(
tableWidget.item(currentInboxRow, column_to).accountString()
tableWidget.item(currentInboxRow, column_to).account_string()
)
self.setSendFromComboBox(toAddressAtCurrentInboxRow)
@ -3202,7 +3310,8 @@ class MyForm(settingsmixin.SMainWindow):
queryreturn = sqlQuery('''select * from blacklist where address=?''',
addressAtCurrentInboxRow)
if queryreturn == []:
label = "\"" + tableWidget.item(currentInboxRow, 2).subject + "\" in " + BMConfigParser().get(recipientAddress, "label")
label = "\"" + tableWidget.item(currentInboxRow, 2).subject + "\" in " + \
BMConfigParser().get(recipientAddress, "label")
sqlExecute('''INSERT INTO blacklist VALUES (?,?, ?)''',
label,
addressAtCurrentInboxRow, True)
@ -3219,7 +3328,8 @@ class MyForm(settingsmixin.SMainWindow):
def deleteRowFromMessagelist(self, row = None, inventoryHash = None, ackData = None, messageLists = None):
if messageLists is None:
messageLists = (self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans, self.ui.tableWidgetInboxSubscriptions)
messageLists = (self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans,
self.ui.tableWidgetInboxSubscriptions)
elif type(messageLists) not in (list, tuple):
messageLists = (messageLists)
for messageList in messageLists:
@ -3315,7 +3425,8 @@ class MyForm(settingsmixin.SMainWindow):
message, = row
defaultFilename = "".join(x for x in subjectAtCurrentInboxRow if x.isalnum()) + '.txt'
filename = QtGui.QFileDialog.getSaveFileName(self, _translate("MainWindow","Save As..."), defaultFilename, "Text files (*.txt);;All files (*.*)")
filename = QtGui.QFileDialog.getSaveFileName(
self, _translate("MainWindow","Save As..."), defaultFilename, "Text files (*.txt);;All files (*.*)")
if filename == '':
return
try: