Search in sources :

Example 1 with RoomInfo

use of org.jivesoftware.smackx.muc.RoomInfo in project xabber-android by redsolution.

the class MUCManager method requestRoomInfo.

public static void requestRoomInfo(final String account, final String roomJid, final RoomInfoListener listener) {
    final XMPPConnection xmppConnection = AccountManager.getInstance().getAccount(account).getConnectionThread().getXMPPConnection();
    final Thread thread = new Thread("Get room " + roomJid + " info for account " + account) {

        @Override
        public void run() {
            RoomInfo roomInfo = null;
            try {
                LogManager.i(MUCManager.class, "Requesting room info " + roomJid);
                roomInfo = MultiUserChatManager.getInstanceFor(xmppConnection).getRoomInfo(roomJid);
            } catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException e) {
                e.printStackTrace();
            }
            final RoomInfo finalRoomInfo = roomInfo;
            Application.getInstance().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    listener.onRoomInfoReceived(finalRoomInfo);
                }
            });
        }
    };
    thread.start();
}
Also used : RoomInfo(org.jivesoftware.smackx.muc.RoomInfo) XMPPConnection(org.jivesoftware.smack.XMPPConnection) ConnectionThread(com.xabber.android.data.connection.ConnectionThread)

Example 2 with RoomInfo

use of org.jivesoftware.smackx.muc.RoomInfo in project xabber-android by redsolution.

the class MUCManager method requestRoomInfo.

public static void requestRoomInfo(final AccountJid account, final EntityBareJid roomJid, final RoomInfoListener listener) {
    AccountItem accountItem = AccountManager.getInstance().getAccount(account);
    if (accountItem == null) {
        listener.onRoomInfoReceived(null);
        return;
    }
    final XMPPConnection xmppConnection = accountItem.getConnection();
    if (!xmppConnection.isAuthenticated()) {
        listener.onRoomInfoReceived(null);
        return;
    }
    Application.getInstance().runInBackgroundUserRequest(new Runnable() {

        @Override
        public void run() {
            RoomInfo roomInfo = null;
            try {
                LogManager.i(MUCManager.class, "Requesting room info " + roomJid);
                roomInfo = MultiUserChatManager.getInstanceFor(xmppConnection).getRoomInfo(roomJid);
            } catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
                LogManager.exception(this, e);
            }
            final RoomInfo finalRoomInfo = roomInfo;
            Application.getInstance().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    listener.onRoomInfoReceived(finalRoomInfo);
                }
            });
        }
    });
}
Also used : AccountItem(com.xabber.android.data.account.AccountItem) SmackException(org.jivesoftware.smack.SmackException) RoomInfo(org.jivesoftware.smackx.muc.RoomInfo) XMPPConnection(org.jivesoftware.smack.XMPPConnection) XMPPException(org.jivesoftware.smack.XMPPException)

Aggregations

XMPPConnection (org.jivesoftware.smack.XMPPConnection)2 RoomInfo (org.jivesoftware.smackx.muc.RoomInfo)2 AccountItem (com.xabber.android.data.account.AccountItem)1 ConnectionThread (com.xabber.android.data.connection.ConnectionThread)1 SmackException (org.jivesoftware.smack.SmackException)1 XMPPException (org.jivesoftware.smack.XMPPException)1