diff --git a/lib/Vroom/I18N/en.pm b/lib/Vroom/I18N/en.pm index 494cd3e..99107d4 100644 --- a/lib/Vroom/I18N/en.pm +++ b/lib/Vroom/I18N/en.pm @@ -32,7 +32,11 @@ our %Lexicon = ( "FROM" => "From", "GIVE_US_YOUR_FEEDBACK" => "Give us your feedback", "YOUR_FEEDBACK_HELPS_US" => "Your feedback (good or bad) can help us improve this application", + "ROOM_LOCKED" => "This room is now locked", + "ROOM_UNLOCKED" => "This room is now unlocked", "ONE_OF_THE_PEERS" => "one of the peers", + "ROOM_LOCKED_BY_s" => "%s locked the room", + "ROOM_UNLOCKED_BY_s" => "%s unlocked the room", "PASSWORD_PROTECT_ON_BY_s" => "%s password protected the room", "PASSWORD_PROTECT_OFF_BY_s" => "%s removed password protection", "OWNER_PASSWORD_CHANGED_BY_s" => "%s changed the room manager password", diff --git a/lib/Vroom/I18N/fr.pm b/lib/Vroom/I18N/fr.pm index 4e1c037..255f85f 100644 --- a/lib/Vroom/I18N/fr.pm +++ b/lib/Vroom/I18N/fr.pm @@ -35,7 +35,11 @@ our %Lexicon = ( "GIVE_US_YOUR_FEEDBACK" => "Parlez-nous de votre expérience", "YOUR_FEEDBACK_HELPS_US" => "Votre retour d'expérience (bonne ou mauvaise) peut nous aider à améliorer cette application", "INVITE_SENT_TO_s" => "Une invitation a été envoyée à %s", + "ROOM_LOCKED" => "Ce salon est maintenant verrouillé", + "ROOM_UNLOCKED" => "Ce salon est maintenant déverrouillé", "ONE_OF_THE_PEERS" => "un des participants", + "ROOM_LOCKED_BY_s" => "%s a verrouillé le salon", + "ROOM_UNLOCKED_BY_s" => "%s a déverrouillé le salon", "PASSWORD_PROTECT_ON_BY_s" => "%s a protégé le salon par un mot de passe", "PASSWORD_PROTECT_OFF_BY_s" => "%s a supprimé la protection par mot de passe", "OWNER_PASSWORD_CHANGED_BY_s" => "%s a modifié le mot de passe du gestionnaire du salon", diff --git a/public/js/vroom.js b/public/js/vroom.js index ec9f0fa..6fac860 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -25,6 +25,8 @@ var locale = { CAM_RESUMED: '', SET_YOUR_NAME_TO_CHAT: '', ONE_OF_THE_PEERS: '', + ROOM_LOCKED_BY_s: '', + ROOM_UNLOCKED_BY_s: '', PASSWORD_PROTECT_ON_BY_s: '', PASSWORD_PROTECT_OFF_BY_s: '', OWNER_PASSWORD_CHANGED_BY_s: '', @@ -446,7 +448,15 @@ function initVroom(room) { $(el).remove(); }); - // A few notif on password set/unset + // A few notif on password set/unset or lock/unlock + webrtc.on('room_locked', function(data){ + $('#lockLabel').addClass('btn-danger active'); + $.notify(sprintf(locale.ROOM_LOCKED_BY_s, stringEscape(peers[data.id].displayName)), 'info'); + }); + webrtc.on('room_unlocked', function(data){ + $('#lockLabel').removeClass('btn-danger active'); + $.notify(sprintf(locale.ROOM_UNLOCKED_BY_s, stringEscape(peers[data.id].displayName)), 'info'); + }); webrtc.on('password_protect_on', function(data){ $.notify(sprintf(locale.PASSWORD_PROTECT_ON_BY_s, stringEscape(peers[data.id].displayName)), 'info'); }); @@ -561,6 +571,32 @@ function initVroom(room) { webrtc.sendDirectlyToAll('vroom', 'setDisplayName', $('#displayName').val()); }); + // Handle room lock/unlock + $('#lockButton').change(function() { + var action = ($(this).is(":checked")) ? 'lock':'unlock'; + $.ajax({ + data: { + action: action, + room: roomName + }, + error: function(data) { + var msg = (data && data.msg) ? data.msg : locale.ERROR_OCCURED; + $.notify(msg, 'error'); + }, + success: function(data) { + $.notify(data.msg, 'info'); + if (action === 'lock'){ + $("#lockLabel").addClass('btn-danger'); + webrtc.sendToAll('room_locked', {}); + } + else{ + $("#lockLabel").removeClass('btn-danger'); + webrtc.sendToAll('room_unlocked', {}); + } + } + }); + }); + // ScreenSharing $('#shareScreenButton').change(function() { var action = ($(this).is(":checked")) ? 'share':'unshare'; diff --git a/public/vroom.pl b/public/vroom.pl index 4524a80..23343a8 100755 --- a/public/vroom.pl +++ b/public/vroom.pl @@ -451,7 +451,8 @@ get '/(*room)' => sub { room => $room ); } - $self->stash(turnPassword => $data->{token}); + $self->stash(locked => $data->{locked} ? 'checked':'', + turnPassword => $data->{token}); $self->render('join'); }; @@ -504,6 +505,32 @@ post '/action' => sub { } ); } + if ($action =~ m/(un)?lock/){ + my ($lock,$success); + if ($action eq 'lock'){ + $lock = 1; + $success = $self->l('ROOM_LOCKED'); + } + else{ + $lock = 0; + $success = $self->l('ROOM_UNLOCKED'); + } + my $room = $self->param('room'); + my $res = $self->lock_room($room,$lock); + unless ($res){ + return $self->render( + json => { + msg => $self->l('ERROR_OCCURED'), + }, + status => '500' + ); + } + return $self->render( + json => { + msg => $success, + } + ); + } elsif ($action eq 'ping'){ my $res = $self->ping_room($room); # Cleanup expired rooms every ~10 pings diff --git a/templates/default/join.html.ep b/templates/default/join.html.ep index 905f738..c5694d1 100644 --- a/templates/default/join.html.ep +++ b/templates/default/join.html.ep @@ -159,6 +159,22 @@ +
  • +
  • +
  • + +