Skip to content

Commit 2a561c0

Browse files
committed
Fix reply-to subscriptions and labels
Closes Bitmessage#1 Also attempts to solve Bitmessage#49 but needs testing.
1 parent 8688e72 commit 2a561c0

File tree

1 file changed

+36
-29
lines changed

1 file changed

+36
-29
lines changed

src/bitmessageqt/__init__.py

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ class MyForm(QtGui.QMainWindow):
8989
# the maximum frequency of message sounds in seconds
9090
maxSoundFrequencySec = 60
9191

92-
str_broadcast_subscribers = '[Broadcast subscribers]'
9392
str_chan = '[chan]'
9493

9594
def init_file_menu(self):
@@ -1161,7 +1160,7 @@ def ubuntuMessagingMenuClear(self, inventoryHash):
11611160
for row in queryreturn:
11621161
toAddress, read = row
11631162
if not read:
1164-
if toAddress == self.str_broadcast_subscribers:
1163+
if toAddress == str_broadcast_subscribers:
11651164
if self.mmapp.has_source("Subscriptions"):
11661165
self.mmapp.remove_source("Subscriptions")
11671166
else:
@@ -1179,8 +1178,8 @@ def getUnread(self):
11791178
msgid, toAddress, read = row
11801179

11811180
try:
1182-
if toAddress == self.str_broadcast_subscribers:
1183-
toLabel = self.str_broadcast_subscribers
1181+
if toAddress == str_broadcast_subscribers:
1182+
toLabel = str_broadcast_subscribers
11841183
else:
11851184
toLabel = shared.config.get(toAddress, 'label')
11861185
except:
@@ -1189,7 +1188,7 @@ def getUnread(self):
11891188
toLabel = toAddress
11901189

11911190
if not read:
1192-
if toLabel == self.str_broadcast_subscribers:
1191+
if toLabel == str_broadcast_subscribers:
11931192
# increment the unread subscriptions
11941193
unreadSubscriptions = unreadSubscriptions + 1
11951194
else:
@@ -1254,7 +1253,7 @@ def ubuntuMessagingMenuUpdate(self, drawAttention, newItem, toLabel):
12541253
return
12551254

12561255
# remember this item to that the messaging menu can find it
1257-
if toLabel == self.str_broadcast_subscribers:
1256+
if toLabel == str_broadcast_subscribers:
12581257
self.newBroadcastItem = newItem
12591258
else:
12601259
self.newMessageItem = newItem
@@ -2096,7 +2095,7 @@ def click_pushButtonSend(self):
20962095
# this is a broadcast message, but we can use it to update the
20972096
# user interface when the POW is done generating.
20982097
ackdata = OpenSSL.rand(32)
2099-
toAddress = self.str_broadcast_subscribers
2098+
toAddress = str_broadcast_subscribers
21002099
ripe = ''
21012100
t = ('', # msgid. We don't know what this will be until the POW is done.
21022101
toAddress,
@@ -2117,7 +2116,7 @@ def click_pushButtonSend(self):
21172116
sqlExecute(
21182117
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
21192118

2120-
toLabel = self.str_broadcast_subscribers
2119+
toLabel = str_broadcast_subscribers
21212120

21222121
self.displayNewSentMessage(
21232122
toAddress, toLabel, fromAddress, subject, message, ackdata)
@@ -2177,15 +2176,13 @@ def rerenderComboBoxSendFrom(self):
21772176

21782177
def rerenderComboBoxSendFromBroadcast(self):
21792178
self.ui.comboBoxSendFromBroadcast.clear()
2180-
configSections = shared.config.sections()
2181-
for addressInKeysFile in configSections:
2182-
if addressInKeysFile != 'bitmessagesettings':
2183-
isEnabled = shared.config.getboolean(
2184-
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
2185-
isMaillinglist = shared.safeConfigGetBoolean(addressInKeysFile, 'mailinglist')
2186-
if isEnabled and isMaillinglist:
2187-
self.ui.comboBoxSendFromBroadcast.insertItem(0, avatarize(addressInKeysFile), unicode(shared.config.get(
2188-
addressInKeysFile, 'label'), 'utf-8'), addressInKeysFile)
2179+
queryreturn = sqlQuery(
2180+
'''select label, address from subscriptions where enabled = 1'''
2181+
)
2182+
2183+
for row in queryreturn:
2184+
label, address = row
2185+
self.ui.comboBoxSendFromBroadcast.insertItem(0, avatarize(address), unicode(label, 'utf-8'), address)
21892186
self.ui.comboBoxSendFromBroadcast.insertItem(0, '', '')
21902187
if(self.ui.comboBoxSendFromBroadcast.count() == 2):
21912188
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(1)
@@ -2861,40 +2858,50 @@ def on_action_InboxReply(self):
28612858
for row in queryreturn:
28622859
messageAtCurrentInboxRow, = row
28632860
acct.parseMessage(toAddressAtCurrentInboxRow, fromAddressAtCurrentInboxRow, str(tableWidget.item(currentInboxRow, 2).data(Qt.UserRole).toPyObject()), messageAtCurrentInboxRow)
2864-
if toAddressAtCurrentInboxRow == self.str_broadcast_subscribers:
2865-
#TODO what does this if?..
2866-
a = a
2861+
widget = {
2862+
'subject': self.ui.lineEditSubject,
2863+
'from': self.ui.comboBoxSendFrom,
2864+
'message': self.ui.textEditMessage
2865+
}
2866+
if toAddressAtCurrentInboxRow == str_broadcast_subscribers:
2867+
widget = {
2868+
'subject': self.ui.lineEditSubjectBroadcast,
2869+
'from': self.ui.comboBoxSendFromBroadcast,
2870+
'message': self.ui.textEditMessageBroadcast
2871+
}
2872+
self.ui.tabWidgetSend.setCurrentIndex(1)
2873+
toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
28672874
elif not shared.config.has_section(toAddressAtCurrentInboxRow):
28682875
QtGui.QMessageBox.information(self, _translate("MainWindow", "Address is gone"), _translate(
28692876
"MainWindow", "Bitmessage cannot find your address %1. Perhaps you removed it?").arg(toAddressAtCurrentInboxRow), QMessageBox.Ok)
28702877
elif not shared.config.getboolean(toAddressAtCurrentInboxRow, 'enabled'):
28712878
QtGui.QMessageBox.information(self, _translate("MainWindow", "Address disabled"), _translate(
28722879
"MainWindow", "Error: The address from which you are trying to send is disabled. You\'ll have to enable it on the \'Your Identities\' tab before using it."), QMessageBox.Ok)
28732880
else:
2874-
self.setBroadcastEnablementDependingOnWhetherThisIsAChanAddress(toAddressAtCurrentInboxRow)
2881+
#self.setBroadcastEnablementDependingOnWhetherThisIsAChanAddress(toAddressAtCurrentInboxRow)
2882+
self.ui.tabWidgetSend.setCurrentIndex(0)
28752883

2876-
self.ui.lineEditTo.setText(str(acct.fromLabel))
2884+
self.ui.lineEditTo.setText(str(acct.fromAddress))
28772885

28782886
# If the previous message was to a chan then we should send our reply to the chan rather than to the particular person who sent the message.
28792887
if shared.config.has_section(toAddressAtCurrentInboxRow):
28802888
if shared.safeConfigGetBoolean(toAddressAtCurrentInboxRow, 'chan'):
28812889
print 'original sent to a chan. Setting the to address in the reply to the chan address.'
28822890
self.ui.lineEditTo.setText(str(toAddressAtCurrentInboxRow))
28832891

2884-
listOfAddressesInComboBoxSendFrom = [str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) for i in range(self.ui.comboBoxSendFrom.count())]
2892+
listOfAddressesInComboBoxSendFrom = [str(widget['from'].itemData(i).toPyObject()) for i in range(widget['from'].count())]
28852893
if toAddressAtCurrentInboxRow in listOfAddressesInComboBoxSendFrom:
28862894
currentIndex = listOfAddressesInComboBoxSendFrom.index(toAddressAtCurrentInboxRow)
2887-
self.ui.comboBoxSendFrom.setCurrentIndex(currentIndex)
2895+
widget['from'].setCurrentIndex(currentIndex)
28882896
else:
2889-
self.ui.comboBoxSendFrom.setCurrentIndex(0)
2897+
widget['from'].setCurrentIndex(0)
28902898

28912899
quotedText = self.quoted_text(unicode(messageAtCurrentInboxRow, 'utf-8'))
2892-
self.ui.textEditMessage.setText(quotedText)
2900+
widget['message'].setText(quotedText)
28932901
if acct.subject[0:3] in ['Re:', 'RE:']:
2894-
self.ui.lineEditSubject.setText(acct.subject)
2902+
widget['subject'].setText(acct.subject)
28952903
else:
2896-
self.ui.lineEditSubject.setText('Re: ' + acct.subject)
2897-
self.ui.tabWidgetSend.setCurrentIndex(0)
2904+
widget['subject'].setText('Re: ' + acct.subject)
28982905
self.ui.tabWidget.setCurrentIndex(1)
28992906

29002907
def on_action_InboxAddSenderToAddressBook(self):

0 commit comments

Comments
 (0)