fixed full jid for account
This commit is contained in:
parent
87c4fd9050
commit
2b99b694eb
|
@ -1,8 +1,8 @@
|
||||||
package eu.siacs.conversations.entities;
|
package eu.siacs.conversations.entities;
|
||||||
|
|
||||||
import java.security.interfaces.DSAPublicKey;
|
import android.content.ContentValues;
|
||||||
import java.util.List;
|
import android.database.Cursor;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
|
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
|
||||||
import net.java.otr4j.crypto.OtrCryptoException;
|
import net.java.otr4j.crypto.OtrCryptoException;
|
||||||
|
@ -10,6 +10,10 @@ import net.java.otr4j.crypto.OtrCryptoException;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.security.interfaces.DSAPublicKey;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.crypto.OtrEngine;
|
import eu.siacs.conversations.crypto.OtrEngine;
|
||||||
|
@ -18,10 +22,6 @@ import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.os.SystemClock;
|
|
||||||
|
|
||||||
public class Account extends AbstractEntity {
|
public class Account extends AbstractEntity {
|
||||||
|
|
||||||
public static final String TABLENAME = "accounts";
|
public static final String TABLENAME = "accounts";
|
||||||
|
@ -51,7 +51,8 @@ public class Account extends AbstractEntity {
|
||||||
public static final int STATUS_REGISTRATION_CONFLICT = 8;
|
public static final int STATUS_REGISTRATION_CONFLICT = 8;
|
||||||
public static final int STATUS_REGISTRATION_SUCCESSFULL = 9;
|
public static final int STATUS_REGISTRATION_SUCCESSFULL = 9;
|
||||||
public static final int STATUS_REGISTRATION_NOT_SUPPORTED = 10;
|
public static final int STATUS_REGISTRATION_NOT_SUPPORTED = 10;
|
||||||
|
public List<Conversation> pendingConferenceJoins = new CopyOnWriteArrayList<>();
|
||||||
|
public List<Conversation> pendingConferenceLeaves = new CopyOnWriteArrayList<>();
|
||||||
protected Jid jid;
|
protected Jid jid;
|
||||||
protected String password;
|
protected String password;
|
||||||
protected int options = 0;
|
protected int options = 0;
|
||||||
|
@ -59,19 +60,14 @@ public class Account extends AbstractEntity {
|
||||||
protected int status = -1;
|
protected int status = -1;
|
||||||
protected JSONObject keys = new JSONObject();
|
protected JSONObject keys = new JSONObject();
|
||||||
protected String avatar;
|
protected String avatar;
|
||||||
|
|
||||||
protected boolean online = false;
|
protected boolean online = false;
|
||||||
|
|
||||||
private OtrEngine otrEngine = null;
|
private OtrEngine otrEngine = null;
|
||||||
private XmppConnection xmppConnection = null;
|
private XmppConnection xmppConnection = null;
|
||||||
private Presences presences = new Presences();
|
private Presences presences = new Presences();
|
||||||
private long mEndGracePeriod = 0L;
|
private long mEndGracePeriod = 0L;
|
||||||
private String otrFingerprint;
|
private String otrFingerprint;
|
||||||
private Roster roster = null;
|
private Roster roster = null;
|
||||||
|
|
||||||
private List<Bookmark> bookmarks = new CopyOnWriteArrayList<>();
|
private List<Bookmark> bookmarks = new CopyOnWriteArrayList<>();
|
||||||
public List<Conversation> pendingConferenceJoins = new CopyOnWriteArrayList<>();
|
|
||||||
public List<Conversation> pendingConferenceLeaves = new CopyOnWriteArrayList<>();
|
|
||||||
|
|
||||||
public Account() {
|
public Account() {
|
||||||
this.uuid = "0";
|
this.uuid = "0";
|
||||||
|
@ -101,6 +97,22 @@ public class Account extends AbstractEntity {
|
||||||
this.avatar = avatar;
|
this.avatar = avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Account fromCursor(Cursor cursor) {
|
||||||
|
Jid jid = null;
|
||||||
|
try {
|
||||||
|
jid = Jid.fromParts(cursor.getString(cursor.getColumnIndex(USERNAME)),
|
||||||
|
cursor.getString(cursor.getColumnIndex(SERVER)), "mobile");
|
||||||
|
} catch (final InvalidJidException ignored) {
|
||||||
|
}
|
||||||
|
return new Account(cursor.getString(cursor.getColumnIndex(UUID)),
|
||||||
|
jid,
|
||||||
|
cursor.getString(cursor.getColumnIndex(PASSWORD)),
|
||||||
|
cursor.getInt(cursor.getColumnIndex(OPTIONS)),
|
||||||
|
cursor.getString(cursor.getColumnIndex(ROSTERVERSION)),
|
||||||
|
cursor.getString(cursor.getColumnIndex(KEYS)),
|
||||||
|
cursor.getString(cursor.getColumnIndex(AVATAR)));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOptionSet(int option) {
|
public boolean isOptionSet(int option) {
|
||||||
return ((options & (1 << option)) != 0);
|
return ((options & (1 << option)) != 0);
|
||||||
}
|
}
|
||||||
|
@ -137,10 +149,6 @@ public class Account extends AbstractEntity {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(final int status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStatus() {
|
public int getStatus() {
|
||||||
if (isOptionSet(OPTION_DISABLED)) {
|
if (isOptionSet(OPTION_DISABLED)) {
|
||||||
return STATUS_DISABLED;
|
return STATUS_DISABLED;
|
||||||
|
@ -149,6 +157,10 @@ public class Account extends AbstractEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStatus(final int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean errorStatus() {
|
public boolean errorStatus() {
|
||||||
int s = getStatus();
|
int s = getStatus();
|
||||||
return (s == STATUS_REGISTRATION_FAILED
|
return (s == STATUS_REGISTRATION_FAILED
|
||||||
|
@ -161,17 +173,17 @@ public class Account extends AbstractEntity {
|
||||||
return getXmppConnection() != null && getStatus() > STATUS_NO_INTERNET && (getXmppConnection().getAttempt() >= 2);
|
return getXmppConnection() != null && getStatus() > STATUS_NO_INTERNET && (getXmppConnection().getAttempt() >= 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(final String resource){
|
public String getResource() {
|
||||||
|
return jid.getResourcepart();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResource(final String resource) {
|
||||||
try {
|
try {
|
||||||
jid = Jid.fromParts(jid.getLocalpart(), jid.getDomainpart(), resource);
|
jid = Jid.fromParts(jid.getLocalpart(), jid.getDomainpart(), resource);
|
||||||
} catch (final InvalidJidException ignored) {
|
} catch (final InvalidJidException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResource() {
|
|
||||||
return jid.getResourcepart();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Jid getJid() {
|
public Jid getJid() {
|
||||||
return jid.toBareJid();
|
return jid.toBareJid();
|
||||||
}
|
}
|
||||||
|
@ -219,22 +231,6 @@ public class Account extends AbstractEntity {
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Account fromCursor(Cursor cursor) {
|
|
||||||
Jid jid = null;
|
|
||||||
try {
|
|
||||||
jid = Jid.fromParts(cursor.getString(cursor.getColumnIndex(USERNAME)),
|
|
||||||
cursor.getString(cursor.getColumnIndex(SERVER)), "mobile");
|
|
||||||
} catch (final InvalidJidException ignored) {
|
|
||||||
}
|
|
||||||
return new Account(cursor.getString(cursor.getColumnIndex(UUID)),
|
|
||||||
jid,
|
|
||||||
cursor.getString(cursor.getColumnIndex(PASSWORD)),
|
|
||||||
cursor.getInt(cursor.getColumnIndex(OPTIONS)),
|
|
||||||
cursor.getString(cursor.getColumnIndex(ROSTERVERSION)),
|
|
||||||
cursor.getString(cursor.getColumnIndex(KEYS)),
|
|
||||||
cursor.getString(cursor.getColumnIndex(AVATAR)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public OtrEngine getOtrEngine(XmppConnectionService context) {
|
public OtrEngine getOtrEngine(XmppConnectionService context) {
|
||||||
if (otrEngine == null) {
|
if (otrEngine == null) {
|
||||||
otrEngine = new OtrEngine(context, this);
|
otrEngine = new OtrEngine(context, this);
|
||||||
|
@ -251,7 +247,7 @@ public class Account extends AbstractEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Jid getFullJid() {
|
public Jid getFullJid() {
|
||||||
return this.getJid();
|
return this.jid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOtrFingerprint() {
|
public String getOtrFingerprint() {
|
||||||
|
@ -328,14 +324,14 @@ public class Account extends AbstractEntity {
|
||||||
return this.roster;
|
return this.roster;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBookmarks(List<Bookmark> bookmarks) {
|
|
||||||
this.bookmarks = bookmarks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Bookmark> getBookmarks() {
|
public List<Bookmark> getBookmarks() {
|
||||||
return this.bookmarks;
|
return this.bookmarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBookmarks(List<Bookmark> bookmarks) {
|
||||||
|
this.bookmarks = bookmarks;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasBookmarkFor(final Jid conferenceJid) {
|
public boolean hasBookmarkFor(final Jid conferenceJid) {
|
||||||
for (Bookmark bmark : this.bookmarks) {
|
for (Bookmark bmark : this.bookmarks) {
|
||||||
if (bmark.getJid().equals(conferenceJid.toBareJid())) {
|
if (bmark.getJid().equals(conferenceJid.toBareJid())) {
|
||||||
|
|
Loading…
Reference in a new issue