org.jivesoftware.smackx.muc.RoomInfo Java Examples

The following examples show how to use org.jivesoftware.smackx.muc.RoomInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: YiIMUtils.java    From yiim_v2 with GNU General Public License v2.0 6 votes vote down vote up
public static boolean isRoomExist(String roomJid) throws Exception {
	XMPPConnection connection = XmppConnectionUtils.getInstance()
			.getRawConnection();
	if (connection == null || !connection.isAuthenticated()) {
		throw new Exception("no connections");
	}
	try {
		RoomInfo roomInfo = MultiUserChat.getRoomInfo(connection, roomJid);
		if (roomInfo != null) {
			return true;
		}
		return false;
	} catch (Exception e) {
		return false;
	}
}
 
Example #2
Source File: XmppManager.java    From weixin with Apache License 2.0 6 votes vote down vote up
/**
 * 获取服务器上所有会议室
 * 
 * @return
 * @throws XMPPException
 */
public List<FriendRooms> getConferenceRoom() throws XMPPException {
	List<FriendRooms> list = new ArrayList<FriendRooms>();
	new ServiceDiscoveryManager(getConnection());
	if (!MultiUserChat.getHostedRooms(getConnection(), getConnection().getServiceName()).isEmpty()) {

		for (HostedRoom k : MultiUserChat.getHostedRooms(getConnection(), getConnection().getServiceName())) {

			for (HostedRoom j : MultiUserChat.getHostedRooms(getConnection(), k.getJid())) {
				RoomInfo info2 = MultiUserChat.getRoomInfo(getConnection(), j.getJid());
				if (j.getJid().indexOf("@") > 0) {

					FriendRooms friendrooms = new FriendRooms();
					friendrooms.setName(j.getName());//聊天室的名称  
					friendrooms.setJid(j.getJid());//聊天室JID  
					friendrooms.setOccupants(info2.getOccupantsCount());//聊天室中占有者数量  
					friendrooms.setDescription(info2.getDescription());//聊天室的描述  
					friendrooms.setSubject(info2.getSubject());//聊天室的主题  
					list.add(friendrooms);
				}
			}
		}
	}
	return list;
}
 
Example #3
Source File: MultiRoomDiscoverActivity.java    From yiim_v2 with GNU General Public License v2.0 5 votes vote down vote up
public void onSearchClick(View view) {
	if (isStringInvalid(mSearchEditText.getText())) {
		showMsgDialog(getString(R.string.err_empty_search_content),
				getString(R.string.str_ok));
		return;
	}

	ArrayList<TabContactsModel> models = new ArrayList<TabContactsModel>();
	try {
		String roomJid = YiHanziToPinyin.getPinYin(mSearchEditText
				.getText().toString())
				+ "@conference."
				+ XmppConnectionUtils.getXmppHost();
		RoomInfo roomInfo = MultiUserChat.getRoomInfo(getXmppBinder()
				.getXmppConnection(), roomJid);
		if (roomInfo != null) {
			TabContactsModel model = new TabContactsModel();

			MultiChatDesc desc = MultiChatDesc.fromString(roomInfo
					.getDescription());

			if (!YiUtils.isStringInvalid(roomInfo.getSubject())) {
				model.setMsg(roomInfo.getSubject());
			} else if (!YiUtils.isStringInvalid(desc.getName())) {
				model.setMsg(desc.getName());
			} else {
				model.setMsg(roomInfo.getRoom());
			}
			model.setUser(roomInfo.getRoom());
			model.setSubMsg(roomInfo.getDescription());
			models.add(model);
		}
	} catch (Exception e) {
		// TODO: handle exception
	}finally {
		Message message = getHandler().obtainMessage(MSG_UPDATE_LIST,
				models);
		message.sendToTarget();
	}
}
 
Example #4
Source File: RoomBrowser.java    From Spark with Apache License 2.0 5 votes vote down vote up
public void displayRoomInformation(final EntityBareJid roomJID) {
     SwingWorker worker = new SwingWorker() {
         RoomInfo roomInfo = null;
         DiscoverItems items = null;

         @Override
public Object construct() {
             try {
                 roomInfo = MultiUserChatManager.getInstanceFor( SparkManager.getConnection() ).getRoomInfo( roomJID );


                 ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
                 items = manager.discoverItems(roomJID);
             }
             catch (XMPPException | SmackException | InterruptedException e) {
                 Log.error(e);
             }
             return "ok";
         }

         @Override
public void finished() {
             setupRoomInformationUI(roomJID, roomInfo, items);
         }
     };

     worker.start();
 }
 
Example #5
Source File: MultiRoomDiscoverActivity.java    From yiim_v2 with GNU General Public License v2.0 4 votes vote down vote up
private void loadRooms() {
	getXmppBinder().execute(new Runnable() {
		@Override
		public void run() {
			// TODO Auto-generated method stub
			try {
				Collection<HostedRoom> hostedRooms = MultiUserChat
						.getHostedRooms(
								getXmppBinder().getXmppConnection(),
								"conference."
										+ XmppConnectionUtils.getXmppHost());
				if (!hostedRooms.isEmpty()) {
					ArrayList<TabContactsModel> models = new ArrayList<TabContactsModel>();
					for (HostedRoom hostedRoom : hostedRooms) {
						RoomInfo roomInfo = MultiUserChat.getRoomInfo(
								getXmppBinder().getXmppConnection(),
								hostedRoom.getJid());
						TabContactsModel model = new TabContactsModel();

						MultiChatDesc desc = MultiChatDesc
								.fromString(roomInfo.getDescription());

						if (!YiUtils.isStringInvalid(roomInfo.getSubject())) {
							model.setMsg(roomInfo.getSubject());
						} else if (!YiUtils.isStringInvalid(desc.getName())) {
							model.setMsg(desc.getName());
						} else {
							model.setMsg(roomInfo.getRoom());
						}
						model.setUser(roomInfo.getRoom());
						model.setSubMsg(roomInfo.getDescription());
						models.add(model);
					}
					Message message = getHandler().obtainMessage(
							MSG_UPDATE_LIST, models);
					message.sendToTarget();
				}
			} catch (Exception e) {
				// TODO: handle exception
				YiLog.getInstance().e(e, "load rooms failed");
			}
		}
	});
}
 
Example #6
Source File: OmemoManager.java    From Smack with Apache License 2.0 3 votes vote down vote up
/**
 * 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 there was an XMPP protocol level error
 * @throws SmackException.NotConnectedException if the connection is not connected
 * @throws InterruptedException                 if the thread is interrupted
 * @throws SmackException.NoResponseException   if the server does not respond
 */
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();
}
 
Example #7
Source File: ConferenceRoomBrowser.java    From Spark with Apache License 2.0 3 votes vote down vote up
/**
    * 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;
   }
 
Example #8
Source File: ConferenceUtils.java    From Spark with Apache License 2.0 2 votes vote down vote up
/**
 * Return the number of occupants in a room.
 *
 * @param roomJID the full JID of the conference room. (ex. [email protected])
 * @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();
}