Search in sources :

Example 6 with MUCUser

use of org.jivesoftware.smackx.packet.MUCUser in project ecf by eclipse.

the class Workgroup method handlePacket.

// PacketListener Implementation.
private void handlePacket(Packet packet) {
    if (packet instanceof Message) {
        Message msg = (Message) packet;
        // Check to see if the user left the queue.
        PacketExtension pe = msg.getExtension("depart-queue", "http://jabber.org/protocol/workgroup");
        PacketExtension queueStatus = msg.getExtension("queue-status", "http://jabber.org/protocol/workgroup");
        if (pe != null) {
            fireQueueDepartedEvent();
        } else if (queueStatus != null) {
            QueueUpdate queueUpdate = (QueueUpdate) queueStatus;
            if (queueUpdate.getPosition() != -1) {
                fireQueuePositionEvent(queueUpdate.getPosition());
            }
            if (queueUpdate.getRemaingTime() != -1) {
                fireQueueTimeEvent(queueUpdate.getRemaingTime());
            }
        } else {
            // Check if a room invitation was sent and if the sender is the workgroup
            MUCUser mucUser = (MUCUser) msg.getExtension("x", "http://jabber.org/protocol/muc#user");
            MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null;
            if (invite != null && workgroupJID.equals(invite.getFrom())) {
                String sessionID = null;
                Map<String, List<String>> metaData = null;
                pe = msg.getExtension(SessionID.ELEMENT_NAME, SessionID.NAMESPACE);
                if (pe != null) {
                    sessionID = ((SessionID) pe).getSessionID();
                }
                pe = msg.getExtension(MetaData.ELEMENT_NAME, MetaData.NAMESPACE);
                if (pe != null) {
                    metaData = ((MetaData) pe).getMetaData();
                }
                WorkgroupInvitation inv = new WorkgroupInvitation(connection.getUser(), msg.getFrom(), workgroupJID, sessionID, msg.getBody(), msg.getFrom(), metaData);
                fireInvitationEvent(inv);
            }
        }
    }
}
Also used : MUCUser(org.jivesoftware.smackx.packet.MUCUser) MetaData(org.jivesoftware.smackx.workgroup.MetaData) WorkgroupInvitation(org.jivesoftware.smackx.workgroup.WorkgroupInvitation) QueueUpdate(org.jivesoftware.smackx.workgroup.packet.QueueUpdate) Map(java.util.Map) SessionID(org.jivesoftware.smackx.workgroup.packet.SessionID)

Example 7 with MUCUser

use of org.jivesoftware.smackx.packet.MUCUser in project ecf by eclipse.

the class XMPPContainer method handleAsExtension.

protected boolean handleAsExtension(Packet packet) {
    final Iterator i = packet.getExtensions().iterator();
    for (; i.hasNext(); ) {
        final Object extension = i.next();
        if (extension instanceof XHTMLExtension) {
            final XHTMLExtension xhtmlExtension = (XHTMLExtension) extension;
            deliverEvent(new MessageEvent((Message) packet, xhtmlExtension.getBodies()));
            return true;
        }
        if (packet instanceof Presence && extension instanceof MUCUser) {
            return true;
        }
    }
    return false;
}
Also used : MUCUser(org.jivesoftware.smackx.packet.MUCUser) ContainerMessage(org.eclipse.ecf.provider.generic.ContainerMessage) Message(org.jivesoftware.smack.packet.Message) MessageEvent(org.eclipse.ecf.internal.provider.xmpp.events.MessageEvent) Iterator(java.util.Iterator) Presence(org.jivesoftware.smack.packet.Presence) XHTMLExtension(org.jivesoftware.smackx.packet.XHTMLExtension)

Aggregations

MUCUser (org.jivesoftware.smackx.packet.MUCUser)7 Message (org.jivesoftware.smack.packet.Message)3 Presence (org.jivesoftware.smack.packet.Presence)3 AndFilter (org.jivesoftware.smack.filter.AndFilter)2 FromMatchesFilter (org.jivesoftware.smack.filter.FromMatchesFilter)2 PacketFilter (org.jivesoftware.smack.filter.PacketFilter)2 PacketTypeFilter (org.jivesoftware.smack.filter.PacketTypeFilter)2 MUCInitialPresence (org.jivesoftware.smackx.packet.MUCInitialPresence)2 MetaData (org.jivesoftware.smackx.workgroup.MetaData)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 MessageEvent (org.eclipse.ecf.internal.provider.xmpp.events.MessageEvent)1 ContainerMessage (org.eclipse.ecf.provider.generic.ContainerMessage)1 PacketCollector (org.jivesoftware.smack.PacketCollector)1 PacketInterceptor (org.jivesoftware.smack.PacketInterceptor)1 PacketListener (org.jivesoftware.smack.PacketListener)1 XMPPException (org.jivesoftware.smack.XMPPException)1 MessageTypeFilter (org.jivesoftware.smack.filter.MessageTypeFilter)1