Search in sources :

Example 96 with IQ

use of org.xmpp.packet.IQ in project Openfire by igniterealtime.

the class SparkVersionManager method handleDiscoItems.

private void handleDiscoItems(IQ packet) {
    IQ replyPacket = IQ.createResultIQ(packet);
    replyPacket.setChildElement("query", "http://jabber.org/protocol/disco#items");
    sendPacket(replyPacket);
}
Also used : IQ(org.xmpp.packet.IQ)

Example 97 with IQ

use of org.xmpp.packet.IQ in project Openfire by igniterealtime.

the class SparkVersionManager method handleDiscoInfo.

private void handleDiscoInfo(IQ packet) {
    IQ replyPacket = IQ.createResultIQ(packet);
    Element responseElement = replyPacket.setChildElement("query", "http://jabber.org/protocol/disco#info");
    Element identity = responseElement.addElement("identity");
    identity.addAttribute("category", "updater");
    identity.addAttribute("type", "text");
    identity.addAttribute("name", "Spark Updater");
    responseElement.addElement("feature").addAttribute("var", "jabber:iq:updater");
    sendPacket(replyPacket);
}
Also used : Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ)

Example 98 with IQ

use of org.xmpp.packet.IQ in project Openfire by igniterealtime.

the class SparkVersionManager method processPacket.

public void processPacket(Packet packet) {
    if (packet instanceof IQ) {
        IQ iqPacket = (IQ) packet;
        if (IQ.Type.get == iqPacket.getType()) {
            Element childElement = (iqPacket).getChildElement();
            String namespace = null;
            if (childElement != null) {
                namespace = childElement.getNamespaceURI();
            }
            // Handle any disco info requests.
            if ("http://jabber.org/protocol/disco#info".equals(namespace)) {
                handleDiscoInfo(iqPacket);
            } else // Handle any disco item requests.
            if ("http://jabber.org/protocol/disco#items".equals(namespace)) {
                handleDiscoItems(iqPacket);
            } else // Handle a jabber spark request.
            if ("jabber:iq:spark".equals(namespace)) {
                handleSparkIQ(iqPacket);
            }
        } else if (IQ.Type.error == iqPacket.getType() || IQ.Type.result == iqPacket.getType()) {
        // Ignore these packets
        } else {
            // Return error since this is an unknown service request
            IQ reply = IQ.createResultIQ(iqPacket);
            reply.setError(PacketError.Condition.service_unavailable);
            sendPacket(reply);
        }
    }
}
Also used : Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ)

Example 99 with IQ

use of org.xmpp.packet.IQ in project Openfire by igniterealtime.

the class BookmarkInterceptor method interceptPacket.

public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed) throws PacketRejectedException {
    if (!processed && packet instanceof IQ && !incoming) {
        // Check for the Bookmark Storage element and hand off to the Bookmark engine.
        IQ iq = (IQ) packet;
        Element childElement = iq.getChildElement();
        if (childElement == null || iq.getType() != IQ.Type.result) {
            return;
        }
        String namespace = childElement.getNamespaceURI();
        if ("jabber:iq:private".equals(namespace)) {
            // In private data, when a user is attempting to retrieve bookmark
            // information, there will be a storage:bookmarks namespace.
            Element storageElement = childElement.element("storage");
            if (storageElement == null) {
                return;
            }
            namespace = storageElement.getNamespaceURI();
            if ("storage:bookmarks".equals(namespace)) {
                // Append Server defined bookmarks for user.
                JID toJID = iq.getTo();
                addBookmarks(toJID, storageElement);
            }
        }
    }
}
Also used : JID(org.xmpp.packet.JID) Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ)

Example 100 with IQ

use of org.xmpp.packet.IQ in project Openfire by igniterealtime.

the class SiteTracker method handleInvitation.

private void handleInvitation(IQ packet, Workgroup workgroup) {
    Element iq = packet.getChildElement();
    // Define default values
    IQ update = new IQ();
    Element elem = update.setChildElement("site-invite", "http://jivesoftware.com/protocol/workgroup");
    String sessionID = iq.attribute("sessionID").getText();
    elem.addAttribute("sessionID", sessionID);
    SiteUser siteUser = siteUsers.get(sessionID);
    IQ reply = IQ.createResultIQ(packet);
    if (siteUser == null) {
        reply.setChildElement(packet.getChildElement().createCopy());
        reply.setError(new PacketError(PacketError.Condition.item_not_found));
        workgroup.send(reply);
        return;
    } else {
        // Send back reply
        workgroup.send(reply);
    }
    String agent = iq.element("agent").getText();
    String message = iq.element("message").getText();
    elem.addElement("agent").setText(agent);
    elem.addElement("message").setText(message);
    update.setTo(siteUser.getJID());
    update.setType(IQ.Type.set);
    workgroup.send(update);
}
Also used : Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ) PacketError(org.xmpp.packet.PacketError)

Aggregations

IQ (org.xmpp.packet.IQ)208 Element (org.dom4j.Element)141 JID (org.xmpp.packet.JID)49 PacketError (org.xmpp.packet.PacketError)35 Presence (org.xmpp.packet.Presence)19 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)18 Message (org.xmpp.packet.Message)17 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)16 ClientSession (org.jivesoftware.openfire.session.ClientSession)14 DataForm (org.xmpp.forms.DataForm)13 ArrayList (java.util.ArrayList)11 AgentNotFoundException (org.jivesoftware.xmpp.workgroup.AgentNotFoundException)10 Packet (org.xmpp.packet.Packet)10 PacketException (org.jivesoftware.openfire.PacketException)9 User (org.jivesoftware.openfire.user.User)8 List (java.util.List)7 PrivacyList (org.jivesoftware.openfire.privacy.PrivacyList)7 Iterator (java.util.Iterator)6 Test (org.junit.Test)6 FormField (org.xmpp.forms.FormField)6