feature1_v3_AQWA
This commit is contained in:
parent
511185055d
commit
c16d9787d2
|
@ -2036,34 +2036,34 @@ class MyForm(QtGui.QMainWindow):
|
|||
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0:
|
||||
shared.config.set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * shared.networkDefaultPayloadLengthExtraBytes)))
|
||||
#my implementation starts here,it was a line here.JOHN
|
||||
#my implementation starts here,it was a line here.AQWA
|
||||
if ((self.settingsDialogInstance.ui.lineEditHours.text()=='') and (self.settingsDialogInstance.ui.lineEditDays.text()=='') and (self.settingsDialogInstance.ui.lineEditMonths.text()=='')):
|
||||
if (((shared.config.get('bitmessagesettings', 'hours')) != str(self.settingsDialogInstance.ui.lineEditHours.text())) or #if we update the time period from one time period(f.e 1/0/0) to default -/-/,inform the user that restart is needed in order his changes to take effect.JOHN
|
||||
if (((shared.config.get('bitmessagesettings', 'hours')) != str(self.settingsDialogInstance.ui.lineEditHours.text())) or #if we update the time period from one time period(f.e 1/0/0) to default -/-/,inform the user that restart is needed in order his changes to take effect.AQWA
|
||||
((shared.config.get('bitmessagesettings', 'days')) != str(self.settingsDialogInstance.ui.lineEditDays.text())) or
|
||||
((shared.config.get('bitmessagesettings', 'months')) != str(self.settingsDialogInstance.ui.lineEditMonths.text()))) :
|
||||
QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
|
||||
"MainWindow", "You must restart Bitmessage for the time period change to take effect."))
|
||||
|
||||
shared.config.set('bitmessagesettings', 'hours', '')#give default values to fields..this default situation is special and thats why its needs special treatment ;).JOHN
|
||||
shared.config.set('bitmessagesettings', 'days', '')#these commands update each field in the keys.dat file.JOHN
|
||||
shared.config.set('bitmessagesettings', 'hours', '')#give default values to fields..this default situation is special and thats why its needs special treatment ;).AQWA
|
||||
shared.config.set('bitmessagesettings', 'days', '')#these commands update each field in the keys.dat file.AQWA
|
||||
shared.config.set('bitmessagesettings', 'months', '')
|
||||
shared.config.set('bitmessagesettings', 'timeperiod', '-1')
|
||||
else:#So,if all time period fields(hours,months,days) have valid values(valid values---> 0/0/0, 0/3/2, -/-/-, no valid--> -/0/5, 5/-/-), you can calculate the time period
|
||||
shared.config.set('bitmessagesettings', 'timeperiod', str(int(str(self.settingsDialogInstance.ui.lineEditHours.text())) * 60 * 60 + int(str(self.settingsDialogInstance.ui.lineEditDays.text())) * 24 * 60 * 60 +
|
||||
int(str(self.settingsDialogInstance.ui.lineEditMonths.text())) * (60 * 60 * 24 *365)/12))
|
||||
|
||||
if (((shared.config.get('bitmessagesettings', 'hours')) != str(self.settingsDialogInstance.ui.lineEditHours.text())) or#inform user tha he needs to restart bitmessage in order his changes to take effect.JOHN
|
||||
if (((shared.config.get('bitmessagesettings', 'hours')) != str(self.settingsDialogInstance.ui.lineEditHours.text())) or#inform user tha he needs to restart bitmessage in order his changes to take effect.AQWA
|
||||
((shared.config.get('bitmessagesettings', 'days')) != str(self.settingsDialogInstance.ui.lineEditDays.text())) or
|
||||
((shared.config.get('bitmessagesettings', 'months')) != str(self.settingsDialogInstance.ui.lineEditMonths.text()))) :
|
||||
QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
|
||||
"MainWindow", "You must restart Bitmessage for the time period change to take effect."))
|
||||
shared.config.set('bitmessagesettings', 'hours', str(#this three commands update the fields of this new setting in keys.dat file.JOHN
|
||||
shared.config.set('bitmessagesettings', 'hours', str(#this three commands update the fields of this new setting in keys.dat file.AQWA
|
||||
self.settingsDialogInstance.ui.lineEditHours.text()))
|
||||
shared.config.set('bitmessagesettings', 'days', str(
|
||||
self.settingsDialogInstance.ui.lineEditDays.text()))
|
||||
shared.config.set('bitmessagesettings', 'months', str(
|
||||
self.settingsDialogInstance.ui.lineEditMonths.text()))
|
||||
#my implementation stops here, there is a line.JOHN
|
||||
#my implementation stops here, there is a line.AQWA
|
||||
|
||||
# if str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText()) == 'All':
|
||||
# shared.config.set('bitmessagesettings', 'maxcores', '99999')
|
||||
|
@ -3001,13 +3001,13 @@ class settingsDialog(QtGui.QDialog):
|
|||
QtCore.QObject.connect(self.ui.pushButtonNamecoinTest, QtCore.SIGNAL(
|
||||
"clicked()"), self.click_pushButtonNamecoinTest)
|
||||
|
||||
#Adjusting time period for resending messages tab.JOHN
|
||||
self.ui.lineEditHours.setText(str(#Giving values to edit boxes in the UI.JOHN
|
||||
#Adjusting time period for resending messages tab.AQWA
|
||||
self.ui.lineEditHours.setText(str(#Giving values to edit boxes in the UI.AQWA
|
||||
shared.config.get('bitmessagesettings', 'hours')))
|
||||
self.ui.lineEditDays.setText(str(
|
||||
shared.config.get('bitmessagesettings', 'days')))
|
||||
self.ui.lineEditMonths.setText(str(
|
||||
shared.config.get('bitmessagesettings', 'months')))#JOHN.
|
||||
shared.config.get('bitmessagesettings', 'months')))#AQWA.
|
||||
|
||||
|
||||
#'System' tab removed for now.
|
||||
|
|
|
@ -320,8 +320,8 @@ class Ui_settingsDialog(object):
|
|||
self.gridLayout.addWidget(self.tabWidgetSettings, 0, 0, 1, 1)
|
||||
#this line existed before
|
||||
#my new implementation starts here
|
||||
self.tabResendingMessagesAdjustment=QtGui.QWidget()#all these lines are for the UI implementation, I dont think that you need special explanation about them.JOHN
|
||||
self.tabResendingMessagesAdjustment.setObjectName(_fromUtf8("tabResendingMessagesAdjustment"))#Please note that approximately 58 line codes added to setting.ui also responsible for the UI.JOHN
|
||||
self.tabResendingMessagesAdjustment=QtGui.QWidget()#all these lines are for the UI implementation, I dont think that you need special explanation about them.AQWA
|
||||
self.tabResendingMessagesAdjustment.setObjectName(_fromUtf8("tabResendingMessagesAdjustment"))#Please note that approximately 58 line codes added to setting.ui also responsible for the UI.AQWA
|
||||
self.gridLayout_9 = QtGui.QGridLayout(self.tabResendingMessagesAdjustment)
|
||||
self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9"))
|
||||
self.label_19 = QtGui.QLabel(self.tabResendingMessagesAdjustment)
|
||||
|
@ -335,11 +335,11 @@ class Ui_settingsDialog(object):
|
|||
self.label_20 = QtGui.QLabel(self.tabResendingMessagesAdjustment)
|
||||
self.label_20.setLayoutDirection(QtCore.Qt.LeftToRight)
|
||||
self.label_20.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
||||
self.label_20.setObjectName(_fromUtf8("label_20"))#This are Qt code..I just add a label to my tab.JOHN
|
||||
self.label_20.setObjectName(_fromUtf8("label_20"))#This are Qt code..I just add a label to my tab.AQWA
|
||||
self.gridLayout_9.addWidget(self.label_20, 2, 0, 1, 1)
|
||||
self.lineEditHours = QtGui.QLineEdit(self.tabResendingMessagesAdjustment)
|
||||
self.lineEditHours.setMaximumSize(QtCore.QSize(33, 16777))
|
||||
self.lineEditHours.setObjectName(_fromUtf8("lineEditHours"))##This are Qt code..I just add a edit box to my tab.JOHN
|
||||
self.lineEditHours.setObjectName(_fromUtf8("lineEditHours"))##This are Qt code..I just add a edit box to my tab.AQWA
|
||||
self.gridLayout_9.addWidget(self.lineEditHours, 2, 1, 1, 1)
|
||||
self.label_22 = QtGui.QLabel(self.tabResendingMessagesAdjustment)
|
||||
self.label_22.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
||||
|
@ -424,7 +424,7 @@ class Ui_settingsDialog(object):
|
|||
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab), _translate("settingsDialog", "Demanded difficulty", None))
|
||||
self.label_15.setText(_translate("settingsDialog", "Here you may set the maximum amount of work you are willing to do to send a message to another person. Setting these values to 0 means that any value is acceptable.", None))
|
||||
self.label_13.setText(_translate("settingsDialog", "Maximum acceptable total difficulty:", None))
|
||||
#my new implementation starts here,it wasn't line here.Too simple to explain :D..JOHN
|
||||
#my new implementation starts here,it wasn't line here.Too simple to explain :D..AQWA
|
||||
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabResendingMessagesAdjustment), _translate("settingsDialog", "Adjusting time period for resending messages", None))
|
||||
self.label_19.setText(_translate("settingsDialog", "<html><head/><body><p>If you send a message to someone and he is offline for more than two days, Bitmessage will send the message again after an additional two days. This will be continued with exponential backoff forever. Messages will continue to be sent after 4, 8,16 days and so on until the receiver get them. </p><p> Here you can adjust Bitmessage to stop trying to send messages after X hours/days/months.</p></body></html>", None))
|
||||
self.label_20.setText(_translate("settingsDialog", "Time in hours/days/months:", None))
|
||||
|
|
|
@ -86,67 +86,19 @@ class singleCleaner(threading.Thread):
|
|||
break
|
||||
toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, status, pubkeyretrynumber, msgretrynumber = row
|
||||
if status == 'awaitingpubkey':
|
||||
if int(shared.config.get('bitmessagesettings', 'timeperiod'))> -1:#My implemenentation starts here.In this file I just added 4 lines.Two here and other two above.The default value of timeperiod is -1.This means that bitmessage resends messages every 5 days(they say 4 but actually is 5)for ever. If user changes the time period, timeperiod variable will have a specific value so the next if will be executed.JOHN
|
||||
if (int(time.time()) - lastactiontime) > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (pubkeyretrynumber))) and ((int(time.time()) - lastactiontime) < int(shared.config.get('bitmessagesettings', 'timeperiod'))):#This line does the magic.This if checks if the time that the public key was sent is longer than 5 days. Then it sends the it again. But with this extra AND it will not send it if this time is shorter than timeperiod.JOHN
|
||||
print 'It has been a long time and we haven\'t heard a response to our getpubkey request. Sending again.'
|
||||
try:
|
||||
del shared.neededPubkeys[
|
||||
toripe] # We need to take this entry out of the shared.neededPubkeys structure because the shared.workerQueue checks to see whether the entry is already present and will not do the POW and send the message because it assumes that it has already done it recently.
|
||||
except:
|
||||
pass
|
||||
|
||||
shared.UISignalQueue.put((
|
||||
'updateStatusBar', 'Doing work necessary to again attempt to request a public key...'))
|
||||
t = ()
|
||||
sqlExecute(
|
||||
'''UPDATE sent SET lastactiontime=?, pubkeyretrynumber=?, status='msgqueued' WHERE toripe=?''',
|
||||
int(time.time()),
|
||||
pubkeyretrynumber + 1,
|
||||
toripe)
|
||||
shared.workerQueue.put(('sendmessage', ''))
|
||||
else:#first it wasn't an else statement here, I put it for this setting. I just copy-paste the code again. If someone has any suggestion how we can do this without this if-else just say it.JOHN
|
||||
if int(shared.config.get('bitmessagesettings', 'timeperiod'))> -1:#My implemenentation starts here.This if statement would become very big with my new code,so I created two function(see at the end of this file) to reduce code.I did.The default value of timeperiod is -1.This means that bitmessage resends messages every 5 days(they say 4 but actually is 5)for ever. If user changes the time period, timeperiod variable will have a specific value so the next if will be executed.AQWA
|
||||
if (int(time.time()) - lastactiontime) > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (pubkeyretrynumber))) and ((int(time.time()) - lastactiontime) < int(shared.config.get('bitmessagesettings', 'timeperiod'))):#This line does the magic.This if checks if the time that the public key was sent is longer than 5 days. Then it sends the it again. But with this extra AND it will not send it if this time is shorter than timeperiod.AQWA
|
||||
resendPubkey(pubkeyretrynumber,toripe)
|
||||
else:#first it wasn't an else statement here, I put it for this setting. I just copy-paste the code again. If someone has any suggestion how we can do this without this if-else just say it.AQWA
|
||||
if int(time.time()) - lastactiontime > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (pubkeyretrynumber))):
|
||||
print 'It has been a long time and we haven\'t heard a response to our getpubkey request. Sending again.'
|
||||
try:
|
||||
del shared.neededPubkeys[
|
||||
toripe] # We need to take this entry out of the shared.neededPubkeys structure because the shared.workerQueue checks to see whether the entry is already present and will not do the POW and send the message because it assumes that it has already done it recently.
|
||||
except:
|
||||
pass
|
||||
|
||||
shared.UISignalQueue.put((
|
||||
'updateStatusBar', 'Doing work necessary to again attempt to request a public key...'))
|
||||
t = ()
|
||||
sqlExecute(
|
||||
'''UPDATE sent SET lastactiontime=?, pubkeyretrynumber=?, status='msgqueued' WHERE toripe=?''',
|
||||
int(time.time()),
|
||||
pubkeyretrynumber + 1,
|
||||
toripe)
|
||||
shared.workerQueue.put(('sendmessage', ''))
|
||||
resendPubkey(pubkeyretrynumber,toripe)
|
||||
else: # status == msgsent
|
||||
if int(shared.config.get('bitmessagesettings', 'timeperiod'))> -1:#same thing here but for the message.Actually this is the most important thing in the whole feature!.JOHN
|
||||
if (int(time.time()) - lastactiontime) > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (pubkeyretrynumber))) and ((int(time.time()) - lastactiontime) < int(shared.config.get('bitmessagesettings', 'timeperiod'))):#same thing here.My implementation in this file stops here.JOHN
|
||||
print 'It has been a long time and we haven\'t heard an acknowledgement to our msg. Sending again.'
|
||||
sqlExecute(
|
||||
'''UPDATE sent SET lastactiontime=?, msgretrynumber=?, status=? WHERE ackdata=?''',
|
||||
int(time.time()),
|
||||
msgretrynumber + 1,
|
||||
'msgqueued',
|
||||
ackdata)
|
||||
shared.workerQueue.put(('sendmessage', ''))
|
||||
shared.UISignalQueue.put((
|
||||
'updateStatusBar', 'Doing work necessary to again attempt to deliver a message...'))
|
||||
if int(shared.config.get('bitmessagesettings', 'timeperiod'))> -1:#same thing here but for the message.Actually this is the most important thing in the whole feature!.AQWA
|
||||
if (int(time.time()) - lastactiontime) > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (msgretrynumber))) and ((int(time.time()) - lastactiontime) < int(shared.config.get('bitmessagesettings', 'timeperiod'))):#same thing here.My implementation in this file stops here.AQWA
|
||||
resendMsg(msgretrynumber,ackdata)
|
||||
else:
|
||||
if int(time.time()) - lastactiontime > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (pubkeyretrynumber))):
|
||||
print 'It has been a long time and we haven\'t heard an acknowledgement to our msg. Sending again.'
|
||||
sqlExecute(
|
||||
'''UPDATE sent SET lastactiontime=?, msgretrynumber=?, status=? WHERE ackdata=?''',
|
||||
int(time.time()),
|
||||
msgretrynumber + 1,
|
||||
'msgqueued',
|
||||
ackdata)
|
||||
shared.workerQueue.put(('sendmessage', ''))
|
||||
shared.UISignalQueue.put((
|
||||
'updateStatusBar', 'Doing work necessary to again attempt to deliver a message...'))
|
||||
if int(time.time()) - lastactiontime > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (msgretrynumber))):
|
||||
resendMsg(msgretrynumber,ackdata)
|
||||
|
||||
|
||||
# Let's also clear and reload shared.inventorySets to keep it from
|
||||
|
@ -178,3 +130,36 @@ class singleCleaner(threading.Thread):
|
|||
shared.knownNodesLock.release()
|
||||
shared.needToWriteKnownNodesToDisk = False
|
||||
time.sleep(300)
|
||||
|
||||
def resendPubkey(pubkeyretrynumber,toripe):#I just structured the code with these two functions. The code inside existed.It is not mine.AQWA
|
||||
print 'It has been a long time and we haven\'t heard a response to our getpubkey request. Sending again.'
|
||||
try:
|
||||
del shared.neededPubkeys[
|
||||
toripe] # We need to take this entry out of the shared.neededPubkeys structure because the shared.workerQueue checks to see whether the entry is already present and will not do the POW and send the message because it assumes that it has already done it recently.
|
||||
except:
|
||||
pass
|
||||
|
||||
shared.UISignalQueue.put((
|
||||
'updateStatusBar', 'Doing work necessary to again attempt to request a public key...'))
|
||||
t = ()
|
||||
sqlExecute(
|
||||
'''UPDATE sent SET lastactiontime=?, pubkeyretrynumber=?, status='msgqueued' WHERE toripe=?''',
|
||||
int(time.time()),
|
||||
pubkeyretrynumber + 1,
|
||||
toripe)
|
||||
shared.workerQueue.put(('sendmessage', ''))
|
||||
|
||||
def resendMsg(msgretrynumber,ackdata):
|
||||
print 'It has been a long time and we haven\'t heard an acknowledgement to our msg. Sending again.'
|
||||
sqlExecute(
|
||||
'''UPDATE sent SET lastactiontime=?, msgretrynumber=?, status=? WHERE ackdata=?''',
|
||||
int(time.time()),
|
||||
msgretrynumber + 1,
|
||||
'msgqueued',
|
||||
ackdata)
|
||||
shared.workerQueue.put(('sendmessage', ''))
|
||||
shared.UISignalQueue.put((
|
||||
'updateStatusBar', 'Doing work necessary to again attempt to deliver a message...'))
|
||||
|
||||
|
||||
|
|
@ -257,16 +257,16 @@ class sqlThread(threading.Thread):
|
|||
# Bitmessage users? Add it right above this line!
|
||||
|
||||
#my new implementation starts here, the most of these comment will be deleted, they are just for documentation
|
||||
if shared.config.getint('bitmessagesettings', 'settingsversion') == 7:#this is the version that all we have,if you see your keys.dat file this is your version.JOHN
|
||||
shared.config.set(#in order to not have to change your keys.dat file I update it with the new lines. I add to your keys.dat three new default fields.JOHN
|
||||
'bitmessagesettings', 'hours', '')# hours, days, months have no value.This means that bitmessage works as before. It re-sends mails every 4,8,16 days..forever.JOHN
|
||||
if shared.config.getint('bitmessagesettings', 'settingsversion') == 7:#this is the version that all we have,if you see your keys.dat file this is your version.AQWA
|
||||
shared.config.set(#in order to not have to change your keys.dat file I update it with the new lines. I add to your keys.dat three new default fields.AQWA
|
||||
'bitmessagesettings', 'hours', '')# hours, days, months have no value.This means that bitmessage works as before. It re-sends mails every 4,8,16 days..forever.AQWA
|
||||
shared.config.set(
|
||||
'bitmessagesettings', 'days', '')
|
||||
shared.config.set(
|
||||
'bitmessagesettings', 'months', '')
|
||||
shared.config.set(
|
||||
'bitmessagesettings', 'timeperiod', '-1')#time period has default value -1. This is used for checking in class_singleCleaner. If you leave default the time period or after you change it(f.i 1/0/0), again you set it with its default value(-/-/-) this variable will be -1.JOHN
|
||||
shared.config.set('bitmessagesettings', 'settingsversion', '8') #We update the version.If I leave it 7 every time that Bitmessage starts your setting will be lost.The default values(-/-/-) will be loaded all the time ;).That was juicy.JOHN
|
||||
'bitmessagesettings', 'timeperiod', '-1')#time period has default value -1. This is used for checking in class_singleCleaner. If you leave default the time period or after you change it(f.i 1/0/0), again you set it with its default value(-/-/-) this variable will be -1.AQWA
|
||||
shared.config.set('bitmessagesettings', 'settingsversion', '8') #We update the version.If I leave it 7 every time that Bitmessage starts your setting will be lost.The default values(-/-/-) will be loaded all the time ;).That was juicy.AQWA
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
#my new implementation in this file stops here
|
||||
|
|
|
@ -91,16 +91,16 @@ def loadConfig():
|
|||
# existing users. To do that, search the class_sqlThread.py file for the
|
||||
# text: "right above this line!"
|
||||
|
||||
#my implementation starts here. JOHN
|
||||
#my implementation starts here. AQWA
|
||||
shared.config.set(
|
||||
'bitmessagesettings', 'hours', '')#here I am adding the new default settings. The first time that the program is going to run these values will be loaded(UI and keys.dat also :) ).JOHN
|
||||
'bitmessagesettings', 'hours', '')#here I am adding the new default settings. The first time that the program is going to run these values will be loaded(UI and keys.dat also :) ).AQWA
|
||||
shared.config.set(
|
||||
'bitmessagesettings', 'days', '')
|
||||
shared.config.set(
|
||||
'bitmessagesettings', 'months', '')
|
||||
shared.config.set(
|
||||
'bitmessagesettings', 'timeperiod', '-1')
|
||||
#my implementation in this file stops here.JOHN
|
||||
#my implementation in this file stops here.AQWA
|
||||
|
||||
ensureNamecoinOptions()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user