Refactoring guest

This commit is contained in:
Hugo Lazzari 2013-07-17 11:01:04 -03:00
parent 7c39c15209
commit a68635561d
9 changed files with 230 additions and 60 deletions

View File

@ -0,0 +1,36 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2010 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.main.events
{
import flash.events.Event;
public class AddGuestEvent extends Event
{
public static const ADD_GUEST:String = "AddGuest";
public var userid:Number;
public var name:String;
public function AddGuestEvent(type:String = ADD_GUEST)
{
super(type, true, false);
}
}
}

View File

@ -0,0 +1,35 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2010 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.main.events
{
import flash.events.Event;
public class RefreshGuestEvent extends Event
{
public static const REFRESH_GUEST_VIEW:String = "RefreshGuestView";
public listOfGuests:Object;
public function RefreshGuestEvent(type:String = REFRESH_GUEST_VIEW)
{
super(type, true, false);
}
}
}

View File

@ -0,0 +1,35 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2010 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.main.events
{
import flash.events.Event;
public class RemoveGuestEvent extends Event
{
public static const REMOVE_GUEST:String = "RemoveGuest";
public static const REMOVE_ALL:String = "RemoveAllGuests";
public var userid:Number;
public function RemoveGuestEvent(type:String = REMOVE_GUEST)
{
super(type, true, false);
}
}
}

View File

@ -31,6 +31,7 @@
<ObjectBuilder generator="{ModulesProxy}" cache="global" /> <ObjectBuilder generator="{ModulesProxy}" cache="global" />
<ObjectBuilder generator="{UserService}" cache="global" /> <ObjectBuilder generator="{UserService}" cache="global" />
<ObjectBuilder generator="{ConfigManager}" cache="global" /> <ObjectBuilder generator="{ConfigManager}" cache="global" />
<ObjectBuilder generator="{GuestManager}" cache="global" />
</EventHandlers> </EventHandlers>
<EventHandlers type="{PortTestEvent.TEST_RTMP}" > <EventHandlers type="{PortTestEvent.TEST_RTMP}" >
@ -38,7 +39,13 @@
</EventHandlers> </EventHandlers>
<EventHandlers type="{AddGuestEvent.ADD_GUEST}" >
<MethodInvoker generator="{GuestManager}" method="addNewGuest" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{ResponseModeratorEvent.RESPONSE}" >
<MethodInvoker generator="{GuestManager}" method="removeGuest" arguments="{event.userid}" />
</EventHandlers>
<EventHandlers type="{PortTestEvent.PORT_TEST_SUCCESS}" > <EventHandlers type="{PortTestEvent.PORT_TEST_SUCCESS}" >
@ -161,6 +168,7 @@
import org.bigbluebutton.main.events.PortTestEvent; import org.bigbluebutton.main.events.PortTestEvent;
import org.bigbluebutton.main.events.SuccessfulLoginEvent; import org.bigbluebutton.main.events.SuccessfulLoginEvent;
import org.bigbluebutton.main.events.UserServicesEvent; import org.bigbluebutton.main.events.UserServicesEvent;
import org.bigbluebutton.main.model.GuestManager;
import org.bigbluebutton.main.model.PortTestProxy; import org.bigbluebutton.main.model.PortTestProxy;
import org.bigbluebutton.main.model.modules.ModulesProxy; import org.bigbluebutton.main.model.modules.ModulesProxy;
import org.bigbluebutton.main.model.users.UserService; import org.bigbluebutton.main.model.users.UserService;
@ -173,6 +181,8 @@
import org.bigbluebutton.main.model.users.events.UsersConnectionEvent; import org.bigbluebutton.main.model.users.events.UsersConnectionEvent;
import org.bigbluebutton.main.events.WaitModeratorEvent; import org.bigbluebutton.main.events.WaitModeratorEvent;
import org.bigbluebutton.main.events.ResponseModeratorEvent; import org.bigbluebutton.main.events.ResponseModeratorEvent;
import org.bigbluebutton.main.events.AddGuestEvent;
import org.bigbluebutton.main.events.ResponseModeratorEvent;
]]> ]]>
</mx:Script> </mx:Script>

View File

@ -20,19 +20,12 @@
package org.bigbluebutton.main.model package org.bigbluebutton.main.model
{ {
import com.asfusion.mate.events.Dispatcher;
public class Guest public class Guest
{ {
private var listOfGuests:Object = new Object(); private var listOfGuests:Object = new Object();
private var numberOfGuests = 0; private var numberOfGuests = 0;
private var dispatcher; private var dispatcher;
function Guest(dispatcher:Dispatcher) {
this.dispatcher = dispatcher;
}
public function hasGuest():Boolean { public function hasGuest():Boolean {
return numberOfGuests > 0; return numberOfGuests > 0;
} }
@ -47,6 +40,10 @@ package org.bigbluebutton.main.model
numberOfGuests++; numberOfGuests++;
} }
public function getGuests():Object {
return this.listOfGuests;
}
public function removeAllGuests():void { public function removeAllGuests():void {
listOfGuests = new Object(); listOfGuests = new Object();
numberOfGuests = 0; numberOfGuests = 0;

View File

@ -0,0 +1,62 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2013 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
* author:
*/
package org.bigbluebutton.main.model
{
import com.asfusion.mate.events.Dispatcher;
import org.bigbluebutton.main.events.RefreshGuestEvent;
import org.bigbluebutton.main.events.AddGuestEvent;
public class GuestManager
{
private var guest:Guest;
function GuestManager(dispatcher:Dispatcher) {
this.dispatcher = new Dispatcher();
this.guest = new Guest();
}
public function addGuest(evt:AddGuestEvent):void {
guest.addGuest(evt.userid, evt.name);
refreshGuestView();
}
private function refreshGuestView():void {
var refreshGuestEvent:RefreshGuestEvent = new RefreshGuestEvent();
refreshGuestEvent.listOfGuests = guest.getGuests();
dispatcher.dispatchEvent(refreshGuestEvent);
}
public function removeAllGuests():void {
guest.removeAllGuests();
}
private function removeGuetFromView(userid:Number):void {
var removeGuestFromViewEvent:RemoveGuestFromViewEvent = new RemoveGuestFromViewEvent();
removeGuestFromViewEvent.userid = userid;
dispatcher.dispatchEvent(removeGuestFromViewEvent);
}
public function removeGuest(userid:Number):void {
guest.remove(userid);
removeGuetFromView(userid);
}
}
}

View File

@ -32,7 +32,7 @@ package org.bigbluebutton.main.model.users {
import org.bigbluebutton.main.events.MadePresenterEvent; import org.bigbluebutton.main.events.MadePresenterEvent;
import org.bigbluebutton.main.events.ParticipantJoinEvent; import org.bigbluebutton.main.events.ParticipantJoinEvent;
import org.bigbluebutton.main.events.PresenterStatusEvent; import org.bigbluebutton.main.events.PresenterStatusEvent;
import org.bigbluebutton.main.events.NewGuestEvent; import org.bigbluebutton.main.events.AddGuestEvent;
import org.bigbluebutton.main.events.RemoveGuestRequestEvent; import org.bigbluebutton.main.events.RemoveGuestRequestEvent;
import org.bigbluebutton.main.events.ModeratorRespEvent; import org.bigbluebutton.main.events.ModeratorRespEvent;
import org.bigbluebutton.main.model.ConferenceParameters; import org.bigbluebutton.main.model.ConferenceParameters;
@ -288,7 +288,7 @@ package org.bigbluebutton.main.model.users {
//Callback from server //Callback from server
public function guestEntrance(userid:Number, name:String):void { public function guestEntrance(userid:Number, name:String):void {
if(UserManager.getInstance().getConference().amIModerator() && UserManager.getInstance().getConference().amIWaitForModerator() == false) { if(UserManager.getInstance().getConference().amIModerator() && UserManager.getInstance().getConference().amIWaitForModerator() == false) {
var e:NewGuestEvent = new NewGuestEvent(NewGuestEvent.NEW_GUEST_EVENT); var e:AddGuestEvent = new AddGuestEvent();
e.userid = userid; e.userid = userid;
e.name = name; e.name = name;
var dispatcher:Dispatcher = new Dispatcher(); var dispatcher:Dispatcher = new Dispatcher();

View File

@ -37,17 +37,16 @@
import org.bigbluebutton.common.Images; import org.bigbluebutton.common.Images;
import org.bigbluebutton.core.BBB; import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.managers.UserManager; import org.bigbluebutton.core.managers.UserManager;
import org.bigbluebutton.main.events.ResponseModeratorEvent;
import org.bigbluebutton.main.events.ModuleLoadEvent; import org.bigbluebutton.main.events.ModuleLoadEvent;
import org.bigbluebutton.main.events.RemoveGuestEvent;
import org.bigbluebutton.util.i18n.ResourceUtil; import org.bigbluebutton.util.i18n.ResourceUtil;
import mx.containers.HBox; import mx.containers.HBox;
import mx.controls.Button; import mx.controls.Button;
import mx.controls.Spacer; import mx.controls.Spacer;
import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.main.events.BBBEvent;
private var guestWindowMap:Object = new Object();
private var guestButtons:Object = new Object(); private var guestButtons:Object = new Object();
[Bindable] private var numberOfGuests:Number = 0; private var numberOfGuests:Number = 0;
private var dispatcher:Dispatcher = new Dispatcher(); private var dispatcher:Dispatcher = new Dispatcher();
public function init():void { public function init():void {
@ -55,19 +54,20 @@
//this.isPopUp = false; //this.isPopUp = false;
} }
public function addGuest(userid:Number, username:String):void { public refreshGuestView(listOfGuests:Object):void {
numberOfGuests++; for (var key:String in listOfGuests) {
guestWindowMap[userid] = username; var userid:Number = new Number(key);
if(guestButtons[userid] == null) {
var guestItem:GuestItem = new GuestItem(); var guestItem:GuestItem = new GuestItem();
guestItem.setUser(username, userid); guestItem.setUser(username, userid);
guestListBox.addChild(guestItem); guestListBox.addChild(guestItem);
guestButtons[userid] = guestItem; guestButtons[userid] = guestItem;
numberOfGuests++;
// ideally we would like to control if the view is displayed or not adding or removing the popup, not using the visible property }
}
this.visible = true; this.visible = true;
} }
public function sendResponseToAllGuests(resp:Boolean):void { public function sendResponseToAllGuests(resp:Boolean):void {
removeAllGuests(); removeAllGuests();
var respCommand:ResponseModeratorEvent = new ResponseModeratorEvent(ResponseModeratorEvent.RESPONSE_ALL); var respCommand:ResponseModeratorEvent = new ResponseModeratorEvent(ResponseModeratorEvent.RESPONSE_ALL);
@ -83,7 +83,7 @@
} else { } else {
event.payload['guestPolicy'] = "ALWAYS_DENY"; event.payload['guestPolicy'] = "ALWAYS_DENY";
} }
dispatchEvent(event); dispatcher.dispatchEvent(event);
} }
sendResponseToAllGuests(resp); sendResponseToAllGuests(resp);
} }
@ -97,27 +97,23 @@
} }
public function removeAllGuests():void { public function removeAllGuests():void {
numberOfGuests = 0; var removeGuestEvent:RemoveGuestEvent = new RemoveGuestEvent(RemoveGuestEvent.REMOVE_ALL):
dispatcher.dispatchEvent(removeGuestEvent);
for (var key:String in guestWindowMap) { closeWindow();
var userid:Number = new Number(key);
guestListBox.removeChild(guestButtons[userid]);
}
guestWindowMap = new Object();
guestButtons = new Object();
close();
} }
public function remove(userid:Number):void { public function remove(userid:Number):void {
if (guestWindowMap[userid] != null) { if (guestButtons[userid] != null) {
numberOfGuests--;
delete guestWindowMap[userid];
guestListBox.removeChild(guestButtons[userid]); guestListBox.removeChild(guestButtons[userid]);
delete guestButtons[userid]; delete guestButtons[userid];
var removeGuestEvent:RemoveGuestEvent = new RemoveGuestEvent():
removeGuestEvent.userid = userid;
dispatcher.dispatchEvent(removeGuestEvent);
if (!hasGuest()) { if (!hasGuest()) {
close(); closeWindow();
} }
} }
} }
@ -126,14 +122,10 @@
return numberOfGuests > 0; return numberOfGuests > 0;
} }
public function removeAll():void { public function closeWindow():void {
close();
PopUpManager.removePopUp(this);
}
public function close():void {
rememberCheckBox.selected = false;
this.visible = false; this.visible = false;
PopUpManager.removePopUp(this);
close();
} }
private function onModeratorResponse(event:ResponseModeratorEvent):void { private function onModeratorResponse(event:ResponseModeratorEvent):void {

View File

@ -45,15 +45,16 @@
<mate:Listener type="{RemoveGuestRequestEvent.GUEST_EVENT}" method="removeGuestWindow" /> <mate:Listener type="{RemoveGuestRequestEvent.GUEST_EVENT}" method="removeGuestWindow" />
<mate:Listener type="SHOW_MIC_SETTINGS" method="showMicSettings" /> <mate:Listener type="SHOW_MIC_SETTINGS" method="showMicSettings" />
<mate:Listener type="SHOW_BBB_SETTINGS" method="showBBBSettings" /> <mate:Listener type="SHOW_BBB_SETTINGS" method="showBBBSettings" />
<mate:Listener type="{NewGuestEvent.NEW_GUEST_EVENT}" method="addNewGuest" />
<mate:Listener type="{ModeratorRespEvent.GUEST_ALLOWED}" method="guestAllowed" /> <mate:Listener type="{ModeratorRespEvent.GUEST_ALLOWED}" method="guestAllowed" />
<mate:Listener type="{BBBEvent.RETRIEVE_GUEST_POLICY}" method="setGuestPolicy"/> <mate:Listener type="{BBBEvent.RETRIEVE_GUEST_POLICY}" method="setGuestPolicy"/>
<mate:Listener type="{RefreshGuestEvent}" method="refreshGuestView"
<mx:Script> <mx:Script>
<![CDATA[ <![CDATA[
import com.asfusion.mate.events.Dispatcher; import com.asfusion.mate.events.Dispatcher;
import flash.events.MouseEvent; import flash.events.MouseEvent;
import flash.events.Event;
import flexlib.mdi.containers.MDIWindow; import flexlib.mdi.containers.MDIWindow;
import flexlib.mdi.effects.effectsLib.MDIVistaEffects; import flexlib.mdi.effects.effectsLib.MDIVistaEffects;
@ -82,12 +83,12 @@
import org.bigbluebutton.main.events.PortTestEvent; import org.bigbluebutton.main.events.PortTestEvent;
import org.bigbluebutton.main.events.RecordStatusEvent; import org.bigbluebutton.main.events.RecordStatusEvent;
import org.bigbluebutton.main.events.WaitModeratorEvent; import org.bigbluebutton.main.events.WaitModeratorEvent;
import org.bigbluebutton.main.events.NewGuestEvent;
import org.bigbluebutton.main.events.RemoveGuestRequestEvent; import org.bigbluebutton.main.events.RemoveGuestRequestEvent;
import org.bigbluebutton.main.events.ModeratorRespEvent; import org.bigbluebutton.main.events.ModeratorRespEvent;
import org.bigbluebutton.main.model.LayoutOptions; import org.bigbluebutton.main.model.LayoutOptions;
import org.bigbluebutton.main.model.users.events.ConnectionFailedEvent; import org.bigbluebutton.main.model.users.events.ConnectionFailedEvent;
import org.bigbluebutton.main.model.Guest; import org.bigbluebutton.main.model.Guest;
import org.bigbluebutton.main.events.RefreshGuestEvent;
import org.bigbluebutton.util.i18n.ResourceUtil; import org.bigbluebutton.util.i18n.ResourceUtil;
import org.bigbluebutton.util.logging.Logger; import org.bigbluebutton.util.logging.Logger;
import org.bigbluebutton.common.events.SettingsComponentEvent; import org.bigbluebutton.common.events.SettingsComponentEvent;
@ -144,15 +145,12 @@
} }
private function setGuestPolicy(event:BBBEvent):void { private function setGuestPolicy(event:BBBEvent):void {
LogUtil.debug("INICIALIZANDO GUEST_POLICY " + event.payload.guestPolicy);
guestPolicy = event.payload.guestPolicy; guestPolicy = event.payload.guestPolicy;
if(guestManagement == null) { if(guestManagement == null) {
LogUtil.debug("ADD Guest Event"); LogUtil.debug("ADD Guest Event");
guestManagement = new GuestManagement(); guestManagement = new GuestManagement();
guestManagement.setGuestPolicy(guestPolicy); guestManagement.setGuestPolicy(guestPolicy);
guestManagement.addToSettings(); guestManagement.addToSettings();
//Add event to init bbbsettings
} }
} }
@ -212,17 +210,22 @@
/* Do something specific here if we switched to normal mode. */ /* Do something specific here if we switched to normal mode. */
} }
} }
private function addNewGuest(evt:NewGuestEvent):void { private function closeGuestWindow(e:Event) {
guest.addGuest(evt.userid, evt.name); LogUtil.debug("CLOSE GUEST WINDOW");
//if(guestWindow == null) { guestWindow = null;
// guestWindow = PopUpManager.createPopUp( mdiCanvas, GuestWindow, false) as GuestWindow;
// guestWindow.x = width - 400;
// guestWindow.y = 20;
//}
//guestWindow.addGuest(evt.userid, evt.name);
} }
private function refreshGuestView(evt:RefreshGuestEvent):void {
if(guestWindow == null) {
guestWindow = PopUpManager.createPopUp( mdiCanvas, GuestWindow, false) as GuestWindow;
guestWindow.addEventListener(Event.CLOSE, closeGuestWindow);
guestWindow.x = width - 400;
guestWindow.y = 20;
}
guestWindow.refreshGuestView(evt.listOfGuests);
}
public function removeGuestWindow(evt:RemoveGuestRequestEvent):void { public function removeGuestWindow(evt:RemoveGuestRequestEvent):void {
if(guestWindow != null) if(guestWindow != null)
guestWindow.remove(evt.userid); guestWindow.remove(evt.userid);