/** * Create or join a MUC if it is necessary, i.e. if not the MUC is not already joined. * * @param nickname the required nickname to use. * @param password the optional password required to join * @return A {@link MucCreateConfigFormHandle} if the room was created while joining, or {@code null} if the room was just joined. * @throws NoResponseException * @throws XMPPErrorException * @throws NotConnectedException * @throws InterruptedException * @throws NotAMucServiceException */ public MucCreateConfigFormHandle createOrJoinIfNecessary(Resourcepart nickname, String password) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAMucServiceException { if (isJoined()) { return null; } MucEnterConfiguration mucEnterConfiguration = getEnterConfigurationBuilder(nickname).withPassword( password).build(); try { return createOrJoin(mucEnterConfiguration); } catch (MucAlreadyJoinedException e) { return null; } }
@SmackIntegrationTest public void testMucBookmarksAutojoin(XMPPTCPConnection connection) throws InterruptedException, TestNotPossibleException, XMPPException, SmackException, IOException { final BookmarkManager bookmarkManager = BookmarkManager.getBookmarkManager(connection); if (!bookmarkManager.isSupported()) { throw new TestNotPossibleException("Private data storage not supported"); } final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(connection); final Resourcepart mucNickname = Resourcepart.from("Nick-" + StringUtils.randomString(6)); final String randomMucName = StringUtils.randomString(6); final DomainBareJid mucComponent = multiUserChatManager.getMucServiceDomains().get(0); final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom( Localpart.from(randomMucName), mucComponent)); MucCreateConfigFormHandle handle = muc.createOrJoin(mucNickname); if (handle != null) { handle.makeInstant(); } muc.leave(); bookmarkManager.addBookmarkedConference("Smack Inttest: " + testRunId, muc.getRoom(), true, mucNickname, null); connection.disconnect(); connection.connect().login(); // MucBookmarkAutojoinManager is also able to do its task automatically // after every login, it's not deterministic when this will be finished. // So we trigger it manually here. MucBookmarkAutojoinManager.getInstanceFor(connection).autojoinBookmarkedConferences(); assertTrue(muc.isJoined()); // If the test went well, leave the MUC muc.leave(); }
@Override public boolean isJoined() { return muc != null && muc.isJoined(); }
if (!groupChat.isJoined()) { LOG.debug("Joining room: {}", xmppChatRoom); try {
if ( !groupChat.isJoined() )
JOptionPane.showMessageDialog( SparkManager.getMainWindow(), error, Res.getString("message.error.unable.join.room"), JOptionPane.ERROR_MESSAGE ); else if ( groupChat.isJoined() && getValue() != null )
if (muc!=null&& (!kc.isConnected() || !muc.isJoined())) { try { kc.reconnect(muc);
/** * Action taking when a user clicks on the reject button. */ private void rejectInvitation() { removeUI(); try { ChatRoom chatRoom = SparkManager.getChatManager().getGroupChat(room); if (chatRoom instanceof GroupChatRoom) { GroupChatRoom gcr = (GroupChatRoom)chatRoom; if (!gcr.getMultiUserChat().isJoined()) { chatRoom.closeChatRoom(); } } } catch (ChatNotFoundException e) { // Ignore } try { MultiUserChatManager.getInstanceFor( SparkManager.getConnection() ).decline( room, inviter, "No thank you"); } catch ( SmackException.NotConnectedException | InterruptedException e ) { Log.warning( "Unable to decline inviation from " + inviter + " to join room " + room, e ); } }
if ( !groupChat.isJoined() )