Java 类org.jivesoftware.smackx.packet.MUCUser 实例源码

项目:EIM    文件:MultiUserChat.java   
/**
 * Initializes the listeners to detect received room invitations and to detect when the
 * connection gets closed. As soon as a room invitation is received the invitations
 * listeners will be fired. When the connection gets closed the monitor will remove
 * his listeners on the connection.
 */
private void init() {
    // Listens for all messages that include a MUCUser extension and fire the invitation
    // listeners if the message includes an invitation.
    invitationFilter =
        new PacketExtensionFilter("x", "http://jabber.org/protocol/muc#user");
    invitationPacketListener = new PacketListener() {
        public void processPacket(Packet packet) {
            // Get the MUCUser extension
            MUCUser mucUser =
                (MUCUser) packet.getExtension("x", "http://jabber.org/protocol/muc#user");
            // Check if the MUCUser extension includes an invitation
            if (mucUser.getInvite() != null &&
                    ((Message) packet).getType() != Message.Type.error) {
                // Fire event for invitation listeners
                fireInvitationListeners(packet.getFrom(), mucUser.getInvite().getFrom(),
                        mucUser.getInvite().getReason(), mucUser.getPassword(), (Message) packet);
            }
        }
    };
    connection.addPacketListener(invitationPacketListener, invitationFilter);
    // Add a listener to detect when the connection gets closed in order to
    // cancel/release this monitor 
    connection.addConnectionListener(this);
}
项目:androidPN-client.    文件:MultiUserChat.java   
/**
 * Initializes the listeners to detect received room invitations and to detect when the
 * connection gets closed. As soon as a room invitation is received the invitations
 * listeners will be fired. When the connection gets closed the monitor will remove
 * his listeners on the connection.
 */
private void init() {
    // Listens for all messages that include a MUCUser extension and fire the invitation
    // listeners if the message includes an invitation.
    invitationFilter =
        new PacketExtensionFilter("x", "http://jabber.org/protocol/muc#user");
    invitationPacketListener = new PacketListener() {
        public void processPacket(Packet packet) {
            // Get the MUCUser extension
            MUCUser mucUser =
                (MUCUser) packet.getExtension("x", "http://jabber.org/protocol/muc#user");
            // Check if the MUCUser extension includes an invitation
            if (mucUser.getInvite() != null &&
                    ((Message) packet).getType() != Message.Type.error) {
                // Fire event for invitation listeners
                fireInvitationListeners(packet.getFrom(), mucUser.getInvite().getFrom(),
                        mucUser.getInvite().getReason(), mucUser.getPassword(), (Message) packet);
            }
        }
    };
    connection.addPacketListener(invitationPacketListener, invitationFilter);
    // Add a listener to detect when the connection gets closed in order to
    // cancel/release this monitor 
    connection.addConnectionListener(this);
}
项目:java-bells    文件:MultiUserChat.java   
/**
 * Initializes the listeners to detect received room invitations and to detect when the
 * connection gets closed. As soon as a room invitation is received the invitations
 * listeners will be fired. When the connection gets closed the monitor will remove
 * his listeners on the connection.
 */
private void init() {
    // Listens for all messages that include a MUCUser extension and fire the invitation
    // listeners if the message includes an invitation.
    invitationFilter =
        new PacketExtensionFilter("x", "http://jabber.org/protocol/muc#user");
    invitationPacketListener = new PacketListener() {
        public void processPacket(Packet packet) {
            // Get the MUCUser extension
            MUCUser mucUser =
                (MUCUser) packet.getExtension("x", "http://jabber.org/protocol/muc#user");
            // Check if the MUCUser extension includes an invitation
            if (mucUser.getInvite() != null &&
                    ((Message) packet).getType() != Message.Type.error) {
                // Fire event for invitation listeners
                fireInvitationListeners(packet.getFrom(), mucUser.getInvite().getFrom(),
                        mucUser.getInvite().getReason(), mucUser.getPassword(), (Message) packet);
            }
        }
    };
    connection.addPacketListener(invitationPacketListener, invitationFilter);
    // Add a listener to detect when the connection gets closed in order to
    // cancel/release this monitor 
    connection.addConnectionListener(this);
}
项目:telegraph    文件:MultiUserChat.java   
/**
 * Initializes the listeners to detect received room invitations and to detect when the
 * connection gets closed. As soon as a room invitation is received the invitations
 * listeners will be fired. When the connection gets closed the monitor will remove
 * his listeners on the connection.
 */
private void init() {
    // Listens for all messages that include a MUCUser extension and fire the invitation
    // listeners if the message includes an invitation.
    invitationFilter =
        new PacketExtensionFilter("x", "http://jabber.org/protocol/muc#user");
    invitationPacketListener = new PacketListener() {
        public void processPacket(Packet packet) {
            // Get the MUCUser extension
            MUCUser mucUser =
                (MUCUser) packet.getExtension("x", "http://jabber.org/protocol/muc#user");
            // Check if the MUCUser extension includes an invitation
            if (mucUser.getInvite() != null &&
                    ((Message) packet).getType() != Message.Type.error) {
                // Fire event for invitation listeners
                fireInvitationListeners(packet.getFrom(), mucUser.getInvite().getFrom(),
                        mucUser.getInvite().getReason(), mucUser.getPassword(), (Message) packet);
            }
        }
    };
    connection.addPacketListener(invitationPacketListener, invitationFilter);
    // Add a listener to detect when the connection gets closed in order to
    // cancel/release this monitor 
    connection.addConnectionListener(this);
}
项目:NewCommunication-Android    文件:MultiUserChat.java   
/**
 * Initializes the listeners to detect received room invitations and to detect when the
 * connection gets closed. As soon as a room invitation is received the invitations
 * listeners will be fired. When the connection gets closed the monitor will remove
 * his listeners on the connection.
 */
private void init() {
    // Listens for all messages that include a MUCUser extension and fire the invitation
    // listeners if the message includes an invitation.
    invitationFilter =
        new PacketExtensionFilter("x", "http://jabber.org/protocol/muc#user");
    invitationPacketListener = new PacketListener() {
        public void processPacket(Packet packet) {
            // Get the MUCUser extension
            MUCUser mucUser =
                (MUCUser) packet.getExtension("x", "http://jabber.org/protocol/muc#user");
            // Check if the MUCUser extension includes an invitation
            if (mucUser.getInvite() != null &&
                    ((Message) packet).getType() != Message.Type.error) {
                // Fire event for invitation listeners
                fireInvitationListeners(packet.getFrom(), mucUser.getInvite().getFrom(),
                        mucUser.getInvite().getReason(), mucUser.getPassword(), (Message) packet);
            }
        }
    };
    connection.addPacketListener(invitationPacketListener, invitationFilter);
    // Add a listener to detect when the connection gets closed in order to
    // cancel/release this monitor 
    connection.addConnectionListener(this);
}
项目:EIM    文件:Occupant.java   
Occupant(Presence presence) {
    super();
    MUCUser mucUser = (MUCUser) presence.getExtension("x",
            "http://jabber.org/protocol/muc#user");
    MUCUser.Item item = mucUser.getItem();
    this.jid = item.getJid();
    this.affiliation = item.getAffiliation();
    this.role = item.getRole();
    // Get the nickname from the FROM attribute of the presence
    this.nick = StringUtils.parseResource(presence.getFrom());
}
项目:EIM    文件:MultiUserChat.java   
/**
 * Returns the MUCUser packet extension included in the packet or <tt>null</tt> if none.
 *
 * @param packet the packet that may include the MUCUser extension.
 * @return the MUCUser found in the packet.
 */
private MUCUser getMUCUserExtension(Packet packet) {
    if (packet != null) {
        // Get the MUC User extension
        return (MUCUser) packet.getExtension("x", "http://jabber.org/protocol/muc#user");
    }
    return null;
}
项目:androidPN-client.    文件:Occupant.java   
Occupant(Presence presence) {
    super();
    MUCUser mucUser = (MUCUser) presence.getExtension("x",
            "http://jabber.org/protocol/muc#user");
    MUCUser.Item item = mucUser.getItem();
    this.jid = item.getJid();
    this.affiliation = item.getAffiliation();
    this.role = item.getRole();
    // Get the nickname from the FROM attribute of the presence
    this.nick = StringUtils.parseResource(presence.getFrom());
}
项目:androidPN-client.    文件:MultiUserChat.java   
/**
 * Returns the MUCUser packet extension included in the packet or <tt>null</tt> if none.
 *
 * @param packet the packet that may include the MUCUser extension.
 * @return the MUCUser found in the packet.
 */
private MUCUser getMUCUserExtension(Packet packet) {
    if (packet != null) {
        // Get the MUC User extension
        return (MUCUser) packet.getExtension("x", "http://jabber.org/protocol/muc#user");
    }
    return null;
}
项目:xmppsupport_v2    文件:Occupant.java   
Occupant(Presence presence) {
    super();
    MUCUser mucUser = (MUCUser) presence.getExtension("x",
            "http://jabber.org/protocol/muc#user");
    MUCUser.Item item = mucUser.getItem();
    this.jid = item.getJid();
    this.affiliation = item.getAffiliation();
    this.role = item.getRole();
    // Get the nickname from the FROM attribute of the presence
    this.nick = StringUtils.parseResource(presence.getFrom());
}
项目:xmppsupport_v2    文件:MultiUserChat.java   
/**
 * Returns the MUCUser packet extension included in the packet or
 * <tt>null</tt> if none.
 * 
 * @param packet
 *            the packet that may include the MUCUser extension.
 * @return the MUCUser found in the packet.
 */
private MUCUser getMUCUserExtension(Packet packet) {
    if (packet != null) {
        // Get the MUC User extension
        return (MUCUser) packet.getExtension("x",
                "http://jabber.org/protocol/muc#user");
    }
    return null;
}
项目:xmppsupport_v2    文件:MultiUserChat.java   
/**
 * Initializes the listeners to detect received room invitations and to
 * detect when the connection gets closed. As soon as a room invitation
 * is received the invitations listeners will be fired. When the
 * connection gets closed the monitor will remove his listeners on the
 * connection.
 */
private void init() {
    // Listens for all messages that include a MUCUser extension and
    // fire the invitation
    // listeners if the message includes an invitation.
    invitationFilter = new PacketExtensionFilter("x",
            "http://jabber.org/protocol/muc#user");
    invitationPacketListener = new PacketListener() {
        public void processPacket(Packet packet) {
            // Get the MUCUser extension
            MUCUser mucUser = (MUCUser) packet.getExtension("x",
                    "http://jabber.org/protocol/muc#user");
            // Check if the MUCUser extension includes an invitation
            if (mucUser.getInvite() != null
                    && ((Message) packet).getType() != Message.Type.error) {
                // Fire event for invitation listeners
                fireInvitationListeners(packet.getFrom(), mucUser
                        .getInvite().getFrom(), mucUser.getInvite()
                        .getReason(), mucUser.getPassword(),
                        (Message) packet);
            }
        }
    };
    connection.addPacketListener(invitationPacketListener,
            invitationFilter);
    // Add a listener to detect when the connection gets closed in order
    // to
    // cancel/release this monitor
    connection.addConnectionListener(this);
}
项目:java-bells    文件:Occupant.java   
Occupant(Presence presence) {
    super();
    MUCUser mucUser = (MUCUser) presence.getExtension("x",
            "http://jabber.org/protocol/muc#user");
    MUCUser.Item item = mucUser.getItem();
    this.jid = item.getJid();
    this.affiliation = item.getAffiliation();
    this.role = item.getRole();
    // Get the nickname from the FROM attribute of the presence
    this.nick = StringUtils.parseResource(presence.getFrom());
}
项目:java-bells    文件:MultiUserChat.java   
/**
 * Returns the MUCUser packet extension included in the packet or <tt>null</tt> if none.
 *
 * @param packet the packet that may include the MUCUser extension.
 * @return the MUCUser found in the packet.
 */
private MUCUser getMUCUserExtension(Packet packet) {
    if (packet != null) {
        // Get the MUC User extension
        return (MUCUser) packet.getExtension("x", "http://jabber.org/protocol/muc#user");
    }
    return null;
}
项目:telegraph    文件:Occupant.java   
Occupant(Presence presence) {
    super();
    MUCUser mucUser = (MUCUser) presence.getExtension("x",
            "http://jabber.org/protocol/muc#user");
    MUCUser.Item item = mucUser.getItem();
    this.jid = item.getJid();
    this.affiliation = item.getAffiliation();
    this.role = item.getRole();
    // Get the nickname from the FROM attribute of the presence
    this.nick = StringUtils.parseResource(presence.getFrom());
}
项目:telegraph    文件:MultiUserChat.java   
/**
 * Returns the MUCUser packet extension included in the packet or <tt>null</tt> if none.
 *
 * @param packet the packet that may include the MUCUser extension.
 * @return the MUCUser found in the packet.
 */
private MUCUser getMUCUserExtension(Packet packet) {
    if (packet != null) {
        // Get the MUC User extension
        return (MUCUser) packet.getExtension("x", "http://jabber.org/protocol/muc#user");
    }
    return null;
}
项目:NewCommunication-Android    文件:Occupant.java   
Occupant(Presence presence) {
    super();
    MUCUser mucUser = (MUCUser) presence.getExtension("x",
            "http://jabber.org/protocol/muc#user");
    MUCUser.Item item = mucUser.getItem();
    this.jid = item.getJid();
    this.affiliation = item.getAffiliation();
    this.role = item.getRole();
    // Get the nickname from the FROM attribute of the presence
    this.nick = StringUtils.parseResource(presence.getFrom());
}
项目:NewCommunication-Android    文件:MultiUserChat.java   
/**
 * Returns the MUCUser packet extension included in the packet or <tt>null</tt> if none.
 *
 * @param packet the packet that may include the MUCUser extension.
 * @return the MUCUser found in the packet.
 */
private MUCUser getMUCUserExtension(Packet packet) {
    if (packet != null) {
        // Get the MUC User extension
        return (MUCUser) packet.getExtension("x", "http://jabber.org/protocol/muc#user");
    }
    return null;
}
项目:spark-svn-mirror    文件:PresenceManager.java   
public static String getJidFromMUCPresence(Presence presence) {     
    Collection<PacketExtension> extensions = presence.getExtensions();
    for (PacketExtension pe : extensions) {
        if (pe instanceof MUCUser) {
            final MUCUser mucUser = (MUCUser) pe;
            String fullJid = mucUser.getItem().getJid();
            String userJid = StringUtils.parseBareAddress(fullJid);
            return userJid;
        }
    }
    return null;
}
项目:EIM    文件:Workgroup.java   
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 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);
            }
        }
    }
}
项目:androidPN-client.    文件:Workgroup.java   
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);
            }
        }
    }
}
项目:xmppsupport_v2    文件:Workgroup.java   
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 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);
            }
        }
    }
}
项目:java-bells    文件:Workgroup.java   
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);
            }
        }
    }
}
项目:telegraph    文件:Workgroup.java   
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 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);
            }
        }
    }
}
项目:NewCommunication-Android    文件:Workgroup.java   
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 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);
            }
        }
    }
}
项目:spark-svn-mirror    文件:GroupChatRoom.java   
/**
    * Handle all presence packets being sent to this Group Chat Room.
    *
    * @param packet
    *            the presence packet.
    */
   private void handlePresencePacket(Packet packet) {
Presence presence = (Presence) packet;
if (presence.getError() != null) {
    return;
}

final String from = presence.getFrom();
final String nickname = StringUtils.parseResource(from);

MUCUser mucUser = (MUCUser) packet.getExtension("x",
    "http://jabber.org/protocol/muc#user");
String code = "";
if (mucUser != null) {
    code = mucUser.getStatus() != null ? mucUser.getStatus().getCode()
        : "";

    Destroy destroy = mucUser.getDestroy();
    if (destroy != null) {
    String reason = destroy.getReason();
    JOptionPane.showMessageDialog(this,
        Res.getString("message.room.destroyed", reason),
        Res.getString("title.room.destroyed"),
        JOptionPane.INFORMATION_MESSAGE);
    leaveChatRoom();
    return;
    }
}

if (presence.getType() == Presence.Type.unavailable
    && !"303".equals(code)) {
    if (currentUserList.contains(from)) {
    if (showPresenceMessages) {
        getTranscriptWindow().insertNotificationMessage(
            Res.getString("message.user.left.room", nickname),
            ChatManager.NOTIFICATION_COLOR);
        scrollToBottom();
    }
    currentUserList.remove(from);
    }
} else {
    if (!currentUserList.contains(from)) {
    currentUserList.add(from);
    getChatInputEditor().setEnabled(true);
    if (showPresenceMessages) {
        getTranscriptWindow()
            .insertNotificationMessage(
                Res.getString("message.user.joined.room",
                    nickname),
                ChatManager.NOTIFICATION_COLOR);
        scrollToBottom();
    }
    }
}
   }