From 9ec8bbdef5292aace4a9fb4a11a674aa066ca1cf Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Thu, 13 Feb 2014 12:24:06 +0200 Subject: Adds configuration property to hide remove chat room right hand menu item if the property is true and the user is owner of the room. --- .../impl/muc/MUCCustomContactActionService.java | 42 +++++++++++++++++----- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'src/net/java/sip/communicator/impl/muc') diff --git a/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java b/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java index c144072..154a3d5 100644 --- a/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java +++ b/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java @@ -38,6 +38,12 @@ public class MUCCustomContactActionService = new LinkedList>(); /** + * + */ + private static final String OWNER_CANT_REMOVE_CHATROOM_PROPERTY + = "net.sip.communicator.impl.muc.OWNER_CANT_REMOVE_CHATROOM"; + + /** * Array of names for the custom actions. */ private String[] actionsNames = { @@ -651,27 +657,45 @@ public class MUCCustomContactActionService if(!(actionSource instanceof ChatRoomSourceContact)) return false; + ChatRoomSourceContact contact + = (ChatRoomSourceContact) actionSource; + ChatRoomWrapper room = MUCActivator.getMUCService() + .findChatRoomWrapperFromSourceContact(contact); if(name.equals("autojoin") || name.equals("autojoin_pressed")) { - ChatRoomSourceContact contact - = (ChatRoomSourceContact) actionSource; - ChatRoomWrapper room = MUCActivator.getMUCService() - .findChatRoomWrapperFromSourceContact(contact); + if(name.equals("autojoin")) return !room.isAutojoin(); if(name.equals("autojoin_pressed")) return room.isAutojoin(); } + else if(name.equals("remove")) + { + if(room == null || room.getChatRoom() == null) + return true; + + if(room.getChatRoom().getUserRole().equals( + ChatRoomMemberRole.OWNER)) + { + if(MUCActivator.getConfigurationService().getBoolean( + OWNER_CANT_REMOVE_CHATROOM_PROPERTY, false)) + { + return false; + } + else + { + return true; + } + } + return true; + } else if(name.equals("destroy_chatroom")) { - ChatRoomSourceContact contact - = (ChatRoomSourceContact) actionSource; - ChatRoomWrapper room = MUCActivator.getMUCService() - .findChatRoomWrapperFromSourceContact(contact); if(room == null || room.getChatRoom() == null) return false; - if(room.getChatRoom().getUserRole().equals(ChatRoomMemberRole.OWNER)) + if(room.getChatRoom().getUserRole().equals( + ChatRoomMemberRole.OWNER)) return true; return false; } -- cgit v1.1