You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2016/09/29 03:05:53 UTC

svn commit: r1762732 [2/2] - in /openmeetings/application: branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ branches/3.2.x/openmeetings-flash/src/main/swf/ branches/3.2.x/openmeetings-flash/src/main/swf/base/ bra...

Modified: openmeetings/application/trunk/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ScopeApplicationAdapter.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ScopeApplicationAdapter.java?rev=1762732&r1=1762731&r2=1762732&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ScopeApplicationAdapter.java (original)
+++ openmeetings/application/trunk/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ScopeApplicationAdapter.java Thu Sep 29 03:05:52 2016
@@ -985,6 +985,10 @@ public class ScopeApplicationAdapter ext
 		return -1L;
 	}
 
+	public static long nextBroadCastId() {
+		return broadCastCounter.getAndIncrement();
+	}
+
 	/**
 	 * there will be set an attribute called "broadCastCounter" this is the name
 	 * this user will publish his stream
@@ -997,7 +1001,7 @@ public class ScopeApplicationAdapter ext
 			IConnection current = Red5.getConnectionLocal();
 			String streamid = current.getClient().getId();
 			Client client = sessionManager.getClientByStreamId(streamid, null);
-			client.setBroadCastID(broadCastCounter.getAndIncrement());
+			client.setBroadCastID(nextBroadCastId());
 			sessionManager.updateClientByStreamId(streamid, client, false, null);
 			return client.getBroadCastID();
 		} catch (Exception err) {
@@ -1009,49 +1013,37 @@ public class ScopeApplicationAdapter ext
 	/**
 	 * this must be set _after_ the Video/Audio-Settings have been chosen (see
 	 * editrecordstream.lzx) but _before_ anything else happens, it cannot be
-	 * applied _after_ the stream has started! avsettings can be: av - video and
-	 * audio a - audio only v - video only n - no a/v only static image
+	 * applied _after_ the stream has started! 
+	 * avsettings can be: 
+	 * 		av - video and audio
+	 * 		a - audio only
+	 * 		v - video only
+	 * 		n - no a/v only static image
 	 * furthermore
 	 * 
 	 * @param avsettings
-	 * @param newMessage
 	 * @param vWidth
 	 * @param vHeight
-	 * @param roomId
-	 * @param publicSID
-	 * @param interviewPodId
+	 * 
 	 * @return RoomClient being updated in case of no errors, null otherwise
 	 */
-	public Client setUserAVSettings(String avsettings,
-			Object newMessage, Integer vWidth, Integer vHeight, 
-			long roomId, String publicSID, Integer interviewPodId) {
+	public Client setUserAVSettings(String avsettings, Integer vWidth, Integer vHeight) {
 		try {
-			IConnection current = Red5.getConnectionLocal();
-			IClient c = current.getClient();
-			String streamid = c.getId();
-			log.debug("-----------  setUserAVSettings {} {} {}", new Object[] {streamid, publicSID, avsettings, newMessage});
-			Client parentClient = sessionManager.getClientByPublicSID(publicSID, null);
+			String streamid = Red5.getConnectionLocal().getClient().getId();
+			log.debug("-----------  setUserAVSettings {} {} {}", new Object[] {streamid, avsettings});
 			Client currentClient = sessionManager.getClientByStreamId(streamid, null);
-			if (parentClient == null || currentClient == null) {
+			if (currentClient == null) {
 				log.warn("Failed to find appropriate clients");
 				return null;
 			}
 			currentClient.setAvsettings(avsettings);
-			currentClient.setRoomId(roomId);
-			currentClient.setPublicSID(publicSID);
 			currentClient.setVWidth(vWidth);
 			currentClient.setVHeight(vHeight);
-			currentClient.setInterviewPodId(interviewPodId);
-			currentClient.setUserId(parentClient.getUserId());
-			currentClient.setLastname(parentClient.getLastname());
-			currentClient.setFirstname(parentClient.getFirstname());
-			currentClient.setPicture_uri(parentClient.getPicture_uri());
 			sessionManager.updateAVClientByStreamId(streamid, currentClient, null);
-			SessionVariablesUtil.initClient(c, publicSID);
 
-			HashMap<String, Object> hsm = new HashMap<String, Object>();
+			HashMap<String, Object> hsm = new HashMap<>();
 			hsm.put("client", currentClient);
-			hsm.put("message", newMessage);
+			hsm.put("message", new Object[]{"avsettings", 0, avsettings});
 
 			sendMessageToCurrentScope("sendVarsToMessageWithClient", hsm, true);
 			return currentClient;

Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java?rev=1762732&r1=1762731&r2=1762732&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java Thu Sep 29 03:05:52 2016
@@ -39,6 +39,7 @@ import java.util.concurrent.ConcurrentHa
 
 import org.apache.openmeetings.IApplication;
 import org.apache.openmeetings.core.remote.MainService;
+import org.apache.openmeetings.core.remote.red5.ScopeApplicationAdapter;
 import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
 import org.apache.openmeetings.db.dao.label.LabelDao;
 import org.apache.openmeetings.db.dao.user.UserDao;
@@ -49,6 +50,7 @@ import org.apache.openmeetings.db.entity
 import org.apache.openmeetings.db.entity.user.User;
 import org.apache.openmeetings.db.entity.user.User.Type;
 import org.apache.openmeetings.util.InitializationContainer;
+import org.apache.openmeetings.web.app.Client.Activity;
 import org.apache.openmeetings.web.pages.AccessDeniedPage;
 import org.apache.openmeetings.web.pages.ActivatePage;
 import org.apache.openmeetings.web.pages.HashPage;
@@ -232,8 +234,24 @@ public class Application extends Authent
 			rcl.setIsSuperModerator(client.hasRight(Right.superModerator));
 			rcl.setIsMod(client.hasRight(Right.moderator));
 			rcl.setIsBroadcasting(client.hasRight(Right.audio));
-			rcl.setCanVideo(client.hasRight(Right.video));
+			rcl.setCanVideo(client.hasRight(Right.video) && client.hasActivity(Activity.broadcastVideo));
 			rcl.setCanDraw(client.hasRight(Right.whiteBoard));
+			if (client.hasActivity(Activity.broadcastAudio) || client.hasActivity(Activity.broadcastVideo)) {
+				rcl.setIsBroadcasting(true);
+				rcl.setBroadCastID(ScopeApplicationAdapter.nextBroadCastId());
+				StringBuilder sb = new StringBuilder();
+				if (client.hasActivity(Activity.broadcastAudio)) {
+					sb.append('a');
+				}
+				if (client.hasActivity(Activity.broadcastVideo)) {
+					sb.append('v');
+				}
+				rcl.setAvsettings(sb.toString());
+			} else {
+				rcl.setAvsettings("n");
+				rcl.setIsBroadcasting(false);
+				rcl.setBroadCastID(-1L);
+			}
 		}
 		return rcl;
 	}

Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java?rev=1762732&r1=1762731&r2=1762732&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java Thu Sep 29 03:05:52 2016
@@ -39,10 +39,11 @@ public class Client implements IDataProv
 	private static final long serialVersionUID = 1L;
 
 	public enum Activity {
-		broadcast
+		broadcastAudio //sends Audio to the room
+		, broadcastVideo //sends Video to the room
 		, share
 		, record
-		, publish
+		, publish //sends A/V to external server
 		, muted
 		, exclusive
 	}

Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java?rev=1762732&r1=1762731&r2=1762732&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java Thu Sep 29 03:05:52 2016
@@ -21,6 +21,7 @@ package org.apache.openmeetings.web.room
 import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
 import static org.apache.openmeetings.web.app.Application.addUserToRoom;
 import static org.apache.openmeetings.web.app.Application.getBean;
+import static org.apache.openmeetings.web.app.Application.getOnlineClient;
 import static org.apache.openmeetings.web.app.Application.getRoomClients;
 import static org.apache.openmeetings.web.app.WebSession.getDateFormat;
 import static org.apache.openmeetings.web.app.WebSession.getUserId;
@@ -29,6 +30,7 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Calendar;
 
+import org.apache.directory.api.util.Strings;
 import org.apache.openmeetings.core.remote.ConferenceLibrary;
 import org.apache.openmeetings.core.remote.red5.ScopeApplicationAdapter;
 import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
@@ -283,14 +285,31 @@ public class RoomPanel extends BasePanel
 						}
 						break;
 					case recordingStoped:
-						//TODO check recordingUser == ((TextRoomMessage)m).getText();
-						recordingUser = null;
-						menu.update(handler);
+						{
+							String uid = ((TextRoomMessage)m).getText();
+							if (Strings.isEmpty(uid) || !uid.equals(recordingUser)) {
+								log.error("Not existing/BAD user has stopped recording {} != {} !!!!", uid, recordingUser);
+							}
+							recordingUser = null;
+							menu.update(handler);
+							Client c = getOnlineClient(uid);
+							if (c == null) {
+								log.error("Not existing user has stopped recording {} !!!!", uid);
+								return;
+							}
+							c.getActivities().remove(Client.Activity.record);
+						}
 						break;
 					case recordingStarted:
 						{
 							recordingUser = ((TextRoomMessage)m).getText();
 							menu.update(handler);
+							Client c = getOnlineClient(recordingUser);
+							if (c == null) {
+								log.error("Not existing user has started recording {} !!!!", recordingUser);
+								return;
+							}
+							c.getActivities().add(Client.Activity.record);
 						}
 						break;
 					case sharingStoped:

Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomSidebar.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomSidebar.java?rev=1762732&r1=1762731&r2=1762732&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomSidebar.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomSidebar.java Thu Sep 29 03:05:52 2016
@@ -27,9 +27,11 @@ import static org.apache.wicket.ajax.att
 import java.util.ArrayList;
 import java.util.Arrays;
 
+import org.apache.openmeetings.db.entity.room.Room;
 import org.apache.openmeetings.db.entity.room.Room.Right;
 import org.apache.openmeetings.db.entity.room.Room.RoomElement;
 import org.apache.openmeetings.web.app.Client;
+import org.apache.openmeetings.web.app.Client.Activity;
 import org.apache.openmeetings.web.room.RoomPanel;
 import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
 import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -55,10 +57,13 @@ public class RoomSidebar extends Panel {
 	private static final long serialVersionUID = 1L;
 	private static final Logger log = Red5LoggerFactory.getLogger(RoomSidebar.class, webAppRootKey);
 	public static final String FUNC_TOGGLE_RIGHT = "toggleRight";
+	public static final String FUNC_TOGGLE_ACTIVITY = "toggleActivity";
 	public static final String FUNC_ACTION = "roomAction";
 	public static final String PARAM_ACTION = "action";
+	public static final String PARAM_ACTIVITY = "activity";
 	public static final String PARAM_RIGHT = "right";
 	public static final String PARAM_UID = "uid";
+	public static final String PARAM_POD = "pod";
 	private final RoomPanel room;
 	private final TabbedPanel tabs;
 	private final ITab userTab;
@@ -67,6 +72,11 @@ public class RoomSidebar extends Panel {
 	private final RoomFilePanel roomFiles;
 	private final SelfIconsPanel selfRights;
 	private boolean showFiles;
+	public enum Pod {
+		none
+		, right
+		, left
+	};
 	private final ListView<Client> users = new ListView<Client>("user", new ArrayList<Client>()) {
 		private static final long serialVersionUID = 1L;
 
@@ -115,7 +125,35 @@ public class RoomSidebar extends Panel {
 					room.requestRight(target, right);
 				}
 			} catch (Exception e) {
-				log.error("Unexpected exception while processing activity action", e);
+				log.error("Unexpected exception while toggle 'right'", e);
+			}
+		}
+	};
+	private final AbstractDefaultAjaxBehavior toggleActivity = new AbstractDefaultAjaxBehavior() {
+		private static final long serialVersionUID = 1L;
+
+		@Override
+		protected void respond(AjaxRequestTarget target) {
+			try {
+				String uid = getRequest().getRequestParameters().getParameterValue(PARAM_UID).toString(); 
+				if (Strings.isEmpty(uid)) {
+					return;
+				}
+				Activity a = Activity.valueOf(getRequest().getRequestParameters().getParameterValue(PARAM_ACTIVITY).toString()); 
+				Client c = getOnlineClient(uid);
+				if (c == null) {
+					return;
+				}
+				if (activityAllowed(c, a, room.getRoom())) {
+					if (c.hasActivity(a)) {
+						c.getActivities().remove(a);
+					} else {
+						c.getActivities().add(a);
+					}
+					room.broadcast(target, c);
+				}
+			} catch (Exception e) {
+				log.error("Unexpected exception while toggle 'activity'", e);
 			}
 		}
 	};
@@ -165,13 +203,14 @@ public class RoomSidebar extends Panel {
 		roomFiles = new RoomFilePanel("tree", room);
 		selfRights = new SelfIconsPanel("icons", room.getClient(), room);
 		add(upload = new UploadDialog("upload", room, roomFiles));
-		add(toggleRight, action);
+		add(toggleRight, toggleActivity, action);
 	}
 	
 	@Override
 	public void renderHead(IHeaderResponse response) {
 		super.renderHead(response);
 		response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forScript(getNamedFunction(FUNC_TOGGLE_RIGHT, toggleRight, explicit(PARAM_RIGHT), explicit(PARAM_UID)), FUNC_TOGGLE_RIGHT)));
+		response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forScript(getNamedFunction(FUNC_TOGGLE_ACTIVITY, toggleActivity, explicit(PARAM_ACTIVITY), explicit(PARAM_UID), explicit(PARAM_POD)), FUNC_TOGGLE_ACTIVITY)));
 		response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forScript(getNamedFunction(FUNC_ACTION, action, explicit(PARAM_ACTION), explicit(PARAM_UID)), FUNC_ACTION)));
 	}
 	
@@ -223,4 +262,25 @@ public class RoomSidebar extends Panel {
 	public void showUpload(IPartialPageRequestHandler handler) {
 		upload.open(handler);
 	}
+
+	public static boolean activityAllowed(Client c, Activity a, Room room) {
+		switch (a) {
+			case broadcastVideo:
+				{
+					if (room.isAudioOnly()) {
+						return false;
+					}
+					if (c.hasRight(Right.moderator)) {
+						return true;
+					}
+					for (Right r : new Right[]{Right.video}) {
+						if (!c.hasRight(r)) {
+							return false;
+						}
+					}
+				}
+				break;
+		}
+		return false;
+	}
 }

Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/SelfIconsPanel.html
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/SelfIconsPanel.html?rev=1762732&r1=1762731&r2=1762732&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/SelfIconsPanel.html (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/SelfIconsPanel.html Thu Sep 29 03:05:52 2016
@@ -21,5 +21,6 @@
 <html xmlns:wicket="http://wicket.apache.org">
 <wicket:extend>
 	<span wicket:id="settings"></span>
+	<span wicket:id="cam"></span>
 </wicket:extend>
 </html>

Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/SelfIconsPanel.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/SelfIconsPanel.java?rev=1762732&r1=1762731&r2=1762732&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/SelfIconsPanel.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/SelfIconsPanel.java Thu Sep 29 03:05:52 2016
@@ -21,15 +21,18 @@ package org.apache.openmeetings.web.room
 import org.apache.openmeetings.web.app.Client;
 import org.apache.openmeetings.web.room.RoomPanel;
 import org.apache.openmeetings.web.room.sidebar.icon.SettingsIcon;
+import org.apache.openmeetings.web.room.sidebar.icon.activity.CamActivityIcon;
 import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
 
 public class SelfIconsPanel extends ClientIconsPanel {
 	private static final long serialVersionUID = 1L;
 	private final SettingsIcon settings;
+	private final CamActivityIcon cam;
 
 	public SelfIconsPanel(String id, Client client, RoomPanel room) {
 		super(id, client, room);
-		add(settings = new SettingsIcon("settings", client, room));
+		add(settings = new SettingsIcon("settings", client, room)
+			, cam = new CamActivityIcon("cam", client, room));
 	}
 
 	@Override
@@ -42,5 +45,6 @@ public class SelfIconsPanel extends Clie
 	public void update(IPartialPageRequestHandler handler) {
 		super.update(handler);
 		settings.update(handler);
+		cam.update(handler);
 	}
 }

Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/SettingsIcon.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/SettingsIcon.java?rev=1762732&r1=1762731&r2=1762732&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/SettingsIcon.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/SettingsIcon.java Thu Sep 29 03:05:52 2016
@@ -42,6 +42,6 @@ public class SettingsIcon extends Client
 
 	@Override
 	protected String getScript() {
-		return String.format("$('#lzapp').showAvSettings(%s);", Room.Type.interview == room.getRoom().getType());
+		return String.format("document.getElementById('lzapp').showAvSettings(%s);", Room.Type.interview == room.getRoom().getType());
 	}
 }

Added: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/activity/CamActivityIcon.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/activity/CamActivityIcon.java?rev=1762732&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/activity/CamActivityIcon.java (added)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/activity/CamActivityIcon.java Thu Sep 29 03:05:52 2016
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.room.sidebar.icon.activity;
+
+import org.apache.openmeetings.web.app.Client;
+import org.apache.openmeetings.web.app.Client.Activity;
+import org.apache.openmeetings.web.room.RoomPanel;
+
+public class CamActivityIcon extends RoomActivityIcon {
+	private static final long serialVersionUID = 1L;
+
+	public CamActivityIcon(String id, Client client, RoomPanel room) {
+		super(id, client, Activity.broadcastVideo, room);
+		mainCssClass = "activity cam ";
+	}
+
+	@Override
+	protected String getTitle() {
+		return getString("687");
+	}
+
+	@Override
+	protected boolean isClickable() {
+		return true;
+	}
+
+}

Added: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/activity/RoomActivityIcon.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/activity/RoomActivityIcon.java?rev=1762732&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/activity/RoomActivityIcon.java (added)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/icon/activity/RoomActivityIcon.java Thu Sep 29 03:05:52 2016
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.room.sidebar.icon.activity;
+
+import static org.apache.openmeetings.web.room.sidebar.RoomSidebar.FUNC_TOGGLE_ACTIVITY;
+
+import org.apache.openmeetings.web.app.Client;
+import org.apache.openmeetings.web.app.Client.Activity;
+import org.apache.openmeetings.web.room.RoomPanel;
+import org.apache.openmeetings.web.room.sidebar.RoomSidebar;
+import org.apache.openmeetings.web.room.sidebar.RoomSidebar.Pod;
+import org.apache.openmeetings.web.room.sidebar.icon.ClientIcon;
+
+public abstract class RoomActivityIcon extends ClientIcon {
+	private static final long serialVersionUID = 1L;
+	private static final String CLS_ENABLED = "enabled ";
+	protected final Activity activity;
+	protected final Pod pod = Pod.none;
+
+	public RoomActivityIcon(String id, Client client, Activity activity, RoomPanel room) {
+		super(id, client, room);
+		this.activity = activity;
+	}
+
+	@Override
+	protected String getScript() {
+		return String.format("%s('%s', '%s', '%s');", FUNC_TOGGLE_ACTIVITY, activity.name(), client.getUid(), pod.name());
+	}
+
+	protected boolean visible() {
+		return RoomSidebar.activityAllowed(client, activity, room.getRoom());
+	}
+
+	@Override
+	protected void internalUpdate() {
+		setVisible(visible());
+		if (client.hasActivity(activity)) {
+			cssClass.append(CLS_ENABLED);
+		}
+	}
+}