use of org.xmpp.packet.IQ in project Openfire by igniterealtime.
the class TransferRequest method userJoinedRoom.
@Override
public void userJoinedRoom(JID roomJID, JID user) {
Log.debug("User " + user + " has joined " + roomJID + ". User should be kicked.");
if (actualInvitee != null && actualInvitee.toBareJID().equals(user.toBareJID())) {
joinedRoom = System.currentTimeMillis();
// This request has been completed so remove it from the list of related
// requests of the original user request
userRequest.removeRelatedRequest(this);
// Kick the inviter from the room
IQ kick = new IQ(IQ.Type.set);
kick.setTo(roomJID);
kick.setFrom(workgroup.getFullJID());
Element childElement = kick.setChildElement("query", "http://jabber.org/protocol/muc#admin");
Element item = childElement.addElement("item");
item.addAttribute("jid", inviter.toString());
item.addAttribute("role", "none");
item.addElement("reason").setText("Transfer was successful");
workgroup.send(kick);
Log.debug("Sent kicked to " + user + " in room " + roomJID + ".");
}
}
use of org.xmpp.packet.IQ in project Openfire by igniterealtime.
the class WorkgroupFormProvider method executeGet.
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
FormManager formManager = FormManager.getInstance();
DataForm dataForm = formManager.getDataForm(workgroup);
if (dataForm == null) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
Element iq = packet.getChildElement();
if (iq.elements().isEmpty()) {
reply.setChildElement(iq.createCopy());
// Send the data form to the requestor
reply.addExtension(dataForm.createCopy());
workgroup.send(reply);
}
}
use of org.xmpp.packet.IQ in project Openfire by igniterealtime.
the class SparkManager method handleDiscoInfo.
/**
* Send a reply back to the client to inform the client that this server has
* a Spark Manager.
*
* @param packet the IQ packet.
*/
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", "manager");
identity.addAttribute("type", "text");
identity.addAttribute("name", "Client Control Manager");
// Add features set
buildFeatureSet(responseElement);
// Send reply
sendPacket(replyPacket);
}
use of org.xmpp.packet.IQ in project Openfire by igniterealtime.
the class SparkManager method requestSoftwareVersion.
/**
* Make a version request (JEP-0092) of the client the specified session is using. If the response is NOT the Spark IM
* client, send a StreamError notification and disconnect the user.
*
* @param session the users session.
*/
private void requestSoftwareVersion(final Session session) {
// Send IQ get to check client version.
final IQ clientPacket = new IQ(IQ.Type.get);
clientPacket.setTo(session.getAddress());
clientPacket.setFrom(serviceName + "." + componentManager.getServerName());
clientPacket.setChildElement("query", "jabber:iq:version");
sendPacket(clientPacket);
}
use of org.xmpp.packet.IQ in project Openfire by igniterealtime.
the class SparkVersionManager method handleSparkIQ.
private void handleSparkIQ(IQ packet) {
IQ reply;
Element iq = packet.getChildElement();
// Define default values
String os = iq.element("os").getText();
reply = IQ.createResultIQ(packet);
// Handle Invalid Requests
if (os == null || (!os.equals("windows") && !os.equals("mac") && !os.equals("linux"))) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.not_acceptable));
sendPacket(reply);
return;
}
Element sparkElement = reply.setChildElement("query", "jabber:iq:spark");
String client = null;
// Handle Windows clients
if (os.equals("windows")) {
client = JiveGlobals.getProperty("spark.windows.client");
} else // Handle Mac clients.
if (os.equals("mac")) {
client = JiveGlobals.getProperty("spark.mac.client");
} else // Handle Linux Client.
if (os.equals("linux")) {
client = JiveGlobals.getProperty("spark.linux.client");
}
if (client != null) {
int index = client.indexOf("_");
// Add version number
String versionNumber = client.substring(index + 1);
int indexOfPeriod = versionNumber.indexOf(".");
versionNumber = versionNumber.substring(0, indexOfPeriod);
versionNumber = versionNumber.replaceAll("_", ".");
sparkElement.addElement("version").setText(versionNumber);
// Add updated time.
File clientFile = new File(JiveGlobals.getHomeDirectory(), "enterprise/spark/" + client);
if (!clientFile.exists()) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
sendPacket(reply);
return;
}
long updatedTime = clientFile.lastModified();
sparkElement.addElement("updatedTime").setText(Long.toString(updatedTime));
// Add download url
String downloadURL = JiveGlobals.getProperty("spark.client.downloadURL");
String server = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
downloadURL = downloadURL.replace("127.0.0.1", server);
sparkElement.addElement("downloadURL").setText(downloadURL + "?client=" + client);
String displayMessage = JiveGlobals.getProperty("spark.client.displayMessage");
if (displayMessage != null && displayMessage.trim().length() > 0) {
sparkElement.addElement("displayMessage").setText(displayMessage);
}
} else {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
sendPacket(reply);
return;
}
sendPacket(reply);
}
Aggregations