AQWA feature: UI setting for Bitmessage to stop trying to send messages after X hours/days/months
This commit is contained in:
parent
44bd876a40
commit
9066dad5e3
|
@ -2027,34 +2027,47 @@ class MyForm(QtGui.QMainWindow):
|
||||||
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0:
|
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0:
|
||||||
shared.config.set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
|
shared.config.set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
|
||||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * shared.networkDefaultPayloadLengthExtraBytes)))
|
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * shared.networkDefaultPayloadLengthExtraBytes)))
|
||||||
#my implementation starts here,it was a line here.AQWA
|
#start:UI setting to stop trying to send messages after X hours/days/months
|
||||||
if ((self.settingsDialogInstance.ui.lineEditHours.text()=='') and (self.settingsDialogInstance.ui.lineEditDays.text()=='') and (self.settingsDialogInstance.ui.lineEditMonths.text()=='')):
|
if ((self.settingsDialogInstance.ui.lineEditHours.text()=='') and (self.settingsDialogInstance.ui.lineEditDays.text()=='') and (self.settingsDialogInstance.ui.lineEditMonths.text()=='')):#We need to handle this special case. Bitmessage has its default behavior. The input is blank/blank/blank
|
||||||
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
|
if (((shared.config.get('bitmessagesettings', 'hours')) != str(self.settingsDialogInstance.ui.lineEditHours.text())) or #the user updated the input, restart is needed
|
||||||
((shared.config.get('bitmessagesettings', 'days')) != str(self.settingsDialogInstance.ui.lineEditDays.text())) or
|
((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 ;).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
|
|
||||||
if (int(str(self.settingsDialogInstance.ui.lineEditHours.text())) >=0 and int(str(self.settingsDialogInstance.ui.lineEditDays.text())) >=0 and
|
|
||||||
int(str(self.settingsDialogInstance.ui.lineEditMonths.text())) >=0):
|
|
||||||
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()))):
|
((shared.config.get('bitmessagesettings', 'months')) != str(self.settingsDialogInstance.ui.lineEditMonths.text()))):
|
||||||
QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
|
QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
|
||||||
"MainWindow", "You must restart Bitmessage for the time period change to take effect."))
|
"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.AQWA
|
shared.config.set('bitmessagesettings', 'hours', '')
|
||||||
self.settingsDialogInstance.ui.lineEditHours.text()))
|
shared.config.set('bitmessagesettings', 'days', '')
|
||||||
shared.config.set('bitmessagesettings', 'days', str(
|
shared.config.set('bitmessagesettings', 'months', '')
|
||||||
self.settingsDialogInstance.ui.lineEditDays.text()))
|
shared.config.set('bitmessagesettings', 'timeperiod', '-1')#when bitmessage has its default resending behavior, we set timeperiod to -1.
|
||||||
shared.config.set('bitmessagesettings', 'months', str(
|
else:#So,if all time period's variables (hours,days,months) have valid values, we calculate the time period
|
||||||
self.settingsDialogInstance.ui.lineEditMonths.text()))
|
if (int(self.settingsDialogInstance.ui.lineEditHours.text()) >=0 and int(self.settingsDialogInstance.ui.lineEditDays.text()) >=0 and
|
||||||
|
int(self.settingsDialogInstance.ui.lineEditMonths.text()) >=0):
|
||||||
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 +
|
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))
|
int(str(self.settingsDialogInstance.ui.lineEditMonths.text())) * (60 * 60 * 24 *365)/12))
|
||||||
#my implementation stops here, it was a line.AQWA
|
if int(shared.config.get('bitmessagesettings', 'timeperiod')) < 432000:#if the time period is less than 5 hours, we give zero values to all fields. No message will be sent again.
|
||||||
|
if ((shared.config.get('bitmessagesettings', 'hours')) != str(int(self.settingsDialogInstance.ui.lineEditHours.text())) or #if the user has given an input bigger than 5 days and he tries now to give an input less than 5 days, restart is needed
|
||||||
|
shared.config.get('bitmessagesettings', 'days') != str(int(self.settingsDialogInstance.ui.lineEditDays.text())) or
|
||||||
|
shared.config.get('bitmessagesettings', 'months') != str(int(self.settingsDialogInstance.ui.lineEditMonths.text()))):
|
||||||
|
if((shared.config.get('bitmessagesettings', 'hours')) != '0' or (shared.config.get('bitmessagesettings', 'days')) != '0' or#if the user has already given an input less than 5 days and he tries now to give again an input less than 5 days, there is no need for restart. Input values will remain zero
|
||||||
|
(shared.config.get('bitmessagesettings', 'months')) != '0'):
|
||||||
|
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', '0')
|
||||||
|
shared.config.set('bitmessagesettings', 'days', '0')
|
||||||
|
shared.config.set('bitmessagesettings', 'months', '0')
|
||||||
|
shared.config.set('bitmessagesettings', 'timeperiod', '0')
|
||||||
|
else:
|
||||||
|
if ((shared.config.get('bitmessagesettings', 'hours')) != str(int(self.settingsDialogInstance.ui.lineEditHours.text())) or
|
||||||
|
shared.config.get('bitmessagesettings', 'days') != str(int(self.settingsDialogInstance.ui.lineEditDays.text())) or
|
||||||
|
shared.config.get('bitmessagesettings', 'months') != str(int(self.settingsDialogInstance.ui.lineEditMonths.text()))):
|
||||||
|
QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(#the user updated the input, restart is needed
|
||||||
|
"MainWindow", "You must restart Bitmessage for the time period change to take effect."))
|
||||||
|
shared.config.set('bitmessagesettings', 'hours', str(int(
|
||||||
|
self.settingsDialogInstance.ui.lineEditHours.text())))
|
||||||
|
shared.config.set('bitmessagesettings', 'days', str(int(
|
||||||
|
self.settingsDialogInstance.ui.lineEditDays.text())))
|
||||||
|
shared.config.set('bitmessagesettings', 'months', str(int(
|
||||||
|
self.settingsDialogInstance.ui.lineEditMonths.text())))
|
||||||
|
#end
|
||||||
|
|
||||||
# if str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText()) == 'All':
|
# if str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText()) == 'All':
|
||||||
# shared.config.set('bitmessagesettings', 'maxcores', '99999')
|
# shared.config.set('bitmessagesettings', 'maxcores', '99999')
|
||||||
|
@ -2992,13 +3005,13 @@ class settingsDialog(QtGui.QDialog):
|
||||||
QtCore.QObject.connect(self.ui.pushButtonNamecoinTest, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.ui.pushButtonNamecoinTest, QtCore.SIGNAL(
|
||||||
"clicked()"), self.click_pushButtonNamecoinTest)
|
"clicked()"), self.click_pushButtonNamecoinTest)
|
||||||
|
|
||||||
#Adjusting time period for resending messages tab.AQWA
|
#Adjusting time period to stop sending messages tab
|
||||||
self.ui.lineEditHours.setText(str(#Giving values to edit boxes in the UI.AQWA
|
self.ui.lineEditHours.setText(str(
|
||||||
shared.config.get('bitmessagesettings', 'hours')))
|
shared.config.get('bitmessagesettings', 'hours')))
|
||||||
self.ui.lineEditDays.setText(str(
|
self.ui.lineEditDays.setText(str(
|
||||||
shared.config.get('bitmessagesettings', 'days')))
|
shared.config.get('bitmessagesettings', 'days')))
|
||||||
self.ui.lineEditMonths.setText(str(
|
self.ui.lineEditMonths.setText(str(
|
||||||
shared.config.get('bitmessagesettings', 'months')))#AQWA.
|
shared.config.get('bitmessagesettings', 'months')))
|
||||||
|
|
||||||
|
|
||||||
#'System' tab removed for now.
|
#'System' tab removed for now.
|
||||||
|
|
|
@ -318,10 +318,9 @@ class Ui_settingsDialog(object):
|
||||||
self.gridLayout_8.addLayout(self.horizontalLayout, 1, 0, 1, 3)
|
self.gridLayout_8.addLayout(self.horizontalLayout, 1, 0, 1, 3)
|
||||||
self.tabWidgetSettings.addTab(self.tabNamecoin, _fromUtf8(""))
|
self.tabWidgetSettings.addTab(self.tabNamecoin, _fromUtf8(""))
|
||||||
self.gridLayout.addWidget(self.tabWidgetSettings, 0, 0, 1, 1)
|
self.gridLayout.addWidget(self.tabWidgetSettings, 0, 0, 1, 1)
|
||||||
#this line existed before
|
#start:UI setting to stop trying to send messages after X hours/days/months
|
||||||
#my new implementation starts here
|
self.tabResendingMessagesAdjustment=QtGui.QWidget()
|
||||||
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"))
|
||||||
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 = QtGui.QGridLayout(self.tabResendingMessagesAdjustment)
|
||||||
self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9"))
|
self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9"))
|
||||||
self.label_19 = QtGui.QLabel(self.tabResendingMessagesAdjustment)
|
self.label_19 = QtGui.QLabel(self.tabResendingMessagesAdjustment)
|
||||||
|
@ -335,11 +334,11 @@ class Ui_settingsDialog(object):
|
||||||
self.label_20 = QtGui.QLabel(self.tabResendingMessagesAdjustment)
|
self.label_20 = QtGui.QLabel(self.tabResendingMessagesAdjustment)
|
||||||
self.label_20.setLayoutDirection(QtCore.Qt.LeftToRight)
|
self.label_20.setLayoutDirection(QtCore.Qt.LeftToRight)
|
||||||
self.label_20.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
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.AQWA
|
self.label_20.setObjectName(_fromUtf8("label_20"))
|
||||||
self.gridLayout_9.addWidget(self.label_20, 2, 0, 1, 1)
|
self.gridLayout_9.addWidget(self.label_20, 2, 0, 1, 1)
|
||||||
self.lineEditHours = QtGui.QLineEdit(self.tabResendingMessagesAdjustment)
|
self.lineEditHours = QtGui.QLineEdit(self.tabResendingMessagesAdjustment)
|
||||||
self.lineEditHours.setMaximumSize(QtCore.QSize(33, 16777))
|
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.AQWA
|
self.lineEditHours.setObjectName(_fromUtf8("lineEditHours"))
|
||||||
self.gridLayout_9.addWidget(self.lineEditHours, 2, 1, 1, 1)
|
self.gridLayout_9.addWidget(self.lineEditHours, 2, 1, 1, 1)
|
||||||
self.label_22 = QtGui.QLabel(self.tabResendingMessagesAdjustment)
|
self.label_22 = QtGui.QLabel(self.tabResendingMessagesAdjustment)
|
||||||
self.label_22.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
self.label_22.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
||||||
|
@ -360,7 +359,7 @@ class Ui_settingsDialog(object):
|
||||||
spacerItem15 = QtGui.QSpacerItem(20, 147, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
spacerItem15 = QtGui.QSpacerItem(20, 147, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||||
self.gridLayout_9.addItem(spacerItem15, 3, 1, 1, 1)
|
self.gridLayout_9.addItem(spacerItem15, 3, 1, 1, 1)
|
||||||
self.tabWidgetSettings.addTab(self.tabResendingMessagesAdjustment, _fromUtf8(""))
|
self.tabWidgetSettings.addTab(self.tabResendingMessagesAdjustment, _fromUtf8(""))
|
||||||
#my new implementation stops here, it wasn't line here
|
#end
|
||||||
self.retranslateUi(settingsDialog)
|
self.retranslateUi(settingsDialog)
|
||||||
self.tabWidgetSettings.setCurrentIndex(0)
|
self.tabWidgetSettings.setCurrentIndex(0)
|
||||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), settingsDialog.accept)
|
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), settingsDialog.accept)
|
||||||
|
@ -424,13 +423,13 @@ class Ui_settingsDialog(object):
|
||||||
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab), _translate("settingsDialog", "Demanded difficulty", None))
|
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_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))
|
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..AQWA
|
#start:UI setting to stop trying to send messages after X hours/days/months
|
||||||
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabResendingMessagesAdjustment), _translate("settingsDialog", "Adjusting time period for resending messages", None))
|
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabResendingMessagesAdjustment), _translate("settingsDialog", "Adjusting time period to stop sending 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_19.setText(_translate("settingsDialog", "<html><head/><body><p>If you send a message to someone and he is offline for more than two and a half days, Bitmessage will send the message again after an additional two and a half days. This will be continued with exponential backoff forever. Μessages will continue to be sent after 5, 10, 20 days etc. until the receiver gets them.</p><p> Leaving all the input fields blank means the default behavior which will continue the resending with exponential backoff.</p><p> Setting these values to 0/0/0 or less than 5 days mean that the client will not resend any messages.</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))
|
self.label_20.setText(_translate("settingsDialog", "Time in hours/days/months:", None))
|
||||||
self.label_22.setText(_translate("settingsDialog", "/", None))
|
self.label_22.setText(_translate("settingsDialog", "/", None))
|
||||||
self.label_23.setText(_translate("settingsDialog", "/", None))
|
self.label_23.setText(_translate("settingsDialog", "/", None))
|
||||||
#my new implementation stops here, it wasn't line here
|
#end
|
||||||
self.label_14.setText(_translate("settingsDialog", "Maximum acceptable small message difficulty:", None))
|
self.label_14.setText(_translate("settingsDialog", "Maximum acceptable small message difficulty:", None))
|
||||||
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab_2), _translate("settingsDialog", "Max acceptable difficulty", None))
|
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab_2), _translate("settingsDialog", "Max acceptable difficulty", None))
|
||||||
self.label_16.setText(_translate("settingsDialog", "<html><head/><body><p>Bitmessage can utilize a different Bitcoin-based program called Namecoin to make addresses human-friendly. For example, instead of having to tell your friend your long Bitmessage address, you can simply tell him to send a message to <span style=\" font-style:italic;\">test. </span></p><p>(Getting your own Bitmessage address into Namecoin is still rather difficult).</p><p>Bitmessage can use either namecoind directly or a running nmcontrol instance.</p></body></html>", None))
|
self.label_16.setText(_translate("settingsDialog", "<html><head/><body><p>Bitmessage can utilize a different Bitcoin-based program called Namecoin to make addresses human-friendly. For example, instead of having to tell your friend your long Bitmessage address, you can simply tell him to send a message to <span style=\" font-style:italic;\">test. </span></p><p>(Getting your own Bitmessage address into Namecoin is still rather difficult).</p><p>Bitmessage can use either namecoind directly or a running nmcontrol instance.</p></body></html>", None))
|
||||||
|
|
|
@ -758,13 +758,13 @@
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tabResendingMessagesAdjustment">
|
<widget class="QWidget" name="tabResendingMessagesAdjustment">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Adjusting time period for resending messages</string>
|
<string>Adjusting time period to stop sending messages</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_9">
|
<layout class="QGridLayout" name="gridLayout_9">
|
||||||
<item row="0" column="0" colspan="5">
|
<item row="0" column="0" colspan="5">
|
||||||
<widget class="QLabel" name="label_19">
|
<widget class="QLabel" name="label_19">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string> 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. Μessages will continue to be sent after 4, 8,16 days etc. until the receiver get them. Here you can adjust Bitmessage to stop trying to send messages after X hours/days/months. This time period needs to be longer than 5 days./p></body></html></string>
|
<string> If you send a message to someone and he is offline for more than two and a half days, Bitmessage will send the message again after an additional two and a half days. This will be continued with exponential backoff forever. Μessages will continue to be sent after 5, 10, 20 days etc. until the receiver gets them. Leaving all the input fields blank means the default behavior which will continue the resending with exponential backoff. Setting these values to 0/0/0 or less than 5 days mean that the client will not resend any messages. Here you can adjust Bitmessage to stop trying to send messages after X hours/days/months./p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
|
@ -85,21 +85,21 @@ class singleCleaner(threading.Thread):
|
||||||
|
|
||||||
break
|
break
|
||||||
toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, status, pubkeyretrynumber, msgretrynumber = row
|
toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, status, pubkeyretrynumber, msgretrynumber = row
|
||||||
if status == 'awaitingpubkey':
|
if status == 'awaitingpubkey':#start:UI setting to stop trying to send messages after X hours/days/months
|
||||||
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(shared.config.get('bitmessagesettings', 'timeperiod'))> -1:#The default value of timeperiod is -1.
|
||||||
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
|
if (int(time.time()) - lastactiontime) > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (pubkeyretrynumber))) and ((int(time.time()) - lastactiontime) < int(shared.config.get('bitmessagesettings', 'timeperiod'))):
|
||||||
resendPubkey(pubkeyretrynumber,toripe)
|
resendPubkey(pubkeyretrynumber,toripe)#This will be executed if the user has adjusted the time period with some value
|
||||||
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
|
else:
|
||||||
if int(time.time()) - lastactiontime > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (pubkeyretrynumber))):
|
if int(time.time()) - lastactiontime > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (pubkeyretrynumber))):
|
||||||
resendPubkey(pubkeyretrynumber,toripe)
|
resendPubkey(pubkeyretrynumber,toripe)#This will be executed if the time period has its default value -1. Input (blank/blank/blank)
|
||||||
else: # status == msgsent
|
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!.AQWA
|
if int(shared.config.get('bitmessagesettings', 'timeperiod'))> -1:
|
||||||
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
|
if (int(time.time()) - lastactiontime) > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (msgretrynumber))) and ((int(time.time()) - lastactiontime) < int(shared.config.get('bitmessagesettings', 'timeperiod'))):
|
||||||
resendMsg(msgretrynumber,ackdata)
|
resendMsg(msgretrynumber,ackdata)
|
||||||
else:
|
else:
|
||||||
if int(time.time()) - lastactiontime > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (msgretrynumber))):
|
if int(time.time()) - lastactiontime > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (msgretrynumber))):
|
||||||
resendMsg(msgretrynumber,ackdata)
|
resendMsg(msgretrynumber,ackdata)
|
||||||
|
#end
|
||||||
|
|
||||||
# Let's also clear and reload shared.inventorySets to keep it from
|
# Let's also clear and reload shared.inventorySets to keep it from
|
||||||
# taking up an unnecessary amount of memory.
|
# taking up an unnecessary amount of memory.
|
||||||
|
@ -130,8 +130,8 @@ class singleCleaner(threading.Thread):
|
||||||
shared.knownNodesLock.release()
|
shared.knownNodesLock.release()
|
||||||
shared.needToWriteKnownNodesToDisk = False
|
shared.needToWriteKnownNodesToDisk = False
|
||||||
time.sleep(300)
|
time.sleep(300)
|
||||||
|
#start:UI setting to stop trying to send messages after X hours/days/months
|
||||||
def resendPubkey(pubkeyretrynumber,toripe):#I just structured the code with these two functions. The code inside existed.It is not mine.AQWA
|
def resendPubkey(pubkeyretrynumber,toripe):#We just structured the code with these two functions to reduce code redundancy
|
||||||
print 'It has been a long time and we haven\'t heard a response to our getpubkey request. Sending again.'
|
print 'It has been a long time and we haven\'t heard a response to our getpubkey request. Sending again.'
|
||||||
try:
|
try:
|
||||||
del shared.neededPubkeys[
|
del shared.neededPubkeys[
|
||||||
|
@ -160,6 +160,7 @@ def resendMsg(msgretrynumber,ackdata):
|
||||||
shared.workerQueue.put(('sendmessage', ''))
|
shared.workerQueue.put(('sendmessage', ''))
|
||||||
shared.UISignalQueue.put((
|
shared.UISignalQueue.put((
|
||||||
'updateStatusBar', 'Doing work necessary to again attempt to deliver a message...'))
|
'updateStatusBar', 'Doing work necessary to again attempt to deliver a message...'))
|
||||||
|
#end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -268,24 +268,23 @@ class sqlThread(threading.Thread):
|
||||||
item = '''update settings set value=? WHERE key='version';'''
|
item = '''update settings set value=? WHERE key='version';'''
|
||||||
parameters = (5,)
|
parameters = (5,)
|
||||||
self.cur.execute(item, parameters)
|
self.cur.execute(item, parameters)
|
||||||
|
|
||||||
# Are you hoping to add a new option to the keys.dat file of existing
|
#Adjusting time period to stop sending messages
|
||||||
# Bitmessage users? Add it right above this line!
|
if shared.config.getint('bitmessagesettings', 'settingsversion') == 7:
|
||||||
|
shared.config.set(
|
||||||
#my new implementation starts here, the most of these comment will be deleted, they are just for documentation
|
'bitmessagesettings', 'hours', '')
|
||||||
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(
|
shared.config.set(
|
||||||
'bitmessagesettings', 'days', '')
|
'bitmessagesettings', 'days', '')
|
||||||
shared.config.set(
|
shared.config.set(
|
||||||
'bitmessagesettings', 'months', '')
|
'bitmessagesettings', 'months', '')
|
||||||
shared.config.set(
|
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.AQWA
|
'bitmessagesettings', 'timeperiod', '-1')
|
||||||
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
|
shared.config.set('bitmessagesettings', 'settingsversion', '8')
|
||||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||||
shared.config.write(configfile)
|
shared.config.write(configfile)
|
||||||
#my new implementation in this file stops here
|
|
||||||
|
# Are you hoping to add a new option to the keys.dat file of existing
|
||||||
|
# Bitmessage users? Add it right above this line!
|
||||||
|
|
||||||
try:
|
try:
|
||||||
testpayload = '\x00\x00'
|
testpayload = '\x00\x00'
|
||||||
|
|
|
@ -85,22 +85,22 @@ def loadConfig():
|
||||||
shared.config.set('bitmessagesettings', 'dontconnect', 'true')
|
shared.config.set('bitmessagesettings', 'dontconnect', 'true')
|
||||||
shared.config.set('bitmessagesettings', 'userlocale', 'system')
|
shared.config.set('bitmessagesettings', 'userlocale', 'system')
|
||||||
|
|
||||||
# Are you hoping to add a new option to the keys.dat file? You're in
|
#start:UI setting to stop trying to send messages after X hours/days/months
|
||||||
# the right place for adding it to users who install the software for
|
|
||||||
# the first time. But you must also add it to the keys.dat file of
|
|
||||||
# existing users. To do that, search the class_sqlThread.py file for the
|
|
||||||
# text: "right above this line!"
|
|
||||||
|
|
||||||
#my implementation starts here. AQWA
|
|
||||||
shared.config.set(
|
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 :) ).AQWA
|
'bitmessagesettings', 'hours', '')
|
||||||
shared.config.set(
|
shared.config.set(
|
||||||
'bitmessagesettings', 'days', '')
|
'bitmessagesettings', 'days', '')
|
||||||
shared.config.set(
|
shared.config.set(
|
||||||
'bitmessagesettings', 'months', '')
|
'bitmessagesettings', 'months', '')
|
||||||
shared.config.set(
|
shared.config.set(
|
||||||
'bitmessagesettings', 'timeperiod', '-1')
|
'bitmessagesettings', 'timeperiod', '-1')
|
||||||
#my implementation in this file stops here.AQWA
|
#end
|
||||||
|
|
||||||
|
# Are you hoping to add a new option to the keys.dat file? You're in
|
||||||
|
# the right place for adding it to users who install the software for
|
||||||
|
# the first time. But you must also add it to the keys.dat file of
|
||||||
|
# existing users. To do that, search the class_sqlThread.py file for the
|
||||||
|
# text: "right above this line!"
|
||||||
|
|
||||||
ensureNamecoinOptions()
|
ensureNamecoinOptions()
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user