Remove inbox item from GUI when using API command trashMessage

This commit is contained in:
Jonathan Warren 2013-06-05 17:15:26 -04:00
parent 518fc68801
commit b6113369c6
2 changed files with 12 additions and 10 deletions

View File

@ -483,20 +483,12 @@ class receiveDataThread(threading.Thread):
hash, = row hash, = row
if hash not in self.objectsOfWhichThisRemoteNodeIsAlreadyAware: if hash not in self.objectsOfWhichThisRemoteNodeIsAlreadyAware:
bigInvList[hash] = 0 bigInvList[hash] = 0
else:
shared.printLock.acquire()
print 'Not including an object hash in a big inv message because the remote node is already aware of it.'#This line is here to check that this feature is working.
shared.printLock.release()
#We also have messages in our inventory in memory (which is a python dictionary). Let's fetch those too. #We also have messages in our inventory in memory (which is a python dictionary). Let's fetch those too.
for hash, storedValue in shared.inventory.items(): for hash, storedValue in shared.inventory.items():
if hash not in self.objectsOfWhichThisRemoteNodeIsAlreadyAware: if hash not in self.objectsOfWhichThisRemoteNodeIsAlreadyAware:
objectType, streamNumber, payload, receivedTime = storedValue objectType, streamNumber, payload, receivedTime = storedValue
if streamNumber == self.streamNumber and receivedTime > int(time.time())-maximumAgeOfObjectsThatIAdvertiseToOthers: if streamNumber == self.streamNumber and receivedTime > int(time.time())-maximumAgeOfObjectsThatIAdvertiseToOthers:
bigInvList[hash] = 0 bigInvList[hash] = 0
else:
shared.printLock.acquire()
print 'Not including an object hash in a big inv message because the remote node is already aware of it.'#This line is here to check that this feature is working.
shared.printLock.release()
numberOfObjectsInInvMessage = 0 numberOfObjectsInInvMessage = 0
payload = '' payload = ''
#Now let us start appending all of these hashes together. They will be sent out in a big inv message to our new peer. #Now let us start appending all of these hashes together. They will be sent out in a big inv message to our new peer.
@ -3692,8 +3684,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
shared.sqlReturnQueue.get() shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
shared.UISignalQueue.put(('updateStatusBar','Per API: Trashed message (assuming message existed). UI not updated.')) shared.UISignalQueue.put(('removeInboxRowByMsgid',msgid))
return 'Trashed message (assuming message existed). UI not updated. To double check, run getAllInboxMessages to see that the message disappeared, or restart Bitmessage and look in the normal Bitmessage GUI.' return 'Trashed message (assuming message existed).'
elif method == 'sendMessage': elif method == 'sendMessage':
if len(params) == 0: if len(params) == 0:
return 'API Error 0000: I need parameters!' return 'API Error 0000: I need parameters!'

View File

@ -427,6 +427,7 @@ class MyForm(QtGui.QMainWindow):
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("setStatusIcon(PyQt_PyObject)"), self.setStatusIcon) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("setStatusIcon(PyQt_PyObject)"), self.setStatusIcon)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("rerenderInboxFromLabels()"), self.rerenderInboxFromLabels) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("rerenderInboxFromLabels()"), self.rerenderInboxFromLabels)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("rerenderSubscriptions()"), self.rerenderSubscriptions) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("rerenderSubscriptions()"), self.rerenderSubscriptions)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"), self.removeInboxRowByMsgid)
self.UISignalThread.start() self.UISignalThread.start()
#Below this point, it would be good if all of the necessary global data structures were initialized. #Below this point, it would be good if all of the necessary global data structures were initialized.
@ -937,6 +938,13 @@ class MyForm(QtGui.QMainWindow):
#self.ui.tableWidgetSent.item(i,3).setText(unicode(textToDisplay,'utf-8')) #self.ui.tableWidgetSent.item(i,3).setText(unicode(textToDisplay,'utf-8'))
self.ui.tableWidgetSent.item(i,3).setText(textToDisplay) self.ui.tableWidgetSent.item(i,3).setText(textToDisplay)
def removeInboxRowByMsgid(self,msgid):#msgid and inventoryHash are the same thing
for i in range(self.ui.tableWidgetInbox.rowCount()):
if msgid == str(self.ui.tableWidgetInbox.item(i,3).data(Qt.UserRole).toPyObject()):
self.statusBar().showMessage('Message trashed')
self.ui.tableWidgetInbox.removeRow(i)
break
def rerenderInboxFromLabels(self): def rerenderInboxFromLabels(self):
for i in range(self.ui.tableWidgetInbox.rowCount()): for i in range(self.ui.tableWidgetInbox.rowCount()):
addressToLookup = str(self.ui.tableWidgetInbox.item(i,1).data(Qt.UserRole).toPyObject()) addressToLookup = str(self.ui.tableWidgetInbox.item(i,1).data(Qt.UserRole).toPyObject())
@ -2291,6 +2299,8 @@ class UISignaler(QThread):
self.emit(SIGNAL("rerenderInboxFromLabels()")) self.emit(SIGNAL("rerenderInboxFromLabels()"))
elif command == 'rerenderSubscriptions': elif command == 'rerenderSubscriptions':
self.emit(SIGNAL("rerenderSubscriptions()")) self.emit(SIGNAL("rerenderSubscriptions()"))
elif command == 'removeInboxRowByMsgid':
self.emit(SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"),data)
else: else:
sys.stderr.write('Command sent to UISignaler not recognized: %s\n' % command) sys.stderr.write('Command sent to UISignaler not recognized: %s\n' % command)