Web needs to know about receive mode, not the OnionShare object

This commit is contained in:
Micah Lee 2018-03-05 08:48:04 -08:00
parent 383ccb94fc
commit cd1a1d9638
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
4 changed files with 20 additions and 6 deletions

View File

@ -67,6 +67,10 @@ def main(cwd=None):
print(strings._('no_filenames'))
sys.exit()
# Tell web if receive mode is enabled
if receive:
web.set_receive_mode()
# Debug mode?
if debug:
common.set_debug(debug)
@ -100,7 +104,7 @@ def main(cwd=None):
# Start the onionshare app
try:
app = OnionShare(onion, receive, local_only, stay_open, shutdown_timeout)
app = OnionShare(onion, local_only, stay_open, shutdown_timeout)
app.set_stealth(stealth)
app.start_onion_service()
except KeyboardInterrupt:

View File

@ -27,7 +27,7 @@ class OnionShare(object):
OnionShare is the main application class. Pass in options and run
start_onion_service and it will do the magic.
"""
def __init__(self, onion, receive, local_only=False, stay_open=False, shutdown_timeout=0):
def __init__(self, onion, local_only=False, stay_open=False, shutdown_timeout=0):
common.log('OnionShare', '__init__')
# The Onion object
@ -37,9 +37,6 @@ class OnionShare(object):
self.onion_host = None
self.stealth = None
# Receiver mode
self.receive = receive
# files and dirs to delete on shutdown
self.cleanup_filenames = []

View File

@ -175,6 +175,19 @@ def set_gui_mode():
gui_mode = True
# Are we using receive mode?
receive_mode = False
def set_receive_mode():
"""
Tell the web service that we're running in GUI mode
"""
global receive_mode
receive_mode = True
print('receive mode enabled')
def debug_mode():
"""
Turn on debugging mode, which will log flask errors to a debug file.

View File

@ -105,7 +105,7 @@ def main():
# Start the OnionShare app
web.set_stay_open(stay_open)
app = OnionShare(onion, False, local_only, stay_open, shutdown_timeout)
app = OnionShare(onion, local_only, stay_open, shutdown_timeout)
# Launch the gui
gui = OnionShareGui(onion, qtapp, app, filenames, config)