Improves password required interface and disables the padlock for participants.
This commit is contained in:
parent
d7be5c0667
commit
9c0e924b13
130
app.js
130
app.js
|
@ -188,6 +188,9 @@ $(document).bind('entered.muc', function (event, jid, info) {
|
|||
focus.addNewParticipant(jid);
|
||||
}
|
||||
}
|
||||
else if (sharedKey) {
|
||||
updateLockButton();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).bind('left.muc', function (event, jid) {
|
||||
|
@ -208,6 +211,33 @@ $(document).bind('left.muc', function (event, jid) {
|
|||
}
|
||||
});
|
||||
|
||||
$(document).bind('passwordrequired.muc', function (event, jid) {
|
||||
console.log('on password required', jid);
|
||||
|
||||
$.prompt('<h2>Password required</h2>' +
|
||||
'<input id="lockKey" type="text" placeholder="shared key" autofocus>',
|
||||
{
|
||||
persistent: true,
|
||||
buttons: { "Ok": true , "Cancel": false},
|
||||
defaultButton: 1,
|
||||
loaded: function(event) {
|
||||
document.getElementById('lockKey').focus();
|
||||
},
|
||||
submit: function(e,v,m,f){
|
||||
if(v)
|
||||
{
|
||||
var lockKey = document.getElementById('lockKey');
|
||||
|
||||
if (lockKey.value != null)
|
||||
{
|
||||
setSharedKey(lockKey);
|
||||
connection.emuc.doJoin(jid, lockKey.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function toggleVideo() {
|
||||
if (!(connection && connection.jingle.localStream)) return;
|
||||
for (var idx = 0; idx < connection.jingle.localStream.getVideoTracks().length; idx++) {
|
||||
|
@ -357,44 +387,62 @@ function buttonClick(id, classname) {
|
|||
* Opens the lock room dialog.
|
||||
*/
|
||||
function openLockDialog() {
|
||||
if (sharedKey)
|
||||
$.prompt("Are you sure you would like to remove your secret key?",
|
||||
{
|
||||
title: "Remove secrect key",
|
||||
persistent: false,
|
||||
buttons: { "Remove": true, "Cancel": false},
|
||||
defaultButton: 1,
|
||||
submit: function(e,v,m,f){
|
||||
if(v)
|
||||
{
|
||||
sharedKey = '';
|
||||
lockRoom();
|
||||
}
|
||||
}
|
||||
});
|
||||
else
|
||||
$.prompt('<h2>Set a secrect key to lock your room</h2>' +
|
||||
'<input id="lockKey" type="text" placeholder="your shared key" autofocus>',
|
||||
{
|
||||
persistent: false,
|
||||
buttons: { "Save": true , "Cancel": false},
|
||||
defaultButton: 1,
|
||||
loaded: function(event) {
|
||||
document.getElementById('lockKey').focus();
|
||||
},
|
||||
submit: function(e,v,m,f){
|
||||
if(v)
|
||||
{
|
||||
var lockKey = document.getElementById('lockKey');
|
||||
|
||||
if (lockKey.value != null)
|
||||
{
|
||||
sharedKey = lockKey.value;
|
||||
// Only the focus is able to set a shared key.
|
||||
if (focus == null) {
|
||||
if (sharedKey)
|
||||
$.prompt("This conversation is currently protected by a shared secret key.",
|
||||
{
|
||||
title: "Secrect key",
|
||||
persistent: false
|
||||
});
|
||||
else
|
||||
$.prompt("This conversation isn't currently protected by a secret key. Only the owner of the conference could set a shared key.",
|
||||
{
|
||||
title: "Secrect key",
|
||||
persistent: false
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (sharedKey)
|
||||
$.prompt("Are you sure you would like to remove your secret key?",
|
||||
{
|
||||
title: "Remove secrect key",
|
||||
persistent: false,
|
||||
buttons: { "Remove": true, "Cancel": false},
|
||||
defaultButton: 1,
|
||||
submit: function(e,v,m,f){
|
||||
if(v)
|
||||
{
|
||||
setSharedKey('');
|
||||
lockRoom();
|
||||
}
|
||||
}
|
||||
});
|
||||
else
|
||||
$.prompt('<h2>Set a secrect key to lock your room</h2>' +
|
||||
'<input id="lockKey" type="text" placeholder="your shared key" autofocus>',
|
||||
{
|
||||
persistent: false,
|
||||
buttons: { "Save": true , "Cancel": false},
|
||||
defaultButton: 1,
|
||||
loaded: function(event) {
|
||||
document.getElementById('lockKey').focus();
|
||||
},
|
||||
submit: function(e,v,m,f){
|
||||
if(v)
|
||||
{
|
||||
var lockKey = document.getElementById('lockKey');
|
||||
|
||||
if (lockKey.value)
|
||||
{
|
||||
console.log("LOCK KEY", lockKey.value);
|
||||
setSharedKey(lockKey.value);
|
||||
lockRoom(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -418,6 +466,20 @@ function openLinkDialog() {
|
|||
function lockRoom(lock) {
|
||||
connection.emuc.lockRoom(sharedKey);
|
||||
|
||||
updateLockButton();
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the shared key.
|
||||
*/
|
||||
function setSharedKey(sKey) {
|
||||
sharedKey = sKey;
|
||||
}
|
||||
|
||||
/*
|
||||
* Updates the lock button state.
|
||||
*/
|
||||
function updateLockButton() {
|
||||
buttonClick("#lockIcon", "fa fa-unlock fa-lg fa fa-lock fa-lg");
|
||||
}
|
||||
|
||||
|
|
12
muc.js
12
muc.js
|
@ -75,18 +75,6 @@ Strophe.addConnectionPlugin('emuc', {
|
|||
var from = pres.getAttribute('from');
|
||||
if ($(pres).find('>error[type="auth"]>not-authorized[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
|
||||
$(document).trigger('passwordrequired.muc', [from]);
|
||||
|
||||
// FIXME: remove once moved to passwordrequired which should reuse dojoin
|
||||
var ob = this;
|
||||
window.setTimeout(function () {
|
||||
var given = window.prompt('Password required');
|
||||
if (given != null) {
|
||||
// FIXME: reuse doJoin?
|
||||
ob.connection.send($pres({to: ob.myroomjid }).c('x', {xmlns: 'http://jabber.org/protocol/muc'}).c('password').t(given));
|
||||
} else {
|
||||
// user aborted
|
||||
}
|
||||
}, 50);
|
||||
} else {
|
||||
console.warn('onPresError ', pres);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue