Merge branch 'pods_vol4' of https://github.com/antobinary/bigbluebutton into antobinary-pods_vol4

This commit is contained in:
Richard Alam 2017-10-27 17:16:57 -07:00
commit 519da9033d
10 changed files with 183 additions and 74 deletions

View File

@ -3,6 +3,7 @@ package org.bigbluebutton.core.apps.presentationpod
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.bus.MessageBus
import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.models.PresentationPod
import org.bigbluebutton.core.running.LiveMeeting
trait CreateNewPresentationPodPubMsgHdlr {
@ -23,21 +24,28 @@ trait CreateNewPresentationPodPubMsgHdlr {
}
val ownerId = msg.body.ownerId
val pod = if (state.presentationPodManager.getNumberOfPods() == 0) {
PresentationPodsApp.createDefaultPresentationPod(ownerId)
} else {
PresentationPodsApp.createPresentationPod(ownerId)
val resultPod: PresentationPod = PresentationPodsApp.getPresentationPod(state, "DEFAULT_PRESENTATION_POD") match {
case None => PresentationPodsApp.createDefaultPresentationPod(ownerId)
case Some(pod) => {
if (pod.ownerId == "") {
PresentationPodsApp.changeOwnershipOfDefaultPod(state, ownerId).get
} else {
PresentationPodsApp.createPresentationPod(ownerId)
}
}
}
val respMsg = buildCreateNewPresentationPodEvtMsg(
liveMeeting.props.meetingProp.intId,
ownerId, pod.id
ownerId, resultPod.id
)
bus.outGW.send(respMsg)
val pods = state.presentationPodManager.addPod(pod)
val pods = state.presentationPodManager.addPod(resultPod)
log.warning("_____ pres pod add, after:" + pods.getNumberOfPods())
log.warning("_____ CreateNewPresentationPodPubMsgHdlr _" + pods.printPods())
state.update(pods)

View File

@ -49,7 +49,12 @@ trait PresentationConversionCompletedSysPubMsgHdlr {
} yield {
broadcastPresentationConversionCompletedEvtMsg(pod.id, msg.header.userId, msg.body.messageKey, msg.body.code, presVO)
val pods = state.presentationPodManager.addPresentationToPod(pod.id, pres)
var pods = state.presentationPodManager.addPod(pod)
pods = pods.addPresentationToPod(pod.id, pres)
pods = pods.setCurrentPresentation(pod.id, pres.id)
log.warning("_____PresentationConversionCompletedSysPubMsgHdlr_ " + pods.printPods())
state.update(pods)
}

View File

@ -14,11 +14,11 @@ object PresentationPodsApp {
PresentationPodFactory.createDefaultPod(ownerId)
}
// def createDefaultPresentationPod(state: MeetingState2x): MeetingState2x = {
// val defaultPresPod = PresentationPodFactory.create("the-owner-id")
// val podManager = state.presentationPodManager.addPod(defaultPresPod)
// state.update(podManager)
// }
// def createDefaultPresentationPod(state: MeetingState2x): MeetingState2x = {
// val defaultPresPod = PresentationPodFactory.create("the-owner-id")
// val podManager = state.presentationPodManager.addPod(defaultPresPod)
// state.update(podManager)
// }
def removePresentationPod(state: MeetingState2x, podId: String): MeetingState2x = {
val podManager = state.presentationPodManager.removePod(podId)
@ -26,7 +26,13 @@ object PresentationPodsApp {
}
def getPresentationPod(state: MeetingState2x, podId: String): Option[PresentationPod] = {
state.presentationPodManager.getPod(podId)
if (getNumberOfPresentationPods(state) == 0) {
val defPod = createDefaultPresentationPod("") // ownerId is to be assigned later
state.presentationPodManager.addPod(defPod)
Some(defPod)
} else {
state.presentationPodManager.getPod(podId)
}
}
def getAllPresentationPodsInMeeting(state: MeetingState2x): Vector[PresentationPod] = {
@ -52,5 +58,23 @@ object PresentationPodsApp {
PresentationVO(pres.id, pres.name, pres.current, pres.pages.values.toVector, pres.downloadable)
}
def setCurrentPresentationInPod(state: MeetingState2x, podId: String, nextCurrentPresId: String): Option[PresentationPod] = {
for {
pod <- getPresentationPod(state, podId)
updatedPod <- pod.setCurrentPresentation(nextCurrentPresId)
} yield {
updatedPod
}
}
// add ownerId to default presentation pod -- in some cases we add it before first user is available
def changeOwnershipOfDefaultPod(state: MeetingState2x, newOwnerId: String): Option[PresentationPod] = {
for {
defPod <- getPresentationPod(state, "DEFAULT_PRESENTATION_POD")
} yield {
println(s"\n\n\n changeOwnershipOfDefaultPod $newOwnerId \n\n\n")
defPod.copy(ownerId = newOwnerId)
}
}
}

View File

@ -28,20 +28,20 @@ trait SetCurrentPresentationPubMsgHdlr {
val presId = msg.body.presentationId
val newState = for {
pod <- PresentationPodsApp.getPresentationPod(state, podId)
// presentation <- setCurrentPresentation(liveMeeting, pod.id, presId)
updatedPod <- PresentationPodsApp.setCurrentPresentationInPod(state, podId, presId)
} yield {
// unset old current
PresentationPodsApp.getPresentationPod(state, podId)
// TODO
// set new current
// TODO
broadcastSetCurrentPresentationEvent(podId, msg.header.userId, presId)
log.warning("_____ SetCurrentPresentationPubMsgHdlr before_ " + state.presentationPodManager.printPods())
val pods = state.presentationPodManager.addPod(updatedPod)
log.warning("_____ SetCurrentPresentationPubMsgHdlr after_ " + pods.printPods())
state.update(pods)
}
newState match {
case Some(ns) => ns
case None => state
}
state
}
}

View File

@ -40,6 +40,7 @@ case class PresentationInPod(id: String, name: String, current: Boolean = false,
case class PresentationPod(id: String, ownerId: String, currentPresenter: String,
presentations: collection.immutable.Map[String, PresentationInPod]) {
def addPresentation(presentation: PresentationInPod): PresentationPod = {
println(s" 1 PresentationPods::addPresentation ${presentation.id} presName=${presentation.name} current=${presentation.current} ")
copy(presentations = presentations + (presentation.id -> presentation))
}
@ -52,22 +53,23 @@ case class PresentationPod(id: String, ownerId: String, currentPresenter: String
def getPresentation(presentationId: String): Option[PresentationInPod] =
presentations.values find (p => p.id == presentationId)
def setCurrentPresentation(presId: String): Option[PresentationInPod] = { // copy(currentPresenter = userId) // ****
def setCurrentPresentation(presId: String): Option[PresentationPod] = {
var tempPod: PresentationPod = this
presentations.values foreach (curPres => { // unset previous current presentation
if (curPres.id != presId) {
val newPres = curPres.copy(current = false)
addPresentation(newPres)
tempPod = tempPod.addPresentation(newPres)
}
})
presentations.get(presId) match { // set new current presentation
case Some(pres) =>
val cp = pres.copy(current = true)
addPresentation(cp)
Some(cp)
tempPod = tempPod.addPresentation(cp)
case None => None
}
Some(tempPod)
}
def setCurrentPage(presentationId: String, pageId: String): Option[PresentationPod] = {
@ -93,6 +95,13 @@ case class PresentationPod(id: String, ownerId: String, currentPresenter: String
def getPresentationsSize(): Int = {
presentations.values.size
}
def printPod(): String = {
val b = s"printPod (${presentations.values.size}):"
var d = ""
presentations.values.foreach(p => d += s"\nPRES_ID=${p.id} NAME=${p.name} CURRENT=${p.current}\n")
b.concat(s"PODID=$id OWNERID=$ownerId CURRENTPRESENTER=$currentPresenter PRESENTATIONS={{{$d}}}\n")
}
}
case class PresentationPodManager(presentationPods: collection.immutable.Map[String, PresentationPod]) {
@ -114,8 +123,28 @@ case class PresentationPodManager(presentationPods: collection.immutable.Map[Str
val updatedManager = for {
pod <- getPod(podId)
} yield {
val updatedPod = pod.addPresentation(pres)
updatePresentationPod(updatedPod)
updatePresentationPod(pod.addPresentation(pres))
}
updatedManager match {
case Some(ns) => ns
case None => this
}
}
def printPods(): String = {
var a = s"printPods (${presentationPods.values.size}):"
presentationPods.values.foreach(pod => a = a.concat(pod.printPod()))
a
}
def setCurrentPresentation(podId: String, presId: String): PresentationPodManager = {
val updatedManager = for {
pod <- getPod(podId)
podWithAdjustedCurrentPresentation <- pod.setCurrentPresentation(presId)
} yield {
updatePresentationPod(podWithAdjustedCurrentPresentation)
}
updatedManager match {

View File

@ -19,10 +19,10 @@
package org.bigbluebutton.modules.present.managers
{
import com.asfusion.mate.events.Dispatcher;
import flash.display.DisplayObject;
import flash.geom.Point;
import mx.core.FlexGlobals;
import mx.collections.ArrayCollection;
@ -32,12 +32,10 @@ package org.bigbluebutton.modules.present.managers
import org.bigbluebutton.common.events.CloseWindowEvent;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.PopUpUtil;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.modules.present.events.ExportEvent;
import org.bigbluebutton.modules.present.events.PresentModuleEvent;
import org.bigbluebutton.modules.present.events.UploadEvent;
import org.bigbluebutton.modules.present.events.NewPresentationPodCreated;
import org.bigbluebutton.modules.present.events.RequestNewPresentationPodEvent;
import org.bigbluebutton.modules.present.events.PresentationPodRemoved;
import org.bigbluebutton.modules.present.events.RequestAllPodsEvent;
import org.bigbluebutton.modules.present.events.GetAllPodsRespEvent;
@ -48,19 +46,17 @@ package org.bigbluebutton.modules.present.managers
import org.bigbluebutton.modules.present.ui.views.FileUploadWindow;
import org.bigbluebutton.modules.present.ui.views.PresentationWindow;
public class PresentManager
{
private var globalDispatcher:Dispatcher;
private var windows: Array = [];
private var podsManager: PresentationPodManager;
public function PresentManager() {
globalDispatcher = new Dispatcher();
podsManager = PresentationPodManager.getInstance();
}
public function handleStartModuleEvent(e:PresentModuleEvent):void{
if (windows.length >= 1) {
return;
@ -74,30 +70,37 @@ package org.bigbluebutton.modules.present.managers
var podId: String = e.podId;
var ownerId: String = e.ownerId;
if(!windows.hasOwnProperty(podId)) {
var newWindow:PresentationWindow = new PresentationWindow();
newWindow.onPodCreated(podId, ownerId);
var presentOptions:PresentOptions = Options.getOptions(PresentOptions) as PresentOptions;
newWindow.visible = true; // TODO
// newWindow.visible = presentOptions.showPresentWindow;
newWindow.showControls = presentOptions.showWindowControls;
windows[podId] = newWindow;
var openEvent:OpenWindowEvent = new OpenWindowEvent(OpenWindowEvent.OPEN_WINDOW_EVENT);
openEvent.window = newWindow;
globalDispatcher.dispatchEvent(openEvent);
podsManager.handleAddPresentationPod(podId, ownerId);
if(windows.hasOwnProperty(podId)) {
// remove pod and replace with the updated version
handlePresentationPodRemovedHelper(podId, ownerId);
}
var newWindow:PresentationWindow = new PresentationWindow();
newWindow.onPodCreated(podId, ownerId);
var presentOptions:PresentOptions = Options.getOptions(PresentOptions) as PresentOptions;
newWindow.visible = true; // TODO
// newWindow.visible = presentOptions.showPresentWindow;
newWindow.showControls = presentOptions.showWindowControls;
windows[podId] = newWindow;
var openEvent:OpenWindowEvent = new OpenWindowEvent(OpenWindowEvent.OPEN_WINDOW_EVENT);
openEvent.window = newWindow;
globalDispatcher.dispatchEvent(openEvent);
podsManager.handleAddPresentationPod(podId, ownerId);
}
public function handlePresentationPodRemoved(e: PresentationPodRemoved): void {
var podId: String = e.podId;
var ownerId: String = e.ownerId;
podsManager.handlePresentationPodRemoved(podId, ownerId); // GOOD
handlePresentationPodRemovedHelper(podId, ownerId);
}
private function handlePresentationPodRemovedHelper(podId: String, ownerId: String): void {
podsManager.handlePresentationPodRemoved(podId, ownerId);
var destroyWindow:PresentationWindow = windows[podId];
if (destroyWindow != null) {
@ -178,5 +181,8 @@ package org.bigbluebutton.modules.present.managers
PopUpUtil.removePopUp(FileExportWindow);
}
// public function handleSetPresenterInPodRespEvent(event: SetPresenterInPodRespEvent): void {
//
// }
}
}

View File

@ -5,6 +5,7 @@ package org.bigbluebutton.modules.present.model
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.modules.present.services.messages.PageChangeVO;
import org.bigbluebutton.main.api.JSLog;
public class PresentationModel
{
@ -30,6 +31,24 @@ package org.bigbluebutton.modules.present.model
_ownerId = ownerId;
}
private function whichPageIsCurrent(presId: String): String {
var result: String = "[";
var pres:Presentation = getPresentation(presId);
if (pres == null) {
} else {
var curPage: Page = pres.getCurrentPage();
result = result + curPage.num;
}
return result + "]";
}
public function printPresentations(calledFrom: String): void {
for (var i:int = 0; i < _presentations.length; i++) {
var pres: Presentation = _presentations.getItemAt(i) as Presentation;
JSLog.warn("2001 " + calledFrom +" " + i + " " + pres.name + " " + pres.id + " " + pres.current.toString() + " " + whichPageIsCurrent(pres.id) , {});
}
}
// /**
// * Return the single instance of the PresentationModel class
// */
@ -50,7 +69,9 @@ package org.bigbluebutton.modules.present.model
}
public function addPresentation(p: Presentation):void {
printPresentations("PresentationModel::addPresentation bef total=" + _presentations.length);
_presentations.addItem(p);
printPresentations("PresentationModel::addPresentation aft total=" + _presentations.length);
}
public function removePresentation(presId:String):Presentation {
@ -205,5 +226,3 @@ package org.bigbluebutton.modules.present.model
}
}
}
class SingletonEnforcer{}

View File

@ -3,17 +3,18 @@ package org.bigbluebutton.modules.present.model {
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.modules.present.services.messages.PageChangeVO;
import org.bigbluebutton.modules.present.services.messages.PresentationPodVO;
import org.bigbluebutton.modules.present.model.PresentationModel;
import org.bigbluebutton.modules.present.events.RequestNewPresentationPodEvent;
import com.asfusion.mate.events.Dispatcher;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.modules.present.services.PresentationService;
import org.bigbluebutton.modules.present.services.messages.PageChangeVO;
import org.bigbluebutton.modules.present.services.messages.PresentationPodVO;
import org.bigbluebutton.modules.present.services.messages.PresentationVO;
import org.bigbluebutton.modules.present.model.PresentationModel;
import org.bigbluebutton.modules.present.events.RequestNewPresentationPodEvent;
import org.bigbluebutton.modules.present.events.NewPresentationPodCreated;
import org.bigbluebutton.modules.present.events.PresentationPodRemoved;
import org.bigbluebutton.modules.present.events.RequestPresentationInfoPodEvent;
import org.bigbluebutton.main.api.JSLog;
public class PresentationPodManager {
@ -23,6 +24,7 @@ package org.bigbluebutton.modules.present.model {
private var _presentationPods: ArrayCollection = new ArrayCollection();
private var globalDispatcher:Dispatcher;
private var presentationService: PresentationService;
/**
@ -52,6 +54,10 @@ package org.bigbluebutton.modules.present.model {
return instance;
}
public function setPresentationService(service: PresentationService): void {
this.presentationService = service;
}
public function requestDefaultPresentationPod(): void {
var event:RequestNewPresentationPodEvent = new RequestNewPresentationPodEvent(RequestNewPresentationPodEvent.REQUEST_NEW_PRES_POD);
event.requesterId = UsersUtil.getMyUserID();
@ -83,7 +89,6 @@ package org.bigbluebutton.modules.present.model {
}
public function handlePresentationPodRemoved(podId: String, ownerId: String): void {
for (var i:int = 0; i < _presentationPods.length; i++) {
var pod: PresentationModel = _presentationPods.getItemAt(i) as PresentationModel;
@ -92,7 +97,6 @@ package org.bigbluebutton.modules.present.model {
return;
}
}
}
public function requestAllPodsPresentationInfo(): void {
@ -105,26 +109,34 @@ package org.bigbluebutton.modules.present.model {
}
}
public function handleGetAllPodsResp(podsAC: ArrayCollection): void {
// flush pod manager and add these pods instead
public function removeAllPresentationPods(): void {
for (var i:int = 0; i < _presentationPods.length; i++) {
var oldPod: PresentationModel = _presentationPods.getItemAt(i) as PresentationModel;
globalDispatcher.dispatchEvent(new PresentationPodRemoved(oldPod.getPodId(), oldPod.getOwnerId()));
// globalDispatcher.dispatchEvent(new PresentationPodRemoved(oldPod.getPodId(), oldPod.getOwnerId()));
}
}
public function handleGetAllPodsResp(podsAC: ArrayCollection): void {
// removeAllPresentationPods();
for (var j:int = 0; j < podsAC.length; j++) {
JSLog.warn("__ PresentationPodManager::handleGetAllPodsResp A: " , podsAC.length);
var podVO: PresentationPodVO = podsAC.getItemAt(j) as PresentationPodVO;
var newPod: PresentationModel = new PresentationModel(podVO.id, podVO.ownerId);
globalDispatcher.dispatchEvent(new NewPresentationPodCreated(newPod.getPodId(), newPod.getOwnerId()));
var presentationsToAdd:ArrayCollection = podVO.getPresentations();
presentationService.addPresentations(podVO.id, presentationsToAdd);
}
if (podsAC.length == 0) { // If there are no pods, request the creation of a default one
requestDefaultPresentationPod();
}
}
}
}

View File

@ -18,24 +18,24 @@ package org.bigbluebutton.modules.present.services
import org.bigbluebutton.modules.present.services.messages.PageVO;
import org.bigbluebutton.modules.present.services.messages.PresentationVO;
import org.bigbluebutton.modules.present.services.messaging.MessageReceiver;
import org.bigbluebutton.modules.present.services.messaging.MessageSender;
public class PresentationService
{
private static const LOGGER:ILogger = getClassLogger(PresentationService);
private static const NUM_PRELOAD:uint = 3;
private var podManager: PresentationPodManager;
private var sender:MessageSender;
private var receiver:MessageReceiver;
private var dispatcher:Dispatcher;
public function PresentationService() {
podManager = PresentationPodManager.getInstance();
podManager.setPresentationService(this);
receiver = new MessageReceiver(this);
dispatcher = new Dispatcher();
}
public function pageChanged(podId: String, pageId:String):void {
podManager.getPod(podId).printPresentations("PresentationService::pageChanged bef");
var np: Page = podManager.getPod(podId).getPage(pageId);
if (np != null) {
var oldPage: Page = podManager.getPod(podId).getCurrentPage();
@ -44,7 +44,8 @@ package org.bigbluebutton.modules.present.services
np.current = true;
// trace(LOG + "Sending page changed event. page [" + np.id + "] oldpage current=[" + oldPage.current + "] newPage current=[" + np.current + "]");
var changePageCommand: ChangePageCommand = new ChangePageCommand(podId, np.id, NUM_PRELOAD);
dispatcher.dispatchEvent(changePageCommand);
dispatcher.dispatchEvent(changePageCommand);
podManager.getPod(podId).printPresentations("PresentationService::pageChanged aft");
}
}
@ -83,7 +84,7 @@ package org.bigbluebutton.modules.present.services
LOGGER.debug("Added new presentation [{0}]", [presentation.id]);
if (presentation.current) {
LOGGER.debug("Making presentation [{0}] current [{1}]", [presentation.id, presentation.current]);
LOGGER.debug("Making presentation [{0}] current [{1}]", [presentation.id, presentation.current]);
var event: PresentationChangedEvent = new PresentationChangedEvent(podId, pres.id);
dispatcher.dispatchEvent(event);
@ -121,12 +122,15 @@ package org.bigbluebutton.modules.present.services
LOGGER.debug("No previous active presentation.");
}
podManager.getPod(podId).printPresentations("PresentationService::changeCurrentPresentation bef");
var newPres:Presentation = podManager.getPod(podId).getPresentation(presentationId);
if (newPres != null) {
LOGGER.debug("Making presentation [{0}] the active presentation.", [presentationId]);
newPres.current = true;
podManager.getPod(podId).printPresentations("PresentationService::changeCurrentPresentation aft");
var event: PresentationChangedEvent = new PresentationChangedEvent(podId, presentationId);
dispatcher.dispatchEvent(event);

View File

@ -238,7 +238,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
private function newPresentationWindowHandler(): void {
presentationPodControls.selectedIndex = 0;
var event:RequestNewPresentationPodEvent = new RequestNewPresentationPodEvent(RequestNewPresentationPodEvent.REQUEST_NEW_PRES_POD);
event.requesterId = UsersUtil.getMyUserID();
localDispatcher.dispatchEvent(event);
}