From 9f63ddd1f7712cad7f348cdd3fe67625f354bf65 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Wed, 20 Aug 2014 07:37:31 -0700 Subject: [PATCH] - add new param (moderatorOnlyMessage) on CREATE API --- bigbluebutton-client/src/ChatModule.mxml | 20 ----- .../bigbluebutton/core/model/MeetingModel.as | 10 ++- .../main/model/modules/ModulesProxy.as | 3 - .../main/model/users/JoinService.as | 78 ++++++++++------- .../main/model/users/UserService.as | 10 ++- .../bigbluebutton/main/views/MainToolbar.mxml | 1 - .../chat/services/ChatMessageService.as | 24 +++++- .../modules/users/maps/UsersMainEventMap.mxml | 1 - .../modules/users/services/MessageReceiver.as | 1 - .../web/controllers/ApiController.groovy | 83 +++++++++++-------- .../org/bigbluebutton/api/MeetingService.java | 4 +- .../org/bigbluebutton/api/domain/Meeting.java | 10 +++ 12 files changed, 150 insertions(+), 95 deletions(-) mode change 100755 => 100644 bigbluebutton-client/src/ChatModule.mxml mode change 100755 => 100644 bigbluebutton-client/src/org/bigbluebutton/main/model/users/JoinService.as mode change 100755 => 100644 bigbluebutton-client/src/org/bigbluebutton/main/views/MainToolbar.mxml mode change 100755 => 100644 bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/ChatMessageService.as mode change 100755 => 100644 bigbluebutton-web/src/java/org/bigbluebutton/api/domain/Meeting.java diff --git a/bigbluebutton-client/src/ChatModule.mxml b/bigbluebutton-client/src/ChatModule.mxml old mode 100755 new mode 100644 index 4de07cfc6f..5d2fdba0e7 --- a/bigbluebutton-client/src/ChatModule.mxml +++ b/bigbluebutton-client/src/ChatModule.mxml @@ -28,8 +28,6 @@ with BigBlueButton; if not, see . - - . trace("Received PRIVATE CHAT MESSAGE EVENT"); } - private function handleTranscriptLoadedEvent(event:Event):void { - LogUtil.debug("Handling TranscriptLoadedEvent"); - var welcome:String = _attributes.welcome as String; - if (welcome != "") { -// var welcomeEvent:PublicChatMessageEvent = new PublicChatMessageEvent(PublicChatMessageEvent.PUBLIC_CHAT_MESSAGE_EVENT); -// var chatobj:ChatMessageVO = new ChatMessageVO(); -// chatobj.message = welcome; -// chatobj.username = " "; -// chatobj.color = "0"; -// chatobj.time = ChatUtil.getCurrentTime(); -// chatobj.language = "en"; -// chatobj.userid = ""; - - // welcomeEvent.chatobj = chatobj; -// var globalDispatcher:Dispatcher = new Dispatcher(); - // globalDispatcher.dispatchEvent(welcomeEvent); - } - } ]]> diff --git a/bigbluebutton-client/src/org/bigbluebutton/core/model/MeetingModel.as b/bigbluebutton-client/src/org/bigbluebutton/core/model/MeetingModel.as index d077fe1356..471e4314e4 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/core/model/MeetingModel.as +++ b/bigbluebutton-client/src/org/bigbluebutton/core/model/MeetingModel.as @@ -10,6 +10,7 @@ package org.bigbluebutton.core.model private var _meetingMuted:Boolean = false; private var _lockSettings:LockSettingsVO; + private var _modOnlyMessage:String = null; public function MeetingModel(enforcer: MeetingModelSingletonEnforcer) { @@ -44,7 +45,14 @@ package org.bigbluebutton.core.model public function get meetingMuted():Boolean { return _meetingMuted; } - + + public function set modOnlyMessage(msg:String):void { + _modOnlyMessage = msg; + } + + public function get modOnlyMessage():String { + return _modOnlyMessage; + } } } diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/modules/ModulesProxy.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/modules/ModulesProxy.as index 67f0126214..2fbb195805 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/modules/ModulesProxy.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/modules/ModulesProxy.as @@ -19,12 +19,9 @@ package org.bigbluebutton.main.model.modules { import com.asfusion.mate.events.Dispatcher; - import mx.controls.Alert; - import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.main.events.PortTestEvent; - import org.bigbluebutton.main.events.SuccessfulLoginEvent; import org.bigbluebutton.main.model.ConferenceParameters; import org.bigbluebutton.main.model.PortTestProxy; diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/JoinService.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/JoinService.as old mode 100755 new mode 100644 index 01d0e288c2..4de8e8cc9a --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/JoinService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/JoinService.as @@ -18,15 +18,13 @@ */ package org.bigbluebutton.main.model.users { - import com.asfusion.mate.events.Dispatcher; - + import com.asfusion.mate.events.Dispatcher; import flash.events.*; import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.URLRequestMethod; import flash.net.URLVariables; import flash.net.navigateToURL; - import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.core.BBB; import org.bigbluebutton.core.model.Me; @@ -40,6 +38,8 @@ package org.bigbluebutton.main.model.users public class JoinService { + private static const LOG:String = "Users::JoinService - "; + private var request:URLRequest = new URLRequest(); private var vars:URLVariables = new URLVariables(); @@ -54,13 +54,13 @@ package org.bigbluebutton.main.model.users var date:Date = new Date(); // url += "?a=" + date.time LogUtil.debug("JoinService:load(...) " + url); - request = new URLRequest(url); - request.method = URLRequestMethod.GET; + request = new URLRequest(url); + request.method = URLRequestMethod.GET; urlLoader.addEventListener(Event.COMPLETE, handleComplete); urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler); urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); - urlLoader.load(request); + urlLoader.load(request); } public function addJoinResultListener(listener:Function):void { @@ -79,33 +79,55 @@ package org.bigbluebutton.main.model.users } private function handleComplete(e:Event):void { - var xml:XML = new XML(e.target.data) - - var returncode:String = xml.returncode; + var result:Object = JSON.parse(e.target.data); + trace(LOG + "Enter response = " + JSON.stringify(result)); + + var returncode:String = result.response.returncode; if (returncode == 'FAILED') { - LogUtil.debug("Join FAILED = " + xml); - + trace(LOG + "Join FAILED = " + JSON.stringify(result)); var dispatcher:Dispatcher = new Dispatcher(); - dispatcher.dispatchEvent(new MeetingNotFoundEvent(xml.logoutURL)); - + dispatcher.dispatchEvent(new MeetingNotFoundEvent(result.response.logoutURL)); } else if (returncode == 'SUCCESS') { - LogUtil.debug("Join SUCESS = " + xml); - trace("JoinService::handleComplete() Join SUCESS = " + xml); - var user:Object = {username:xml.fullname, conference:xml.conference, - conferenceName:xml.confname, externMeetingID:xml.externMeetingID, - meetingID:xml.meetingID, externUserID:xml.externUserID, - internalUserId:xml.internalUserID, - role:xml.role, room:xml.room, authToken:xml.room, record:xml.record, - webvoiceconf:xml.webvoiceconf, dialnumber:xml.dialnumber, - voicebridge:xml.voicebridge, mode:xml.mode, welcome:xml.welcome, logoutUrl:xml.logoutUrl, - defaultLayout:xml.defaultLayout, avatarURL:xml.avatarURL}; + trace("Join SUCESS = " + JSON.stringify(result)); + var user:Object = new Object(); + user.username = result.response.fullname; + user.conference = result.response.conference; + user.conferenceName = result.response.confname; + user.externMeetingID = result.response.externMeetingID; + user.meetingID = result.response.meetingID; + user.externUserID = result.response.externUserID; + user.internalUserId = result.response.internalUserID; + user.role = result.response.role; + user.room = result.response.room; + user.authToken = result.response.room; + user.record = result.response.record; + user.webvoiceconf = result.response.webvoiceconf; + user.dialnumber = result.response.dialnumber; + user.voicebridge = result.response.voicebridge; + user.mode = result.response.mode; + user.welcome = result.response.welcome; + user.logoutUrl = result.response.logoutUrl; + user.defaultLayout = result.response.defaultLayout; + user.avatarURL = result.response.avatarURL + + if (result.response.hasOwnProperty("modOnlyMessage")) { + user.modOnlyMessage = result.response.modOnlyMessage; + MeetingModel.getInstance().modOnlyMessage = user.modOnlyMessage; + } + user.customdata = new Object(); - if(xml.customdata) { - for each(var cdnode:XML in xml.customdata.elements()){ - LogUtil.debug("checking user customdata: "+ cdnode.name() + " = " + cdnode); - user.customdata[cdnode.name()] = cdnode.toString(); - } + if (result.response.customdata) { + var cdata:Array = result.response.customdata as Array; + trace(LOG + "num custom data = " + cdata.length); + for each (var item:Object in cdata) { + trace(LOG + item.toString()); + for (var id:String in item) { + var value:String = item[id] as String; + trace(id + " = " + value); + user.customdata[id] = value; + } + } } UsersModel.getInstance().me = new MeBuilder(user.internalUserId, user.username).withAvatar(user.avatarURL) diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as index 120b8c8abf..dcb4acde93 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as @@ -19,11 +19,14 @@ package org.bigbluebutton.main.model.users { import com.asfusion.mate.events.Dispatcher; + import flash.events.TimerEvent; import flash.external.ExternalInterface; import flash.net.NetConnection; - import flash.utils.Timer; - import mx.collections.ArrayCollection; + import flash.utils.Timer; + + import mx.collections.ArrayCollection; + import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.core.BBB; import org.bigbluebutton.core.UsersUtil; @@ -34,6 +37,7 @@ package org.bigbluebutton.main.model.users import org.bigbluebutton.core.managers.UserConfigManager; import org.bigbluebutton.core.managers.UserManager; import org.bigbluebutton.core.model.Config; + import org.bigbluebutton.core.model.MeetingModel; import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.main.events.SuccessfulLoginEvent; import org.bigbluebutton.main.events.UserServicesEvent; @@ -99,6 +103,8 @@ package org.bigbluebutton.main.model.users UserManager.getInstance().getConference().dialNumber = result.dialnumber; UserManager.getInstance().getConference().record = (result.record != "false"); + + _conferenceParameters = new ConferenceParameters(); _conferenceParameters.meetingName = result.conferenceName; _conferenceParameters.externMeetingID = result.externMeetingID; diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/MainToolbar.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/MainToolbar.mxml old mode 100755 new mode 100644 index 7862eccfcc..54307de793 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/MainToolbar.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/MainToolbar.mxml @@ -58,7 +58,6 @@ with BigBlueButton; if not, see . import org.bigbluebutton.main.events.LogoutEvent; import org.bigbluebutton.main.events.SettingsEvent; import org.bigbluebutton.main.events.ShortcutEvent; - import org.bigbluebutton.main.events.SuccessfulLoginEvent; import org.bigbluebutton.main.model.LayoutOptions; import org.bigbluebutton.main.model.users.events.ConferenceCreatedEvent; import org.bigbluebutton.main.model.users.events.ConnectionFailedEvent; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/ChatMessageService.as b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/ChatMessageService.as old mode 100755 new mode 100644 index bb6ebe86cf..df5a4a387b --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/ChatMessageService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/services/ChatMessageService.as @@ -18,9 +18,11 @@ */ package org.bigbluebutton.modules.chat.services { - import flash.events.IEventDispatcher; + import flash.events.IEventDispatcher; import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.core.BBB; + import org.bigbluebutton.core.UsersUtil; + import org.bigbluebutton.core.model.MeetingModel; import org.bigbluebutton.modules.chat.ChatConstants; import org.bigbluebutton.modules.chat.events.PublicChatMessageEvent; import org.bigbluebutton.modules.chat.vo.ChatMessageVO; @@ -105,6 +107,26 @@ package org.bigbluebutton.modules.chat.services pcEvent.message = msg; dispatcher.dispatchEvent(pcEvent); } + + if (UsersUtil.amIModerator()) { + if (MeetingModel.getInstance().modOnlyMessage != null) { + var msg:ChatMessageVO = new ChatMessageVO(); + msg.chatType = ChatConstants.PUBLIC_CHAT; + msg.fromUserID = SPACE; + msg.fromUsername = SPACE; + msg.fromColor = "86187"; + msg.fromLang = "en"; + msg.fromTime = new Date().getTime(); + msg.fromTimezoneOffset = new Date().getTimezoneOffset(); + msg.toUserID = SPACE; + msg.toUsername = SPACE; + msg.message = MeetingModel.getInstance().modOnlyMessage; + + var pcEvent:PublicChatMessageEvent = new PublicChatMessageEvent(PublicChatMessageEvent.PUBLIC_CHAT_MESSAGE_EVENT); + pcEvent.message = msg; + dispatcher.dispatchEvent(pcEvent); + } + } } } } \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml index 77869ce054..5205fcd806 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml @@ -28,7 +28,6 @@ with BigBlueButton; if not, see . import org.bigbluebutton.core.events.VoiceConfEvent; import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.main.events.LogoutEvent; - import org.bigbluebutton.main.events.SuccessfulLoginEvent; import org.bigbluebutton.main.events.UserServicesEvent; import org.bigbluebutton.main.model.users.UserService; import org.bigbluebutton.main.model.users.events.BroadcastStartedEvent; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as index a8e47b52f9..d81731729a 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as @@ -47,7 +47,6 @@ package org.bigbluebutton.modules.users.services import org.bigbluebutton.modules.present.events.NavigationEvent; import org.bigbluebutton.modules.present.events.RemovePresentationEvent; import org.bigbluebutton.modules.present.events.UploadEvent; - import org.bigbluebutton.modules.present.model.PresentationModel; import org.bigbluebutton.modules.users.events.MeetingMutedEvent; public class MessageReceiver implements IMessageListener diff --git a/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy b/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy index 50c11dc052..557cc78f46 100644 --- a/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy +++ b/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy @@ -148,7 +148,11 @@ class ApiController { } Meeting newMeeting = paramsProcessorUtil.processCreateParams(params); - + + if (! StringUtils.isEmpty(params.moderatorOnlyMessage)) { + newMeeting.setModeratorOnlyMessage(params.moderatorOnlyMessage); + } + meetingService.createMeeting(newMeeting); // See if the request came with pre-uploading of presentation. @@ -303,9 +307,12 @@ class ApiController { //Return a Map with the user custom data Map userCustomData = paramsProcessorUtil.getUserCustomData(params); + userCustomData.put("foo", "fooval"); + userCustomData.put("bar", "barvalue"); + //Currently, it's associated with the externalUserID - if(userCustomData.size()>0) - meetingService.addUserCustomData(meeting.getInternalId(),externUserID,userCustomData); + if (userCustomData.size() > 0) + meetingService.addUserCustomData(meeting.getInternalId(), externUserID, userCustomData); String configxml = null; @@ -1312,46 +1319,52 @@ class ApiController { response.addHeader("Cache-Control", "no-cache") withFormat { - xml { - render(contentType:"text/xml") { - response() { - returncode("FAILED") - message("Could not find conference.") - logoutURL(logoutUrl) + json { + render(contentType: "application/json") { + response = { + returncode = "FAILED" + message = "Could not find conference." + logoutURL = logoutUrl } } } } } else { + + Map userCustomData = paramsProcessorUtil.getUserCustomData(params); + log.info("Found conference for " + us.fullname) response.addHeader("Cache-Control", "no-cache") withFormat { - xml { - render(contentType:"text/xml") { - response() { - returncode("SUCCESS") - fullname(us.fullname) - confname(us.conferencename) - meetingID(us.meetingID) - externMeetingID(us.externMeetingID) - externUserID(us.externUserID) - internalUserID(us.internalUserId) - role(us.role) - conference(us.conference) - room(us.room) - voicebridge(us.voicebridge) - dialnumber(meeting.getDialNumber()) - webvoiceconf(us.webvoiceconf) - mode(us.mode) - record(us.record) - welcome(us.welcome) - logoutUrl(us.logoutUrl) - defaultLayout(us.defaultLayout) - avatarURL(us.avatarURL) - customdata(){ - meeting.getUserCustomData(us.externUserID).each{ k,v -> - "$k"("$v") - } + json { + render(contentType: "application/json") { + response = { + returncode = "SUCCESS" + fullname = us.fullname + confname = us.conferencename + meetingID = us.meetingID + externMeetingID = us.externMeetingID + externUserID = us.externUserID + internalUserID = us.internalUserId + role = us.role + conference = us.conference + room = us.room + voicebridge = us.voicebridge + dialnumber = meeting.getDialNumber() + webvoiceconf = us.webvoiceconf + mode = us.mode + record = us.record + welcome = us.welcome + if (! StringUtils.isEmpty(meeting.moderatorOnlyMessage)) + modOnlyMessage = meeting.moderatorOnlyMessage + logoutUrl = us.logoutUrl + defaultLayout = us.defaultLayout + avatarURL = us.avatarURL + customdata = array { + userCustomData.each { k, v -> + // Somehow we need to prepend something (custdata) for the JSON to work + custdata "$k" : v + } } } } diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java b/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java index 71f4e63b24..658688bb67 100644 --- a/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java +++ b/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java @@ -376,8 +376,8 @@ public class MeetingService implements MessageListener { public void addUserCustomData(String meetingId, String userID, Map userCustomData){ Meeting m = getMeeting(meetingId); - if(m != null){ - m.addUserCustomData(userID,userCustomData); + if (m != null){ + m.addUserCustomData(userID, userCustomData); } } diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/api/domain/Meeting.java b/bigbluebutton-web/src/java/org/bigbluebutton/api/domain/Meeting.java old mode 100755 new mode 100644 index 366170d810..464095b142 --- a/bigbluebutton-web/src/java/org/bigbluebutton/api/domain/Meeting.java +++ b/bigbluebutton-web/src/java/org/bigbluebutton/api/domain/Meeting.java @@ -44,6 +44,7 @@ public class Meeting { private String moderatorPass; private String viewerPass; private String welcomeMsg; + private String modOnlyMessage; private String logoutUrl; private int maxUsers; private boolean record; @@ -74,6 +75,7 @@ public class Meeting { metadata = builder.metadata; createdTime = builder.createdTime; userCustomData = new HashMap(); + users = new ConcurrentHashMap(); configs = new ConcurrentHashMap(); @@ -138,6 +140,14 @@ public class Meeting { return endTime; } + public void setModeratorOnlyMessage(String msg) { + modOnlyMessage = msg; + } + + public String getModeratorOnlyMessage() { + return modOnlyMessage; + } + public void setEndTime(long t) { endTime = t; }