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);
}
}
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);
}
}
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;
}
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;
}
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);
}
}
Aggregations