aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/generator/PresenceGenerator.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/generator/PresenceGenerator.java')
-rw-r--r--src/eu/siacs/conversations/generator/PresenceGenerator.java26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/eu/siacs/conversations/generator/PresenceGenerator.java b/src/eu/siacs/conversations/generator/PresenceGenerator.java
index 1ca8cd05..a301392e 100644
--- a/src/eu/siacs/conversations/generator/PresenceGenerator.java
+++ b/src/eu/siacs/conversations/generator/PresenceGenerator.java
@@ -6,36 +6,28 @@ import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
public class PresenceGenerator {
- public PresencePacket requestPresenceUpdatesFrom(Contact contact) {
+ private PresencePacket subscription(String type, Contact contact) {
PresencePacket packet = new PresencePacket();
- packet.setAttribute("type", "subscribe");
+ packet.setAttribute("type", type);
packet.setAttribute("to", contact.getJid());
packet.setAttribute("from", contact.getAccount().getJid());
return packet;
}
+
+ public PresencePacket requestPresenceUpdatesFrom(Contact contact) {
+ return subscription("subscribe", contact);
+ }
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;
+ return subscription("unsubscribe", contact);
}
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;
+ return subscription("unsubscribed", contact);
}
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;
+ return subscription("subscribed", contact);
}
public PresencePacket sendPresence(Account account) {