diff --git a/bbb-api-demo/src/main/webapp/bbb_api.jsp b/bbb-api-demo/src/main/webapp/bbb_api.jsp index d3229a3382..e4a131bb2a 100755 --- a/bbb-api-demo/src/main/webapp/bbb_api.jsp +++ b/bbb-api-demo/src/main/webapp/bbb_api.jsp @@ -1,979 +1,980 @@ -<%/** -* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ -* -* Copyright (c) 2012 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 3.0 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 . -* -*/%> -<%@page import="java.text.SimpleDateFormat"%> -<%@page import="javax.xml.transform.dom.DOMSource"%> -<%@page import="javax.xml.transform.stream.StreamResult"%> -<%@page import="javax.xml.transform.OutputKeys"%> -<%@page import="javax.xml.transform.TransformerFactory"%> -<%@page import="javax.xml.transform.Transformer"%> -<%@page import="org.w3c.dom.Element"%> -<%@page import="com.sun.org.apache.xerces.internal.dom.ChildNode"%> -<%@page import="org.w3c.dom.Node"%> -<%@page import="org.w3c.dom.NodeList"%> -<%@page import="java.util.*,java.io.*,java.net.*,javax.crypto.*,javax.xml.parsers.*,org.w3c.dom.Document,org.xml.sax.*" errorPage="error.jsp"%> - -<%@ page import="org.apache.commons.codec.digest.*"%> -<%@ page import="java.io.*"%> -<%@ page import="java.nio.channels.FileChannel"%> -<%@ page import="org.apache.commons.lang.StringEscapeUtils"%> - -<%@ include file="bbb_api_conf.jsp"%> - -<%!// -// Create a meeting with specific -// - meetingID -// - welcome message -// - moderator password -// - viewer password -// - voiceBridge -// - logoutURL -// -// Added for 0.8 -// -// - metadata -// - xml (for pre-upload of slides) -// -public String createMeeting(String meetingID, String welcome, String moderatorPassword, String moderatorWelcomeMsg, String viewerPassword, Integer voiceBridge, String logoutURL) { - String base_url_create = BigBlueButtonURL + "api/create?"; - - String welcome_param = ""; - String checksum = ""; - - String attendee_password_param = "&attendeePW=ap"; - String moderator_password_param = "&moderatorPW=mp"; - String voice_bridge_param = ""; - String logoutURL_param = ""; - String moderatorWelcomeMsg_param = ""; - - if ((welcome != null) && !welcome.equals("")) { - welcome_param = "&welcome=" + urlEncode(welcome); - } - - if ((moderatorPassword != null) && !moderatorPassword.equals("")) { - moderator_password_param = "&moderatorPW=" + urlEncode(moderatorPassword); - } - - if ((moderatorWelcomeMsg != null) && !moderatorWelcomeMsg.equals("")) { - moderatorWelcomeMsg_param = "&moderatorOnlyMessage=" + urlEncode(moderatorWelcomeMsg); - } - if ((viewerPassword != null) && !viewerPassword.equals("")) { - attendee_password_param = "&attendeePW=" + urlEncode(viewerPassword); - } - - if ((voiceBridge != null) && voiceBridge > 0) { - voice_bridge_param = "&voiceBridge=" + urlEncode(voiceBridge.toString()); - } else { - // No voice bridge number passed, so we'll generate a random one for this meeting - Random random = new Random(); - Integer n = 70000 + random.nextInt(9999); - voice_bridge_param = "&voiceBridge=" + n; - } - - if ((logoutURL != null) && !logoutURL.equals("")) { - logoutURL_param = "&logoutURL=" + urlEncode(logoutURL); - } - - // - // Now create the URL - // - - String create_parameters = "name=" + urlEncode(meetingID) - + "&meetingID=" + urlEncode(meetingID) + welcome_param - + attendee_password_param + moderator_password_param - + moderatorWelcomeMsg_param + voice_bridge_param + logoutURL_param; - - Document doc = null; - - try { - // Attempt to create a meeting using meetingID - String xml = getURL(base_url_create + create_parameters - + "&checksum=" - + checksum("create" + create_parameters + salt)); - doc = parseXml(xml); - } catch (Exception e) { - e.printStackTrace(); - } - - if (doc.getElementsByTagName("returncode").item(0).getTextContent().trim().equals("SUCCESS")) { - return meetingID; - } - - return "Error " - + doc.getElementsByTagName("messageKey").item(0).getTextContent().trim() - + ": " - + doc.getElementsByTagName("message").item(0).getTextContent() - .trim(); -} - -// -// getJoinMeetingURL() -- get join meeting URL for both viewer and moderator as guest -// - -public String getJoinMeetingURL(String username, String meetingID, String password, String clientURL, Boolean guest) { - String base_url_join = BigBlueButtonURL + "api/join?"; - String clientURL_param = ""; - - if ((clientURL != null) && !clientURL.equals("")) { - clientURL_param = "&redirectClient=true&clientURL=" + urlEncode( clientURL ); - } - - - String join_parameters = "meetingID=" + urlEncode(meetingID) - + "&fullName=" + urlEncode(username) + "&password=" - + urlEncode(password) + "&guest=" + urlEncode(guest.toString()) + clientURL_param; - - return base_url_join + join_parameters + "&checksum=" - + checksum("join" + join_parameters + salt); -} - -// -// getJoinMeetingURL() -- get join meeting URL for both viewer and moderator -// -public String getJoinMeetingURL(String username, String meetingID, String password, String clientURL) { - String base_url_join = BigBlueButtonURL + "api/join?"; - String clientURL_param = ""; - - if ((clientURL != null) && !clientURL.equals("")) { - clientURL_param = "&redirectClient=true&clientURL=" + urlEncode( clientURL ); - } - - - String join_parameters = "meetingID=" + urlEncode(meetingID) - + "&fullName=" + urlEncode(username) + "&password=" - + urlEncode(password) + clientURL_param; - - return base_url_join + join_parameters + "&checksum=" - + checksum("join" + join_parameters + salt); -} - - - - -// -// Create a meeting and return a URL to join it as moderator. This is used for the API demos. -// -// Passed -// - username -// - meetingID -// - record ["true", "false"] -// - welcome message (null causes BigBlueButton to use the default welcome message -// - metadata (passed through when record="true" -// - xml (used for pre-upload of slides)_ -// -// Returned -// - valid join URL using the username -// -// Note this meeting will use username for meetingID - -public String getJoinURL(String username, String meetingID, String record, String welcome, Map metadata, String xml) { - String base_url_create = BigBlueButtonURL + "api/create?"; - String base_url_join = BigBlueButtonURL + "api/join?"; - - String welcome_param = ""; - if ((welcome != null) && !welcome.equals("")) { - welcome_param = "&welcome=" + urlEncode(welcome); - } - - String xml_param = ""; - if ((xml != null) && !xml.equals("")) { - xml_param = xml; - } - - Random random = new Random(); - String voiceBridge_param = "&voiceBridge=" + (70000 + random.nextInt(9999)); - - // - // When creating a meeting, the 'name' parameter is the name of the meeting (not to be confused with - // the username). For example, the name could be "Fred's meeting" and the meetingID could be "ID-1234312". - // - // While name and meetingID should be different, we'll keep them the same. Why? Because calling api/create? - // with a previously used meetingID will return same meetingToken (regardless if the meeting is running or not). - // - // This means the first person to call getJoinURL with meetingID="Demo Meeting" will actually create the - // meeting. Subsequent calls will return the same meetingToken and thus subsequent users will join the same - // meeting. - // - // Note: We're hard-coding the password for moderator and attendee (viewer) for purposes of demo. - // - - String create_parameters = "name=" + urlEncode(meetingID) - + "&meetingID=" + urlEncode(meetingID) + welcome_param + voiceBridge_param - + "&attendeePW=ap&moderatorPW=mp" - + "&record=" + record + getMetaData( metadata ); - - - // Attempt to create a meeting using meetingID - Document doc = null; - try { - String url = base_url_create + create_parameters - + "&checksum=" - + checksum("create" + create_parameters + salt); - doc = parseXml( postURL( url, xml_param ) ); - } catch (Exception e) { - e.printStackTrace(); - } - - if (doc.getElementsByTagName("returncode").item(0).getTextContent() - .trim().equals("SUCCESS")) { - - // - // Looks good, now return a URL to join that meeting - // - - String join_parameters = "meetingID=" + urlEncode(meetingID) - + "&fullName=" + urlEncode(username) + "&password=mp"; - - return base_url_join + join_parameters + "&checksum=" - + checksum("join" + join_parameters + salt); - } - - return doc.getElementsByTagName("messageKey").item(0).getTextContent() - .trim() - + ": " - + doc.getElementsByTagName("message").item(0).getTextContent() - .trim(); -} - - -///////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////// -public String getJoinURLwithDynamicConfigXML(String username, String meetingID, String configXML) { - - String base_url_create = BigBlueButtonURL + "api/create?"; - String base_url_join = BigBlueButtonURL + "api/join?"; - String base_url_setConfigXML = BigBlueButtonURL + "api/setConfigXML.xml?"; - - Random random = new Random(); - String voiceBridge_param = "&voiceBridge=" + (70000 + random.nextInt(9999)); - - String url; - // - // When creating a meeting, the 'name' parameter is the name of the meeting (not to be confused with - // the username). For example, the name could be "Fred's meeting" and the meetingID could be "ID-1234312". - // - // While name and meetingID should be different, we'll keep them the same. Why? Because calling api/create? - // with a previously used meetingID will return same meetingToken (regardless if the meeting is running or not). - // - // This means the first person to call getJoinURL with meetingID="Demo Meeting" will actually create the - // meeting. Subsequent calls will return the same meetingToken and thus subsequent users will join the same - // meeting. - // - // Note: We're hard-coding the password for moderator and attendee (viewer) for purposes of demo. - // - - String create_parameters = "name=" + urlEncode(meetingID) - + "&meetingID=" + urlEncode(meetingID) + voiceBridge_param - + "&attendeePW=ap&moderatorPW=mp"; - - - // Attempt to create a meeting using meetingID - Document doc = null; - url = ""; - try { - url = base_url_create + create_parameters - + "&checksum=" - + checksum("create" + create_parameters + salt); - doc = parseXml( postURL( url, "" ) ); - } catch (Exception e) { - e.printStackTrace(); - } - - if (!doc.getElementsByTagName("returncode").item(0).getTextContent().trim().equals("SUCCESS")) { - // - // Someting went wrong, return the error - // - return " " + url + "
" + doc.getElementsByTagName("messageKey").item(0).getTextContent() - .trim() - + ": " - + doc.getElementsByTagName("message").item(0).getTextContent() - .trim(); - } - - - // - // Looks good, now Attempt to send the ConfigXML file and get the token - // - - String xml_param = ""; - if ((configXML != null) && !configXML.equals("")) { - xml_param = configXML; - xml_param = xml_param.replace("\n", ""); - xml_param = xml_param.replace("\t", ""); - xml_param = xml_param.replace("> <", "><"); - xml_param = xml_param.replace("> <", "><"); - } - - // Create the parameters we want to send to the server. - Map paramsMap = new HashMap(); - paramsMap.put("meetingID", new String[]{urlEncode(meetingID)}); - paramsMap.put("configXML", new String[]{urlEncode(xml_param)}); - - String baseString = createBaseString(paramsMap); - - String setConfigXML_parameters = baseString + "&checksum=" + checksum("setConfigXML" + baseString + salt); - - try { - doc = parseXml( postURL( base_url_setConfigXML, setConfigXML_parameters, "application/x-www-form-urlencoded" ) ); - } catch (Exception e) { - e.printStackTrace(); - } - - String configToken = ""; - if (!doc.getElementsByTagName("returncode").item(0).getTextContent().trim().equals("SUCCESS")) { - // - // Someting went wrong, return the error - // - return " " + base_url_setConfigXML + "
" + doc.getElementsByTagName("messageKey").item(0).getTextContent().trim() - + ": " - + doc.getElementsByTagName("message").item(0).getTextContent().trim() + "
" + encodeURIComponent(xml_param); - } else { - configToken = doc.getElementsByTagName("configToken").item(0).getTextContent().trim(); - } - - // - // And finally return a URL to join that meeting using the specific config.xml - // - String join_parameters = "meetingID=" + urlEncode(meetingID) + "&fullName=" + urlEncode(username) + "&password=mp&configToken=" + configToken; - - return base_url_join + join_parameters + "&checksum=" + checksum("join" + join_parameters + salt); - -} - -// From the list of parameters we want to pass. Creates a base string with parameters -// sorted in alphabetical order for us to sign. -public String createBaseString(Map params) { - StringBuffer csbuf = new StringBuffer(); - SortedSet keys = new TreeSet(params.keySet()); - - boolean first = true; - String checksum = null; - for (String key: keys) { - for (String value: params.get(key)) { - if (first) { - first = false; - } else { - csbuf.append("&"); - } - csbuf.append(key); - csbuf.append("="); - csbuf.append(value); - } - } - - return csbuf.toString(); -} - - -// -// Create a meeting and return a URL to join it as moderator -// -public String getJoinURLXML(String username, String meetingID, String welcome, String xml) { - String base_url_create = BigBlueButtonURL + "api/create?"; - String base_url_join = BigBlueButtonURL + "api/join?"; - - String welcome_param = ""; - - Random random = new Random(); - Integer voiceBridge = 70000 + random.nextInt(9999); - - if ((welcome != null) && !welcome.equals("")) { - welcome_param = "&welcome=" + urlEncode(welcome); - } - - String xml_param = ""; - if ((xml != null) && !xml.equals("")) { - xml_param = xml; - } - - String create_parameters = "name=" + urlEncode(meetingID) - + "&meetingID=" + urlEncode(meetingID) + welcome_param - + "&attendeePW=ap&moderatorPW=mp&voiceBridge=" + voiceBridge; - - Document doc = null; - - try { - // Attempt to create a meeting using meetingID - String params = postURL(base_url_create + create_parameters - + "&checksum=" - + checksum("create" + create_parameters + salt), xml_param); - doc = parseXml(params); - } catch (Exception e) { - e.printStackTrace(); - } - - if (doc.getElementsByTagName("returncode").item(0).getTextContent() - .trim().equals("SUCCESS")) { - - String join_parameters = "meetingID=" + urlEncode(meetingID) - + "&fullName=" + urlEncode(username) + "&password=mp"; - - return base_url_join + join_parameters + "&checksum=" - + checksum("join" + join_parameters + salt); - } - - return doc.getElementsByTagName("messageKey").item(0).getTextContent() - .trim() - + ": " - + doc.getElementsByTagName("message").item(0).getTextContent() - .trim(); -} - -// -// getJoinURLViewer() -- Get the URL to join a meeting as viewer -// -public String getJoinURLViewer(String username, String meetingID) { - String base_url_join = BigBlueButtonURL + "api/join?"; - String join_parameters = "meetingID=" + urlEncode(meetingID) - + "&fullName=" + urlEncode(username) + "&password=ap"; - - return base_url_join + join_parameters + "&checksum=" - + checksum("join" + join_parameters + salt); -} - - -// -// getURLisMeetingRunning() -- return a URL that the client can use to poll for whether the given meeting is running -// -public String getURLisMeetingRunning(String meetingID) { - String meetingParameters = "meetingID=" + urlEncode(meetingID); - return BigBlueButtonURL + "api/isMeetingRunning?" + meetingParameters - + "&checksum=" - + checksum("isMeetingRunning" + meetingParameters + salt); -} - -// -// isMeetingRunning() -- check the BigBlueButton server to see if the meeting is running (i.e. there is someone in the meeting) -// -public String isMeetingRunning(String meetingID) { - Document doc = null; - try { - doc = parseXml( getURL( getURLisMeetingRunning(meetingID) )); - } catch (Exception e) { - e.printStackTrace(); - } - - if (doc.getElementsByTagName("returncode").item(0).getTextContent() - .trim().equals("SUCCESS")) { - return doc.getElementsByTagName("running").item(0).getTextContent() - .trim(); - } - - return "Error " - + doc.getElementsByTagName("messageKey").item(0) - .getTextContent().trim() - + ": " - + doc.getElementsByTagName("message").item(0).getTextContent() - .trim(); -} - -public String getMeetingInfoURL(String meetingID, String password) { - String meetingParameters = "meetingID=" + urlEncode(meetingID) - + "&password=" + password; - return BigBlueButtonURL + "api/getMeetingInfo?" + meetingParameters - + "&checksum=" - + checksum("getMeetingInfo" + meetingParameters + salt); -} - -public String getMeetingInfo(String meetingID, String password) { - try { - return getURL( getMeetingInfoURL(meetingID, password)); - } catch (Exception e) { - e.printStackTrace(System.out); - return null; - } -} - -public String getDefaultConfigXML() { - try { - return getURL( getDefaultConfigXMLURL() ); - } catch (Exception e) { - e.printStackTrace(System.out); - return null; - } -} - -public String getDefaultConfigXMLURL() { - String meetingParameters = ""; - return BigBlueButtonURL + "api/getDefaultConfigXML?" + meetingParameters - + "&checksum=" - + checksum("getDefaultConfigXML" + meetingParameters + salt); -} - -public String getMeetingsURL() { - String meetingParameters = "random=" + new Random().nextInt(9999); - return BigBlueButtonURL + "api/getMeetings?" + meetingParameters - + "&checksum=" - + checksum("getMeetings" + meetingParameters + salt); -} - -// -// Calls getMeetings to obtain the list of meetings, then calls getMeetingInfo for each meeting -// and concatenates the result. -// -public String getMeetings() { - try { - Document doc = parseXml( getURL( getMeetingsURL() )); - - // tags needed for parsing xml documents - final String startTag = ""; - final String endTag = ""; - final String startResponse = ""; - final String endResponse = ""; - - // if the request succeeded, then calculate the checksum of each meeting and insert it into the document - NodeList meetingsList = doc.getElementsByTagName("meeting"); - - String newXMldocument = startTag; - for (int i = 0; i < meetingsList.getLength(); i++) { - Element meeting = (Element) meetingsList.item(i); - String meetingID = meeting.getElementsByTagName("meetingID").item(0).getTextContent(); - String password = meeting.getElementsByTagName("moderatorPW").item(0).getTextContent(); - - String data = getURL( getMeetingInfoURL(meetingID, password) ); - - if (data.indexOf("") != -1) { - int startIndex = data.indexOf(startResponse) + startTag.length(); - int endIndex = data.indexOf(endResponse); - newXMldocument += "" + data.substring(startIndex, endIndex) + ""; - } - } - newXMldocument += endTag; - - return newXMldocument; - } catch (Exception e) { - e.printStackTrace(System.out); - return null; - } -} - - - -public String getendMeetingURL(String meetingID, String moderatorPassword) { - String end_parameters = "meetingID=" + urlEncode(meetingID) + "&password=" - + urlEncode(moderatorPassword); - return BigBlueButtonURL + "api/end?" + end_parameters + "&checksum=" - + checksum("end" + end_parameters + salt); -} - -public String endMeeting(String meetingID, String moderatorPassword) { - - Document doc = null; - try { - String xml = getURL(getendMeetingURL(meetingID, moderatorPassword)); - doc = parseXml(xml); - } catch (Exception e) { - e.printStackTrace(); - } - - if (doc.getElementsByTagName("returncode").item(0).getTextContent() - .trim().equals("SUCCESS")) { - return "true"; - } - - return "Error " - + doc.getElementsByTagName("messageKey").item(0) - .getTextContent().trim() - + ": " - + doc.getElementsByTagName("message").item(0).getTextContent() - .trim(); -} - - -////////////////////////////////////////////////////////////////////////////// -// -// Added for BigBlueButton 0.8 -// -////////////////////////////////////////////////////////////////////////////// - -public String getRecordingsURL(String meetingID) { - String record_parameters = "meetingID=" + urlEncode(meetingID); - return BigBlueButtonURL + "api/getRecordings?" + record_parameters + "&checksum=" - + checksum("getRecordings" + record_parameters + salt); -} - -public String getRecordings(String meetingID) { - //recordID,name,description,starttime,published,playback,length - String newXMLdoc = ""; - - try { - Document doc = null; - String url = getRecordingsURL(meetingID); - doc = parseXml( getURL(url) ); - - // if the request succeeded, then calculate the checksum of each meeting and insert it into the document - NodeList recordingList = doc.getElementsByTagName("recording"); - - - for (int i = 0; i < recordingList.getLength(); i++) { - Element recording = (Element) recordingList.item(i); - - if(recording.getElementsByTagName("recordID").getLength()>0){ - - String recordID = recording.getElementsByTagName("recordID").item(0).getTextContent(); - String name = recording.getElementsByTagName("name").item(0).getTextContent(); - String description = ""; - NodeList metadata = recording.getElementsByTagName("metadata"); - if(metadata.getLength()>0){ - Element metadataElem = (Element) metadata.item(0); - if(metadataElem.getElementsByTagName("description").getLength() > 0){ - description = metadataElem.getElementsByTagName("description").item(0).getTextContent(); - } - } - - String starttime = recording.getElementsByTagName("startTime").item(0).getTextContent(); - try{ - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); - Date resultdate = new Date(Long.parseLong(starttime)); - starttime = sdf.format(resultdate); - }catch(Exception e){ - - } - String published = recording.getElementsByTagName("published").item(0).getTextContent(); - String playback = ""; - String length = ""; - NodeList formats = recording.getElementsByTagName("format"); - for (int j = 0; j < formats.getLength(); j++){ - Element format = (Element) formats.item(j); - - String typeP = format.getElementsByTagName("type").item(0).getTextContent(); - String urlP = format.getElementsByTagName("url").item(0).getTextContent(); - String lengthP = format.getElementsByTagName("length").item(0).getTextContent(); - - if (j != 0){ - playback +=", "; - } - playback += StringEscapeUtils.escapeXml("" + typeP + ""); - - if(typeP.equalsIgnoreCase("slides") || typeP.equalsIgnoreCase("presentation")){ - length = lengthP; - } - } - - newXMLdoc += ""; - - newXMLdoc += "" + recordID + ""; - newXMLdoc += ""; - newXMLdoc += ""; - newXMLdoc += "" + starttime + ""; - newXMLdoc += "" + published + ""; - newXMLdoc += "" + playback + ""; - newXMLdoc += "" + length + ""; - - newXMLdoc += ""; - } - } - }catch (Exception e) { - e.printStackTrace(System.out); - return "error: "+e.getMessage(); - } - newXMLdoc += ""; - return newXMLdoc; -} - -public String getPublishRecordingsURL(boolean publish, String recordID) { - String publish_parameters = "recordID=" + urlEncode(recordID) - + "&publish=" + publish; - return BigBlueButtonURL + "api/publishRecordings?" + publish_parameters + "&checksum=" - + checksum("publishRecordings" + publish_parameters + salt); -} - -public String setPublishRecordings(boolean publish, String recordID){ - try { - return getURL( getPublishRecordingsURL(publish,recordID)); - } catch (Exception e) { - e.printStackTrace(System.out); - return null; - } -} - -public String getDeleteRecordingsURL(String recordID) { - String delete_parameters = "recordID=" + urlEncode(recordID); - return BigBlueButtonURL + "api/deleteRecordings?" + delete_parameters + "&checksum=" - + checksum("deleteRecordings" + delete_parameters + salt); -} - -public String deleteRecordings(String recordID){ - try { - return getURL( getDeleteRecordingsURL(recordID)); - } catch (Exception e) { - e.printStackTrace(System.out); - return null; - } -} - - - -////////////////////////////////////////////////////////////////////////////// -// -// Helper Routines -// -////////////////////////////////////////////////////////////////////////////// - -public String getMetaData( Map metadata ) { - String metadata_params = ""; - - if ( metadata!=null ){ - for(String metakey : metadata.keySet()){ - metadata_params = metadata_params + "&meta_" + urlEncode(metakey) + "=" + urlEncode(metadata.get(metakey)); - } - } - - return metadata_params; -} - -// -// checksum() -- Return a checksum based on SHA-1 digest -// -public static String checksum(String s) { - String checksum = ""; - try { - checksum = org.apache.commons.codec.digest.DigestUtils.shaHex(s); - } catch (Exception e) { - e.printStackTrace(); - } - return checksum; -} - -// -// getURL() -- fetch a URL and return its contents as a String -// -public static String getURL(String url) { - StringBuffer response = null; - - try { - URL u = new URL(url); - HttpURLConnection httpConnection = (HttpURLConnection) u.openConnection(); - - httpConnection.setUseCaches(false); - httpConnection.setDoOutput(true); - httpConnection.setRequestMethod("GET"); - - httpConnection.connect(); - int responseCode = httpConnection.getResponseCode(); - if (responseCode == HttpURLConnection.HTTP_OK) { - InputStream input = httpConnection.getInputStream(); - - // Read server's response. - response = new StringBuffer(); - Reader reader = new InputStreamReader(input, "UTF-8"); - reader = new BufferedReader(reader); - char[] buffer = new char[1024]; - for (int n = 0; n >= 0;) { - n = reader.read(buffer, 0, buffer.length); - if (n > 0) - response.append(buffer, 0, n); - } - - input.close(); - httpConnection.disconnect(); - } - } catch (Exception e) { - e.printStackTrace(); - } - - if (response != null) { - return response.toString(); - } else { - return ""; - } -} - -public static String postURL(String targetURL, String urlParameters) -{ - return postURL(targetURL, urlParameters, "text/xml"); -} - -public static String postURL(String targetURL, String urlParameters, String contentType) -{ - URL url; - HttpURLConnection connection = null; - int responseCode = 0; - try { - //Create connection - url = new URL(targetURL); - connection = (HttpURLConnection)url.openConnection(); - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", contentType); - - connection.setRequestProperty("Content-Length", "" + - Integer.toString(urlParameters.getBytes().length)); - connection.setRequestProperty("Content-Language", "en-US"); - - connection.setUseCaches (false); - connection.setDoInput(true); - connection.setDoOutput(true); - - //Send request - DataOutputStream wr = new DataOutputStream ( - connection.getOutputStream ()); - wr.writeBytes (urlParameters); - wr.flush (); - wr.close (); - - //Get Response - InputStream is = connection.getInputStream(); - BufferedReader rd = new BufferedReader(new InputStreamReader(is)); - String line; - StringBuffer response = new StringBuffer(); - while((line = rd.readLine()) != null) { - response.append(line); - response.append('\r'); - } - rd.close(); - return response.toString(); - - } catch (Exception e) { - - e.printStackTrace(); - return null; - - } finally { - - if(connection != null) { - connection.disconnect(); - } - } -} - -// -// parseXml() -- return a DOM of the XML -// -public static Document parseXml(String xml) -throws ParserConfigurationException, IOException, SAXException { - DocumentBuilderFactory docFactory = DocumentBuilderFactory - .newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - Document doc = docBuilder.parse(new InputSource(new StringReader(xml))); - return doc; -} - -// -// urlEncode() -- URL encode the string -// -public static String urlEncode(String s) { - try { - return URLEncoder.encode(s, "UTF-8"); - } catch (Exception e) { - e.printStackTrace(); - } - return ""; -} - -// -//encodeURIComponent() -- Java encoding similiar to JavaScript encodeURIComponent -// -public static String encodeURIComponent(String component) { - String result = null; - - try { - result = URLEncoder.encode(component, "UTF-8") - .replaceAll("\\%28", "(") - .replaceAll("\\%29", ")") - .replaceAll("\\+", "%20") - .replaceAll("\\%27", "'") - .replaceAll("\\%21", "!") - .replaceAll("\\%7E", "~"); - } catch (UnsupportedEncodingException e) { - result = component; - } - - return result; -} - -public String getMeetingsWithoutPasswords() { - try { - Document doc = parseXml( getURL( getMeetingsURL() )); - - // tags needed for parsing xml documents - final String startTag = ""; - final String endTag = ""; - final String startResponse = ""; - final String endResponse = ""; - - // if the request succeeded, then calculate the checksum of each meeting and insert it into the document - NodeList meetingsList = doc.getElementsByTagName("meeting"); - - String newXMldocument = startTag; - for (int i = 0; i < meetingsList.getLength(); i++) { - Element meeting = (Element) meetingsList.item(i); - String meetingID = meeting.getElementsByTagName("meetingID").item(0).getTextContent(); - String password = meeting.getElementsByTagName("moderatorPW").item(0).getTextContent(); - - String data = getURL( getMeetingInfoURL(meetingID, password) ); - - if (data.indexOf("") != -1) { - data = removeTag(data, "", ""); - data = removeTag(data, "", ""); - - int startIndex = data.indexOf(startResponse) + startResponse.length(); - int endIndex = data.indexOf(endResponse); - newXMldocument += "" + data.substring(startIndex, endIndex) + ""; - } - } - newXMldocument += endTag; - - return newXMldocument; - } catch (Exception e) { - e.printStackTrace(System.out); - return null; - } -} - -public static String removeTag(String data, String startTag, String endTag){ - int startIndex = data.indexOf(startTag); - int endIndex = data.indexOf(endTag) + endTag.length(); - String tagStr = data.substring(startIndex, endIndex); - return data.replace(tagStr,""); -} - -public String getBigBlueButtonIP() -{ - try { - URL url = new URL(BigBlueButtonURL); - String bbbIP = url.getHost(); - return bbbIP; - } catch (Exception e) { - e.printStackTrace(); - return "localhost"; - } -} - -public static Element getElementWithAttribute(Node root, String attrName, String attrValue) -{ - NodeList nl = root.getChildNodes(); - for (int i = 0; i < nl.getLength(); i++) { - Node n = nl.item(i); - if (n instanceof Element) { - Element el = (Element) n; - if (el.getAttribute(attrName).equals(attrValue)) { - return el; - }else{ - el = getElementWithAttribute(n, attrName, attrValue); //search recursively - if(el != null){ - return el; - } - } - } - } - return null; -} - -%> +<%/** +* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ +* +* Copyright (c) 2012 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 3.0 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 . +* +*/%> +<%@page import="java.text.SimpleDateFormat"%> +<%@page import="javax.xml.transform.dom.DOMSource"%> +<%@page import="javax.xml.transform.stream.StreamResult"%> +<%@page import="javax.xml.transform.OutputKeys"%> +<%@page import="javax.xml.transform.TransformerFactory"%> +<%@page import="javax.xml.transform.Transformer"%> +<%@page import="org.w3c.dom.Element"%> +<%@page import="com.sun.org.apache.xerces.internal.dom.ChildNode"%> +<%@page import="org.w3c.dom.Node"%> +<%@page import="org.w3c.dom.NodeList"%> +<%@page import="java.util.*,java.io.*,java.net.*,javax.crypto.*,javax.xml.parsers.*,org.w3c.dom.Document,org.xml.sax.*" errorPage="error.jsp"%> + +<%@ page import="org.apache.commons.codec.digest.*"%> +<%@ page import="java.io.*"%> +<%@ page import="java.nio.channels.FileChannel"%> +<%@ page import="org.apache.commons.lang.StringEscapeUtils"%> + +<%@ include file="bbb_api_conf.jsp"%> + +<%!// +// Create a meeting with specific +// - meetingID +// - welcome message +// - moderator password +// - viewer password +// - voiceBridge +// - logoutURL +// +// Added for 0.8 +// +// - metadata +// - xml (for pre-upload of slides) +// +public String createMeeting(String meetingID, String welcome, String moderatorPassword, String moderatorWelcomeMsg, String viewerPassword, Integer voiceBridge, String logoutURL) { + String base_url_create = BigBlueButtonURL + "api/create?"; + + String welcome_param = ""; + String checksum = ""; + + String attendee_password_param = "&attendeePW=ap"; + String moderator_password_param = "&moderatorPW=mp"; + String voice_bridge_param = ""; + String logoutURL_param = ""; + String moderatorWelcomeMsg_param = ""; + + if ((welcome != null) && !welcome.equals("")) { + welcome_param = "&welcome=" + urlEncode(welcome); + } + + if ((moderatorPassword != null) && !moderatorPassword.equals("")) { + moderator_password_param = "&moderatorPW=" + urlEncode(moderatorPassword); + } + + if ((moderatorWelcomeMsg != null) && !moderatorWelcomeMsg.equals("")) { + moderatorWelcomeMsg_param = "&moderatorOnlyMessage=" + urlEncode(moderatorWelcomeMsg); + } + + if ((viewerPassword != null) && !viewerPassword.equals("")) { + attendee_password_param = "&attendeePW=" + urlEncode(viewerPassword); + } + + if ((voiceBridge != null) && voiceBridge > 0) { + voice_bridge_param = "&voiceBridge=" + urlEncode(voiceBridge.toString()); + } else { + // No voice bridge number passed, so we'll generate a random one for this meeting + Random random = new Random(); + Integer n = 70000 + random.nextInt(9999); + voice_bridge_param = "&voiceBridge=" + n; + } + + if ((logoutURL != null) && !logoutURL.equals("")) { + logoutURL_param = "&logoutURL=" + urlEncode(logoutURL); + } + + // + // Now create the URL + // + + String create_parameters = "name=" + urlEncode(meetingID) + + "&meetingID=" + urlEncode(meetingID) + welcome_param + + attendee_password_param + moderator_password_param + + moderatorWelcomeMsg_param + voice_bridge_param + logoutURL_param; + + Document doc = null; + + try { + // Attempt to create a meeting using meetingID + String xml = getURL(base_url_create + create_parameters + + "&checksum=" + + checksum("create" + create_parameters + salt)); + doc = parseXml(xml); + } catch (Exception e) { + e.printStackTrace(); + } + + if (doc.getElementsByTagName("returncode").item(0).getTextContent().trim().equals("SUCCESS")) { + return meetingID; + } + + return "Error " + + doc.getElementsByTagName("messageKey").item(0).getTextContent().trim() + + ": " + + doc.getElementsByTagName("message").item(0).getTextContent() + .trim(); +} + +// +// getJoinMeetingURL() -- get join meeting URL for both viewer and moderator as guest +// + +public String getJoinMeetingURL(String username, String meetingID, String password, String clientURL, Boolean guest) { + String base_url_join = BigBlueButtonURL + "api/join?"; + String clientURL_param = ""; + + if ((clientURL != null) && !clientURL.equals("")) { + clientURL_param = "&redirectClient=true&clientURL=" + urlEncode( clientURL ); + } + + + String join_parameters = "meetingID=" + urlEncode(meetingID) + + "&fullName=" + urlEncode(username) + "&password=" + + urlEncode(password) + "&guest=" + urlEncode(guest.toString()) + clientURL_param; + + return base_url_join + join_parameters + "&checksum=" + + checksum("join" + join_parameters + salt); +} + +// +// getJoinMeetingURL() -- get join meeting URL for both viewer and moderator +// +public String getJoinMeetingURL(String username, String meetingID, String password, String clientURL) { + String base_url_join = BigBlueButtonURL + "api/join?"; + String clientURL_param = ""; + + if ((clientURL != null) && !clientURL.equals("")) { + clientURL_param = "&redirectClient=true&clientURL=" + urlEncode( clientURL ); + } + + + String join_parameters = "meetingID=" + urlEncode(meetingID) + + "&fullName=" + urlEncode(username) + "&password=" + + urlEncode(password) + clientURL_param; + + return base_url_join + join_parameters + "&checksum=" + + checksum("join" + join_parameters + salt); +} + + + + +// +// Create a meeting and return a URL to join it as moderator. This is used for the API demos. +// +// Passed +// - username +// - meetingID +// - record ["true", "false"] +// - welcome message (null causes BigBlueButton to use the default welcome message +// - metadata (passed through when record="true" +// - xml (used for pre-upload of slides)_ +// +// Returned +// - valid join URL using the username +// +// Note this meeting will use username for meetingID + +public String getJoinURL(String username, String meetingID, String record, String welcome, Map metadata, String xml) { + String base_url_create = BigBlueButtonURL + "api/create?"; + String base_url_join = BigBlueButtonURL + "api/join?"; + + String welcome_param = ""; + if ((welcome != null) && !welcome.equals("")) { + welcome_param = "&welcome=" + urlEncode(welcome); + } + + String xml_param = ""; + if ((xml != null) && !xml.equals("")) { + xml_param = xml; + } + + Random random = new Random(); + String voiceBridge_param = "&voiceBridge=" + (70000 + random.nextInt(9999)); + + // + // When creating a meeting, the 'name' parameter is the name of the meeting (not to be confused with + // the username). For example, the name could be "Fred's meeting" and the meetingID could be "ID-1234312". + // + // While name and meetingID should be different, we'll keep them the same. Why? Because calling api/create? + // with a previously used meetingID will return same meetingToken (regardless if the meeting is running or not). + // + // This means the first person to call getJoinURL with meetingID="Demo Meeting" will actually create the + // meeting. Subsequent calls will return the same meetingToken and thus subsequent users will join the same + // meeting. + // + // Note: We're hard-coding the password for moderator and attendee (viewer) for purposes of demo. + // + + String create_parameters = "name=" + urlEncode(meetingID) + + "&meetingID=" + urlEncode(meetingID) + welcome_param + voiceBridge_param + + "&attendeePW=ap&moderatorPW=mp" + + "&record=" + record + getMetaData( metadata ); + + + // Attempt to create a meeting using meetingID + Document doc = null; + try { + String url = base_url_create + create_parameters + + "&checksum=" + + checksum("create" + create_parameters + salt); + doc = parseXml( postURL( url, xml_param ) ); + } catch (Exception e) { + e.printStackTrace(); + } + + if (doc.getElementsByTagName("returncode").item(0).getTextContent() + .trim().equals("SUCCESS")) { + + // + // Looks good, now return a URL to join that meeting + // + + String join_parameters = "meetingID=" + urlEncode(meetingID) + + "&fullName=" + urlEncode(username) + "&password=mp"; + + return base_url_join + join_parameters + "&checksum=" + + checksum("join" + join_parameters + salt); + } + + return doc.getElementsByTagName("messageKey").item(0).getTextContent() + .trim() + + ": " + + doc.getElementsByTagName("message").item(0).getTextContent() + .trim(); +} + + +///////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////// +public String getJoinURLwithDynamicConfigXML(String username, String meetingID, String configXML) { + + String base_url_create = BigBlueButtonURL + "api/create?"; + String base_url_join = BigBlueButtonURL + "api/join?"; + String base_url_setConfigXML = BigBlueButtonURL + "api/setConfigXML.xml?"; + + Random random = new Random(); + String voiceBridge_param = "&voiceBridge=" + (70000 + random.nextInt(9999)); + + String url; + // + // When creating a meeting, the 'name' parameter is the name of the meeting (not to be confused with + // the username). For example, the name could be "Fred's meeting" and the meetingID could be "ID-1234312". + // + // While name and meetingID should be different, we'll keep them the same. Why? Because calling api/create? + // with a previously used meetingID will return same meetingToken (regardless if the meeting is running or not). + // + // This means the first person to call getJoinURL with meetingID="Demo Meeting" will actually create the + // meeting. Subsequent calls will return the same meetingToken and thus subsequent users will join the same + // meeting. + // + // Note: We're hard-coding the password for moderator and attendee (viewer) for purposes of demo. + // + + String create_parameters = "name=" + urlEncode(meetingID) + + "&meetingID=" + urlEncode(meetingID) + voiceBridge_param + + "&attendeePW=ap&moderatorPW=mp"; + + + // Attempt to create a meeting using meetingID + Document doc = null; + url = ""; + try { + url = base_url_create + create_parameters + + "&checksum=" + + checksum("create" + create_parameters + salt); + doc = parseXml( postURL( url, "" ) ); + } catch (Exception e) { + e.printStackTrace(); + } + + if (!doc.getElementsByTagName("returncode").item(0).getTextContent().trim().equals("SUCCESS")) { + // + // Someting went wrong, return the error + // + return " " + url + "
" + doc.getElementsByTagName("messageKey").item(0).getTextContent() + .trim() + + ": " + + doc.getElementsByTagName("message").item(0).getTextContent() + .trim(); + } + + + // + // Looks good, now Attempt to send the ConfigXML file and get the token + // + + String xml_param = ""; + if ((configXML != null) && !configXML.equals("")) { + xml_param = configXML; + xml_param = xml_param.replace("\n", ""); + xml_param = xml_param.replace("\t", ""); + xml_param = xml_param.replace("> <", "><"); + xml_param = xml_param.replace("> <", "><"); + } + + // Create the parameters we want to send to the server. + Map paramsMap = new HashMap(); + paramsMap.put("meetingID", new String[]{urlEncode(meetingID)}); + paramsMap.put("configXML", new String[]{urlEncode(xml_param)}); + + String baseString = createBaseString(paramsMap); + + String setConfigXML_parameters = baseString + "&checksum=" + checksum("setConfigXML" + baseString + salt); + + try { + doc = parseXml( postURL( base_url_setConfigXML, setConfigXML_parameters, "application/x-www-form-urlencoded" ) ); + } catch (Exception e) { + e.printStackTrace(); + } + + String configToken = ""; + if (!doc.getElementsByTagName("returncode").item(0).getTextContent().trim().equals("SUCCESS")) { + // + // Someting went wrong, return the error + // + return " " + base_url_setConfigXML + "
" + doc.getElementsByTagName("messageKey").item(0).getTextContent().trim() + + ": " + + doc.getElementsByTagName("message").item(0).getTextContent().trim() + "
" + encodeURIComponent(xml_param); + } else { + configToken = doc.getElementsByTagName("configToken").item(0).getTextContent().trim(); + } + + // + // And finally return a URL to join that meeting using the specific config.xml + // + String join_parameters = "meetingID=" + urlEncode(meetingID) + "&fullName=" + urlEncode(username) + "&password=mp&configToken=" + configToken; + + return base_url_join + join_parameters + "&checksum=" + checksum("join" + join_parameters + salt); + +} + +// From the list of parameters we want to pass. Creates a base string with parameters +// sorted in alphabetical order for us to sign. +public String createBaseString(Map params) { + StringBuffer csbuf = new StringBuffer(); + SortedSet keys = new TreeSet(params.keySet()); + + boolean first = true; + String checksum = null; + for (String key: keys) { + for (String value: params.get(key)) { + if (first) { + first = false; + } else { + csbuf.append("&"); + } + csbuf.append(key); + csbuf.append("="); + csbuf.append(value); + } + } + + return csbuf.toString(); +} + + +// +// Create a meeting and return a URL to join it as moderator +// +public String getJoinURLXML(String username, String meetingID, String welcome, String xml) { + String base_url_create = BigBlueButtonURL + "api/create?"; + String base_url_join = BigBlueButtonURL + "api/join?"; + + String welcome_param = ""; + + Random random = new Random(); + Integer voiceBridge = 70000 + random.nextInt(9999); + + if ((welcome != null) && !welcome.equals("")) { + welcome_param = "&welcome=" + urlEncode(welcome); + } + + String xml_param = ""; + if ((xml != null) && !xml.equals("")) { + xml_param = xml; + } + + String create_parameters = "name=" + urlEncode(meetingID) + + "&meetingID=" + urlEncode(meetingID) + welcome_param + + "&attendeePW=ap&moderatorPW=mp&voiceBridge=" + voiceBridge; + + Document doc = null; + + try { + // Attempt to create a meeting using meetingID + String params = postURL(base_url_create + create_parameters + + "&checksum=" + + checksum("create" + create_parameters + salt), xml_param); + doc = parseXml(params); + } catch (Exception e) { + e.printStackTrace(); + } + + if (doc.getElementsByTagName("returncode").item(0).getTextContent() + .trim().equals("SUCCESS")) { + + String join_parameters = "meetingID=" + urlEncode(meetingID) + + "&fullName=" + urlEncode(username) + "&password=mp"; + + return base_url_join + join_parameters + "&checksum=" + + checksum("join" + join_parameters + salt); + } + + return doc.getElementsByTagName("messageKey").item(0).getTextContent() + .trim() + + ": " + + doc.getElementsByTagName("message").item(0).getTextContent() + .trim(); +} + +// +// getJoinURLViewer() -- Get the URL to join a meeting as viewer +// +public String getJoinURLViewer(String username, String meetingID) { + String base_url_join = BigBlueButtonURL + "api/join?"; + String join_parameters = "meetingID=" + urlEncode(meetingID) + + "&fullName=" + urlEncode(username) + "&password=ap"; + + return base_url_join + join_parameters + "&checksum=" + + checksum("join" + join_parameters + salt); +} + + +// +// getURLisMeetingRunning() -- return a URL that the client can use to poll for whether the given meeting is running +// +public String getURLisMeetingRunning(String meetingID) { + String meetingParameters = "meetingID=" + urlEncode(meetingID); + return BigBlueButtonURL + "api/isMeetingRunning?" + meetingParameters + + "&checksum=" + + checksum("isMeetingRunning" + meetingParameters + salt); +} + +// +// isMeetingRunning() -- check the BigBlueButton server to see if the meeting is running (i.e. there is someone in the meeting) +// +public String isMeetingRunning(String meetingID) { + Document doc = null; + try { + doc = parseXml( getURL( getURLisMeetingRunning(meetingID) )); + } catch (Exception e) { + e.printStackTrace(); + } + + if (doc.getElementsByTagName("returncode").item(0).getTextContent() + .trim().equals("SUCCESS")) { + return doc.getElementsByTagName("running").item(0).getTextContent() + .trim(); + } + + return "Error " + + doc.getElementsByTagName("messageKey").item(0) + .getTextContent().trim() + + ": " + + doc.getElementsByTagName("message").item(0).getTextContent() + .trim(); +} + +public String getMeetingInfoURL(String meetingID, String password) { + String meetingParameters = "meetingID=" + urlEncode(meetingID) + + "&password=" + password; + return BigBlueButtonURL + "api/getMeetingInfo?" + meetingParameters + + "&checksum=" + + checksum("getMeetingInfo" + meetingParameters + salt); +} + +public String getMeetingInfo(String meetingID, String password) { + try { + return getURL( getMeetingInfoURL(meetingID, password)); + } catch (Exception e) { + e.printStackTrace(System.out); + return null; + } +} + +public String getDefaultConfigXML() { + try { + return getURL( getDefaultConfigXMLURL() ); + } catch (Exception e) { + e.printStackTrace(System.out); + return null; + } +} + +public String getDefaultConfigXMLURL() { + String meetingParameters = ""; + return BigBlueButtonURL + "api/getDefaultConfigXML?" + meetingParameters + + "&checksum=" + + checksum("getDefaultConfigXML" + meetingParameters + salt); +} + +public String getMeetingsURL() { + String meetingParameters = "random=" + new Random().nextInt(9999); + return BigBlueButtonURL + "api/getMeetings?" + meetingParameters + + "&checksum=" + + checksum("getMeetings" + meetingParameters + salt); +} + +// +// Calls getMeetings to obtain the list of meetings, then calls getMeetingInfo for each meeting +// and concatenates the result. +// +public String getMeetings() { + try { + Document doc = parseXml( getURL( getMeetingsURL() )); + + // tags needed for parsing xml documents + final String startTag = ""; + final String endTag = ""; + final String startResponse = ""; + final String endResponse = ""; + + // if the request succeeded, then calculate the checksum of each meeting and insert it into the document + NodeList meetingsList = doc.getElementsByTagName("meeting"); + + String newXMldocument = startTag; + for (int i = 0; i < meetingsList.getLength(); i++) { + Element meeting = (Element) meetingsList.item(i); + String meetingID = meeting.getElementsByTagName("meetingID").item(0).getTextContent(); + String password = meeting.getElementsByTagName("moderatorPW").item(0).getTextContent(); + + String data = getURL( getMeetingInfoURL(meetingID, password) ); + + if (data.indexOf("") != -1) { + int startIndex = data.indexOf(startResponse) + startTag.length(); + int endIndex = data.indexOf(endResponse); + newXMldocument += "" + data.substring(startIndex, endIndex) + ""; + } + } + newXMldocument += endTag; + + return newXMldocument; + } catch (Exception e) { + e.printStackTrace(System.out); + return null; + } +} + + + +public String getendMeetingURL(String meetingID, String moderatorPassword) { + String end_parameters = "meetingID=" + urlEncode(meetingID) + "&password=" + + urlEncode(moderatorPassword); + return BigBlueButtonURL + "api/end?" + end_parameters + "&checksum=" + + checksum("end" + end_parameters + salt); +} + +public String endMeeting(String meetingID, String moderatorPassword) { + + Document doc = null; + try { + String xml = getURL(getendMeetingURL(meetingID, moderatorPassword)); + doc = parseXml(xml); + } catch (Exception e) { + e.printStackTrace(); + } + + if (doc.getElementsByTagName("returncode").item(0).getTextContent() + .trim().equals("SUCCESS")) { + return "true"; + } + + return "Error " + + doc.getElementsByTagName("messageKey").item(0) + .getTextContent().trim() + + ": " + + doc.getElementsByTagName("message").item(0).getTextContent() + .trim(); +} + + +////////////////////////////////////////////////////////////////////////////// +// +// Added for BigBlueButton 0.8 +// +////////////////////////////////////////////////////////////////////////////// + +public String getRecordingsURL(String meetingID) { + String record_parameters = "meetingID=" + urlEncode(meetingID); + return BigBlueButtonURL + "api/getRecordings?" + record_parameters + "&checksum=" + + checksum("getRecordings" + record_parameters + salt); +} + +public String getRecordings(String meetingID) { + //recordID,name,description,starttime,published,playback,length + String newXMLdoc = ""; + + try { + Document doc = null; + String url = getRecordingsURL(meetingID); + doc = parseXml( getURL(url) ); + + // if the request succeeded, then calculate the checksum of each meeting and insert it into the document + NodeList recordingList = doc.getElementsByTagName("recording"); + + + for (int i = 0; i < recordingList.getLength(); i++) { + Element recording = (Element) recordingList.item(i); + + if(recording.getElementsByTagName("recordID").getLength()>0){ + + String recordID = recording.getElementsByTagName("recordID").item(0).getTextContent(); + String name = recording.getElementsByTagName("name").item(0).getTextContent(); + String description = ""; + NodeList metadata = recording.getElementsByTagName("metadata"); + if(metadata.getLength()>0){ + Element metadataElem = (Element) metadata.item(0); + if(metadataElem.getElementsByTagName("description").getLength() > 0){ + description = metadataElem.getElementsByTagName("description").item(0).getTextContent(); + } + } + + String starttime = recording.getElementsByTagName("startTime").item(0).getTextContent(); + try{ + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + Date resultdate = new Date(Long.parseLong(starttime)); + starttime = sdf.format(resultdate); + }catch(Exception e){ + + } + String published = recording.getElementsByTagName("published").item(0).getTextContent(); + String playback = ""; + String length = ""; + NodeList formats = recording.getElementsByTagName("format"); + for (int j = 0; j < formats.getLength(); j++){ + Element format = (Element) formats.item(j); + + String typeP = format.getElementsByTagName("type").item(0).getTextContent(); + String urlP = format.getElementsByTagName("url").item(0).getTextContent(); + String lengthP = format.getElementsByTagName("length").item(0).getTextContent(); + + if (j != 0){ + playback +=", "; + } + playback += StringEscapeUtils.escapeXml("" + typeP + ""); + + if(typeP.equalsIgnoreCase("slides") || typeP.equalsIgnoreCase("presentation")){ + length = lengthP; + } + } + + newXMLdoc += ""; + + newXMLdoc += "" + recordID + ""; + newXMLdoc += ""; + newXMLdoc += ""; + newXMLdoc += "" + starttime + ""; + newXMLdoc += "" + published + ""; + newXMLdoc += "" + playback + ""; + newXMLdoc += "" + length + ""; + + newXMLdoc += ""; + } + } + }catch (Exception e) { + e.printStackTrace(System.out); + return "error: "+e.getMessage(); + } + newXMLdoc += ""; + return newXMLdoc; +} + +public String getPublishRecordingsURL(boolean publish, String recordID) { + String publish_parameters = "recordID=" + urlEncode(recordID) + + "&publish=" + publish; + return BigBlueButtonURL + "api/publishRecordings?" + publish_parameters + "&checksum=" + + checksum("publishRecordings" + publish_parameters + salt); +} + +public String setPublishRecordings(boolean publish, String recordID){ + try { + return getURL( getPublishRecordingsURL(publish,recordID)); + } catch (Exception e) { + e.printStackTrace(System.out); + return null; + } +} + +public String getDeleteRecordingsURL(String recordID) { + String delete_parameters = "recordID=" + urlEncode(recordID); + return BigBlueButtonURL + "api/deleteRecordings?" + delete_parameters + "&checksum=" + + checksum("deleteRecordings" + delete_parameters + salt); +} + +public String deleteRecordings(String recordID){ + try { + return getURL( getDeleteRecordingsURL(recordID)); + } catch (Exception e) { + e.printStackTrace(System.out); + return null; + } +} + + + +////////////////////////////////////////////////////////////////////////////// +// +// Helper Routines +// +////////////////////////////////////////////////////////////////////////////// + +public String getMetaData( Map metadata ) { + String metadata_params = ""; + + if ( metadata!=null ){ + for(String metakey : metadata.keySet()){ + metadata_params = metadata_params + "&meta_" + urlEncode(metakey) + "=" + urlEncode(metadata.get(metakey)); + } + } + + return metadata_params; +} + +// +// checksum() -- Return a checksum based on SHA-1 digest +// +public static String checksum(String s) { + String checksum = ""; + try { + checksum = org.apache.commons.codec.digest.DigestUtils.shaHex(s); + } catch (Exception e) { + e.printStackTrace(); + } + return checksum; +} + +// +// getURL() -- fetch a URL and return its contents as a String +// +public static String getURL(String url) { + StringBuffer response = null; + + try { + URL u = new URL(url); + HttpURLConnection httpConnection = (HttpURLConnection) u.openConnection(); + + httpConnection.setUseCaches(false); + httpConnection.setDoOutput(true); + httpConnection.setRequestMethod("GET"); + + httpConnection.connect(); + int responseCode = httpConnection.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { + InputStream input = httpConnection.getInputStream(); + + // Read server's response. + response = new StringBuffer(); + Reader reader = new InputStreamReader(input, "UTF-8"); + reader = new BufferedReader(reader); + char[] buffer = new char[1024]; + for (int n = 0; n >= 0;) { + n = reader.read(buffer, 0, buffer.length); + if (n > 0) + response.append(buffer, 0, n); + } + + input.close(); + httpConnection.disconnect(); + } + } catch (Exception e) { + e.printStackTrace(); + } + + if (response != null) { + return response.toString(); + } else { + return ""; + } +} + +public static String postURL(String targetURL, String urlParameters) +{ + return postURL(targetURL, urlParameters, "text/xml"); +} + +public static String postURL(String targetURL, String urlParameters, String contentType) +{ + URL url; + HttpURLConnection connection = null; + int responseCode = 0; + try { + //Create connection + url = new URL(targetURL); + connection = (HttpURLConnection)url.openConnection(); + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", contentType); + + connection.setRequestProperty("Content-Length", "" + + Integer.toString(urlParameters.getBytes().length)); + connection.setRequestProperty("Content-Language", "en-US"); + + connection.setUseCaches (false); + connection.setDoInput(true); + connection.setDoOutput(true); + + //Send request + DataOutputStream wr = new DataOutputStream ( + connection.getOutputStream ()); + wr.writeBytes (urlParameters); + wr.flush (); + wr.close (); + + //Get Response + InputStream is = connection.getInputStream(); + BufferedReader rd = new BufferedReader(new InputStreamReader(is)); + String line; + StringBuffer response = new StringBuffer(); + while((line = rd.readLine()) != null) { + response.append(line); + response.append('\r'); + } + rd.close(); + return response.toString(); + + } catch (Exception e) { + + e.printStackTrace(); + return null; + + } finally { + + if(connection != null) { + connection.disconnect(); + } + } +} + +// +// parseXml() -- return a DOM of the XML +// +public static Document parseXml(String xml) +throws ParserConfigurationException, IOException, SAXException { + DocumentBuilderFactory docFactory = DocumentBuilderFactory + .newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + Document doc = docBuilder.parse(new InputSource(new StringReader(xml))); + return doc; +} + +// +// urlEncode() -- URL encode the string +// +public static String urlEncode(String s) { + try { + return URLEncoder.encode(s, "UTF-8"); + } catch (Exception e) { + e.printStackTrace(); + } + return ""; +} + +// +//encodeURIComponent() -- Java encoding similiar to JavaScript encodeURIComponent +// +public static String encodeURIComponent(String component) { + String result = null; + + try { + result = URLEncoder.encode(component, "UTF-8") + .replaceAll("\\%28", "(") + .replaceAll("\\%29", ")") + .replaceAll("\\+", "%20") + .replaceAll("\\%27", "'") + .replaceAll("\\%21", "!") + .replaceAll("\\%7E", "~"); + } catch (UnsupportedEncodingException e) { + result = component; + } + + return result; +} + +public String getMeetingsWithoutPasswords() { + try { + Document doc = parseXml( getURL( getMeetingsURL() )); + + // tags needed for parsing xml documents + final String startTag = ""; + final String endTag = ""; + final String startResponse = ""; + final String endResponse = ""; + + // if the request succeeded, then calculate the checksum of each meeting and insert it into the document + NodeList meetingsList = doc.getElementsByTagName("meeting"); + + String newXMldocument = startTag; + for (int i = 0; i < meetingsList.getLength(); i++) { + Element meeting = (Element) meetingsList.item(i); + String meetingID = meeting.getElementsByTagName("meetingID").item(0).getTextContent(); + String password = meeting.getElementsByTagName("moderatorPW").item(0).getTextContent(); + + String data = getURL( getMeetingInfoURL(meetingID, password) ); + + if (data.indexOf("") != -1) { + data = removeTag(data, "", ""); + data = removeTag(data, "", ""); + + int startIndex = data.indexOf(startResponse) + startResponse.length(); + int endIndex = data.indexOf(endResponse); + newXMldocument += "" + data.substring(startIndex, endIndex) + ""; + } + } + newXMldocument += endTag; + + return newXMldocument; + } catch (Exception e) { + e.printStackTrace(System.out); + return null; + } +} + +public static String removeTag(String data, String startTag, String endTag){ + int startIndex = data.indexOf(startTag); + int endIndex = data.indexOf(endTag) + endTag.length(); + String tagStr = data.substring(startIndex, endIndex); + return data.replace(tagStr,""); +} + +public String getBigBlueButtonIP() +{ + try { + URL url = new URL(BigBlueButtonURL); + String bbbIP = url.getHost(); + return bbbIP; + } catch (Exception e) { + e.printStackTrace(); + return "localhost"; + } +} + +public static Element getElementWithAttribute(Node root, String attrName, String attrValue) +{ + NodeList nl = root.getChildNodes(); + for (int i = 0; i < nl.getLength(); i++) { + Node n = nl.item(i); + if (n instanceof Element) { + Element el = (Element) n; + if (el.getAttribute(attrName).equals(attrValue)) { + return el; + }else{ + el = getElementWithAttribute(n, attrName, attrValue); //search recursively + if(el != null){ + return el; + } + } + } + } + return null; +} + +%> diff --git a/bbb-api-demo/src/main/webapp/demo3.jsp b/bbb-api-demo/src/main/webapp/demo3.jsp index 76dceabce4..13ca4b343c 100755 --- a/bbb-api-demo/src/main/webapp/demo3.jsp +++ b/bbb-api-demo/src/main/webapp/demo3.jsp @@ -19,8 +19,7 @@ with BigBlueButton; if not, If not, see . Author: Fred Dixon --> - -<%@ page language="java" contentType="text/html; charset=UTF-8" + <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% request.setCharacterEncoding("UTF-8"); @@ -283,7 +282,7 @@ Error: createMeeting() failed // // We've got a valid meeting_ID and passoword -- let's join! // - + String joinURL; if(request.getParameter("guest") != null) joinURL = getJoinMeetingURL(username, meeting_ID, password, null, true); diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/BigBlueButtonApplication.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/BigBlueButtonApplication.java index 0c47ca3849..6a66336bf2 100755 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/BigBlueButtonApplication.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/BigBlueButtonApplication.java @@ -137,7 +137,7 @@ public class BigBlueButtonApplication extends MultiThreadedApplicationAdapter { if (params.length >= 10 && ((Boolean) params[10])) { guest = true; } - + if (record == true) { recorderApplication.createRecordSession(room); } diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsApplication.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsApplication.java index 0e61efb0da..7601a299c5 100644 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsApplication.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsApplication.java @@ -79,32 +79,16 @@ public class ParticipantsApplication { bbbInGW.getRecordingStatus(meetingId, userId); } - public void askingToEnter(String meetingId, String userId) { - bbbInGW.userRequestToEnter(meetingId, userId); - } - public void getGuestPolicy(String meetingId, String requesterId) { bbbInGW.getGuestPolicy(meetingId, requesterId); } - public void newGuestPolicy(String meetingId, String guestPolicy) { - bbbInGW.setGuestPolicy(meetingId, guestPolicy); + public void newGuestPolicy(String meetingId, String guestPolicy, String setBy) { + bbbInGW.setGuestPolicy(meetingId, guestPolicy, setBy); } - public void askingForGuestWaiting(String meetingId, String requesterId) { - bbbInGW.getGuestsWaiting(meetingId, requesterId); - } - - public void responseToGuest(String meetingId, String userId, Boolean resp) { - bbbInGW.responseToGuest(meetingId, userId, resp); - } - - public void responseToAllGuests(String meetingId, Boolean resp) { - bbbInGW.responseToAllGuests(meetingId, resp); - } - - public void kickGuest(String meetingId, String guestId) { - bbbInGW.kickGuest(meetingId, guestId); + public void responseToGuest(String meetingId, String userId, Boolean response, String requesterId) { + bbbInGW.responseToGuest(meetingId, userId, response, requesterId); } public void setParticipantRole(String meetingId, String userId, String role) { diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsService.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsService.java index c0b1546313..6f2e945e71 100644 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsService.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsService.java @@ -99,12 +99,6 @@ public class ParticipantsService { return (BigBlueButtonSession) Red5.getConnectionLocal().getAttribute(Constants.SESSION); } - public void askingToEnter() { - String userId = getBbbSession().getInternalUserID(); - String roomName = Red5.getConnectionLocal().getScope().getName(); - application.askingToEnter(roomName, userId); - } - public void getGuestPolicy() { String requesterId = getBbbSession().getInternalUserID(); String roomName = Red5.getConnectionLocal().getScope().getName(); @@ -112,29 +106,15 @@ public class ParticipantsService { } public void setGuestPolicy(String guestPolicy) { + String requesterId = getBbbSession().getInternalUserID(); String roomName = Red5.getConnectionLocal().getScope().getName(); - application.newGuestPolicy(roomName, guestPolicy); - } - - public void getGuestsWaiting() { - String userId = getBbbSession().getInternalUserID(); - String roomName = Red5.getConnectionLocal().getScope().getName(); - application.askingForGuestWaiting(roomName, userId); - } - - public void responseToAllGuests(Boolean resp) { - String roomName = Red5.getConnectionLocal().getScope().getName(); - application.responseToAllGuests(roomName, resp); + application.newGuestPolicy(roomName, guestPolicy, requesterId); } public void responseToGuest(Map msg) { + String requesterId = getBbbSession().getInternalUserID(); String roomName = Red5.getConnectionLocal().getScope().getName(); - application.responseToGuest(roomName, (String) msg.get("guestID"), (Boolean) msg.get("response")); - } - - public void kickGuest(String guestId) { - String roomName = Red5.getConnectionLocal().getScope().getName(); - application.kickGuest(roomName, guestId); + application.responseToGuest(roomName, (String) msg.get("userId"), (Boolean) msg.get("response"), requesterId); } public void setParticipantRole(Map msg) { diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java index 1dfc6008cd..0ed57dd0f2 100644 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java @@ -44,13 +44,9 @@ public interface IBigBlueButtonInGW { void getRecordingStatus(String meetingId, String userId); void userConnectedToGlobalAudio(String voiceConf, String userid, String name); void userDisconnectedFromGlobalAudio(String voiceConf, String userid, String name); - void userRequestToEnter(String meetingID, String userID); void getGuestPolicy(String meetingID, String userID); - void setGuestPolicy(String meetingID, String guestPolicy); - void getGuestsWaiting(String meetingID, String requesterID); - void responseToGuest(String meetingID, String userID, Boolean response); - void responseToAllGuests(String meetingID, Boolean response); - void kickGuest(String meetingID, String guestID); + void setGuestPolicy(String meetingID, String guestPolicy, String setBy); + void responseToGuest(String meetingID, String userID, Boolean response, String requesterID); // Voice void muteAllExceptPresenter(String meetingID, String requesterID, Boolean mute); diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala index ec9f2c2976..a97e9cd8d0 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala @@ -198,15 +198,11 @@ class BigBlueButtonInGW(bbbGW: BigBlueButtonGateway, presUtil: PreuploadedPresen } // Guest support - def userRequestToEnter(meetingID: String, userID: String) { - bbbGW.accept(new UserRequestToEnter(meetingID, userID)) - } - def getGuestPolicy(meetingID: String, requesterID: String) { bbbGW.accept(new GetGuestPolicy(meetingID, requesterID)) } - def setGuestPolicy(meetingID: String, guestPolicy: String) { + def setGuestPolicy(meetingID: String, guestPolicy: String, setBy: String) { val policy = guestPolicy.toUpperCase() match { case "ALWAYS_ACCEPT" => GuestPolicy.ALWAYS_ACCEPT case "ALWAYS_DENY" => GuestPolicy.ALWAYS_DENY @@ -214,25 +210,13 @@ class BigBlueButtonInGW(bbbGW: BigBlueButtonGateway, presUtil: PreuploadedPresen //default case undef => GuestPolicy.ASK_MODERATOR } - bbbGW.accept(new SetGuestPolicy(meetingID, policy)) + bbbGW.accept(new SetGuestPolicy(meetingID, policy, setBy)) } - def getGuestsWaiting(meetingID: String, requesterID: String) { - bbbGW.accept(new GetGuestsWaiting(meetingID, requesterID)) + def responseToGuest(meetingID: String, userId: String, response: java.lang.Boolean, requesterID: String) { + bbbGW.accept(new RespondToGuest(meetingID, userId, response, requesterID)) } - - def responseToGuest(meetingID: String, guestID: String, response: java.lang.Boolean) { - bbbGW.accept(new RespondToGuest(meetingID, guestID, response)) - } - - def responseToAllGuests(meetingID: String, response: java.lang.Boolean) { - bbbGW.accept(new RespondToAllGuests(meetingID, response)) - } - - def kickGuest(meetingID: String, guestID: String) { - bbbGW.accept(new KickGuest(meetingID, guestID)) - } - + /************************************************************************************** * Message Interface for Presentation **************************************************************************************/ diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/CollectorActor.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/CollectorActor.scala index bae51c4979..256f56949a 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/CollectorActor.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/CollectorActor.scala @@ -98,12 +98,9 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { case msg: EnableWhiteboardRequest => handleEnableWhiteboardRequest(msg) case msg: IsWhiteboardEnabledRequest => handleIsWhiteboardEnabledRequest(msg) case msg: GetStreamPath => handleGetStreamPath(msg) - case msg: UserRequestToEnter => handleUserRequestToEnter(msg) case msg: GetGuestPolicy => handleGetGuestPolicy(msg) case msg: SetGuestPolicy => handleSetGuestPolicy(msg) - case msg: GetGuestsWaiting => handleGetGuestsWaiting(msg) case msg: RespondToGuest => handleRespondToGuest(msg) - case msg: KickGuest => handleKickGuest(msg) case msg: GetAllMeetingsRequest => handleGetAllMeetingsRequest(msg) //OUT MESSAGES @@ -184,12 +181,9 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { case msg: UndoWhiteboardEvent => handleUndoWhiteboardEvent(msg) case msg: WhiteboardEnabledEvent => handleWhiteboardEnabledEvent(msg) case msg: IsWhiteboardEnabledReply => handleIsWhiteboardEnabledReply(msg) - case msg: GuestRequestedToEnter => handleGuestRequestedToEnter(msg) case msg: GetGuestPolicyReply => handleGetGuestPolicyReply(msg) case msg: GuestPolicyChanged => handleGuestPolicyChanged(msg) - case msg: GetGuestsWaitingReply => handleGetGuestsWaitingReply(msg) - case msg: ResponseToGuest => handleResponseToGuest(msg) - case msg: GuestKicked => handleGuestKicked(msg) + case msg: GuestAccessDenied => handleGuestAccessDenied(msg) case msg: GetAllMeetingsReply => handleGetAllMeetingsReply(msg) case _ => // do nothing @@ -220,6 +214,8 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { wuser.put(Constants.LOCKED, user.locked:java.lang.Boolean) wuser.put(Constants.WEBCAM_STREAM, user.webcamStreams) wuser.put(Constants.PHONE_USER, user.phoneUser:java.lang.Boolean) + wuser.put(Constants.GUEST, user.guest:java.lang.Boolean) + wuser.put(Constants.WAITING_FOR_ACCEPTANCE, user.waitingForAcceptance:java.lang.Boolean) wuser.put(Constants.VOICE_USER, vuser) wuser @@ -2223,20 +2219,6 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { dispatcher.dispatch(buildJson(header, payload)) } - private def handleUserRequestToEnter(msg: UserRequestToEnter) { - val payload = new java.util.HashMap[String, Any]() - payload.put(Constants.MEETING_ID, msg.meetingID) - payload.put(Constants.USER_ID, msg.userID) - - val header = new java.util.HashMap[String, Any]() - header.put(Constants.NAME, MessageNames.USER_REQUEST_TO_ENTER) - header.put(Constants.TIMESTAMP, TimestampGenerator.generateTimestamp) - header.put(Constants.CURRENT_TIME, TimestampGenerator.getCurrentTime) - -// println("***** DISPATCHING USER REQUEST TO ENTER *****************") - dispatcher.dispatch(buildJson(header, payload)) - } - private def handleGetGuestPolicy(msg: GetGuestPolicy) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) @@ -2265,25 +2247,12 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { dispatcher.dispatch(buildJson(header, payload)) } - private def handleGetGuestsWaiting(msg: GetGuestsWaiting) { - val payload = new java.util.HashMap[String, Any]() - payload.put(Constants.MEETING_ID, msg.meetingID) - payload.put(Constants.REQUESTER_ID, msg.requesterID) - - val header = new java.util.HashMap[String, Any]() - header.put(Constants.NAME, MessageNames.GET_GUESTS_WAITING) - header.put(Constants.TIMESTAMP, TimestampGenerator.generateTimestamp) - header.put(Constants.CURRENT_TIME, TimestampGenerator.getCurrentTime) - -// println("***** DISPATCHING GET GUESTS WAITING *****************") - dispatcher.dispatch(buildJson(header, payload)) - } - private def handleRespondToGuest(msg: RespondToGuest) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) - payload.put(Constants.USER_ID, msg.guestID) + payload.put(Constants.USER_ID, msg.userId) payload.put(Constants.RESPONSE, msg.response.toString()) + payload.put(Constants.REQUESTER_ID, msg.requesterID) val header = new java.util.HashMap[String, Any]() header.put(Constants.NAME, MessageNames.RESPOND_TO_GUEST) @@ -2294,35 +2263,6 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { dispatcher.dispatch(buildJson(header, payload)) } - private def handleKickGuest(msg: KickGuest) { - val payload = new java.util.HashMap[String, Any]() - payload.put(Constants.MEETING_ID, msg.meetingID) - payload.put(Constants.USER_ID, msg.guestID) - - val header = new java.util.HashMap[String, Any]() - header.put(Constants.NAME, MessageNames.KICK_GUEST) - header.put(Constants.TIMESTAMP, TimestampGenerator.generateTimestamp) - header.put(Constants.CURRENT_TIME, TimestampGenerator.getCurrentTime) - -// println("***** DISPATCHING KICK GUEST *****************") - dispatcher.dispatch(buildJson(header, payload)) - } - - private def handleGuestRequestedToEnter(msg: GuestRequestedToEnter) { - val payload = new java.util.HashMap[String, Any]() - payload.put(Constants.MEETING_ID, msg.meetingID) - payload.put(Constants.USER_ID, msg.userID) - payload.put(Constants.NAME, msg.name) - - val header = new java.util.HashMap[String, Any]() - header.put(Constants.NAME, MessageNames.GUEST_REQUESTED_TO_ENTER) - header.put(Constants.TIMESTAMP, TimestampGenerator.generateTimestamp) - header.put(Constants.CURRENT_TIME, TimestampGenerator.getCurrentTime) - -// println("***** DISPATCHING GUEST REQUESTED TO ENTER *****************") - dispatcher.dispatch(buildJson(header, payload)) - } - private def handleGetGuestPolicyReply(msg: GetGuestPolicyReply) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) @@ -2352,29 +2292,13 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { dispatcher.dispatch(buildJson(header, payload)) } - private def handleGetGuestsWaitingReply(msg: GetGuestsWaitingReply) { + private def handleGuestAccessDenied(msg: GuestAccessDenied) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) - payload.put(Constants.REQUESTER_ID, msg.requesterID) - payload.put(Constants.GUESTS_WAITING, msg.guestsWaiting) + payload.put(Constants.USER_ID, msg.userId) val header = new java.util.HashMap[String, Any]() - header.put(Constants.NAME, MessageNames.GET_GUESTS_WAITING_REPLY) - header.put(Constants.TIMESTAMP, TimestampGenerator.generateTimestamp) - header.put(Constants.CURRENT_TIME, TimestampGenerator.getCurrentTime) - -// println("***** DISPATCHING GET GUESTS WAITING REPLY *****************") - dispatcher.dispatch(buildJson(header, payload)) - } - - private def handleResponseToGuest(msg: ResponseToGuest) { - val payload = new java.util.HashMap[String, Any]() - payload.put(Constants.MEETING_ID, msg.meetingID) - payload.put(Constants.USER_ID, msg.guestID) - payload.put(Constants.RESPONSE, msg.response) - - val header = new java.util.HashMap[String, Any]() - header.put(Constants.NAME, MessageNames.RESPONSE_TO_GUEST) + header.put(Constants.NAME, MessageNames.GUEST_ACCESS_DENIED) header.put(Constants.TIMESTAMP, TimestampGenerator.generateTimestamp) header.put(Constants.CURRENT_TIME, TimestampGenerator.getCurrentTime) @@ -2382,20 +2306,6 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { dispatcher.dispatch(buildJson(header, payload)) } - private def handleGuestKicked(msg: GuestKicked) { - val payload = new java.util.HashMap[String, Any]() - payload.put(Constants.MEETING_ID, msg.meetingID) - payload.put(Constants.USER_ID, msg.guestID) - - val header = new java.util.HashMap[String, Any]() - header.put(Constants.NAME, MessageNames.GUEST_KICKED) - header.put(Constants.TIMESTAMP, TimestampGenerator.generateTimestamp) - header.put(Constants.CURRENT_TIME, TimestampGenerator.getCurrentTime) - -// println("***** DISPATCHING GUEST KICKED *****************") - dispatcher.dispatch(buildJson(header, payload)) - } - private def handleGetAllMeetingsReply(msg: GetAllMeetingsReply) { val json = MeetingMessageToJsonConverter.getAllMeetingsReplyToJson(msg) println("***** DISPATCHING GET ALL MEETINGS REPLY OUTMSG *****************") diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala index 31cb16887e..05a18c3a01 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala @@ -34,7 +34,9 @@ class MeetingActor(val meetingID: String, val externalMeetingID: String, val mee var recording = false; var muted = false; var meetingEnded = false + var guestPolicy = GuestPolicy.ASK_MODERATOR + var guestPolicySetBy:String = null def getDuration():Long = { duration @@ -136,13 +138,9 @@ class MeetingActor(val meetingID: String, val externalMeetingID: String, val mee case msg: GetRecordingStatus => handleGetRecordingStatus(msg) case msg: VoiceRecording => handleVoiceRecording(msg) case msg: GetStreamPath => handleGetStreamPath(msg) - case msg: UserRequestToEnter => handleUserRequestToEnter(msg) case msg: GetGuestPolicy => handleGetGuestPolicy(msg) case msg: SetGuestPolicy => handleSetGuestPolicy(msg) - case msg: GetGuestsWaiting => handleGetGuestsWaiting(msg) case msg: RespondToGuest => handleRespondToGuest(msg) - case msg: RespondToAllGuests => handleRespondToAllGuests(msg) - case msg: KickGuest => handleKickGuest(msg) case msg: PatchDocumentRequest => handlePatchDocumentRequest(msg) case msg: GetCurrentDocumentRequest => handleGetCurrentDocumentRequest(msg) @@ -267,6 +265,7 @@ class MeetingActor(val meetingID: String, val externalMeetingID: String, val mee private def handleSetGuestPolicy(msg: SetGuestPolicy) { guestPolicy = msg.policy + guestPolicySetBy = msg.setBy outGW.send(new GuestPolicyChanged(msg.meetingID, recorded, guestPolicy.toString())) } diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/Constants.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/Constants.scala index f09932fb2c..6e2a62b12c 100644 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/Constants.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/Constants.scala @@ -97,6 +97,7 @@ object Constants { val STREAM_PATH = "stream_path" val STREAM_PATH_DEFAULT = "stream_path_default" val GUEST = "guest" + val WAITING_FOR_ACCEPTANCE = "waiting_for_acceptance" val GUEST_POLICY = "guest_policy" val GUESTS_WAITING = "guests_waiting" -} +} diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/InMessages.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/InMessages.scala index 145ac145fa..0da9af8bb1 100644 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/InMessages.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/InMessages.scala @@ -202,11 +202,6 @@ case class UserDisconnectedFromGlobalAudio( ) extends InMessage // Guest support -case class UserRequestToEnter( - meetingID: String, - userID: String -) extends InMessage - case class GetGuestPolicy( meetingID: String, requesterID: String @@ -214,28 +209,15 @@ case class GetGuestPolicy( case class SetGuestPolicy( meetingID: String, - policy: GuestPolicy -) extends InMessage - -case class GetGuestsWaiting( - meetingID: String, - requesterID: String + policy: GuestPolicy, + setBy: String ) extends InMessage case class RespondToGuest( meetingID: String, - guestID: String, - response: Boolean -) extends InMessage - -case class RespondToAllGuests( - meetingID: String, - response: Boolean -) extends InMessage - -case class KickGuest( - meetingID: String, - guestID: String + userId: String, + response: Boolean, + requesterID: String ) extends InMessage // Layout diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/MessageNames.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/MessageNames.scala index 389f18a049..d875c58660 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/MessageNames.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/MessageNames.scala @@ -1,180 +1,173 @@ -package org.bigbluebutton.core.api - -object MessageNames { - val CREATE_MEETING = "create_meeting_request" - val INITIALIZE_MEETING = "initialize_meeting_request" - val DESTROY_MEETING = "destroy_meeting_request" - val START_MEETING = "start_meeting_request" - val END_MEETING = "end_meeting_request" - val LOCK_SETTING = "lock_setting_request" - val LOCK_USER = "lock_user_request" - val INIT_LOCK_SETTINGS = "init_lock_settings" - val SET_LOCK_SETTINGS = "set_lock_settings" - val GET_LOCK_SETTINGS = "get_lock_settings" - val IS_MEETING_LOCKED = "is_meeting_locked" - val VALIDATE_AUTH_TOKEN = "validate_auth_token_request" - val VALIDATE_AUTH_TOKEN_REPLY = "validate_auth_token_reply" - val REGISTER_USER = "register_user_request" - val USER_JOINING = "user_joining_request" - val USER_LEAVING = "user_leaving_request" - val GET_USERS = "get_users_request" - val RAISE_HAND = "user_raise_hand_request" - val LOWER_HAND = "user_lower_hand_request" - val USER_SHARE_WEBCAM = "user_share_webcam_request" - val USER_UNSHARE_WEBCAM = "user_unshare_webcam_request" - val CHANGE_USER_STATUS = "change_user_status_request" - val CHANGE_USER_ROLE = "change_user_role_request" - val ASSIGN_PRESENTER = "assign_presenter_request" - val SET_RECORDING_STATUS = "set_recording_status_request" - val GET_CHAT_HISTORY = "get_chat_history_request" - val SEND_PUBLIC_MESSAGE = "send_public_chat_message_request" - val SEND_PRIVATE_MESSAGE = "send_private_chat_message_request" - val GET_CURRENT_LAYOUT = "get_current_layout_request" - val SET_LAYOUT = "set_layout_request" - val BROADCAST_LAYOUT = "broadcast_layout_request" - val UNLOCK_LAYOUT = "unlock_layout_request" - val PRECREATED_POLL = "precreated_poll_request" - val CREATE_POLL = "create_poll_request" - val UPDATE_POLL = "update_poll_request" - val GET_POLLS = "get_polls_request" - val DESTROY_POLL = "destroy_poll_request" - val REMOVE_POLL = "remove_poll_request" - val SHARE_POLL = "share_poll_request" - val SHOW_POLL_RESULT = "show_poll_result_request" - val HIDE_POLL_RESULT = "hide_poll_result_request" - val START_POLL = "start_poll_request" - val STOP_POLL = "stop_poll_request" - val CLEAR_POLL = "clear_poll_request" - val GET_POLL_RESULT = "get_poll_result_request" - val RESPONT_TO_POLL = "respond_to_poll_request" - val CLEAR_PRESENTATION = "clear_presentation_request" - val REMOVE_PRESENTATION = "remove_presentation_request" - val GET_PRESENTATION_INFO = "get_presentation_info_request" - val RESIZE_AND_MOVE_SLIDE = "resize_and_move_slide_request" - val GO_TO_SLIDE = "go_to_slide_request" - val SHARE_PRESENTATION = "share_presentation_request" - val GET_SLIDE_INFO = "get_slide_info_request" - val GET_SLIDE_INFO_REPLY = "get_slide_info_reply" - val PREUPLOADED_PRESENTATIONS = "preuploaded_presentation_request" - val PRESENTATION_CONVERSION_UPDATE = "presentation_conversion_update_message" - val PRESENTATION_PAGE_COUNT_ERROR = "presentation_page_count_error_message" - val PRESENTATION_SLIDE_GENERATED = "presentation_slide_generated_message" - val PRESENTATION_CONVERSION_COMPLETED = "presentation_conversion_completed_message" - val PRESENTATION_CURSOR_UPDATED = "presentation_cursor_updated_message" - val SEND_VOICE_USERS_REQUEST = "send_voice_users_request" - val MUTE_MEETING_REQUEST = "mute_meeting_request" - val IS_MEETING_MUTED = "is_meeting_muted_request" - val MUTE_USER = "mute_user_request" - val EJECT_USER = "eject_user_request" - val VOICE_USER_JOINED_MESSAGE = "voice_user_joined_message" - val VOICE_USER_JOINED = "voice_user_joined" - val VOICE_USER_LEFT = "voice_user_left_message" - val VOICE_USER_LOCKED = "voice_user_locked_message" - val VOICE_USER_MUTED = "voice_user_muted_message" - val VOICE_USER_TALKING = "voice_user_talking_message" - val VOICE_RECORDING = "voice_recording_message" - val SEND_WHITEBOARD_ANNOTATION = "send_whiteboard_annotation_request" - val GET_WHITEBOARD_SHAPES = "get_whiteboard_shapes_request" - val CLEAR_WHITEBOARD = "clear_whiteboard_request" - val UNDO_WHITEBOARD = "undo_whiteboard_request" - val ENABLE_WHITEBOARD = "enable_whiteboard_request" - val IS_WHITEBOARD_ENABLED = "is_whiteboard_enabled_request" - val GET_STREAM_PATH = "get_stream_path_request" - val USER_REQUEST_TO_ENTER = "user_request_to_enter" - var GET_GUEST_POLICY = "get_guest_policy" - val SET_GUEST_POLICY = "set_guest_policy" - val GET_GUESTS_WAITING = "get_guests_waiting" - val RESPOND_TO_GUEST = "respond_to_guest" - val RESPOND_TO_ALL_GUESTS = "respond_to_all_guests" - val KICK_GUEST = "kick_guest" - val GET_ALL_MEETINGS_REQUEST = "get_all_meetings_request" - - // OUT MESSAGES - val MEETING_CREATED = "meeting_created_message" - val VOICE_RECORDING_STARTED = "voice_recording_started_message" - val VOICE_RECORDING_STOPPED = "voice_recording_stopped_message" - val RECORDING_STATUS_CHANGED = "recording_status_changed_message" - val GET_RECORDING_STATUS_REPLY = "get_recording_status_reply" - val MEETING_ENDED = "meeting_ended_message" - val MEETING_HAS_ENDED = "meeting_has_ended_message" - val MEETING_DESTROYED = "meeting_destroyed_message" - val DISCONNECT_ALL_USERS = "disconnect_all_users_message" - val DISCONNECT_USER = "disconnect_user_message" - val PERMISSION_SETTING_INITIALIZED = "permisssion_setting_initialized_message" - val NEW_PERMISSION_SETTINGS = "new_permission_settings" - val USER_LOCKED = "user_locked_message" - val USERS_LOCKED = "users_locked_message" - val GET_PERMISSION_SETTINGS_REPLY = "get_permissions_setting_reply" - val IS_MEETING_LOCKED_REPLY = "is_meeting_locked_reply" - val USER_REGISTERED = "user_registered_message" - val USER_LEFT = "user_left_message" - val PRESENTER_ASSIGNED = "presenter_assigned_message" - val END_AND_KICK_ALL = "end_and_kick_all_message" - val GET_USERS_REPLY = "get_users_reply" - val USER_JOINED = "user_joined_message" - val USER_RAISED_HAND = "user_raised_hand_message" - val USER_LOWERED_HAND = "user_lowered_hand_message" - val USER_SHARED_WEBCAM = "user_shared_webcam_message" - val USER_UNSHARED_WEBCAM = "user_unshared_webcam_message" - val USER_STATUS_CHANGED = "user_status_changed_message" - val USER_ROLE_CHANGED = "user_role_changed_message" - val MUTE_VOICE_USER = "mute_voice_user_request" - val USER_VOICE_MUTED = "user_voice_muted_message" - val USER_VOICE_TALKING = "user_voice_talking_message" - val EJECT_VOICE_USER = "eject_voice_user_message" - val USER_JOINED_VOICE = "user_joined_voice_message" - val USER_LEFT_VOICE = "user_left_voice_message" - val IS_MEETING_MUTED_REPLY = "is_meeting_muted_reply" - val START_RECORDING = "start_recording_message" - val STOP_RECORDING = "stop_recording_message" - val GET_CHAT_HISTORY_REPLY = "get_chat_history_reply" - val SEND_PUBLIC_CHAT_MESSAGE = "send_public_chat_message" - val SEND_PRIVATE_CHAT_MESSAGE = "send_private_chat_message" - val GET_CURRENT_LAYOUT_REPLY = "get_current_layout_reply" - val SET_LAYOUT_REPLY = "set_layout_reply" - val BROADCAST_LAYOUT_REPLY = "broadcast_layout_reply" - val UNLOCK_LAYOUT_REPLY = "unlock_layout_reply" - val GET_POLL_RESULT_REPLY = "get_poll_result_reply" - val POLL_CLEARED = "poll_cleared_message" - val GET_POLLS_REPLY = "get_polls_reply" - val CLEAR_POLL_FAILED = "clear_poll_failed" - val POLL_STARTED = "poll_started_message" - val POLL_STOPPED = "poll_stopped_message" - val POLL_REMOVED = "poll_removed" - val POLL_UPDATED = "poll_updated_message" - val POLL_CREATED = "poll_created_message" - val POLL_RESPONSE = "poll_response_message" - val POLL_HIDE_RESULT = "poll_hide_result_message" - val POLL_SHOW_RESULT = "poll_show_result_message" - val PRESENTATION_CLEARED = "presentation_cleared_message" - val PRESENTATION_REMOVED = "presentation_removed_message" - val GET_PRESENTATION_INFO_REPLY = "get_presentation_info_reply" - val PRESENTATION_PAGE_RESIZED = "presentation_page_resized_message" - val PRESENTATION_PAGE_CHANGED = "presentation_page_changed_message" - val PRESENTATION_SHARED = "presentation_shared_message" - val GET_PREUPLOADED_PRESENTATIONS = "get_preuploaded_presentations_message" - val PRESENTATION_CONVERSION_PROGRESS = "presentation_conversion_progress_message" - val PRESENTATION_CONVERSION_ERROR = "presentation_conversion_error_message" - val PRESENTATION_CONVERSION_DONE = "presentation_conversion_done_message" - val PRESENTATION_CHANGED = "presentation_changed_message" - val GET_PRESENTATION_STATUS_REPLY = "get_presentation_status_reply" - val PRESENTATION_REMOVED_MESSAGE = "presentation_removed_message" - val PRESENTATION_PAGE_GENERATED = "presentation_page_generated_message" - val GET_WHITEBOARD_SHAPES_REPLY = "get_whiteboard_shapes_reply" - val SEND_WHITEBOARD_SHAPE = "send_whiteboard_shape_message" - val UNDO_WHITEBOARD_MESSAGE = "undo_whiteboard_message" - val WHITEBOARD_ENABLED = "whiteboard_enabled_message" - val WHITEBOARD_CLEARED = "whiteboard_cleared_message" - val IS_WHITEBOARD_ENABLED_REPLY = "is_whiteboard_enabled_reply" - val MEETING_DESTROYED_EVENT = "meeting_destroyed_event" - val KEEP_ALIVE_REPLY = "keep_alive_reply" - val USER_LISTEN_ONLY = "user_listening_only" - val GET_STREAM_PATH_REPLY = "get_stream_path_reply" - val GUEST_REQUESTED_TO_ENTER = "guest_requested_to_enter" - var GET_GUEST_POLICY_REPLY = "get_guest_policy_reply" - val GUEST_POLICY_CHANGED = "guest_policy_changed" - val GET_GUESTS_WAITING_REPLY = "get_guests_waiting_reply" - val RESPONSE_TO_GUEST = "response_to_guest" - val GUEST_KICKED = "guest_kicked" - val GET_ALL_MEETINGS_REPLY = "get_all_meetings_reply" +package org.bigbluebutton.core.api + +object MessageNames { + val CREATE_MEETING = "create_meeting_request" + val INITIALIZE_MEETING = "initialize_meeting_request" + val DESTROY_MEETING = "destroy_meeting_request" + val START_MEETING = "start_meeting_request" + val END_MEETING = "end_meeting_request" + val LOCK_SETTING = "lock_setting_request" + val LOCK_USER = "lock_user_request" + val INIT_LOCK_SETTINGS = "init_lock_settings" + val SET_LOCK_SETTINGS = "set_lock_settings" + val GET_LOCK_SETTINGS = "get_lock_settings" + val IS_MEETING_LOCKED = "is_meeting_locked" + val VALIDATE_AUTH_TOKEN = "validate_auth_token_request" + val VALIDATE_AUTH_TOKEN_REPLY = "validate_auth_token_reply" + val REGISTER_USER = "register_user_request" + val USER_JOINING = "user_joining_request" + val USER_LEAVING = "user_leaving_request" + val GET_USERS = "get_users_request" + val RAISE_HAND = "user_raise_hand_request" + val LOWER_HAND = "user_lower_hand_request" + val USER_SHARE_WEBCAM = "user_share_webcam_request" + val USER_UNSHARE_WEBCAM = "user_unshare_webcam_request" + val CHANGE_USER_STATUS = "change_user_status_request" + val CHANGE_USER_ROLE = "change_user_role_request" + val ASSIGN_PRESENTER = "assign_presenter_request" + val SET_RECORDING_STATUS = "set_recording_status_request" + val GET_CHAT_HISTORY = "get_chat_history_request" + val SEND_PUBLIC_MESSAGE = "send_public_chat_message_request" + val SEND_PRIVATE_MESSAGE = "send_private_chat_message_request" + val GET_CURRENT_LAYOUT = "get_current_layout_request" + val SET_LAYOUT = "set_layout_request" + val BROADCAST_LAYOUT = "broadcast_layout_request" + val UNLOCK_LAYOUT = "unlock_layout_request" + val PRECREATED_POLL = "precreated_poll_request" + val CREATE_POLL = "create_poll_request" + val UPDATE_POLL = "update_poll_request" + val GET_POLLS = "get_polls_request" + val DESTROY_POLL = "destroy_poll_request" + val REMOVE_POLL = "remove_poll_request" + val SHARE_POLL = "share_poll_request" + val SHOW_POLL_RESULT = "show_poll_result_request" + val HIDE_POLL_RESULT = "hide_poll_result_request" + val START_POLL = "start_poll_request" + val STOP_POLL = "stop_poll_request" + val CLEAR_POLL = "clear_poll_request" + val GET_POLL_RESULT = "get_poll_result_request" + val RESPONT_TO_POLL = "respond_to_poll_request" + val CLEAR_PRESENTATION = "clear_presentation_request" + val REMOVE_PRESENTATION = "remove_presentation_request" + val GET_PRESENTATION_INFO = "get_presentation_info_request" + val RESIZE_AND_MOVE_SLIDE = "resize_and_move_slide_request" + val GO_TO_SLIDE = "go_to_slide_request" + val SHARE_PRESENTATION = "share_presentation_request" + val GET_SLIDE_INFO = "get_slide_info_request" + val GET_SLIDE_INFO_REPLY = "get_slide_info_reply" + val PREUPLOADED_PRESENTATIONS = "preuploaded_presentation_request" + val PRESENTATION_CONVERSION_UPDATE = "presentation_conversion_update_message" + val PRESENTATION_PAGE_COUNT_ERROR = "presentation_page_count_error_message" + val PRESENTATION_SLIDE_GENERATED = "presentation_slide_generated_message" + val PRESENTATION_CONVERSION_COMPLETED = "presentation_conversion_completed_message" + val PRESENTATION_CURSOR_UPDATED = "presentation_cursor_updated_message" + val SEND_VOICE_USERS_REQUEST = "send_voice_users_request" + val MUTE_MEETING_REQUEST = "mute_meeting_request" + val IS_MEETING_MUTED = "is_meeting_muted_request" + val MUTE_USER = "mute_user_request" + val EJECT_USER = "eject_user_request" + val VOICE_USER_JOINED_MESSAGE = "voice_user_joined_message" + val VOICE_USER_JOINED = "voice_user_joined" + val VOICE_USER_LEFT = "voice_user_left_message" + val VOICE_USER_LOCKED = "voice_user_locked_message" + val VOICE_USER_MUTED = "voice_user_muted_message" + val VOICE_USER_TALKING = "voice_user_talking_message" + val VOICE_RECORDING = "voice_recording_message" + val SEND_WHITEBOARD_ANNOTATION = "send_whiteboard_annotation_request" + val GET_WHITEBOARD_SHAPES = "get_whiteboard_shapes_request" + val CLEAR_WHITEBOARD = "clear_whiteboard_request" + val UNDO_WHITEBOARD = "undo_whiteboard_request" + val ENABLE_WHITEBOARD = "enable_whiteboard_request" + val IS_WHITEBOARD_ENABLED = "is_whiteboard_enabled_request" + val GET_STREAM_PATH = "get_stream_path_request" + var GET_GUEST_POLICY = "get_guest_policy" + val SET_GUEST_POLICY = "set_guest_policy" + val RESPOND_TO_GUEST = "respond_to_guest" + val GET_ALL_MEETINGS_REQUEST = "get_all_meetings_request" + + // OUT MESSAGES + val MEETING_CREATED = "meeting_created_message" + val VOICE_RECORDING_STARTED = "voice_recording_started_message" + val VOICE_RECORDING_STOPPED = "voice_recording_stopped_message" + val RECORDING_STATUS_CHANGED = "recording_status_changed_message" + val GET_RECORDING_STATUS_REPLY = "get_recording_status_reply" + val MEETING_ENDED = "meeting_ended_message" + val MEETING_HAS_ENDED = "meeting_has_ended_message" + val MEETING_DESTROYED = "meeting_destroyed_message" + val DISCONNECT_ALL_USERS = "disconnect_all_users_message" + val DISCONNECT_USER = "disconnect_user_message" + val PERMISSION_SETTING_INITIALIZED = "permisssion_setting_initialized_message" + val NEW_PERMISSION_SETTINGS = "new_permission_settings" + val USER_LOCKED = "user_locked_message" + val USERS_LOCKED = "users_locked_message" + val GET_PERMISSION_SETTINGS_REPLY = "get_permissions_setting_reply" + val IS_MEETING_LOCKED_REPLY = "is_meeting_locked_reply" + val USER_REGISTERED = "user_registered_message" + val USER_LEFT = "user_left_message" + val PRESENTER_ASSIGNED = "presenter_assigned_message" + val END_AND_KICK_ALL = "end_and_kick_all_message" + val GET_USERS_REPLY = "get_users_reply" + val USER_JOINED = "user_joined_message" + val USER_RAISED_HAND = "user_raised_hand_message" + val USER_LOWERED_HAND = "user_lowered_hand_message" + val USER_SHARED_WEBCAM = "user_shared_webcam_message" + val USER_UNSHARED_WEBCAM = "user_unshared_webcam_message" + val USER_STATUS_CHANGED = "user_status_changed_message" + val USER_ROLE_CHANGED = "user_role_changed_message" + val MUTE_VOICE_USER = "mute_voice_user_request" + val USER_VOICE_MUTED = "user_voice_muted_message" + val USER_VOICE_TALKING = "user_voice_talking_message" + val EJECT_VOICE_USER = "eject_voice_user_message" + val USER_JOINED_VOICE = "user_joined_voice_message" + val USER_LEFT_VOICE = "user_left_voice_message" + val IS_MEETING_MUTED_REPLY = "is_meeting_muted_reply" + val START_RECORDING = "start_recording_message" + val STOP_RECORDING = "stop_recording_message" + val GET_CHAT_HISTORY_REPLY = "get_chat_history_reply" + val SEND_PUBLIC_CHAT_MESSAGE = "send_public_chat_message" + val SEND_PRIVATE_CHAT_MESSAGE = "send_private_chat_message" + val GET_CURRENT_LAYOUT_REPLY = "get_current_layout_reply" + val SET_LAYOUT_REPLY = "set_layout_reply" + val BROADCAST_LAYOUT_REPLY = "broadcast_layout_reply" + val UNLOCK_LAYOUT_REPLY = "unlock_layout_reply" + val GET_POLL_RESULT_REPLY = "get_poll_result_reply" + val POLL_CLEARED = "poll_cleared_message" + val GET_POLLS_REPLY = "get_polls_reply" + val CLEAR_POLL_FAILED = "clear_poll_failed" + val POLL_STARTED = "poll_started_message" + val POLL_STOPPED = "poll_stopped_message" + val POLL_REMOVED = "poll_removed" + val POLL_UPDATED = "poll_updated_message" + val POLL_CREATED = "poll_created_message" + val POLL_RESPONSE = "poll_response_message" + val POLL_HIDE_RESULT = "poll_hide_result_message" + val POLL_SHOW_RESULT = "poll_show_result_message" + val PRESENTATION_CLEARED = "presentation_cleared_message" + val PRESENTATION_REMOVED = "presentation_removed_message" + val GET_PRESENTATION_INFO_REPLY = "get_presentation_info_reply" + val PRESENTATION_PAGE_RESIZED = "presentation_page_resized_message" + val PRESENTATION_PAGE_CHANGED = "presentation_page_changed_message" + val PRESENTATION_SHARED = "presentation_shared_message" + val GET_PREUPLOADED_PRESENTATIONS = "get_preuploaded_presentations_message" + val PRESENTATION_CONVERSION_PROGRESS = "presentation_conversion_progress_message" + val PRESENTATION_CONVERSION_ERROR = "presentation_conversion_error_message" + val PRESENTATION_CONVERSION_DONE = "presentation_conversion_done_message" + val PRESENTATION_CHANGED = "presentation_changed_message" + val GET_PRESENTATION_STATUS_REPLY = "get_presentation_status_reply" + val PRESENTATION_REMOVED_MESSAGE = "presentation_removed_message" + val PRESENTATION_PAGE_GENERATED = "presentation_page_generated_message" + val GET_WHITEBOARD_SHAPES_REPLY = "get_whiteboard_shapes_reply" + val SEND_WHITEBOARD_SHAPE = "send_whiteboard_shape_message" + val UNDO_WHITEBOARD_MESSAGE = "undo_whiteboard_message" + val WHITEBOARD_ENABLED = "whiteboard_enabled_message" + val WHITEBOARD_CLEARED = "whiteboard_cleared_message" + val IS_WHITEBOARD_ENABLED_REPLY = "is_whiteboard_enabled_reply" + val MEETING_DESTROYED_EVENT = "meeting_destroyed_event" + val KEEP_ALIVE_REPLY = "keep_alive_reply" + val USER_LISTEN_ONLY = "user_listening_only" + val GET_STREAM_PATH_REPLY = "get_stream_path_reply" + var GET_GUEST_POLICY_REPLY = "get_guest_policy_reply" + val GUEST_POLICY_CHANGED = "guest_policy_changed" + val GUEST_ACCESS_DENIED = "guest_access_denied" + val GET_ALL_MEETINGS_REPLY = "get_all_meetings_reply" } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala index ac6f736c6b..afd9700466 100644 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala @@ -210,13 +210,6 @@ case class UserJoined( user:UserVO, version:String = Versions.V_0_0_1 ) extends IOutMessage - -case class JoinMeetingReply( - meetingID: String, - recorded: Boolean, - user:UserVO, - version:String = Versions.V_0_0_1 -) extends IOutMessage case class UserRaisedHand( meetingID: String, @@ -667,13 +660,6 @@ case class IsWhiteboardEnabledReply( version:String = Versions.V_0_0_1 ) extends IOutMessage -case class GuestRequestedToEnter ( - meetingID: String, - recorded: Boolean, - userID: String, - name: String -) extends IOutMessage - case class GetGuestPolicyReply( meetingID: String, recorded: Boolean, @@ -687,24 +673,10 @@ case class GuestPolicyChanged( policy: String ) extends IOutMessage -case class GetGuestsWaitingReply( +case class GuestAccessDenied( meetingID: String, recorded: Boolean, - requesterID: String, - guestsWaiting: String -) extends IOutMessage - -case class ResponseToGuest( - meetingID: String, - recorded: Boolean, - guestID: String, - response: Boolean -) extends IOutMessage - -case class GuestKicked( - meetingID: String, - recorded: Boolean, - guestID: String + userId: String ) extends IOutMessage case class GetAllMeetingsReply( diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/ValueObjects.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/ValueObjects.scala index b2a209f04d..c64db9f4c0 100644 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/ValueObjects.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/api/ValueObjects.scala @@ -72,6 +72,7 @@ case class UserVO( name: String, role: Role.Role, guest: Boolean, + waitingForAcceptance: Boolean, mood: String, presenter: Boolean, hasStream: Boolean, diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala index 6f28c5759b..f1c436ecee 100644 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala @@ -20,8 +20,6 @@ trait UsersApp { private var meetingMuted = false private var currentPresenter = new Presenter("system", "system", "system") - - private var guestsWaiting = new collection.immutable.ListSet[String] def hasUser(userID: String):Boolean = { users.hasUser(userID) @@ -273,9 +271,7 @@ trait UsersApp { } def handleGetUsers(msg: GetUsers):Unit = { - // Filter out guests waiting - val approvedUsers = users.getUsers.filter(x => !guestsWaiting.contains(x.userID)) - outGW.send(new GetUsersReply(msg.meetingID, msg.requesterID, approvedUsers)) + outGW.send(new GetUsersReply(msg.meetingID, msg.requesterID, users.getUsers)) } def handleUserJoin(msg: UserJoining):Unit = { @@ -283,37 +279,38 @@ trait UsersApp { regUser foreach { ru => val vu = new VoiceUser(msg.userID, msg.userID, ru.name, ru.name, false, false, false, false) + val waitingForAcceptance = ru.guest && guestPolicy == GuestPolicy.ASK_MODERATOR; val uvo = new UserVO(msg.userID, ru.externId, ru.name, - ru.role, ru.guest, mood="", presenter=false, + ru.role, ru.guest, waitingForAcceptance=waitingForAcceptance, mood="", presenter=false, hasStream=false, locked=false, webcamStreams=new ListSet[String](), phoneUser=false, vu, listenOnly=false, permissions) users.addUser(uvo) - // Send UserJoined only if is not a guest or guest policy is always accept - // For guests this message will be sent when they are accepted - if(!ru.guest || guestPolicy == GuestPolicy.ALWAYS_ACCEPT) { - logger.info("User joined meeting: mid=[" + meetingID + "] uid=[" + uvo.userID + "]") + logger.info("User joined meeting: mid=[" + meetingID + "] uid=[" + uvo.userID + "]") + + if (uvo.guest && guestPolicy == GuestPolicy.ALWAYS_DENY) { + outGW.send(new GuestAccessDenied(meetingID, recorded, uvo.userID)) + } else { outGW.send(new UserJoined(meetingID, recorded, uvo)) outGW.send(new MeetingState(meetingID, recorded, uvo.userID, permissions, meetingMuted)) - - // Become presenter if the only moderator - if (users.numModerators == 1) { - if (ru.role == Role.MODERATOR) { - assignNewPresenter(msg.userID, ru.name, msg.userID) + if (!waitingForAcceptance) { + // Become presenter if the only moderator + if (users.numModerators == 1) { + if (ru.role == Role.MODERATOR) { + assignNewPresenter(msg.userID, ru.name, msg.userID) + } } } + webUserJoined + startRecordingIfAutoStart() } - outGW.send(new JoinMeetingReply(meetingID, recorded, uvo)) - webUserJoined - startRecordingIfAutoStart() } } def handleUserLeft(msg: UserLeaving):Unit = { if (users.hasUser(msg.userID)) { - guestsWaiting = guestsWaiting - msg.userID val user = users.removeUser(msg.userID) user foreach { u => logger.info("User left meeting: mid=[" + meetingID + "] uid=[" + u.userID + "]") @@ -339,14 +336,13 @@ trait UsersApp { msg.voiceUser.callerName, msg.voiceUser.callerNum, true, false, false, false) val uvo = new UserVO(webUserId, webUserId, msg.voiceUser.callerName, - Role.VIEWER, guest=false, mood="", presenter=false, + Role.VIEWER, guest=false, waitingForAcceptance=false, mood="", presenter=false, hasStream=false, locked=false, webcamStreams=new ListSet[String](), phoneUser=true, vu, listenOnly=false, permissions) users.addUser(uvo) logger.info("New user joined voice for user [" + uvo.name + "] userid=[" + msg.voiceUser.webUserId + "]") outGW.send(new UserJoined(meetingID, recorded, uvo)) - outGW.send(new JoinMeetingReply(meetingID, recorded, uvo)) outGW.send(new UserJoinedVoice(meetingID, recorded, voiceBridge, uvo)) if (meetingMuted) @@ -442,61 +438,31 @@ trait UsersApp { } } - def handleUserRequestToEnter(msg: UserRequestToEnter) { - users.getUser(msg.userID) match { - case Some(user) => { - guestsWaiting = guestsWaiting + msg.userID; - outGW.send(new GuestRequestedToEnter(meetingID, recorded, msg.userID, user.name)) - } - case None => { -// println("handleUserRequestToEnter user [" + msg.userId + "] not found.") - } - } - } - - def handleGetGuestsWaiting(msg: GetGuestsWaiting) { - if(users.hasUser(msg.requesterID)) { - var message = ""; - guestsWaiting foreach {guest => { - users.getUser(guest) match { - case Some(user) => message = message + user.userID + ":" + user.name + "," - case None => {} - } - }} - outGW.send(new GetGuestsWaitingReply(meetingID, recorded, msg.requesterID, message)) + private def isModerator(userId: String):Boolean = { + users.getUser(userId) match { + case Some(user) => return user.role == Role.MODERATOR && !user.waitingForAcceptance + case None => return false } } def handleRespondToGuest(msg: RespondToGuest) { - if(guestsWaiting.contains(msg.guestID)) { - guestsWaiting = guestsWaiting - msg.guestID - outGW.send(new ResponseToGuest(meetingID, recorded, msg.guestID, msg.response)) - if(msg.response == true) { - users.getUser(msg.guestID) foreach {user => - println("UsersApp - handleResponseToGuest sending userJoined["+user.userID+"]"); - outGW.send(new UserJoined(meetingID, recorded, user)) - outGW.send(new MeetingState(meetingID, recorded, user.userID, permissions, meetingMuted)) + if (isModerator(msg.requesterID)) { + var usersToAnswer:Array[UserVO] = null; + if (msg.userId == null) { + usersToAnswer = users.getUsers.filter(u => u.waitingForAcceptance == true) + } else { + usersToAnswer = users.getUsers.filter(u => u.waitingForAcceptance == true && u.userID == msg.userId) + } + usersToAnswer foreach {user => + println("UsersApp - handleGuestAccessDenied for user [" + user.userID + "]"); + if (msg.response == true) { + val nu = user.copy(waitingForAcceptance=false) + users.addUser(nu) + outGW.send(new UserJoined(meetingID, recorded, nu)) + } else { + outGW.send(new GuestAccessDenied(meetingID, recorded, user.userID)) } } } } - - def handleRespondToAllGuests(msg: RespondToAllGuests) { - guestsWaiting foreach {guest => - if(msg.response == true) { - users.getUser(guest) foreach {user => - println("UsersApp - handleResponseToGuest sending userJoined["+user.userID+"]"); - outGW.send(new UserJoined(meetingID, recorded, user)) - outGW.send(new MeetingState(meetingID, recorded, user.userID, permissions, meetingMuted)) - } - } - outGW.send(new ResponseToGuest(meetingID, recorded, guest, msg.response)) - } - guestsWaiting = new collection.immutable.ListSet[String] - } - - def handleKickGuest(msg: KickGuest) { - guestsWaiting = guestsWaiting - msg.guestID; - outGW.send(new GuestKicked(meetingID, recorded, msg.guestID)) - } } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/red5/UsersClientMessageSender.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/red5/UsersClientMessageSender.scala index 42bbf841cb..b013ced0e0 100644 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/red5/UsersClientMessageSender.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/red5/UsersClientMessageSender.scala @@ -23,7 +23,6 @@ class UsersClientMessageSender(service: ConnectionInvokerService) extends OutMes case msg: DisconnectUser => handleDisconnectUser(msg) case msg: PresenterAssigned => handleAssignPresenter(msg) case msg: UserJoined => handleUserJoined(msg) - case msg: JoinMeetingReply => handleJoinMeetingReply(msg) case msg: UserLeft => handleUserLeft(msg) case msg: UserStatusChange => handleUserStatusChange(msg) case msg: UserRoleChange => handleUserRoleChange(msg) @@ -42,12 +41,9 @@ class UsersClientMessageSender(service: ConnectionInvokerService) extends OutMes case msg: NewPermissionsSetting => handleNewPermissionsSetting(msg) case msg: MeetingMuted => handleMeetingMuted(msg) case msg: MeetingState => handleMeetingState(msg) - case msg: GuestRequestedToEnter => handleGuestRequestedToEnter(msg) case msg: GetGuestPolicyReply => handleGetGuestPolicyReply(msg) case msg: GuestPolicyChanged => handleGuestPolicyChanged(msg) - case msg: GetGuestsWaitingReply => handleGetGuestsWaitingReply(msg) - case msg: ResponseToGuest => handleResponseToGuest(msg) - case msg: GuestKicked => handleGuestKicked(msg) + case msg: GuestAccessDenied => handleGuestAccessDenied(msg) case _ => // println("Unhandled message in UsersClientMessageSender") } @@ -81,6 +77,7 @@ class UsersClientMessageSender(service: ConnectionInvokerService) extends OutMes wuser.put("name", user.name) wuser.put("role", user.role.toString()) wuser.put("guest", user.guest:java.lang.Boolean) + wuser.put("waitingForAcceptance", user.waitingForAcceptance:java.lang.Boolean) wuser.put("mood", user.mood:java.lang.String) wuser.put("presenter", user.presenter:java.lang.Boolean) wuser.put("hasStream", user.hasStream:java.lang.Boolean) @@ -354,25 +351,19 @@ class UsersClientMessageSender(service: ConnectionInvokerService) extends OutMes val gson = new Gson(); message.put("msg", gson.toJson(args)) +// println("UsersClientMessageSender - joinMeetingReply \n" + message.get("msg") + "\n") + + var jmr = new DirectClientMessage(msg.meetingID, msg.user.userID, "joinMeetingReply", message); + service.sendMessage(jmr); + // println("UsersClientMessageSender - handleUserJoined \n" + message.get("msg") + "\n") var m = new BroadcastClientMessage(msg.meetingID, "participantJoined", message); service.sendMessage(m); } - private def handleJoinMeetingReply(msg: JoinMeetingReply):Unit = { - var args = new HashMap[String, Object](); - args.put("user", buildUserHashMap(msg.user)); - - val message = new java.util.HashMap[String, Object]() - val gson = new Gson(); - message.put("msg", gson.toJson(args)) - -// println("UsersClientMessageSender - joinMeetingReply \n" + message.get("msg") + "\n") - var jmr = new DirectClientMessage(msg.meetingID, msg.user.userID, "joinMeetingReply", message); - service.sendMessage(jmr); - } - + + private def handleUserLeft(msg: UserLeft):Unit = { var args = new HashMap[String, Object](); args.put("user", buildUserHashMap(msg.user)); @@ -463,21 +454,6 @@ class UsersClientMessageSender(service: ConnectionInvokerService) extends OutMes service.sendMessage(m); } - private def handleGuestRequestedToEnter(msg: GuestRequestedToEnter) { - var args = new HashMap[String, Object](); - args.put("userId", msg.userID); - args.put("name", msg.name); - - val message = new java.util.HashMap[String, Object]() - val gson = new Gson(); - message.put("msg", gson.toJson(args)) - -// println("UsersClientMessageSender - handleGuestRequestedToEnter \n" + message.get("msg") + "\n") - - var m = new BroadcastClientMessage(msg.meetingID, "user_requested_to_enter", message); - service.sendMessage(m); - } - private def handleGetGuestPolicyReply(msg: GetGuestPolicyReply) { var args = new HashMap[String, Object](); args.put("guestPolicy", msg.policy.toString()); @@ -506,46 +482,17 @@ class UsersClientMessageSender(service: ConnectionInvokerService) extends OutMes service.sendMessage(m); } - private def handleGetGuestsWaitingReply(msg: GetGuestsWaitingReply) { + private def handleGuestAccessDenied(msg: GuestAccessDenied) { var args = new HashMap[String, Object](); - args.put("guestsWaiting", msg.guestsWaiting); + args.put("userId", msg.userId); val message = new java.util.HashMap[String, Object]() val gson = new Gson(); message.put("msg", gson.toJson(args)) -// println("UsersClientMessageSender - handleGetGuestsWaitingReply \n" + message.get("msg") + "\n") +// println("UsersClientMessageSender - handleGuestAccessDenied \n" + message.get("msg") + "\n") - val m = new DirectClientMessage(msg.meetingID, msg.requesterID, "get_guests_waiting_reply", message); - service.sendMessage(m); - } - - private def handleResponseToGuest(msg: ResponseToGuest) { - var args = new HashMap[String, Object](); - args.put("userId", msg.guestID); - args.put("response", msg.response:java.lang.Boolean); - - val message = new java.util.HashMap[String, Object]() - val gson = new Gson(); - message.put("msg", gson.toJson(args)) - -// println("UsersClientMessageSender - handleResponseToGuest \n" + message.get("msg") + "\n") - - val m = new BroadcastClientMessage(msg.meetingID, "response_to_guest", message); - service.sendMessage(m); - } - - private def handleGuestKicked(msg: GuestKicked) { - var args = new HashMap[String, Object](); - args.put("guestId", msg.guestID); - - val message = new java.util.HashMap[String, Object]() - val gson = new Gson(); - message.put("msg", gson.toJson(args)) - -// println("UsersClientMessageSender - handleGuestKicked \n" + message.get("msg") + "\n") - - val m = new BroadcastClientMessage(msg.meetingID, "guest_kicked", message); + val m = new DirectClientMessage(msg.meetingID, msg.userId, "guest_access_denied", message); service.sendMessage(m); } } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersMessageToJsonConverter.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersMessageToJsonConverter.scala index 4e4e196f00..13c73c668d 100644 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersMessageToJsonConverter.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersMessageToJsonConverter.scala @@ -17,6 +17,7 @@ object UsersMessageToJsonConverter { wuser += "name" -> user.name wuser += "role" -> user.role.toString() wuser += "guest" -> user.guest + wuser += "waiting_for_acceptance" -> user.waitingForAcceptance wuser += "mood" -> user.mood wuser += "presenter" -> user.presenter wuser += "has_stream" -> user.hasStream diff --git a/bigbluebutton-client/src/org/bigbluebutton/core/UsersUtil.as b/bigbluebutton-client/src/org/bigbluebutton/core/UsersUtil.as index 70c771022d..76d27f4546 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/core/UsersUtil.as +++ b/bigbluebutton-client/src/org/bigbluebutton/core/UsersUtil.as @@ -181,17 +181,6 @@ package org.bigbluebutton.core } return null; } - - public static function amIGuest(): Boolean { - return UserManager.getInstance().getConference().amIGuest(); - } - - public static function amIWaitForModerator(): Boolean { - return UserManager.getInstance().getConference().amIWaitForModerator(); - } - - public static function setWaitForModerator(state: Boolean): void { - UserManager.getInstance().getConference().setWaitForModerator(state); - } + } -} +} diff --git a/bigbluebutton-client/src/org/bigbluebutton/core/managers/ConnectionManager.as b/bigbluebutton-client/src/org/bigbluebutton/core/managers/ConnectionManager.as index c3ce1269b2..550e139b2c 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/core/managers/ConnectionManager.as +++ b/bigbluebutton-client/src/org/bigbluebutton/core/managers/ConnectionManager.as @@ -64,13 +64,13 @@ package org.bigbluebutton.core.managers connDelegate.sendMessage(service, onSuccess, onFailure, message); } - public function forceClose():void { - connDelegate.forceClose(); - } + public function forceClose():void { + connDelegate.forceClose(); + } - public function guestDisconnect():void { - connDelegate.guestDisconnect(); - } + public function guestDisconnect():void { + connDelegate.guestDisconnect(); + } } } \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/core/model/MeBuilder.as b/bigbluebutton-client/src/org/bigbluebutton/core/model/MeBuilder.as index e2c2fd20e8..b69d15ac87 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/core/model/MeBuilder.as +++ b/bigbluebutton-client/src/org/bigbluebutton/core/model/MeBuilder.as @@ -64,7 +64,7 @@ package org.bigbluebutton.core.model guest = value; return this; } - + public function withCustomData(value: Object):MeBuilder { customData = value; return this; @@ -74,4 +74,4 @@ package org.bigbluebutton.core.model return new Me(this); } } -} +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/core/model/users/UserBuilder.as b/bigbluebutton-client/src/org/bigbluebutton/core/model/users/UserBuilder.as index eb735e5cc0..41a5db2f8b 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/core/model/users/UserBuilder.as +++ b/bigbluebutton-client/src/org/bigbluebutton/core/model/users/UserBuilder.as @@ -47,7 +47,7 @@ package org.bigbluebutton.core.model.users public function withGuest(value: Boolean):UserBuilder { return this; } - + public function withCustomData(value: String):UserBuilder { return this; } @@ -57,4 +57,4 @@ package org.bigbluebutton.core.model.users } } -} +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/events/AddGuestEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/events/AddGuestEvent.as deleted file mode 100644 index ced851bed5..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/main/events/AddGuestEvent.as +++ /dev/null @@ -1,36 +0,0 @@ -/** -* 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 . -* -*/ -package org.bigbluebutton.main.events -{ - import flash.events.Event; - - public class AddGuestEvent extends Event - { - public static const ADD_GUEST:String = "AddGuest"; - - - public var userid:String; - public var name:String; - - public function AddGuestEvent(type:String = ADD_GUEST) - { - super(type, true, false); - } - } -} diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/events/BBBEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/events/BBBEvent.as index f15635cf35..87a1f84678 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/events/BBBEvent.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/events/BBBEvent.as @@ -31,7 +31,7 @@ package org.bigbluebutton.main.events { public static const VIDEO_STARTED:String = 'BBB_VIDEO_STARTED'; public static const START_DESKSHARE:String = 'BBB_START_DESKSHARE'; public static const DESKSHARE_STARTED:String = 'BBB_DESKSHARE_STARTED'; - public static const USER_VOICE_JOINED:String = 'user voice joined event'; + public static const USER_VOICE_JOINED:String = 'user voice joined event'; public static const USER_VOICE_MUTED:String = "user voice muted event"; public static const USER_LOCKED:String = "user locked event"; public static const USER_VOICE_LEFT:String = "user voice left event"; @@ -45,18 +45,16 @@ package org.bigbluebutton.main.events { public static const SETTINGS_CONFIRMED:String = "BBB_SETTINGS_CONFIRMED"; public static const SETTINGS_CANCELLED:String = "BBB_SETTINGS_CANCELLED"; + public static const ACCEPT_ALL_WAITING_GUESTS:String = "BBB_ACCEPT_ALL_WAITING_GUESTS"; public static const DENY_ALL_WAITING_GUESTS:String = "BBB_DENY_ALL_WAITING_GUESTS"; - - public static const DENY_GUEST:String = "BBB_DENY_GUEST"; - public static const ACCEPT_GUEST:String = "BBB_ACCEPT_GUEST"; - public static const ASK_TO_ACCEPT_GUEST:String = "BBB_ASK_TO_ACCEPT_GUEST"; - public static const BROADCAST_GUEST_POLICY:String = "BBB_BROADCAST_GUEST_POLICY"; public static const RETRIEVE_GUEST_POLICY:String = "BBB_RETRIEVE_GUEST_POLICY"; - - public static const KICK_GUEST:String = "KICK_GUEST"; - + public static const MODERATOR_ALLOWED_ME_TO_JOIN:String = "MODERATOR_ALLOWED_ME_TO_JOIN"; + public static const WAITING_FOR_MODERATOR_ACCEPTANCE:String = "WAITING_FOR_MODERATOR_ACCEPTANCE"; + public static const ADD_GUEST_TO_LIST:String = "ADD_GUEST_TO_LIST"; + public static const REMOVE_GUEST_FROM_LIST:String = "REMOVE_GUEST_FROM_LIST"; + public var message:String; public var payload:Object = new Object(); @@ -65,4 +63,4 @@ package org.bigbluebutton.main.events { this.message = message; } } -} +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/events/LogoutEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/events/LogoutEvent.as index 1f904bf1bf..a8504044c4 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/events/LogoutEvent.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/events/LogoutEvent.as @@ -25,7 +25,7 @@ package org.bigbluebutton.main.events public static const USER_LOGGED_OUT:String = "USER_LOGGED_OUT"; public static const DISCONNECT_TEST:String = "disconnect_test"; public static const USER_KICKED_OUT:String = "USER_KICKED_OUT"; - public static const GUEST_KICKED_OUT:String = "GUEST_KICKED_OUT"; + public static const MODERATOR_DENIED_ME:String = "MODERATOR_DENIED_ME"; public static const CONFIRM_LOGOUT:String = "CONFIRM_LOGOUT"; public static const REFOCUS_CONFIRM:String = "REFOCUS_CONFIRM"; diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/events/ModeratorRespEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/events/ModeratorRespEvent.as deleted file mode 100755 index 6819b02dd6..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/main/events/ModeratorRespEvent.as +++ /dev/null @@ -1,32 +0,0 @@ -/** -* 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 . -* -*/ -package org.bigbluebutton.main.events -{ - import flash.events.Event; - - public class ModeratorRespEvent extends Event - { - public static const GUEST_ALLOWED:String = "GuestAllowed"; - - public function ModeratorRespEvent(type:String) - { - super(type, true, false); - } - } -} diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/events/NewGuestEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/events/NewGuestEvent.as deleted file mode 100755 index e90d1a178f..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/main/events/NewGuestEvent.as +++ /dev/null @@ -1,40 +0,0 @@ -/** -* 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 . -* -*/ -package org.bigbluebutton.main.events -{ - import flash.events.Event; - - - import org.bigbluebutton.main.model.users.BBBUser; - - - public class NewGuestEvent extends Event - { - public static const NEW_GUEST_EVENT:String = "NewGuestEvent"; - - - public var userid:String; - public var name:String; - - public function NewGuestEvent(type:String) - { - super(type, true, false); - } - } -} diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/events/RemoveGuestRequestEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/events/RemoveGuestRequestEvent.as deleted file mode 100755 index 3ff7d06500..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/main/events/RemoveGuestRequestEvent.as +++ /dev/null @@ -1,38 +0,0 @@ -/** -* 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 . -* -*/ -package org.bigbluebutton.main.events -{ - import flash.events.Event; - - - - - public class RemoveGuestRequestEvent extends Event - { - public static const GUEST_EVENT:String = "GuestEvent"; - - - public var userid:String; - - public function RemoveGuestRequestEvent(type:String) - { - super(type, true, false); - } - } -} diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/events/WaitModeratorEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/events/WaitModeratorEvent.as deleted file mode 100755 index 9727d5a4f6..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/main/events/WaitModeratorEvent.as +++ /dev/null @@ -1,36 +0,0 @@ -/** -* 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 . -* -*/ -package org.bigbluebutton.main.events -{ - import flash.events.Event; - - import org.bigbluebutton.main.model.ConferenceParameters; - - public class WaitModeratorEvent extends Event - { - public static const USER_LOGGED_IN:String = "UserLoggedIn"; - - public var conferenceParameters:ConferenceParameters; - - public function WaitModeratorEvent(type:String) - { - super(type, true, false); - } - } -} diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/maps/ApplicationEventMap.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/maps/ApplicationEventMap.mxml index 909c5364f5..e28be22b28 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/maps/ApplicationEventMap.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/maps/ApplicationEventMap.mxml @@ -48,11 +48,11 @@ with BigBlueButton; if not, see . - + - + @@ -66,10 +66,11 @@ with BigBlueButton; if not, see . - + + . import org.bigbluebutton.main.events.SuccessfulLoginEvent; import org.bigbluebutton.main.model.PortTestProxy; import org.bigbluebutton.main.model.modules.ModulesProxy; - + ]]> diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/ConferenceParameters.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/ConferenceParameters.as index 48a898b723..765327f548 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/ConferenceParameters.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/ConferenceParameters.as @@ -105,4 +105,4 @@ package org.bigbluebutton.main.model * */ public var lockSettings:Object; } -} +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/GuestManager.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/GuestManager.as index 2a8699d58a..f3b366e766 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/GuestManager.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/GuestManager.as @@ -21,8 +21,8 @@ package org.bigbluebutton.main.model { import com.asfusion.mate.events.Dispatcher; + import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.main.events.RefreshGuestEvent; - import org.bigbluebutton.main.events.AddGuestEvent; import org.bigbluebutton.main.events.RemoveGuestFromViewEvent; public class GuestManager @@ -35,8 +35,8 @@ package org.bigbluebutton.main.model this.guest = new Guest(); } - public function addGuest(evt:AddGuestEvent):void { - guest.addGuest(evt.userid, evt.name); + public function addGuest(evt:BBBEvent):void { + guest.addGuest(evt.payload.userId, evt.payload.name); refreshGuestView(); } diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/User.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/User.as index 2fc9fc2124..b7f6d7f67c 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/User.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/User.as @@ -30,4 +30,4 @@ package org.bigbluebutton.main.model public var authToken:String; public var guest:Boolean; } -} +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/BBBUser.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/BBBUser.as index fb6d444510..15d3ac535c 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/BBBUser.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/BBBUser.as @@ -54,9 +54,8 @@ package org.bigbluebutton.main.model.users [Bindable] public var disableMyPublicChat:Boolean = false; [Bindable] public var lockedLayout:Boolean = false; - [Bindable] public var waitingForMod:Boolean = false; - [Bindable] public var guest:Boolean; - [Bindable] public var acceptedJoin:Boolean = false; + [Bindable] public var guest:Boolean = false; + [Bindable] public var waitingForAcceptance:Boolean = false; [Bindable] public function get hasStream():Boolean { diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/Conference.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/Conference.as index 6fc7eab0be..0f78f4e5cb 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/Conference.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/Conference.as @@ -110,15 +110,13 @@ package org.bigbluebutton.main.model.users { public function addUser(newuser:BBBUser):void { trace("Adding new user [" + newuser.userID + "]"); - if (! hasUser(newuser.userID)) { - trace("Am I this new user [" + newuser.userID + ", " + me.userID + "]"); - if (newuser.userID == me.userID) { - newuser.me = true; - } - - users.addItem(newuser); - users.refresh(); - } + removeUserHelper(newuser.userID); + if (newuser.userID == me.userID) { + newuser.me = true; + } + + users.addItem(newuser); + users.refresh(); } public function setCamPublishing(publishing:Boolean):void { @@ -140,14 +138,6 @@ package org.bigbluebutton.main.model.users { public function getDefaultLayout():String { return defaultLayout; } - - public function amIWaitForModerator():Boolean { - return me.waitingForMod; - } - - public function setWaitForModerator(state:Boolean):void { - me.waitingForMod = state; - } public function hasUser(userID:String):Boolean { var p:Object = getUserIndex(userID); @@ -227,15 +217,23 @@ package org.bigbluebutton.main.model.users { var a:BBBUser = user.participant as BBBUser; return a.presenter; } - - public function removeUser(userID:String):void { + + private function removeUserHelper(userID:String):BBBUser { var p:Object = getUserIndex(userID); if (p != null) { - trace("removing user[" + p.participant.name + "," + p.participant.userID + "]"); users.removeItemAt(p.index); - //sort(); + return p.participant as BBBUser; + } else { + return null; + } + } + + public function removeUser(userID:String):void { + var p:Object = removeUserHelper(userID); + if (p != null) { + trace("removing user[" + p.name + "," + p.userID + "]"); users.refresh(); - } + } } /** diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/JoinService.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/JoinService.as index 464f6af88e..9da693f92b 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/JoinService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/JoinService.as @@ -158,4 +158,4 @@ package org.bigbluebutton.main.model.users return this.urlLoader; } } -} +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as index ad71429594..e6f3debf78 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as @@ -31,7 +31,7 @@ package org.bigbluebutton.main.model.users import org.bigbluebutton.main.events.InvalidAuthTokenEvent; import org.bigbluebutton.main.model.ConferenceParameters; import org.bigbluebutton.main.model.users.events.ConnectionFailedEvent; - import org.bigbluebutton.main.model.users.events.UsersConnectionEvent; + import org.bigbluebutton.main.model.users.events.UsersConnectionEvent; public class NetConnectionDelegate { @@ -228,11 +228,12 @@ package org.bigbluebutton.main.model.users this.guestKickedOutCommand = true; _netConnection.close(); } - - public function forceClose():void { - _netConnection.close(); - } - + + + public function forceClose():void { + _netConnection.close(); + } + protected function netStatus(event:NetStatusEvent):void { handleResult( event ); } @@ -337,7 +338,7 @@ package org.bigbluebutton.main.model.users sendUserLoggedOutEvent(); return; } - + var e:ConnectionFailedEvent = new ConnectionFailedEvent(reason); dispatcher.dispatchEvent(e); @@ -350,7 +351,7 @@ package org.bigbluebutton.main.model.users } private function sendGuestUserKickedOutEvent():void { - var e:ConnectionFailedEvent = new ConnectionFailedEvent(ConnectionFailedEvent.GUEST_KICKED_OUT); + var e:ConnectionFailedEvent = new ConnectionFailedEvent(ConnectionFailedEvent.MODERATOR_DENIED_ME); dispatcher.dispatchEvent(e); } 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 f5401204fb..fa92b879f0 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as @@ -36,13 +36,12 @@ package org.bigbluebutton.main.model.users import org.bigbluebutton.core.managers.ConnectionManager; import org.bigbluebutton.core.managers.UserConfigManager; import org.bigbluebutton.core.managers.UserManager; - import org.bigbluebutton.core.model.Config + import org.bigbluebutton.core.model.Config; import org.bigbluebutton.common.Role; + import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.main.events.SuccessfulLoginEvent; - import org.bigbluebutton.main.events.WaitModeratorEvent; import org.bigbluebutton.main.events.UserServicesEvent; import org.bigbluebutton.main.events.ResponseModeratorEvent; - import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.main.events.LogoutEvent; import org.bigbluebutton.main.model.ConferenceParameters; import org.bigbluebutton.main.model.users.events.BroadcastStartedEvent; @@ -72,6 +71,15 @@ package org.bigbluebutton.main.model.users public function UserService() { dispatcher = new Dispatcher(); + msgReceiver.onAllowedToJoin = function():void { + sender.queryForParticipants(); + sender.queryForRecordingStatus(); + sender.queryForGuestPolicy(); + + var loadCommand:SuccessfulLoginEvent = new SuccessfulLoginEvent(SuccessfulLoginEvent.USER_LOGGED_IN); + loadCommand.conferenceParameters = _conferenceParameters; + dispatcher.dispatchEvent(loadCommand); + } } public function startService(e:UserServicesEvent):void { @@ -207,50 +215,20 @@ package org.bigbluebutton.main.model.users trace(LOG + "userLoggedIn - Setting my userid to [" + e.userid + "]"); UserManager.getInstance().getConference().setMyUserid(e.userid); _conferenceParameters.userid = e.userid; - - sender.queryForParticipants(); - sender.queryForRecordingStatus(); - sender.queryForGuestPolicy(); - - if(UsersUtil.amIGuest() == false) { - var loadCommand:SuccessfulLoginEvent = new SuccessfulLoginEvent(SuccessfulLoginEvent.USER_LOGGED_IN); - loadCommand.conferenceParameters = _conferenceParameters; - dispatcher.dispatchEvent(loadCommand); - } } - public function askToAccept():void { - UserManager.getInstance().getConference().setWaitForModerator(true); - var guestCommand:WaitModeratorEvent = new WaitModeratorEvent(WaitModeratorEvent.USER_LOGGED_IN); - guestCommand.conferenceParameters = _conferenceParameters; - dispatcher.dispatchEvent(guestCommand); - - } - - public function acceptGuest():void { - var loadCommand:SuccessfulLoginEvent = new SuccessfulLoginEvent(SuccessfulLoginEvent.USER_LOGGED_IN); - loadCommand.conferenceParameters = _conferenceParameters; - dispatcher.dispatchEvent(loadCommand); - } - public function denyGuest():void { - dispatcher.dispatchEvent(new LogoutEvent(LogoutEvent.GUEST_KICKED_OUT)); + dispatcher.dispatchEvent(new LogoutEvent(LogoutEvent.MODERATOR_DENIED_ME)); } - public function newGuestPolicy(event:BBBEvent):void { + public function setGuestPolicy(event:BBBEvent):void { sender.setGuestPolicy(event.payload['guestPolicy']); } - public function getAllGuests(e:SuccessfulLoginEvent):void { - if(UserManager.getInstance().getConference().amIModerator()) { - sender.queryForGuestsWaiting(); - } - } - public function guestDisconnect():void { _connectionManager.guestDisconnect(); } - + public function isModerator():Boolean { return UserManager.getInstance().getConference().amIModerator(); } @@ -270,22 +248,10 @@ package org.bigbluebutton.main.model.users public function changeStatus(e:ChangeStatusEvent):void { sender.changeStatus(e.userId, e.getStatusName()); } - - public function askToEnter(e:WaitModeratorEvent):void { - sender.askToEnter(); - } public function responseToGuest(e:ResponseModeratorEvent):void { sender.responseToGuest(e.userid, e.resp); } - - public function responseToAllGuests(e:ResponseModeratorEvent):void { - sender.responseToAllGuests(e.resp); - } - - public function kickGuest(e:BBBEvent):void { - sender.kickGuest(e.payload.userId); - } public function kickUser(e:KickUserEvent):void{ if (this.isModerator()) sender.kickUser(e.userid); diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/ConnectionFailedEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/ConnectionFailedEvent.as index 6b9953bb86..ba9a68a101 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/ConnectionFailedEvent.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/ConnectionFailedEvent.as @@ -30,11 +30,11 @@ package org.bigbluebutton.main.model.users.events public static const CONNECTION_REJECTED:String = "connectionRejected"; public static const ASYNC_ERROR:String = "asyncError"; public static const USER_LOGGED_OUT:String = "userHasLoggedOut"; - public static const GUEST_KICKED_OUT:String = "guestKickedOut"; - + public static const MODERATOR_DENIED_ME:String = "moderatorDeniedMe"; + public function ConnectionFailedEvent(type:String) { super(type, true, false); } } -} +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UsersConnectionEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UsersConnectionEvent.as index 8f81660c60..8d1ce31e88 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UsersConnectionEvent.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UsersConnectionEvent.as @@ -25,12 +25,10 @@ package org.bigbluebutton.main.model.users.events { public static const CONNECTION_SUCCESS:String = "usersConnectionSuccess"; - public var connection:NetConnection; - public var userid:String; - public var guest:Boolean; + public var userid:String; public function UsersConnectionEvent(type:String) { super(type, true, false); } } -} +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/LoggedOutWindow.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/LoggedOutWindow.mxml index 985037cc65..d74ceea141 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/LoggedOutWindow.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/LoggedOutWindow.mxml @@ -118,7 +118,7 @@ with BigBlueButton; if not, see . setCurrentState(DISPLAY_MESSAGE_ONLY_STATE); redirect(); // we know that the disconnect was requested so automatically redirect break; - case ConnectionFailedEvent.GUEST_KICKED_OUT: + case ConnectionFailedEvent.MODERATOR_DENIED_ME: message = ResourceUtil.getInstance().getString('bbb.logout.guestkickedout'); setCurrentState(DISPLAY_MESSAGE_ONLY_STATE); break; diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml index 0323b58519..4f0008a23b 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml @@ -63,11 +63,11 @@ with BigBlueButton; if not, see . - - + + - - + + . import org.bigbluebutton.common.events.SettingsComponentEvent; import org.bigbluebutton.common.events.ToolbarButtonEvent; import org.bigbluebutton.core.BBB; + import org.bigbluebutton.core.UsersUtil; import org.bigbluebutton.core.events.LockControlEvent; import org.bigbluebutton.core.managers.UserManager; import org.bigbluebutton.core.vo.LockSettingsVO; @@ -108,14 +109,11 @@ with BigBlueButton; if not, see . import org.bigbluebutton.main.events.LogoutEvent; import org.bigbluebutton.main.events.NetworkStatsEvent; import org.bigbluebutton.main.events.MeetingNotFoundEvent; - import org.bigbluebutton.main.events.ModeratorRespEvent; import org.bigbluebutton.main.events.ModuleLoadEvent; import org.bigbluebutton.main.events.PortTestEvent; import org.bigbluebutton.main.events.RefreshGuestEvent; - import org.bigbluebutton.main.events.RemoveGuestRequestEvent; import org.bigbluebutton.main.events.ShortcutEvent; import org.bigbluebutton.main.events.SuccessfulLoginEvent; - import org.bigbluebutton.main.events.WaitModeratorEvent; import org.bigbluebutton.main.model.Guest; import org.bigbluebutton.main.model.LayoutOptions; import org.bigbluebutton.main.model.users.Conference; @@ -385,7 +383,15 @@ with BigBlueButton; if not, see . var dispatcher:Dispatcher = new Dispatcher(); dispatcher.dispatchEvent(new ModuleLoadEvent(ModuleLoadEvent.START_ALL_MODULES)); } - + + public function guestAllowed(evt:BBBEvent):void { + progressBar.visible = true; + if (waitWindow != null) { + PopUpManager.removePopUp(waitWindow); + waitWindow = null; + } + } + private function fullScreenHandler(evt:FullScreenEvent):void { if (evt.fullScreen) { LogUtil.debug("Switching to full screen"); @@ -396,13 +402,8 @@ with BigBlueButton; if not, see . fullscreen_icon = images.full_screen; showToolbars(); } - } - - public function guestAllowed(evt:ModeratorRespEvent):void { - progressBar.visible = true; - waitWindow.guestAllowed(); - } - + } + private function closeGuestWindow(e:Event):void { if(guestWindow != null) { guestWindow.closeWindow(); @@ -411,8 +412,15 @@ with BigBlueButton; if not, see . } private function refreshGuestView(evt:RefreshGuestEvent):void { - LogUtil.debug("REFRESH GUEST"); - if(guestWindow == null) { + // do not show the guest window if the user isn't moderator or if he's moderator but is still waiting for acceptance + if ( ! ( + UsersUtil.amIModerator() + && UserManager.getInstance().getConference().getMyUser() != null + && !UserManager.getInstance().getConference().getMyUser().waitingForAcceptance) ) { + return; + } + + if (guestWindow == null) { guestWindow = PopUpManager.createPopUp( mdiCanvas, GuestWindow, false) as GuestWindow; guestWindow.addEventListener(Event.CLOSE, closeGuestWindow); @@ -422,15 +430,15 @@ with BigBlueButton; if not, see . guestWindow.refreshGuestView(evt.listOfGuests); } - public function removeGuestWindow(evt:RemoveGuestRequestEvent):void { - if(guestWindow != null) - guestWindow.remove(evt.userid); + public function removeGuestWindow(evt:BBBEvent):void { + if (guestWindow != null) { + guestWindow.remove(evt.payload.userId); + } } - private function openWaitWindow(evt:WaitModeratorEvent):void { + private function openWaitWindow(evt:BBBEvent):void { progressBar.visible = false; waitWindow = PopUpManager.createPopUp( mdiCanvas, WaitingWindow, false) as WaitingWindow; - waitWindow.conferenceParameters = evt.conferenceParameters; // Calculate position of TitleWindow in Application's coordinates. waitWindow.x = (systemManager.screen.width - waitWindow.width) / 2; diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/MainToolbar.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/MainToolbar.mxml index e77c39e7c1..2659efdf51 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/MainToolbar.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/MainToolbar.mxml @@ -37,18 +37,18 @@ with BigBlueButton; if not, see . - + - - + - + . import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.main.events.ConfigEvent; import org.bigbluebutton.main.events.LogoutEvent; - import org.bigbluebutton.main.events.ModeratorRespEvent; import org.bigbluebutton.main.events.NetworkStatsEvent; import org.bigbluebutton.main.events.SettingsEvent; import org.bigbluebutton.main.events.ShortcutEvent; import org.bigbluebutton.main.events.SuccessfulLoginEvent; - import org.bigbluebutton.main.events.WaitModeratorEvent; import org.bigbluebutton.main.model.LayoutOptions; import org.bigbluebutton.main.model.NetworkStatsData; import org.bigbluebutton.main.model.users.events.ChangeMyRole; @@ -88,8 +86,9 @@ with BigBlueButton; if not, see . [Bindable] private var showHelpBtn:Boolean = false; [Bindable] private var showToolbar:Boolean = false; - [Bindable] private var showConfigurationsButton:Boolean = false; - [Bindable] public var toolbarOptions:LayoutOptions = new LayoutOptions(); + [Bindable] private var showGuestSettingsButton:Boolean = false; + [Bindable] private var showRecordButton:Boolean = false; + [Bindable] public var toolbarOptions:LayoutOptions = new LayoutOptions(); [Bindable] private var baseIndex:int; [Bindable] private var numButtons:int; @@ -109,7 +108,7 @@ with BigBlueButton; if not, see . private var xml:XML; private var settingsComponents:Array = new Array(); private var settingsPopup:BBBSettings = null; - + private function init():void{ if (Capabilities.hasAccessibility) { AlertAccImpl.enableAccessibility(); @@ -123,8 +122,7 @@ with BigBlueButton; if not, see . timer.addEventListener(TimerEvent.TIMER, checkAccessiblity); timer.start(); - - + BindingUtils.bindSetter(refreshModeratorButtonsVisibility, UserManager.getInstance().getConference(), "record"); } private function onCreationComplete():void { @@ -182,23 +180,24 @@ with BigBlueButton; if not, see . initBandwidthToolTip(); } } - + private function retrieveMeetingName(e:ConferenceCreatedEvent):void { if (toolbarOptions.showMeetingName) { - var meetingTitle:String = BBB.initUserConfigManager().getMeetingTitle(); + var meetingTitle:String = BBB.initUserConfigManager().getMeetingTitle(); if (meetingTitle != null) { meetingNameLbl.text = meetingTitle; - } + } } - // need to put it here because on init() the conference object - // still doesn't have the updated information - refreshSettingsBtn(null); } - private function refreshSettingsBtn(e:*):void { - showConfigurationsButton = UsersUtil.amIModerator() && !UsersUtil.amIWaitForModerator(); - } + private function refreshModeratorButtonsVisibility(e:*):void { + showGuestSettingsButton = UsersUtil.amIModerator() + && UserManager.getInstance().getConference().getMyUser() != null + && !UserManager.getInstance().getConference().getMyUser().waitingForAcceptance; + showRecordButton = showGuestSettingsButton && UserManager.getInstance().getConference().record; + } + public function addButton(name:String):Button{ var btn:Button = new Button(); btn.id = name; @@ -430,7 +429,7 @@ with BigBlueButton; if not, see . } private function refreshRole(e:ChangeMyRole):void { - refreshSettingsBtn(null); + refreshModeratorButtonsVisibility(null); } ]]> @@ -452,7 +451,7 @@ with BigBlueButton; if not, see . tabIndex="{baseIndex+4}" height="22" styleName="quickWindowLinkStyle" /> - + @@ -461,8 +460,8 @@ with BigBlueButton; if not, see . . : ResourceUtil.getInstance().getString('bbb.mainToolbar.recordBtn.toolTip.notRecording')}" enabled="false" creationComplete="onCreationComplete()" - visible="{UserManager.getInstance().getConference().record}" - includeInLayout="{UserManager.getInstance().getConference().record}" mouseOver="onRecordButtonMouseOver(event)" mouseOut="onRecordButtonMouseOut(event)" > diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/WaitingWindow.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/WaitingWindow.mxml index 85b8a58fd1..660472502e 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/WaitingWindow.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/WaitingWindow.mxml @@ -21,39 +21,18 @@ --> + title="{ResourceUtil.getInstance().getString('bbb.waitWindow.waitMessage.title')}" showCloseButton="false" + layout="vertical" width="350" horizontalAlign="center"> 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 f2d9217366..c5e983becf 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml @@ -29,12 +29,9 @@ with BigBlueButton; if not, see . import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.main.events.LogoutEvent; - import org.bigbluebutton.main.events.AddGuestEvent; - import org.bigbluebutton.main.events.RemoveGuestRequestEvent; import org.bigbluebutton.main.events.ResponseModeratorEvent; import org.bigbluebutton.main.events.SuccessfulLoginEvent; import org.bigbluebutton.main.events.UserServicesEvent; - import org.bigbluebutton.main.events.WaitModeratorEvent; import org.bigbluebutton.main.model.GuestManager; import org.bigbluebutton.main.model.users.UserService; import org.bigbluebutton.main.model.users.events.BroadcastStartedEvent; @@ -150,58 +147,30 @@ with BigBlueButton; if not, see . - - - - - + - + + + + + - - - - - - - - - - - - - + - - - - - - - - - - - - - + - - - - - + 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 35a375c0c6..8d688d66ca 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as @@ -32,13 +32,10 @@ package org.bigbluebutton.modules.users.services import org.bigbluebutton.core.services.UsersService; import org.bigbluebutton.core.vo.LockSettings; import org.bigbluebutton.core.vo.LockSettingsVO; - import org.bigbluebutton.main.events.AddGuestEvent; import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.main.events.LogoutEvent; import org.bigbluebutton.main.events.MadePresenterEvent; - import org.bigbluebutton.main.events.ModeratorRespEvent; import org.bigbluebutton.main.events.PresenterStatusEvent; - import org.bigbluebutton.main.events.RemoveGuestRequestEvent; import org.bigbluebutton.main.events.SwitchedPresenterEvent; import org.bigbluebutton.main.events.UserJoinedEvent; import org.bigbluebutton.main.events.UserLeftEvent; @@ -61,6 +58,7 @@ package org.bigbluebutton.modules.users.services private var dispatcher:Dispatcher; private var _conference:Conference; + public var onAllowedToJoin:Function = null; private static var globalDispatcher:Dispatcher = new Dispatcher(); public function MessageReceiver() { @@ -136,23 +134,14 @@ package org.bigbluebutton.modules.users.services case "permissionsSettingsChanged": handlePermissionsSettingsChanged(message); break; - case "user_requested_to_enter": - handleGuestRequestedToEnter(message); - break; case "get_guest_policy_reply": handleGetGuestPolicyReply(message); break; case "guest_policy_changed": handleGuestPolicyChanged(message); break; - case "get_guests_waiting_reply": - handleGetGuestsWaitingReply(message); - break; - case "response_to_guest": - handleResponseToGuest(message); - break; - case "guest_kicked": - handleGuestKicked(message); + case "guest_access_denied": + handleGuestAccessDenied(message); break; } } @@ -381,10 +370,10 @@ package org.bigbluebutton.modules.users.services UsersService.getInstance().userLeft(webUser); - if(webUser.guest) { - var e:RemoveGuestRequestEvent = new RemoveGuestRequestEvent(RemoveGuestRequestEvent.GUEST_EVENT); - e.userid = webUser.userId; - dispatcher.dispatchEvent(e); + if(webUser.waitingForAcceptance) { + var removeGuest:BBBEvent = new BBBEvent(BBBEvent.REMOVE_GUEST_FROM_LIST); + removeGuest.payload.userId = webUser.userId; + dispatcher.dispatchEvent(removeGuest); } var user:BBBUser = UserManager.getInstance().getConference().getUser(webUserId); @@ -516,7 +505,7 @@ package org.bigbluebutton.modules.users.services private function handleUserUnsharedWebcam(msg: Object):void { trace(LOG + "*** handleUserUnsharedWebcam " + msg.msg + " **** \n"); - var map:Object = JSON.parse(msg.msg); + var map:Object = JSON.parse(msg.msg); UserManager.getInstance().getConference().unsharedWebcam(map.userId, map.webcamStream); } @@ -539,10 +528,11 @@ package org.bigbluebutton.modules.users.services user.name = joinedUser.name; user.role = joinedUser.role; user.guest = joinedUser.guest; - user.acceptedJoin = !user.guest; + user.waitingForAcceptance = joinedUser.waitingForAcceptance; user.externUserID = joinedUser.externUserID; user.isLeavingFlag = false; user.listenOnly = joinedUser.listenOnly; + user.me = (user.userID == UserManager.getInstance().getConference().getMyUserId()) trace(LOG + "User status: hasStream " + joinedUser.hasStream); @@ -562,7 +552,36 @@ package org.bigbluebutton.modules.users.services var joinEvent:UserJoinedEvent = new UserJoinedEvent(UserJoinedEvent.JOINED); joinEvent.userID = user.userID; dispatcher.dispatchEvent(joinEvent); - + + if (user.guest) { + if (user.waitingForAcceptance) { + if (user.me) { + var waitCommand:BBBEvent = new BBBEvent(BBBEvent.WAITING_FOR_MODERATOR_ACCEPTANCE); + dispatcher.dispatchEvent(waitCommand); + } else { + var e:BBBEvent = new BBBEvent(BBBEvent.ADD_GUEST_TO_LIST); + e.payload.userId = user.userID; + e.payload.name = user.name; + dispatcher.dispatchEvent(e); + } + } else { + if (user.me) { + var allowedCommand:BBBEvent = new BBBEvent(BBBEvent.MODERATOR_ALLOWED_ME_TO_JOIN); + dispatcher.dispatchEvent(allowedCommand); + } else { + var removeGuest:BBBEvent = new BBBEvent(BBBEvent.REMOVE_GUEST_FROM_LIST); + removeGuest.payload.userId = user.userID; + dispatcher.dispatchEvent(removeGuest); + } + } + } + + if (user.me && (!user.guest || !user.waitingForAcceptance)) { + if (onAllowedToJoin != null) { + onAllowedToJoin(); + onAllowedToJoin = null; + } + } } /** @@ -579,7 +598,7 @@ package org.bigbluebutton.modules.users.services if(map.status == "mood") { dispatcher.dispatchEvent(new ChangeStatusBtnEvent(map.userID, statusArray[0])); } - + if (msg.status == "presenter"){ var e:PresenterStatusEvent = new PresenterStatusEvent(PresenterStatusEvent.PRESENTER_NAME_CHANGE); e.userID = map.userID; @@ -599,18 +618,6 @@ package org.bigbluebutton.modules.users.services } } - public function handleGuestRequestedToEnter(msg:Object):void { - trace(LOG + "*** handleRequestedToEnter " + msg.msg + " **** \n"); - var map:Object = JSON.parse(msg.msg); - if(UsersUtil.amIModerator() && UsersUtil.amIWaitForModerator() == false) { - var e:AddGuestEvent = new AddGuestEvent(); - e.userid = map.userId; - e.name = map.name; - var dispatcher:Dispatcher = new Dispatcher(); - dispatcher.dispatchEvent(e); - } - } - public function handleGuestPolicyChanged(msg:Object):void { trace(LOG + "*** handleGuestPolicyChanged " + msg.msg + " **** \n"); var map:Object = JSON.parse(msg.msg); @@ -626,69 +633,15 @@ package org.bigbluebutton.modules.users.services var policy:BBBEvent = new BBBEvent(BBBEvent.RETRIEVE_GUEST_POLICY); policy.payload['guestPolicy'] = map.guestPolicy; - - if(UsersUtil.amIGuest()) { - if(map.guestPolicy == "ALWAYS_DENY") - dispatcher.dispatchEvent(new BBBEvent(BBBEvent.DENY_GUEST)); - else if(map.guestPolicy == "ALWAYS_ACCEPT") - dispatcher.dispatchEvent(new BBBEvent(BBBEvent.ACCEPT_GUEST)); - else - dispatcher.dispatchEvent(new BBBEvent(BBBEvent.ASK_TO_ACCEPT_GUEST)); - } dispatcher.dispatchEvent(policy); } - public function handleResponseToGuest(msg:Object):void { - trace(LOG + "*** handleResponseToGuest " + msg.msg + " **** \n"); + public function handleGuestAccessDenied(msg:Object):void { + trace(LOG + "*** handleGuestAccessDenied " + msg.msg + " ****"); var map:Object = JSON.parse(msg.msg); - var dispatcher:Dispatcher = new Dispatcher(); - - if(UsersUtil.getMyUserID() == map.userId && UsersUtil.amIWaitForModerator()) { - UsersUtil.setWaitForModerator(false); - if(map.response == false) { - var kickEvent:BBBEvent = new BBBEvent(BBBEvent.KICK_GUEST); - kickEvent.payload.userId = map.userId; - dispatcher.dispatchEvent(kickEvent); - } - else { - var allowCommand:ModeratorRespEvent = new ModeratorRespEvent(ModeratorRespEvent.GUEST_ALLOWED); - dispatcher.dispatchEvent(allowCommand); - } - } - - if(UsersUtil.amIModerator()) { - var e:RemoveGuestRequestEvent = new RemoveGuestRequestEvent(RemoveGuestRequestEvent.GUEST_EVENT); - e.userid = map.userId; - dispatcher.dispatchEvent(e); - } - } - - public function handleGetGuestsWaitingReply(msg:Object):void { - trace(LOG + "*** handleGetGuestsPolicyReply " + msg.msg + " **** \n"); - var map:Object = JSON.parse(msg.msg); - - if(UsersUtil.amIModerator()) { - var guests:Array = map.guestsWaiting.split(","); - for each(var guest:String in guests) { - if(guest != "") { - var pairSplited:Array = guest.split(":"); - var addGuestEvent:AddGuestEvent = new AddGuestEvent(AddGuestEvent.ADD_GUEST); - addGuestEvent.userid = pairSplited[0]; - addGuestEvent.name = pairSplited[1]; - var dispatcher:Dispatcher = new Dispatcher(); - dispatcher.dispatchEvent(addGuestEvent); - } - } - } - } - - public function handleGuestKicked(msg:Object):void { - trace(LOG + "*** handleGuestKicked " + msg.msg + " **** \n"); - var map:Object = JSON.parse(msg.msg); - - if (UsersUtil.getMyUserID() == map.guestId){ - var dispatcher:Dispatcher = new Dispatcher(); - dispatcher.dispatchEvent(new LogoutEvent(LogoutEvent.GUEST_KICKED_OUT)); + + if (UsersUtil.getMyUserID() == map.userId) { + dispatcher.dispatchEvent(new LogoutEvent(LogoutEvent.MODERATOR_DENIED_ME)); } } } diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as index 516ec283fa..7bc7b00df6 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as @@ -395,58 +395,11 @@ package org.bigbluebutton.modules.users.services ); } - public function queryForGuestsWaiting():void { - trace(LOG + "queryForGuestsWaiting"); - var _nc:ConnectionManager = BBB.initConnectionManager(); - _nc.sendMessage( - "participants.getGuestsWaiting", - function(result:String):void { // On successful result - LogUtil.debug(result); - }, - function(status:String):void { // status - On error occurred - LogUtil.error(status); - } - ); - } - - public function kickGuest(userId:String):void { - trace(LOG + "kickGuest userID:[" + userId + "]"); - var _nc:ConnectionManager = BBB.initConnectionManager(); - _nc.sendMessage( - "participants.kickGuest", - function(result:String):void { // On successful result - LogUtil.debug(result); - }, - function(status:String):void { // status - On error occurred - LogUtil.error(status); - }, - userId - ); - } - - public function guestDisconnect():void { - //TODO: Still need this? - } - - public function askToEnter():void { - trace(LOG + "askToEnter - userID:[" + UsersUtil.getMyUserID() + "]"); - var _nc:ConnectionManager = BBB.initConnectionManager(); - _nc.sendMessage( - "participants.askingToEnter", - function(result:String):void { // On successful result - LogUtil.debug(result); - }, - function(status:String):void { // status - On error occurred - LogUtil.error(status); - } - ); - } - public function responseToGuest(userId:String, response:Boolean):void { - trace(LOG + "responseToGuest - guestID:[" + userId + "] response:[" + response + "]"); + trace(LOG + "responseToGuest - userId:[" + userId + "] response:[" + response + "]"); var message:Object = new Object(); - message["guestID"] = userId; + message["userId"] = userId; message["response"] = response; var _nc:ConnectionManager = BBB.initConnectionManager(); @@ -463,18 +416,7 @@ package org.bigbluebutton.modules.users.services } public function responseToAllGuests(response:Boolean):void { - trace(LOG + "responseToAllGuests - response:[" + response + "]"); - var _nc:ConnectionManager = BBB.initConnectionManager(); - _nc.sendMessage( - "participants.responseToAllGuests", - function(result:String):void { // On successful result - LogUtil.debug(result); - }, - function(status:String):void { // status - On error occurred - LogUtil.error(status); - }, - response - ); + responseToGuest(null, response); } } -} +} 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 5fc34c09d1..ad4267e475 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 @@ -1853,6 +1853,8 @@ class ApiController { userID("${att.externalUserId}") fullName("${att.fullname}") role("${att.role}") + guest("${att.guest}") + waitingForAcceptance("${att.waitingForAcceptance}") isPresenter("${att.isPresenter()}") isListeningOnly("${att.isListeningOnly()}") hasJoinedVoice("${att.isVoiceJoined()}") diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java b/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java index 9f91228324..beedec7591 100755 --- a/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java +++ b/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java @@ -589,7 +589,7 @@ public class MeetingService implements MessageListener { log.debug("User joined in meeting[{}]", message.meetingId); Meeting m = getMeeting(message.meetingId); if (m != null) { - User user = new User(message.userId, message.externalUserId, message.name, message.role, message.guest); + User user = new User(message.userId, message.externalUserId, message.name, message.role, message.guest, message.waitingForAcceptance); m.userJoined(user); log.info("New user in meeting [" + message.meetingId + "] user [" + user.getFullname() + "]"); @@ -601,8 +601,10 @@ public class MeetingService implements MessageListener { logData.put("externalUserId", user.getExternalUserId()); logData.put("username", user.getFullname()); logData.put("role", user.getRole()); - logData.put("event", "user_joined_meeting"); - logData.put("description", "User had joined the meeting."); + logData.put("guest", user.isGuest()); + logData.put("waitingForAcceptance", user.isWaitingForAcceptance()); + logData.put("event", MessagingConstants.USER_JOINED_EVENT); + logData.put("description", "User has joined the meeting."); Gson gson = new Gson(); String logStr = gson.toJson(logData); @@ -630,8 +632,10 @@ public class MeetingService implements MessageListener { logData.put("externalUserId", user.getExternalUserId()); logData.put("username", user.getFullname()); logData.put("role", user.getRole()); - logData.put("event", "user_joined_meeting"); - logData.put("description", "User had joined the meeting."); + logData.put("guest", user.isGuest()); + logData.put("waitingForAcceptance", user.isWaitingForAcceptance()); + logData.put("event", MessagingConstants.USER_LEFT_EVENT); + logData.put("description", "User left the meeting."); Gson gson = new Gson(); String logStr = gson.toJson(logData); diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/api/domain/User.java b/bigbluebutton-web/src/java/org/bigbluebutton/api/domain/User.java index 9f5dcf5d44..87a6d9bbb4 100755 --- a/bigbluebutton-web/src/java/org/bigbluebutton/api/domain/User.java +++ b/bigbluebutton-web/src/java/org/bigbluebutton/api/domain/User.java @@ -32,16 +32,18 @@ public class User { private String role; private Map status; private Boolean guest; + private Boolean waitingForAcceptance; private Boolean listeningOnly = false; private Boolean voiceJoined = false; private List streams; - public User(String internalUserId, String externalUserId, String fullname, String role, Boolean guest) { + public User(String internalUserId, String externalUserId, String fullname, String role, Boolean guest, Boolean waitingForAcceptance) { this.internalUserId = internalUserId; this.externalUserId = externalUserId; this.fullname = fullname; this.role = role; this.guest = guest; + this.waitingForAcceptance = waitingForAcceptance; this.status = new ConcurrentHashMap(); this.streams = Collections.synchronizedList(new ArrayList()); } @@ -68,6 +70,14 @@ public class User { public Boolean isGuest() { return this.guest; } + + public void setWaitingForAcceptance(Boolean waitingForAcceptance) { + this.waitingForAcceptance = waitingForAcceptance; + } + + public Boolean isWaitingForAcceptance() { + return this.waitingForAcceptance; + } public String getFullname() { return fullname; diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/Constants.java b/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/Constants.java index b4b19d86e2..a7472fdd4e 100644 --- a/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/Constants.java +++ b/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/Constants.java @@ -93,4 +93,5 @@ public class Constants { public static final String CREATE_TIME = "create_time"; public static final String CREATE_DATE = "create_date"; public static final String GUEST = "guest"; + public static final String WAITING_FOR_ACCEPTANCE = "waiting_for_acceptance"; } diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/MeetingMessageHandler.java b/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/MeetingMessageHandler.java index a750d054b0..df6037d137 100755 --- a/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/MeetingMessageHandler.java +++ b/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/MeetingMessageHandler.java @@ -106,9 +106,10 @@ public class MeetingMessageHandler implements MessageHandler { String username = user.get("name").getAsString(); String role = user.get("role").getAsString(); Boolean guest = user.get("guest").getAsBoolean(); + Boolean waitingForAcceptance = user.get("waiting_for_acceptance").getAsBoolean(); for (MessageListener listener : listeners) { - listener.handle(new UserJoined(meetingId, userid, externuserid, username, role, guest)); + listener.handle(new UserJoined(meetingId, userid, externuserid, username, role, guest, waitingForAcceptance)); } } else if(MessagingConstants.USER_STATUS_CHANGE_EVENT.equalsIgnoreCase(messageName)) { System.out.println("Handling [" + messageName + "] message."); diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/messages/UserJoined.java b/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/messages/UserJoined.java index 380207505e..0970fcea48 100755 --- a/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/messages/UserJoined.java +++ b/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/messages/UserJoined.java @@ -7,13 +7,15 @@ public class UserJoined implements IMessage { public final String name; public final String role; public final Boolean guest; + public final Boolean waitingForAcceptance; - public UserJoined(String meetingId, String userId, String externalUserId, String name, String role, Boolean guest) { + public UserJoined(String meetingId, String userId, String externalUserId, String name, String role, Boolean guest, Boolean waitingForAcceptance) { this.meetingId = meetingId; this.userId = userId; this.externalUserId = externalUserId; this.name = name; this.role = role; this.guest = guest; + this.waitingForAcceptance = waitingForAcceptance; } }