Search in sources :

Example 11 with MultiUserChatService

use of org.jivesoftware.openfire.muc.MultiUserChatService in project Openfire by igniterealtime.

the class IQQueryHandler method handleIQ.

public IQ handleIQ(IQ packet) throws UnauthorizedException {
    Session session = sessionManager.getSession(packet.getFrom());
    // If no session was found then answer with an error (if possible)
    if (session == null) {
        Log.error("Error during resource binding. Session not found in " + sessionManager.getPreAuthenticatedKeys() + " for key " + packet.getFrom());
        return buildErrorResponse(packet);
    }
    if (packet.getType().equals(IQ.Type.get)) {
        return buildSupportedFieldsResult(packet, session);
    }
    // Default to user's own archive
    JID archiveJid = packet.getTo();
    if (archiveJid == null) {
        archiveJid = packet.getFrom().asBareJID();
    }
    Log.debug("Archive requested is {}", archiveJid);
    // Now decide the type.
    boolean muc = false;
    if (!XMPPServer.getInstance().isLocal(archiveJid)) {
        Log.debug("Archive is not local (user)");
        if (XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(archiveJid) == null) {
            Log.debug("No chat service for this domain");
            return buildErrorResponse(packet);
        } else {
            muc = true;
            Log.debug("MUC");
        }
    }
    JID requestor = packet.getFrom().asBareJID();
    Log.debug("Requestor is {} for muc=={}", requestor, muc);
    // Auth checking.
    if (muc) {
        MultiUserChatService service = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(archiveJid);
        MUCRoom room = service.getChatRoom(archiveJid.getNode());
        if (room == null) {
            return buildErrorResponse(packet);
        }
        boolean pass = false;
        if (service.isSysadmin(requestor)) {
            pass = true;
        }
        MUCRole.Affiliation aff = room.getAffiliation(requestor);
        if (aff != MUCRole.Affiliation.outcast) {
            if (aff == MUCRole.Affiliation.owner || aff == MUCRole.Affiliation.admin) {
                pass = true;
            } else if (room.isMembersOnly()) {
                if (aff == MUCRole.Affiliation.member) {
                    pass = true;
                }
            } else {
                pass = true;
            }
        }
        if (!pass) {
            return buildForbiddenResponse(packet);
        }
    } else if (!archiveJid.equals(requestor)) {
        // ... disallow unless admin.
        if (!XMPPServer.getInstance().getAdmins().contains(requestor)) {
            return buildForbiddenResponse(packet);
        }
    }
    sendMidQuery(packet, session);
    final QueryRequest queryRequest = new QueryRequest(packet.getChildElement(), archiveJid);
    Collection<ArchivedMessage> archivedMessages = retrieveMessages(queryRequest);
    for (ArchivedMessage archivedMessage : archivedMessages) {
        sendMessageResult(session, queryRequest, archivedMessage);
    }
    sendEndQuery(packet, session, queryRequest);
    return null;
}
Also used : MUCRole(org.jivesoftware.openfire.muc.MUCRole) MUCRoom(org.jivesoftware.openfire.muc.MUCRoom) ArchivedMessage(com.reucon.openfire.plugin.archive.model.ArchivedMessage) MultiUserChatService(org.jivesoftware.openfire.muc.MultiUserChatService) Session(org.jivesoftware.openfire.session.Session)

Example 12 with MultiUserChatService

use of org.jivesoftware.openfire.muc.MultiUserChatService in project Openfire by igniterealtime.

the class RoomAvailableEvent method run.

@Override
public void run() {
    MultiUserChatService mucService = room.getMUCService();
    mucService.chatRoomAdded(room);
}
Also used : MultiUserChatService(org.jivesoftware.openfire.muc.MultiUserChatService)

Example 13 with MultiUserChatService

use of org.jivesoftware.openfire.muc.MultiUserChatService in project Openfire by igniterealtime.

the class OccupantKickedForNicknameTask method run.

@Override
public void run() {
    final MultiUserChatService multiUserChatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(subdomain);
    ((MultiUserChatServiceImpl) multiUserChatService).getOccupantManager().process(this);
}
Also used : MultiUserChatService(org.jivesoftware.openfire.muc.MultiUserChatService)

Example 14 with MultiUserChatService

use of org.jivesoftware.openfire.muc.MultiUserChatService in project Openfire by igniterealtime.

the class OccupantAddedTask method run.

@Override
public void run() {
    final MultiUserChatService multiUserChatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(subdomain);
    ((MultiUserChatServiceImpl) multiUserChatService).getOccupantManager().process(this);
}
Also used : MultiUserChatService(org.jivesoftware.openfire.muc.MultiUserChatService)

Example 15 with MultiUserChatService

use of org.jivesoftware.openfire.muc.MultiUserChatService in project Openfire by igniterealtime.

the class OccupantRemovedTask method run.

@Override
public void run() {
    final MultiUserChatService multiUserChatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(subdomain);
    ((MultiUserChatServiceImpl) multiUserChatService).getOccupantManager().process(this);
}
Also used : MultiUserChatService(org.jivesoftware.openfire.muc.MultiUserChatService)

Aggregations

MultiUserChatService (org.jivesoftware.openfire.muc.MultiUserChatService)17 MUCRoom (org.jivesoftware.openfire.muc.MUCRoom)5 MUCRole (org.jivesoftware.openfire.muc.MUCRole)3 MultiUserChatManager (org.jivesoftware.openfire.muc.MultiUserChatManager)3 MultiUserChatServiceImpl (org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl)3 JID (org.xmpp.packet.JID)3 ArchivedMessage (com.reucon.openfire.plugin.archive.model.ArchivedMessage)2 Date (java.util.Date)2 List (java.util.List)2 Lock (java.util.concurrent.locks.Lock)2 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)2 ServerFeaturesProvider (org.jivesoftware.openfire.disco.ServerFeaturesProvider)2 IQHandler (org.jivesoftware.openfire.handler.IQHandler)2 NotAllowedException (org.jivesoftware.openfire.muc.NotAllowedException)2 LocalMUCRoom (org.jivesoftware.openfire.muc.spi.LocalMUCRoom)2 XmppResultSet (com.reucon.openfire.plugin.archive.xep0059.XmppResultSet)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1