mirror of
https://github.com/onionshare/onionshare.git
synced 2025-08-19 03:18:11 -04:00
onionshare closes automatically (if box is checked) when download finishes. fixes #36
This commit is contained in:
parent
de0e8f9eb0
commit
86d835f291
7 changed files with 56 additions and 7 deletions
|
@ -73,10 +73,11 @@ def download():
|
||||||
chunk = fp.read(102400)
|
chunk = fp.read(102400)
|
||||||
if chunk == '':
|
if chunk == '':
|
||||||
done = True
|
done = True
|
||||||
yield chunk
|
else:
|
||||||
|
yield chunk
|
||||||
# tell GUI the progress
|
|
||||||
add_request(REQUEST_PROGRESS, path, { 'id':download_id, 'bytes':fp.tell() })
|
# tell GUI the progress
|
||||||
|
add_request(REQUEST_PROGRESS, path, { 'id':download_id, 'bytes':fp.tell() })
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
r = Response(generate())
|
r = Response(generate())
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
"download_started": "Download started",
|
"download_started": "Download started",
|
||||||
"download_finished": "Download finished",
|
"download_finished": "Download finished",
|
||||||
"other_page_loaded": "Other page has been loaded",
|
"other_page_loaded": "Other page has been loaded",
|
||||||
"tails_requires_root": "You must run OnionShare as root in Tails"
|
"tails_requires_root": "You must run OnionShare as root in Tails",
|
||||||
|
"close_on_finish": "Close automatically",
|
||||||
|
"close_countdown": "Closing in {0} seconds..."
|
||||||
}, "no": {
|
}, "no": {
|
||||||
"punching_a_hole": "Åpner port i brannmuren.",
|
"punching_a_hole": "Åpner port i brannmuren.",
|
||||||
"closing_hole": "Lukker port i brannmuren.",
|
"closing_hole": "Lukker port i brannmuren.",
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import onionshare, webapp
|
import onionshare, webapp
|
||||||
import threading, gtk, gobject, webkit, os, sys, subprocess
|
import threading, gtk, gobject, webkit, os, sys, subprocess
|
||||||
|
|
||||||
|
window = gtk.Window()
|
||||||
|
|
||||||
def alert(msg, type=gtk.MESSAGE_INFO):
|
def alert(msg, type=gtk.MESSAGE_INFO):
|
||||||
dialog = gtk.MessageDialog(
|
dialog = gtk.MessageDialog(
|
||||||
parent=None,
|
parent=None,
|
||||||
|
@ -43,10 +45,12 @@ def select_file(strings):
|
||||||
return filename, basename
|
return filename, basename
|
||||||
|
|
||||||
def start_webapp(webapp_port, onionshare_port, filename, onion_host):
|
def start_webapp(webapp_port, onionshare_port, filename, onion_host):
|
||||||
|
global window
|
||||||
webapp.onionshare = onionshare
|
webapp.onionshare = onionshare
|
||||||
webapp.onionshare_port = onionshare_port
|
webapp.onionshare_port = onionshare_port
|
||||||
webapp.filename = filename
|
webapp.filename = filename
|
||||||
webapp.onion_host = onion_host
|
webapp.onion_host = onion_host
|
||||||
|
webapp.window = window
|
||||||
webapp.app.run(port=webapp_port)
|
webapp.app.run(port=webapp_port)
|
||||||
|
|
||||||
def launch_window(webapp_port, onionshare_port):
|
def launch_window(webapp_port, onionshare_port):
|
||||||
|
@ -55,7 +59,7 @@ def launch_window(webapp_port, onionshare_port):
|
||||||
onionshare.tails_close_port(webapp_port)
|
onionshare.tails_close_port(webapp_port)
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
||||||
window = gtk.Window()
|
global window
|
||||||
window.set_title('OnionShare')
|
window.set_title('OnionShare')
|
||||||
window.resize(520, 400)
|
window.resize(520, 400)
|
||||||
window.set_resizable(False)
|
window.set_resizable(False)
|
||||||
|
|
|
@ -44,6 +44,22 @@ $(function(){
|
||||||
// is the download complete?
|
// is the download complete?
|
||||||
if(r.data.bytes == onionshare.filesize) {
|
if(r.data.bytes == onionshare.filesize) {
|
||||||
$('#download-'+r.data.id).html(onionshare.strings['download_finished']);
|
$('#download-'+r.data.id).html(onionshare.strings['download_finished']);
|
||||||
|
|
||||||
|
// close on finish?
|
||||||
|
if($('#close-on-finish').is(':checked')) {
|
||||||
|
function close_countdown(i) {
|
||||||
|
$('#close-countdown').html(onionshare.strings['close_countdown'].replace('{0}', i));
|
||||||
|
if(i == 0) {
|
||||||
|
// close program
|
||||||
|
$.ajax({ url: '/close' });
|
||||||
|
} else {
|
||||||
|
// continue countdown
|
||||||
|
setTimeout(function(){ close_countdown(i-1) }, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update($('<span>').attr('id', 'close-countdown'));
|
||||||
|
close_countdown(3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// still in progress
|
// still in progress
|
||||||
else {
|
else {
|
||||||
|
@ -71,6 +87,7 @@ $(function(){
|
||||||
$('#basename').html(onionshare.basename);
|
$('#basename').html(onionshare.basename);
|
||||||
$('#filesize .label').html(onionshare.strings['filesize']+':');
|
$('#filesize .label').html(onionshare.strings['filesize']+':');
|
||||||
$('#filehash .label').html(onionshare.strings['sha1_checksum']+':');
|
$('#filehash .label').html(onionshare.strings['sha1_checksum']+':');
|
||||||
|
$('#close-on-finish-wrapper label').html(onionshare.strings['close_on_finish']);
|
||||||
$('#loading .calculating').html(onionshare.strings['calculating_sha1']);
|
$('#loading .calculating').html(onionshare.strings['calculating_sha1']);
|
||||||
|
|
||||||
// after getting the initial info, start the onionshare server
|
// after getting the initial info, start the onionshare server
|
||||||
|
|
|
@ -46,6 +46,16 @@ body {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
#metadata #close-on-finish-wrapper {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
#metadata #close-on-finish-wrapper input {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
#metadata #close-on-finish-wrapper label {
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
ul#log {
|
ul#log {
|
||||||
float: left;
|
float: left;
|
||||||
|
@ -88,6 +98,10 @@ ul#log li#loading .calculating {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
ul#log #close-countdown {
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
-moz-box-shadow:inset 0px 1px 0px 0px #d197fe;
|
-moz-box-shadow:inset 0px 1px 0px 0px #d197fe;
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
<span class="label"></span>
|
<span class="label"></span>
|
||||||
<span class="value"></span>
|
<span class="value"></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="close-on-finish-wrapper">
|
||||||
|
<input type="checkbox" id="close-on-finish" name="close-on-finish" checked />
|
||||||
|
<label for="close-on-finish"></span>
|
||||||
|
</div>
|
||||||
<div id="button-wrapper">
|
<div id="button-wrapper">
|
||||||
<button class="button" id="copy-button">Copy URL</button>
|
<button class="button" id="copy-button">Copy URL</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template
|
||||||
import threading, json, os, gtk
|
import threading, json, os, gtk, gobject
|
||||||
|
|
||||||
onionshare = None
|
onionshare = None
|
||||||
onionshare_port = None
|
onionshare_port = None
|
||||||
filename = None
|
filename = None
|
||||||
onion_host = None
|
onion_host = None
|
||||||
|
window = None
|
||||||
|
|
||||||
clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
|
clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
|
||||||
url = None
|
url = None
|
||||||
|
@ -66,3 +67,9 @@ def check_for_requests():
|
||||||
|
|
||||||
return json.dumps(events)
|
return json.dumps(events)
|
||||||
|
|
||||||
|
@app.route("/close")
|
||||||
|
def close():
|
||||||
|
global window
|
||||||
|
gobject.timeout_add(1000, window.destroy)
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue