From e1fc820226ce6a3c2a2581d7f25fecaa33ab8a30 Mon Sep 17 00:00:00 2001 From: ikarakatsanis Date: Sat, 28 Sep 2013 04:47:16 +0400 Subject: [PATCH] changes in keys.dat, edit hours/days/months is working now, variable time_period inserted --- src/bitmessageqt/__init__.py | 28 +++++++++++++++++++++++++++- src/class_sqlThread.py | 13 +++++++++++++ src/helper_startup.py | 9 ++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 8cbea0f9..3f59ba4e 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2036,6 +2036,23 @@ 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 + time_period = (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 time_period < shared.maximumAgeOfAnObjectThatIAmWillingToAccept * 2: + QMessageBox.about(self, _translate("MainWindow", "Error"), _translate( + "MainWindow", "You must insert a time period longer than 5 days.")) + shared.config.set('bitmessagesettings', 'hours', '0') + shared.config.set('bitmessagesettings', 'days', '5') + shared.config.set('bitmessagesettings', 'months', '0') + else: + shared.config.set('bitmessagesettings', 'hours', str( + 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 # if str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText()) == 'All': # shared.config.set('bitmessagesettings', 'maxcores', '99999') @@ -2964,7 +2981,7 @@ class settingsDialog(QtGui.QDialog): self.ui.lineEditNamecoinPassword.setEnabled(False) self.ui.labelNamecoinPassword.setEnabled(False) else: - assert False + assert False QtCore.QObject.connect(self.ui.radioButtonNamecoinNamecoind, QtCore.SIGNAL( "toggled(bool)"), self.namecoinTypeChanged) @@ -2973,6 +2990,15 @@ class settingsDialog(QtGui.QDialog): QtCore.QObject.connect(self.ui.pushButtonNamecoinTest, QtCore.SIGNAL( "clicked()"), self.click_pushButtonNamecoinTest) + #Adjust tab + self.ui.lineEditHours.setText(str( + 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'))) + + #'System' tab removed for now. """try: maxCores = shared.config.getint('bitmessagesettings', 'maxcores') diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index 829b243d..ba016eba 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -256,6 +256,19 @@ class sqlThread(threading.Thread): # Are you hoping to add a new option to the keys.dat file of existing # Bitmessage users? Add it right above this line! + #my new implementation starts here + if shared.config.getint('bitmessagesettings', 'settingsversion') == 6: + shared.config.set( + 'bitmessagesettings', 'hours', '0') + shared.config.set( + 'bitmessagesettings', 'days', '5') + shared.config.set( + 'bitmessagesettings', 'months', '0') + shared.config.set('bitmessagesettings', 'settingsversion', '7') + with open(shared.appdata + 'keys.dat', 'wb') as configfile: + shared.config.write(configfile) + #my new implementation stops here + try: testpayload = '\x00\x00' t = ('1234', testpayload, '12345678', 'no') diff --git a/src/helper_startup.py b/src/helper_startup.py index 5a5d7b81..35251f70 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -84,12 +84,19 @@ def loadConfig(): 'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', '0') shared.config.set('bitmessagesettings', 'dontconnect', 'true') shared.config.set('bitmessagesettings', 'userlocale', 'system') - + # 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!" + + shared.config.set( + 'bitmessagesettings', 'hours', '0') + shared.config.set( + 'bitmessagesettings', 'days', '5') + shared.config.set( + 'bitmessagesettings', 'months', '0') ensureNamecoinOptions()