made our spanish friends happy. fixed #68

This commit is contained in:
Daniel Gultsch 2014-04-20 20:53:36 +02:00
parent d140ef6390
commit 04418484a2
1 changed files with 22 additions and 21 deletions

View File

@ -39,7 +39,7 @@ public class Contact extends AbstractEntity implements Serializable {
protected Presences presences = new Presences();
protected Account account;
protected boolean inRoster = true;
public Contact(Account account, String displayName, String jid,
@ -120,7 +120,7 @@ public class Contact extends AbstractEntity implements Serializable {
cursor.getString(cursor.getColumnIndex(KEYS)),
cursor.getString(cursor.getColumnIndex(PRESENCES)));
}
public int getSubscription() {
return this.subscription;
}
@ -152,8 +152,10 @@ public class Contact extends AbstractEntity implements Serializable {
return false;
} else {
return (domainParts[0].equals("conf")
|| domainParts[0].equals("conference") || domainParts[0]
.equals("muc"));
|| domainParts[0].equals("conference")
|| domainParts[0].equals("muc")
|| domainParts[0].equals("sala")
|| domainParts[0].equals("salas"));
}
}
}
@ -169,7 +171,7 @@ public class Contact extends AbstractEntity implements Serializable {
public void removePresence(String resource) {
this.presences.removePresence(resource);
}
public void clearPresences() {
this.presences.clearPresences();
}
@ -198,7 +200,8 @@ public class Contact extends AbstractEntity implements Serializable {
Set<String> set = new HashSet<String>();
try {
if (this.keys.has("otr_fingerprints")) {
JSONArray fingerprints = this.keys.getJSONArray("otr_fingerprints");
JSONArray fingerprints = this.keys
.getJSONArray("otr_fingerprints");
for (int i = 0; i < fingerprints.length(); ++i) {
set.add(fingerprints.getString(i));
}
@ -225,15 +228,15 @@ public class Contact extends AbstractEntity implements Serializable {
}
}
public void setPgpKeyId(long keyId) {
try {
this.keys.put("pgp_keyid", keyId);
} catch (JSONException e) {
}
}
public long getPgpKeyId() {
if (this.keys.has("pgp_keyid")) {
try {
@ -245,24 +248,24 @@ public class Contact extends AbstractEntity implements Serializable {
return 0;
}
}
public void setSubscriptionOption(int option) {
this.subscription |= 1 << option;
}
public void resetSubscriptionOption(int option) {
this.subscription &= ~(1 << option);
}
public boolean getSubscriptionOption(int option) {
return ((this.subscription & (1 << option)) != 0);
}
public void parseSubscriptionFromElement(Element item) {
String ask = item.getAttribute("ask");
String subscription = item.getAttribute("subscription");
if (subscription!=null) {
if (subscription != null) {
if (subscription.equals("to")) {
this.resetSubscriptionOption(Contact.Subscription.FROM);
this.setSubscriptionOption(Contact.Subscription.TO);
@ -274,15 +277,14 @@ public class Contact extends AbstractEntity implements Serializable {
this.setSubscriptionOption(Contact.Subscription.FROM);
}
}
if ((ask!=null)&&(ask.equals("subscribe"))) {
if ((ask != null) && (ask.equals("subscribe"))) {
this.setSubscriptionOption(Contact.Subscription.ASKING);
} else {
this.resetSubscriptionOption(Contact.Subscription.ASKING);
}
}
public class Subscription {
public static final int TO = 0;
public static final int FROM = 1;
@ -290,11 +292,10 @@ public class Contact extends AbstractEntity implements Serializable {
public static final int PREEMPTIVE_GRANT = 4;
}
public void flagAsNotInRoster() {
this.inRoster = false;
}
public boolean isInRoster() {
return this.inRoster;
}