Further work to implement the Connect dialog on startup
This commit is contained in:
parent
bfd2d35a57
commit
c27494ace9
|
@ -9,7 +9,7 @@
|
|||
|
||||
# The software version variable is now held in shared.py
|
||||
|
||||
#import ctypes
|
||||
# import ctypes
|
||||
try:
|
||||
from gevent import monkey
|
||||
monkey.patch_all()
|
||||
|
@ -36,7 +36,7 @@ import helper_bootstrap
|
|||
|
||||
import sys
|
||||
if sys.platform == 'darwin':
|
||||
if float( "{1}.{2}".format(*sys.version_info) ) < 7.5:
|
||||
if float("{1}.{2}".format(*sys.version_info)) < 7.5:
|
||||
print "You should use python 2.7.5 or greater."
|
||||
print "Your version: {0}.{1}.{2}".format(*sys.version_info)
|
||||
sys.exit(0)
|
||||
|
@ -56,8 +56,6 @@ def connectToStream(streamNumber):
|
|||
# This is one of several classes that constitute the API
|
||||
# This class was written by Vaibhav Bhatia. Modified by Jonathan Warren (Atheros).
|
||||
# http://code.activestate.com/recipes/501148-xmlrpc-serverclient-which-does-cookie-handling-and/
|
||||
|
||||
|
||||
class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||
|
||||
def do_POST(self):
|
||||
|
@ -342,7 +340,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
msgid, toAddress, fromAddress, subject, received, message, encodingtype = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'receivedTime':received},indent=4, separators=(',', ': '))
|
||||
data += json.dumps({'msgid':msgid.encode('hex'), 'toAddress':toAddress, 'fromAddress':fromAddress, 'subject':subject.encode('base64'), 'message':message.encode('base64'), 'encodingType':encodingtype, 'receivedTime':received}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'getAllSentMessages':
|
||||
|
@ -358,7 +356,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
if len(data) > 25:
|
||||
data += ','
|
||||
data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status,'ackData':ackdata.encode('hex')},indent=4, separators=(',', ': '))
|
||||
data += json.dumps({'msgid':msgid.encode('hex'), 'toAddress':toAddress, 'fromAddress':fromAddress, 'subject':subject.encode('base64'), 'message':message.encode('base64'), 'encodingType':encodingtype, 'lastActionTime':lastactiontime, 'status':status, 'ackData':ackdata.encode('hex')}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'getInboxMessagesByAddress':
|
||||
|
@ -373,12 +371,12 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
shared.sqlLock.release()
|
||||
data = '{"inboxMessages":['
|
||||
for row in queryreturn:
|
||||
msgid, toAddress, fromAddress, subject, received, message, encodingtype= row
|
||||
msgid, toAddress, fromAddress, subject, received, message, encodingtype = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
if len(data) > 25:
|
||||
data += ','
|
||||
data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'receivedTime':received},indent=4, separators=(',', ': '))
|
||||
data += json.dumps({'msgid':msgid.encode('hex'), 'toAddress':toAddress, 'fromAddress':fromAddress, 'subject':subject.encode('base64'), 'message':message.encode('base64'), 'encodingType':encodingtype, 'receivedTime':received}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'getSentMessageById':
|
||||
|
@ -396,7 +394,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
msgid, toAddress, fromAddress, subject, lastactiontime, message, encodingtype, status, ackdata = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status,'ackData':ackdata.encode('hex')},indent=4, separators=(',', ': '))
|
||||
data += json.dumps({'msgid':msgid.encode('hex'), 'toAddress':toAddress, 'fromAddress':fromAddress, 'subject':subject.encode('base64'), 'message':message.encode('base64'), 'encodingType':encodingtype, 'lastActionTime':lastactiontime, 'status':status, 'ackData':ackdata.encode('hex')}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'getSentMessagesByAddress':
|
||||
|
@ -416,7 +414,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
if len(data) > 25:
|
||||
data += ','
|
||||
data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status,'ackData':ackdata.encode('hex')},indent=4, separators=(',', ': '))
|
||||
data += json.dumps({'msgid':msgid.encode('hex'), 'toAddress':toAddress, 'fromAddress':fromAddress, 'subject':subject.encode('base64'), 'message':message.encode('base64'), 'encodingType':encodingtype, 'lastActionTime':lastactiontime, 'status':status, 'ackData':ackdata.encode('hex')}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'getSentMessageByAckData':
|
||||
|
@ -434,7 +432,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
msgid, toAddress, fromAddress, subject, lastactiontime, message, encodingtype, status, ackdata = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status,'ackData':ackdata.encode('hex')},indent=4, separators=(',', ': '))
|
||||
data += json.dumps({'msgid':msgid.encode('hex'), 'toAddress':toAddress, 'fromAddress':fromAddress, 'subject':subject.encode('base64'), 'message':message.encode('base64'), 'encodingType':encodingtype, 'lastActionTime':lastactiontime, 'status':status, 'ackData':ackdata.encode('hex')}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
elif (method == 'trashMessage') or (method == 'trashInboxMessage'):
|
||||
|
@ -454,7 +452,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
#shared.UISignalQueue.put(('removeSentRowByMsgid',msgid)) This function doesn't exist yet.
|
||||
# shared.UISignalQueue.put(('removeSentRowByMsgid',msgid)) This function doesn't exist yet.
|
||||
return 'Trashed sent message (assuming message existed).'
|
||||
elif method == 'sendMessage':
|
||||
if len(params) == 0:
|
||||
|
@ -719,7 +717,6 @@ if __name__ == "__main__":
|
|||
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
|
||||
helper_bootstrap.knownNodes()
|
||||
helper_bootstrap.dns()
|
||||
# Start the address generation thread
|
||||
addressGeneratorThread = addressGenerator()
|
||||
addressGeneratorThread.daemon = True # close the main program even if there are threads left
|
||||
|
@ -757,13 +754,6 @@ if __name__ == "__main__":
|
|||
singleAPIThread = singleAPI()
|
||||
singleAPIThread.daemon = True # close the main program even if there are threads left
|
||||
singleAPIThread.start()
|
||||
# self.singleAPISignalHandlerThread = singleAPISignalHandler()
|
||||
# self.singleAPISignalHandlerThread.start()
|
||||
# QtCore.QObject.connect(self.singleAPISignalHandlerThread, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar)
|
||||
# QtCore.QObject.connect(self.singleAPISignalHandlerThread, QtCore.SIGNAL("passAddressGeneratorObjectThrough(PyQt_PyObject)"), self.connectObjectToAddressGeneratorSignals)
|
||||
# QtCore.QObject.connect(self.singleAPISignalHandlerThread,
|
||||
# QtCore.SIGNAL("displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
|
||||
# self.displayNewSentMessage)
|
||||
|
||||
connectToStream(1)
|
||||
|
||||
|
@ -783,6 +773,7 @@ if __name__ == "__main__":
|
|||
import bitmessageqt
|
||||
bitmessageqt.run()
|
||||
else:
|
||||
shared.config.remove_option('bitmessagesettings', 'dontconnect')
|
||||
with shared.printLock:
|
||||
print 'Running as a daemon. You can use Ctrl+C to exit.'
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Form implementation generated from reading ui file 'connect.ui'
|
||||
#
|
||||
# Created: Wed Jul 24 10:41:58 2013
|
||||
# Created: Wed Jul 24 12:42:01 2013
|
||||
# by: PyQt4 UI code generator 4.10
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
@ -36,9 +36,9 @@ class Ui_connectDialog(object):
|
|||
self.radioButtonConnectNow.setChecked(True)
|
||||
self.radioButtonConnectNow.setObjectName(_fromUtf8("radioButtonConnectNow"))
|
||||
self.gridLayout.addWidget(self.radioButtonConnectNow, 1, 0, 1, 2)
|
||||
self.radioButton = QtGui.QRadioButton(connectDialog)
|
||||
self.radioButton.setObjectName(_fromUtf8("radioButton"))
|
||||
self.gridLayout.addWidget(self.radioButton, 2, 0, 1, 2)
|
||||
self.radioButtonConfigureNetwork = QtGui.QRadioButton(connectDialog)
|
||||
self.radioButtonConfigureNetwork.setObjectName(_fromUtf8("radioButtonConfigureNetwork"))
|
||||
self.gridLayout.addWidget(self.radioButtonConfigureNetwork, 2, 0, 1, 2)
|
||||
spacerItem = QtGui.QSpacerItem(185, 24, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout.addItem(spacerItem, 3, 0, 1, 1)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(connectDialog)
|
||||
|
@ -53,8 +53,8 @@ class Ui_connectDialog(object):
|
|||
QtCore.QMetaObject.connectSlotsByName(connectDialog)
|
||||
|
||||
def retranslateUi(self, connectDialog):
|
||||
connectDialog.setWindowTitle(_translate("connectDialog", "Dialog", None))
|
||||
connectDialog.setWindowTitle(_translate("connectDialog", "Bitmessage", None))
|
||||
self.label.setText(_translate("connectDialog", "Bitmessage won\'t connect to anyone until you let it. ", None))
|
||||
self.radioButtonConnectNow.setText(_translate("connectDialog", "Connect now", None))
|
||||
self.radioButton.setText(_translate("connectDialog", "Let me configure special network settings first", None))
|
||||
self.radioButtonConfigureNetwork.setText(_translate("connectDialog", "Let me configure special network settings first", None))
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Bitmessage</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
|
@ -32,7 +32,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<widget class="QRadioButton" name="radioButtonConfigureNetwork">
|
||||
<property name="text">
|
||||
<string>Let me configure special network settings first</string>
|
||||
</property>
|
||||
|
|
|
@ -3,6 +3,7 @@ import shared
|
|||
import socket
|
||||
from class_sendDataThread import *
|
||||
from class_receiveDataThread import *
|
||||
import helper_bootstrap
|
||||
|
||||
# Only one singleListener thread will ever exist. It creates the
|
||||
# receiveDataThread and sendDataThread for each incoming connection. Note
|
||||
|
@ -21,14 +22,15 @@ class singleListener(threading.Thread):
|
|||
self.selfInitiatedConnections = selfInitiatedConnections
|
||||
|
||||
def run(self):
|
||||
while shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||
time.sleep(1)
|
||||
helper_bootstrap.dns()
|
||||
# We typically don't want to accept incoming connections if the user is using a
|
||||
# SOCKS proxy, unless they have configured otherwise. If they eventually select
|
||||
# proxy 'none' or configure SOCKS listening then this will start listening for
|
||||
# connections.
|
||||
while shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and not shared.config.getboolean('bitmessagesettings', 'sockslisten'):
|
||||
time.sleep(10)
|
||||
while shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||
time.sleep(1)
|
||||
time.sleep(5)
|
||||
|
||||
with shared.printLock:
|
||||
print 'Listening for incoming connections.'
|
||||
|
|
|
@ -12,21 +12,18 @@ def knownNodes():
|
|||
shared.knownNodes = pickle.load(pickleFile)
|
||||
pickleFile.close()
|
||||
except:
|
||||
defaultKnownNodes.createDefaultKnownNodes(shared.appdata)
|
||||
pickleFile = open(shared.appdata + 'knownnodes.dat', 'rb')
|
||||
shared.knownNodes = pickle.load(pickleFile)
|
||||
pickleFile.close()
|
||||
shared.knownNodes = defaultKnownNodes.createDefaultKnownNodes(shared.appdata)
|
||||
if shared.config.getint('bitmessagesettings', 'settingsversion') > 6:
|
||||
print 'Bitmessage cannot read future versions of the keys file (keys.dat). Run the newer version of Bitmessage.'
|
||||
raise SystemExit
|
||||
|
||||
|
||||
def dns():
|
||||
# DNS bootstrap. This could be programmed to use the SOCKS proxy to do the
|
||||
# DNS lookup some day but for now we will just rely on the entries in
|
||||
# defaultKnownNodes.py. Hopefully either they are up to date or the user
|
||||
# has run Bitmessage recently without SOCKS turned on and received good
|
||||
# bootstrap nodes using that method.
|
||||
with shared.printLock:
|
||||
if shared.config.get('bitmessagesettings', 'socksproxytype') == 'none':
|
||||
try:
|
||||
for item in socket.getaddrinfo('bootstrap8080.bitmessage.org', 80):
|
||||
|
|
Reference in New Issue
Block a user