aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-05-13 10:45:30 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-05-13 10:45:30 +0200
commitb756d61c45f5cd3a3c69dd93115ad558f41de216 (patch)
tree85bbb056fae16db58d6ca37992582819bedbbd4f /src/main/java/eu/siacs/conversations/entities
parente6ff1539b47d71142d8de0186149117d10f5ce72 (diff)
show presence of other resources as template
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Account.java4
-rw-r--r--src/main/java/eu/siacs/conversations/entities/PresenceTemplate.java20
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Presences.java11
3 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java
index c6b655d0a..1cdf0d673 100644
--- a/src/main/java/eu/siacs/conversations/entities/Account.java
+++ b/src/main/java/eu/siacs/conversations/entities/Account.java
@@ -79,6 +79,10 @@ public class Account extends AbstractEntity {
}
}
+ public Contact getSelfContact() {
+ return getRoster().getContact(jid);
+ }
+
public enum State {
DISABLED,
OFFLINE,
diff --git a/src/main/java/eu/siacs/conversations/entities/PresenceTemplate.java b/src/main/java/eu/siacs/conversations/entities/PresenceTemplate.java
index 3b3ce08db..c268b24c2 100644
--- a/src/main/java/eu/siacs/conversations/entities/PresenceTemplate.java
+++ b/src/main/java/eu/siacs/conversations/entities/PresenceTemplate.java
@@ -53,4 +53,24 @@ public class PresenceTemplate extends AbstractEntity {
public String getStatusMessage() {
return statusMessage;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ PresenceTemplate template = (PresenceTemplate) o;
+
+ if (statusMessage != null ? !statusMessage.equals(template.statusMessage) : template.statusMessage != null)
+ return false;
+ return status == template.status;
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = statusMessage != null ? statusMessage.hashCode() : 0;
+ result = 31 * result + status.hashCode();
+ return result;
+ }
}
diff --git a/src/main/java/eu/siacs/conversations/entities/Presences.java b/src/main/java/eu/siacs/conversations/entities/Presences.java
index 754175ab2..7630fd936 100644
--- a/src/main/java/eu/siacs/conversations/entities/Presences.java
+++ b/src/main/java/eu/siacs/conversations/entities/Presences.java
@@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import eu.siacs.conversations.xml.Element;
@@ -54,6 +55,16 @@ public class Presences {
}
}
+ public List<PresenceTemplate> asTemplates() {
+ synchronized (this.presences) {
+ ArrayList<PresenceTemplate> templates = new ArrayList<>(presences.size());
+ for(Presence p : presences.values()) {
+ templates.add(new PresenceTemplate(p.getStatus(),p.getMessage()));
+ }
+ return templates;
+ }
+ }
+
public boolean has(String presence) {
synchronized (this.presences) {
return presences.containsKey(presence);