added option to show recent broadcasts when subscribing

This commit is contained in:
Jonathan Warren 2013-11-30 23:15:18 -05:00
parent 45a0046e7d
commit 44618ffcc2
6 changed files with 326 additions and 92 deletions

View File

@ -16,6 +16,7 @@ import shared
from bitmessageui import * from bitmessageui import *
from namecoin import namecoinConnection, ensureNamecoinOptions from namecoin import namecoinConnection, ensureNamecoinOptions
from newaddressdialog import * from newaddressdialog import *
from addaddressdialog import *
from newsubscriptiondialog import * from newsubscriptiondialog import *
from regenerateaddresses import * from regenerateaddresses import *
from newchandialog import * from newchandialog import *
@ -2063,15 +2064,15 @@ class MyForm(QtGui.QMainWindow):
self.ubuntuMessagingMenuUpdate(True, newItem, toLabel) self.ubuntuMessagingMenuUpdate(True, newItem, toLabel)
def click_pushButtonAddAddressBook(self): def click_pushButtonAddAddressBook(self):
self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self) self.AddAddressDialogInstance = AddAddressDialog(self)
if self.NewSubscriptionDialogInstance.exec_(): if self.AddAddressDialogInstance.exec_():
if self.NewSubscriptionDialogInstance.ui.labelSubscriptionAddressCheck.text() == _translate("MainWindow", "Address is valid."): if self.AddAddressDialogInstance.ui.labelAddressCheck.text() == _translate("MainWindow", "Address is valid."):
# First we must check to see if the address is already in the # First we must check to see if the address is already in the
# address book. The user cannot add it again or else it will # address book. The user cannot add it again or else it will
# cause problems when updating and deleting the entry. # cause problems when updating and deleting the entry.
address = addBMIfNotPresent(str( address = addBMIfNotPresent(str(
self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())) self.AddAddressDialogInstance.ui.lineEditAddress.text()))
label = self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8() label = self.AddAddressDialogInstance.ui.newAddressLabel.text().toUtf8()
self.addEntryToAddressBook(address,label) self.addEntryToAddressBook(address,label)
else: else:
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
@ -2120,7 +2121,7 @@ class MyForm(QtGui.QMainWindow):
def click_pushButtonAddSubscription(self): def click_pushButtonAddSubscription(self):
self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self) self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self)
if self.NewSubscriptionDialogInstance.exec_(): if self.NewSubscriptionDialogInstance.exec_():
if self.NewSubscriptionDialogInstance.ui.labelSubscriptionAddressCheck.text() != _translate("MainWindow", "Address is valid."): if self.NewSubscriptionDialogInstance.ui.labelAddressCheck.text() != _translate("MainWindow", "Address is valid."):
self.statusBar().showMessage(_translate("MainWindow", "The address you entered was invalid. Ignoring it.")) self.statusBar().showMessage(_translate("MainWindow", "The address you entered was invalid. Ignoring it."))
return return
address = addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text())) address = addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text()))
@ -2130,6 +2131,23 @@ class MyForm(QtGui.QMainWindow):
return return
label = self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8() label = self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8()
self.addSubscription(address, label) self.addSubscription(address, label)
# Now, if the user wants to display old broadcasts, let's get them out of the inventory and put them
# in the objectProcessorQueue to be processed
if self.NewSubscriptionDialogInstance.ui.checkBoxDisplayMessagesAlreadyInInventory.isChecked():
status, addressVersion, streamNumber, ripe = decodeAddress(address)
shared.flushInventory()
doubleHashOfAddressData = hashlib.sha512(hashlib.sha512(encodeVarint(
addressVersion) + encodeVarint(streamNumber) + ripe).digest()).digest()
tag = doubleHashOfAddressData[32:]
queryreturn = sqlQuery(
'''select payload from inventory where objecttype='broadcast' and tag=?''', tag)
for row in queryreturn:
payload, = row
objectType = 'broadcast'
with shared.objectProcessorQueueSizeLock:
shared.objectProcessorQueueSize += len(payload)
shared.objectProcessorQueue.put((objectType,payload))
####
def loadBlackWhiteList(self): def loadBlackWhiteList(self):
# Initialize the Blacklist or Whitelist table # Initialize the Blacklist or Whitelist table
@ -2368,11 +2386,11 @@ class MyForm(QtGui.QMainWindow):
self.ui.tabWidget.setTabText(6, 'Whitelist') self.ui.tabWidget.setTabText(6, 'Whitelist')
def click_pushButtonAddBlacklist(self): def click_pushButtonAddBlacklist(self):
self.NewBlacklistDialogInstance = NewSubscriptionDialog(self) self.NewBlacklistDialogInstance = AddAddressDialog(self)
if self.NewBlacklistDialogInstance.exec_(): if self.NewBlacklistDialogInstance.exec_():
if self.NewBlacklistDialogInstance.ui.labelSubscriptionAddressCheck.text() == _translate("MainWindow", "Address is valid."): if self.NewBlacklistDialogInstance.ui.labelAddressCheck.text() == _translate("MainWindow", "Address is valid."):
address = addBMIfNotPresent(str( address = addBMIfNotPresent(str(
self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())) self.NewBlacklistDialogInstance.ui.lineEditAddress.text()))
# First we must check to see if the address is already in the # First we must check to see if the address is already in the
# address book. The user cannot add it again or else it will # address book. The user cannot add it again or else it will
# cause problems when updating and deleting the entry. # cause problems when updating and deleting the entry.
@ -2386,7 +2404,7 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetBlacklist.setSortingEnabled(False) self.ui.tableWidgetBlacklist.setSortingEnabled(False)
self.ui.tableWidgetBlacklist.insertRow(0) self.ui.tableWidgetBlacklist.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode( newItem = QtGui.QTableWidgetItem(unicode(
self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8(), 'utf-8')) self.NewBlacklistDialogInstance.ui.newAddressLabel.text().toUtf8(), 'utf-8'))
newItem.setIcon(avatarize(address)) newItem.setIcon(avatarize(address))
self.ui.tableWidgetBlacklist.setItem(0, 0, newItem) self.ui.tableWidgetBlacklist.setItem(0, 0, newItem)
newItem = QtGui.QTableWidgetItem(address) newItem = QtGui.QTableWidgetItem(address)
@ -2394,7 +2412,7 @@ class MyForm(QtGui.QMainWindow):
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetBlacklist.setItem(0, 1, newItem) self.ui.tableWidgetBlacklist.setItem(0, 1, newItem)
self.ui.tableWidgetBlacklist.setSortingEnabled(True) self.ui.tableWidgetBlacklist.setSortingEnabled(True)
t = (str(self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8()), address, True) t = (str(self.NewBlacklistDialogInstance.ui.newAddressLabel.text().toUtf8()), address, True)
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black': if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
sql = '''INSERT INTO blacklist VALUES (?,?,?)''' sql = '''INSERT INTO blacklist VALUES (?,?,?)'''
else: else:
@ -3465,6 +3483,40 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog):
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self)) QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
class AddAddressDialog(QtGui.QDialog):
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_AddAddressDialog()
self.ui.setupUi(self)
self.parent = parent
QtCore.QObject.connect(self.ui.lineEditAddress, QtCore.SIGNAL(
"textChanged(QString)"), self.addressChanged)
def addressChanged(self, QString):
status, a, b, c = decodeAddress(str(QString))
if status == 'missingbm':
self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "The address should start with ''BM-''"))
elif status == 'checksumfailed':
self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "The address is not typed or copied correctly (the checksum failed)."))
elif status == 'versiontoohigh':
self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "The version number of this address is higher than this software can support. Please upgrade Bitmessage."))
elif status == 'invalidcharacters':
self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "The address contains invalid characters."))
elif status == 'ripetooshort':
self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "Some data encoded in the address is too short."))
elif status == 'ripetoolong':
self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "Some data encoded in the address is too long."))
elif status == 'success':
self.ui.labelAddressCheck.setText(
_translate("MainWindow", "Address is valid."))
class NewSubscriptionDialog(QtGui.QDialog): class NewSubscriptionDialog(QtGui.QDialog):
def __init__(self, parent): def __init__(self, parent):
@ -3473,31 +3525,56 @@ class NewSubscriptionDialog(QtGui.QDialog):
self.ui.setupUi(self) self.ui.setupUi(self)
self.parent = parent self.parent = parent
QtCore.QObject.connect(self.ui.lineEditSubscriptionAddress, QtCore.SIGNAL( QtCore.QObject.connect(self.ui.lineEditSubscriptionAddress, QtCore.SIGNAL(
"textChanged(QString)"), self.subscriptionAddressChanged) "textChanged(QString)"), self.addressChanged)
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setText(
_translate("MainWindow", "Enter an address above."))
def subscriptionAddressChanged(self, QString): def addressChanged(self, QString):
status, a, b, c = decodeAddress(str(QString)) self.ui.checkBoxDisplayMessagesAlreadyInInventory.setEnabled(False)
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setChecked(False)
status, addressVersion, streamNumber, ripe = decodeAddress(str(QString))
if status == 'missingbm': if status == 'missingbm':
self.ui.labelSubscriptionAddressCheck.setText(_translate( self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "The address should start with ''BM-''")) "MainWindow", "The address should start with ''BM-''"))
elif status == 'checksumfailed': elif status == 'checksumfailed':
self.ui.labelSubscriptionAddressCheck.setText(_translate( self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "The address is not typed or copied correctly (the checksum failed).")) "MainWindow", "The address is not typed or copied correctly (the checksum failed)."))
elif status == 'versiontoohigh': elif status == 'versiontoohigh':
self.ui.labelSubscriptionAddressCheck.setText(_translate( self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "The version number of this address is higher than this software can support. Please upgrade Bitmessage.")) "MainWindow", "The version number of this address is higher than this software can support. Please upgrade Bitmessage."))
elif status == 'invalidcharacters': elif status == 'invalidcharacters':
self.ui.labelSubscriptionAddressCheck.setText(_translate( self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "The address contains invalid characters.")) "MainWindow", "The address contains invalid characters."))
elif status == 'ripetooshort': elif status == 'ripetooshort':
self.ui.labelSubscriptionAddressCheck.setText(_translate( self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "Some data encoded in the address is too short.")) "MainWindow", "Some data encoded in the address is too short."))
elif status == 'ripetoolong': elif status == 'ripetoolong':
self.ui.labelSubscriptionAddressCheck.setText(_translate( self.ui.labelAddressCheck.setText(_translate(
"MainWindow", "Some data encoded in the address is too long.")) "MainWindow", "Some data encoded in the address is too long."))
elif status == 'success': elif status == 'success':
self.ui.labelSubscriptionAddressCheck.setText( self.ui.labelAddressCheck.setText(
_translate("MainWindow", "Address is valid.")) _translate("MainWindow", "Address is valid."))
if addressVersion <= 3:
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setText(
_translate("MainWindow", "Address is an old type. We cannot display its past broadcasts."))
else:
shared.flushInventory()
doubleHashOfAddressData = hashlib.sha512(hashlib.sha512(encodeVarint(
addressVersion) + encodeVarint(streamNumber) + ripe).digest()).digest()
tag = doubleHashOfAddressData[32:]
queryreturn = sqlQuery(
'''select hash from inventory where objecttype='broadcast' and tag=?''', tag)
if len(queryreturn) == 0:
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setText(
_translate("MainWindow", "There are no recent broadcasts from this address to display."))
elif len(queryreturn) == 1:
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setEnabled(True)
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setText(
_translate("MainWindow", "Display the %1 recent broadcast from this address.").arg(str(len(queryreturn))))
else:
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setEnabled(True)
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setText(
_translate("MainWindow", "Display the %1 recent broadcasts from this address.").arg(str(len(queryreturn))))
class NewAddressDialog(QtGui.QDialog): class NewAddressDialog(QtGui.QDialog):

View File

@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'addaddressdialog.ui'
#
# Created: Sat Nov 30 20:35:38 2013
# by: PyQt4 UI code generator 4.10.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_AddAddressDialog(object):
def setupUi(self, AddAddressDialog):
AddAddressDialog.setObjectName(_fromUtf8("AddAddressDialog"))
AddAddressDialog.resize(368, 162)
self.formLayout = QtGui.QFormLayout(AddAddressDialog)
self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout.setObjectName(_fromUtf8("formLayout"))
self.label_2 = QtGui.QLabel(AddAddressDialog)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.formLayout.setWidget(0, QtGui.QFormLayout.SpanningRole, self.label_2)
self.newAddressLabel = QtGui.QLineEdit(AddAddressDialog)
self.newAddressLabel.setObjectName(_fromUtf8("newAddressLabel"))
self.formLayout.setWidget(2, QtGui.QFormLayout.SpanningRole, self.newAddressLabel)
self.label = QtGui.QLabel(AddAddressDialog)
self.label.setObjectName(_fromUtf8("label"))
self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.label)
self.lineEditAddress = QtGui.QLineEdit(AddAddressDialog)
self.lineEditAddress.setObjectName(_fromUtf8("lineEditAddress"))
self.formLayout.setWidget(5, QtGui.QFormLayout.SpanningRole, self.lineEditAddress)
self.labelAddressCheck = QtGui.QLabel(AddAddressDialog)
self.labelAddressCheck.setText(_fromUtf8(""))
self.labelAddressCheck.setWordWrap(True)
self.labelAddressCheck.setObjectName(_fromUtf8("labelAddressCheck"))
self.formLayout.setWidget(6, QtGui.QFormLayout.SpanningRole, self.labelAddressCheck)
self.buttonBox = QtGui.QDialogButtonBox(AddAddressDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.formLayout.setWidget(7, QtGui.QFormLayout.FieldRole, self.buttonBox)
self.retranslateUi(AddAddressDialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), AddAddressDialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), AddAddressDialog.reject)
QtCore.QMetaObject.connectSlotsByName(AddAddressDialog)
def retranslateUi(self, AddAddressDialog):
AddAddressDialog.setWindowTitle(_translate("AddAddressDialog", "Add new entry", None))
self.label_2.setText(_translate("AddAddressDialog", "Label", None))
self.label.setText(_translate("AddAddressDialog", "Address", None))

View File

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddAddressDialog</class>
<widget class="QDialog" name="AddAddressDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>368</width>
<height>162</height>
</rect>
</property>
<property name="windowTitle">
<string>Add new entry</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLineEdit" name="newAddressLabel"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Address</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLineEdit" name="lineEditAddress"/>
</item>
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="labelAddressCheck">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddAddressDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>360</x>
<y>234</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>256</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddAddressDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>360</x>
<y>240</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>256</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'newsubscriptiondialog.ui' # Form implementation generated from reading ui file 'newsubscriptiondialog.ui'
# #
# Created: Fri Oct 19 15:30:41 2012 # Created: Sat Nov 30 21:53:38 2013
# by: PyQt4 UI code generator 4.9.4 # by: PyQt4 UI code generator 4.10.3
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -12,41 +12,49 @@ from PyQt4 import QtCore, QtGui
try: try:
_fromUtf8 = QtCore.QString.fromUtf8 _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError: except AttributeError:
_fromUtf8 = lambda s: s def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_NewSubscriptionDialog(object): class Ui_NewSubscriptionDialog(object):
def setupUi(self, NewSubscriptionDialog): def setupUi(self, NewSubscriptionDialog):
NewSubscriptionDialog.setObjectName(_fromUtf8("NewSubscriptionDialog")) NewSubscriptionDialog.setObjectName(_fromUtf8("NewSubscriptionDialog"))
NewSubscriptionDialog.resize(368, 192) NewSubscriptionDialog.resize(368, 173)
self.formLayout = QtGui.QFormLayout(NewSubscriptionDialog) self.formLayout = QtGui.QFormLayout(NewSubscriptionDialog)
self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout.setObjectName(_fromUtf8("formLayout")) self.formLayout.setObjectName(_fromUtf8("formLayout"))
self.label_2 = QtGui.QLabel(NewSubscriptionDialog) self.label_2 = QtGui.QLabel(NewSubscriptionDialog)
self.label_2.setObjectName(_fromUtf8("label_2")) self.label_2.setObjectName(_fromUtf8("label_2"))
self.formLayout.setWidget(0, QtGui.QFormLayout.SpanningRole, self.label_2) self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.label_2)
self.newsubscriptionlabel = QtGui.QLineEdit(NewSubscriptionDialog) self.newsubscriptionlabel = QtGui.QLineEdit(NewSubscriptionDialog)
self.newsubscriptionlabel.setObjectName(_fromUtf8("newsubscriptionlabel")) self.newsubscriptionlabel.setObjectName(_fromUtf8("newsubscriptionlabel"))
self.formLayout.setWidget(2, QtGui.QFormLayout.SpanningRole, self.newsubscriptionlabel) self.formLayout.setWidget(1, QtGui.QFormLayout.SpanningRole, self.newsubscriptionlabel)
self.label = QtGui.QLabel(NewSubscriptionDialog) self.label = QtGui.QLabel(NewSubscriptionDialog)
self.label.setObjectName(_fromUtf8("label")) self.label.setObjectName(_fromUtf8("label"))
self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.label) self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.label)
spacerItem = QtGui.QSpacerItem(302, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.formLayout.setItem(4, QtGui.QFormLayout.FieldRole, spacerItem)
self.lineEditSubscriptionAddress = QtGui.QLineEdit(NewSubscriptionDialog) self.lineEditSubscriptionAddress = QtGui.QLineEdit(NewSubscriptionDialog)
self.lineEditSubscriptionAddress.setObjectName(_fromUtf8("lineEditSubscriptionAddress")) self.lineEditSubscriptionAddress.setObjectName(_fromUtf8("lineEditSubscriptionAddress"))
self.formLayout.setWidget(5, QtGui.QFormLayout.SpanningRole, self.lineEditSubscriptionAddress) self.formLayout.setWidget(3, QtGui.QFormLayout.SpanningRole, self.lineEditSubscriptionAddress)
self.labelAddressCheck = QtGui.QLabel(NewSubscriptionDialog)
self.labelAddressCheck.setText(_fromUtf8(""))
self.labelAddressCheck.setWordWrap(True)
self.labelAddressCheck.setObjectName(_fromUtf8("labelAddressCheck"))
self.formLayout.setWidget(4, QtGui.QFormLayout.SpanningRole, self.labelAddressCheck)
self.checkBoxDisplayMessagesAlreadyInInventory = QtGui.QCheckBox(NewSubscriptionDialog)
self.checkBoxDisplayMessagesAlreadyInInventory.setEnabled(False)
self.checkBoxDisplayMessagesAlreadyInInventory.setObjectName(_fromUtf8("checkBoxDisplayMessagesAlreadyInInventory"))
self.formLayout.setWidget(5, QtGui.QFormLayout.SpanningRole, self.checkBoxDisplayMessagesAlreadyInInventory)
self.buttonBox = QtGui.QDialogButtonBox(NewSubscriptionDialog) self.buttonBox = QtGui.QDialogButtonBox(NewSubscriptionDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.formLayout.setWidget(8, QtGui.QFormLayout.FieldRole, self.buttonBox) self.formLayout.setWidget(6, QtGui.QFormLayout.FieldRole, self.buttonBox)
spacerItem1 = QtGui.QSpacerItem(20, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.formLayout.setItem(7, QtGui.QFormLayout.FieldRole, spacerItem1)
self.labelSubscriptionAddressCheck = QtGui.QLabel(NewSubscriptionDialog)
self.labelSubscriptionAddressCheck.setText(_fromUtf8(""))
self.labelSubscriptionAddressCheck.setWordWrap(True)
self.labelSubscriptionAddressCheck.setObjectName(_fromUtf8("labelSubscriptionAddressCheck"))
self.formLayout.setWidget(6, QtGui.QFormLayout.SpanningRole, self.labelSubscriptionAddressCheck)
self.retranslateUi(NewSubscriptionDialog) self.retranslateUi(NewSubscriptionDialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), NewSubscriptionDialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), NewSubscriptionDialog.accept)
@ -54,7 +62,8 @@ class Ui_NewSubscriptionDialog(object):
QtCore.QMetaObject.connectSlotsByName(NewSubscriptionDialog) QtCore.QMetaObject.connectSlotsByName(NewSubscriptionDialog)
def retranslateUi(self, NewSubscriptionDialog): def retranslateUi(self, NewSubscriptionDialog):
NewSubscriptionDialog.setWindowTitle(QtGui.QApplication.translate("NewSubscriptionDialog", "Add new entry", None, QtGui.QApplication.UnicodeUTF8)) NewSubscriptionDialog.setWindowTitle(_translate("NewSubscriptionDialog", "Add new entry", None))
self.label_2.setText(QtGui.QApplication.translate("NewSubscriptionDialog", "Label", None, QtGui.QApplication.UnicodeUTF8)) self.label_2.setText(_translate("NewSubscriptionDialog", "Label", None))
self.label.setText(QtGui.QApplication.translate("NewSubscriptionDialog", "Address", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(_translate("NewSubscriptionDialog", "Address", None))
self.checkBoxDisplayMessagesAlreadyInInventory.setText(_translate("NewSubscriptionDialog", "CheckBox", None))

View File

@ -7,50 +7,54 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>368</width> <width>368</width>
<height>192</height> <height>173</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Add new entry</string> <string>Add new entry</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy"> <item row="0" column="0">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Label</string> <string>Label</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<widget class="QLineEdit" name="newsubscriptionlabel"/> <widget class="QLineEdit" name="newsubscriptionlabel"/>
</item> </item>
<item row="4" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Address</string> <string>Address</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="3" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>302</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLineEdit" name="lineEditSubscriptionAddress"/> <widget class="QLineEdit" name="lineEditSubscriptionAddress"/>
</item> </item>
<item row="8" column="1"> <item row="4" column="0" colspan="2">
<widget class="QLabel" name="labelAddressCheck">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxDisplayMessagesAlreadyInInventory">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -60,29 +64,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="labelSubscriptionAddressCheck">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@ -708,13 +708,18 @@ def checkAndShareBroadcastWithPeers(data):
return return
broadcastVersion, broadcastVersionLength = decodeVarint( broadcastVersion, broadcastVersionLength = decodeVarint(
data[readPosition:readPosition + 10]) data[readPosition:readPosition + 10])
readPosition += broadcastVersionLength
if broadcastVersion >= 2: if broadcastVersion >= 2:
streamNumber, streamNumberLength = decodeVarint(data[ streamNumber, streamNumberLength = decodeVarint(data[readPosition:readPosition + 10])
readPosition + broadcastVersionLength:readPosition + broadcastVersionLength + 10]) readPosition += streamNumberLength
if not streamNumber in streamsInWhichIAmParticipating: if not streamNumber in streamsInWhichIAmParticipating:
print 'The streamNumber', streamNumber, 'isn\'t one we are interested in.' print 'The streamNumber', streamNumber, 'isn\'t one we are interested in.'
return return
if broadcastVersion >= 3:
tag = data[readPosition:readPosition+32]
print 'debugging. in broadcast, tag is:', tag.encode('hex')
else:
tag = ''
shared.numberOfInventoryLookupsPerformed += 1 shared.numberOfInventoryLookupsPerformed += 1
inventoryLock.acquire() inventoryLock.acquire()
inventoryHash = calculateInventoryHash(data) inventoryHash = calculateInventoryHash(data)
@ -729,7 +734,7 @@ def checkAndShareBroadcastWithPeers(data):
# It is valid. Let's let our peers know about it. # It is valid. Let's let our peers know about it.
objectType = 'broadcast' objectType = 'broadcast'
inventory[inventoryHash] = ( inventory[inventoryHash] = (
objectType, streamNumber, data, embeddedTime,'') objectType, streamNumber, data, embeddedTime, tag)
inventorySets[streamNumber].add(inventoryHash) inventorySets[streamNumber].add(inventoryHash)
inventoryLock.release() inventoryLock.release()
# This object is valid. Forward it to peers. # This object is valid. Forward it to peers.