use of org.xmpp.packet.IQ in project Openfire by igniterealtime.
the class Workgroup method processTransfer.
public void processTransfer(TransferRequest transfer, IQ packet) {
IQ reply = IQ.createResultIQ(packet);
reply.setFrom(getJID());
// Verify that requester is a valid agent
AgentSession agentSession = null;
try {
agentSession = agentManager.getAgentSession(packet.getFrom());
} catch (AgentNotFoundException e) {
// Ignore
}
if (agentSession == null) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
send(reply);
Log.debug("Agent not found while accepting offer");
return;
}
// Answer that the transfer was received and that it is being processed
send(reply);
// Execute the transfer
transfer.execute();
}
use of org.xmpp.packet.IQ in project Openfire by igniterealtime.
the class AgentSession method sendAgentInfo.
/**
* Sends information of the agent to the agent that requested it.
*
* @param packet the original packet that made the request to obtain the agent's info.
*/
public void sendAgentInfo(IQ packet) {
IQ statusPacket = IQ.createResultIQ(packet);
Element agentInfo = statusPacket.setChildElement("agent-info", "http://jivesoftware.com/protocol/workgroup");
agentInfo.addElement("jid").setText(getAgent().getAgentJID().toBareJID());
agentInfo.addElement("name").setText(getAgent().getNickname());
// Send the response
WorkgroupManager.getInstance().send(statusPacket);
}
use of org.xmpp.packet.IQ in project Openfire by igniterealtime.
the class WorkgroupManager method processPacket.
public void processPacket(Packet packet) {
try {
// Check if the packet is a disco request
if (packet instanceof IQ) {
if (process((IQ) packet)) {
return;
}
}
// was found then let the workgroup process the packet
try {
Workgroup workgroup = getWorkgroup(packet.getTo());
workgroup.process(packet);
} catch (UserNotFoundException e) {
// above situations
if (packet instanceof Presence) {
if (((Presence) packet).getType() == Presence.Type.error) {
// Skip Presence packets of type error
return;
}
Presence reply = new Presence();
reply.setID(packet.getID());
reply.setTo(packet.getFrom());
reply.setFrom(packet.getTo());
reply.setError(PacketError.Condition.not_authorized);
send(reply);
} else if (packet instanceof IQ) {
if (((IQ) packet).getType() == IQ.Type.error) {
// Skip IQ packets of type error
return;
}
IQ reply = IQ.createResultIQ((IQ) packet);
reply.setChildElement(((IQ) packet).getChildElement().createCopy());
reply.setError(PacketError.Condition.not_authorized);
send(reply);
} else {
if (((Message) packet).getType() == Message.Type.error) {
// Skip Message packets of type error
return;
}
Message reply = new Message();
reply.setID(packet.getID());
reply.setTo(packet.getFrom());
reply.setFrom(packet.getTo());
reply.setError(PacketError.Condition.not_authorized);
send(reply);
}
}
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
}
use of org.xmpp.packet.IQ in project Openfire by igniterealtime.
the class WorkgroupManager method sendWorkgroups.
private void sendWorkgroups(IQ request, Agent agent) {
IQ reply = IQ.createResultIQ(request);
Element workgroupsElement = reply.setChildElement("workgroups", "http://jabber.org/protocol/workgroup");
workgroupsElement.addAttribute("jid", agent.getAgentJID().toBareJID());
for (Workgroup workgroup : getWorkgroups()) {
if (workgroup.getAgents().contains(agent)) {
// Add the information of the workgroup
Element workgroupElement = workgroupsElement.addElement("workgroup");
workgroupElement.addAttribute("jid", workgroup.getJID().toBareJID());
}
}
send(reply);
}
use of org.xmpp.packet.IQ in project Openfire by igniterealtime.
the class OfflineSettingsProvider method executeGet.
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
OfflineSettingsManager offlineSettingsManager = new OfflineSettingsManager();
OfflineSettings settings;
try {
settings = offlineSettingsManager.getOfflineSettings(workgroup);
} catch (OfflineSettingsNotFound offlineSettingsNotFound) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
Element offline = reply.setChildElement("offline-settings", "http://jivesoftware.com/protocol/workgroup");
if (ModelUtil.hasLength(settings.getRedirectURL())) {
offline.addElement("redirectPage").setText(settings.getRedirectURL());
} else {
offline.addElement("emailAddress").setText(settings.getEmailAddress());
offline.addElement("offlineText").setText(settings.getOfflineText());
offline.addElement("subject").setText(settings.getSubject());
}
workgroup.send(reply);
}
Aggregations