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