aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/entities
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-07 16:50:29 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-07 16:50:29 +0100
commit95068ee776d9ec8e6c390133ca2bed083a46546f (patch)
tree26be6da8d503d213b5611f8a862f87cbd737321b /src/de/gultsch/chat/entities
parent86dbb2f411c28a5eaae207caf1e6bcd1e56503b0 (diff)
reworked new conversation activity again. less asking more knowing. mucs are now connected on creation of the conversation. no reconnect required
Diffstat (limited to 'src/de/gultsch/chat/entities')
-rw-r--r--src/de/gultsch/chat/entities/Contact.java59
-rw-r--r--src/de/gultsch/chat/entities/Conversation.java4
2 files changed, 42 insertions, 21 deletions
diff --git a/src/de/gultsch/chat/entities/Contact.java b/src/de/gultsch/chat/entities/Contact.java
index 3478eac7..6079d9bb 100644
--- a/src/de/gultsch/chat/entities/Contact.java
+++ b/src/de/gultsch/chat/entities/Contact.java
@@ -7,10 +7,9 @@ import android.database.Cursor;
public class Contact extends AbstractEntity implements Serializable {
private static final long serialVersionUID = -4570817093119419962L;
-
-
+
public static final String TABLENAME = "contacts";
-
+
public static final String DISPLAYNAME = "name";
public static final String JID = "jid";
public static final String SUBSCRIPTION = "subscription";
@@ -19,7 +18,7 @@ public class Contact extends AbstractEntity implements Serializable {
public static final String OPENPGPKEY = "pgpkey";
public static final String LASTPRESENCE = "presence";
public static final String ACCOUNT = "accountUuid";
-
+
protected String accountUuid;
protected String displayName;
protected String jid;
@@ -29,10 +28,10 @@ public class Contact extends AbstractEntity implements Serializable {
protected String openPGPKey;
protected long lastPresence;
-
protected Account account;
-
- public Contact(Account account, String displayName, String jid, String photoUri) {
+
+ public Contact(Account account, String displayName, String jid,
+ String photoUri) {
if (account == null) {
this.accountUuid = null;
} else {
@@ -42,8 +41,10 @@ public class Contact extends AbstractEntity implements Serializable {
this.jid = jid;
this.photoUri = photoUri;
}
-
- public Contact(String uuid, String account, String displayName, String jid, String subscription, String photoUri, int systemAccount, String pgpKey, long lastseen) {
+
+ public Contact(String uuid, String account, String displayName, String jid,
+ String subscription, String photoUri, int systemAccount,
+ String pgpKey, long lastseen) {
this.uuid = uuid;
this.accountUuid = account;
this.displayName = displayName;
@@ -62,30 +63,31 @@ public class Contact extends AbstractEntity implements Serializable {
public String getProfilePhoto() {
return this.photoUri;
}
-
+
public String getJid() {
return this.jid;
}
-
+
public boolean match(String needle) {
- return (jid.toLowerCase().contains(needle.toLowerCase()) || (displayName.toLowerCase().contains(needle.toLowerCase())));
+ return (jid.toLowerCase().contains(needle.toLowerCase()) || (displayName
+ .toLowerCase().contains(needle.toLowerCase())));
}
@Override
public ContentValues getContentValues() {
ContentValues values = new ContentValues();
- values.put(UUID,uuid);
- values.put(ACCOUNT,accountUuid);
+ values.put(UUID, uuid);
+ values.put(ACCOUNT, accountUuid);
values.put(DISPLAYNAME, displayName);
values.put(JID, jid);
- values.put(SUBSCRIPTION,subscription);
+ values.put(SUBSCRIPTION, subscription);
values.put(SYSTEMACCOUNT, systemAccount);
- values.put(PHOTOURI,photoUri);
- values.put(OPENPGPKEY,openPGPKey);
- values.put(LASTPRESENCE,lastPresence);
+ values.put(PHOTOURI, photoUri);
+ values.put(OPENPGPKEY, openPGPKey);
+ values.put(LASTPRESENCE, lastPresence);
return values;
}
-
+
public static Contact fromCursor(Cursor cursor) {
return new Contact(cursor.getString(cursor.getColumnIndex(UUID)),
cursor.getString(cursor.getColumnIndex(ACCOUNT)),
@@ -95,8 +97,7 @@ public class Contact extends AbstractEntity implements Serializable {
cursor.getString(cursor.getColumnIndex(PHOTOURI)),
cursor.getInt(cursor.getColumnIndex(SYSTEMACCOUNT)),
cursor.getString(cursor.getColumnIndex(OPENPGPKEY)),
- cursor.getLong(cursor.getColumnIndex(LASTPRESENCE))
- );
+ cursor.getLong(cursor.getColumnIndex(LASTPRESENCE)));
}
public void setSubscription(String subscription) {
@@ -119,4 +120,20 @@ public class Contact extends AbstractEntity implements Serializable {
public void setUuid(String uuid) {
this.uuid = uuid;
}
+
+ public boolean couldBeMuc() {
+ String[] split = this.getJid().split("@");
+ if (split.length != 2) {
+ return false;
+ } else {
+ String[] domainParts = split[1].split("\\.");
+ if (domainParts.length < 3) {
+ return false;
+ } else {
+ return (domainParts[0].equals("conf")
+ || domainParts[0].equals("conference") || domainParts[0]
+ .equals("muc"));
+ }
+ }
+ }
}
diff --git a/src/de/gultsch/chat/entities/Conversation.java b/src/de/gultsch/chat/entities/Conversation.java
index 1b666ce3..329f2bea 100644
--- a/src/de/gultsch/chat/entities/Conversation.java
+++ b/src/de/gultsch/chat/entities/Conversation.java
@@ -160,4 +160,8 @@ public class Conversation extends AbstractEntity {
public int getMode() {
return this.mode;
}
+
+ public void setMode(int mode) {
+ this.mode = mode;
+ }
}