34
34
from regenerateaddresses import *
35
35
from newchandialog import *
36
36
from specialaddressbehavior import *
37
+ from emailgateway import *
37
38
from settings import *
38
39
from about import *
39
40
from help import *
@@ -213,6 +214,10 @@ def init_identities_popup_menu(self, connectSignal=True):
213
214
_translate (
214
215
"MainWindow" , "Special address behavior..." ),
215
216
self .on_action_SpecialAddressBehaviorDialog )
217
+ self .actionEmailGateway = self .ui .addressContextMenuToolbarYourIdentities .addAction (
218
+ _translate (
219
+ "MainWindow" , "Email gateway" ),
220
+ self .on_action_EmailGatewayDialog )
216
221
217
222
self .ui .treeWidgetYourIdentities .setContextMenuPolicy (
218
223
QtCore .Qt .CustomContextMenu )
@@ -230,6 +235,7 @@ def init_identities_popup_menu(self, connectSignal=True):
230
235
self .popMenuYourIdentities .addAction (self .actionDisableYourIdentities )
231
236
self .popMenuYourIdentities .addAction (self .actionSetAvatarYourIdentities )
232
237
self .popMenuYourIdentities .addAction (self .actionSpecialAddressBehaviorYourIdentities )
238
+ self .popMenuYourIdentities .addAction (self .actionEmailGateway )
233
239
234
240
def init_chan_popup_menu (self , connectSignal = True ):
235
241
# Popup menu for the Channels tab
@@ -902,6 +908,7 @@ def loadSent(self, tableWidget, account, where="", what=""):
902
908
903
909
subjectItem = QtGui .QTableWidgetItem (unicode (acct .subject , 'utf-8' ))
904
910
subjectItem .setToolTip (unicode (acct .subject , 'utf-8' ))
911
+ subjectItem .setData (Qt .UserRole , str (subject ))
905
912
subjectItem .setFlags (
906
913
QtCore .Qt .ItemIsSelectable | QtCore .Qt .ItemIsEnabled )
907
914
tableWidget .setItem (0 , 2 , subjectItem )
@@ -1038,6 +1045,7 @@ def loadMessagelist(self, tableWidget, account, folder="inbox", where="", what="
1038
1045
# subject
1039
1046
subject_item = QtGui .QTableWidgetItem (unicode (acct .subject , 'utf-8' ))
1040
1047
subject_item .setToolTip (unicode (acct .subject , 'utf-8' ))
1048
+ subject_item .setData (Qt .UserRole , str (subject ))
1041
1049
subject_item .setFlags (
1042
1050
QtCore .Qt .ItemIsSelectable | QtCore .Qt .ItemIsEnabled )
1043
1051
if not read :
@@ -1966,6 +1974,8 @@ def click_pushButtonSend(self):
1966
1974
QMessageBox .about (self , _translate ("MainWindow" , "Message too long" ), _translate (
1967
1975
"MainWindow" , "The message that you are trying to send is too long by %1 bytes. (The maximum is 261644 bytes). Please cut it down before sending." ).arg (len (message ) - (2 ** 18 - 500 )))
1968
1976
return
1977
+
1978
+ acct = accountClass (fromAddress )
1969
1979
1970
1980
if sendMessageToPeople : # To send a message to specific people (rather than broadcast)
1971
1981
toAddressesList = [s .strip ()
@@ -1974,6 +1984,12 @@ def click_pushButtonSend(self):
1974
1984
toAddressesList )) # remove duplicate addresses. If the user has one address with a BM- and the same address without the BM-, this will not catch it. They'll send the message to the person twice.
1975
1985
for toAddress in toAddressesList :
1976
1986
if toAddress != '' :
1987
+ if toAddress .find ("@" ) >= 0 and isinstance (acct , GatewayAccount ):
1988
+ acct .createMessage (toAddress , fromAddress , subject , message )
1989
+ subject = acct .subject
1990
+ toAddress = acct .toAddress
1991
+ print "Subject: %s" % (subject )
1992
+ print "address: %s" % (toAddress )
1977
1993
status , addressVersionNumber , streamNumber , ripe = decodeAddress (
1978
1994
toAddress )
1979
1995
if status != 'success' :
@@ -2195,6 +2211,8 @@ def displayNewSentMessage(self, toAddress, toLabel, fromAddress, subject, messag
2195
2211
self .ui .tableWidgetInbox .setItem (0 , 1 , newItem )
2196
2212
newItem = QtGui .QTableWidgetItem (unicode (acct .subject , 'utf-8)' ))
2197
2213
newItem .setToolTip (unicode (acct .subject , 'utf-8)' ))
2214
+ newItem .setData (Qt .UserRole , str (subject ))
2215
+
2198
2216
#newItem.setData(Qt.UserRole, unicode(message, 'utf-8)')) # No longer hold the message in the table; we'll use a SQL query to display it as needed.
2199
2217
self .ui .tableWidgetInbox .setItem (0 , 2 , newItem )
2200
2218
# newItem = QtGui.QTableWidgetItem('Doing work necessary to send
@@ -2240,6 +2258,8 @@ def displayNewInboxMessage(self, inventoryHash, toAddress, fromAddress, subject,
2240
2258
self .ui .tableWidgetInbox .setItem (0 , 1 , newItem )
2241
2259
newItem = QtGui .QTableWidgetItem (unicode (acct .subject , 'utf-8)' ))
2242
2260
newItem .setToolTip (unicode (acct .subject , 'utf-8)' ))
2261
+ newItem .setData (Qt .UserRole , str (subject ))
2262
+
2243
2263
#newItem.setData(Qt.UserRole, unicode(message, 'utf-8)')) # No longer hold the message in the table; we'll use a SQL query to display it as needed.
2244
2264
newItem .setFont (font )
2245
2265
self .ui .tableWidgetInbox .setItem (0 , 2 , newItem )
@@ -2629,18 +2649,42 @@ def on_action_SpecialAddressBehaviorDialog(self):
2629
2649
shared .writeKeysFile ()
2630
2650
self .rerenderInboxToLabels ()
2631
2651
2652
+ def on_action_EmailGatewayDialog (self ):
2653
+ self .dialog = EmailGatewayDialog (self )
2654
+ # For Modal dialogs
2655
+ if self .dialog .exec_ ():
2656
+ addressAtCurrentRow = self .getCurrentAccount ()
2657
+ acct = accountClass (addressAtCurrentRow )
2658
+ if isinstance (acct , GatewayAccount ) and self .dialog .ui .radioButtonUnregister .isChecked ():
2659
+ print "unregister"
2660
+ acct .unregister ()
2661
+ shared .config .remove_option (addressAtCurrentRow , 'gateway' )
2662
+ shared .writeKeysFile ()
2663
+ elif (not isinstance (acct , GatewayAccount )) and self .dialog .ui .radioButtonRegister .isChecked ():
2664
+ print "register"
2665
+ email = str (self .dialog .ui .lineEditEmail .text ().toUtf8 ())
2666
+ acct = MailchuckAccount (addressAtCurrentRow )
2667
+ acct .register (email )
2668
+ shared .config .set (addressAtCurrentRow , 'label' , email )
2669
+ shared .config .set (addressAtCurrentRow , 'gateway' , 'mailchuck' )
2670
+ shared .writeKeysFile ()
2671
+ else :
2672
+ print "well nothing"
2673
+ # shared.writeKeysFile()
2674
+ # self.rerenderInboxToLabels()
2675
+
2632
2676
def click_NewAddressDialog (self ):
2633
2677
addresses = []
2634
2678
configSections = shared .config .sections ()
2635
2679
for addressInKeysFile in configSections :
2636
2680
if addressInKeysFile == 'bitmessagesettings' :
2637
2681
continue
2638
2682
addresses .append (addressInKeysFile )
2639
- self .dialog = Ui_NewAddressWizard (addresses )
2640
- self .dialog .exec_ ()
2683
+ # self.dialog = Ui_NewAddressWizard(addresses)
2684
+ # self.dialog.exec_()
2641
2685
# print "Name: " + self.dialog.field("name").toString()
2642
2686
# print "Email: " + self.dialog.field("email").toString()
2643
- return
2687
+ # return
2644
2688
self .dialog = NewAddressDialog (self )
2645
2689
# For Modal dialogs
2646
2690
if self .dialog .exec_ ():
@@ -2787,6 +2831,7 @@ def on_action_InboxReply(self):
2787
2831
currentInboxRow = tableWidget .currentRow ()
2788
2832
toAddressAtCurrentInboxRow = str (tableWidget .item (
2789
2833
currentInboxRow , 0 ).data (Qt .UserRole ).toPyObject ())
2834
+ acct = accountClass (toAddressAtCurrentInboxRow )
2790
2835
fromAddressAtCurrentInboxRow = str (tableWidget .item (
2791
2836
currentInboxRow , 1 ).data (Qt .UserRole ).toPyObject ())
2792
2837
msgid = str (tableWidget .item (
@@ -2796,6 +2841,7 @@ def on_action_InboxReply(self):
2796
2841
if queryreturn != []:
2797
2842
for row in queryreturn :
2798
2843
messageAtCurrentInboxRow , = row
2844
+ acct .parseMessage (toAddressAtCurrentInboxRow , fromAddressAtCurrentInboxRow , str (tableWidget .item (currentInboxRow , 2 ).data (Qt .UserRole ).toPyObject ()), messageAtCurrentInboxRow )
2799
2845
if toAddressAtCurrentInboxRow == self .str_broadcast_subscribers :
2800
2846
#TODO what does this if?..
2801
2847
a = a
@@ -2808,7 +2854,7 @@ def on_action_InboxReply(self):
2808
2854
else :
2809
2855
self .setBroadcastEnablementDependingOnWhetherThisIsAChanAddress (toAddressAtCurrentInboxRow )
2810
2856
2811
- self .ui .lineEditTo .setText (str (fromAddressAtCurrentInboxRow ))
2857
+ self .ui .lineEditTo .setText (str (acct . fromLabel ))
2812
2858
2813
2859
# 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.
2814
2860
if shared .config .has_section (toAddressAtCurrentInboxRow ):
@@ -2825,12 +2871,10 @@ def on_action_InboxReply(self):
2825
2871
2826
2872
quotedText = self .quoted_text (unicode (messageAtCurrentInboxRow , 'utf-8' ))
2827
2873
self .ui .textEditMessage .setText (quotedText )
2828
- if tableWidget .item (currentInboxRow , 2 ).text ()[0 :3 ] in ['Re:' , 'RE:' ]:
2829
- self .ui .lineEditSubject .setText (
2830
- tableWidget .item (currentInboxRow , 2 ).text ())
2874
+ if acct .subject [0 :3 ] in ['Re:' , 'RE:' ]:
2875
+ self .ui .lineEditSubject .setText (acct .subject )
2831
2876
else :
2832
- self .ui .lineEditSubject .setText (
2833
- 'Re: ' + tableWidget .item (currentInboxRow , 2 ).text ())
2877
+ self .ui .lineEditSubject .setText ('Re: ' + acct .subject )
2834
2878
self .ui .tabWidgetSend .setCurrentIndex (0 )
2835
2879
self .ui .tabWidget .setCurrentIndex (1 )
2836
2880
@@ -3772,6 +3816,23 @@ def __init__(self, parent):
3772
3816
3773
3817
QtGui .QWidget .resize (self , QtGui .QWidget .sizeHint (self ))
3774
3818
3819
+ class EmailGatewayDialog (QtGui .QDialog ):
3820
+
3821
+ def __init__ (self , parent ):
3822
+ QtGui .QWidget .__init__ (self , parent )
3823
+ self .ui = Ui_EmailGatewayDialog ()
3824
+ self .ui .setupUi (self )
3825
+ self .parent = parent
3826
+ addressAtCurrentRow = parent .getCurrentAccount ()
3827
+ acct = accountClass (addressAtCurrentRow )
3828
+ # if isinstance(acct, GatewayAccount):
3829
+ label = shared .config .get (addressAtCurrentRow , 'label' )
3830
+ if label .find ("@mailchuck.com" ) > - 1 :
3831
+ self .ui .lineEditEmail .setText (label )
3832
+
3833
+ QtGui .QWidget .resize (self , QtGui .QWidget .sizeHint (self ))
3834
+
3835
+
3775
3836
class AddAddressDialog (QtGui .QDialog ):
3776
3837
3777
3838
def __init__ (self , parent ):
@@ -3999,11 +4060,11 @@ def run():
3999
4060
if shared .safeConfigGetBoolean ('bitmessagesettings' , 'dontconnect' ):
4000
4061
myapp .showConnectDialog () # ask the user if we may connect
4001
4062
4002
- try :
4003
- if shared .config .get ('bitmessagesettings' , 'mailchuck' ) < 1 :
4004
- myapp .showMigrationWizard (shared .config .get ('bitmessagesettings' , 'mailchuck' ))
4005
- except :
4006
- myapp .showMigrationWizard (0 )
4063
+ # try:
4064
+ # if shared.config.get('bitmessagesettings', 'mailchuck') < 1:
4065
+ # myapp.showMigrationWizard(shared.config.get('bitmessagesettings', 'mailchuck'))
4066
+ # except:
4067
+ # myapp.showMigrationWizard(0)
4007
4068
4008
4069
# only show after wizards and connect dialogs have completed
4009
4070
if not shared .config .getboolean ('bitmessagesettings' , 'startintray' ):
0 commit comments