electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 456d3d5b5594becebf4cb77f4bc380a69b22a2ce
parent a64b8498cd823d40dfeb18896d7632cb839778cb
Author: ThomasV <thomasv@gitorious>
Date:   Thu, 18 Oct 2012 20:29:53 +0200

add SSL protocols to network dialog

Diffstat:
Mlib/gui_qt.py | 22+++++++++++++++++-----
Mlib/interface.py | 5+++--
2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/lib/gui_qt.py b/lib/gui_qt.py @@ -1419,12 +1419,15 @@ class ElectrumWindow(QMainWindow): server_host.setFixedWidth(200) server_port = QLineEdit() server_port.setFixedWidth(60) - server_protocol.addItems(['TCP', 'HTTP']) + + protocol_names = ['TCP', 'HTTP', 'TCP/SSL', 'HTTPS'] + protocol_letters = 'thsg' + server_protocol.addItems(protocol_names) host, port, protocol = server.split(':') server_host.setText(host) server_port.setText(port) - server_protocol.setCurrentIndex(0 if protocol=='t' else 1) + server_protocol.setCurrentIndex(protocol_letters.index(protocol)) grid.addWidget(QLabel(_('Server') + ':'), 0, 0) grid.addWidget(server_protocol, 0, 1) @@ -1432,7 +1435,7 @@ class ElectrumWindow(QMainWindow): grid.addWidget(server_port, 0, 3) def change_protocol(p): - protocol = 't' if p == 0 else 'h' + protocol = protocol_letters[p] host = unicode(server_host.text()) pp = plist[host] if protocol not in pp.keys(): @@ -1465,7 +1468,16 @@ class ElectrumWindow(QMainWindow): port = pp[protocol] server_host.setText( host ) server_port.setText( port ) - server_protocol.setCurrentIndex(0 if protocol == 't' else 1) + server_protocol.setCurrentIndex(protocol_letters.index(protocol)) + + for p in protocol_letters: + i = protocol_letters.index(p) + j = server_protocol.model().index(i,0) + if p not in pp.keys(): + server_protocol.model().setData(j, QtCore.QVariant(0), QtCore.Qt.UserRole-1) + else: + server_protocol.model().setData(j, QtCore.QVariant(0,False), QtCore.Qt.UserRole-1) + servers_list_widget.connect(servers_list_widget, SIGNAL('itemClicked(QTreeWidgetItem*, int)'), change_server) grid.addWidget(servers_list_widget, 1, 1, 1, 3) @@ -1511,7 +1523,7 @@ class ElectrumWindow(QMainWindow): if not d.exec_(): return - server = unicode( server_host.text() ) + ':' + unicode( server_port.text() ) + ':' + ('t' if server_protocol.currentIndex() == 0 else 'h') + server = unicode( server_host.text() ) + ':' + unicode( server_port.text() ) + ':' + (protocol_letters[server_protocol.currentIndex()]) if proxy_mode.currentText() != 'NONE': proxy = { u'mode':unicode(proxy_mode.currentText()).lower(), u'host':unicode(proxy_host.text()), u'port':unicode(proxy_port.text()) } else: diff --git a/lib/interface.py b/lib/interface.py @@ -27,6 +27,7 @@ from util import print_error DEFAULT_TIMEOUT = 5 DEFAULT_SERVERS = [ 'electrum.novit.ro:50001:t', + 'electrum.pdmc.net:50001:t', #'ecdsa.org:50002:s', 'electrum.bitcoins.sk:50001:t', 'uncle-enzo.info:50001:t', @@ -372,7 +373,7 @@ class Interface(TcpStratumInterface, HttpStratumInterface): # raise an error if the format isnt correct a,b,c = server.split(':') b = int(b) - assert c in ['t', 'h'] + assert c in 'stgh' # set the server if server != self.server or proxy != self.proxy: print "changing server:", server, proxy @@ -435,7 +436,7 @@ class WalletSynchronizer(threading.Thread): version = None if len(item) > 2: for v in item[2]: - if re.match("[th]\d+", v): + if re.match("[stgh]\d+", v): ports.append((v[0], v[1:])) if re.match("v(.?)+", v): version = v[1:]