[Pkg-privacy-commits] [onionshare] 124/256: Add bundled Tor to Tor connection settings, and make it only work in Windows and Mac, and not in dev mode

Ulrike Uhlig ulrike at moszumanska.debian.org
Fri May 26 12:53:26 UTC 2017


This is an automated email from the git hooks/post-receive script.

ulrike pushed a commit to branch master
in repository onionshare.

commit 8280b1b5d88f81428a742e25f6153edc5e8a5d8e
Author: Micah Lee <micah at micahflee.com>
Date:   Sat Apr 8 17:48:58 2017 -0700

    Add bundled Tor to Tor connection settings, and make it only work in Windows and Mac, and not in dev mode
---
 onionshare_gui/settings_dialog.py | 41 ++++++++++++++++++++++++++++++++++-----
 share/locale/en.json              |  1 +
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py
index 7c3c3a5..3a41dfd 100644
--- a/onionshare_gui/settings_dialog.py
+++ b/onionshare_gui/settings_dialog.py
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 from PyQt5 import QtCore, QtWidgets, QtGui
+import sys, platform
 
 from onionshare import strings
 from onionshare.settings import Settings
@@ -68,6 +69,21 @@ class SettingsDialog(QtWidgets.QDialog):
 
         # Connection type: either automatic, control port, or socket file
 
+        # Bundled Tor
+        self.connection_type_bundled_radio = QtWidgets.QRadioButton(strings._('gui_settings_connection_type_bundled_option', True))
+        self.connection_type_bundled_radio.toggled.connect(self.connection_type_bundled_toggled)
+
+        # Bundled Tor only works in Windows and Mac
+        p = platform.system()
+        if (p == 'Windows' or p == 'Darwin'):
+            # Bundled Tor doesn't work on dev mode
+            if getattr(sys, 'onionshare_dev_mode', False):
+                self.connection_type_bundled_radio.setEnabled(False)
+        else:
+            # If not using Windows or Mac, disable and hide bundled Tor
+            self.connection_type_bundled_radio.setEnabled(False)
+            self.connection_type_bundled_radio.hide()
+
         # Automatic
         self.connection_type_automatic_radio = QtWidgets.QRadioButton(strings._('gui_settings_connection_type_automatic_option', True))
         self.connection_type_automatic_radio.toggled.connect(self.connection_type_automatic_toggled)
@@ -104,6 +120,7 @@ class SettingsDialog(QtWidgets.QDialog):
 
         # Connection type layout
         connection_type_group_layout = QtWidgets.QVBoxLayout()
+        connection_type_group_layout.addWidget(self.connection_type_bundled_radio)
         connection_type_group_layout.addWidget(self.connection_type_automatic_radio)
         connection_type_group_layout.addWidget(self.connection_type_control_port_radio)
         connection_type_group_layout.addWidget(self.connection_type_socket_file_radio)
@@ -182,7 +199,13 @@ class SettingsDialog(QtWidgets.QDialog):
             self.stealth_checkbox.setCheckState(QtCore.Qt.Unchecked)
 
         connection_type = settings.get('connection_type')
-        if connection_type == 'automatic':
+        if connection_type == 'bundled':
+            if self.connection_type_bundled_radio.isEnabled():
+                self.connection_type_bundled_radio.setChecked(True)
+            else:
+                # If bundled tor is disabled, fallback to automatic
+                self.connection_type_automatic_radio.setChecked(True)
+        elif connection_type == 'automatic':
             self.connection_type_automatic_radio.setChecked(True)
         elif connection_type == 'control_port':
             self.connection_type_control_port_radio.setChecked(True)
@@ -201,15 +224,19 @@ class SettingsDialog(QtWidgets.QDialog):
         # Show the dialog
         self.exec_()
 
+    def connection_type_bundled_toggled(self, checked):
+        """
+        Connection type bundled was toggled. If checked, hide authentication fields.
+        """
+        if checked:
+            self.authenticate_group.hide()
+
     def connection_type_automatic_toggled(self, checked):
         """
-        Connection type automatic was toggled. If checked, disable all other
-        fields. If unchecked, enable all other fields.
+        Connection type automatic was toggled. If checked, hide authentication fields.
         """
         if checked:
             self.authenticate_group.hide()
-        else:
-            self.authenticate_group.show()
 
     def connection_type_control_port_toggled(self, checked):
         """
@@ -217,6 +244,7 @@ class SettingsDialog(QtWidgets.QDialog):
         for Tor control address and port. If unchecked, hide those extra fields.
         """
         if checked:
+            self.authenticate_group.show()
             self.connection_type_control_port_extras.show()
         else:
             self.connection_type_control_port_extras.hide()
@@ -228,6 +256,7 @@ class SettingsDialog(QtWidgets.QDialog):
         for socket file. If unchecked, hide those extra fields.
         """
         if checked:
+            self.authenticate_group.show()
             self.connection_type_socket_file_extras.show()
         else:
             self.connection_type_socket_file_extras.hide()
@@ -287,6 +316,8 @@ class SettingsDialog(QtWidgets.QDialog):
         settings.set('close_after_first_download', self.close_after_first_download_checkbox.isChecked())
         settings.set('use_stealth', self.stealth_checkbox.isChecked())
 
+        if self.connection_type_bundled_radio.isChecked():
+            settings.set('connection_type', 'bundled')
         if self.connection_type_automatic_radio.isChecked():
             settings.set('connection_type', 'automatic')
         if self.connection_type_control_port_radio.isChecked():
diff --git a/share/locale/en.json b/share/locale/en.json
index b18ffda..9f192a4 100644
--- a/share/locale/en.json
+++ b/share/locale/en.json
@@ -62,6 +62,7 @@
     "gui_settings_sharing_label": "Sharing options",
     "gui_settings_close_after_first_download_option": "Stop sharing after first download",
     "gui_settings_connection_type_label": "How should OnionShare connect to Tor?",
+    "gui_settings_connection_type_bundled_option": "Use Tor that is bundled with OnionShare",
     "gui_settings_connection_type_automatic_option": "Attempt automatic configuration with Tor Browser",
     "gui_settings_connection_type_control_port_option": "Connect using control port",
     "gui_settings_connection_type_socket_file_option": "Connect using socket file",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list