mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-24 13:41:14 -05:00
Make GUI pass the mode type into start_onion_service
This commit is contained in:
parent
6d38b8e0c4
commit
2aefe0ff4e
@ -107,6 +107,12 @@ class Mode(QtWidgets.QWidget):
|
||||
"""
|
||||
pass
|
||||
|
||||
def get_type(self):
|
||||
"""
|
||||
Returns the type of mode as a string (e.g. "share", "receive", etc.)
|
||||
"""
|
||||
pass
|
||||
|
||||
def human_friendly_time(self, secs):
|
||||
"""
|
||||
Returns a human-friendly time delta from given seconds.
|
||||
|
@ -101,6 +101,12 @@ class ChatMode(Mode):
|
||||
self.wrapper_layout.addLayout(self.column_layout)
|
||||
self.setLayout(self.wrapper_layout)
|
||||
|
||||
def get_type(self):
|
||||
"""
|
||||
Returns the type of mode as a string (e.g. "share", "receive", etc.)
|
||||
"""
|
||||
return "chat"
|
||||
|
||||
def get_stop_server_autostop_timer_text(self):
|
||||
"""
|
||||
Return the string to put on the stop server button, if there's an auto-stop timer
|
||||
|
@ -149,6 +149,12 @@ class ReceiveMode(Mode):
|
||||
self.wrapper_layout.addLayout(self.column_layout)
|
||||
self.setLayout(self.wrapper_layout)
|
||||
|
||||
def get_type(self):
|
||||
"""
|
||||
Returns the type of mode as a string (e.g. "share", "receive", etc.)
|
||||
"""
|
||||
return "receive"
|
||||
|
||||
def data_dir_button_clicked(self):
|
||||
"""
|
||||
Browse for a new OnionShare data directory, and save to tab settings
|
||||
|
@ -173,6 +173,12 @@ class ShareMode(Mode):
|
||||
# Always start with focus on file selection
|
||||
self.file_selection.setFocus()
|
||||
|
||||
def get_type(self):
|
||||
"""
|
||||
Returns the type of mode as a string (e.g. "share", "receive", etc.)
|
||||
"""
|
||||
return "share"
|
||||
|
||||
def autostop_sharing_checkbox_clicked(self):
|
||||
"""
|
||||
Save autostop sharing setting to the tab settings
|
||||
|
@ -173,6 +173,12 @@ class WebsiteMode(Mode):
|
||||
# Always start with focus on file selection
|
||||
self.file_selection.setFocus()
|
||||
|
||||
def get_type(self):
|
||||
"""
|
||||
Returns the type of mode as a string (e.g. "share", "receive", etc.)
|
||||
"""
|
||||
return "website"
|
||||
|
||||
def disable_csp_checkbox_clicked(self):
|
||||
"""
|
||||
Save disable CSP setting to the tab settings
|
||||
|
@ -74,7 +74,7 @@ class OnionThread(QtCore.QThread):
|
||||
try:
|
||||
if self.mode.obtain_onion_early:
|
||||
self.mode.app.start_onion_service(
|
||||
self.mode.settings, await_publication=False
|
||||
self.mode.get_type(), self.mode.settings, await_publication=False
|
||||
)
|
||||
# wait for modules in thread to load, preventing a thread-related cx_Freeze crash
|
||||
time.sleep(0.2)
|
||||
@ -83,7 +83,7 @@ class OnionThread(QtCore.QThread):
|
||||
self.mode.app.stop_onion_service(self.mode.settings)
|
||||
else:
|
||||
self.mode.app.start_onion_service(
|
||||
self.mode.settings, await_publication=True
|
||||
self.mode.get_type(), self.mode.settings, await_publication=True
|
||||
)
|
||||
# wait for modules in thread to load, preventing a thread-related cx_Freeze crash
|
||||
time.sleep(0.2)
|
||||
@ -174,7 +174,7 @@ class AutoStartTimer(QtCore.QThread):
|
||||
|
||||
class EventHandlerThread(QtCore.QThread):
|
||||
"""
|
||||
To trigger an event, write a JSON line to the events file. When that file changes,
|
||||
To trigger an event, write a JSON line to the events file. When that file changes,
|
||||
each line will be handled as an event. Valid events are:
|
||||
{"type": "new_tab"}
|
||||
{"type": "new_share_tab", "filenames": ["file1", "file2"]}
|
||||
|
Loading…
Reference in New Issue
Block a user