aboutsummaryrefslogtreecommitdiff
path: root/onionshare
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2019-11-02 10:43:20 -0700
committerMicah Lee <micah@micahflee.com>2019-11-02 10:43:20 -0700
commit9534a440512e848b35a6c9e4535d70ed8d373a95 (patch)
tree233ca0dec7477df962ed1c28b31660ec53aeb490 /onionshare
parent2984577f28e90ec7780a94f80f2b6f7c3398611a (diff)
downloadonionshare-9534a440512e848b35a6c9e4535d70ed8d373a95.tar.gz
onionshare-9534a440512e848b35a6c9e4535d70ed8d373a95.zip
Make a new ModeSettings class in onionshare, and use this instead of tab_settings
Diffstat (limited to 'onionshare')
-rw-r--r--onionshare/mode_settings.py54
-rw-r--r--onionshare/web/web.py11
2 files changed, 64 insertions, 1 deletions
diff --git a/onionshare/mode_settings.py b/onionshare/mode_settings.py
new file mode 100644
index 00000000..9557abcd
--- /dev/null
+++ b/onionshare/mode_settings.py
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+"""
+OnionShare | https://onionshare.org/
+
+Copyright (C) 2014-2018 Micah Lee <micah@micahflee.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+
+class ModeSettings:
+ """
+ This stores the settings for a single instance of an OnionShare mode. In CLI there
+ is only one TabSettings, and in the GUI there is a separate TabSettings for each tab
+ """
+
+ def __init__(self, common):
+ self.common = common
+
+ self.settings = {
+ "persistent": {
+ "enabled": False,
+ "private_key": None,
+ "hidservauth": None,
+ "password": None,
+ },
+ "general": {
+ "public": False,
+ "autostart_timer": False,
+ "autostop_timer": False,
+ "legacy": False,
+ "client_auth": False,
+ },
+ "share": {"autostop_sharing": True},
+ "receive": {"data_dir": self.common.settings.build_default_data_dir()},
+ "website": {"disable_csp": False},
+ }
+
+ def get(self, group, key):
+ return self.settings[group][key]
+
+ def set(self, group, key, val):
+ self.settings[group][key] = val
diff --git a/onionshare/web/web.py b/onionshare/web/web.py
index 16dfffd0..604faf02 100644
--- a/onionshare/web/web.py
+++ b/onionshare/web/web.py
@@ -60,10 +60,19 @@ class Web:
REQUEST_OTHER = 13
REQUEST_INVALID_PASSWORD = 14
- def __init__(self, common, is_gui, mode="share"):
+ def __init__(
+ self, common, is_gui, tab_settings_get=None, tab_settings_set=None, mode="share"
+ ):
+ """
+ tab_settings_get and tab_settings_set are getter and setter functions for tab settings
+ """
+
self.common = common
self.common.log("Web", "__init__", f"is_gui={is_gui}, mode={mode}")
+ self.settings_get = tab_settings_get
+ self.settings_set = tab_settings_set
+
# The flask app
self.app = Flask(
__name__,