From aeeb7c9878bc979fcb6f44c9373b4adeab374b6c Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Tue, 18 Jun 2013 13:59:51 -0400 Subject: [PATCH] Moved UI related files all into the bitmessageqt folder --- src/bitmessagemain.py | 251 +++++++++--------- src/{ => bitmessageqt}/about.py | 0 src/{ => bitmessageqt}/about.ui | 0 src/bitmessageqt/addpeer.ui | 118 ++++++++ src/{ => bitmessageqt}/bitmessage_icons.qrc | 0 src/{ => bitmessageqt}/bitmessage_icons_rc.py | 0 src/{ => bitmessageqt}/bitmessageui.py | 0 src/{ => bitmessageqt}/bitmessageui.ui | 0 src/{ => bitmessageqt}/help.py | 0 src/{ => bitmessageqt}/help.ui | 0 src/{ => bitmessageqt}/iconglossary.py | 0 src/{ => bitmessageqt}/iconglossary.ui | 0 src/{ => bitmessageqt}/newaddressdialog.py | 0 src/{ => bitmessageqt}/newaddressdialog.ui | 0 .../newsubscriptiondialog.py | 0 .../newsubscriptiondialog.ui | 0 src/{ => bitmessageqt}/regenerateaddresses.py | 0 src/{ => bitmessageqt}/regenerateaddresses.ui | 0 src/{ => bitmessageqt}/settings.py | 0 src/{ => bitmessageqt}/settings.ui | 0 .../specialaddressbehavior.py | 0 .../specialaddressbehavior.ui | 0 src/bitmessageqt/wanlan.ui | 217 +++++++++++++++ 23 files changed, 461 insertions(+), 125 deletions(-) rename src/{ => bitmessageqt}/about.py (100%) rename src/{ => bitmessageqt}/about.ui (100%) create mode 100644 src/bitmessageqt/addpeer.ui rename src/{ => bitmessageqt}/bitmessage_icons.qrc (100%) rename src/{ => bitmessageqt}/bitmessage_icons_rc.py (100%) rename src/{ => bitmessageqt}/bitmessageui.py (100%) rename src/{ => bitmessageqt}/bitmessageui.ui (100%) rename src/{ => bitmessageqt}/help.py (100%) rename src/{ => bitmessageqt}/help.ui (100%) rename src/{ => bitmessageqt}/iconglossary.py (100%) rename src/{ => bitmessageqt}/iconglossary.ui (100%) rename src/{ => bitmessageqt}/newaddressdialog.py (100%) rename src/{ => bitmessageqt}/newaddressdialog.ui (100%) rename src/{ => bitmessageqt}/newsubscriptiondialog.py (100%) rename src/{ => bitmessageqt}/newsubscriptiondialog.ui (100%) rename src/{ => bitmessageqt}/regenerateaddresses.py (100%) rename src/{ => bitmessageqt}/regenerateaddresses.ui (100%) rename src/{ => bitmessageqt}/settings.py (100%) rename src/{ => bitmessageqt}/settings.ui (100%) rename src/{ => bitmessageqt}/specialaddressbehavior.py (100%) rename src/{ => bitmessageqt}/specialaddressbehavior.ui (100%) create mode 100644 src/bitmessageqt/wanlan.ui diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index be2fdf48..0eec7149 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -64,146 +64,147 @@ class outgoingSynSender(threading.Thread): time.sleep(1) global alreadyAttemptedConnectionsListResetTime while True: - if len(selfInitiatedConnections[self.streamNumber]) >= 8: # maximum number of outgoing connections = 8 + while len(selfInitiatedConnections[self.streamNumber]) >= 8: # maximum number of outgoing connections = 8 time.sleep(10) - else: - random.seed() - HOST, = random.sample(shared.knownNodes[self.streamNumber], 1) - alreadyAttemptedConnectionsListLock.acquire() - while HOST in alreadyAttemptedConnectionsList or HOST in shared.connectedHostsList: - alreadyAttemptedConnectionsListLock.release() - # print 'choosing new sample' - random.seed() - HOST, = random.sample(shared.knownNodes[ - self.streamNumber], 1) - time.sleep(1) - # Clear out the alreadyAttemptedConnectionsList every half - # hour so that this program will again attempt a connection - # to any nodes, even ones it has already tried. - if (time.time() - alreadyAttemptedConnectionsListResetTime) > 1800: - alreadyAttemptedConnectionsList.clear() - alreadyAttemptedConnectionsListResetTime = int( - time.time()) - alreadyAttemptedConnectionsListLock.acquire() - alreadyAttemptedConnectionsList[HOST] = 0 + if shared.shutdown: + break + random.seed() + HOST, = random.sample(shared.knownNodes[self.streamNumber], 1) + alreadyAttemptedConnectionsListLock.acquire() + while HOST in alreadyAttemptedConnectionsList or HOST in shared.connectedHostsList: alreadyAttemptedConnectionsListLock.release() - PORT, timeNodeLastSeen = shared.knownNodes[ + # print 'choosing new sample' + random.seed() + HOST, = random.sample(shared.knownNodes[ + self.streamNumber], 1) + time.sleep(1) + # Clear out the alreadyAttemptedConnectionsList every half + # hour so that this program will again attempt a connection + # to any nodes, even ones it has already tried. + if (time.time() - alreadyAttemptedConnectionsListResetTime) > 1800: + alreadyAttemptedConnectionsList.clear() + alreadyAttemptedConnectionsListResetTime = int( + time.time()) + alreadyAttemptedConnectionsListLock.acquire() + alreadyAttemptedConnectionsList[HOST] = 0 + alreadyAttemptedConnectionsListLock.release() + PORT, timeNodeLastSeen = shared.knownNodes[ + self.streamNumber][HOST] + sock = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM) + # This option apparently avoids the TIME_WAIT state so that we + # can rebind faster + sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + sock.settimeout(20) + if shared.config.get('bitmessagesettings', 'socksproxytype') == 'none' and verbose >= 2: + shared.printLock.acquire() + print 'Trying an outgoing connection to', HOST, ':', PORT + shared.printLock.release() + # sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + elif shared.config.get('bitmessagesettings', 'socksproxytype') == 'SOCKS4a': + if verbose >= 2: + shared.printLock.acquire() + print '(Using SOCKS4a) Trying an outgoing connection to', HOST, ':', PORT + shared.printLock.release() + proxytype = socks.PROXY_TYPE_SOCKS4 + sockshostname = shared.config.get( + 'bitmessagesettings', 'sockshostname') + socksport = shared.config.getint( + 'bitmessagesettings', 'socksport') + rdns = True # Do domain name lookups through the proxy; though this setting doesn't really matter since we won't be doing any domain name lookups anyway. + if shared.config.getboolean('bitmessagesettings', 'socksauthentication'): + socksusername = shared.config.get( + 'bitmessagesettings', 'socksusername') + sockspassword = shared.config.get( + 'bitmessagesettings', 'sockspassword') + sock.setproxy( + proxytype, sockshostname, socksport, rdns, socksusername, sockspassword) + else: + sock.setproxy( + proxytype, sockshostname, socksport, rdns) + elif shared.config.get('bitmessagesettings', 'socksproxytype') == 'SOCKS5': + if verbose >= 2: + shared.printLock.acquire() + print '(Using SOCKS5) Trying an outgoing connection to', HOST, ':', PORT + shared.printLock.release() + proxytype = socks.PROXY_TYPE_SOCKS5 + sockshostname = shared.config.get( + 'bitmessagesettings', 'sockshostname') + socksport = shared.config.getint( + 'bitmessagesettings', 'socksport') + rdns = True # Do domain name lookups through the proxy; though this setting doesn't really matter since we won't be doing any domain name lookups anyway. + if shared.config.getboolean('bitmessagesettings', 'socksauthentication'): + socksusername = shared.config.get( + 'bitmessagesettings', 'socksusername') + sockspassword = shared.config.get( + 'bitmessagesettings', 'sockspassword') + sock.setproxy( + proxytype, sockshostname, socksport, rdns, socksusername, sockspassword) + else: + sock.setproxy( + proxytype, sockshostname, socksport, rdns) + + try: + sock.connect((HOST, PORT)) + rd = receiveDataThread() + rd.daemon = True # close the main program even if there are threads left + objectsOfWhichThisRemoteNodeIsAlreadyAware = {} + rd.setup(sock, HOST, PORT, self.streamNumber, + objectsOfWhichThisRemoteNodeIsAlreadyAware) + rd.start() + shared.printLock.acquire() + print self, 'connected to', HOST, 'during an outgoing attempt.' + shared.printLock.release() + + sd = sendDataThread() + sd.setup(sock, HOST, PORT, self.streamNumber, + objectsOfWhichThisRemoteNodeIsAlreadyAware) + sd.start() + sd.sendVersionMessage() + + except socks.GeneralProxyError as err: + if verbose >= 2: + shared.printLock.acquire() + print 'Could NOT connect to', HOST, 'during outgoing attempt.', err + shared.printLock.release() + PORT, timeLastSeen = shared.knownNodes[ self.streamNumber][HOST] - sock = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM) - # This option apparently avoids the TIME_WAIT state so that we - # can rebind faster - sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - sock.settimeout(20) - if shared.config.get('bitmessagesettings', 'socksproxytype') == 'none' and verbose >= 2: + if (int(time.time()) - timeLastSeen) > 172800 and len(shared.knownNodes[self.streamNumber]) > 1000: # for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the shared.knownNodes data-structure. + shared.knownNodesLock.acquire() + del shared.knownNodes[self.streamNumber][HOST] + shared.knownNodesLock.release() shared.printLock.acquire() - print 'Trying an outgoing connection to', HOST, ':', PORT + print 'deleting ', HOST, 'from shared.knownNodes because it is more than 48 hours old and we could not connect to it.' shared.printLock.release() - # sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - elif shared.config.get('bitmessagesettings', 'socksproxytype') == 'SOCKS4a': - if verbose >= 2: - shared.printLock.acquire() - print '(Using SOCKS4a) Trying an outgoing connection to', HOST, ':', PORT - shared.printLock.release() - proxytype = socks.PROXY_TYPE_SOCKS4 - sockshostname = shared.config.get( - 'bitmessagesettings', 'sockshostname') - socksport = shared.config.getint( - 'bitmessagesettings', 'socksport') - rdns = True # Do domain name lookups through the proxy; though this setting doesn't really matter since we won't be doing any domain name lookups anyway. - if shared.config.getboolean('bitmessagesettings', 'socksauthentication'): - socksusername = shared.config.get( - 'bitmessagesettings', 'socksusername') - sockspassword = shared.config.get( - 'bitmessagesettings', 'sockspassword') - sock.setproxy( - proxytype, sockshostname, socksport, rdns, socksusername, sockspassword) - else: - sock.setproxy( - proxytype, sockshostname, socksport, rdns) - elif shared.config.get('bitmessagesettings', 'socksproxytype') == 'SOCKS5': - if verbose >= 2: - shared.printLock.acquire() - print '(Using SOCKS5) Trying an outgoing connection to', HOST, ':', PORT - shared.printLock.release() - proxytype = socks.PROXY_TYPE_SOCKS5 - sockshostname = shared.config.get( - 'bitmessagesettings', 'sockshostname') - socksport = shared.config.getint( - 'bitmessagesettings', 'socksport') - rdns = True # Do domain name lookups through the proxy; though this setting doesn't really matter since we won't be doing any domain name lookups anyway. - if shared.config.getboolean('bitmessagesettings', 'socksauthentication'): - socksusername = shared.config.get( - 'bitmessagesettings', 'socksusername') - sockspassword = shared.config.get( - 'bitmessagesettings', 'sockspassword') - sock.setproxy( - proxytype, sockshostname, socksport, rdns, socksusername, sockspassword) - else: - sock.setproxy( - proxytype, sockshostname, socksport, rdns) - - try: - sock.connect((HOST, PORT)) - rd = receiveDataThread() - rd.daemon = True # close the main program even if there are threads left - objectsOfWhichThisRemoteNodeIsAlreadyAware = {} - rd.setup(sock, HOST, PORT, self.streamNumber, - objectsOfWhichThisRemoteNodeIsAlreadyAware) - rd.start() - shared.printLock.acquire() - print self, 'connected to', HOST, 'during an outgoing attempt.' - shared.printLock.release() - - sd = sendDataThread() - sd.setup(sock, HOST, PORT, self.streamNumber, - objectsOfWhichThisRemoteNodeIsAlreadyAware) - sd.start() - sd.sendVersionMessage() - - except socks.GeneralProxyError as err: - if verbose >= 2: + except socks.Socks5AuthError as err: + shared.UISignalQueue.put(( + 'updateStatusBar', _translate( + "MainWindow", "SOCKS5 Authentication problem: %1").arg(str(err)))) + except socks.Socks5Error as err: + pass + print 'SOCKS5 error. (It is possible that the server wants authentication).)', str(err) + except socks.Socks4Error as err: + print 'Socks4Error:', err + except socket.error as err: + if shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS': + print 'Bitmessage MIGHT be having trouble connecting to the SOCKS server. ' + str(err) + else: + if verbose >= 1: shared.printLock.acquire() print 'Could NOT connect to', HOST, 'during outgoing attempt.', err shared.printLock.release() PORT, timeLastSeen = shared.knownNodes[ self.streamNumber][HOST] - if (int(time.time()) - timeLastSeen) > 172800 and len(shared.knownNodes[self.streamNumber]) > 1000: # for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the shared.knownNodes data-structure. + if (int(time.time()) - timeLastSeen) > 172800 and len(shared.knownNodes[self.streamNumber]) > 1000: # for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the knownNodes data-structure. shared.knownNodesLock.acquire() del shared.knownNodes[self.streamNumber][HOST] shared.knownNodesLock.release() shared.printLock.acquire() - print 'deleting ', HOST, 'from shared.knownNodes because it is more than 48 hours old and we could not connect to it.' + print 'deleting ', HOST, 'from knownNodes because it is more than 48 hours old and we could not connect to it.' shared.printLock.release() - except socks.Socks5AuthError as err: - shared.UISignalQueue.put(( - 'updateStatusBar', _translate( - "MainWindow", "SOCKS5 Authentication problem: %1").arg(str(err)))) - except socks.Socks5Error as err: - pass - print 'SOCKS5 error. (It is possible that the server wants authentication).)', str(err) - except socks.Socks4Error as err: - print 'Socks4Error:', err - except socket.error as err: - if shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS': - print 'Bitmessage MIGHT be having trouble connecting to the SOCKS server. ' + str(err) - else: - if verbose >= 1: - shared.printLock.acquire() - print 'Could NOT connect to', HOST, 'during outgoing attempt.', err - shared.printLock.release() - PORT, timeLastSeen = shared.knownNodes[ - self.streamNumber][HOST] - if (int(time.time()) - timeLastSeen) > 172800 and len(shared.knownNodes[self.streamNumber]) > 1000: # for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the knownNodes data-structure. - shared.knownNodesLock.acquire() - del shared.knownNodes[self.streamNumber][HOST] - shared.knownNodesLock.release() - shared.printLock.acquire() - print 'deleting ', HOST, 'from knownNodes because it is more than 48 hours old and we could not connect to it.' - shared.printLock.release() - except Exception as err: - sys.stderr.write( - 'An exception has occurred in the outgoingSynSender thread that was not caught by other exception types: %s\n' % err) - time.sleep(0.1) + except Exception as err: + sys.stderr.write( + 'An exception has occurred in the outgoingSynSender thread that was not caught by other exception types: %s\n' % err) + time.sleep(0.1) # Only one singleListener thread will ever exist. It creates the # receiveDataThread and sendDataThread for each incoming connection. Note diff --git a/src/about.py b/src/bitmessageqt/about.py similarity index 100% rename from src/about.py rename to src/bitmessageqt/about.py diff --git a/src/about.ui b/src/bitmessageqt/about.ui similarity index 100% rename from src/about.ui rename to src/bitmessageqt/about.ui diff --git a/src/bitmessageqt/addpeer.ui b/src/bitmessageqt/addpeer.ui new file mode 100644 index 00000000..522759a8 --- /dev/null +++ b/src/bitmessageqt/addpeer.ui @@ -0,0 +1,118 @@ + + + Dialog + + + + 0 + 0 + 362 + 136 + + + + Dialog + + + + + + When you opened this dialog box, you had X peers in your list of peers. + + + + + + + You can manually add a peer here: + + + + + + + IP + + + + + + + Port + + + + + + + + + + + + + Add + + + + + + + Qt::Horizontal + + + + 47 + 20 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/bitmessage_icons.qrc b/src/bitmessageqt/bitmessage_icons.qrc similarity index 100% rename from src/bitmessage_icons.qrc rename to src/bitmessageqt/bitmessage_icons.qrc diff --git a/src/bitmessage_icons_rc.py b/src/bitmessageqt/bitmessage_icons_rc.py similarity index 100% rename from src/bitmessage_icons_rc.py rename to src/bitmessageqt/bitmessage_icons_rc.py diff --git a/src/bitmessageui.py b/src/bitmessageqt/bitmessageui.py similarity index 100% rename from src/bitmessageui.py rename to src/bitmessageqt/bitmessageui.py diff --git a/src/bitmessageui.ui b/src/bitmessageqt/bitmessageui.ui similarity index 100% rename from src/bitmessageui.ui rename to src/bitmessageqt/bitmessageui.ui diff --git a/src/help.py b/src/bitmessageqt/help.py similarity index 100% rename from src/help.py rename to src/bitmessageqt/help.py diff --git a/src/help.ui b/src/bitmessageqt/help.ui similarity index 100% rename from src/help.ui rename to src/bitmessageqt/help.ui diff --git a/src/iconglossary.py b/src/bitmessageqt/iconglossary.py similarity index 100% rename from src/iconglossary.py rename to src/bitmessageqt/iconglossary.py diff --git a/src/iconglossary.ui b/src/bitmessageqt/iconglossary.ui similarity index 100% rename from src/iconglossary.ui rename to src/bitmessageqt/iconglossary.ui diff --git a/src/newaddressdialog.py b/src/bitmessageqt/newaddressdialog.py similarity index 100% rename from src/newaddressdialog.py rename to src/bitmessageqt/newaddressdialog.py diff --git a/src/newaddressdialog.ui b/src/bitmessageqt/newaddressdialog.ui similarity index 100% rename from src/newaddressdialog.ui rename to src/bitmessageqt/newaddressdialog.ui diff --git a/src/newsubscriptiondialog.py b/src/bitmessageqt/newsubscriptiondialog.py similarity index 100% rename from src/newsubscriptiondialog.py rename to src/bitmessageqt/newsubscriptiondialog.py diff --git a/src/newsubscriptiondialog.ui b/src/bitmessageqt/newsubscriptiondialog.ui similarity index 100% rename from src/newsubscriptiondialog.ui rename to src/bitmessageqt/newsubscriptiondialog.ui diff --git a/src/regenerateaddresses.py b/src/bitmessageqt/regenerateaddresses.py similarity index 100% rename from src/regenerateaddresses.py rename to src/bitmessageqt/regenerateaddresses.py diff --git a/src/regenerateaddresses.ui b/src/bitmessageqt/regenerateaddresses.ui similarity index 100% rename from src/regenerateaddresses.ui rename to src/bitmessageqt/regenerateaddresses.ui diff --git a/src/settings.py b/src/bitmessageqt/settings.py similarity index 100% rename from src/settings.py rename to src/bitmessageqt/settings.py diff --git a/src/settings.ui b/src/bitmessageqt/settings.ui similarity index 100% rename from src/settings.ui rename to src/bitmessageqt/settings.ui diff --git a/src/specialaddressbehavior.py b/src/bitmessageqt/specialaddressbehavior.py similarity index 100% rename from src/specialaddressbehavior.py rename to src/bitmessageqt/specialaddressbehavior.py diff --git a/src/specialaddressbehavior.ui b/src/bitmessageqt/specialaddressbehavior.ui similarity index 100% rename from src/specialaddressbehavior.ui rename to src/bitmessageqt/specialaddressbehavior.ui diff --git a/src/bitmessageqt/wanlan.ui b/src/bitmessageqt/wanlan.ui new file mode 100644 index 00000000..156a111f --- /dev/null +++ b/src/bitmessageqt/wanlan.ui @@ -0,0 +1,217 @@ + + + Dialog + + + true + + + + 0 + 0 + 338 + 225 + + + + Dialog + + + + + + Connect on the Internet with everyone else + + + true + + + + + + + Ignore Internet nodes. Only try to connect to these hosts: + + + + + + + false + + + example.domain.local:8444 + + + + + + + false + + + 10.244.30.70:8080 + + + + + + + false + + + Note that you can still receive incoming connections from anyone unless they are blocked by a firewall. + + + true + + + + + + + false + + + Store network objects for two months rather than two days + + + + + + + false + + + Forgo the proof of work + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 227 + 201 + + + 157 + 218 + + + + + buttonBox + rejected() + Dialog + reject() + + + 295 + 207 + + + 286 + 218 + + + + + radioButton_2 + toggled(bool) + checkBox + setEnabled(bool) + + + 127 + 40 + + + 93 + 146 + + + + + radioButton_2 + toggled(bool) + checkBox_2 + setEnabled(bool) + + + 160 + 38 + + + 135 + 169 + + + + + radioButton_2 + toggled(bool) + lineEdit + setEnabled(bool) + + + 63 + 41 + + + 68 + 74 + + + + + radioButton_2 + toggled(bool) + lineEdit_2 + setEnabled(bool) + + + 43 + 38 + + + 50 + 98 + + + + + radioButton_2 + toggled(bool) + label + setEnabled(bool) + + + 161 + 44 + + + 160 + 120 + + + + +