@@ -798,26 +798,14 @@ def __init__(self, parent=None):
798
798
"valueChanged(int)" ), self .updateTTL )
799
799
800
800
self .initSettings ()
801
-
802
- namecoin .ensureNamecoinOptions ()
803
- self .namecoin = namecoin .namecoinConnection ()
804
-
805
- # Check to see whether we can connect to namecoin.
806
- # Hide the 'Fetch Namecoin ID' button if we can't.
807
- if BMConfigParser ().safeGetBoolean (
808
- 'bitmessagesettings' , 'dontconnect'
809
- ) or self .namecoin .test ()[0 ] == 'failed' :
810
- logger .warning (
811
- 'There was a problem testing for a Namecoin daemon. Hiding the'
812
- ' Fetch Namecoin ID button' )
813
- self .ui .pushButtonFetchNamecoinID .hide ()
801
+ self .resetNamecoinConnection ()
814
802
815
803
def updateTTL (self , sliderPosition ):
816
804
TTL = int (sliderPosition ** 3.199 + 3600 )
817
805
self .updateHumanFriendlyTTLDescription (TTL )
818
806
BMConfigParser ().set ('bitmessagesettings' , 'ttl' , str (TTL ))
819
807
BMConfigParser ().save ()
820
-
808
+
821
809
def updateHumanFriendlyTTLDescription (self , TTL ):
822
810
numberOfHours = int (round (TTL / (60 * 60 )))
823
811
font = QtGui .QFont ()
@@ -2160,9 +2148,8 @@ def click_pushButtonLoadFromAddressBook(self):
2160
2148
))
2161
2149
2162
2150
def click_pushButtonFetchNamecoinID (self ):
2163
- nc = namecoinConnection ()
2164
2151
identities = str (self .ui .lineEditTo .text ().toUtf8 ()).split (";" )
2165
- err , addr = nc .query (identities [- 1 ].strip ())
2152
+ err , addr = self . namecoin .query (identities [- 1 ].strip ())
2166
2153
if err is not None :
2167
2154
self .updateStatusBar (
2168
2155
_translate ("MainWindow" , "Error: %1" ).arg (err ))
@@ -2481,7 +2468,8 @@ def click_actionSettings(self):
2481
2468
self .settingsDialogInstance .ui .lineEditNamecoinUser .text ()))
2482
2469
BMConfigParser ().set ('bitmessagesettings' , 'namecoinrpcpassword' , str (
2483
2470
self .settingsDialogInstance .ui .lineEditNamecoinPassword .text ()))
2484
-
2471
+ self .resetNamecoinConnection ()
2472
+
2485
2473
# Demanded difficulty tab
2486
2474
if float (self .settingsDialogInstance .ui .lineEditTotalDifficulty .text ()) >= 1 :
2487
2475
BMConfigParser ().set ('bitmessagesettings' , 'defaultnoncetrialsperbyte' , str (int (float (
@@ -4129,6 +4117,22 @@ def updateStatusBar(self, data):
4129
4117
else :
4130
4118
self .statusbar .showMessage (message , 10000 )
4131
4119
4120
+ def resetNamecoinConnection (self ):
4121
+ namecoin .ensureNamecoinOptions ()
4122
+ self .namecoin = namecoin .namecoinConnection ()
4123
+
4124
+ # Check to see whether we can connect to namecoin.
4125
+ # Hide the 'Fetch Namecoin ID' button if we can't.
4126
+ if BMConfigParser ().safeGetBoolean (
4127
+ 'bitmessagesettings' , 'dontconnect'
4128
+ ) or self .namecoin .test ()[0 ] == 'failed' :
4129
+ logger .warning (
4130
+ 'There was a problem testing for a Namecoin daemon. Hiding the'
4131
+ ' Fetch Namecoin ID button' )
4132
+ self .ui .pushButtonFetchNamecoinID .hide ()
4133
+ else :
4134
+ self .ui .pushButtonFetchNamecoinID .show ()
4135
+
4132
4136
def initSettings (self ):
4133
4137
QtCore .QCoreApplication .setOrganizationName ("PyBitmessage" )
4134
4138
QtCore .QCoreApplication .setOrganizationDomain ("bitmessage.org" )
@@ -4344,7 +4348,7 @@ def getNamecoinType(self):
4344
4348
def namecoinTypeChanged (self , checked ):
4345
4349
nmctype = self .getNamecoinType ()
4346
4350
assert nmctype == "namecoind" or nmctype == "nmcontrol"
4347
-
4351
+
4348
4352
isNamecoind = (nmctype == "namecoind" )
4349
4353
self .ui .lineEditNamecoinUser .setEnabled (isNamecoind )
4350
4354
self .ui .labelNamecoinUser .setEnabled (isNamecoind )
@@ -4356,23 +4360,21 @@ def namecoinTypeChanged(self, checked):
4356
4360
else :
4357
4361
self .ui .lineEditNamecoinPort .setText ("9000" )
4358
4362
4359
- # Test the namecoin settings specified in the settings dialog.
4360
4363
def click_pushButtonNamecoinTest (self ):
4364
+ """Test the namecoin settings specified in the settings dialog."""
4361
4365
self .ui .labelNamecoinTestResult .setText (_translate (
4362
- "MainWindow" , "Testing..." ))
4366
+ "MainWindow" , "Testing..." ))
4363
4367
options = {}
4364
4368
options ["type" ] = self .getNamecoinType ()
4365
4369
options ["host" ] = str (self .ui .lineEditNamecoinHost .text ().toUtf8 ())
4366
4370
options ["port" ] = str (self .ui .lineEditNamecoinPort .text ().toUtf8 ())
4367
4371
options ["user" ] = str (self .ui .lineEditNamecoinUser .text ().toUtf8 ())
4368
4372
options ["password" ] = str (self .ui .lineEditNamecoinPassword .text ().toUtf8 ())
4369
- nc = namecoinConnection (options )
4370
- response = nc .test ()
4371
- responseStatus = response [0 ]
4372
- responseText = response [1 ]
4373
- self .ui .labelNamecoinTestResult .setText (responseText )
4374
- if responseStatus == 'success' :
4375
- self .parent .ui .pushButtonFetchNamecoinID .show ()
4373
+ nc = namecoin .namecoinConnection (options )
4374
+ status , text = nc .test ()
4375
+ self .ui .labelNamecoinTestResult .setText (text )
4376
+ if status == 'success' :
4377
+ self .parent .namecoin = nc
4376
4378
4377
4379
4378
4380
# In order for the time columns on the Inbox and Sent tabs to be sorted
0 commit comments