Added sending cancellation
This commit is contained in:
parent
c66156aeea
commit
ce4fe3a66b
|
@ -369,13 +369,16 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
# Popup menu for the Sent page
|
# Popup menu for the Sent page
|
||||||
self.ui.sentContextMenuToolbar = QtGui.QToolBar()
|
self.ui.sentContextMenuToolbar = QtGui.QToolBar()
|
||||||
# Actions
|
# Actions
|
||||||
self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction(
|
|
||||||
_translate(
|
|
||||||
"MainWindow", "Move to Trash"), self.on_action_SentTrash)
|
|
||||||
self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction(
|
self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction(
|
||||||
_translate(
|
_translate(
|
||||||
"MainWindow", "Copy destination address to clipboard"),
|
"MainWindow", "Copy destination address to clipboard"),
|
||||||
self.on_action_SentClipboard)
|
self.on_action_SentClipboard)
|
||||||
|
self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction(
|
||||||
|
_translate(
|
||||||
|
"MainWindow", "Move to Trash"), self.on_action_SentTrash)
|
||||||
|
self.actionCancelSending = self.ui.sentContextMenuToolbar.addAction(
|
||||||
|
_translate(
|
||||||
|
"MainWindow", "Cancel sending"), self.on_action_CancelSending)
|
||||||
self.actionForceSend = self.ui.sentContextMenuToolbar.addAction(
|
self.actionForceSend = self.ui.sentContextMenuToolbar.addAction(
|
||||||
_translate(
|
_translate(
|
||||||
"MainWindow", "Force send"), self.on_action_ForceSend)
|
"MainWindow", "Force send"), self.on_action_ForceSend)
|
||||||
|
@ -778,13 +781,15 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
"updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
|
"updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
"updateSentItemStatusByToAddress(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByToAddress)
|
"updateSentItemStatusByToAddress(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByToAddress)
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
"updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata)
|
"updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByAckdata)
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
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(
|
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(
|
||||||
|
"deleteSentItemByAckData(PyQt_PyObject)"), self.deleteSentItemByAckData)
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
"setStatusIcon(PyQt_PyObject)"), self.setStatusIcon)
|
"setStatusIcon(PyQt_PyObject)"), self.setStatusIcon)
|
||||||
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
|
||||||
|
@ -1102,6 +1107,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
elif status == 'ackreceived':
|
elif status == 'ackreceived':
|
||||||
statusText = _translate("MainWindow", "Acknowledgement of the message received %1").arg(
|
statusText = _translate("MainWindow", "Acknowledgement of the message received %1").arg(
|
||||||
l10n.formatTimestamp(lastactiontime))
|
l10n.formatTimestamp(lastactiontime))
|
||||||
|
elif status == "msgcanceled":
|
||||||
|
statusText = _translate("MainWindow", "Message canceled.")
|
||||||
elif status == 'broadcastqueued':
|
elif status == 'broadcastqueued':
|
||||||
statusText = _translate(
|
statusText = _translate(
|
||||||
"MainWindow", "Broadcast queued.")
|
"MainWindow", "Broadcast queued.")
|
||||||
|
@ -1111,6 +1118,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
elif status == 'broadcastsent':
|
elif status == 'broadcastsent':
|
||||||
statusText = _translate("MainWindow", "Broadcast on %1").arg(
|
statusText = _translate("MainWindow", "Broadcast on %1").arg(
|
||||||
l10n.formatTimestamp(lastactiontime))
|
l10n.formatTimestamp(lastactiontime))
|
||||||
|
elif status == "broadcastcanceled":
|
||||||
|
statusText = _translate("MainWindow", "Broadcast canceled.")
|
||||||
elif status == 'toodifficult':
|
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))
|
l10n.formatTimestamp(lastactiontime))
|
||||||
|
@ -1764,7 +1773,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.unreadCount = count
|
self.unreadCount = count
|
||||||
return self.unreadCount
|
return self.unreadCount
|
||||||
|
|
||||||
def updateSentItemStatusByToAddress(self, toAddress, textToDisplay):
|
def updateSentItemStatusByToAddress(self, status, toAddress, textToDisplay):
|
||||||
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
|
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
|
||||||
treeWidget = self.widgetConvert(sent)
|
treeWidget = self.widgetConvert(sent)
|
||||||
if self.getCurrentFolder(treeWidget) != "sent":
|
if self.getCurrentFolder(treeWidget) != "sent":
|
||||||
|
@ -1775,6 +1784,16 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
for i in range(sent.rowCount()):
|
for i in range(sent.rowCount()):
|
||||||
rowAddress = sent.item(i, 0).data(QtCore.Qt.UserRole)
|
rowAddress = sent.item(i, 0).data(QtCore.Qt.UserRole)
|
||||||
if toAddress == rowAddress:
|
if toAddress == rowAddress:
|
||||||
|
tableAckData = str(sent.item(i, 3).data(QtCore.Qt.UserRole).toPyObject())
|
||||||
|
|
||||||
|
count = sqlQuery("""
|
||||||
|
SELECT COUNT(*) FROM "sent"
|
||||||
|
WHERE "ackdata" == ? AND "status" == ?;
|
||||||
|
""", tableAckData, status)[0][0]
|
||||||
|
|
||||||
|
if count == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
sent.item(i, 3).setToolTip(textToDisplay)
|
sent.item(i, 3).setToolTip(textToDisplay)
|
||||||
try:
|
try:
|
||||||
newlinePosition = textToDisplay.indexOf('\n')
|
newlinePosition = textToDisplay.indexOf('\n')
|
||||||
|
@ -1786,7 +1805,15 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
else:
|
else:
|
||||||
sent.item(i, 3).setText(textToDisplay)
|
sent.item(i, 3).setText(textToDisplay)
|
||||||
|
|
||||||
def updateSentItemStatusByAckdata(self, ackdata, textToDisplay):
|
def updateSentItemStatusByAckdata(self, status, ackdata, textToDisplay):
|
||||||
|
count = sqlQuery("""
|
||||||
|
SELECT COUNT(*) FROM "sent"
|
||||||
|
WHERE "ackdata" == ? AND "status" == ?;
|
||||||
|
""", ackdata, status)[0][0]
|
||||||
|
|
||||||
|
if count == 0:
|
||||||
|
return
|
||||||
|
|
||||||
if type(ackdata) is str:
|
if type(ackdata) is str:
|
||||||
ackdata = QtCore.QByteArray(ackdata)
|
ackdata = QtCore.QByteArray(ackdata)
|
||||||
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
|
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
|
||||||
|
@ -2356,6 +2383,37 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
dialogs.EmailGatewayDialog(
|
dialogs.EmailGatewayDialog(
|
||||||
self, BMConfigParser(), acct).exec_()
|
self, BMConfigParser(), acct).exec_()
|
||||||
|
|
||||||
|
def deleteSentItemByAckData(self, ackData):
|
||||||
|
ackData = QtCore.QByteArray(ackData)
|
||||||
|
|
||||||
|
for tableWidget in [
|
||||||
|
self.ui.tableWidgetInbox,
|
||||||
|
self.ui.tableWidgetInboxSubscriptions,
|
||||||
|
self.ui.tableWidgetInboxChans
|
||||||
|
]:
|
||||||
|
treeWidget = self.widgetConvert(tableWidget)
|
||||||
|
|
||||||
|
if self.getCurrentFolder(treeWidget) != "sent":
|
||||||
|
continue
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
while i < tableWidget.rowCount():
|
||||||
|
tableAckData = tableWidget.item(i, 3).data(QtCore.Qt.UserRole).toPyObject()
|
||||||
|
|
||||||
|
if ackData == tableAckData:
|
||||||
|
textEdit = self.getCurrentMessageTextedit()
|
||||||
|
|
||||||
|
if textEdit is not False:
|
||||||
|
textEdit.setPlainText("")
|
||||||
|
|
||||||
|
tableWidget.removeRow(i)
|
||||||
|
tableWidget.selectRow(max(0, i - 1))
|
||||||
|
|
||||||
|
self.updateStatusBar(_translate("MainWindow", "Moved items to trash."))
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
|
||||||
def click_pushButtonAddAddressBook(self, dialog=None):
|
def click_pushButtonAddAddressBook(self, dialog=None):
|
||||||
if not dialog:
|
if not dialog:
|
||||||
dialog = dialogs.AddAddressDialog(self)
|
dialog = dialogs.AddAddressDialog(self)
|
||||||
|
@ -3286,47 +3344,95 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
logger.exception('Message not saved', exc_info=True)
|
logger.exception('Message not saved', exc_info=True)
|
||||||
self.updateStatusBar(_translate("MainWindow", "Write error."))
|
self.updateStatusBar(_translate("MainWindow", "Write error."))
|
||||||
|
|
||||||
# Send item on the Sent tab to trash
|
|
||||||
def on_action_SentTrash(self):
|
def on_action_SentTrash(self):
|
||||||
currentRow = 0
|
|
||||||
unread = False
|
|
||||||
tableWidget = self.getCurrentMessagelist()
|
tableWidget = self.getCurrentMessagelist()
|
||||||
|
|
||||||
if not tableWidget:
|
if not tableWidget:
|
||||||
return
|
return
|
||||||
folder = self.getCurrentFolder()
|
|
||||||
shifted = (QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier) > 0
|
|
||||||
while tableWidget.selectedIndexes() != []:
|
|
||||||
currentRow = tableWidget.selectedIndexes()[0].row()
|
|
||||||
ackdataToTrash = str(tableWidget.item(
|
|
||||||
currentRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
|
||||||
if folder == "trash" or shifted:
|
|
||||||
sqlExecute('''DELETE FROM sent WHERE ackdata=?''', ackdataToTrash)
|
|
||||||
else:
|
|
||||||
sqlExecute('''UPDATE sent SET folder='trash' WHERE ackdata=?''', ackdataToTrash)
|
|
||||||
if tableWidget.item(currentRow, 0).unread:
|
|
||||||
self.propagateUnreadCount(tableWidget.item(currentRow, 1 if tableWidget.item(currentRow, 1).type == AccountMixin.SUBSCRIPTION else 0).data(QtCore.Qt.UserRole), folder, self.getCurrentTreeWidget(), -1)
|
|
||||||
self.getCurrentMessageTextedit().setPlainText("")
|
|
||||||
tableWidget.removeRow(currentRow)
|
|
||||||
self.updateStatusBar(_translate(
|
|
||||||
"MainWindow", "Moved items to trash."))
|
|
||||||
|
|
||||||
self.ui.tableWidgetInbox.selectRow(
|
shiftPressed = QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier != 0
|
||||||
currentRow if currentRow == 0 else currentRow - 1)
|
folder = self.getCurrentFolder()
|
||||||
|
trash = not (folder == "trash" or shiftPressed)
|
||||||
|
|
||||||
|
for i in tableWidget.selectedIndexes():
|
||||||
|
if i.column() != 3:
|
||||||
|
continue
|
||||||
|
|
||||||
|
currentRow = i.row()
|
||||||
|
ackData = str(i.data(QtCore.Qt.UserRole).toPyObject())
|
||||||
|
|
||||||
|
queryReturn = sqlQuery("""SELECT "status" FROM "sent" WHERE "ackdata" == ?;""", ackData)
|
||||||
|
|
||||||
|
if len(queryReturn) == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
status = queryReturn[0][0]
|
||||||
|
|
||||||
|
if status in ["broadcastqueued", "doingbroadcastpow", "broadcastsent", "broadcastcanceled"]:
|
||||||
|
queues.workerQueue.put(("cancelBroadcast", ackData, True, trash))
|
||||||
|
else:
|
||||||
|
queues.workerQueue.put(("cancelMessage", ackData, True, trash))
|
||||||
|
|
||||||
|
def on_action_CancelSending(self):
|
||||||
|
tableWidget = self.getCurrentMessagelist()
|
||||||
|
|
||||||
|
if not tableWidget:
|
||||||
|
return
|
||||||
|
|
||||||
|
for i in tableWidget.selectedIndexes():
|
||||||
|
if i.column() != 3:
|
||||||
|
continue
|
||||||
|
|
||||||
|
currentRow = i.row()
|
||||||
|
ackData = str(i.data(QtCore.Qt.UserRole).toPyObject())
|
||||||
|
|
||||||
|
queryReturn = sqlQuery("""SELECT "status" FROM "sent" WHERE "ackdata" == ?;""", ackData)
|
||||||
|
|
||||||
|
if len(queryReturn) == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
status = queryReturn[0][0]
|
||||||
|
|
||||||
|
if status in ["broadcastqueued", "doingbroadcastpow"]:
|
||||||
|
queues.workerQueue.put(("cancelBroadcast", ackData, False, None))
|
||||||
|
elif status not in ["ackreceived", "msgsentnoackexpected", "badkey", "msgcanceled"]:
|
||||||
|
queues.workerQueue.put(("cancelMessage", ackData, False, None))
|
||||||
|
|
||||||
def on_action_ForceSend(self):
|
def on_action_ForceSend(self):
|
||||||
currentRow = self.ui.tableWidgetInbox.currentRow()
|
tableWidget = self.getCurrentMessagelist()
|
||||||
addressAtCurrentRow = self.ui.tableWidgetInbox.item(
|
|
||||||
currentRow, 0).data(QtCore.Qt.UserRole)
|
if not tableWidget:
|
||||||
toRipe = decodeAddress(addressAtCurrentRow)[3]
|
return
|
||||||
sqlExecute(
|
|
||||||
'''UPDATE sent SET status='forcepow' WHERE toripe=? AND status='toodifficult' and folder='sent' ''',
|
resendMessages = False
|
||||||
toRipe)
|
|
||||||
queryreturn = sqlQuery('''select ackdata FROM sent WHERE status='forcepow' ''')
|
for i in tableWidget.selectedIndexes():
|
||||||
for row in queryreturn:
|
if i.column() != 3:
|
||||||
ackdata, = row
|
continue
|
||||||
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
|
||||||
ackdata, 'Overriding maximum-difficulty setting. Work queued.')))
|
ackData = str(i.data(QtCore.Qt.UserRole).toPyObject())
|
||||||
queues.workerQueue.put(('sendmessage', ''))
|
|
||||||
|
queryReturn = sqlQuery("""SELECT "status" FROM "sent" WHERE "ackdata" == ?;""", ackData)
|
||||||
|
|
||||||
|
if len(queryReturn) == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if queryReturn[0][0] == "toodifficult":
|
||||||
|
sqlExecute("""
|
||||||
|
UPDATE "sent" SET "status" = 'forcepow'
|
||||||
|
WHERE "ackdata" == ? AND "status" == 'toodifficult' AND "folder" = 'sent';
|
||||||
|
""", ackData)
|
||||||
|
|
||||||
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"forcepow",
|
||||||
|
ackData,
|
||||||
|
"Overriding maximum-difficulty setting. Work queued." # TODO: add translation?
|
||||||
|
)))
|
||||||
|
|
||||||
|
resendMessages = True
|
||||||
|
|
||||||
|
if resendMessages:
|
||||||
|
queues.workerQueue.put(("sendmessage", ))
|
||||||
|
|
||||||
def on_action_SentClipboard(self):
|
def on_action_SentClipboard(self):
|
||||||
currentRow = self.ui.tableWidgetInbox.currentRow()
|
currentRow = self.ui.tableWidgetInbox.currentRow()
|
||||||
|
@ -3988,23 +4094,51 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.popMenuInbox.exec_(tableWidget.mapToGlobal(point))
|
self.popMenuInbox.exec_(tableWidget.mapToGlobal(point))
|
||||||
|
|
||||||
def on_context_menuSent(self, point):
|
def on_context_menuSent(self, point):
|
||||||
|
tableWidget = self.getCurrentMessagelist()
|
||||||
|
|
||||||
|
if not tableWidget:
|
||||||
|
return
|
||||||
|
|
||||||
|
showMenu = False
|
||||||
|
cancelSending = False
|
||||||
|
forceSend = False
|
||||||
|
|
||||||
|
for i in tableWidget.selectedIndexes():
|
||||||
|
if i.column() != 3:
|
||||||
|
continue
|
||||||
|
|
||||||
|
ackData = str(i.data(QtCore.Qt.UserRole).toPyObject())
|
||||||
|
|
||||||
|
queryReturn = sqlQuery("""SELECT "status" FROM "sent" WHERE "ackdata" == ?;""", ackData)
|
||||||
|
|
||||||
|
if len(queryReturn) == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
status = queryReturn[0][0]
|
||||||
|
|
||||||
|
if status not in [
|
||||||
|
"ackreceived", "msgsentnoackexpected", "badkey", "msgcanceled",
|
||||||
|
"broadcastsent", "broadcastcanceled"
|
||||||
|
]:
|
||||||
|
cancelSending = True
|
||||||
|
|
||||||
|
if status == "toodifficult":
|
||||||
|
forceSend = True
|
||||||
|
|
||||||
|
showMenu = True
|
||||||
|
|
||||||
|
if showMenu:
|
||||||
self.popMenuSent = QtGui.QMenu(self)
|
self.popMenuSent = QtGui.QMenu(self)
|
||||||
self.popMenuSent.addAction(self.actionSentClipboard)
|
self.popMenuSent.addAction(self.actionSentClipboard)
|
||||||
self.popMenuSent.addAction(self.actionTrashSentMessage)
|
self.popMenuSent.addAction(self.actionTrashSentMessage)
|
||||||
|
|
||||||
# Check to see if this item is toodifficult and display an additional
|
if cancelSending:
|
||||||
# menu option (Force Send) if it is.
|
self.popMenuSent.addAction(self.actionCancelSending)
|
||||||
currentRow = self.ui.tableWidgetInbox.currentRow()
|
|
||||||
if currentRow >= 0:
|
if forceSend:
|
||||||
ackData = str(self.ui.tableWidgetInbox.item(
|
|
||||||
currentRow, 3).data(QtCore.Qt.UserRole).toPyObject())
|
|
||||||
queryreturn = sqlQuery('''SELECT status FROM sent where ackdata=?''', ackData)
|
|
||||||
for row in queryreturn:
|
|
||||||
status, = row
|
|
||||||
if status == 'toodifficult':
|
|
||||||
self.popMenuSent.addAction(self.actionForceSend)
|
self.popMenuSent.addAction(self.actionForceSend)
|
||||||
|
|
||||||
self.popMenuSent.exec_(self.ui.tableWidgetInbox.mapToGlobal(point))
|
self.popMenuSent.exec_(tableWidget.mapToGlobal(point))
|
||||||
|
|
||||||
def inboxSearchLineEditUpdated(self, text):
|
def inboxSearchLineEditUpdated(self, text):
|
||||||
# dynamic search for too short text is slow
|
# dynamic search for too short text is slow
|
||||||
|
|
|
@ -26,14 +26,13 @@ class UISignaler(QThread):
|
||||||
"writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), label, address, str(streamNumber))
|
"writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), label, address, str(streamNumber))
|
||||||
elif command == 'updateStatusBar':
|
elif command == 'updateStatusBar':
|
||||||
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"), data)
|
self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"), data)
|
||||||
elif command == 'updateSentItemStatusByToAddress':
|
elif command == "updateSentItemStatusByToAddress":
|
||||||
toAddress, message = data
|
|
||||||
self.emit(SIGNAL(
|
self.emit(SIGNAL(
|
||||||
"updateSentItemStatusByToAddress(PyQt_PyObject,PyQt_PyObject)"), toAddress, message)
|
"updateSentItemStatusByToAddress(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), *data)
|
||||||
elif command == 'updateSentItemStatusByAckdata':
|
elif command == "updateSentItemStatusByAckdata":
|
||||||
ackData, message = data
|
status, address, message = data
|
||||||
self.emit(SIGNAL(
|
self.emit(SIGNAL(
|
||||||
"updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), ackData, message)
|
"updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), *data)
|
||||||
elif command == 'displayNewInboxMessage':
|
elif command == 'displayNewInboxMessage':
|
||||||
inventoryHash, toAddress, fromAddress, subject, body = data
|
inventoryHash, toAddress, fromAddress, subject, body = data
|
||||||
self.emit(SIGNAL(
|
self.emit(SIGNAL(
|
||||||
|
@ -44,6 +43,8 @@ class UISignaler(QThread):
|
||||||
self.emit(SIGNAL(
|
self.emit(SIGNAL(
|
||||||
"displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
|
"displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
|
||||||
toAddress, fromLabel, fromAddress, subject, message, ackdata)
|
toAddress, fromLabel, fromAddress, subject, message, ackdata)
|
||||||
|
elif command == "deleteSentItemByAckData":
|
||||||
|
self.emit(SIGNAL("deleteSentItemByAckData(PyQt_PyObject)"), data)
|
||||||
elif command == 'updateNetworkStatusTab':
|
elif command == 'updateNetworkStatusTab':
|
||||||
outbound, add, destination = data
|
outbound, add, destination = data
|
||||||
self.emit(SIGNAL("updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), outbound, add, destination)
|
self.emit(SIGNAL("updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), outbound, add, destination)
|
||||||
|
|
|
@ -131,6 +131,7 @@ class objectProcessor(threading.Thread):
|
||||||
""", int(time.time()), ackData)
|
""", int(time.time()), ackData)
|
||||||
|
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"ackreceived",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -1041,6 +1042,7 @@ class objectProcessor(threading.Thread):
|
||||||
|
|
||||||
for i, in queued:
|
for i, in queued:
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"msgqueued",
|
||||||
i,
|
i,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
|
|
@ -60,6 +60,7 @@ def resendStaleMessages():
|
||||||
""", ackData)
|
""", ackData)
|
||||||
|
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"msgqueued",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
|
|
@ -42,10 +42,10 @@ class smtpDeliver(threading.Thread, StoppableThread):
|
||||||
elif command == 'updateStatusBar':
|
elif command == 'updateStatusBar':
|
||||||
pass
|
pass
|
||||||
elif command == 'updateSentItemStatusByToAddress':
|
elif command == 'updateSentItemStatusByToAddress':
|
||||||
toAddress, message = data
|
status, toAddress, message = data
|
||||||
pass
|
pass
|
||||||
elif command == 'updateSentItemStatusByAckdata':
|
elif command == 'updateSentItemStatusByAckdata':
|
||||||
ackData, message = data
|
status, ackData, message = data
|
||||||
pass
|
pass
|
||||||
elif command == 'displayNewInboxMessage':
|
elif command == 'displayNewInboxMessage':
|
||||||
inventoryHash, toAddress, fromAddress, subject, body = data
|
inventoryHash, toAddress, fromAddress, subject, body = data
|
||||||
|
|
|
@ -38,10 +38,14 @@ import workprover
|
||||||
# | +-> toodifficult --> forcepow -+
|
# | +-> toodifficult --> forcepow -+
|
||||||
# | |
|
# | |
|
||||||
# +--------------------------------+
|
# +--------------------------------+
|
||||||
|
#
|
||||||
|
# Can also be "msgcanceled"
|
||||||
|
|
||||||
# Broadcast status flow:
|
# Broadcast status flow:
|
||||||
#
|
#
|
||||||
# broadcastqueued --> doingbroadcastpow --> broadcastsent
|
# broadcastqueued --> doingbroadcastpow --> broadcastsent
|
||||||
|
#
|
||||||
|
# Can also be "broadcastcanceled"
|
||||||
|
|
||||||
# TODO: queued pubkey messages are not saved to the database, they disappear when the client is closed
|
# TODO: queued pubkey messages are not saved to the database, they disappear when the client is closed
|
||||||
|
|
||||||
|
@ -191,6 +195,7 @@ def getDestinationAddressProperties(address):
|
||||||
|
|
||||||
for i, in queued:
|
for i, in queued:
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"msgqueued",
|
||||||
i,
|
i,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -282,8 +287,12 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
|
|
||||||
if command == "sendmessage":
|
if command == "sendmessage":
|
||||||
self.sendMessages()
|
self.sendMessages()
|
||||||
|
elif command == "cancelMessage":
|
||||||
|
self.cancelMessage(*arguments)
|
||||||
elif command == "sendbroadcast":
|
elif command == "sendbroadcast":
|
||||||
self.sendBroadcasts()
|
self.sendBroadcasts()
|
||||||
|
elif command == "cancelBroadcast":
|
||||||
|
self.cancelBroadcast(*arguments)
|
||||||
elif command == "sendMyPubkey":
|
elif command == "sendMyPubkey":
|
||||||
self.sendMyPubkey(*arguments)
|
self.sendMyPubkey(*arguments)
|
||||||
elif command == "requestPubkey":
|
elif command == "requestPubkey":
|
||||||
|
@ -316,6 +325,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
def workDone(self, ID, nonce, expiryTime):
|
def workDone(self, ID, nonce, expiryTime):
|
||||||
debug.logger.info("Found proof of work %s", ID)
|
debug.logger.info("Found proof of work %s", ID)
|
||||||
|
|
||||||
|
if ID in self.startedWorks:
|
||||||
self.startedWorks[ID](nonce, expiryTime)
|
self.startedWorks[ID](nonce, expiryTime)
|
||||||
|
|
||||||
del self.startedWorks[ID]
|
del self.startedWorks[ID]
|
||||||
|
@ -426,6 +436,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
addressProperties = getMyAddressProperties(address)
|
addressProperties = getMyAddressProperties(address)
|
||||||
except:
|
except:
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"broadcastqueued",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -527,6 +538,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
""", inventoryHash, int(time.time()), ackData)
|
""", inventoryHash, int(time.time()), ackData)
|
||||||
|
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"broadcastsent",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate("MainWindow", "Broadcast sent on %1").arg(l10n.formatTimestamp())
|
tr._translate("MainWindow", "Broadcast sent on %1").arg(l10n.formatTimestamp())
|
||||||
)))
|
)))
|
||||||
|
@ -543,6 +555,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
helper_sql.sqlExecute("""UPDATE "sent" SET "status" = 'doingbroadcastpow' WHERE "ackdata" == ?;""", ackData)
|
helper_sql.sqlExecute("""UPDATE "sent" SET "status" = 'doingbroadcastpow' WHERE "ackdata" == ?;""", ackData)
|
||||||
|
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"doingbroadcastpow",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -569,6 +582,36 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
|
|
||||||
self.processBroadcast(*i)
|
self.processBroadcast(*i)
|
||||||
|
|
||||||
|
def cancelBroadcast(self, ackData, delete, trash):
|
||||||
|
ID = "broadcast", ackData
|
||||||
|
|
||||||
|
if ID in self.startedWorks:
|
||||||
|
del self.startedWorks[ID]
|
||||||
|
|
||||||
|
self.workProver.commandsQueue.put(("cancelTask", ID))
|
||||||
|
|
||||||
|
helper_sql.sqlExecute("""
|
||||||
|
UPDATE "sent" SET "status" = 'broadcastcanceled'
|
||||||
|
WHERE "ackdata" == ? AND "status" != 'broadcastsent';
|
||||||
|
""", ackData)
|
||||||
|
|
||||||
|
if delete:
|
||||||
|
if trash:
|
||||||
|
helper_sql.sqlExecute("""UPDATE "sent" SET "folder" = 'trash' WHERE "ackdata" == ?;""", ackData)
|
||||||
|
else:
|
||||||
|
helper_sql.sqlExecute("""DELETE FROM "sent" WHERE "ackdata" == ?""", ackData)
|
||||||
|
|
||||||
|
queues.UISignalQueue.put(("deleteSentItemByAckData", ackData))
|
||||||
|
else:
|
||||||
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"broadcastcanceled",
|
||||||
|
ackData,
|
||||||
|
tr._translate(
|
||||||
|
"MainWindow",
|
||||||
|
"Broadcast canceled."
|
||||||
|
)
|
||||||
|
)))
|
||||||
|
|
||||||
def generateAckMessage(self, ackData, stream, TTL, callback):
|
def generateAckMessage(self, ackData, stream, TTL, callback):
|
||||||
ID = "ack", ackData
|
ID = "ack", ackData
|
||||||
|
|
||||||
|
@ -616,6 +659,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
queues.workerQueue.put(("requestPubkey", destination))
|
queues.workerQueue.put(("requestPubkey", destination))
|
||||||
|
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"awaitingpubkey",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -634,6 +678,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
sourceProperties = getMyAddressProperties(source, defaultDifficulty)
|
sourceProperties = getMyAddressProperties(source, defaultDifficulty)
|
||||||
except:
|
except:
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"msgqueued",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -669,6 +714,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
helper_sql.sqlExecute("""UPDATE "sent" SET "status" = 'toodifficult' WHERE "ackdata" == ?;""", ackData)
|
helper_sql.sqlExecute("""UPDATE "sent" SET "status" = 'toodifficult' WHERE "ackdata" == ?;""", ackData)
|
||||||
|
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"toodifficult",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -733,6 +779,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
helper_sql.sqlExecute("""UPDATE "sent" SET "status" = 'badkey' WHERE "ackdata" == ?;""", ackData)
|
helper_sql.sqlExecute("""UPDATE "sent" SET "status" = 'badkey' WHERE "ackdata" == ?;""", ackData)
|
||||||
|
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"badkey",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -784,6 +831,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
|
|
||||||
if ackMessage is None:
|
if ackMessage is None:
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"msgsentnoackexpected",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -792,6 +840,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
)))
|
)))
|
||||||
else:
|
else:
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"msgsent",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -811,6 +860,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
|
|
||||||
if relativeByteDifficulty != 1 or relativeLengthExtension != 1:
|
if relativeByteDifficulty != 1 or relativeLengthExtension != 1:
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"doingmsgpow",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -819,6 +869,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
)))
|
)))
|
||||||
else:
|
else:
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"doingmsgpow",
|
||||||
ackData,
|
ackData,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -849,6 +900,75 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
|
|
||||||
self.processMessage(*i)
|
self.processMessage(*i)
|
||||||
|
|
||||||
|
def cancelMessage(self, ackData, delete, trash):
|
||||||
|
#multpubky
|
||||||
|
#neededkeys
|
||||||
|
|
||||||
|
ID = "ack", ackData
|
||||||
|
|
||||||
|
if ID in self.startedWorks:
|
||||||
|
del self.startedWorks[ID]
|
||||||
|
|
||||||
|
self.workProver.commandsQueue.put(("cancelTask", ID))
|
||||||
|
|
||||||
|
ID = "message", ackData
|
||||||
|
|
||||||
|
if ID in self.startedWorks:
|
||||||
|
del self.startedWorks[ID]
|
||||||
|
|
||||||
|
self.workProver.commandsQueue.put(("cancelTask", ID))
|
||||||
|
|
||||||
|
state.watchedAckData -= {ackData}
|
||||||
|
|
||||||
|
queryReturn = helper_sql.sqlQuery("""SELECT "toaddress" FROM "sent" WHERE "ackdata" == ?;""", ackData)
|
||||||
|
|
||||||
|
if len(queryReturn) != 0:
|
||||||
|
destination = queryReturn[0][0]
|
||||||
|
|
||||||
|
count = helper_sql.sqlQuery("""
|
||||||
|
SELECT COUNT(*) FROM "sent"
|
||||||
|
WHERE "status" IN ('doingpubkeypow', 'awaitingpubkey') AND "toaddress" == ? AND "ackdata" != ?;
|
||||||
|
""", destination, ackData)[0][0]
|
||||||
|
|
||||||
|
if count == 0:
|
||||||
|
ID = "getpubkey", destination
|
||||||
|
|
||||||
|
if ID in self.startedWorks:
|
||||||
|
del self.startedWorks[ID]
|
||||||
|
|
||||||
|
self.workProver.commandsQueue.put(("cancelTask", ID))
|
||||||
|
|
||||||
|
status, version, stream, ripe = addresses.decodeAddress(destination)
|
||||||
|
|
||||||
|
if version == 4:
|
||||||
|
secretEncryptionKey, tag = protocol.calculateAddressTag(version, stream, ripe)
|
||||||
|
|
||||||
|
state.neededPubkeys.pop(tag, None)
|
||||||
|
else:
|
||||||
|
state.neededPubkeys.pop(destination, None)
|
||||||
|
|
||||||
|
helper_sql.sqlExecute("""
|
||||||
|
UPDATE "sent" SET "status" = 'msgcanceled'
|
||||||
|
WHERE "ackdata" == ? AND "status" NOT IN ('ackreceived', 'msgsentnoackexpected', 'badkey');
|
||||||
|
""", ackData)
|
||||||
|
|
||||||
|
if delete:
|
||||||
|
if trash:
|
||||||
|
helper_sql.sqlExecute("""UPDATE "sent" SET "folder" = 'trash' WHERE "ackdata" == ?;""", ackData)
|
||||||
|
else:
|
||||||
|
helper_sql.sqlExecute("""DELETE FROM "sent" WHERE "ackdata" == ?""", ackData)
|
||||||
|
|
||||||
|
queues.UISignalQueue.put(("deleteSentItemByAckData", ackData))
|
||||||
|
else:
|
||||||
|
queues.UISignalQueue.put(("updateSentItemStatusByAckdata", (
|
||||||
|
"msgcanceled",
|
||||||
|
ackData,
|
||||||
|
tr._translate(
|
||||||
|
"MainWindow",
|
||||||
|
"Message canceled."
|
||||||
|
)
|
||||||
|
)))
|
||||||
|
|
||||||
def requestPubkey(self, address):
|
def requestPubkey(self, address):
|
||||||
ID = "getpubkey", address
|
ID = "getpubkey", address
|
||||||
|
|
||||||
|
@ -879,6 +999,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
""", currentExpiryTime, address)
|
""", currentExpiryTime, address)
|
||||||
|
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByToAddress", (
|
queues.UISignalQueue.put(("updateSentItemStatusByToAddress", (
|
||||||
|
"awaitingpubkey",
|
||||||
address,
|
address,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -912,6 +1033,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
""", sleepTill, int(time.time()), address)
|
""", sleepTill, int(time.time()), address)
|
||||||
|
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByToAddress", (
|
queues.UISignalQueue.put(("updateSentItemStatusByToAddress", (
|
||||||
|
"awaitingpubkey",
|
||||||
address,
|
address,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -925,6 +1047,7 @@ class singleWorker(threading.Thread, helper_threading.StoppableThread):
|
||||||
""", address)
|
""", address)
|
||||||
|
|
||||||
queues.UISignalQueue.put(("updateSentItemStatusByToAddress", (
|
queues.UISignalQueue.put(("updateSentItemStatusByToAddress", (
|
||||||
|
"doingpubkeypow",
|
||||||
address,
|
address,
|
||||||
tr._translate(
|
tr._translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
|
Reference in New Issue
Block a user