Skip to content

Commit bf9bdaa

Browse files
mailchuckPeterSurda
authored andcommitted
Fix reply-to subscriptions and labels
Closes #1 Also attempts to solve #49 but needs testing.
1 parent 2320774 commit bf9bdaa

File tree

1 file changed

+36
-29
lines changed

1 file changed

+36
-29
lines changed

src/bitmessageqt/__init__.py

+36-29
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
@@ -2098,7 +2097,7 @@ def click_pushButtonSend(self):
20982097
# this is a broadcast message, but we can use it to update the
20992098
# user interface when the POW is done generating.
21002099
ackdata = OpenSSL.rand(32)
2101-
toAddress = self.str_broadcast_subscribers
2100+
toAddress = str_broadcast_subscribers
21022101
ripe = ''
21032102
t = ('', # msgid. We don't know what this will be until the POW is done.
21042103
toAddress,
@@ -2119,7 +2118,7 @@ def click_pushButtonSend(self):
21192118
sqlExecute(
21202119
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
21212120

2122-
toLabel = self.str_broadcast_subscribers
2121+
toLabel = str_broadcast_subscribers
21232122

21242123
self.displayNewSentMessage(
21252124
toAddress, toLabel, fromAddress, subject, message, ackdata)
@@ -2179,15 +2178,13 @@ def rerenderComboBoxSendFrom(self):
21792178

21802179
def rerenderComboBoxSendFromBroadcast(self):
21812180
self.ui.comboBoxSendFromBroadcast.clear()
2182-
configSections = shared.config.sections()
2183-
for addressInKeysFile in configSections:
2184-
if addressInKeysFile != 'bitmessagesettings':
2185-
isEnabled = shared.config.getboolean(
2186-
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
2187-
isMaillinglist = shared.safeConfigGetBoolean(addressInKeysFile, 'mailinglist')
2188-
if isEnabled and isMaillinglist:
2189-
self.ui.comboBoxSendFromBroadcast.insertItem(0, avatarize(addressInKeysFile), unicode(shared.config.get(
2190-
addressInKeysFile, 'label'), 'utf-8'), addressInKeysFile)
2181+
queryreturn = sqlQuery(
2182+
'''select label, address from subscriptions where enabled = 1'''
2183+
)
2184+
2185+
for row in queryreturn:
2186+
label, address = row
2187+
self.ui.comboBoxSendFromBroadcast.insertItem(0, avatarize(address), unicode(label, 'utf-8'), address)
21912188
self.ui.comboBoxSendFromBroadcast.insertItem(0, '', '')
21922189
if(self.ui.comboBoxSendFromBroadcast.count() == 2):
21932190
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(1)
@@ -2863,40 +2860,50 @@ def on_action_InboxReply(self):
28632860
for row in queryreturn:
28642861
messageAtCurrentInboxRow, = row
28652862
acct.parseMessage(toAddressAtCurrentInboxRow, fromAddressAtCurrentInboxRow, str(tableWidget.item(currentInboxRow, 2).data(Qt.UserRole).toPyObject()), messageAtCurrentInboxRow)
2866-
if toAddressAtCurrentInboxRow == self.str_broadcast_subscribers:
2867-
#TODO what does this if?..
2868-
a = a
2863+
widget = {
2864+
'subject': self.ui.lineEditSubject,
2865+
'from': self.ui.comboBoxSendFrom,
2866+
'message': self.ui.textEditMessage
2867+
}
2868+
if toAddressAtCurrentInboxRow == str_broadcast_subscribers:
2869+
widget = {
2870+
'subject': self.ui.lineEditSubjectBroadcast,
2871+
'from': self.ui.comboBoxSendFromBroadcast,
2872+
'message': self.ui.textEditMessageBroadcast
2873+
}
2874+
self.ui.tabWidgetSend.setCurrentIndex(1)
2875+
toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
28692876
elif not shared.config.has_section(toAddressAtCurrentInboxRow):
28702877
QtGui.QMessageBox.information(self, _translate("MainWindow", "Address is gone"), _translate(
28712878
"MainWindow", "Bitmessage cannot find your address %1. Perhaps you removed it?").arg(toAddressAtCurrentInboxRow), QMessageBox.Ok)
28722879
elif not shared.config.getboolean(toAddressAtCurrentInboxRow, 'enabled'):
28732880
QtGui.QMessageBox.information(self, _translate("MainWindow", "Address disabled"), _translate(
28742881
"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)
28752882
else:
2876-
self.setBroadcastEnablementDependingOnWhetherThisIsAChanAddress(toAddressAtCurrentInboxRow)
2883+
#self.setBroadcastEnablementDependingOnWhetherThisIsAChanAddress(toAddressAtCurrentInboxRow)
2884+
self.ui.tabWidgetSend.setCurrentIndex(0)
28772885

2878-
self.ui.lineEditTo.setText(str(acct.fromLabel))
2886+
self.ui.lineEditTo.setText(str(acct.fromAddress))
28792887

28802888
# 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.
28812889
if shared.config.has_section(toAddressAtCurrentInboxRow):
28822890
if shared.safeConfigGetBoolean(toAddressAtCurrentInboxRow, 'chan'):
28832891
print 'original sent to a chan. Setting the to address in the reply to the chan address.'
28842892
self.ui.lineEditTo.setText(str(toAddressAtCurrentInboxRow))
28852893

2886-
listOfAddressesInComboBoxSendFrom = [str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) for i in range(self.ui.comboBoxSendFrom.count())]
2894+
listOfAddressesInComboBoxSendFrom = [str(widget['from'].itemData(i).toPyObject()) for i in range(widget['from'].count())]
28872895
if toAddressAtCurrentInboxRow in listOfAddressesInComboBoxSendFrom:
28882896
currentIndex = listOfAddressesInComboBoxSendFrom.index(toAddressAtCurrentInboxRow)
2889-
self.ui.comboBoxSendFrom.setCurrentIndex(currentIndex)
2897+
widget['from'].setCurrentIndex(currentIndex)
28902898
else:
2891-
self.ui.comboBoxSendFrom.setCurrentIndex(0)
2899+
widget['from'].setCurrentIndex(0)
28922900

28932901
quotedText = self.quoted_text(unicode(messageAtCurrentInboxRow, 'utf-8'))
2894-
self.ui.textEditMessage.setText(quotedText)
2902+
widget['message'].setText(quotedText)
28952903
if acct.subject[0:3] in ['Re:', 'RE:']:
2896-
self.ui.lineEditSubject.setText(acct.subject)
2904+
widget['subject'].setText(acct.subject)
28972905
else:
2898-
self.ui.lineEditSubject.setText('Re: ' + acct.subject)
2899-
self.ui.tabWidgetSend.setCurrentIndex(0)
2906+
widget['subject'].setText('Re: ' + acct.subject)
29002907
self.ui.tabWidget.setCurrentIndex(1)
29012908

29022909
def on_action_InboxAddSenderToAddressBook(self):

0 commit comments

Comments
 (0)