aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-17 20:02:46 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-17 20:02:46 +0100
commitf41c3eee04a647fa3f44da20ca77928731ce8946 (patch)
tree1b60f0b00425ed4d4f354aef33f7a9eb8282337e /src/main/java/eu/siacs/conversations/entities
parent283d5058e5f91e11fc651a83ce2968580bd94d4a (diff)
context menu for muc participants + refactor trueCounterpart to use Jid class
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Message.java25
-rw-r--r--src/main/java/eu/siacs/conversations/entities/MucOptions.java10
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Roster.java5
3 files changed, 27 insertions, 13 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java
index 33f3443b..eae08f31 100644
--- a/src/main/java/eu/siacs/conversations/entities/Message.java
+++ b/src/main/java/eu/siacs/conversations/entities/Message.java
@@ -49,7 +49,7 @@ public class Message extends AbstractEntity {
public boolean markable = false;
protected String conversationUuid;
protected Jid counterpart;
- protected String trueCounterpart;
+ protected Jid trueCounterpart;
protected String body;
protected String encryptedBody;
protected long timeSent;
@@ -81,7 +81,7 @@ public class Message extends AbstractEntity {
}
public Message(final String uuid, final String conversationUUid, final Jid counterpart,
- final String trueCounterpart, final String body, final long timeSent,
+ final Jid trueCounterpart, final String body, final long timeSent,
final int encryption, final int status, final int type, final String remoteMsgId, final String relativeFilePath) {
this.uuid = uuid;
this.conversationUuid = conversationUUid;
@@ -108,10 +108,21 @@ public class Message extends AbstractEntity {
} catch (InvalidJidException e) {
jid = null;
}
+ Jid trueCounterpart;
+ try {
+ String value = cursor.getString(cursor.getColumnIndex(TRUE_COUNTERPART));
+ if (value!=null) {
+ trueCounterpart = Jid.fromString(value);
+ } else {
+ trueCounterpart = null;
+ }
+ } catch (InvalidJidException e) {
+ trueCounterpart = null;
+ }
return new Message(cursor.getString(cursor.getColumnIndex(UUID)),
cursor.getString(cursor.getColumnIndex(CONVERSATION)),
jid,
- cursor.getString(cursor.getColumnIndex(TRUE_COUNTERPART)),
+ trueCounterpart,
cursor.getString(cursor.getColumnIndex(BODY)),
cursor.getLong(cursor.getColumnIndex(TIME_SENT)),
cursor.getInt(cursor.getColumnIndex(ENCRYPTION)),
@@ -138,7 +149,11 @@ public class Message extends AbstractEntity {
} else {
values.put(COUNTERPART, counterpart.toString());
}
- values.put(TRUE_COUNTERPART, trueCounterpart);
+ if (trueCounterpart == null ) {
+ values.putNull(TRUE_COUNTERPART);
+ } else {
+ values.put(TRUE_COUNTERPART, trueCounterpart.toString());
+ }
values.put(BODY, body);
values.put(TIME_SENT, timeSent);
values.put(ENCRYPTION, encryption);
@@ -258,7 +273,7 @@ public class Message extends AbstractEntity {
this.type = type;
}
- public void setTrueCounterpart(String trueCounterpart) {
+ public void setTrueCounterpart(Jid trueCounterpart) {
this.trueCounterpart = trueCounterpart;
}
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java
index 6eb1d43c..4725bffa 100644
--- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java
@@ -43,7 +43,7 @@ public class MucOptions {
private int role;
private int affiliation;
private String name;
- private String jid;
+ private Jid jid;
private long pgpKeyId = 0;
public String getName() {
@@ -54,11 +54,11 @@ public class MucOptions {
this.name = user;
}
- public void setJid(String jid) {
+ public void setJid(Jid jid) {
this.jid = jid;
}
- public String getJid() {
+ public Jid getJid() {
return this.jid;
}
@@ -165,7 +165,7 @@ public class MucOptions {
user.setName(name);
user.setAffiliation(item.getAttribute("affiliation"));
user.setRole(item.getAttribute("role"));
- user.setJid(item.getAttribute("jid"));
+ user.setJid(item.getAttributeAsJid("jid"));
user.setName(name);
if (name.equals(this.joinnick)) {
this.isOnline = true;
@@ -346,7 +346,7 @@ public class MucOptions {
}
}
- public String getTrueCounterpart(String counterpart) {
+ public Jid getTrueCounterpart(String counterpart) {
for (User user : this.getUsers()) {
if (user.getName().equals(counterpart)) {
return user.getJid();
diff --git a/src/main/java/eu/siacs/conversations/entities/Roster.java b/src/main/java/eu/siacs/conversations/entities/Roster.java
index 27d4deb0..12a89cec 100644
--- a/src/main/java/eu/siacs/conversations/entities/Roster.java
+++ b/src/main/java/eu/siacs/conversations/entities/Roster.java
@@ -15,12 +15,11 @@ public class Roster {
this.account = account;
}
- public Contact getContactFromRoster(String jid) {
+ public Contact getContactFromRoster(Jid jid) {
if (jid == null) {
return null;
}
- String cleanJid = jid.split("/", 2)[0];
- Contact contact = contacts.get(cleanJid);
+ Contact contact = contacts.get(jid.toBareJid().toString());
if (contact != null && contact.showInRoster()) {
return contact;
} else {