Prompt user before connecting the first time #332
|
@ -23,6 +23,7 @@ from settings import *
|
||||||
from about import *
|
from about import *
|
||||||
from help import *
|
from help import *
|
||||||
from iconglossary import *
|
from iconglossary import *
|
||||||
|
from connect import *
|
||||||
import sys
|
import sys
|
||||||
from time import strftime, localtime, gmtime
|
from time import strftime, localtime, gmtime
|
||||||
import time
|
import time
|
||||||
|
@ -424,6 +425,8 @@ class MyForm(QtGui.QMainWindow):
|
||||||
|
|
||||||
self.rerenderComboBoxSendFrom()
|
self.rerenderComboBoxSendFrom()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Show or hide the application window after clicking an item within the
|
# Show or hide the application window after clicking an item within the
|
||||||
# tray icon or, on Windows, the try icon itself.
|
# tray icon or, on Windows, the try icon itself.
|
||||||
def appIndicatorShowOrHideWindow(self):
|
def appIndicatorShowOrHideWindow(self):
|
||||||
|
@ -1160,6 +1163,16 @@ class MyForm(QtGui.QMainWindow):
|
||||||
"MainWindow", "Successfully joined chan. "))
|
"MainWindow", "Successfully joined chan. "))
|
||||||
self.ui.tabWidget.setCurrentIndex(3)
|
self.ui.tabWidget.setCurrentIndex(3)
|
||||||
|
|
||||||
|
def showConnectDialog(self):
|
||||||
|
self.connectDialogInstance = connectDialog(self)
|
||||||
|
if self.connectDialogInstance.exec_():
|
||||||
|
if self.connectDialogInstance.ui.radioButtonConnectNow.isChecked():
|
||||||
|
shared.config.remove_option('bitmessagesettings', 'dontconnect')
|
||||||
|
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||||
|
shared.config.write(configfile)
|
||||||
|
else:
|
||||||
|
self.click_actionSettings()
|
||||||
|
|
||||||
def openKeysFile(self):
|
def openKeysFile(self):
|
||||||
if 'linux' in sys.platform:
|
if 'linux' in sys.platform:
|
||||||
subprocess.call(["xdg-open", shared.appdata + 'keys.dat'])
|
subprocess.call(["xdg-open", shared.appdata + 'keys.dat'])
|
||||||
|
@ -1946,6 +1959,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
shared.config.set('bitmessagesettings', 'startintray', str(
|
shared.config.set('bitmessagesettings', 'startintray', str(
|
||||||
self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked()))
|
self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked()))
|
||||||
if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
|
if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
|
||||||
|
if not shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||||
QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
|
QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
|
||||||
"MainWindow", "You must restart Bitmessage for the port number change to take effect."))
|
"MainWindow", "You must restart Bitmessage for the port number change to take effect."))
|
||||||
shared.config.set('bitmessagesettings', 'port', str(
|
shared.config.set('bitmessagesettings', 'port', str(
|
||||||
|
@ -2868,6 +2882,14 @@ class helpDialog(QtGui.QDialog):
|
||||||
self.ui.labelHelpURI.setOpenExternalLinks(True)
|
self.ui.labelHelpURI.setOpenExternalLinks(True)
|
||||||
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||||
|
|
||||||
|
class connectDialog(QtGui.QDialog):
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
QtGui.QWidget.__init__(self, parent)
|
||||||
|
self.ui = Ui_connectDialog()
|
||||||
|
self.ui.setupUi(self)
|
||||||
|
self.parent = parent
|
||||||
|
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||||
|
|
||||||
class aboutDialog(QtGui.QDialog):
|
class aboutDialog(QtGui.QDialog):
|
||||||
|
|
||||||
|
@ -3211,6 +3233,8 @@ def run():
|
||||||
myapp.appIndicatorInit(app)
|
myapp.appIndicatorInit(app)
|
||||||
myapp.ubuntuMessagingMenuInit()
|
myapp.ubuntuMessagingMenuInit()
|
||||||
myapp.notifierInit()
|
myapp.notifierInit()
|
||||||
|
if shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||||
|
myapp.showConnectDialog() # ask the user if we may connect
|
||||||
if gevent is None:
|
if gevent is None:
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
else:
|
else:
|
||||||
|
|
60
src/bitmessageqt/connect.py
Normal file
60
src/bitmessageqt/connect.py
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Form implementation generated from reading ui file 'connect.ui'
|
||||||
|
#
|
||||||
|
# Created: Wed Jul 24 10:41:58 2013
|
||||||
|
# by: PyQt4 UI code generator 4.10
|
||||||
|
#
|
||||||
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
try:
|
||||||
|
_fromUtf8 = QtCore.QString.fromUtf8
|
||||||
|
except AttributeError:
|
||||||
|
def _fromUtf8(s):
|
||||||
|
return s
|
||||||
|
|
||||||
|
try:
|
||||||
|
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||||
|
def _translate(context, text, disambig):
|
||||||
|
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||||
|
except AttributeError:
|
||||||
|
def _translate(context, text, disambig):
|
||||||
|
return QtGui.QApplication.translate(context, text, disambig)
|
||||||
|
|
||||||
|
class Ui_connectDialog(object):
|
||||||
|
def setupUi(self, connectDialog):
|
||||||
|
connectDialog.setObjectName(_fromUtf8("connectDialog"))
|
||||||
|
connectDialog.resize(400, 124)
|
||||||
|
self.gridLayout = QtGui.QGridLayout(connectDialog)
|
||||||
|
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
|
||||||
|
self.label = QtGui.QLabel(connectDialog)
|
||||||
|
self.label.setObjectName(_fromUtf8("label"))
|
||||||
|
self.gridLayout.addWidget(self.label, 0, 0, 1, 2)
|
||||||
|
self.radioButtonConnectNow = QtGui.QRadioButton(connectDialog)
|
||||||
|
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)
|
||||||
|
spacerItem = QtGui.QSpacerItem(185, 24, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||||
|
self.gridLayout.addItem(spacerItem, 3, 0, 1, 1)
|
||||||
|
self.buttonBox = QtGui.QDialogButtonBox(connectDialog)
|
||||||
|
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||||
|
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
|
||||||
|
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
||||||
|
self.gridLayout.addWidget(self.buttonBox, 3, 1, 1, 1)
|
||||||
|
|
||||||
|
self.retranslateUi(connectDialog)
|
||||||
|
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), connectDialog.accept)
|
||||||
|
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), connectDialog.reject)
|
||||||
|
QtCore.QMetaObject.connectSlotsByName(connectDialog)
|
||||||
|
|
||||||
|
def retranslateUi(self, connectDialog):
|
||||||
|
connectDialog.setWindowTitle(_translate("connectDialog", "Dialog", 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))
|
||||||
|
|
101
src/bitmessageqt/connect.ui
Normal file
101
src/bitmessageqt/connect.ui
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>connectDialog</class>
|
||||||
|
<widget class="QDialog" name="connectDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>124</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Bitmessage won't connect to anyone until you let it. </string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QRadioButton" name="radioButtonConnectNow">
|
||||||
|
<property name="text">
|
||||||
|
<string>Connect now</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QRadioButton" name="radioButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Let me configure special network settings first</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>185</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>connectDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>connectDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -23,7 +23,8 @@ class outgoingSynSender(threading.Thread):
|
||||||
self.selfInitiatedConnections = selfInitiatedConnections
|
self.selfInitiatedConnections = selfInitiatedConnections
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
time.sleep(1)
|
while shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||||
|
time.sleep(2)
|
||||||
while True:
|
while True:
|
||||||
while len(self.selfInitiatedConnections[self.streamNumber]) >= 8: # maximum number of outgoing connections = 8
|
while len(self.selfInitiatedConnections[self.streamNumber]) >= 8: # maximum number of outgoing connections = 8
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
|
@ -26,7 +26,9 @@ class singleListener(threading.Thread):
|
||||||
# proxy 'none' or configure SOCKS listening then this will start listening for
|
# proxy 'none' or configure SOCKS listening then this will start listening for
|
||||||
# connections.
|
# connections.
|
||||||
while shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and not shared.config.getboolean('bitmessagesettings', 'sockslisten'):
|
while shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and not shared.config.getboolean('bitmessagesettings', 'sockslisten'):
|
||||||
time.sleep(300)
|
time.sleep(10)
|
||||||
|
while shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
with shared.printLock:
|
with shared.printLock:
|
||||||
print 'Listening for incoming connections.'
|
print 'Listening for incoming connections.'
|
||||||
|
|
|
@ -66,6 +66,7 @@ def loadConfig():
|
||||||
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte', '0')
|
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte', '0')
|
||||||
shared.config.set(
|
shared.config.set(
|
||||||
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', '0')
|
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', '0')
|
||||||
|
shared.config.set('bitmessagesettings', 'dontconnect', 'true')
|
||||||
|
|
||||||
if storeConfigFilesInSameDirectoryAsProgramByDefault:
|
if storeConfigFilesInSameDirectoryAsProgramByDefault:
|
||||||
# Just use the same directory as the program and forget about
|
# Just use the same directory as the program and forget about
|
||||||
|
|
Reference in New Issue
Block a user