try to migrate to Python3 + PyQt6; part 2

TLS is disabled
This commit is contained in:
Kashiko Koibumi 2024-05-13 12:47:42 +09:00
parent 6dfecbe361
commit 057e856925
No known key found for this signature in database
GPG Key ID: 8F06E069E37C40C4
32 changed files with 391 additions and 326 deletions

View File

@ -609,12 +609,12 @@ class MyForm(settingsmixin.SMainWindow):
if addressVersionNumber == 1:
displayMsg = _translate(
"MainWindow",
"One of your addresses, %1, is an old version 1 address. "
"One of your addresses, {0}, is an old version 1 address. "
"Version 1 addresses are no longer supported. "
"May we delete it now?").arg(addressInKeysFile)
"May we delete it now?").format(addressInKeysFile)
reply = QtGui.QMessageBox.question(
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
self, 'Message', displayMsg, QtGui.QMessageBox.StandardButton.Yes, QtGui.QMessageBox.StandardButton.No)
if reply == QtGui.QMessageBox.StandardButton.Yes:
config.remove_section(addressInKeysFile)
config.save()
@ -1062,20 +1062,20 @@ class MyForm(settingsmixin.SMainWindow):
elif status == 'msgsent':
statusText = _translate(
"MainWindow",
"Message sent. Waiting for acknowledgement. Sent at %1"
).arg(l10n.formatTimestamp(lastactiontime))
"Message sent. Waiting for acknowledgement. Sent at {0}"
).format(l10n.formatTimestamp(lastactiontime))
elif status == 'msgsentnoackexpected':
statusText = _translate(
"MainWindow", "Message sent. Sent at %1"
).arg(l10n.formatTimestamp(lastactiontime))
"MainWindow", "Message sent. Sent at {0}"
).format(l10n.formatTimestamp(lastactiontime))
elif status == 'doingmsgpow':
statusText = _translate(
"MainWindow", "Doing work necessary to send message.")
elif status == 'ackreceived':
statusText = _translate(
"MainWindow",
"Acknowledgement of the message received %1"
).arg(l10n.formatTimestamp(lastactiontime))
"Acknowledgement of the message received {0}"
).format(l10n.formatTimestamp(lastactiontime))
elif status == 'broadcastqueued':
statusText = _translate(
"MainWindow", "Broadcast queued.")
@ -1083,27 +1083,27 @@ class MyForm(settingsmixin.SMainWindow):
statusText = _translate(
"MainWindow", "Doing work necessary to send broadcast.")
elif status == 'broadcastsent':
statusText = _translate("MainWindow", "Broadcast on %1").arg(
statusText = _translate("MainWindow", "Broadcast on {0}").format(
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(l10n.formatTimestamp(lastactiontime))
" difficult than you are willing to do. {0}"
).format(l10n.formatTimestamp(lastactiontime))
elif status == 'badkey':
statusText = _translate(
"MainWindow",
"Problem: The recipient\'s encryption key is no good."
" Could not encrypt message. %1"
).arg(l10n.formatTimestamp(lastactiontime))
" Could not encrypt message. {0}"
).format(l10n.formatTimestamp(lastactiontime))
elif status == 'forcepow':
statusText = _translate(
"MainWindow",
"Forced difficulty override. Send should start soon.")
else:
statusText = _translate(
"MainWindow", "Unknown status: %1 %2").arg(status).arg(
"MainWindow", "Unknown status: {0} {1}").format(status,
l10n.formatTimestamp(lastactiontime))
items = [
@ -1387,7 +1387,7 @@ class MyForm(settingsmixin.SMainWindow):
def notifierInit(self):
def _simple_notify(
title, subtitle, category, label=None, icon=None):
self.tray.showMessage(title, subtitle, 1, 2000)
self.tray.showMessage(title, subtitle, icon, 2000)
self._notifier = _simple_notify
# does nothing if isAvailable returns false
@ -1504,7 +1504,7 @@ class MyForm(settingsmixin.SMainWindow):
# reply = QtGui.QMessageBox.information(self, 'keys.dat?','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.', QMessageBox.Ok)
# back up this file.', QMessageBox.StandardButton.Ok)
reply = QtGui.QMessageBox.information(
self,
'keys.dat?',
@ -1513,7 +1513,7 @@ class MyForm(settingsmixin.SMainWindow):
"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)
QtGui.QMessageBox.StandardButton.Ok)
else:
QtGui.QMessageBox.information(
@ -1522,10 +1522,10 @@ class MyForm(settingsmixin.SMainWindow):
_translate(
"MainWindow",
"You may manage your keys by editing the keys.dat file stored in"
"\n %1 \n"
"\n {0} \n"
"It is important that you back up this file."
).arg(state.appdata),
QtGui.QMessageBox.Ok)
).format(state.appdata),
QtGui.QMessageBox.StandardButton.Ok)
elif sys.platform == 'win32' or sys.platform == 'win64':
if state.appdata == '':
reply = QtGui.QMessageBox.question(
@ -1537,19 +1537,19 @@ class MyForm(settingsmixin.SMainWindow):
"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)
QtGui.QMessageBox.StandardButton.Yes,
QtGui.QMessageBox.StandardButton.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 \n"
"You may manage your keys by editing the keys.dat file stored in\n {0} \n"
"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.)").arg(state.appdata),
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
"(Be sure to close Bitmessage before making any changes.)").format(state.appdata),
QtGui.QMessageBox.StandardButton.Yes, QtGui.QMessageBox.StandardButton.No)
if reply == QtGui.QMessageBox.StandardButton.Yes:
openKeysFile()
# menu button 'delete all treshed messages'
@ -1558,8 +1558,8 @@ class MyForm(settingsmixin.SMainWindow):
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:
QtGui.QMessageBox.StandardButton.Yes,
QtGui.QMessageBox.StandardButton.No) == QtGui.QMessageBox.StandardButton.No:
return
sqlStoredProcedure('deleteandvacuume')
self.rerenderTabTreeMessages()
@ -1654,7 +1654,7 @@ class MyForm(settingsmixin.SMainWindow):
pass
def changeEvent(self, event):
if event.type() == QtCore.QEvent.LanguageChange:
if event.type() == QtCore.QEvent.Type.LanguageChange:
self.ui.retranslateUi(self)
self.init_inbox_popup_menu(False)
self.init_identities_popup_menu(False)
@ -1663,7 +1663,7 @@ class MyForm(settingsmixin.SMainWindow):
self.init_subscriptions_popup_menu(False)
self.init_sent_popup_menu(False)
self.ui.blackwhitelist.init_blacklist_popup_menu(False)
if event.type() == QtCore.QEvent.WindowStateChange:
if event.type() == QtCore.QEvent.Type.WindowStateChange:
if self.windowState() & QtCore.Qt.WindowMinimized:
if config.getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform:
QtCore.QTimer.singleShot(0, self.appIndicatorHide)
@ -1890,14 +1890,14 @@ class MyForm(settingsmixin.SMainWindow):
self.notifiedNewVersion = ".".join(str(n) for n in version)
self.updateStatusBar(_translate(
"MainWindow",
"New version of PyBitmessage is available: %1. Download it"
"New version of PyBitmessage is available: {0}. Download it"
" from https://github.com/Bitmessage/PyBitmessage/releases/latest"
).arg(self.notifiedNewVersion)
).format(self.notifiedNewVersion)
)
def displayAlert(self, title, text, exitAfterUserClicksOk):
self.updateStatusBar(text)
QtGui.QMessageBox.critical(self, title, text, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.critical(self, title, text, QtGui.QMessageBox.StandardButton.Ok)
if exitAfterUserClicksOk:
os._exit(0)
@ -1982,7 +1982,7 @@ class MyForm(settingsmixin.SMainWindow):
,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)
QtGui.QMessageBox.StandardButton.Ok)
def click_pushButtonClear(self):
self.ui.lineEditSubject.setText("")
@ -2028,9 +2028,9 @@ class MyForm(settingsmixin.SMainWindow):
_translate(
"MainWindow",
"The message that you are trying to send is too long"
" by %1 bytes. (The maximum is 261644 bytes). Please"
" by {0} bytes. (The maximum is 261644 bytes). Please"
" cut it down before sending."
).arg(len(message) - (2 ** 18 - 500)))
).format(len(message) - (2 ** 18 - 500)))
return
acct = accountClass(fromAddress)
@ -2062,7 +2062,7 @@ class MyForm(settingsmixin.SMainWindow):
"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:
QtGui.QMessageBox.StandardButton.Yes|QtGui.QMessageBox.StandardButton.No) != QtGui.QMessageBox.StandardButton.Yes:
continue
email = acct.getLabel()
if email[-14:] != "@mailchuck.com": # attempt register
@ -2079,9 +2079,9 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow",
"Error: Your account wasn't registered at"
" an email gateway. Sending registration"
" now as %1, please wait for the registration"
" now as {0}, please wait for the registration"
" to be processed before retrying sending."
).arg(email)
).format(email)
)
return
status, addressVersionNumber, streamNumber = decodeAddress(toAddress)[:3]
@ -2096,58 +2096,58 @@ class MyForm(settingsmixin.SMainWindow):
self.updateStatusBar(_translate(
"MainWindow",
"Error: Bitmessage addresses start with"
" BM- Please check the recipient address %1"
).arg(toAddress))
" BM- Please check the recipient address {0}"
).format(toAddress))
elif status == 'checksumfailed':
self.updateStatusBar(_translate(
"MainWindow",
"Error: The recipient address %1 is not"
"Error: The recipient address {0} is not"
" typed or copied correctly. Please check it."
).arg(toAddress))
).format(toAddress))
elif status == 'invalidcharacters':
self.updateStatusBar(_translate(
"MainWindow",
"Error: The recipient address %1 contains"
"Error: The recipient address {0} contains"
" invalid characters. Please check it."
).arg(toAddress))
).format(toAddress))
elif status == 'versiontoohigh':
self.updateStatusBar(_translate(
"MainWindow",
"Error: The version of the recipient address"
" %1 is too high. Either you need to upgrade"
" {0} is too high. Either you need to upgrade"
" your Bitmessage software or your"
" acquaintance is being clever."
).arg(toAddress))
).format(toAddress))
elif status == 'ripetooshort':
self.updateStatusBar(_translate(
"MainWindow",
"Error: Some data encoded in the recipient"
" address %1 is too short. There might be"
" address {0} is too short. There might be"
" something wrong with the software of"
" your acquaintance."
).arg(toAddress))
).format(toAddress))
elif status == 'ripetoolong':
self.updateStatusBar(_translate(
"MainWindow",
"Error: Some data encoded in the recipient"
" address %1 is too long. There might be"
" address {0} is too long. There might be"
" something wrong with the software of"
" your acquaintance."
).arg(toAddress))
).format(toAddress))
elif status == 'varintmalformed':
self.updateStatusBar(_translate(
"MainWindow",
"Error: Some data encoded in the recipient"
" address %1 is malformed. There might be"
" address {0} is malformed. There might be"
" something wrong with the software of"
" your acquaintance."
).arg(toAddress))
).format(toAddress))
else:
self.updateStatusBar(_translate(
"MainWindow",
"Error: Something is wrong with the"
" recipient address %1."
).arg(toAddress))
" recipient address {0}."
).format(toAddress))
elif fromAddress == '':
self.updateStatusBar(_translate(
"MainWindow",
@ -2164,9 +2164,9 @@ class MyForm(settingsmixin.SMainWindow):
_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)))
"Concerning the address {0}, Bitmessage cannot understand address version numbers"
" of {1}. Perhaps upgrade Bitmessage to the latest version."
).format(toAddress, str(addressVersionNumber)))
continue
if streamNumber > 1 or streamNumber == 0:
QtGui.QMessageBox.about(
@ -2174,9 +2174,9 @@ class MyForm(settingsmixin.SMainWindow):
_translate("MainWindow", "Stream number"),
_translate(
"MainWindow",
"Concerning the address %1, Bitmessage cannot handle stream numbers of %2."
"Concerning the address {0}, Bitmessage cannot handle stream numbers of {1}."
" Perhaps upgrade Bitmessage to the latest version."
).arg(toAddress).arg(str(streamNumber)))
).format(toAddress, str(streamNumber)))
continue
self.statusbar.clearMessage()
if state.statusIconColor == 'red':
@ -2265,7 +2265,7 @@ class MyForm(settingsmixin.SMainWindow):
err, addr = self.namecoin.query(identities[-1].strip())
if err is not None:
self.updateStatusBar(
_translate("MainWindow", "Error: %1").arg(err))
_translate("MainWindow", "Error: {0}").format(err))
else:
identities[-1] = addr
self.ui.lineEditTo.setText("; ".join(identities))
@ -2420,7 +2420,7 @@ class MyForm(settingsmixin.SMainWindow):
'bitmessagesettings', 'showtraynotifications'):
self.notifierShow(
_translate("MainWindow", "New Message"),
_translate("MainWindow", "From %1").arg(
_translate("MainWindow", "From {0}").format(
str(acct.fromLabel, 'utf-8')),
sound.SOUND_UNKNOWN
)
@ -2583,8 +2583,8 @@ class MyForm(settingsmixin.SMainWindow):
_translate(
"MainWindow",
"Are you sure you would like to mark all messages read?"
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
) != QtGui.QMessageBox.Yes:
), QtGui.QMessageBox.StandardButton.Yes | QtGui.QMessageBox.StandardButton.No
) != QtGui.QMessageBox.StandardButton.Yes:
return
tableWidget = self.getCurrentMessagelist()
@ -2612,7 +2612,7 @@ class MyForm(settingsmixin.SMainWindow):
def network_switch(self):
dontconnect_option = not config.safeGetBoolean(
'bitmessagesettings', 'dontconnect')
reply = QtGui.QMessageBox.question(
reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Disconnecting")
if dontconnect_option else _translate("MainWindow", "Connecting"),
_translate(
@ -2621,9 +2621,9 @@ class MyForm(settingsmixin.SMainWindow):
) if dontconnect_option else _translate(
"MainWindow",
"Bitmessage will now start connecting to network. Are you sure?"
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel,
QtGui.QMessageBox.Cancel)
if reply != QtGui.QMessageBox.Yes:
), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.Cancel,
QtWidgets.QMessageBox.StandardButton.Cancel)
if reply != QtWidgets.QMessageBox.StandardButton.Yes:
return
config.set(
'bitmessagesettings', 'dontconnect', str(dontconnect_option))
@ -2650,7 +2650,7 @@ class MyForm(settingsmixin.SMainWindow):
# C PoW currently doesn't support interrupting and OpenCL is untested
if getPowType() == "python" and (powQueueSize() > 0 or pendingUpload() > 0):
reply = QtGui.QMessageBox.question(
reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Proof of work pending"),
_translate(
"MainWindow",
@ -2664,15 +2664,15 @@ class MyForm(settingsmixin.SMainWindow):
) + "\n\n" +
_translate(
"MainWindow", "Wait until these tasks finish?"),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel)
if reply == QtGui.QMessageBox.No:
QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
| QtWidgets.QMessageBox.StandardButton.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel)
if reply == QtWidgets.QMessageBox.StandardButton.No:
waitForPow = False
elif reply == QtGui.QMessageBox.Cancel:
elif reply == QtWidgets.QMessageBox.StandardButton.Cancel:
return
if pendingDownload() > 0:
reply = QtGui.QMessageBox.question(
reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Synchronisation pending"),
_translate(
"MainWindow",
@ -2682,16 +2682,16 @@ class MyForm(settingsmixin.SMainWindow):
" synchronisation finishes?", None,
QtCore.QCoreApplication.CodecForTr, pendingDownload()
),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel)
if reply == QtGui.QMessageBox.Yes:
QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
| QtWidgets.QMessageBox.StandardButton.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel)
if reply == QtWidgets.QMessageBox.StandardButton.Yes:
self.wait = waitForSync = True
elif reply == QtGui.QMessageBox.Cancel:
elif reply == QtWidgets.QMessageBox.StandardButton.Cancel:
return
if state.statusIconColor == 'red' and not config.safeGetBoolean(
'bitmessagesettings', 'dontconnect'):
reply = QtGui.QMessageBox.question(
reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Not connected"),
_translate(
"MainWindow",
@ -2699,18 +2699,18 @@ class MyForm(settingsmixin.SMainWindow):
" quit now, it may cause delivery delays. Wait until"
" connected and the synchronisation finishes?"
),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel)
if reply == QtGui.QMessageBox.Yes:
QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
| QtWidgets.QMessageBox.StandardButton.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel)
if reply == QtWidgets.QMessageBox.StandardButton.Yes:
waitForConnection = True
self.wait = waitForSync = True
elif reply == QtGui.QMessageBox.Cancel:
elif reply == QtWidgets.QMessageBox.StandardButton.Cancel:
return
self.quitAccepted = True
self.updateStatusBar(_translate(
"MainWindow", "Shutting down PyBitmessage... %1%").arg(0))
"MainWindow", "Shutting down PyBitmessage... {0}%").format(0))
if waitForConnection:
self.updateStatusBar(_translate(
@ -2718,7 +2718,7 @@ class MyForm(settingsmixin.SMainWindow):
while state.statusIconColor == 'red':
time.sleep(0.5)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
)
# this probably will not work correctly, because there is a delay
@ -2730,7 +2730,7 @@ class MyForm(settingsmixin.SMainWindow):
while pendingDownload() > 0:
time.sleep(0.5)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
)
if waitForPow:
@ -2744,54 +2744,54 @@ class MyForm(settingsmixin.SMainWindow):
maxWorkerQueue = curWorkerQueue
if curWorkerQueue > 0:
self.updateStatusBar(_translate(
"MainWindow", "Waiting for PoW to finish... %1%"
).arg(50 * (maxWorkerQueue - curWorkerQueue) /
"MainWindow", "Waiting for PoW to finish... {0}%"
).format(50 * (maxWorkerQueue - curWorkerQueue) /
maxWorkerQueue))
time.sleep(0.5)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
)
self.updateStatusBar(_translate(
"MainWindow", "Shutting down Pybitmessage... %1%").arg(50))
"MainWindow", "Shutting down Pybitmessage... {0}%").format(50))
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
)
if maxWorkerQueue > 0:
# a bit of time so that the hashHolder is populated
time.sleep(0.5)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
)
# check if upload (of objects created locally) pending
self.updateStatusBar(_translate(
"MainWindow", "Waiting for objects to be sent... %1%").arg(50))
"MainWindow", "Waiting for objects to be sent... {0}%").format(50))
maxPendingUpload = max(1, pendingUpload())
while pendingUpload() > 1:
self.updateStatusBar(_translate(
"MainWindow",
"Waiting for objects to be sent... %1%"
).arg(int(50 + 20 * (pendingUpload() / maxPendingUpload))))
"Waiting for objects to be sent... {0}%"
).format(int(50 + 20 * (pendingUpload() / maxPendingUpload))))
time.sleep(0.5)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
)
# save state and geometry self and all widgets
self.updateStatusBar(_translate(
"MainWindow", "Saving settings... %1%").arg(70))
"MainWindow", "Saving settings... {0}%").format(70))
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
)
self.saveSettings()
for attr, obj in self.ui.__dict__.items():
@ -2802,18 +2802,18 @@ class MyForm(settingsmixin.SMainWindow):
obj.saveSettings()
self.updateStatusBar(_translate(
"MainWindow", "Shutting down core... %1%").arg(80))
"MainWindow", "Shutting down core... {0}%").format(80))
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
)
shutdown.doCleanShutdown()
self.updateStatusBar(_translate(
"MainWindow", "Stopping notifications... %1%").arg(90))
"MainWindow", "Stopping notifications... {0}%").format(90))
self.tray.hide()
self.updateStatusBar(_translate(
"MainWindow", "Shutdown imminent... %1%").arg(100))
"MainWindow", "Shutdown imminent... {0}%").format(100))
logger.info("Shutdown complete")
self.close()
@ -2982,23 +2982,23 @@ class MyForm(settingsmixin.SMainWindow):
)
# toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
elif not config.has_section(toAddressAtCurrentInboxRow):
QtGui.QMessageBox.information(
QtWidgets.QMessageBox.information(
self, _translate("MainWindow", "Address is gone"),
_translate(
"MainWindow",
"Bitmessage cannot find your address %1. Perhaps you"
"Bitmessage cannot find your address {0}. Perhaps you"
" removed it?"
).arg(toAddressAtCurrentInboxRow), QtGui.QMessageBox.Ok)
).format(toAddressAtCurrentInboxRow), QtWidgets.QMessageBox.StandardButton.Ok)
elif not config.getboolean(
toAddressAtCurrentInboxRow, 'enabled'):
QtGui.QMessageBox.information(
QtWidgets.QMessageBox.information(
self, _translate("MainWindow", "Address disabled"),
_translate(
"MainWindow",
"Error: The address from which you are trying to send"
" is disabled. You\'ll have to enable it on the"
" \'Your Identities\' tab before using it."
), QtGui.QMessageBox.Ok)
), QtWidgets.QMessageBox.StandardButton.Ok)
else:
self.setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(toAddressAtCurrentInboxRow)
broadcast_tab_index = self.ui.tabWidgetSend.indexOf(
@ -3126,7 +3126,7 @@ class MyForm(settingsmixin.SMainWindow):
return
currentRow = 0
folder = self.getCurrentFolder()
shifted = QtGui.QApplication.queryKeyboardModifiers() \
shifted = QtWidgets.QApplication.queryKeyboardModifiers() \
& QtCore.Qt.ShiftModifier
tableWidget.setUpdatesEnabled(False)
inventoryHashesToTrash = set()
@ -3199,7 +3199,7 @@ class MyForm(settingsmixin.SMainWindow):
message, = row
defaultFilename = "".join(x for x in subjectAtCurrentInboxRow if x.isalnum()) + '.txt'
filename = QtGui.QFileDialog.getSaveFileName(
filename = QtWidgets.QFileDialog.getSaveFileName(
self,
_translate("MainWindow","Save As..."),
defaultFilename,
@ -3220,7 +3220,7 @@ class MyForm(settingsmixin.SMainWindow):
if not tableWidget:
return
folder = self.getCurrentFolder()
shifted = QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier
shifted = QtWidgets.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier
while tableWidget.selectedIndexes() != []:
currentRow = tableWidget.selectedIndexes()[0].row()
ackdataToTrash = tableWidget.item(currentRow, 3).data()
@ -3256,7 +3256,7 @@ class MyForm(settingsmixin.SMainWindow):
currentRow = self.ui.tableWidgetInbox.currentRow()
addressAtCurrentRow = self.ui.tableWidgetInbox.item(
currentRow, 0).data(QtCore.Qt.UserRole)
clipboard = QtGui.QApplication.clipboard()
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(str(addressAtCurrentRow))
# Group of functions for the Address Book dialog box
@ -3281,7 +3281,7 @@ class MyForm(settingsmixin.SMainWindow):
addresses_string = item.address
else:
addresses_string += ', ' + item.address
clipboard = QtGui.QApplication.clipboard()
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(addresses_string)
def on_action_AddressBookSend(self):
@ -3323,7 +3323,7 @@ class MyForm(settingsmixin.SMainWindow):
)
def on_context_menuAddressBook(self, point):
self.popMenuAddressBook = QtGui.QMenu(self)
self.popMenuAddressBook = QtWidgets.QMenu(self)
self.popMenuAddressBook.addAction(self.actionAddressBookSend)
self.popMenuAddressBook.addAction(self.actionAddressBookClipboard)
self.popMenuAddressBook.addAction(self.actionAddressBookSubscribe)
@ -3353,7 +3353,7 @@ class MyForm(settingsmixin.SMainWindow):
self.click_pushButtonAddSubscription()
def on_action_SubscriptionsDelete(self):
if QtGui.QMessageBox.question(
if QtWidgets.QMessageBox.question(
self, "Delete subscription?",
_translate(
"MainWindow",
@ -3364,8 +3364,8 @@ class MyForm(settingsmixin.SMainWindow):
" messages, but you can still view messages you"
" already received.\n\nAre you sure you want to"
" delete the subscription?"
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
) != QtGui.QMessageBox.Yes:
), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
) != QtWidgets.QMessageBox.StandardButton.Yes:
return
address = self.getCurrentAccount()
sqlExecute('''DELETE FROM subscriptions WHERE address=?''',
@ -3377,7 +3377,7 @@ class MyForm(settingsmixin.SMainWindow):
def on_action_SubscriptionsClipboard(self):
address = self.getCurrentAccount()
clipboard = QtGui.QApplication.clipboard()
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(str(address))
def on_action_SubscriptionsEnable(self):
@ -3402,7 +3402,7 @@ class MyForm(settingsmixin.SMainWindow):
def on_context_menuSubscriptions(self, point):
currentItem = self.getCurrentItem()
self.popMenuSubscriptions = QtGui.QMenu(self)
self.popMenuSubscriptions = QtWidgets.QMenu(self)
if isinstance(currentItem, Ui_AddressWidget):
self.popMenuSubscriptions.addAction(self.actionsubscriptionsNew)
self.popMenuSubscriptions.addAction(self.actionsubscriptionsDelete)
@ -3588,7 +3588,7 @@ class MyForm(settingsmixin.SMainWindow):
if account.type == AccountMixin.NORMAL:
return # maybe in the future
elif account.type == AccountMixin.CHAN:
if QtGui.QMessageBox.question(
if QtWidgets.QMessageBox.question(
self, "Delete channel?",
_translate(
"MainWindow",
@ -3599,8 +3599,8 @@ class MyForm(settingsmixin.SMainWindow):
" messages, but you can still view messages you"
" already received.\n\nAre you sure you want to"
" delete the channel?"
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
) == QtGui.QMessageBox.Yes:
), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
) == QtWidgets.QMessageBox.StandardButton.Yes:
config.remove_section(str(account.address))
else:
return
@ -3641,7 +3641,7 @@ class MyForm(settingsmixin.SMainWindow):
def on_action_Clipboard(self):
address = self.getCurrentAccount()
clipboard = QtGui.QApplication.clipboard()
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(str(address))
def on_action_ClipboardMessagelist(self):
@ -3666,7 +3666,7 @@ class MyForm(settingsmixin.SMainWindow):
else:
text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole)
clipboard = QtGui.QApplication.clipboard()
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(text)
# set avatar functions
@ -3724,7 +3724,7 @@ class MyForm(settingsmixin.SMainWindow):
current_files += [upper]
filters[0:0] = ['Image files (' + ' '.join(all_images_filter) + ')']
filters[1:1] = ['All files (*.*)']
sourcefile = QtGui.QFileDialog.getOpenFileName(
sourcefile = QtWidgets.QFileDialog.getOpenFileName(
self, _translate("MainWindow", "Set avatar..."),
filter=';;'.join(filters)
)
@ -3736,11 +3736,11 @@ class MyForm(settingsmixin.SMainWindow):
if exists | (len(current_files) > 0):
displayMsg = _translate(
"MainWindow", "Do you really want to remove this avatar?")
overwrite = QtGui.QMessageBox.question(
overwrite = QtWidgets.QMessageBox.question(
self, 'Message', displayMsg,
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No)
else:
overwrite = QtGui.QMessageBox.No
overwrite = QtWidgets.QMessageBox.StandardButton.No
else:
# ask whether to overwrite old avatar
if exists | (len(current_files) > 0):
@ -3748,15 +3748,15 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow",
"You have already set an avatar for this address."
" Do you really want to overwrite it?")
overwrite = QtGui.QMessageBox.question(
overwrite = QtWidgets.QMessageBox.question(
self, 'Message', displayMsg,
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No)
else:
overwrite = QtGui.QMessageBox.No
overwrite = QtWidgets.QMessageBox.StandardButton.No
# copy the image file to the appdata folder
if (not exists) | (overwrite == QtGui.QMessageBox.Yes):
if overwrite == QtGui.QMessageBox.Yes:
if (not exists) | (overwrite == QtWidgets.QMessageBox.StandardButton.Yes):
if overwrite == QtWidgets.QMessageBox.StandardButton.Yes:
for file in current_files:
QtCore.QFile.remove(file)
QtCore.QFile.remove(destination)
@ -3788,7 +3788,7 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "Sound files (%s)" %
' '.join(['*%s%s' % (os.extsep, ext) for ext in sound.extensions])
))]
sourcefile = str(QtGui.QFileDialog.getOpenFileName(
sourcefile = str(QtWidgets.QFileDialog.getOpenFileName(
self, _translate("MainWindow", "Set notification sound..."),
filter=';;'.join(filters)
))
@ -3806,15 +3806,15 @@ class MyForm(settingsmixin.SMainWindow):
pattern = destfile.lower()
for item in os.listdir(destdir):
if item.lower() == pattern:
overwrite = QtGui.QMessageBox.question(
overwrite = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Message"),
_translate(
"MainWindow",
"You have already set a notification sound"
" for this address book entry."
" Do you really want to overwrite it?"),
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No
) == QtGui.QMessageBox.Yes
QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No
) == QtWidgets.QMessageBox.StandardButton.Yes
if overwrite:
QtCore.QFile.remove(os.path.join(destdir, item))
break
@ -3825,7 +3825,7 @@ class MyForm(settingsmixin.SMainWindow):
def on_context_menuYourIdentities(self, point):
currentItem = self.getCurrentItem()
self.popMenuYourIdentities = QtGui.QMenu(self)
self.popMenuYourIdentities = QtWidgets.QMenu(self)
if isinstance(currentItem, Ui_AddressWidget):
self.popMenuYourIdentities.addAction(self.actionNewYourIdentities)
self.popMenuYourIdentities.addSeparator()
@ -3855,7 +3855,7 @@ class MyForm(settingsmixin.SMainWindow):
# TODO make one popMenu
def on_context_menuChan(self, point):
currentItem = self.getCurrentItem()
self.popMenu = QtGui.QMenu(self)
self.popMenu = QtWidgets.QMenu(self)
if isinstance(currentItem, Ui_AddressWidget):
self.popMenu.addAction(self.actionNew)
self.popMenu.addAction(self.actionDelete)
@ -3891,7 +3891,7 @@ class MyForm(settingsmixin.SMainWindow):
self.on_context_menuSent(point)
return
self.popMenuInbox = QtGui.QMenu(self)
self.popMenuInbox = QtWidgets.QMenu(self)
self.popMenuInbox.addAction(self.actionForceHtml)
self.popMenuInbox.addAction(self.actionMarkUnread)
self.popMenuInbox.addSeparator()
@ -3926,7 +3926,7 @@ class MyForm(settingsmixin.SMainWindow):
def on_context_menuSent(self, point):
currentRow = self.ui.tableWidgetInbox.currentRow()
self.popMenuSent = QtGui.QMenu(self)
self.popMenuSent = QtWidgets.QMenu(self)
self.popMenuSent.addAction(self.actionSentClipboard)
self._contact_selected = self.ui.tableWidgetInbox.item(currentRow, 0)
# preloaded gui.menu plugins with prefix 'address'

View File

@ -9,10 +9,13 @@
from PyQt6 import QtCore, QtGui, QtWidgets
from bmconfigparser import config
from .foldertree import AddressBookCompleter
from .blacklist import Blacklist
from .networkstatus import NetworkStatus
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(885, 580)
self.MainDock = QtWidgets.QDockWidget(parent=MainWindow)
self.MainDock.setGeometry(QtCore.QRect(0, 0, 885, 580))
icon = QtGui.QIcon()
@ -434,8 +437,14 @@ class Ui_MainWindow(object):
icon8 = QtGui.QIcon()
icon8.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-16px.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.tabWidget.addTab(self.tab_3, icon8, "")
self.blackwhitelist = QtWidgets.QWidget()
self.blackwhitelist = Blacklist()
self.blackwhitelist.setObjectName("blackwhitelist")
self.tabWidget.addTab(self.blackwhitelist, QtGui.QIcon(":/newPrefix/images/blacklist.png"), "")
# Initialize the Blacklist or Whitelist
if config.get('bitmessagesettings', 'blackwhitelist') == 'white':
self.blackwhitelist.radioButtonWhitelist.click()
self.blackwhitelist.rerenderBlackWhiteList()
self.gridLayout_6 = QtWidgets.QGridLayout(self.blackwhitelist)
self.gridLayout_6.setObjectName("gridLayout_6")
self.radioButtonBlacklist = QtWidgets.QRadioButton(parent=self.blackwhitelist)
@ -471,7 +480,8 @@ class Ui_MainWindow(object):
icon9 = QtGui.QIcon()
icon9.addPixmap(QtGui.QPixmap(":/newPrefix/images/blacklist.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.tabWidget.addTab(self.blackwhitelist, icon9, "")
self.networkstatus = QtWidgets.QWidget()
self.networkstatus = NetworkStatus()
self.tabWidget.addTab(self.networkstatus, QtGui.QIcon(":/newPrefix/images/networkstatus.png"), "")
self.networkstatus.setObjectName("networkstatus")
self.pushButtonStatusIcon = QtWidgets.QPushButton(parent=self.networkstatus)
self.pushButtonStatusIcon.setGeometry(QtCore.QRect(680, 440, 21, 23))
@ -539,8 +549,7 @@ class Ui_MainWindow(object):
self.tabWidget.addTab(self.networkstatus, icon11, "")
self.gridLayout_10.addWidget(self.tabWidget, 0, 0, 1, 1)
self.MainDock.setWidget(self.centralwidget)
# XXX unresolved
#MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(None), self.MainDock)
MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea.AllDockWidgetAreas, self.MainDock)
self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 885, 27))
self.menubar.setObjectName("menubar")
@ -637,6 +646,7 @@ class Ui_MainWindow(object):
self.subscriptionsContextMenuToolbar = QtWidgets.QToolBar()
def updateNetworkSwitchMenuLabel(self, dontconnect=None):
_translate = QtCore.QCoreApplication.translate
if dontconnect is None:
_translate = QtCore.QCoreApplication.translate
dontconnect = config.safeGetBoolean(
@ -741,7 +751,10 @@ class Ui_MainWindow(object):
item.setText(_translate("MainWindow", "Name or Label"))
item = self.tableWidgetBlacklist.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Address"))
self.blackwhitelist.retranslateUi()
self.tabWidget.setTabText(self.tabWidget.indexOf(self.blackwhitelist), _translate("MainWindow", "Blacklist"))
self.networkstatus.retranslateUi()
self.tabWidget.setTabText(self.tabWidget.indexOf(self.networkstatus), _translate("MainWindow", "Network Status"))
item = self.tableWidgetConnectionCount.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Stream #"))
item = self.tableWidgetConnectionCount.horizontalHeaderItem(1)

View File

@ -1,16 +1,18 @@
--- bitmessageui.py.orig 2024-05-12 18:57:04.429581050 +0900
+++ bitmessageui.py 2024-05-12 19:50:49.951776910 +0900
@@ -7,7 +7,8 @@
--- bitmessageui.py.orig 2024-05-13 08:32:22.376971328 +0900
+++ bitmessageui.py 2024-05-13 09:48:39.354481762 +0900
@@ -7,7 +7,10 @@
from PyQt6 import QtCore, QtGui, QtWidgets
-
+from bmconfigparser import config
+from .foldertree import AddressBookCompleter
+from .blacklist import Blacklist
+from .networkstatus import NetworkStatus
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
@@ -137,6 +138,11 @@
@@ -140,6 +143,11 @@
self.tableWidgetAddressBook.horizontalHeader().setStretchLastSection(True)
self.tableWidgetAddressBook.verticalHeader().setVisible(False)
self.verticalLayout_2.addWidget(self.tableWidgetAddressBook)
@ -22,7 +24,7 @@
self.pushButtonAddAddressBook = QtWidgets.QPushButton(parent=self.send)
self.pushButtonAddAddressBook.setMaximumSize(QtCore.QSize(200, 16777215))
self.pushButtonAddAddressBook.setObjectName("pushButtonAddAddressBook")
@@ -181,6 +187,7 @@
@@ -184,6 +192,7 @@
self.lineEditTo = QtWidgets.QLineEdit(parent=self.tab)
self.lineEditTo.setObjectName("lineEditTo")
self.gridLayout_2.addWidget(self.lineEditTo, 1, 1, 1, 1)
@ -30,7 +32,7 @@
self.verticalLayout_5.addLayout(self.gridLayout_2)
self.textEditMessage = QtWidgets.QTextEdit(parent=self.tab)
self.textEditMessage.setObjectName("textEditMessage")
@@ -260,6 +267,9 @@
@@ -263,6 +272,9 @@
self.labelHumanFriendlyTTLDescription.setMaximumSize(QtCore.QSize(45, 16777215))
self.labelHumanFriendlyTTLDescription.setObjectName("labelHumanFriendlyTTLDescription")
self.horizontalLayout_5.addWidget(self.labelHumanFriendlyTTLDescription)
@ -40,7 +42,42 @@
self.pushButtonSend = QtWidgets.QPushButton(parent=self.send)
self.pushButtonSend.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.pushButtonSend.setObjectName("pushButtonSend")
@@ -546,6 +556,8 @@
@@ -425,8 +437,14 @@
icon8 = QtGui.QIcon()
icon8.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-16px.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.tabWidget.addTab(self.tab_3, icon8, "")
- self.blackwhitelist = QtWidgets.QWidget()
+ self.blackwhitelist = Blacklist()
self.blackwhitelist.setObjectName("blackwhitelist")
+ self.tabWidget.addTab(self.blackwhitelist, QtGui.QIcon(":/newPrefix/images/blacklist.png"), "")
+ # Initialize the Blacklist or Whitelist
+ if config.get('bitmessagesettings', 'blackwhitelist') == 'white':
+ self.blackwhitelist.radioButtonWhitelist.click()
+ self.blackwhitelist.rerenderBlackWhiteList()
+
self.gridLayout_6 = QtWidgets.QGridLayout(self.blackwhitelist)
self.gridLayout_6.setObjectName("gridLayout_6")
self.radioButtonBlacklist = QtWidgets.QRadioButton(parent=self.blackwhitelist)
@@ -462,7 +480,8 @@
icon9 = QtGui.QIcon()
icon9.addPixmap(QtGui.QPixmap(":/newPrefix/images/blacklist.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.tabWidget.addTab(self.blackwhitelist, icon9, "")
- self.networkstatus = QtWidgets.QWidget()
+ self.networkstatus = NetworkStatus()
+ self.tabWidget.addTab(self.networkstatus, QtGui.QIcon(":/newPrefix/images/networkstatus.png"), "")
self.networkstatus.setObjectName("networkstatus")
self.pushButtonStatusIcon = QtWidgets.QPushButton(parent=self.networkstatus)
self.pushButtonStatusIcon.setGeometry(QtCore.QRect(680, 440, 21, 23))
@@ -530,7 +549,7 @@
self.tabWidget.addTab(self.networkstatus, icon11, "")
self.gridLayout_10.addWidget(self.tabWidget, 0, 0, 1, 1)
self.MainDock.setWidget(self.centralwidget)
- MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(None), self.MainDock)
+ MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea.AllDockWidgetAreas, self.MainDock)
self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 885, 27))
self.menubar.setObjectName("menubar")
@@ -550,6 +569,8 @@
self.actionManageKeys = QtGui.QAction(parent=MainWindow)
self.actionManageKeys.setCheckable(False)
self.actionManageKeys.setEnabled(True)
@ -49,7 +86,7 @@
icon = QtGui.QIcon.fromTheme("dialog-password")
self.actionManageKeys.setIcon(icon)
self.actionManageKeys.setObjectName("actionManageKeys")
@@ -557,6 +569,10 @@
@@ -561,6 +582,10 @@
icon = QtGui.QIcon.fromTheme("help-contents")
self.actionHelp.setIcon(icon)
self.actionHelp.setObjectName("actionHelp")
@ -60,7 +97,7 @@
self.actionAbout = QtGui.QAction(parent=MainWindow)
icon = QtGui.QIcon.fromTheme("help-about")
self.actionAbout.setIcon(icon)
@@ -580,9 +596,11 @@
@@ -584,9 +609,11 @@
self.menuFile.addAction(self.actionManageKeys)
self.menuFile.addAction(self.actionDeleteAllTrashedMessages)
self.menuFile.addAction(self.actionRegenerateDeterministicAddresses)
@ -72,7 +109,7 @@
self.menuHelp.addAction(self.actionAbout)
self.menubar.addAction(self.menuFile.menuAction())
self.menubar.addAction(self.menuSettings.menuAction())
@@ -606,6 +624,25 @@
@@ -610,6 +637,26 @@
MainWindow.setTabOrder(self.tableWidgetBlacklist, self.tableWidgetConnectionCount)
MainWindow.setTabOrder(self.tableWidgetConnectionCount, self.pushButtonStatusIcon)
@ -85,6 +122,7 @@
+ self.subscriptionsContextMenuToolbar = QtWidgets.QToolBar()
+
+ def updateNetworkSwitchMenuLabel(self, dontconnect=None):
+ _translate = QtCore.QCoreApplication.translate
+ if dontconnect is None:
+ _translate = QtCore.QCoreApplication.translate
+ dontconnect = config.safeGetBoolean(
@ -97,8 +135,8 @@
+
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Bitmessage"))
@@ -653,6 +690,7 @@
self.MainDock.setWindowTitle(_translate("MainWindow", "Bitmessage"))
@@ -657,6 +704,7 @@
self.tabWidgetSend.setTabText(self.tabWidgetSend.indexOf(self.tab_2), _translate("MainWindow", "Send Message to your Subscribers"))
self.pushButtonTTL.setText(_translate("MainWindow", "TTL:"))
self.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "X days"))
@ -106,7 +144,18 @@
self.pushButtonSend.setText(_translate("MainWindow", "Send"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.send), _translate("MainWindow", "Send"))
self.treeWidgetSubscriptions.headerItem().setText(0, _translate("MainWindow", "Subscriptions"))
@@ -722,8 +760,10 @@
@@ -703,7 +751,10 @@
item.setText(_translate("MainWindow", "Name or Label"))
item = self.tableWidgetBlacklist.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Address"))
+ self.blackwhitelist.retranslateUi()
self.tabWidget.setTabText(self.tabWidget.indexOf(self.blackwhitelist), _translate("MainWindow", "Blacklist"))
+ self.networkstatus.retranslateUi()
+ self.tabWidget.setTabText(self.tabWidget.indexOf(self.networkstatus), _translate("MainWindow", "Network Status"))
item = self.tableWidgetConnectionCount.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Stream #"))
item = self.tableWidgetConnectionCount.horizontalHeaderItem(1)
@@ -726,8 +777,10 @@
self.actionExit.setShortcut(_translate("MainWindow", "Ctrl+Q"))
self.actionHelp.setText(_translate("MainWindow", "Help"))
self.actionHelp.setShortcut(_translate("MainWindow", "F1"))

View File

@ -12,6 +12,7 @@ from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(885, 580)
self.MainDock = QtWidgets.QDockWidget(parent=MainWindow)
self.MainDock.setGeometry(QtCore.QRect(0, 0, 885, 580))
icon = QtGui.QIcon()

View File

@ -2,6 +2,14 @@
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>885</width>
<height>580</height>
</rect>
</property>
<widget class="QDockWidget" name="MainDock">
<property name="geometry">
<rect>

View File

@ -51,13 +51,13 @@ class AccountMixin(object):
def accountBrush(self):
"""Account brush (for QT UI)"""
brush = QtGui.QBrush(self.accountColor())
brush.setStyle(QtCore.Qt.NoBrush)
brush.setStyle(QtCore.Qt.BrushStyle.NoBrush)
return brush
def folderBrush(self):
"""Folder brush (for QT UI)"""
brush = QtGui.QBrush(self.folderColor())
brush.setStyle(QtCore.Qt.NoBrush)
brush.setStyle(QtCore.Qt.BrushStyle.NoBrush)
return brush
def accountString(self):
@ -124,7 +124,7 @@ class AccountMixin(object):
AccountMixin.NORMAL,
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
try:
retval = unicode(
retval = str(
config.get(self.address, 'label'), 'utf-8')
except Exception:
queryreturn = sqlQuery(
@ -136,12 +136,12 @@ class AccountMixin(object):
if queryreturn != []:
for row in queryreturn:
retval, = row
retval = unicode(retval, 'utf-8')
retval = str(retval, 'utf-8')
elif self.address is None or self.type == AccountMixin.ALL:
return unicode(
return str(
str(_translate("MainWindow", "All accounts")), 'utf-8')
return retval or unicode(self.address, 'utf-8')
return retval or str(self.address, 'utf-8')
class BMTreeWidgetItem(QtWidgets.QTreeWidgetItem, AccountMixin):
@ -210,7 +210,7 @@ class Ui_FolderWidget(BMTreeWidgetItem):
y = self.folderWeight[other.folderName]
else:
y = 99
reverse = QtCore.Qt.DescendingOrder == \
reverse = QtCore.Qt.SortOrder.DescendingOrder == \
self.treeWidget().header().sortIndicatorOrder()
if x == y:
return self.folderName < other.folderName
@ -232,15 +232,15 @@ class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin):
def _getLabel(self):
if self.address is None:
return unicode(_translate(
"MainWindow", "All accounts").toUtf8(), 'utf-8', 'ignore')
return _translate(
"MainWindow", "All accounts")
else:
try:
return unicode(
return str(
config.get(self.address, 'label'),
'utf-8', 'ignore')
except:
return unicode(self.address, 'utf-8')
return str(self.address, 'utf-8')
def _getAddressBracket(self, unreadCount=False):
ret = "" if self.isExpanded() \
@ -284,7 +284,7 @@ class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin):
def __lt__(self, other):
# pylint: disable=protected-access
if isinstance(other, Ui_AddressWidget):
reverse = QtCore.Qt.DescendingOrder == \
reverse = QtCore.Qt.SortOrder.DescendingOrder == \
self.treeWidget().header().sortIndicatorOrder()
if self._getSortRank() == other._getSortRank():
x = self._getLabel().lower()
@ -311,8 +311,8 @@ class Ui_SubscriptionWidget(Ui_AddressWidget):
if queryreturn != []:
for row in queryreturn:
retval, = row
return unicode(retval, 'utf-8', 'ignore')
return unicode(self.address, 'utf-8')
return str(retval, 'utf-8', 'ignore')
return str(self.address, 'utf-8')
def setType(self):
"""Set account type"""
@ -326,7 +326,7 @@ class Ui_SubscriptionWidget(Ui_AddressWidget):
label = str(
value.toString().toUtf8()).decode('utf-8', 'ignore')
else:
label = unicode(value, 'utf-8', 'ignore')
label = str(value, 'utf-8', 'ignore')
sqlExecute(
'''UPDATE subscriptions SET label=? WHERE address=?''',
label, self.address)
@ -407,7 +407,7 @@ class MessageList_AddressWidget(BMAddressWidget):
AccountMixin.NORMAL,
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
try:
newLabel = unicode(
newLabel = str(
config.get(self.address, 'label'),
'utf-8', 'ignore')
except:
@ -418,7 +418,7 @@ class MessageList_AddressWidget(BMAddressWidget):
'''select label from subscriptions where address=?''', self.address)
if queryreturn:
for row in queryreturn:
newLabel = unicode(row[0], 'utf-8', 'ignore')
newLabel = str(row[0], 'utf-8', 'ignore')
self.label = newLabel
@ -456,7 +456,7 @@ class MessageList_SubjectWidget(BMTableWidgetItem):
if role == QtCore.Qt.ItemDataRole.UserRole:
return self.subject
if role == QtCore.Qt.ItemDataRole.ToolTipRole:
return escape(unicode(self.subject, 'utf-8'))
return escape(str(self.subject, 'utf-8'))
return super(MessageList_SubjectWidget, self).data(role)
# label (or address) alphabetically, disabled at the end
@ -534,7 +534,7 @@ class Ui_AddressBookWidgetItem(BMAddressWidget):
def __lt__(self, other):
if isinstance(other, Ui_AddressBookWidgetItem):
reverse = QtCore.Qt.DescendingOrder == \
reverse = QtCore.Qt.SortOrder.DescendingOrder == \
self.tableWidget().horizontalHeader().sortIndicatorOrder()
if self.type == other.type:
@ -584,14 +584,14 @@ class AddressBookCompleter(QtWidgets.QCompleter):
def splitPath(self, path):
"""Split on semicolon"""
text = unicode(path.toUtf8(), 'utf-8')
text = str(path.toUtf8(), 'utf-8')
return [text[:self.widget().cursorPosition()].split(';')[-1].strip()]
def pathFromIndex(self, index):
"""Perform autocompletion (reimplemented QCompleter method)"""
autoString = unicode(
autoString = str(
index.data(QtCore.Qt.ItemDataRole.EditRole).toString().toUtf8(), 'utf-8')
text = unicode(self.widget().text().toUtf8(), 'utf-8')
text = str(self.widget().text().toUtf8(), 'utf-8')
# If cursor position was saved, restore it, else save it
if self.cursorPos != -1:

View File

@ -125,12 +125,12 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
self.labelBytesRecvCount.setText(
_translate(
"networkstatus",
"Down: %1/s Total: %2").arg(
"Down: {0}/s Total: {1}").format(
self.formatByteRate(network.stats.downloadSpeed()),
self.formatBytes(network.stats.receivedBytes())))
self.labelBytesSentCount.setText(
_translate(
"networkstatus", "Up: %1/s Total: %2").arg(
"networkstatus", "Up: {0}/s Total: {1}").format(
self.formatByteRate(network.stats.uploadSpeed()),
self.formatBytes(network.stats.sentBytes())))
@ -160,19 +160,19 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
self.tableWidgetConnectionCount.insertRow(0)
self.tableWidgetConnectionCount.setItem(
0, 0,
QtGui.QTableWidgetItem("%s:%i" % (destination.host, destination.port))
QtWidgets.QTableWidgetItem("%s:%i" % (destination.host, destination.port))
)
self.tableWidgetConnectionCount.setItem(
0, 2,
QtGui.QTableWidgetItem("%s" % (c.userAgent))
QtWidgets.QTableWidgetItem("%s" % (c.userAgent))
)
self.tableWidgetConnectionCount.setItem(
0, 3,
QtGui.QTableWidgetItem("%s" % (c.tlsVersion))
QtWidgets.QTableWidgetItem("%s" % (c.tlsVersion))
)
self.tableWidgetConnectionCount.setItem(
0, 4,
QtGui.QTableWidgetItem("%s" % (",".join(map(str, c.streams))))
QtWidgets.QTableWidgetItem("%s" % (",".join(map(str, c.streams))))
)
try:
# .. todo:: FIXME: hard coded stream no
@ -181,23 +181,23 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
rating = "-"
self.tableWidgetConnectionCount.setItem(
0, 1,
QtGui.QTableWidgetItem("%s" % (rating))
QtWidgets.QTableWidgetItem("%s" % (rating))
)
if outbound:
brush = QtGui.QBrush(QtGui.QColor("yellow"), QtCore.Qt.SolidPattern)
brush = QtGui.QBrush(QtGui.QColor("yellow"), QtCore.Qt.BrushStyle.SolidPattern)
else:
brush = QtGui.QBrush(QtGui.QColor("green"), QtCore.Qt.SolidPattern)
brush = QtGui.QBrush(QtGui.QColor("green"), QtCore.Qt.BrushStyle.SolidPattern)
for j in range(1):
self.tableWidgetConnectionCount.item(0, j).setBackground(brush)
self.tableWidgetConnectionCount.item(0, 0).setData(QtCore.Qt.UserRole, destination)
self.tableWidgetConnectionCount.item(0, 1).setData(QtCore.Qt.UserRole, outbound)
self.tableWidgetConnectionCount.item(0, 0).setData(QtCore.Qt.ItemDataRole.UserRole, destination)
self.tableWidgetConnectionCount.item(0, 1).setData(QtCore.Qt.ItemDataRole.UserRole, outbound)
else:
if not connectionpool.pool.inboundConnections:
self.window().setStatusIcon('yellow')
for i in range(self.tableWidgetConnectionCount.rowCount()):
if self.tableWidgetConnectionCount.item(i, 0).data(QtCore.Qt.UserRole).toPyObject() != destination:
if self.tableWidgetConnectionCount.item(i, 0).data(QtCore.Qt.ItemDataRole.UserRole).toPyObject() != destination:
continue
if self.tableWidgetConnectionCount.item(i, 1).data(QtCore.Qt.UserRole).toPyObject() == outbound:
if self.tableWidgetConnectionCount.item(i, 1).data(QtCore.Qt.ItemDataRole.UserRole).toPyObject() == outbound:
self.tableWidgetConnectionCount.removeRow(i)
break
@ -205,7 +205,7 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
self.tableWidgetConnectionCount.setSortingEnabled(True)
self.labelTotalConnections.setText(
_translate(
"networkstatus", "Total Connections: %1").arg(
"networkstatus", "Total Connections: {0}").format(
str(self.tableWidgetConnectionCount.rowCount())))
# FYI: The 'singlelistener' thread sets the icon color to green when it
# receives an incoming connection, meaning that the user's firewall is
@ -218,7 +218,7 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
# timer driven
def runEveryTwoSeconds(self):
"""Updates counters, runs every 2 seconds if the timer is running"""
self.labelLookupsPerSecond.setText(_translate("networkstatus", "Inventory lookups per second: %1").arg(
self.labelLookupsPerSecond.setText(_translate("networkstatus", "Inventory lookups per second: {0}").format(
str(state.Inventory.numberOfInventoryLookupsPerformed / 2)))
state.Inventory.numberOfInventoryLookupsPerformed = 0
self.updateNumberOfBytes()
@ -229,11 +229,11 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
super(NetworkStatus, self).retranslateUi()
self.labelTotalConnections.setText(
_translate(
"networkstatus", "Total Connections: %1").arg(
"networkstatus", "Total Connections: {0}").format(
str(self.tableWidgetConnectionCount.rowCount())))
self.labelStartupTime.setText(_translate(
"networkstatus", "Since startup on %1"
).arg(l10n.formatTimestamp(self.startup)))
"networkstatus", "Since startup on {0}"
).format(l10n.formatTimestamp(self.startup)))
self.updateNumberOfMessagesProcessed()
self.updateNumberOfBroadcastsProcessed()
self.updateNumberOfPubkeysProcessed()

View File

@ -1,17 +1,17 @@
from os import path
from PyQt6 import QtGui
from PyQt6 import QtGui, QtWidgets
from debug import logger
import bitmessageqt.widgets
import bitmessageqt.widgets as widgets
class RetranslateMixin(object):
def retranslateUi(self):
defaults = QtGui.QWidget()
defaults = QtWidgets.QWidget()
widgets.load(self.__class__.__name__.lower() + '.ui', defaults)
for attr, value in defaults.__dict__.iteritems():
for attr, value in defaults.__dict__.items():
setTextMethod = getattr(value, "setText", None)
if callable(setTextMethod):
getattr(self, attr).setText(getattr(defaults, attr).text())
elif isinstance(value, QtGui.QTableWidget):
elif isinstance(value, QtWidgets.QTableWidget):
for i in range (value.columnCount()):
getattr(self, attr).horizontalHeaderItem(i).setText(
getattr(defaults, attr).horizontalHeaderItem(i).text())

View File

@ -163,7 +163,7 @@ class SettingsDialog(QtWidgets.QDialog):
self.comboBoxProxyTypeChanged(self.comboBoxProxyType.currentIndex())
if self._proxy_type:
for node, info in six.iteritems(
for node, info in six.items(
knownnodes.knownNodes.get(
min(state.streamsInWhichIAmParticipating), [])
):

View File

@ -43,69 +43,51 @@ class UISignaler(QThread):
command, data = queues.UISignalQueue.get()
if command == 'writeNewAddressToTable':
label, address, streamNumber = data
self.emit(
SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
label,
address,
str(streamNumber))
self.writeNewAddressToTable.emit(label, address, str(streamNumber))
elif command == 'updateStatusBar':
self.updateStatusBar.emit(data)
elif command == 'updateSentItemStatusByToAddress':
toAddress, message = data
self.emit(SIGNAL(
"updateSentItemStatusByToAddress(PyQt_PyObject,PyQt_PyObject)"), toAddress, message)
self.updateSentItemStatusByToAddress.emit(toAddress, message)
elif command == 'updateSentItemStatusByAckdata':
ackData, message = data
self.emit(SIGNAL(
"updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), ackData, message)
self.updateSentItemStatusByAckdata.emit(ackData, message)
elif command == 'displayNewInboxMessage':
inventoryHash, toAddress, fromAddress, subject, body = data
self.emit(SIGNAL(
"displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
inventoryHash, toAddress, fromAddress, subject, body)
self.displayNewInboxMessage.emit(inventoryHash, toAddress, fromAddress, subject, body)
elif command == 'displayNewSentMessage':
toAddress, fromLabel, fromAddress, subject, message, ackdata = data
self.emit(SIGNAL(
"displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
toAddress, fromLabel, fromAddress, subject, message, ackdata)
self.displayNewSentMessage.emit(toAddress, fromLabel, fromAddress, subject, message, ackdata)
elif command == 'updateNetworkStatusTab':
outbound, add, destination = data
self.emit(
SIGNAL("updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
outbound,
add,
destination)
self.updateNetworkStatusTab.emit(outbound, add, destination)
elif command == 'updateNumberOfMessagesProcessed':
self.emit(SIGNAL("updateNumberOfMessagesProcessed()"))
self.updateNumberOfMessagesProcessed.emit()
elif command == 'updateNumberOfPubkeysProcessed':
self.emit(SIGNAL("updateNumberOfPubkeysProcessed()"))
self.updateNumberOfPubkeysProcessed.emit()
elif command == 'updateNumberOfBroadcastsProcessed':
self.emit(SIGNAL("updateNumberOfBroadcastsProcessed()"))
self.updateNumberOfBroadcastsProcessed.emit()
elif command == 'setStatusIcon':
self.emit(SIGNAL("setStatusIcon(PyQt_PyObject)"), data)
self.setStatusIcon.emit(data)
elif command == 'changedInboxUnread':
self.emit(SIGNAL("changedInboxUnread(PyQt_PyObject)"), data)
self.changedInboxUnread.emit(data)
elif command == 'rerenderMessagelistFromLabels':
self.emit(SIGNAL("rerenderMessagelistFromLabels()"))
self.rerenderMessagelistFromLabels.emit()
elif command == 'rerenderMessagelistToLabels':
self.emit(SIGNAL("rerenderMessagelistToLabels()"))
self.rerenderMessagelistToLabels.emit()
elif command == 'rerenderAddressBook':
self.emit(SIGNAL("rerenderAddressBook()"))
self.rerenderAddressBook.emit()
elif command == 'rerenderSubscriptions':
self.emit(SIGNAL("rerenderSubscriptions()"))
self.rerenderSubscriptions.emit()
elif command == 'rerenderBlackWhiteList':
self.emit(SIGNAL("rerenderBlackWhiteList()"))
self.rerenderBlackWhiteList.emit()
elif command == 'removeInboxRowByMsgid':
self.emit(SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"), data)
self.removeInboxRowByMsgid.emit(data)
elif command == 'newVersionAvailable':
self.emit(SIGNAL("newVersionAvailable(PyQt_PyObject)"), data)
self.newVersionAvailable.emit(data)
elif command == 'alert':
title, text, exitAfterUserClicksOk = data
self.emit(
SIGNAL("displayAlert(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)"),
title,
text,
exitAfterUserClicksOk)
self.displayAlert.emit(title, text, exitAfterUserClicksOk)
else:
sys.stderr.write(
'Command sent to UISignaler not recognized: %s\n' % command)

View File

@ -38,7 +38,7 @@ def identiconize(address):
# stripped from PIL and uses QT instead (by sendiulo, same license)
import qidenticon
icon_hash = hashlib.md5(
addBMIfNotPresent(address) + identiconsuffix).hexdigest()
(addBMIfNotPresent(address) + identiconsuffix).encode()).hexdigest()
use_two_colors = identicon_lib[:len('qidenticon_two')] == 'qidenticon_two'
opacity = int(
identicon_lib not in (
@ -51,7 +51,7 @@ def identiconize(address):
# filename = './images/identicons/'+hash+'.png'
# image.save(filename)
idcon = QtGui.QIcon()
idcon.addPixmap(image, QtGui.QIcon.Normal, QtGui.QIcon.Off)
idcon.addPixmap(image, QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
return idcon
elif identicon_lib == 'pydenticon':
# Here you could load pydenticon.py
@ -81,7 +81,7 @@ def avatarize(address):
falls back to identiconize(address)
"""
idcon = QtGui.QIcon()
icon_hash = hashlib.md5(addBMIfNotPresent(address)).hexdigest()
icon_hash = hashlib.md5(addBMIfNotPresent(address).encode()).hexdigest()
if address == str_broadcast_subscribers:
# don't hash [Broadcast subscribers]
icon_hash = address

View File

@ -1511,4 +1511,4 @@ class singleWorker(StoppableThread):
payload = self._doPOWDefaults(
payload, TTL, log_prefix='(For ack message)', log_time=True)
return protocol.CreatePacket('object', payload)
return protocol.CreatePacket(b'object', payload)

View File

@ -12,7 +12,7 @@ def start(config, state):
"""Start network threads"""
import state
from .announcethread import AnnounceThread
import network.connectionpool # pylint: disable=relative-import
import network.connectionpool as connectionpool # pylint: disable=relative-import
from .addrthread import AddrThread
from .dandelion import Dandelion
from .downloadthread import DownloadThread

View File

@ -5,7 +5,7 @@ from six.moves import queue
# magic imports!
import state
import network.connectionpool
import network.connectionpool as connectionpool
from helper_random import randomshuffle
from protocol import assembleAddrMessage
from queues import addrQueue # FIXME: init with queue

View File

@ -723,20 +723,21 @@ class dispatcher(object):
if why.args[0] not in (ENOTCONN, EBADF):
raise
# XXX unresolved
# cheap inheritance, used to pass all other attribute
# references to the underlying socket object.
def __getattr__(self, attr):
try:
retattr = getattr(self.socket, attr)
except AttributeError:
raise AttributeError(
"%s instance has no attribute '%s'"
% (self.__class__.__name__, attr))
else:
msg = "%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s"\
" instead" % {'me': self.__class__.__name__, 'attr': attr}
warnings.warn(msg, DeprecationWarning, stacklevel=2)
return retattr
#def __getattr__(self, attr):
# try:
# retattr = getattr(self.socket, attr)
# except AttributeError:
# raise AttributeError(
# "%s instance has no attribute '%s'"
# % (self.__class__.__name__, attr))
# else:
# msg = "%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s"\
# " instead" % {'me': self.__class__.__name__, 'attr': attr}
# warnings.warn(msg, DeprecationWarning, stacklevel=2)
# return retattr
# log and log_info may be overridden to provide more sophisticated
# logging and warning methods. In general, log is for 'hit' logging

View File

@ -12,10 +12,10 @@ import time
# magic imports!
import addresses
import network.knownnodes
import network.knownnodes as knownnodes
import protocol
import state
import network.connectionpool
import network.connectionpool as connectionpool
from bmconfigparser import config
from queues import invQueue, objectProcessorQueue, portCheckerQueue
from randomtrackingdict import RandomTrackingDict
@ -82,7 +82,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
"""Process incoming header"""
self.magic, self.command, self.payloadLength, self.checksum = \
protocol.Header.unpack(self.read_buf[:protocol.Header.size])
self.command = self.command.rstrip('\x00')
self.command = self.command.rstrip(b'\x00')
if self.magic != protocol.magic:
# skip 1 byte in order to sync
self.set_state("bm_header", length=1)
@ -107,18 +107,18 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
self.invalid = True
retval = True
if not self.fullyEstablished and self.command not in (
"error", "version", "verack"):
b"error", b"version", b"verack"):
logger.error(
'Received command %s before connection was fully'
' established, ignoring', self.command)
' established, ignoring', self.command.decode())
self.invalid = True
if not self.invalid:
try:
retval = getattr(
self, "bm_command_" + str(self.command).lower())()
self, "bm_command_" + self.command.decode().lower())()
except AttributeError:
# unimplemented command
logger.debug('unimplemented command %s', self.command)
logger.debug('unimplemented command %s', self.command.decode())
except BMProtoInsufficientDataError:
logger.debug('packet length too short, skipping')
except BMProtoExcessiveDataError:
@ -141,8 +141,8 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
# broken read, ignore
pass
else:
logger.debug('Closing due to invalid command %s', self.command)
self.close_reason = "Invalid command %s" % self.command
logger.debug('Closing due to invalid command %s', self.command.decode())
self.close_reason = "Invalid command %s" % self.command.decode()
self.set_state("close")
return False
if retval:
@ -168,17 +168,17 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
"""Decode node details from the payload"""
# protocol.checkIPAddress()
services, host, port = self.decode_payload_content("Q16sH")
if host[0:12] == '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF':
host = socket.inet_ntop(socket.AF_INET, str(host[12:16]))
elif host[0:6] == '\xfd\x87\xd8\x7e\xeb\x43':
if host[0:12] == b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF':
host = socket.inet_ntop(socket.AF_INET, host[12:16])
elif host[0:6] == b'\xfd\x87\xd8\x7e\xeb\x43':
# Onion, based on BMD/bitcoind
host = base64.b32encode(host[6:]).lower() + ".onion"
host = base64.b32encode(host[6:]).lower() + b".onion"
else:
host = socket.inet_ntop(socket.AF_INET6, str(host))
if host == "":
host = socket.inet_ntop(socket.AF_INET6, host)
if host == b"":
# This can happen on Windows systems which are not 64-bit
# compatible so let us drop the IPv6 address.
host = socket.inet_ntop(socket.AF_INET, str(host[12:16]))
host = socket.inet_ntop(socket.AF_INET, host[12:16])
return Node(services, host, port)
@ -443,13 +443,16 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
"""Incoming addresses, process them"""
# not using services
for seenTime, stream, _, ip, port in self._decode_addr():
ip = str(ip)
if (
stream not in state.streamsInWhichIAmParticipating
# FIXME: should check against complete list
or ip.startswith('bootstrap')
):
if (stream not in state.streamsInWhichIAmParticipating):
continue
try:
if (
# FIXME: should check against complete list
ip.decode().startswith('bootstrap')
):
continue
except UnicodeDecodeError:
pass
decodedIP = protocol.checkIPAddress(ip)
if (
decodedIP and time.time() - seenTime > 0
@ -477,7 +480,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
def bm_command_ping(self):
"""Incoming ping, respond to it."""
self.append_write_buf(protocol.CreatePacket('pong'))
self.append_write_buf(protocol.CreatePacket(b'pong'))
return True
@staticmethod
@ -531,12 +534,12 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
if not self.peerValidityChecks():
# ABORT afterwards
return True
self.append_write_buf(protocol.CreatePacket('verack'))
self.append_write_buf(protocol.CreatePacket(b'verack'))
self.verackSent = True
ua_valid = re.match(
r'^/[a-zA-Z]+:[0-9]+\.?[\w\s\(\)\./:;-]*/$', self.userAgent)
r'^/[a-zA-Z]+:[0-9]+\.?[\w\s\(\)\./:;-]*/$', self.userAgent.decode())
if not ua_valid:
self.userAgent = '/INVALID:0/'
self.userAgent = b'/INVALID:0/'
if not self.isOutbound:
self.append_write_buf(protocol.assembleVersionMessage(
self.destination.host, self.destination.port,

View File

@ -5,7 +5,7 @@ Select which node to connect to
import logging
import random
import network.knownnodes
import network.knownnodes as knownnodes
import protocol
import state
from bmconfigparser import config
@ -45,7 +45,7 @@ def chooseConnection(stream):
return getDiscoveredPeer()
for _ in range(50):
peer = random.choice( # nosec B311
knownnodes.knownNodes[stream].keys())
list(knownnodes.knownNodes[stream].keys()))
try:
peer_info = knownnodes.knownNodes[stream][peer]
if peer_info.get('self'):

View File

@ -10,7 +10,7 @@ import time
import network.asyncore_pollchoose as asyncore
import helper_random
import network.knownnodes
import network.knownnodes as knownnodes
import protocol
import state
from bmconfigparser import config
@ -382,14 +382,14 @@ class BMConnectionPool(object):
minTx -= 300 - 20
if i.lastTx < minTx:
if i.fullyEstablished:
i.append_write_buf(protocol.CreatePacket('ping'))
i.append_write_buf(protocol.CreatePacket(b'ping'))
else:
i.close_reason = "Timeout (%is)" % (
time.time() - i.lastTx)
i.set_state("close")
for i in (
self.connections()
+ self.listeningSockets.values() + self.udpSockets.values()
+ list(self.listeningSockets.values()) + list(self.udpSockets.values())
):
if not (i.accepting or i.connecting or i.connected):
reaper.append(i)

View File

@ -7,7 +7,7 @@ from random import choice, expovariate, sample
from threading import RLock
from time import time
import network.connectionpool
import network.connectionpool as connectionpool
import state
from queues import invQueue

View File

@ -6,7 +6,7 @@ import state
import addresses
import helper_random
import protocol
import network.connectionpool
import network.connectionpool as connectionpool
from .objectracker import missingObjects
from .threads import StoppableThread
@ -71,7 +71,7 @@ class DownloadThread(StoppableThread):
if not chunkCount:
continue
payload[0:0] = addresses.encodeVarint(chunkCount)
i.append_write_buf(protocol.CreatePacket('getdata', payload))
i.append_write_buf(protocol.CreatePacket(b'getdata', payload))
self.logger.debug(
'%s:%i Requesting %i objects',
i.destination.host, i.destination.port, chunkCount)

View File

@ -8,7 +8,7 @@ from time import time
import addresses
import protocol
import state
import network.connectionpool
import network.connectionpool as connectionpool
from queues import invQueue
from .threads import StoppableThread
@ -90,13 +90,13 @@ class InvThread(StoppableThread):
if fluffs:
random.shuffle(fluffs)
connection.append_write_buf(protocol.CreatePacket(
'inv',
b'inv',
addresses.encodeVarint(
len(fluffs)) + ''.join(fluffs)))
if stems:
random.shuffle(stems)
connection.append_write_buf(protocol.CreatePacket(
'dinv',
b'dinv',
addresses.encodeVarint(
len(stems)) + ''.join(stems)))

View File

@ -3,7 +3,7 @@ A thread to handle network concerns
"""
import network.asyncore_pollchoose as asyncore
import state
import network.connectionpool
import network.connectionpool as connectionpool
from queues import excQueue
from .threads import StoppableThread

View File

@ -5,7 +5,7 @@ import time
from threading import RLock
import state
import network.connectionpool
import network.connectionpool as connectionpool
from randomtrackingdict import RandomTrackingDict
haveBloom = False

View File

@ -6,7 +6,7 @@ import queue
import socket
import state
import network.connectionpool
import network.connectionpool as connectionpool
from network.advanceddispatcher import UnknownStateError
from queues import receiveDataQueue
from .threads import StoppableThread

View File

@ -4,7 +4,7 @@ Network statistics
import time
import network.asyncore_pollchoose as asyncore
import network.connectionpool
import network.connectionpool as connectionpool
from .objectracker import missingObjects

View File

@ -15,14 +15,14 @@ import helper_random
import l10n
import protocol
import state
import network.connectionpool
import network.connectionpool as connectionpool
from bmconfigparser import config
from highlevelcrypto import randomBytes
from queues import invQueue, receiveDataQueue, UISignalQueue
from tr import _translate
import network.asyncore_pollchoose as asyncore
import network.knownnodes
import network.knownnodes as knownnodes
from network.advanceddispatcher import AdvancedDispatcher
from network.bmproto import BMProto
from network.objectracker import ObjectTracker
@ -180,6 +180,15 @@ class TCPConnection(BMProto, TLSDispatcher):
maxAddrCount = config.safeGetInt(
"bitmessagesettings", "maxaddrperstreamsend", 500)
def endsWith(s, tail):
try:
return s.endswith(tail)
except:
try:
return s.decode().endswith(tail)
except UnicodeDecodeError:
return False
templist = []
addrs = {}
for stream in self.streams:
@ -194,7 +203,7 @@ class TCPConnection(BMProto, TLSDispatcher):
(k, v) for k, v in nodes.items()
if v["lastseen"] > int(time.time())
- maximumAgeOfNodesThatIAdvertiseToOthers
and v["rating"] >= 0 and not k.host.endswith('.onion')
and v["rating"] >= 0 and not endsWith(k.host, '.onion')
]
# sent 250 only if the remote isn't interested in it
elemCount = min(
@ -220,7 +229,7 @@ class TCPConnection(BMProto, TLSDispatcher):
'Sending huge inv message with %i objects to just this'
' one peer', objectCount)
self.append_write_buf(protocol.CreatePacket(
'inv', addresses.encodeVarint(objectCount) + payload))
b'inv', addresses.encodeVarint(objectCount) + payload))
# Select all hashes for objects in this stream.
bigInvList = {}

View File

@ -49,7 +49,7 @@ class UploadThread(StoppableThread):
break
try:
payload.extend(protocol.CreatePacket(
'object', state.Inventory[chunk].payload))
b'object', state.Inventory[chunk].payload))
chunk_count += 1
except KeyError:
i.antiIntersectionDelay()

View File

@ -173,7 +173,7 @@ def checkIPAddress(host, private=False):
return checkIPv4Address(host[12:], hostStandardFormat, private)
elif host[0:6] == b'\xfd\x87\xd8\x7e\xeb\x43':
# Onion, based on BMD/bitcoind
hostStandardFormat = base64.b32encode(host[6:]).lower() + ".onion"
hostStandardFormat = base64.b32encode(host[6:]).lower() + b".onion"
if private:
return False
return hostStandardFormat
@ -250,6 +250,8 @@ def haveSSL(server=False):
python < 2.7.9's ssl library does not support ECDSA server due to
missing initialisation of available curves, but client works ok
"""
# XXX debug - disable TLS
return False
if not server:
return True
elif sys.version_info >= (2, 7, 9):

View File

@ -41,12 +41,7 @@ Returns an instance of :class:`QPixmap` which have generated identicon image.
"""
from six.moves import range
try:
from PyQt5 import QtCore, QtGui
except (ImportError, RuntimeError):
from PyQt4 import QtCore, QtGui
from PyQt6 import QtCore, QtGui
class IdenticonRendererBase(object):
"""Encapsulate methods around rendering identicons"""
@ -129,11 +124,13 @@ class IdenticonRendererBase(object):
QtCore.QPointF(size, size), QtCore.QPointF(0., size)]
rotation = [0, 90, 180, 270]
nopen = QtGui.QPen(foreColor, QtCore.Qt.NoPen)
foreBrush = QtGui.QBrush(foreColor, QtCore.Qt.SolidPattern)
nopen = QtGui.QPen(foreColor)
nopen.setStyle(QtCore.Qt.PenStyle.NoPen)
foreBrush = QtGui.QBrush(foreColor, QtCore.Qt.BrushStyle.SolidPattern)
if penwidth > 0:
pen_color = QtGui.QColor(255, 255, 255)
pen = QtGui.QPen(pen_color, QtCore.Qt.SolidPattern)
pen = QtGui.QPen(pen_color)
pen.setBrush(QtCore.Qt.BrushStyle.SolidPattern)
pen.setWidth(penwidth)
painter = QtGui.QPainter()
@ -153,10 +150,10 @@ class IdenticonRendererBase(object):
if penwidth > 0:
# draw the borders
painter.setPen(pen)
painter.drawPolygon(polygon, QtCore.Qt.WindingFill)
painter.drawPolygon(polygon, QtCore.Qt.FillRule.WindingFill)
# draw the fill
painter.setPen(nopen)
painter.drawPolygon(polygon, QtCore.Qt.WindingFill)
painter.drawPolygon(polygon, QtCore.Qt.FillRule.WindingFill)
painter.end()

View File

@ -23,7 +23,7 @@ def doCleanShutdown():
objectProcessorQueue.put(('checkShutdownVariable', 'no data'))
for thread in threading.enumerate():
if thread.isAlive() and isinstance(thread, StoppableThread):
if thread.is_alive() and isinstance(thread, StoppableThread):
thread.stopThread()
UISignalQueue.put((

View File

@ -33,7 +33,7 @@ class SqliteInventory(InventoryStorage):
return True
rows = sqlQuery(
'SELECT streamnumber FROM inventory WHERE hash=?',
sqlite3.Binary(hash_))
sqlite3.Binary(hash_.encode()))
if not rows:
return False
self._objects[hash_] = rows[0][0]
@ -44,8 +44,8 @@ class SqliteInventory(InventoryStorage):
if hash_ in self._inventory:
return self._inventory[hash_]
rows = sqlQuery(
'SELECT objecttype, streamnumber, payload, expirestime, tag'
' FROM inventory WHERE hash=?', sqlite3.Binary(hash_))
b'SELECT objecttype, streamnumber, payload, expirestime, tag'
b' FROM inventory WHERE hash=?', sqlite3.Binary(hash_.encode()))
if not rows:
raise KeyError(hash_)
return InventoryItem(*rows[0])

View File

@ -28,7 +28,7 @@ class translateClass:
return self.text
def _translate(context, text, disambiguation=None, encoding=None, n=None):
def _translate(context, text, disambiguation=None, n=None):
# pylint: disable=unused-argument
return translateText(context, text, n)
@ -52,7 +52,7 @@ def translateText(context, text, n=None):
os._exit(0) # pylint: disable=protected-access
if n is None:
return QtWidgets.QApplication.translate(context, text)
return QtGui.QApplication.translate(context, text, None, QtCore.QCoreApplication.CodecForTr, n)
return QtWidgets.QApplication.translate(context, text, None, n)
else:
if '%' in text:
return translateClass(context, text.replace('%', '', 1))