Dont show Fetch button if cannot connect to Namecoin
This commit is contained in:
parent
27f10f6ac1
commit
077177b742
|
@ -432,10 +432,21 @@ class MyForm(QtGui.QMainWindow):
|
||||||
"removeInboxRowByMsgid(PyQt_PyObject)"), self.removeInboxRowByMsgid)
|
"removeInboxRowByMsgid(PyQt_PyObject)"), self.removeInboxRowByMsgid)
|
||||||
self.UISignalThread.start()
|
self.UISignalThread.start()
|
||||||
|
|
||||||
# Below this point, it would be good if all of the necessary global data
|
# Below this point, it would be good if all of the necessary global data
|
||||||
# structures were initialized.
|
# structures were initialized.
|
||||||
|
|
||||||
self.rerenderComboBoxSendFrom()
|
self.rerenderComboBoxSendFrom()
|
||||||
|
|
||||||
|
# Check to see whether we can connect to namecoin. Hide the 'Fetch Namecoin ID' button if we can't.
|
||||||
|
options = {}
|
||||||
|
options["type"] = shared.config.get('bitmessagesettings', 'namecoinrpctype')
|
||||||
|
options["host"] = shared.config.get('bitmessagesettings', 'namecoinrpchost')
|
||||||
|
options["port"] = shared.config.get('bitmessagesettings', 'namecoinrpcport')
|
||||||
|
options["user"] = shared.config.get('bitmessagesettings', 'namecoinrpcuser')
|
||||||
|
options["password"] = shared.config.get('bitmessagesettings', 'namecoinrpcpassword')
|
||||||
|
nc = namecoinConnection(options)
|
||||||
|
if nc.test()[0] == 'failed':
|
||||||
|
self.ui.pushButtonFetchNamecoinID.hide()
|
||||||
|
|
||||||
|
|
||||||
# Show or hide the application window after clicking an item within the
|
# Show or hide the application window after clicking an item within the
|
||||||
|
@ -3180,6 +3191,8 @@ class settingsDialog(QtGui.QDialog):
|
||||||
|
|
||||||
# Test the namecoin settings specified in the settings dialog.
|
# Test the namecoin settings specified in the settings dialog.
|
||||||
def click_pushButtonNamecoinTest(self):
|
def click_pushButtonNamecoinTest(self):
|
||||||
|
self.ui.labelNamecoinTestResult.setText(_translate(
|
||||||
|
"MainWindow", "Testing..."))
|
||||||
options = {}
|
options = {}
|
||||||
options["type"] = self.getNamecoinType()
|
options["type"] = self.getNamecoinType()
|
||||||
options["host"] = self.ui.lineEditNamecoinHost.text()
|
options["host"] = self.ui.lineEditNamecoinHost.text()
|
||||||
|
@ -3187,8 +3200,10 @@ class settingsDialog(QtGui.QDialog):
|
||||||
options["user"] = self.ui.lineEditNamecoinUser.text()
|
options["user"] = self.ui.lineEditNamecoinUser.text()
|
||||||
options["password"] = self.ui.lineEditNamecoinPassword.text()
|
options["password"] = self.ui.lineEditNamecoinPassword.text()
|
||||||
nc = namecoinConnection(options)
|
nc = namecoinConnection(options)
|
||||||
res = nc.test()
|
responseStatus = nc.test()[1]
|
||||||
self.ui.labelNamecoinTestResult.setText(res)
|
self.ui.labelNamecoinTestResult.setText(responseStatus)
|
||||||
|
if nc.test()[0]== 'success':
|
||||||
|
self.parent.ui.pushButtonFetchNamecoinID.show()
|
||||||
|
|
||||||
|
|
||||||
class SpecialAddressBehaviorDialog(QtGui.QDialog):
|
class SpecialAddressBehaviorDialog(QtGui.QDialog):
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'settings.ui'
|
# Form implementation generated from reading ui file 'settings.ui'
|
||||||
#
|
#
|
||||||
# Created: Sun Aug 11 22:12:58 2013
|
# Created: Wed Aug 14 18:31:34 2013
|
||||||
# by: PyQt4 UI code generator 4.10.2
|
# by: PyQt4 UI code generator 4.10
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ except AttributeError:
|
||||||
class Ui_settingsDialog(object):
|
class Ui_settingsDialog(object):
|
||||||
def setupUi(self, settingsDialog):
|
def setupUi(self, settingsDialog):
|
||||||
settingsDialog.setObjectName(_fromUtf8("settingsDialog"))
|
settingsDialog.setObjectName(_fromUtf8("settingsDialog"))
|
||||||
settingsDialog.resize(462, 343)
|
settingsDialog.resize(567, 343)
|
||||||
self.gridLayout = QtGui.QGridLayout(settingsDialog)
|
self.gridLayout = QtGui.QGridLayout(settingsDialog)
|
||||||
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
|
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
|
||||||
self.buttonBox = QtGui.QDialogButtonBox(settingsDialog)
|
self.buttonBox = QtGui.QDialogButtonBox(settingsDialog)
|
||||||
|
@ -356,7 +356,7 @@ class Ui_settingsDialog(object):
|
||||||
self.label_13.setText(_translate("settingsDialog", "Maximum acceptable total difficulty:", None))
|
self.label_13.setText(_translate("settingsDialog", "Maximum acceptable total difficulty:", None))
|
||||||
self.label_14.setText(_translate("settingsDialog", "Maximum acceptable small message difficulty:", None))
|
self.label_14.setText(_translate("settingsDialog", "Maximum acceptable small message difficulty:", None))
|
||||||
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab_2), _translate("settingsDialog", "Max acceptable difficulty", None))
|
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tab_2), _translate("settingsDialog", "Max acceptable difficulty", None))
|
||||||
self.label_16.setText(_translate("settingsDialog", "Bitmessage addresses can be fetched automatically from Namecoin identities. You can use either namecoind directly or a running nmcontrol instance.", None))
|
self.label_16.setText(_translate("settingsDialog", "<html><head/><body><p>Bitmessage can utilize a different Bitcoin-based program called Namecoin to make addresses human-friendly. For example, instead of having to tell your friend your long Bitmessage address, you can simply tell him to send a message to <span style=\" font-style:italic;\">test. </span></p><p>(Getting your own Bitmessage address into Namecoin is still rather difficult).</p><p>Bitmessage can use either namecoind directly or a running nmcontrol instance.</p></body></html>", None))
|
||||||
self.label_17.setText(_translate("settingsDialog", "Host:", None))
|
self.label_17.setText(_translate("settingsDialog", "Host:", None))
|
||||||
self.label_18.setText(_translate("settingsDialog", "Port:", None))
|
self.label_18.setText(_translate("settingsDialog", "Port:", None))
|
||||||
self.labelNamecoinUser.setText(_translate("settingsDialog", "Username:", None))
|
self.labelNamecoinUser.setText(_translate("settingsDialog", "Username:", None))
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>462</width>
|
<width>567</width>
|
||||||
<height>343</height>
|
<height>343</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -526,7 +526,7 @@
|
||||||
<item row="0" column="0" colspan="3">
|
<item row="0" column="0" colspan="3">
|
||||||
<widget class="QLabel" name="label_16">
|
<widget class="QLabel" name="label_16">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Bitmessage addresses can be fetched automatically from Namecoin identities. You can use either namecoind directly or a running nmcontrol instance.</string>
|
<string><html><head/><body><p>Bitmessage can utilize a different Bitcoin-based program called Namecoin to make addresses human-friendly. For example, instead of having to tell your friend your long Bitmessage address, you can simply tell him to send a message to <span style=" font-style:italic;">test. </span></p><p>(Getting your own Bitmessage address into Namecoin is still rather difficult).</p><p>Bitmessage can use either namecoind directly or a running nmcontrol instance.</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
|
@ -25,6 +25,7 @@ import socket
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import shared
|
import shared
|
||||||
|
import tr # translate
|
||||||
|
|
||||||
configSection = "bitmessagesettings"
|
configSection = "bitmessagesettings"
|
||||||
|
|
||||||
|
@ -89,24 +90,21 @@ class namecoinConnection (object):
|
||||||
assert False
|
assert False
|
||||||
except RPCError as exc:
|
except RPCError as exc:
|
||||||
if exc.error["code"] == -4:
|
if exc.error["code"] == -4:
|
||||||
return ("The name '%s' was not found." % string, None)
|
return (tr.translateText("MainWindow",'The name %1 was not found.').arg(unicode(string)), None)
|
||||||
else:
|
else:
|
||||||
return ("The namecoin query failed (%s)" % exc.error["message"],
|
return (tr.translateText("MainWindow",'The namecoin query failed (%1)').arg(unicode(exc.error["message"])), None)
|
||||||
None)
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print "Namecoin query exception: %s" % str (exc)
|
print "Namecoin query exception: %s" % str (exc)
|
||||||
return ("The namecoin query failed.", None)
|
return (tr.translateText("MainWindow",'The namecoin query failed.'), None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
val = json.loads (res)
|
val = json.loads (res)
|
||||||
except:
|
except:
|
||||||
return ("The name '%s' has no valid JSON data." % string, None)
|
return (tr.translateText("MainWindow",'The name %1 has no valid JSON data.').arg(unicode(string)), None)
|
||||||
|
|
||||||
if "bitmessage" in val:
|
if "bitmessage" in val:
|
||||||
return (None, val["bitmessage"])
|
return (None, val["bitmessage"])
|
||||||
|
return (tr.translateText("MainWindow",'The name %1 has no associated Bitmessage address.').arg(unicode(string)), None)
|
||||||
return ("The name '%s' has no associated Bitmessage address." % string,
|
|
||||||
None)
|
|
||||||
|
|
||||||
# Test the connection settings. This routine tries to query a "getinfo"
|
# Test the connection settings. This routine tries to query a "getinfo"
|
||||||
# command, and builds either an error message or a success message with
|
# command, and builds either an error message or a success message with
|
||||||
|
@ -126,24 +124,23 @@ class namecoinConnection (object):
|
||||||
versStr = "0.%d.%d" % (v1, v2)
|
versStr = "0.%d.%d" % (v1, v2)
|
||||||
else:
|
else:
|
||||||
versStr = "0.%d.%d.%d" % (v1, v2, v3)
|
versStr = "0.%d.%d.%d" % (v1, v2, v3)
|
||||||
|
return ('success', tr.translateText("MainWindow",'Success! Namecoind version %1 running.').arg(unicode(versStr)) )
|
||||||
return "Success! Namecoind version %s running." % versStr
|
|
||||||
|
|
||||||
elif self.nmctype == "nmcontrol":
|
elif self.nmctype == "nmcontrol":
|
||||||
res = self.callRPC ("data", ["status"])
|
res = self.callRPC ("data", ["status"])
|
||||||
prefix = "Plugin data running"
|
prefix = "Plugin data running"
|
||||||
if ("reply" in res) and res["reply"][:len(prefix)] == prefix:
|
if ("reply" in res) and res["reply"][:len(prefix)] == prefix:
|
||||||
return "Success! NMControll is up and running."
|
return ('success', tr.translateText("MainWindow",'Success! NMControll is up and running.'))
|
||||||
|
|
||||||
print "Unexpected nmcontrol reply: %s" % res
|
print "Unexpected nmcontrol reply: %s" % res
|
||||||
return "Couldn't understand NMControl."
|
return ('failed', tr.translateText("MainWindow",'Couldn\'t understand NMControl.'))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print "Exception testing the namecoin connection:\n%s" % str (exc)
|
print "Exception testing the namecoin connection:\n%s" % str (exc)
|
||||||
return "The connection to namecoin failed."
|
return ('failed', "The connection to namecoin failed.")
|
||||||
|
|
||||||
# Helper routine that actually performs an JSON RPC call.
|
# Helper routine that actually performs an JSON RPC call.
|
||||||
def callRPC (self, method, params):
|
def callRPC (self, method, params):
|
||||||
|
@ -195,6 +192,7 @@ class namecoinConnection (object):
|
||||||
try:
|
try:
|
||||||
s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.setsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
s.setsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
s.settimeout(3)
|
||||||
s.connect ((self.host, int (self.port)))
|
s.connect ((self.host, int (self.port)))
|
||||||
s.sendall (data)
|
s.sendall (data)
|
||||||
result = ""
|
result = ""
|
||||||
|
|
Reference in New Issue
Block a user