Search in sources :

Example 1 with IQ

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

the class ComponentList method getComponentInfo.

private void getComponentInfo() {
    IQRouter iqRouter;
    Collection<String> components = routingTable.getComponentsDomains();
    iqRouter = server.getIQRouter();
    for (String componentDomain : components) {
        IQ iq = new IQ(IQ.Type.get);
        iq.setFrom(server.getServerInfo().getXMPPDomain());
        iq.setTo(componentDomain);
        iq.setChildElement("query", "http://jabber.org/protocol/disco#info");
        iqRouter.addIQResultListener(iq.getID(), this);
        iqRouter.route(iq);
    }
}
Also used : IQ(org.xmpp.packet.IQ) IQRouter(org.jivesoftware.openfire.IQRouter)

Example 2 with IQ

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

the class SearchPlugin method processPacket.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.xmpp.component.Component#processPacket(org.xmpp.packet.Packet)
	 */
public void processPacket(Packet p) {
    if (!(p instanceof IQ)) {
        return;
    }
    final IQ packet = (IQ) p;
    if (packet.getType().equals(IQ.Type.error) || packet.getType().equals(IQ.Type.result)) {
        return;
    }
    // Packet p is an IQ stanza of type GET or SET. Therefor, it _must_ be
    // replied to.
    final IQ replyPacket = handleIQRequest(packet);
    try {
        componentManager.sendPacket(this, replyPacket);
    } catch (ComponentException e) {
        Log.error(e.getMessage(), e);
    }
}
Also used : IQ(org.xmpp.packet.IQ) ComponentException(org.xmpp.component.ComponentException)

Example 3 with IQ

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

the class SearchPlugin method replyNonDataFormResult.

/**
	 * Constructs a query that is returned as an IQ packet that contains the search results.
	 * 
	 * @param users
	 *            set of users that will be used to construct the search results
	 * @param packet
	 *            the IQ packet sent by the client
	 * @return the iq packet that contains the search results
	 */
private IQ replyNonDataFormResult(Collection<User> users, IQ packet) {
    IQ replyPacket = IQ.createResultIQ(packet);
    Element replyQuery = replyPacket.setChildElement("query", NAMESPACE_JABBER_IQ_SEARCH);
    for (User user : users) {
        Element item = replyQuery.addElement("item");
        String username = JID.unescapeNode(user.getUsername());
        item.addAttribute("jid", username + "@" + serverName);
        // return to the client the same fields that were submitted
        for (String field : reverseFieldLookup.keySet()) {
            if ("Username".equals(field)) {
                Element element = item.addElement(reverseFieldLookup.get(field));
                element.addText(username);
            }
            if ("Name".equals(field)) {
                Element element = item.addElement(reverseFieldLookup.get(field));
                element.addText(user.isNameVisible() ? removeNull(user.getName()) : "");
            }
            if ("Email".equals(field)) {
                Element element = item.addElement(reverseFieldLookup.get(field));
                element.addText(user.isEmailVisible() ? removeNull(user.getEmail()) : "");
            }
        }
    }
    return replyPacket;
}
Also used : User(org.jivesoftware.openfire.user.User) Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ)

Example 4 with IQ

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

the class SearchPlugin method replyDisabled.

/**
	 * Constructs a IQ result stanza, based on the request stanza that is provided as an argument. The stanza tells the recipient that this
	 * service is currently unavailable.
	 * 
	 * @param packet
	 *            The request IQ stanza to which a result will be returned.
	 * @return A result stanza, telling the user that this service is unavailable.
	 */
private static IQ replyDisabled(IQ packet) {
    IQ replyPacket = IQ.createResultIQ(packet);
    Element reply = replyPacket.setChildElement("query", NAMESPACE_JABBER_IQ_SEARCH);
    final DataForm unavailableForm = new DataForm(DataForm.Type.cancel);
    unavailableForm.setTitle(LocaleUtils.getLocalizedString("advance.user.search.title", "search"));
    unavailableForm.addInstruction(LocaleUtils.getLocalizedString("search.service_unavailable", "search"));
    reply.add(unavailableForm.getElement());
    return replyPacket;
}
Also used : Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ) DataForm(org.xmpp.forms.DataForm)

Example 5 with IQ

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

the class LogComponent method processPacket.

// Component Interface
public void processPacket(Packet packet) {
    if (packet instanceof IQ) {
        // Handle disco packets
        IQ iq = (IQ) packet;
        // Ignore IQs of type ERROR or RESULT
        if (IQ.Type.error == iq.getType() || IQ.Type.result == iq.getType()) {
            return;
        }
        processIQ(iq);
    }
}
Also used : IQ(org.xmpp.packet.IQ)

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