2014-09-02 20:30:01 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-09-02 15:10:42 -04:00
|
|
|
"""
|
|
|
|
OnionShare | https://onionshare.org/
|
|
|
|
|
2016-02-16 01:37:28 -05:00
|
|
|
Copyright (C) 2016 Micah Lee <micah@micahflee.com>
|
2014-09-02 15:10:42 -04:00
|
|
|
|
|
|
|
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/>.
|
|
|
|
"""
|
2014-08-14 10:37:33 -04:00
|
|
|
from __future__ import division
|
2014-08-29 17:32:19 -04:00
|
|
|
import os, sys, subprocess, inspect, platform, argparse, threading, time, math, inspect, platform
|
2016-02-12 18:12:27 -05:00
|
|
|
from PyQt5 import QtCore, QtWidgets, QtGui
|
2014-06-19 16:19:46 -04:00
|
|
|
|
2016-02-12 18:45:26 -05:00
|
|
|
import onionshare
|
2014-08-26 22:04:39 -04:00
|
|
|
from onionshare import strings, helpers, web
|
2014-08-14 10:37:33 -04:00
|
|
|
|
2016-02-12 18:12:27 -05:00
|
|
|
from .file_selection import FileSelection
|
|
|
|
from .server_status import ServerStatus
|
|
|
|
from .downloads import Downloads
|
|
|
|
from .options import Options
|
2014-08-27 17:21:08 -04:00
|
|
|
|
2014-11-18 12:29:32 -05:00
|
|
|
|
2016-02-12 18:12:27 -05:00
|
|
|
class Application(QtWidgets.QApplication):
|
2015-11-15 22:01:20 -05:00
|
|
|
"""
|
|
|
|
This is Qt's QApplication class. It has been overridden to support threads
|
|
|
|
and the quick keyboard shortcut.
|
|
|
|
"""
|
2014-06-19 23:00:36 -04:00
|
|
|
def __init__(self):
|
2014-08-26 22:04:39 -04:00
|
|
|
platform = helpers.get_platform()
|
2015-09-08 00:44:29 -04:00
|
|
|
if platform == 'Linux':
|
2014-08-14 10:37:33 -04:00
|
|
|
self.setAttribute(QtCore.Qt.AA_X11InitThreads, True)
|
2016-02-12 18:12:27 -05:00
|
|
|
QtWidgets.QApplication.__init__(self, sys.argv)
|
2015-11-06 20:43:37 -05:00
|
|
|
self.installEventFilter(self)
|
|
|
|
|
|
|
|
def eventFilter(self, obj, event):
|
|
|
|
if (event.type() == QtCore.QEvent.KeyPress and
|
|
|
|
event.key() == QtCore.Qt.Key_Q and
|
|
|
|
event.modifiers() == QtCore.Qt.ControlModifier):
|
|
|
|
self.quit()
|
|
|
|
return False
|
2014-06-19 21:16:22 -04:00
|
|
|
|
2014-11-18 12:29:32 -05:00
|
|
|
|
2016-02-12 18:45:26 -05:00
|
|
|
class OnionShareGui(QtWidgets.QMainWindow):
|
2015-11-15 22:01:20 -05:00
|
|
|
"""
|
|
|
|
OnionShareGui is the main window for the GUI that contains all of the
|
|
|
|
GUI elements.
|
|
|
|
"""
|
2014-08-28 19:16:41 -04:00
|
|
|
start_server_finished = QtCore.pyqtSignal()
|
|
|
|
stop_server_finished = QtCore.pyqtSignal()
|
2014-09-22 15:19:24 -04:00
|
|
|
starting_server_step2 = QtCore.pyqtSignal()
|
2016-09-05 15:29:58 -04:00
|
|
|
starting_server_step3 = QtCore.pyqtSignal()
|
|
|
|
starting_server_error = QtCore.pyqtSignal(str)
|
2014-08-28 19:16:41 -04:00
|
|
|
|
2014-08-27 22:07:15 -04:00
|
|
|
def __init__(self, qtapp, app):
|
2014-08-14 10:37:33 -04:00
|
|
|
super(OnionShareGui, self).__init__()
|
2014-08-27 22:07:15 -04:00
|
|
|
self.qtapp = qtapp
|
2014-08-26 22:04:39 -04:00
|
|
|
self.app = app
|
2014-08-27 17:21:08 -04:00
|
|
|
|
|
|
|
self.setWindowTitle('OnionShare')
|
|
|
|
self.setWindowIcon(window_icon)
|
|
|
|
|
2014-08-27 20:52:45 -04:00
|
|
|
def send_files(self, filenames=None):
|
2015-11-15 22:01:20 -05:00
|
|
|
"""
|
|
|
|
Build the GUI in send files mode.
|
|
|
|
Note that this is the only mode currently implemented.
|
|
|
|
"""
|
2014-08-27 17:21:08 -04:00
|
|
|
# file selection
|
2014-08-27 22:07:15 -04:00
|
|
|
self.file_selection = FileSelection()
|
2014-08-27 20:24:44 -04:00
|
|
|
if filenames:
|
|
|
|
for filename in filenames:
|
2014-08-27 22:07:15 -04:00
|
|
|
self.file_selection.file_list.add_file(filename)
|
2014-08-27 17:21:08 -04:00
|
|
|
|
2014-08-27 19:11:43 -04:00
|
|
|
# server status
|
2014-08-27 22:07:15 -04:00
|
|
|
self.server_status = ServerStatus(self.qtapp, self.app, web, self.file_selection)
|
|
|
|
self.server_status.server_started.connect(self.file_selection.server_started)
|
2014-08-27 20:52:45 -04:00
|
|
|
self.server_status.server_started.connect(self.start_server)
|
2014-08-27 22:07:15 -04:00
|
|
|
self.server_status.server_stopped.connect(self.file_selection.server_stopped)
|
2014-08-27 20:52:45 -04:00
|
|
|
self.server_status.server_stopped.connect(self.stop_server)
|
2014-08-29 18:43:07 -04:00
|
|
|
self.start_server_finished.connect(self.clear_message)
|
2014-08-28 19:16:41 -04:00
|
|
|
self.start_server_finished.connect(self.server_status.start_server_finished)
|
|
|
|
self.stop_server_finished.connect(self.server_status.stop_server_finished)
|
2014-08-27 22:07:15 -04:00
|
|
|
self.file_selection.file_list.files_updated.connect(self.server_status.update)
|
2014-08-29 18:43:07 -04:00
|
|
|
self.server_status.url_copied.connect(self.copy_url)
|
2014-09-22 15:19:24 -04:00
|
|
|
self.starting_server_step2.connect(self.start_server_step2)
|
2016-09-05 15:29:58 -04:00
|
|
|
self.starting_server_step3.connect(self.start_server_step3)
|
|
|
|
self.starting_server_error.connect(self.start_server_error)
|
2014-08-27 19:11:43 -04:00
|
|
|
|
2014-09-17 21:35:30 -04:00
|
|
|
# filesize warning
|
2016-02-12 18:12:27 -05:00
|
|
|
self.filesize_warning = QtWidgets.QLabel()
|
2014-09-17 21:35:30 -04:00
|
|
|
self.filesize_warning.setStyleSheet('padding: 10px 0; font-weight: bold; color: #333333;')
|
|
|
|
self.filesize_warning.hide()
|
|
|
|
|
2014-08-27 19:43:18 -04:00
|
|
|
# downloads
|
2014-08-28 02:52:56 -04:00
|
|
|
self.downloads = Downloads()
|
2014-08-27 19:43:18 -04:00
|
|
|
|
2014-08-27 19:46:19 -04:00
|
|
|
# options
|
2015-11-20 16:43:19 -05:00
|
|
|
self.options = Options(web, self.app)
|
2014-08-27 19:46:19 -04:00
|
|
|
|
2014-08-29 18:43:07 -04:00
|
|
|
# status bar
|
2016-02-12 18:12:27 -05:00
|
|
|
self.status_bar = QtWidgets.QStatusBar()
|
2014-08-29 18:43:07 -04:00
|
|
|
self.status_bar.setSizeGripEnabled(False)
|
2016-02-12 18:12:27 -05:00
|
|
|
version_label = QtWidgets.QLabel('v{0:s}'.format(helpers.get_version()))
|
2016-02-12 18:45:26 -05:00
|
|
|
version_label.setStyleSheet('color: #666666; padding: 0 10px;')
|
2016-02-12 13:48:25 -05:00
|
|
|
self.status_bar.addPermanentWidget(version_label)
|
2016-02-12 18:45:26 -05:00
|
|
|
self.setStatusBar(self.status_bar)
|
2014-08-29 18:43:07 -04:00
|
|
|
|
2014-08-27 17:21:08 -04:00
|
|
|
# main layout
|
2016-02-12 18:12:27 -05:00
|
|
|
self.layout = QtWidgets.QVBoxLayout()
|
2014-08-27 22:07:15 -04:00
|
|
|
self.layout.addLayout(self.file_selection)
|
2014-08-27 20:52:45 -04:00
|
|
|
self.layout.addLayout(self.server_status)
|
2014-09-17 21:35:30 -04:00
|
|
|
self.layout.addWidget(self.filesize_warning)
|
2014-08-28 02:52:56 -04:00
|
|
|
self.layout.addLayout(self.downloads)
|
|
|
|
self.layout.addLayout(self.options)
|
2016-02-12 18:45:26 -05:00
|
|
|
central_widget = QtWidgets.QWidget()
|
|
|
|
central_widget.setLayout(self.layout)
|
|
|
|
self.setCentralWidget(central_widget)
|
2014-08-27 17:21:08 -04:00
|
|
|
self.show()
|
2014-08-26 22:04:39 -04:00
|
|
|
|
2014-08-28 02:52:56 -04:00
|
|
|
# check for requests frequently
|
|
|
|
self.timer = QtCore.QTimer()
|
2016-02-12 18:12:27 -05:00
|
|
|
self.timer.timeout.connect(self.check_for_requests)
|
2014-08-28 02:52:56 -04:00
|
|
|
self.timer.start(500)
|
|
|
|
|
2014-08-27 20:52:45 -04:00
|
|
|
def start_server(self):
|
2015-11-15 22:01:20 -05:00
|
|
|
"""
|
2016-09-04 20:23:06 -04:00
|
|
|
Start the onionshare server. This uses multiple threads to start the Tor onion
|
2015-11-15 22:01:20 -05:00
|
|
|
server and the web app.
|
|
|
|
"""
|
2016-04-12 19:49:46 -04:00
|
|
|
# Reset web counters
|
|
|
|
web.download_count = 0
|
|
|
|
web.error404_count = 0
|
|
|
|
|
2016-09-05 15:29:58 -04:00
|
|
|
# pick an available local port for the http service to listen on
|
2015-09-08 21:12:24 -04:00
|
|
|
self.app.choose_port()
|
2016-09-05 15:29:58 -04:00
|
|
|
|
|
|
|
# start the onion service in a new thread
|
|
|
|
def start_onion_service(self):
|
|
|
|
self.status_bar.showMessage(strings._('gui_starting_server1', True))
|
|
|
|
try:
|
|
|
|
self.app.start_onion_service()
|
|
|
|
self.starting_server_step2.emit()
|
|
|
|
|
|
|
|
except onionshare.onion.NoTor as e:
|
|
|
|
self.starting_server_error.emit(e.args[0])
|
|
|
|
return
|
|
|
|
|
|
|
|
t1 = threading.Thread(target=start_onion_service, kwargs={'self': self})
|
|
|
|
t1.daemon = True
|
|
|
|
t1.start()
|
2014-08-14 10:37:33 -04:00
|
|
|
|
2016-09-05 14:36:41 -04:00
|
|
|
# start onionshare http service in new thread
|
2016-09-05 15:29:58 -04:00
|
|
|
t2 = threading.Thread(target=web.start, args=(self.app.port, self.app.stay_open, self.app.transparent_torification))
|
|
|
|
t2.daemon = True
|
|
|
|
t2.start()
|
2014-08-14 10:37:33 -04:00
|
|
|
|
2016-09-05 15:29:58 -04:00
|
|
|
def start_server_step2(self):
|
|
|
|
"""
|
|
|
|
Step 2 in starting the onionshare server. Prepare files for serving.
|
|
|
|
"""
|
2014-08-28 19:16:41 -04:00
|
|
|
# prepare the files for sending in a new thread
|
|
|
|
def finish_starting_server(self):
|
2014-08-29 17:35:25 -04:00
|
|
|
# prepare files to share
|
2014-08-28 19:16:41 -04:00
|
|
|
web.set_file_info(self.file_selection.file_list.filenames)
|
|
|
|
self.app.cleanup_filenames.append(web.zip_filename)
|
2016-09-05 15:29:58 -04:00
|
|
|
self.starting_server_step3.emit()
|
2014-08-29 17:35:25 -04:00
|
|
|
|
|
|
|
# wait for hs
|
2016-09-05 14:36:41 -04:00
|
|
|
if not self.app.local_only and not self.app.onion.supports_ephemeral:
|
2015-12-22 23:09:30 -05:00
|
|
|
self.status_bar.showMessage(strings._('gui_starting_server3', True))
|
2016-09-05 14:16:54 -04:00
|
|
|
self.app.onion.wait_for_hs(self.app.onion_host)
|
2014-08-29 17:35:25 -04:00
|
|
|
|
|
|
|
# done
|
2014-08-28 19:16:41 -04:00
|
|
|
self.start_server_finished.emit()
|
2014-08-27 22:07:15 -04:00
|
|
|
|
2014-09-22 15:19:24 -04:00
|
|
|
self.status_bar.showMessage(strings._('gui_starting_server2', True))
|
2014-11-18 12:35:09 -05:00
|
|
|
t = threading.Thread(target=finish_starting_server, kwargs={'self': self})
|
2014-08-28 19:16:41 -04:00
|
|
|
t.daemon = True
|
|
|
|
t.start()
|
2014-08-27 22:07:15 -04:00
|
|
|
|
2016-09-05 15:29:58 -04:00
|
|
|
def start_server_step3(self):
|
|
|
|
"""
|
|
|
|
Step 3 in starting the onionshare server. This displays the large filesize
|
|
|
|
warning, if applicable.
|
|
|
|
"""
|
|
|
|
# warn about sending large files over Tor
|
|
|
|
if web.zip_filesize >= 157286400: # 150mb
|
|
|
|
self.filesize_warning.setText(strings._("large_filesize", True))
|
|
|
|
self.filesize_warning.show()
|
|
|
|
|
|
|
|
def start_server_error(self, error):
|
|
|
|
"""
|
|
|
|
If there's an error when trying to start the onion service
|
|
|
|
"""
|
|
|
|
alert(error, QtWidgets.QMessageBox.Warning)
|
|
|
|
self.server_status.stop_server()
|
|
|
|
self.status_bar.clearMessage()
|
|
|
|
|
2014-08-27 20:52:45 -04:00
|
|
|
def stop_server(self):
|
2015-11-15 22:01:20 -05:00
|
|
|
"""
|
|
|
|
Stop the onionshare server.
|
|
|
|
"""
|
2015-12-04 16:17:45 -05:00
|
|
|
if self.server_status.status != self.server_status.STATUS_STOPPED:
|
2014-09-03 20:56:10 -04:00
|
|
|
web.stop(self.app.port)
|
2014-08-27 22:07:15 -04:00
|
|
|
self.app.cleanup()
|
2014-09-17 21:35:30 -04:00
|
|
|
self.filesize_warning.hide()
|
2014-08-28 19:16:41 -04:00
|
|
|
self.stop_server_finished.emit()
|
2014-08-14 10:37:33 -04:00
|
|
|
|
2014-08-28 02:52:56 -04:00
|
|
|
def check_for_requests(self):
|
2015-11-15 22:01:20 -05:00
|
|
|
"""
|
|
|
|
Check for messages communicated from the web app, and update the GUI accordingly.
|
|
|
|
"""
|
2014-08-28 02:52:56 -04:00
|
|
|
self.update()
|
|
|
|
# only check for requests if the server is running
|
|
|
|
if self.server_status.status != self.server_status.STATUS_STARTED:
|
|
|
|
return
|
|
|
|
|
|
|
|
events = []
|
|
|
|
|
|
|
|
done = False
|
|
|
|
while not done:
|
|
|
|
try:
|
|
|
|
r = web.q.get(False)
|
|
|
|
events.append(r)
|
2016-02-12 18:12:27 -05:00
|
|
|
except web.queue.Empty:
|
2014-08-28 02:52:56 -04:00
|
|
|
done = True
|
|
|
|
|
|
|
|
for event in events:
|
2014-08-29 18:43:07 -04:00
|
|
|
if event["type"] == web.REQUEST_LOAD:
|
2014-09-15 22:09:37 -04:00
|
|
|
self.status_bar.showMessage(strings._('download_page_loaded', True))
|
2014-08-28 02:52:56 -04:00
|
|
|
|
2014-08-29 18:43:07 -04:00
|
|
|
elif event["type"] == web.REQUEST_DOWNLOAD:
|
2014-08-28 02:52:56 -04:00
|
|
|
self.downloads.add_download(event["data"]["id"], web.zip_filesize)
|
|
|
|
|
2016-04-12 19:49:46 -04:00
|
|
|
elif event["type"] == web.REQUEST_RATE_LIMIT:
|
|
|
|
self.stop_server()
|
|
|
|
alert(strings._('error_rate_limit'), QtWidgets.QMessageBox.Critical)
|
|
|
|
|
2014-08-28 02:52:56 -04:00
|
|
|
elif event["type"] == web.REQUEST_PROGRESS:
|
2015-12-23 00:57:46 -05:00
|
|
|
self.downloads.update_download(event["data"]["id"], event["data"]["bytes"])
|
2014-08-28 02:52:56 -04:00
|
|
|
|
|
|
|
# is the download complete?
|
|
|
|
if event["data"]["bytes"] == web.zip_filesize:
|
|
|
|
# close on finish?
|
|
|
|
if not web.get_stay_open():
|
|
|
|
self.server_status.stop_server()
|
2014-09-22 15:19:24 -04:00
|
|
|
|
2014-09-22 16:22:30 -04:00
|
|
|
elif event["type"] == web.REQUEST_CANCELED:
|
|
|
|
self.downloads.cancel_download(event["data"]["id"])
|
|
|
|
|
2014-08-29 18:43:07 -04:00
|
|
|
elif event["path"] != '/favicon.ico':
|
2016-04-12 19:49:46 -04:00
|
|
|
self.status_bar.showMessage('[#{0:d}] {1:s}: {2:s}'.format(web.error404_count, strings._('other_page_loaded', True), event["path"]))
|
2014-08-29 18:43:07 -04:00
|
|
|
|
|
|
|
def copy_url(self):
|
2015-11-15 22:01:20 -05:00
|
|
|
"""
|
|
|
|
When the URL gets copied to the clipboard, display this in the status bar.
|
|
|
|
"""
|
2014-09-15 22:09:37 -04:00
|
|
|
self.status_bar.showMessage(strings._('gui_copied_url', True), 2000)
|
2014-08-29 18:43:07 -04:00
|
|
|
|
|
|
|
def clear_message(self):
|
2015-11-15 22:01:20 -05:00
|
|
|
"""
|
|
|
|
Clear messages from the status bar.
|
|
|
|
"""
|
2014-08-29 18:43:07 -04:00
|
|
|
self.status_bar.clearMessage()
|
2014-08-28 02:52:56 -04:00
|
|
|
|
2016-04-10 20:43:37 -04:00
|
|
|
def closeEvent(self, e):
|
2016-04-10 22:28:22 -04:00
|
|
|
if self.server_status.status != self.server_status.STATUS_STOPPED:
|
|
|
|
dialog = QtWidgets.QMessageBox()
|
2016-04-11 13:08:24 -04:00
|
|
|
dialog.setWindowTitle("OnionShare")
|
2016-04-10 22:28:22 -04:00
|
|
|
dialog.setText(strings._('gui_quit_warning', True))
|
2016-04-11 13:08:24 -04:00
|
|
|
quit_button = dialog.addButton(strings._('gui_quit_warning_quit', True), QtWidgets.QMessageBox.YesRole)
|
|
|
|
dont_quit_button = dialog.addButton(strings._('gui_quit_warning_dont_quit', True), QtWidgets.QMessageBox.NoRole)
|
2016-04-10 22:28:22 -04:00
|
|
|
dialog.setDefaultButton(dont_quit_button)
|
|
|
|
reply = dialog.exec_()
|
|
|
|
|
|
|
|
# Quit
|
|
|
|
if reply == 0:
|
|
|
|
self.stop_server()
|
|
|
|
e.accept()
|
|
|
|
# Don't Quit
|
|
|
|
else:
|
|
|
|
e.ignore()
|
2016-04-10 20:43:37 -04:00
|
|
|
|
2014-11-18 12:29:32 -05:00
|
|
|
|
2016-02-12 18:12:27 -05:00
|
|
|
def alert(msg, icon=QtWidgets.QMessageBox.NoIcon):
|
2015-11-15 22:01:20 -05:00
|
|
|
"""
|
|
|
|
Pop up a message in a dialog window.
|
|
|
|
"""
|
2016-02-12 18:12:27 -05:00
|
|
|
dialog = QtWidgets.QMessageBox()
|
2014-06-19 20:28:55 -04:00
|
|
|
dialog.setWindowTitle("OnionShare")
|
2014-06-20 21:15:46 -04:00
|
|
|
dialog.setWindowIcon(window_icon)
|
2014-06-19 16:51:40 -04:00
|
|
|
dialog.setText(msg)
|
|
|
|
dialog.setIcon(icon)
|
|
|
|
dialog.exec_()
|
2014-05-30 20:46:24 -04:00
|
|
|
|
2014-11-18 12:29:32 -05:00
|
|
|
|
2014-05-29 21:05:30 -04:00
|
|
|
def main():
|
2015-11-15 22:01:20 -05:00
|
|
|
"""
|
|
|
|
The main() function implements all of the logic that the GUI version of onionshare uses.
|
|
|
|
"""
|
2016-09-04 23:09:18 -04:00
|
|
|
strings.load_strings(helpers)
|
2016-02-12 18:12:27 -05:00
|
|
|
print(strings._('version_string').format(helpers.get_version()))
|
2014-05-30 20:46:24 -04:00
|
|
|
|
2014-06-20 00:13:55 -04:00
|
|
|
# start the Qt app
|
2014-08-26 22:04:39 -04:00
|
|
|
global qtapp
|
|
|
|
qtapp = Application()
|
2014-06-20 00:13:55 -04:00
|
|
|
|
2014-06-26 14:22:32 -04:00
|
|
|
# parse arguments
|
|
|
|
parser = argparse.ArgumentParser()
|
2014-08-26 22:04:39 -04:00
|
|
|
parser.add_argument('--local-only', action='store_true', dest='local_only', help=strings._("help_local_only"))
|
|
|
|
parser.add_argument('--stay-open', action='store_true', dest='stay_open', help=strings._("help_stay_open"))
|
|
|
|
parser.add_argument('--debug', action='store_true', dest='debug', help=strings._("help_debug"))
|
2015-09-08 21:12:24 -04:00
|
|
|
parser.add_argument('--transparent', action='store_true', dest='transparent_torification', help=strings._("help_transparent_torification"))
|
2014-08-27 17:21:08 -04:00
|
|
|
parser.add_argument('--filenames', metavar='filenames', nargs='+', help=strings._('help_filename'))
|
2014-06-26 14:22:32 -04:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2014-08-27 17:21:08 -04:00
|
|
|
filenames = args.filenames
|
|
|
|
if filenames:
|
|
|
|
for i in range(len(filenames)):
|
|
|
|
filenames[i] = os.path.abspath(filenames[i])
|
|
|
|
|
2014-07-07 18:53:32 -04:00
|
|
|
local_only = bool(args.local_only)
|
2014-06-26 14:45:18 -04:00
|
|
|
stay_open = bool(args.stay_open)
|
2014-06-26 19:02:59 -04:00
|
|
|
debug = bool(args.debug)
|
2015-09-08 21:12:24 -04:00
|
|
|
transparent_torification = bool(args.transparent_torification)
|
2014-06-26 14:22:32 -04:00
|
|
|
|
2015-06-16 13:54:18 -04:00
|
|
|
# create the onionshare icon
|
|
|
|
global window_icon
|
2016-04-12 18:14:02 -04:00
|
|
|
window_icon = QtGui.QIcon(helpers.get_resource_path('images/logo.png'))
|
2015-06-16 13:54:18 -04:00
|
|
|
|
2014-08-27 17:21:08 -04:00
|
|
|
# validation
|
|
|
|
if filenames:
|
|
|
|
valid = True
|
|
|
|
for filename in filenames:
|
|
|
|
if not os.path.exists(filename):
|
2014-09-15 22:09:37 -04:00
|
|
|
alert(strings._("not_a_file", True).format(filename))
|
2014-08-27 17:21:08 -04:00
|
|
|
valid = False
|
|
|
|
if not valid:
|
|
|
|
sys.exit()
|
2014-08-20 17:30:28 -04:00
|
|
|
|
2014-08-26 22:04:39 -04:00
|
|
|
# start the onionshare app
|
2014-08-27 17:21:08 -04:00
|
|
|
web.set_stay_open(stay_open)
|
2015-09-08 21:12:24 -04:00
|
|
|
web.set_transparent_torification(transparent_torification)
|
|
|
|
app = onionshare.OnionShare(debug, local_only, stay_open, transparent_torification)
|
2014-08-27 17:21:08 -04:00
|
|
|
|
2014-06-20 00:13:55 -04:00
|
|
|
# clean up when app quits
|
|
|
|
def shutdown():
|
2014-08-26 22:04:39 -04:00
|
|
|
app.cleanup()
|
2016-02-12 18:12:27 -05:00
|
|
|
qtapp.aboutToQuit.connect(shutdown)
|
2014-06-20 00:13:55 -04:00
|
|
|
|
2014-08-14 10:37:33 -04:00
|
|
|
# launch the gui
|
2014-08-27 22:07:15 -04:00
|
|
|
gui = OnionShareGui(qtapp, app)
|
2014-08-27 20:52:45 -04:00
|
|
|
gui.send_files(filenames)
|
2014-06-19 21:46:22 -04:00
|
|
|
|
|
|
|
# all done
|
2014-08-26 22:04:39 -04:00
|
|
|
sys.exit(qtapp.exec_())
|
2014-05-29 21:05:30 -04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|