package eu.siacs.conversations.generator; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.xmpp.stanzas.PresencePacket; public class PresenceGenerator { public PresencePacket requestPresenceUpdatesFrom(Contact contact) { PresencePacket packet = new PresencePacket(); packet.setAttribute("type", "subscribe"); packet.setAttribute("to", contact.getJid()); packet.setAttribute("from", contact.getAccount().getJid()); return packet; } public PresencePacket stopPresenceUpdatesFrom(Contact contact) { PresencePacket packet = new PresencePacket(); packet.setAttribute("type", "unsubscribe"); packet.setAttribute("to", contact.getJid()); packet.setAttribute("from", contact.getAccount().getJid()); return packet; } public PresencePacket stopPresenceUpdatesTo(Contact contact) { PresencePacket packet = new PresencePacket(); packet.setAttribute("type", "unsubscribed"); packet.setAttribute("to", contact.getJid()); packet.setAttribute("from", contact.getAccount().getJid()); return packet; } public PresencePacket sendPresenceUpdatesTo(Contact contact) { PresencePacket packet = new PresencePacket(); packet.setAttribute("type", "subscribed"); packet.setAttribute("to", contact.getJid()); packet.setAttribute("from", contact.getAccount().getJid()); return packet; } public PresencePacket sendPresence(Account account) { PresencePacket packet = new PresencePacket(); packet.setAttribute("from", account.getFullJid()); String sig = account.getPgpSignature(); if (sig != null) { packet.addChild("status").setContent("online"); packet.addChild("x", "jabber:x:signed").setContent(sig); } return packet; } }