Skip to content

Commit

Permalink
Merge pull request #8691 from ritzalam/pres-url-on-page-convert
Browse files Browse the repository at this point in the history
Improve presentation conversion
  • Loading branch information
ffdixon committed Mar 2, 2020
2 parents 035beb9 + 6c841ce commit ce94cd5
Show file tree
Hide file tree
Showing 60 changed files with 1,793 additions and 773 deletions.
Expand Up @@ -3,6 +3,7 @@ package org.bigbluebutton.core.apps.breakout
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.apps.{ BreakoutModel, PermissionCheck, RightsManagementTrait }
import org.bigbluebutton.core.domain.{ BreakoutRoom2x, MeetingState2x }
import org.bigbluebutton.core.models.PresentationInPod
import org.bigbluebutton.core.running.{ LiveMeeting, OutMsgRouter }
import org.bigbluebutton.core.running.MeetingActor

Expand Down Expand Up @@ -103,7 +104,7 @@ trait CreateBreakoutRoomsCmdMsgHdlr extends RightsManagementTrait {
for {
defaultPod <- state.presentationPodManager.getDefaultPod()
curPres <- defaultPod.getCurrentPresentation()
curPage <- curPres.getCurrentPage(curPres)
curPage <- PresentationInPod.getCurrentPage(curPres)
} yield {
currentSlide = curPage.num
}
Expand Down
Expand Up @@ -6,7 +6,7 @@ import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.running.LiveMeeting

trait PdfConversionInvalidErrorSysPubMsgHdlr {
this: PresentationPodHdlrs =>
this: PresentationPodHdlrs =>

def handle(
msg: PdfConversionInvalidErrorSysPubMsg, state: MeetingState2x,
Expand Down
Expand Up @@ -4,8 +4,6 @@ import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.bus.MessageBus
import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.running.LiveMeeting
import org.bigbluebutton.common2.domain.{ PageVO }
import org.bigbluebutton.core.models.PresentationInPod

trait PresentationConversionCompletedSysPubMsgHdlr {

Expand All @@ -18,32 +16,33 @@ trait PresentationConversionCompletedSysPubMsgHdlr {

val meetingId = liveMeeting.props.meetingProp.intId

val pages = new collection.mutable.HashMap[String, PageVO]

msg.body.presentation.pages.foreach { p =>
val page = PageVO(p.id, p.num, p.thumbUri, p.swfUri, p.txtUri, p.svgUri, p.current, p.xOffset, p.yOffset,
p.widthRatio, p.heightRatio)
pages += page.id -> page
}

val downloadable = msg.body.presentation.downloadable
val presentationId = msg.body.presentation.id
val pres = new PresentationInPod(presentationId, msg.body.presentation.name, msg.body.presentation.current,
pages.toMap, downloadable)
val presVO = PresentationPodsApp.translatePresentationToPresentationVO(pres)
val podId = msg.body.podId

val newState = for {
pod <- PresentationPodsApp.getPresentationPod(state, podId)
pod <- PresentationPodsApp.getPresentationPod(state, msg.body.podId)
pres <- pod.getPresentation(msg.body.presentation.id)
} yield {
PresentationSender.broadcastPresentationConversionCompletedEvtMsg(bus, meetingId,
pod.id, msg.header.userId, msg.body.messageKey, msg.body.code, presVO)
PresentationSender.broadcastSetPresentationDownloadableEvtMsg(bus, meetingId, pod.id,
msg.header.userId, presentationId, downloadable, pres.name)
val presVO = PresentationPodsApp.translatePresentationToPresentationVO(pres)

PresentationSender.broadcastPresentationConversionCompletedEvtMsg(
bus,
meetingId,
pod.id,
msg.header.userId,
msg.body.messageKey,
msg.body.code,
presVO
)
PresentationSender.broadcastSetPresentationDownloadableEvtMsg(
bus,
meetingId,
pod.id,
msg.header.userId,
pres.id,
pres.downloadable,
pres.name
)

var pods = state.presentationPodManager.addPod(pod)
pods = pods.addPresentationToPod(pod.id, pres)
pods = pods.setCurrentPresentation(pod.id, pres.id)

state.update(pods)
}
Expand Down
@@ -0,0 +1,40 @@
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.running.LiveMeeting

trait PresentationConversionEndedSysMsgHdlr {
this: PresentationPodHdlrs =>

def handle(msg: PresentationConversionEndedSysMsg, state: MeetingState2x,
liveMeeting: LiveMeeting, bus: MessageBus): MeetingState2x = {

def broadcastEvent(msg: PresentationConversionEndedSysMsg): Unit = {
val routing = Routing.addMsgToClientRouting(
MessageTypes.BROADCAST_TO_MEETING,
liveMeeting.props.meetingProp.intId, msg.header.userId
)
val envelope = BbbCoreEnvelope(PresentationConversionEndedEventMsg.NAME, routing)
val header = BbbClientMsgHeader(
PresentationConversionEndedEventMsg.NAME,
liveMeeting.props.meetingProp.intId, msg.header.userId
)

val body = PresentationConversionEndedEventMsgBody(
podId = msg.body.podId,
presentationId = msg.body.presentationId,
presName = msg.body.presName
)
val event = PresentationConversionEndedEventMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
bus.outGW.send(msgEvent)
}

broadcastEvent(msg)

state
}

}
Expand Up @@ -22,8 +22,13 @@ trait PresentationConversionUpdatePubMsgHdlr {
liveMeeting.props.meetingProp.intId, msg.header.userId
)

val body = PresentationConversionUpdateEvtMsgBody(msg.body.podId, msg.body.messageKey,
msg.body.code, msg.body.presentationId, msg.body.presName)
val body = PresentationConversionUpdateEvtMsgBody(
msg.body.podId,
msg.body.messageKey,
msg.body.code,
msg.body.presentationId,
msg.body.presName
)
val event = PresentationConversionUpdateEvtMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
bus.outGW.send(msgEvent)
Expand Down
@@ -0,0 +1,66 @@
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.PresentationInPod
import org.bigbluebutton.core.running.LiveMeeting

trait PresentationPageConversionStartedSysMsgHdlr {
this: PresentationPodHdlrs =>

def handle(msg: PresentationPageConversionStartedSysMsg, state: MeetingState2x,
liveMeeting: LiveMeeting, bus: MessageBus): MeetingState2x = {

def broadcastEvent(msg: PresentationPageConversionStartedSysMsg): Unit = {
val routing = Routing.addMsgToClientRouting(
MessageTypes.BROADCAST_TO_MEETING,
liveMeeting.props.meetingProp.intId, msg.header.userId
)
val envelope = BbbCoreEnvelope(PresentationPageConversionStartedSysMsg.NAME, routing)
val header = BbbClientMsgHeader(
PresentationPageConversionStartedSysMsg.NAME,
liveMeeting.props.meetingProp.intId, msg.header.userId
)

val body = PresentationPageConversionStartedSysMsgBody(
podId = msg.body.podId,
presentationId = msg.body.presentationId,
current = msg.body.current,
presName = msg.body.presName,
downloadable = msg.body.downloadable,
authzToken = msg.body.authzToken,
numPages = msg.body.numPages
)
val event = PresentationPageConversionStartedSysMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
bus.outGW.send(msgEvent)
}

val downloadable = msg.body.downloadable
val presentationId = msg.body.presentationId
val podId = msg.body.podId

val pres = new PresentationInPod(presentationId, msg.body.presName, msg.body.current, Map.empty, downloadable)

val newState = for {
pod <- PresentationPodsApp.getPresentationPod(state, podId)
} yield {
var pods = state.presentationPodManager.addPod(pod)
pods = pods.addPresentationToPod(pod.id, pres)
if (msg.body.current) {
pods = pods.setCurrentPresentation(pod.id, pres.id)
}

state.update(pods)
}

broadcastEvent(msg)

newState match {
case Some(ns) => ns
case None => state
}

}
}
@@ -0,0 +1,78 @@
package org.bigbluebutton.core.apps.presentationpod

import org.bigbluebutton.common2.domain.PresentationPageVO
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.bus.MessageBus
import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.models.{ PresentationInPod, PresentationPage }
import org.bigbluebutton.core.running.LiveMeeting

trait PresentationPageConvertedSysMsgHdlr {
this: PresentationPodHdlrs =>

def handle(
msg: PresentationPageConvertedSysMsg,
state: MeetingState2x,
liveMeeting: LiveMeeting,
bus: MessageBus
): MeetingState2x = {

def broadcastEvent(msg: PresentationPageConvertedSysMsg): Unit = {
val routing = Routing.addMsgToClientRouting(
MessageTypes.BROADCAST_TO_MEETING,
liveMeeting.props.meetingProp.intId, msg.header.userId
)
val envelope = BbbCoreEnvelope(PresentationPageConvertedEventMsg.NAME, routing)
val header = BbbClientMsgHeader(
PresentationPageConvertedEventMsg.NAME,
liveMeeting.props.meetingProp.intId, msg.header.userId
)

val page = PresentationPageVO(
id = msg.body.page.id,
num = msg.body.page.num,
urls = msg.body.page.urls,
current = msg.body.page.current
)

val body = PresentationPageConvertedEventMsgBody(
msg.body.podId,
msg.body.messageKey,
msg.body.code,
msg.body.presentationId,
msg.body.numberOfPages,
msg.body.pagesCompleted,
msg.body.presName,
page
)
val event = PresentationPageConvertedEventMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
bus.outGW.send(msgEvent)
}

val page = PresentationPage(
msg.body.page.id,
msg.body.page.num,
msg.body.page.urls,
msg.body.page.current
)

val newState = for {
pod <- PresentationPodsApp.getPresentationPod(state, msg.body.podId)
pres <- pod.getPresentation(msg.body.presentationId)
} yield {
val newPres = PresentationInPod.addPage(pres, page)
var pods = state.presentationPodManager.addPod(pod)
pods = pods.addPresentationToPod(pod.id, newPres)

state.update(pods)
}

broadcastEvent(msg)

newState match {
case Some(ns) => ns
case None => state
}
}
}
Expand Up @@ -20,7 +20,10 @@ class PresentationPodHdlrs(implicit val context: ActorContext)
with PresentationUploadTokenReqMsgHdlr
with ResizeAndMovePagePubMsgHdlr
with SyncGetPresentationPodsMsgHdlr
with RemovePresentationPodPubMsgHdlr {
with RemovePresentationPodPubMsgHdlr
with PresentationPageConvertedSysMsgHdlr
with PresentationPageConversionStartedSysMsgHdlr
with PresentationConversionEndedSysMsgHdlr {

val log = Logging(context.system, getClass)
}
Expand Up @@ -41,10 +41,28 @@ object PresentationPodsApp {

def translatePresentationPodToVO(pod: PresentationPod): PresentationPodVO = {
val presentationObjects = pod.presentations
val presentationVOs = presentationObjects.values.map(p => PresentationVO(p.id, p.name, p.current,
p.pages.values.toVector, p.downloadable)).toVector
val presentationVOs = presentationObjects.values.map { p =>
val pages = p.pages.values.map { page =>
PageVO(
id = page.id,
num = page.num,
thumbUri = page.urls.getOrElse("thumb", ""),
swfUri = page.urls.getOrElse("swf", ""),
txtUri = page.urls.getOrElse("text", ""),
svgUri = page.urls.getOrElse("svg", ""),
current = page.current,
xOffset = page.xOffset,
yOffset = page.yOffset,
widthRatio = page.widthRatio,
heightRatio = page.heightRatio
)
}

PresentationVO(p.id, p.name, p.current,
pages.toVector, p.downloadable)
}

PresentationPodVO(pod.id, pod.currentPresenter, presentationVOs)
PresentationPodVO(pod.id, pod.currentPresenter, presentationVOs.toVector)
}

def findPodsWhereUserIsPresenter(mgr: PresentationPodManager, userId: String): Vector[PresentationPod] = {
Expand All @@ -57,7 +75,22 @@ object PresentationPodsApp {
}

def translatePresentationToPresentationVO(pres: PresentationInPod): PresentationVO = {
PresentationVO(pres.id, pres.name, pres.current, pres.pages.values.toVector, pres.downloadable)
val pages = pres.pages.values.map { page =>
PageVO(
id = page.id,
num = page.num,
thumbUri = page.urls.getOrElse("thumb", ""),
swfUri = page.urls.getOrElse("swf", ""),
txtUri = page.urls.getOrElse("text", ""),
svgUri = page.urls.getOrElse("svg", ""),
current = page.current,
xOffset = page.xOffset,
yOffset = page.yOffset,
widthRatio = page.widthRatio,
heightRatio = page.heightRatio
)
}
PresentationVO(pres.id, pres.name, pres.current, pages.toVector, pres.downloadable)
}

def setCurrentPresentationInPod(state: MeetingState2x, podId: String, nextCurrentPresId: String): Option[PresentationPod] = {
Expand Down
@@ -1,19 +1,19 @@
package org.bigbluebutton.core.apps.presentationpod

import org.bigbluebutton.common2.domain.PageVO
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.bus.MessageBus
import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.running.LiveMeeting
import org.bigbluebutton.core.apps.{ PermissionCheck, RightsManagementTrait }
import org.bigbluebutton.core.models.PresentationPage

trait ResizeAndMovePagePubMsgHdlr extends RightsManagementTrait {
this: PresentationPodHdlrs =>

def handle(msg: ResizeAndMovePagePubMsg, state: MeetingState2x,
liveMeeting: LiveMeeting, bus: MessageBus): MeetingState2x = {

def broadcastEvent(msg: ResizeAndMovePagePubMsg, podId: String, page: PageVO): Unit = {
def broadcastEvent(msg: ResizeAndMovePagePubMsg, podId: String, page: PresentationPage): Unit = {
val routing = Routing.addMsgToClientRouting(
MessageTypes.BROADCAST_TO_MEETING,
liveMeeting.props.meetingProp.intId, msg.header.userId
Expand Down

0 comments on commit ce94cd5

Please sign in to comment.