@@ -89,7 +89,6 @@ class MyForm(QtGui.QMainWindow):
89
89
# the maximum frequency of message sounds in seconds
90
90
maxSoundFrequencySec = 60
91
91
92
- str_broadcast_subscribers = '[Broadcast subscribers]'
93
92
str_chan = '[chan]'
94
93
95
94
def init_file_menu (self ):
@@ -1161,7 +1160,7 @@ def ubuntuMessagingMenuClear(self, inventoryHash):
1161
1160
for row in queryreturn :
1162
1161
toAddress , read = row
1163
1162
if not read :
1164
- if toAddress == self . str_broadcast_subscribers :
1163
+ if toAddress == str_broadcast_subscribers :
1165
1164
if self .mmapp .has_source ("Subscriptions" ):
1166
1165
self .mmapp .remove_source ("Subscriptions" )
1167
1166
else :
@@ -1179,8 +1178,8 @@ def getUnread(self):
1179
1178
msgid , toAddress , read = row
1180
1179
1181
1180
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
1184
1183
else :
1185
1184
toLabel = shared .config .get (toAddress , 'label' )
1186
1185
except :
@@ -1189,7 +1188,7 @@ def getUnread(self):
1189
1188
toLabel = toAddress
1190
1189
1191
1190
if not read :
1192
- if toLabel == self . str_broadcast_subscribers :
1191
+ if toLabel == str_broadcast_subscribers :
1193
1192
# increment the unread subscriptions
1194
1193
unreadSubscriptions = unreadSubscriptions + 1
1195
1194
else :
@@ -1254,7 +1253,7 @@ def ubuntuMessagingMenuUpdate(self, drawAttention, newItem, toLabel):
1254
1253
return
1255
1254
1256
1255
# remember this item to that the messaging menu can find it
1257
- if toLabel == self . str_broadcast_subscribers :
1256
+ if toLabel == str_broadcast_subscribers :
1258
1257
self .newBroadcastItem = newItem
1259
1258
else :
1260
1259
self .newMessageItem = newItem
@@ -2098,7 +2097,7 @@ def click_pushButtonSend(self):
2098
2097
# this is a broadcast message, but we can use it to update the
2099
2098
# user interface when the POW is done generating.
2100
2099
ackdata = OpenSSL .rand (32 )
2101
- toAddress = self . str_broadcast_subscribers
2100
+ toAddress = str_broadcast_subscribers
2102
2101
ripe = ''
2103
2102
t = ('' , # msgid. We don't know what this will be until the POW is done.
2104
2103
toAddress ,
@@ -2119,7 +2118,7 @@ def click_pushButtonSend(self):
2119
2118
sqlExecute (
2120
2119
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''' , * t )
2121
2120
2122
- toLabel = self . str_broadcast_subscribers
2121
+ toLabel = str_broadcast_subscribers
2123
2122
2124
2123
self .displayNewSentMessage (
2125
2124
toAddress , toLabel , fromAddress , subject , message , ackdata )
@@ -2179,15 +2178,13 @@ def rerenderComboBoxSendFrom(self):
2179
2178
2180
2179
def rerenderComboBoxSendFromBroadcast (self ):
2181
2180
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 )
2191
2188
self .ui .comboBoxSendFromBroadcast .insertItem (0 , '' , '' )
2192
2189
if (self .ui .comboBoxSendFromBroadcast .count () == 2 ):
2193
2190
self .ui .comboBoxSendFromBroadcast .setCurrentIndex (1 )
@@ -2863,40 +2860,50 @@ def on_action_InboxReply(self):
2863
2860
for row in queryreturn :
2864
2861
messageAtCurrentInboxRow , = row
2865
2862
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
2869
2876
elif not shared .config .has_section (toAddressAtCurrentInboxRow ):
2870
2877
QtGui .QMessageBox .information (self , _translate ("MainWindow" , "Address is gone" ), _translate (
2871
2878
"MainWindow" , "Bitmessage cannot find your address %1. Perhaps you removed it?" ).arg (toAddressAtCurrentInboxRow ), QMessageBox .Ok )
2872
2879
elif not shared .config .getboolean (toAddressAtCurrentInboxRow , 'enabled' ):
2873
2880
QtGui .QMessageBox .information (self , _translate ("MainWindow" , "Address disabled" ), _translate (
2874
2881
"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 )
2875
2882
else :
2876
- self .setBroadcastEnablementDependingOnWhetherThisIsAChanAddress (toAddressAtCurrentInboxRow )
2883
+ #self.setBroadcastEnablementDependingOnWhetherThisIsAChanAddress(toAddressAtCurrentInboxRow)
2884
+ self .ui .tabWidgetSend .setCurrentIndex (0 )
2877
2885
2878
- self .ui .lineEditTo .setText (str (acct .fromLabel ))
2886
+ self .ui .lineEditTo .setText (str (acct .fromAddress ))
2879
2887
2880
2888
# 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.
2881
2889
if shared .config .has_section (toAddressAtCurrentInboxRow ):
2882
2890
if shared .safeConfigGetBoolean (toAddressAtCurrentInboxRow , 'chan' ):
2883
2891
print 'original sent to a chan. Setting the to address in the reply to the chan address.'
2884
2892
self .ui .lineEditTo .setText (str (toAddressAtCurrentInboxRow ))
2885
2893
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 ())]
2887
2895
if toAddressAtCurrentInboxRow in listOfAddressesInComboBoxSendFrom :
2888
2896
currentIndex = listOfAddressesInComboBoxSendFrom .index (toAddressAtCurrentInboxRow )
2889
- self . ui . comboBoxSendFrom .setCurrentIndex (currentIndex )
2897
+ widget [ 'from' ] .setCurrentIndex (currentIndex )
2890
2898
else :
2891
- self . ui . comboBoxSendFrom .setCurrentIndex (0 )
2899
+ widget [ 'from' ] .setCurrentIndex (0 )
2892
2900
2893
2901
quotedText = self .quoted_text (unicode (messageAtCurrentInboxRow , 'utf-8' ))
2894
- self . ui . textEditMessage .setText (quotedText )
2902
+ widget [ 'message' ] .setText (quotedText )
2895
2903
if acct .subject [0 :3 ] in ['Re:' , 'RE:' ]:
2896
- self . ui . lineEditSubject .setText (acct .subject )
2904
+ widget [ 'subject' ] .setText (acct .subject )
2897
2905
else :
2898
- self .ui .lineEditSubject .setText ('Re: ' + acct .subject )
2899
- self .ui .tabWidgetSend .setCurrentIndex (0 )
2906
+ widget ['subject' ].setText ('Re: ' + acct .subject )
2900
2907
self .ui .tabWidget .setCurrentIndex (1 )
2901
2908
2902
2909
def on_action_InboxAddSenderToAddressBook (self ):
0 commit comments