Returned AddAddressDialog and NewSubscriptionDialog into dialogs module
where it's been initialized by loading the ui-files.
This commit is contained in:
parent
81c80aa98f
commit
d9d9f9d787
|
@ -27,7 +27,6 @@ from newaddresswizard import *
|
||||||
from messageview import MessageView
|
from messageview import MessageView
|
||||||
from migrationwizard import *
|
from migrationwizard import *
|
||||||
from foldertree import *
|
from foldertree import *
|
||||||
from newsubscriptiondialog import *
|
|
||||||
from regenerateaddresses import *
|
from regenerateaddresses import *
|
||||||
from newchandialog import *
|
from newchandialog import *
|
||||||
from safehtmlparser import *
|
from safehtmlparser import *
|
||||||
|
@ -51,14 +50,14 @@ import debug
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from helper_sql import *
|
|
||||||
from helper_ackPayload import genAckPayload
|
from helper_ackPayload import genAckPayload
|
||||||
|
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
|
||||||
import helper_search
|
import helper_search
|
||||||
import l10n
|
import l10n
|
||||||
import openclpow
|
import openclpow
|
||||||
from utils import str_broadcast_subscribers, avatarize
|
from utils import str_broadcast_subscribers, avatarize
|
||||||
from account import *
|
from account import *
|
||||||
from dialogs import AddAddressDialog
|
import dialogs
|
||||||
from helper_generic import powQueueSize
|
from helper_generic import powQueueSize
|
||||||
from inventory import (
|
from inventory import (
|
||||||
Inventory, PendingDownloadQueue, PendingUpload,
|
Inventory, PendingDownloadQueue, PendingUpload,
|
||||||
|
@ -2140,71 +2139,85 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
def click_pushButtonAddAddressBook(self, dialog=None):
|
def click_pushButtonAddAddressBook(self, dialog=None):
|
||||||
if not dialog:
|
if not dialog:
|
||||||
dialog = AddAddressDialog(self)
|
dialog = dialogs.AddAddressDialog(self)
|
||||||
if dialog.exec_():
|
if dialog.exec_():
|
||||||
if dialog.ui.labelAddressCheck.text() == \
|
if not dialog.valid:
|
||||||
_translate("MainWindow", "Address is valid."):
|
|
||||||
# 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
|
|
||||||
# cause problems when updating and deleting the entry.
|
|
||||||
address = addBMIfNotPresent(
|
|
||||||
str(dialog.ui.lineEditAddress.text()))
|
|
||||||
label = str(dialog.ui.newAddressLabel.text().toUtf8())
|
|
||||||
self.addEntryToAddressBook(address, label)
|
|
||||||
else:
|
|
||||||
self.statusBar().showMessage(_translate(
|
self.statusBar().showMessage(_translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
"The address you entered was invalid. Ignoring it."
|
"The address you entered was invalid. Ignoring it."
|
||||||
), 10000)
|
), 10000)
|
||||||
|
return
|
||||||
|
|
||||||
|
address = addBMIfNotPresent(str(dialog.lineEditAddress.text()))
|
||||||
|
# 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
|
||||||
|
# cause problems when updating and deleting the entry.
|
||||||
|
if shared.isAddressInMyAddressBook(address):
|
||||||
|
self.statusBar().showMessage(_translate(
|
||||||
|
"MainWindow",
|
||||||
|
"Error: You cannot add the same address to your"
|
||||||
|
" address book twice. Try renaming the existing one"
|
||||||
|
" if you want."
|
||||||
|
), 10000)
|
||||||
|
return
|
||||||
|
label = str(dialog.lineEditLabel.text().toUtf8())
|
||||||
|
self.addEntryToAddressBook(address, label)
|
||||||
|
|
||||||
def addEntryToAddressBook(self, address, label):
|
def addEntryToAddressBook(self, address, label):
|
||||||
queryreturn = sqlQuery(
|
if shared.isAddressInMyAddressBook(address):
|
||||||
'''select * from addressbook where address=?''', address)
|
return
|
||||||
if queryreturn == []:
|
sqlExecute('''INSERT INTO addressbook VALUES (?,?)''', label, address)
|
||||||
sqlExecute('''INSERT INTO addressbook VALUES (?,?)''',
|
|
||||||
label, address)
|
|
||||||
self.rerenderMessagelistFromLabels()
|
self.rerenderMessagelistFromLabels()
|
||||||
self.rerenderMessagelistToLabels()
|
self.rerenderMessagelistToLabels()
|
||||||
self.rerenderAddressBook()
|
self.rerenderAddressBook()
|
||||||
else:
|
|
||||||
self.statusBar().showMessage(_translate(
|
|
||||||
"MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want."), 10000)
|
|
||||||
|
|
||||||
def addSubscription(self, address, label):
|
def addSubscription(self, address, label):
|
||||||
address = addBMIfNotPresent(address)
|
# This should be handled outside of this function, for error displaying
|
||||||
#This should be handled outside of this function, for error displaying and such, but it must also be checked here.
|
# and such, but it must also be checked here.
|
||||||
if shared.isAddressInMySubscriptionsList(address):
|
if shared.isAddressInMySubscriptionsList(address):
|
||||||
return
|
return
|
||||||
#Add to database (perhaps this should be separated from the MyForm class)
|
# Add to database (perhaps this should be separated from the MyForm class)
|
||||||
sqlExecute('''INSERT INTO subscriptions VALUES (?,?,?)''',str(label),address,True)
|
sqlExecute(
|
||||||
|
'''INSERT INTO subscriptions VALUES (?,?,?)''',
|
||||||
|
label, address, True
|
||||||
|
)
|
||||||
self.rerenderMessagelistFromLabels()
|
self.rerenderMessagelistFromLabels()
|
||||||
shared.reloadBroadcastSendersForWhichImWatching()
|
shared.reloadBroadcastSendersForWhichImWatching()
|
||||||
self.rerenderAddressBook()
|
self.rerenderAddressBook()
|
||||||
self.rerenderTabTreeSubscriptions()
|
self.rerenderTabTreeSubscriptions()
|
||||||
|
|
||||||
def click_pushButtonAddSubscription(self):
|
def click_pushButtonAddSubscription(self):
|
||||||
self.NewSubscriptionDialogInstance = NewSubscriptionDialog(self)
|
dialog = dialogs.NewSubscriptionDialog(self)
|
||||||
if self.NewSubscriptionDialogInstance.exec_():
|
if dialog.exec_():
|
||||||
if self.NewSubscriptionDialogInstance.ui.labelAddressCheck.text() != _translate("MainWindow", "Address is valid."):
|
if not dialog.valid:
|
||||||
self.statusBar().showMessage(_translate("MainWindow", "The address you entered was invalid. Ignoring it."), 10000)
|
self.statusBar().showMessage(_translate(
|
||||||
|
"MainWindow",
|
||||||
|
"The address you entered was invalid. Ignoring it."
|
||||||
|
), 10000)
|
||||||
return
|
return
|
||||||
address = addBMIfNotPresent(str(self.NewSubscriptionDialogInstance.ui.lineEditSubscriptionAddress.text()))
|
|
||||||
# We must check to see if the address is already in the subscriptions list. The user cannot add it again or else it will cause problems when updating and deleting the entry.
|
address = addBMIfNotPresent(str(dialog.lineEditAddress.text()))
|
||||||
|
# We must check to see if the address is already in the
|
||||||
|
# subscriptions list. The user cannot add it again or else it
|
||||||
|
# will cause problems when updating and deleting the entry.
|
||||||
if shared.isAddressInMySubscriptionsList(address):
|
if shared.isAddressInMySubscriptionsList(address):
|
||||||
self.statusBar().showMessage(_translate("MainWindow", "Error: You cannot add the same address to your subscriptions twice. Perhaps rename the existing one if you want."), 10000)
|
self.statusBar().showMessage(_translate(
|
||||||
|
"MainWindow",
|
||||||
|
"Error: You cannot add the same address to your"
|
||||||
|
" subscriptions twice. Perhaps rename the existing one"
|
||||||
|
" if you want."
|
||||||
|
), 10000)
|
||||||
return
|
return
|
||||||
label = self.NewSubscriptionDialogInstance.ui.newsubscriptionlabel.text().toUtf8()
|
label = str(dialog.lineEditLabel.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
|
# Now, if the user wants to display old broadcasts, let's get
|
||||||
# in the objectProcessorQueue to be processed
|
# them out of the inventory and put them
|
||||||
if self.NewSubscriptionDialogInstance.ui.checkBoxDisplayMessagesAlreadyInInventory.isChecked():
|
# to the objectProcessorQueue to be processed
|
||||||
status, addressVersion, streamNumber, ripe = decodeAddress(address)
|
if dialog.checkBoxDisplayMessagesAlreadyInInventory.isChecked():
|
||||||
Inventory().flush()
|
for value in dialog.recent:
|
||||||
doubleHashOfAddressData = hashlib.sha512(hashlib.sha512(encodeVarint(
|
queues.objectProcessorQueue.put((
|
||||||
addressVersion) + encodeVarint(streamNumber) + ripe).digest()).digest()
|
value.type, value.payload
|
||||||
tag = doubleHashOfAddressData[32:]
|
))
|
||||||
for value in Inventory().by_type_and_tag(3, tag):
|
|
||||||
queues.objectProcessorQueue.put((value.type, value.payload))
|
|
||||||
|
|
||||||
def click_pushButtonStatusIcon(self):
|
def click_pushButtonStatusIcon(self):
|
||||||
logger.debug('click_pushButtonStatusIcon')
|
logger.debug('click_pushButtonStatusIcon')
|
||||||
|
@ -2942,8 +2955,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
addressAtCurrentInboxRow = tableWidget.item(
|
addressAtCurrentInboxRow = tableWidget.item(
|
||||||
currentInboxRow, 1).data(Qt.UserRole)
|
currentInboxRow, 1).data(Qt.UserRole)
|
||||||
self.ui.tabWidget.setCurrentIndex(1)
|
self.ui.tabWidget.setCurrentIndex(1)
|
||||||
dialog = AddAddressDialog(self)
|
dialog = dialogs.AddAddressDialog(self)
|
||||||
dialog.ui.lineEditAddress.setText(addressAtCurrentInboxRow)
|
dialog.lineEditAddress.setText(addressAtCurrentInboxRow)
|
||||||
self.click_pushButtonAddAddressBook(dialog)
|
self.click_pushButtonAddAddressBook(dialog)
|
||||||
|
|
||||||
def on_action_InboxAddSenderToBlackList(self):
|
def on_action_InboxAddSenderToBlackList(self):
|
||||||
|
@ -4280,64 +4293,6 @@ class EmailGatewayRegistrationDialog(QtGui.QDialog):
|
||||||
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||||
|
|
||||||
|
|
||||||
class NewSubscriptionDialog(QtGui.QDialog):
|
|
||||||
|
|
||||||
def __init__(self, parent):
|
|
||||||
QtGui.QWidget.__init__(self, parent)
|
|
||||||
self.ui = Ui_NewSubscriptionDialog()
|
|
||||||
self.ui.setupUi(self)
|
|
||||||
self.parent = parent
|
|
||||||
QtCore.QObject.connect(self.ui.lineEditSubscriptionAddress, QtCore.SIGNAL(
|
|
||||||
"textChanged(QString)"), self.addressChanged)
|
|
||||||
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setText(
|
|
||||||
_translate("MainWindow", "Enter an address above."))
|
|
||||||
|
|
||||||
def addressChanged(self, QString):
|
|
||||||
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setEnabled(False)
|
|
||||||
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setChecked(False)
|
|
||||||
status, addressVersion, streamNumber, ripe = 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 == 'varintmalformed':
|
|
||||||
self.ui.labelAddressCheck.setText(_translate(
|
|
||||||
"MainWindow", "Some data encoded in the address is malformed."))
|
|
||||||
elif status == 'success':
|
|
||||||
self.ui.labelAddressCheck.setText(
|
|
||||||
_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:
|
|
||||||
Inventory().flush()
|
|
||||||
doubleHashOfAddressData = hashlib.sha512(hashlib.sha512(encodeVarint(
|
|
||||||
addressVersion) + encodeVarint(streamNumber) + ripe).digest()).digest()
|
|
||||||
tag = doubleHashOfAddressData[32:]
|
|
||||||
count = len(Inventory().by_type_and_tag(3, tag))
|
|
||||||
if count == 0:
|
|
||||||
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setText(
|
|
||||||
_translate("MainWindow", "There are no recent broadcasts from this address to display."))
|
|
||||||
else:
|
|
||||||
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setEnabled(True)
|
|
||||||
self.ui.checkBoxDisplayMessagesAlreadyInInventory.setText(
|
|
||||||
_translate("MainWindow", "Display the %1 recent broadcast(s) from this address.").arg(count))
|
|
||||||
|
|
||||||
|
|
||||||
class NewAddressDialog(QtGui.QDialog):
|
class NewAddressDialog(QtGui.QDialog):
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
# -*- 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))
|
|
||||||
|
|
|
@ -7,9 +7,15 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>368</width>
|
<width>368</width>
|
||||||
<height>162</height>
|
<height>232</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>368</width>
|
||||||
|
<height>200</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Add new entry</string>
|
<string>Add new entry</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -25,7 +31,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="2" column="0" colspan="2">
|
||||||
<widget class="QLineEdit" name="newAddressLabel"/>
|
<widget class="QLineEdit" name="lineEditLabel"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
@ -47,7 +53,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="8" 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>
|
||||||
|
@ -57,6 +63,19 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="7" column="1">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -1,42 +1,107 @@
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from addaddressdialog import Ui_AddAddressDialog
|
from addresses import decodeAddress, encodeVarint
|
||||||
from addresses import decodeAddress
|
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
from retranslateui import RetranslateMixin
|
||||||
|
import widgets
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
from inventory import Inventory
|
||||||
|
|
||||||
|
|
||||||
class AddAddressDialog(QtGui.QDialog):
|
class AddressCheckMixin(object):
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self):
|
||||||
QtGui.QWidget.__init__(self, parent)
|
self.valid = False
|
||||||
self.ui = Ui_AddAddressDialog()
|
QtCore.QObject.connect(self.lineEditAddress, QtCore.SIGNAL(
|
||||||
self.ui.setupUi(self)
|
|
||||||
self.parent = parent
|
|
||||||
QtCore.QObject.connect(self.ui.lineEditAddress, QtCore.SIGNAL(
|
|
||||||
"textChanged(QString)"), self.addressChanged)
|
"textChanged(QString)"), self.addressChanged)
|
||||||
|
|
||||||
|
def _onSuccess(self, addressVersion, streamNumber, ripe):
|
||||||
|
pass
|
||||||
|
|
||||||
def addressChanged(self, QString):
|
def addressChanged(self, QString):
|
||||||
status, a, b, c = decodeAddress(str(QString))
|
status, addressVersion, streamNumber, ripe = decodeAddress(
|
||||||
if status == 'missingbm':
|
str(QString))
|
||||||
self.ui.labelAddressCheck.setText(_translate(
|
self.valid = status == 'success'
|
||||||
|
if self.valid:
|
||||||
|
self.labelAddressCheck.setText(
|
||||||
|
_translate("MainWindow", "Address is valid."))
|
||||||
|
self._onSuccess(addressVersion, streamNumber, ripe)
|
||||||
|
elif status == 'missingbm':
|
||||||
|
self.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.labelAddressCheck.setText(_translate(
|
self.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.labelAddressCheck.setText(_translate(
|
self.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.labelAddressCheck.setText(_translate(
|
self.labelAddressCheck.setText(_translate(
|
||||||
"MainWindow", "The address contains invalid characters."))
|
"MainWindow", "The address contains invalid characters."))
|
||||||
elif status == 'ripetooshort':
|
elif status == 'ripetooshort':
|
||||||
self.ui.labelAddressCheck.setText(_translate(
|
self.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.labelAddressCheck.setText(_translate(
|
self.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 == 'varintmalformed':
|
elif status == 'varintmalformed':
|
||||||
self.ui.labelAddressCheck.setText(_translate(
|
self.labelAddressCheck.setText(_translate(
|
||||||
"MainWindow", "Some data encoded in the address is malformed."))
|
"MainWindow",
|
||||||
elif status == 'success':
|
"Some data encoded in the address is malformed."
|
||||||
self.ui.labelAddressCheck.setText(
|
))
|
||||||
_translate("MainWindow", "Address is valid."))
|
|
||||||
|
|
||||||
|
class AddAddressDialog(QtGui.QDialog, RetranslateMixin, AddressCheckMixin):
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super(AddAddressDialog, self).__init__(parent)
|
||||||
|
widgets.load('addaddressdialog.ui', self)
|
||||||
|
AddressCheckMixin.__init__(self)
|
||||||
|
|
||||||
|
|
||||||
|
class NewSubscriptionDialog(
|
||||||
|
QtGui.QDialog, RetranslateMixin, AddressCheckMixin):
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super(NewSubscriptionDialog, self).__init__(parent)
|
||||||
|
widgets.load('newsubscriptiondialog.ui', self)
|
||||||
|
AddressCheckMixin.__init__(self)
|
||||||
|
|
||||||
|
def _onSuccess(self, addressVersion, streamNumber, ripe):
|
||||||
|
if addressVersion <= 3:
|
||||||
|
self.checkBoxDisplayMessagesAlreadyInInventory.setText(_translate(
|
||||||
|
"MainWindow",
|
||||||
|
"Address is an old type. We cannot display its past"
|
||||||
|
" broadcasts."
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
Inventory().flush()
|
||||||
|
doubleHashOfAddressData = hashlib.sha512(hashlib.sha512(
|
||||||
|
encodeVarint(addressVersion) +
|
||||||
|
encodeVarint(streamNumber) + ripe
|
||||||
|
).digest()).digest()
|
||||||
|
tag = doubleHashOfAddressData[32:]
|
||||||
|
self.recent = Inventory().by_type_and_tag(3, tag)
|
||||||
|
count = len(self.recent)
|
||||||
|
if count == 0:
|
||||||
|
self.checkBoxDisplayMessagesAlreadyInInventory.setText(
|
||||||
|
_translate(
|
||||||
|
"MainWindow",
|
||||||
|
"There are no recent broadcasts from this address"
|
||||||
|
" to display."
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
self.checkBoxDisplayMessagesAlreadyInInventory.setEnabled(True)
|
||||||
|
self.checkBoxDisplayMessagesAlreadyInInventory.setText(
|
||||||
|
_translate(
|
||||||
|
"MainWindow",
|
||||||
|
"Display the %1 recent broadcast(s) from this address."
|
||||||
|
).arg(count))
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'newsubscriptiondialog.ui'
|
|
||||||
#
|
|
||||||
# Created: Sat Nov 30 21:53: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_NewSubscriptionDialog(object):
|
|
||||||
def setupUi(self, NewSubscriptionDialog):
|
|
||||||
NewSubscriptionDialog.setObjectName(_fromUtf8("NewSubscriptionDialog"))
|
|
||||||
NewSubscriptionDialog.resize(368, 173)
|
|
||||||
self.formLayout = QtGui.QFormLayout(NewSubscriptionDialog)
|
|
||||||
self.formLayout.setObjectName(_fromUtf8("formLayout"))
|
|
||||||
self.label_2 = QtGui.QLabel(NewSubscriptionDialog)
|
|
||||||
self.label_2.setObjectName(_fromUtf8("label_2"))
|
|
||||||
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.label_2)
|
|
||||||
self.newsubscriptionlabel = QtGui.QLineEdit(NewSubscriptionDialog)
|
|
||||||
self.newsubscriptionlabel.setObjectName(_fromUtf8("newsubscriptionlabel"))
|
|
||||||
self.formLayout.setWidget(1, QtGui.QFormLayout.SpanningRole, self.newsubscriptionlabel)
|
|
||||||
self.label = QtGui.QLabel(NewSubscriptionDialog)
|
|
||||||
self.label.setObjectName(_fromUtf8("label"))
|
|
||||||
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.label)
|
|
||||||
self.lineEditSubscriptionAddress = QtGui.QLineEdit(NewSubscriptionDialog)
|
|
||||||
self.lineEditSubscriptionAddress.setObjectName(_fromUtf8("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.setOrientation(QtCore.Qt.Horizontal)
|
|
||||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
|
|
||||||
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
|
||||||
self.formLayout.setWidget(6, QtGui.QFormLayout.FieldRole, self.buttonBox)
|
|
||||||
|
|
||||||
self.retranslateUi(NewSubscriptionDialog)
|
|
||||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), NewSubscriptionDialog.accept)
|
|
||||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), NewSubscriptionDialog.reject)
|
|
||||||
QtCore.QMetaObject.connectSlotsByName(NewSubscriptionDialog)
|
|
||||||
|
|
||||||
def retranslateUi(self, NewSubscriptionDialog):
|
|
||||||
NewSubscriptionDialog.setWindowTitle(_translate("NewSubscriptionDialog", "Add new entry", None))
|
|
||||||
self.label_2.setText(_translate("NewSubscriptionDialog", "Label", None))
|
|
||||||
self.label.setText(_translate("NewSubscriptionDialog", "Address", None))
|
|
||||||
self.checkBoxDisplayMessagesAlreadyInInventory.setText(_translate("NewSubscriptionDialog", "Enter an address above.", None))
|
|
||||||
|
|
|
@ -7,9 +7,15 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>368</width>
|
<width>368</width>
|
||||||
<height>173</height>
|
<height>254</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>368</width>
|
||||||
|
<height>200</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Add new entry</string>
|
<string>Add new entry</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -22,7 +28,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QLineEdit" name="newsubscriptionlabel"/>
|
<widget class="QLineEdit" name="lineEditLabel"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
@ -32,7 +38,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QLineEdit" name="lineEditSubscriptionAddress"/>
|
<widget class="QLineEdit" name="lineEditAddress"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="2">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="labelAddressCheck">
|
<widget class="QLabel" name="labelAddressCheck">
|
||||||
|
@ -44,17 +50,17 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="2">
|
<item row="6" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="checkBoxDisplayMessagesAlreadyInInventory">
|
<widget class="QCheckBox" name="checkBoxDisplayMessagesAlreadyInInventory">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>CheckBox</string>
|
<string>Enter an address above.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="7" 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>
|
||||||
|
@ -64,6 +70,19 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user