diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 4daaf8a7..e6f42cd7 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -718,6 +718,8 @@ class MyForm(QtGui.QMainWindow): "rerenderBlackWhiteList()"), self.rerenderBlackWhiteList) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( "removeInboxRowByMsgid(PyQt_PyObject)"), self.removeInboxRowByMsgid) + QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( + "newVersionAvailable(PyQt_PyObject)"), self.newVersionAvailable) QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( "displayAlert(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayAlert) self.UISignalThread.start() @@ -1814,6 +1816,31 @@ class MyForm(QtGui.QMainWindow): inbox.removeRow(i) break self.changedInboxUnread() + + def newVersionAvailable(self, version): +# if (not (self.windowState() & QtCore.Qt.WindowActive)) or (self.windowState() & QtCore.Qt.WindowMinimized): +# print "SHIIIIIIIIIIIIIIIIT" +# return + # only notify once until next restart + try: + if self.notifiedNewVersion: + return + except AttributeError: + pass + + self.notifiedNewVersion = ".".join(str(n) for n in version) + message = "New " + if version[1] % 2: + message += "UNSTABLE" + else: + message += "stable" + message += " version of PyBitmessage is available: " + self.notifiedNewVersion + ". Download it from https://github.com/" + if version[0] == 0 and version[1] == 5: + message += "mailchuck" + else: + message += "Bitmessage" + message += "/PyBitmessage/releases/latest" + self.displayAlert("New release of PyBitmessage available", message, False) def displayAlert(self, title, text, exitAfterUserClicksOk): self.statusBar().showMessage(text) @@ -4145,6 +4172,8 @@ class UISignaler(QThread): self.emit(SIGNAL("rerenderBlackWhiteList()")) elif command == 'removeInboxRowByMsgid': self.emit(SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"), data) + elif command == 'newVersionAvailable': + self.emit(SIGNAL("newVersionAvailable(PyQt_PyObject)"), data) elif command == 'alert': title, text, exitAfterUserClicksOk = data self.emit(SIGNAL("displayAlert(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)"), title, text, exitAfterUserClicksOk) diff --git a/src/class_receiveDataThread.py b/src/class_receiveDataThread.py index ff5371ad..07569b7b 100644 --- a/src/class_receiveDataThread.py +++ b/src/class_receiveDataThread.py @@ -698,6 +698,17 @@ class receiveDataThread(threading.Thread): data[80:84]) readPosition = 80 + lengthOfUseragentVarint useragent = data[readPosition:readPosition + useragentLength] + + # version check + userAgentName, userAgentVersion = useragent[1:-1].split(":") + if userAgentName == "PyBitmessage": + myVersion = [int(n) for n in shared.softwareVersion.split(".")] + remoteVersion = [int(n) for n in userAgentVersion.split(".")] + # remote is newer, but do not cross between stable and unstable + if cmp(remoteVersion, myVersion) > 0 and \ + (myVersion[1] % 2 == remoteVersion[1] % 2): + shared.UISignalQueue.put(('newVersionAvailable', remoteVersion)) + readPosition += useragentLength numberOfStreamsInVersionMessage, lengthOfNumberOfStreamsInVersionMessage = decodeVarint( data[readPosition:])