Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* define "steal" flag so clients can specify if they want to take a session from another client
* refactor the form flag forwarding code to be more generic (we must forward both "true" and "false" values since some will have different defaults)

git-svn-id: https://xpra.org/svn/Xpra/trunk@15393 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 25, 2017
1 parent 7423df0 commit de7d884
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 23 deletions.
39 changes: 18 additions & 21 deletions src/html5/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ <h4 class="panel-title">Advanced options</h4>
<li class="list-group-item">
<input type="checkbox" id="sharing"> <span>Share session</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="steal"> <span>Steal session from existing client</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="video"> <span>Video (experimental) <input type="checkbox" id="mediasource_video"> Native decoding</span>
</li>
Expand Down Expand Up @@ -292,7 +295,7 @@ <h4 class="panel-title">Advanced options</h4>
var printing = document.getElementById("printing").checked;
var file_transfer = document.getElementById("file_transfer").checked;
// url to client
var url = "/index.html?server="+encodeData(server)+"&port="+port+"&encoding="+encodeData(encoding)+"&keyboard_layout="+encodeData(keyboard_layout)+"&submit=true&clipboard="+clipboard+"&printing="+printing+"&file_transfer="+file_transfer;
var url = "/index.html?server="+encodeData(server)+"&port="+port+"&encoding="+encodeData(encoding)+"&keyboard_layout="+encodeData(keyboard_layout)+"&submit=true";
if (username.length>0)
url += "&username="+encodeData(username);
if (password.length>0)
Expand Down Expand Up @@ -328,12 +331,18 @@ <h4 class="panel-title">Advanced options</h4>
url = url + "&start="+encodeData(start);
}

var bool_props = ["sound", "exit_with_children", "exit_with_client", "sharing", "video", "mediasource_video", "normal_fullscreen", "debug", "insecure"];
var bool_props = ["clipboard", "printing", "file_transfer",
"exit_with_children", "exit_with_client",
"sharing", "steal", "video",
"mediasource_video", "normal_fullscreen", "debug", "insecure"];
for (var i = 0; i < bool_props.length; i++) {
var prop = bool_props[i];
if(document.getElementById(prop).checked) {
url = url + "&"+prop+"=true";
}
else {
url = url + "&"+prop+"=false";
}
}
window.location = url;
}
Expand Down Expand Up @@ -404,23 +413,6 @@ <h4 class="panel-title">Advanced options</h4>
var keyboard_layout = Utilities.getKeyboardLayout();
document.getElementById('keyboard_layout').value = keyboard_layout;

var clipboard = getboolparam("clipboard", true);
$('input#clipboard').prop("checked", clipboard);

var printing = getboolparam("printing", true);
$('input#printing').prop("checked", clipboard);
var file_transfer = getboolparam("file_transfer", true);
$('input#file_transfer').prop("checked", file_transfer);

var exit_with_children = getboolparam("exit_with_children");
if(exit_with_children) {
$('input#exit_with_children').prop("checked", exit_with_children);
}
var exit_with_client = getparam("exit_with_client");
if(exit_with_client) {
$('input#exit_with_client').prop("checked", exit_with_client);
}

var audio_codec = getparam("audio_codec") || "";
var audio_codec_select = document.getElementById("audio_codec");
var ignore_audio_blacklist = getparam("ignore_audio_blacklist");
Expand Down Expand Up @@ -484,10 +476,15 @@ <h4 class="panel-title">Advanced options</h4>
video.onchange = toggle_mediasource_video;
toggle_mediasource_video();

var bool_props = ["exit_with_children", "exit_with_client", "sharing", "video", "mediasource_video", "normal_fullscreen", "debug", "insecure"];
var bool_props = ["clipboard", "printing", "file_transfer",
"exit_with_children", "exit_with_client",
"sharing", "steal", "video",
"mediasource_video", "normal_fullscreen", "debug", "insecure"];
var default_on = ["steal", "clipboard", "printing", "file_transfer", "exit_with_children", "exit_with_client"];
for (var i = 0; i < bool_props.length; i++) {
var prop = bool_props[i];
document.getElementById(prop).checked = getparam(prop);
var def = default_on.indexOf(prop)>=0;
document.getElementById(prop).checked = getboolparam(prop, def);
}

$("#expandopts").click(function() {
Expand Down
5 changes: 4 additions & 1 deletion src/html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
var clipboard = getboolparam("clipboard", true);
var printing = getboolparam("printing", true);
var file_transfer = getboolparam("file_transfer", true);
var steal = getboolparam("steal", true);

// create the client
var client = new XpraClient('screen');
Expand All @@ -141,6 +142,7 @@
client.clipboard_enabled = clipboard;
client.printing = printing;
client.file_transfer = file_transfer;
client.steal = steal;

// mediasource video
if(video) {
Expand Down Expand Up @@ -230,6 +232,7 @@
"exit_with_children": exit_with_children,
"exit_with_client" : exit_with_client,
"sharing" : sharing,
"steal" : steal,
"normal_fullscreen" : normal_fullscreen,
"video" : video,
"mediasource_video" : mediasource_video,
Expand All @@ -240,7 +243,7 @@
}
for (var name in props) {
var value = props[name];
if(value) {
if(value !== undefined) {
url += "&"+name+"="+encodeData(value);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function XpraClient(container) {
// authentication
this.insecure = false;
this.authentication_key = null;
this.steal = true;
// hello
this.HELLO_TIMEOUT = 2000;
this.hello_timer = null;
Expand Down Expand Up @@ -686,6 +687,7 @@ XpraClient.prototype._make_hello_base = function() {
"platform.platform" : navigator.appVersion,
"namespace" : true,
"share" : this.sharing,
"steal" : this.steal,
"client_type" : "HTML5",
"encoding.generic" : true,
"username" : this.username,
Expand Down
5 changes: 4 additions & 1 deletion src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from xpra.child_reaper import getChildReaper
from xpra.os_util import BytesIOClass, thread, livefds, load_binary_file, pollwait, monotonic_time, OSX
from xpra.util import typedict, flatten_dict, updict, envbool, log_screen_sizes, engs, repr_ellipsized, csv, iround, \
SERVER_EXIT, SERVER_ERROR, SERVER_SHUTDOWN, DETACH_REQUEST, NEW_CLIENT, DONE, IDLE_TIMEOUT
SERVER_EXIT, SERVER_ERROR, SERVER_SHUTDOWN, DETACH_REQUEST, NEW_CLIENT, DONE, IDLE_TIMEOUT, SESSION_BUSY
from xpra.net.bytestreams import set_socket_timeout
from xpra.platform import get_username
from xpra.platform.paths import get_icon_filename
Expand Down Expand Up @@ -1045,6 +1045,9 @@ def hello_oked(self, proto, packet, c, auth_caps):
if ServerCore.hello_oked(self, proto, packet, c, auth_caps):
#has been handled
return
if not c.boolget("steal", True) and self._server_sources:
self.disconnect_client(proto, SESSION_BUSY, "this session is already active")
return
if c.boolget("screenshot_request"):
self.send_screenshot(proto)
return
Expand Down
1 change: 1 addition & 0 deletions src/xpra/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
DETACH_REQUEST = "detach request"
NEW_CLIENT = "new client"
IDLE_TIMEOUT = "idle timeout"
SESSION_BUSY = "session busy"
#client telling the server:
CLIENT_EXIT = "client exit"

Expand Down

0 comments on commit de7d884

Please sign in to comment.