diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 1e5acdca..38d025dd 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -212,6 +212,8 @@ class MyForm(QtGui.QMainWindow): "clicked()"), self.click_pushButtonAddSubscription) QtCore.QObject.connect(self.ui.pushButtonAddBlacklist, QtCore.SIGNAL( "clicked()"), self.click_pushButtonAddBlacklist) + QtCore.QObject.connect(self.ui.pushButtonTTL, QtCore.SIGNAL( + "clicked()"), self.click_pushButtonTTL) QtCore.QObject.connect(self.ui.pushButtonSend, QtCore.SIGNAL( "clicked()"), self.click_pushButtonSend) QtCore.QObject.connect(self.ui.pushButtonLoadFromAddressBook, @@ -648,6 +650,18 @@ class MyForm(QtGui.QMainWindow): self.rerenderComboBoxSendFrom() + # Put the TTL slider in the correct spot + TTL = shared.config.getint('bitmessagesettings', 'ttl') + if TTL < 3600: # an hour + TTL = 3600 + elif TTL > 28*24*60*60: # 28 days + TTL = 28*24*60*60 + self.ui.horizontalSliderTTL.setSliderPosition((TTL - 3600) ** (1/3.199)) + self.updateHumanFriendlyTTLDescription(TTL) + + QtCore.QObject.connect(self.ui.horizontalSliderTTL, QtCore.SIGNAL( + "valueChanged(int)"), self.updateTTL) + # Check to see whether we can connect to namecoin. Hide the 'Fetch Namecoin ID' button if we can't. try: options = {} @@ -662,7 +676,23 @@ class MyForm(QtGui.QMainWindow): except: print 'There was a problem testing for a Namecoin daemon. Hiding the Fetch Namecoin ID button' self.ui.pushButtonFetchNamecoinID.hide() - + + def updateTTL(self, sliderPosition): + TTL = int(sliderPosition ** 3.199 + 3600) + self.updateHumanFriendlyTTLDescription(TTL) + shared.config.set('bitmessagesettings', 'ttl', str(TTL)) + shared.writeKeysFile() + + def updateHumanFriendlyTTLDescription(self, TTL): + numberOfHours = int(round(TTL / (60*60))) + if numberOfHours < 48: + if numberOfHours == 1: + self.ui.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "1 hour")) + else: + self.ui.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%1 hours").arg(numberOfHours)) + else: + numberOfDays = int(round(TTL / (24*60*60))) + self.ui.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%1 days").arg(numberOfDays)) # Show or hide the application window after clicking an item within the # tray icon or, on Windows, the try icon itself. @@ -1868,6 +1898,14 @@ class MyForm(QtGui.QMainWindow): newItem.setTextColor(QtGui.QColor(128, 128, 128)) self.ui.tableWidgetBlacklist.setItem(0, 1, newItem) + def click_pushButtonTTL(self): + QtGui.QMessageBox.information(self, 'Time To Live', _translate( + "MainWindow", "The TTL, or Time-To-Live is the length of time that the network will hold the message. \ +The recipient must get it during this time. If your client does not hear an acknowledgement, your \ +Bitmessage client will resend the message automatically if it is open. The longer the Time-To-Live, the \ +more work your computer must do to send the message. A Time-To-Live of four or five days is often appropriate."), QMessageBox.Ok) + ############### + def click_pushButtonSend(self): self.statusBar().showMessage('') toAddresses = str(self.ui.lineEditTo.text()) @@ -1953,10 +1991,11 @@ class MyForm(QtGui.QMainWindow): ackdata, int(time.time()), 'msgqueued', - 1, - 1, + 1, # pubkeyretrynumber + 1, # msgretrynumber 'sent', - 2) + 2 # encodingtype + ) toLabel = '' queryreturn = sqlQuery('''select label from addressbook where address=?''', @@ -2421,13 +2460,6 @@ class MyForm(QtGui.QMainWindow): self.settingsDialogInstance.ui.lineEditDays.text()))) shared.config.set('bitmessagesettings', 'stopresendingafterxmonths', str(float( self.settingsDialogInstance.ui.lineEditMonths.text()))) - #end - - # if str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText()) == 'All': - # shared.config.set('bitmessagesettings', 'maxcores', '99999') - # else: - # shared.config.set('bitmessagesettings', 'maxcores', - # str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText())) shared.writeKeysFile() @@ -3756,8 +3788,6 @@ class NewAddressDialog(QtGui.QDialog): # the 'Your Identities' tab. while self.parent.ui.tableWidgetYourIdentities.item(row - 1, 1): self.ui.radioButtonExisting.click() - # print - # self.parent.ui.tableWidgetYourIdentities.item(row-1,1).text() self.ui.comboBoxExisting.addItem( self.parent.ui.tableWidgetYourIdentities.item(row - 1, 1).text()) row += 1 diff --git a/src/bitmessageqt/bitmessageui.py b/src/bitmessageqt/bitmessageui.py index 318c1caf..c2d45a76 100644 --- a/src/bitmessageqt/bitmessageui.py +++ b/src/bitmessageqt/bitmessageui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'bitmessageui.ui' # -# Created: Mon Jan 05 16:21:20 2015 +# Created: Fri Feb 27 18:48:36 2015 # by: PyQt4 UI code generator 4.10.3 # # WARNING! All changes made in this file will be lost! @@ -109,62 +109,55 @@ class Ui_MainWindow(object): self.send.setObjectName(_fromUtf8("send")) self.gridLayout_2 = QtGui.QGridLayout(self.send) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) + self.lineEditSubject = QtGui.QLineEdit(self.send) + self.lineEditSubject.setText(_fromUtf8("")) + self.lineEditSubject.setObjectName(_fromUtf8("lineEditSubject")) + self.gridLayout_2.addWidget(self.lineEditSubject, 4, 1, 1, 1) self.pushButtonLoadFromAddressBook = QtGui.QPushButton(self.send) font = QtGui.QFont() font.setPointSize(7) self.pushButtonLoadFromAddressBook.setFont(font) self.pushButtonLoadFromAddressBook.setObjectName(_fromUtf8("pushButtonLoadFromAddressBook")) self.gridLayout_2.addWidget(self.pushButtonLoadFromAddressBook, 3, 2, 1, 1) - self.pushButtonFetchNamecoinID = QtGui.QPushButton(self.send) - font = QtGui.QFont() - font.setPointSize(7) - self.pushButtonFetchNamecoinID.setFont(font) - self.pushButtonFetchNamecoinID.setObjectName(_fromUtf8("pushButtonFetchNamecoinID")) - self.gridLayout_2.addWidget(self.pushButtonFetchNamecoinID, 3, 3, 1, 1) - self.label_4 = QtGui.QLabel(self.send) - self.label_4.setObjectName(_fromUtf8("label_4")) - self.gridLayout_2.addWidget(self.label_4, 5, 0, 1, 1) + self.label_3 = QtGui.QLabel(self.send) + self.label_3.setObjectName(_fromUtf8("label_3")) + self.gridLayout_2.addWidget(self.label_3, 4, 0, 1, 1) + self.pushButtonSend = QtGui.QPushButton(self.send) + self.pushButtonSend.setObjectName(_fromUtf8("pushButtonSend")) + self.gridLayout_2.addWidget(self.pushButtonSend, 7, 8, 1, 1) + self.horizontalSliderTTL = QtGui.QSlider(self.send) + self.horizontalSliderTTL.setMaximumSize(QtCore.QSize(70, 16777215)) + self.horizontalSliderTTL.setOrientation(QtCore.Qt.Horizontal) + self.horizontalSliderTTL.setInvertedAppearance(False) + self.horizontalSliderTTL.setInvertedControls(False) + self.horizontalSliderTTL.setObjectName(_fromUtf8("horizontalSliderTTL")) + self.gridLayout_2.addWidget(self.horizontalSliderTTL, 7, 6, 1, 1) + spacerItem = QtGui.QSpacerItem(20, 297, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout_2.addItem(spacerItem, 6, 0, 1, 1) self.comboBoxSendFrom = QtGui.QComboBox(self.send) self.comboBoxSendFrom.setMinimumSize(QtCore.QSize(300, 0)) self.comboBoxSendFrom.setObjectName(_fromUtf8("comboBoxSendFrom")) self.gridLayout_2.addWidget(self.comboBoxSendFrom, 2, 1, 1, 1) - self.label_3 = QtGui.QLabel(self.send) - self.label_3.setObjectName(_fromUtf8("label_3")) - self.gridLayout_2.addWidget(self.label_3, 4, 0, 1, 1) - self.labelFrom = QtGui.QLabel(self.send) - self.labelFrom.setText(_fromUtf8("")) - self.labelFrom.setObjectName(_fromUtf8("labelFrom")) - self.gridLayout_2.addWidget(self.labelFrom, 2, 2, 1, 3) + self.labelHumanFriendlyTTLDescription = QtGui.QLabel(self.send) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.labelHumanFriendlyTTLDescription.sizePolicy().hasHeightForWidth()) + self.labelHumanFriendlyTTLDescription.setSizePolicy(sizePolicy) + self.labelHumanFriendlyTTLDescription.setMinimumSize(QtCore.QSize(45, 0)) + self.labelHumanFriendlyTTLDescription.setMaximumSize(QtCore.QSize(45, 16777215)) + self.labelHumanFriendlyTTLDescription.setObjectName(_fromUtf8("labelHumanFriendlyTTLDescription")) + self.gridLayout_2.addWidget(self.labelHumanFriendlyTTLDescription, 7, 7, 1, 1) + self.label_4 = QtGui.QLabel(self.send) + self.label_4.setObjectName(_fromUtf8("label_4")) + self.gridLayout_2.addWidget(self.label_4, 5, 0, 1, 1) + self.label = QtGui.QLabel(self.send) + self.label.setObjectName(_fromUtf8("label")) + self.gridLayout_2.addWidget(self.label, 3, 0, 1, 1) self.radioButtonSpecific = QtGui.QRadioButton(self.send) self.radioButtonSpecific.setChecked(True) self.radioButtonSpecific.setObjectName(_fromUtf8("radioButtonSpecific")) self.gridLayout_2.addWidget(self.radioButtonSpecific, 0, 1, 1, 1) - self.lineEditTo = QtGui.QLineEdit(self.send) - self.lineEditTo.setObjectName(_fromUtf8("lineEditTo")) - self.gridLayout_2.addWidget(self.lineEditTo, 3, 1, 1, 1) - self.textEditMessage = QtGui.QTextEdit(self.send) - self.textEditMessage.setObjectName(_fromUtf8("textEditMessage")) - self.gridLayout_2.addWidget(self.textEditMessage, 5, 1, 2, 5) - self.label = QtGui.QLabel(self.send) - self.label.setObjectName(_fromUtf8("label")) - self.gridLayout_2.addWidget(self.label, 3, 0, 1, 1) - self.label_2 = QtGui.QLabel(self.send) - self.label_2.setObjectName(_fromUtf8("label_2")) - self.gridLayout_2.addWidget(self.label_2, 2, 0, 1, 1) - spacerItem = QtGui.QSpacerItem(20, 297, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.gridLayout_2.addItem(spacerItem, 6, 0, 1, 1) - self.radioButtonBroadcast = QtGui.QRadioButton(self.send) - self.radioButtonBroadcast.setObjectName(_fromUtf8("radioButtonBroadcast")) - self.gridLayout_2.addWidget(self.radioButtonBroadcast, 1, 1, 1, 3) - self.lineEditSubject = QtGui.QLineEdit(self.send) - self.lineEditSubject.setText(_fromUtf8("")) - self.lineEditSubject.setObjectName(_fromUtf8("lineEditSubject")) - self.gridLayout_2.addWidget(self.lineEditSubject, 4, 1, 1, 5) - spacerItem1 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.gridLayout_2.addItem(spacerItem1, 3, 4, 1, 1) - self.pushButtonSend = QtGui.QPushButton(self.send) - self.pushButtonSend.setObjectName(_fromUtf8("pushButtonSend")) - self.gridLayout_2.addWidget(self.pushButtonSend, 7, 5, 1, 1) self.labelSendBroadcastWarning = QtGui.QLabel(self.send) self.labelSendBroadcastWarning.setEnabled(True) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Preferred) @@ -175,6 +168,54 @@ class Ui_MainWindow(object): self.labelSendBroadcastWarning.setIndent(-1) self.labelSendBroadcastWarning.setObjectName(_fromUtf8("labelSendBroadcastWarning")) self.gridLayout_2.addWidget(self.labelSendBroadcastWarning, 7, 1, 1, 4) + self.radioButtonBroadcast = QtGui.QRadioButton(self.send) + self.radioButtonBroadcast.setObjectName(_fromUtf8("radioButtonBroadcast")) + self.gridLayout_2.addWidget(self.radioButtonBroadcast, 1, 1, 1, 2) + self.pushButtonTTL = QtGui.QPushButton(self.send) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pushButtonTTL.sizePolicy().hasHeightForWidth()) + self.pushButtonTTL.setSizePolicy(sizePolicy) + self.pushButtonTTL.setMaximumSize(QtCore.QSize(32, 16777215)) + palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(120, 120, 120)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) + self.pushButtonTTL.setPalette(palette) + font = QtGui.QFont() + font.setUnderline(True) + self.pushButtonTTL.setFont(font) + self.pushButtonTTL.setFlat(True) + self.pushButtonTTL.setObjectName(_fromUtf8("pushButtonTTL")) + self.gridLayout_2.addWidget(self.pushButtonTTL, 7, 5, 1, 1) + self.label_2 = QtGui.QLabel(self.send) + self.label_2.setObjectName(_fromUtf8("label_2")) + self.gridLayout_2.addWidget(self.label_2, 2, 0, 1, 1) + self.labelFrom = QtGui.QLabel(self.send) + self.labelFrom.setText(_fromUtf8("")) + self.labelFrom.setObjectName(_fromUtf8("labelFrom")) + self.gridLayout_2.addWidget(self.labelFrom, 2, 2, 1, 1) + spacerItem1 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.gridLayout_2.addItem(spacerItem1, 3, 4, 1, 1) + self.lineEditTo = QtGui.QLineEdit(self.send) + self.lineEditTo.setObjectName(_fromUtf8("lineEditTo")) + self.gridLayout_2.addWidget(self.lineEditTo, 3, 1, 1, 1) + self.textEditMessage = QtGui.QTextEdit(self.send) + self.textEditMessage.setObjectName(_fromUtf8("textEditMessage")) + self.gridLayout_2.addWidget(self.textEditMessage, 5, 1, 2, 8) + self.pushButtonFetchNamecoinID = QtGui.QPushButton(self.send) + font = QtGui.QFont() + font.setPointSize(7) + self.pushButtonFetchNamecoinID.setFont(font) + self.pushButtonFetchNamecoinID.setObjectName(_fromUtf8("pushButtonFetchNamecoinID")) + self.gridLayout_2.addWidget(self.pushButtonFetchNamecoinID, 3, 3, 1, 1) icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/send.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tabWidget.addTab(self.send, icon2, _fromUtf8("")) @@ -556,20 +597,22 @@ class Ui_MainWindow(object): item.setText(_translate("MainWindow", "Received", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.inbox), _translate("MainWindow", "Inbox", None)) self.pushButtonLoadFromAddressBook.setText(_translate("MainWindow", "Load from Address book", None)) - self.pushButtonFetchNamecoinID.setText(_translate("MainWindow", "Fetch Namecoin ID", None)) - self.label_4.setText(_translate("MainWindow", "Message:", None)) self.label_3.setText(_translate("MainWindow", "Subject:", None)) + self.pushButtonSend.setText(_translate("MainWindow", "Send", None)) + self.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "X days", None)) + self.label_4.setText(_translate("MainWindow", "Message:", None)) + self.label.setText(_translate("MainWindow", "To:", None)) self.radioButtonSpecific.setText(_translate("MainWindow", "Send to one or more specific people", None)) + self.labelSendBroadcastWarning.setText(_translate("MainWindow", "Be aware that broadcasts are only encrypted with your address. Anyone who knows your address can read them.", None)) + self.radioButtonBroadcast.setText(_translate("MainWindow", "Broadcast to everyone who is subscribed to your address", None)) + self.pushButtonTTL.setText(_translate("MainWindow", "TTL:", None)) + self.label_2.setText(_translate("MainWindow", "From:", None)) self.textEditMessage.setHtml(_translate("MainWindow", "\n" "\n" "


", None)) - self.label.setText(_translate("MainWindow", "To:", None)) - self.label_2.setText(_translate("MainWindow", "From:", None)) - self.radioButtonBroadcast.setText(_translate("MainWindow", "Broadcast to everyone who is subscribed to your address", None)) - self.pushButtonSend.setText(_translate("MainWindow", "Send", None)) - self.labelSendBroadcastWarning.setText(_translate("MainWindow", "Be aware that broadcasts are only encrypted with your address. Anyone who knows your address can read them.", None)) + self.pushButtonFetchNamecoinID.setText(_translate("MainWindow", "Fetch Namecoin ID", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.send), _translate("MainWindow", "Send", None)) self.sentSearchLineEdit.setPlaceholderText(_translate("MainWindow", "Search", None)) self.sentSearchOptionCB.setItemText(0, _translate("MainWindow", "All", None)) diff --git a/src/bitmessageqt/bitmessageui.ui b/src/bitmessageqt/bitmessageui.ui index 58e115d7..09ce6ff8 100644 --- a/src/bitmessageqt/bitmessageui.ui +++ b/src/bitmessageqt/bitmessageui.ui @@ -204,6 +204,13 @@ Send + + + + + + + @@ -216,35 +223,6 @@ - - - - - 7 - - - - Fetch Namecoin ID - - - - - - - Message: - - - - - - - - 300 - 0 - - - - @@ -252,48 +230,29 @@ - - + + - + Send - - - - Send to one or more specific people + + + + + 70 + 16777215 + - - true + + Qt::Horizontal - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + false - - - - - - To: - - - - - - - From: + + false @@ -310,37 +269,62 @@ p, li { white-space: pre-wrap; } - - - - Broadcast to everyone who is subscribed to your address - - - - - - - - - - - - - - Qt::Horizontal - - + + + - 20 - 20 + 300 + 0 - + - - + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + - Send + X days + + + + + + + Message: + + + + + + + To: + + + + + + + Send to one or more specific people + + + true @@ -363,6 +347,130 @@ p, li { white-space: pre-wrap; } + + + + Broadcast to everyone who is subscribed to your address + + + + + + + + 0 + 0 + + + + + 32 + 16777215 + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 120 + 120 + 120 + + + + + + + + + true + + + + TTL: + + + true + + + + + + + From: + + + + + + + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + + + + + + + 7 + + + + Fetch Namecoin ID + + + diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index d4c69b59..56e86118 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -375,6 +375,10 @@ class sqlThread(threading.Thread): item = '''update settings set value=? WHERE key='version';''' parameters = (9,) self.cur.execute(item, parameters) + + # TTL is now user-specifyable. Let's add an option to save whatever the user selects. + if not shared.config.has_option('bitmessagesettings', 'ttl'): + shared.config.set('bitmessagesettings', 'ttl', '367200') # Are you hoping to add a new option to the keys.dat file of existing # Bitmessage users or modify the SQLite database? Add it right above this line! diff --git a/src/helper_startup.py b/src/helper_startup.py index c71ee436..ef40dd51 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -104,6 +104,7 @@ def loadConfig(): shared.config.set('bitmessagesettings', 'replybelow', 'False') shared.config.set('bitmessagesettings', 'maxdownloadrate', '0') shared.config.set('bitmessagesettings', 'maxuploadrate', '0') + shared.config.set('bitmessagesettings', 'ttl', '367200') #start:UI setting to stop trying to send messages after X days/months shared.config.set(