/** * Returns existing chat rooms for the given <tt>chatRoomProvider</tt>. * * @param chatRoomProvider the <tt>ChatRoomProviderWrapper</tt>, which chat rooms we're looking * for * @return existing chat rooms for the given <tt>chatRoomProvider</tt> */ public List<String> getExistingChatRooms(ChatRoomProviderWrapper chatRoomProvider) { if (chatRoomProvider == null) return null; ProtocolProviderService protocolProvider = chatRoomProvider.getProtocolProvider(); if (protocolProvider == null) return null; OperationSetMultiUserChat groupChatOpSet = protocolProvider.getOperationSet(OperationSetMultiUserChat.class); if (groupChatOpSet == null) return null; List<String> chatRooms = null; try { chatRooms = groupChatOpSet.getExistingChatRooms(); } catch (OperationFailedException e) { if (logger.isTraceEnabled()) logger.trace( "Failed to obtain existing chat rooms for server: " + protocolProvider.getAccountID().getService(), e); } catch (OperationNotSupportedException e) { if (logger.isTraceEnabled()) logger.trace( "Failed to obtain existing chat rooms for server: " + protocolProvider.getAccountID().getService(), e); } return chatRooms; }
/** * Joins the room with the given name though the given chat room provider. * * @param chatRoomName the name of the room to join. * @param chatRoomProvider the chat room provider to join through. */ public void joinChatRoom(String chatRoomName, ChatRoomProviderWrapper chatRoomProvider) { OperationSetMultiUserChat groupChatOpSet = chatRoomProvider.getProtocolProvider().getOperationSet(OperationSetMultiUserChat.class); ChatRoom chatRoom = null; try { chatRoom = groupChatOpSet.findRoom(chatRoomName); } catch (Exception e) { if (logger.isTraceEnabled()) logger.trace("Un exception occurred while searching for room:" + chatRoomName, e); } if (chatRoom != null) { ChatRoomWrapper chatRoomWrapper = chatRoomList.findChatRoomWrapperFromChatRoom(chatRoom); if (chatRoomWrapper == null) { ChatRoomProviderWrapper parentProvider = chatRoomList.findServerWrapperFromProvider(chatRoom.getParentProvider()); chatRoomWrapper = new ChatRoomWrapperImpl(parentProvider, chatRoom); chatRoomList.addChatRoom(chatRoomWrapper); fireChatRoomListChangedEvent(chatRoomWrapper, ChatRoomListChangeEvent.CHAT_ROOM_ADDED); } joinChatRoom(chatRoomWrapper); } else MUCActivator.getAlertUIService() .showAlertDialog( MUCActivator.getResources().getI18NString("service.gui.ERROR"), MUCActivator.getResources() .getI18NString( "service.gui.CHAT_ROOM_NOT_EXIST", new String[] { chatRoomName, chatRoomProvider.getProtocolProvider().getAccountID().getService() })); }