@Test public void validateRoomWithEmptyForm() { DataForm dataForm = new DataForm(DataForm.Type.result); DiscoverInfo discoInfo = new DiscoverInfo(); discoInfo.addExtension(dataForm); RoomInfo roomInfo = new RoomInfo(discoInfo); assertTrue(roomInfo.getDescription().isEmpty()); assertTrue(roomInfo.getSubject().isEmpty()); assertEquals(-1, roomInfo.getOccupantsCount()); }
/** * Returns true, if the MUC with the EntityBareJid multiUserChat is non-anonymous and members only (prerequisite * for OMEMO encryption in MUC). * * @param multiUserChat MUC * @return true if chat supports OMEMO * @throws XMPPException.XMPPErrorException if * @throws SmackException.NotConnectedException something * @throws InterruptedException goes * @throws SmackException.NoResponseException wrong */ public boolean multiUserChatSupportsOmemo(MultiUserChat multiUserChat) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException { EntityBareJid jid = multiUserChat.getRoom(); RoomInfo roomInfo = MultiUserChatManager.getInstanceFor(connection()).getRoomInfo(jid); return roomInfo.isNonanonymous() && roomInfo.isMembersOnly(); }
/** * Returns the discovered information of a given room without actually having to join the room. The server will * provide information only for rooms that are public. * * @param room the name of the room in the form "roomName@service" of which we want to discover its information. * @return the discovered information of a given room without actually having to join the room. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException * @throws InterruptedException */ public RoomInfo getRoomInfo(EntityBareJid room) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection()).discoverInfo(room); return new RoomInfo(info); }
roomNameValue.setText("n/a"); try { descriptionValue.setText(roomInfo.getDescription()); subjectValue.setText(roomInfo.getSubject()); if (roomInfo.getOccupantsCount() == -1) { occupantsValue.setText("n/a"); occupantsValue.setText(Integer.toString(roomInfo.getOccupantsCount())); roomNameValue.setText(roomInfo.getRoom().toString());
/** * Return the number of occupants in a room. * * @param roomJID the full JID of the conference room. (ex. dev@conference.jivesoftware.com) * @return the number of occupants in the room if available. * @throws XMPPException thrown if an error occured during retrieval of the information. * @throws InterruptedException */ public static int getNumberOfOccupants(EntityBareJid roomJID) throws SmackException, XMPPException, InterruptedException { final RoomInfo roomInfo = MultiUserChatManager.getInstanceFor( SparkManager.getConnection() ).getRoomInfo( roomJID ); return roomInfo.getOccupantsCount(); }
RoomInfo roomInfo = MultiUserChat.getRoomInfo(connection, "roomname@somehost.com") String roomDescription = roomInfo.getDescription()
/** * Returns true if the room is password protected or Members only * * @param roomjid * @return */ private boolean isPasswordProtected(EntityBareJid roomjid) { boolean result = false; try { RoomInfo rif = MultiUserChatManager.getInstanceFor( SparkManager.getConnection() ).getRoomInfo( roomjid ); result = rif.isMembersOnly() || rif.isPasswordProtected(); } catch (XMPPException | SmackException | NumberFormatException | InterruptedException e) { } return result; }
RoomInfo info = MultiUserChatManager.getInstanceFor( SparkManager.getConnection() ).getRoomInfo( chat.getRoom() ); if (!info.isPersistent()) { BookmarkManager.getBookmarkManager(SparkManager.getConnection()).removeBookmarkedConference(info.getRoom());
/** * Returns the discovered information of a given room without actually having to join the room. * The server will provide information only for rooms that are public. * * @param connection the XMPP connection to use for discovering information about the room. * @param room the name of the room in the form "roomName@service" of which we want to discover * its information. * @return the discovered information of a given room without actually having to join the room. * @throws XMPPException if an error occured while trying to discover information of a room. */ public static RoomInfo getRoomInfo(Connection connection, String room) throws XMPPException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room); return new RoomInfo(info); }
@Test public void validateRoomWithForm() { DataForm dataForm = new DataForm(DataForm.Type.result); FormField desc = new FormField("muc#roominfo_description"); desc.addValue("The place for all good witches!"); dataForm.addField(desc); FormField subject = new FormField("muc#roominfo_subject"); subject.addValue("Spells"); dataForm.addField(subject); FormField occupants = new FormField("muc#roominfo_occupants"); occupants.addValue("3"); dataForm.addField(occupants); DiscoverInfo discoInfo = new DiscoverInfo(); discoInfo.addExtension(dataForm); RoomInfo roomInfo = new RoomInfo(discoInfo); assertEquals("The place for all good witches!", roomInfo.getDescription()); assertEquals("Spells", roomInfo.getSubject()); assertEquals(3, roomInfo.getOccupantsCount()); } }
/** * Returns the discovered information of a given room without actually having to join the room. * The server will provide information only for rooms that are public. * * @param connection the XMPP connection to use for discovering information about the room. * @param room the name of the room in the form "roomName@service" of which we want to discover * its information. * @return the discovered information of a given room without actually having to join the room. * @throws XMPPException if an error occured while trying to discover information of a room. */ public static RoomInfo getRoomInfo(Connection connection, String room) throws XMPPException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room); return new RoomInfo(info); }
numberOfOccupants = roomInfo.getOccupantsCount(); if (numberOfOccupants == -1) {
/** * Returns the discovered information of a given room without actually having to join the room. * The server will provide information only for rooms that are public. * * @param connection the XMPP connection to use for discovering information about the room. * @param room the name of the room in the form "roomName@service" of which we want to discover * its information. * @return the discovered information of a given room without actually having to join the room. * @throws XMPPException if an error occured while trying to discover information of a room. */ public static RoomInfo getRoomInfo(Connection connection, String room) throws XMPPException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room); return new RoomInfo(info); }
/** * Returns the discovered information of a given room without actually having to join the room. * The server will provide information only for rooms that are public. * * @param connection the XMPP connection to use for discovering information about the room. * @param room the name of the room in the form "roomName@service" of which we want to discover * its information. * @return the discovered information of a given room without actually having to join the room. * @throws XMPPException if an error occured while trying to discover information of a room. */ public static RoomInfo getRoomInfo(XMPPConnection connection, String room) throws XMPPException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room); return new RoomInfo(info); }