/** * Leaves the given chat room. * * @param chatRoomWrapper the chat room to leave. * @return <tt>ChatRoomWrapper</tt> instance associated with the chat room. */ public ChatRoomWrapper leaveChatRoom(ChatRoomWrapper chatRoomWrapper) { ChatRoom chatRoom = chatRoomWrapper.getChatRoom(); if (chatRoom == null) { ResourceManagementService resources = MUCActivator.getResources(); MUCActivator.getAlertUIService() .showAlertDialog( resources.getI18NString("service.gui.WARNING"), resources.getI18NString("service.gui.CHAT_ROOM_LEAVE_NOT_CONNECTED")); return null; } if (chatRoom.isJoined()) chatRoom.leave(); ChatRoomWrapper existChatRoomWrapper = chatRoomList.findChatRoomWrapperFromChatRoom(chatRoom); if (existChatRoomWrapper == null) return null; // We save the choice of the user, before the chat room is really // joined, because even the join fails we want the next time when // we login to join this chat room automatically. ConfigurationUtils.updateChatRoomStatus( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID(), GlobalStatusEnum.OFFLINE_STATUS); return existChatRoomWrapper; }
/** * Handles adding a chat room provider. * * @param provider the provider. * @param addQueryResult indicates whether we should add the chat room to the query results or * fire an event without adding it to the results. */ private void providerAdded(ChatRoomProviderWrapper provider, boolean addQueryResult) { for (int i = 0; i < provider.countChatRooms(); i++) { ChatRoomWrapper chatRoom = provider.getChatRoom(i); addChatRoom( provider.getProtocolProvider(), chatRoom.getChatRoomName(), chatRoom.getChatRoomID(), addQueryResult, chatRoom.isAutojoin()); } }
/** * Opens a chat window for the chat room. * * @param room the chat room. */ public void openChatRoom(ChatRoomWrapper room) { if (room.getChatRoom() == null) { room = createChatRoom( room.getChatRoomName(), room.getParentProvider().getProtocolProvider(), new ArrayList<String>(), "", false, false, true); // leave the chatroom because getChatRoom().isJoined() returns true // otherwise if (room.getChatRoom().isJoined()) room.getChatRoom().leave(); } if (!room.getChatRoom().isJoined()) { String savedNick = ConfigurationUtils.getChatRoomProperty( room.getParentProvider().getProtocolProvider(), room.getChatRoomID(), "userNickName"); String subject = null; if (savedNick == null) { String[] joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( room.getParentProvider().getProtocolProvider(), room.getChatRoomID(), getDefaultNickname(room.getParentProvider().getProtocolProvider())); savedNick = joinOptions[0]; subject = joinOptions[1]; } if (savedNick != null) { joinChatRoom(room, savedNick, null, subject); } else return; } MUCActivator.getUIService().openChatRoomWindow(room); }
/** * Test equality of contact to chat room wrapper. This method does not rely on a chat room * instance, since that may not be available in case of removal. * * @param contact the contact * @param chatRoomWrapper the chat room wrapper * @return returns <tt>true</tt> if they are equal, or <tt>false</tt> if they are different. */ private boolean contactEqualsChatRoom( final ChatRoomSourceContact contact, final ChatRoomWrapper chatRoomWrapper) { return contact.getProvider() == chatRoomWrapper.getParentProvider().getProtocolProvider() && contact.getContactAddress().equals(chatRoomWrapper.getChatRoomID()); }