mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 20:52:21 -05:00
fixed full jid for account
This commit is contained in:
parent
87c4fd9050
commit
2b99b694eb
@ -1,8 +1,8 @@
|
||||
package eu.siacs.conversations.entities;
|
||||
|
||||
import java.security.interfaces.DSAPublicKey;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
|
||||
import net.java.otr4j.crypto.OtrCryptoException;
|
||||
@ -10,6 +10,10 @@ import net.java.otr4j.crypto.OtrCryptoException;
|
||||
import org.json.JSONException;
|
||||
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.R;
|
||||
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.Jid;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.os.SystemClock;
|
||||
|
||||
public class Account extends AbstractEntity {
|
||||
|
||||
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_SUCCESSFULL = 9;
|
||||
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 String password;
|
||||
protected int options = 0;
|
||||
@ -59,19 +60,14 @@ public class Account extends AbstractEntity {
|
||||
protected int status = -1;
|
||||
protected JSONObject keys = new JSONObject();
|
||||
protected String avatar;
|
||||
|
||||
protected boolean online = false;
|
||||
|
||||
private OtrEngine otrEngine = null;
|
||||
private XmppConnection xmppConnection = null;
|
||||
private Presences presences = new Presences();
|
||||
private long mEndGracePeriod = 0L;
|
||||
private String otrFingerprint;
|
||||
private Roster roster = null;
|
||||
|
||||
private List<Bookmark> bookmarks = new CopyOnWriteArrayList<>();
|
||||
public List<Conversation> pendingConferenceJoins = new CopyOnWriteArrayList<>();
|
||||
public List<Conversation> pendingConferenceLeaves = new CopyOnWriteArrayList<>();
|
||||
|
||||
public Account() {
|
||||
this.uuid = "0";
|
||||
@ -101,6 +97,22 @@ public class Account extends AbstractEntity {
|
||||
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) {
|
||||
return ((options & (1 << option)) != 0);
|
||||
}
|
||||
@ -137,10 +149,6 @@ public class Account extends AbstractEntity {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setStatus(final int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
if (isOptionSet(OPTION_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() {
|
||||
int s = getStatus();
|
||||
return (s == STATUS_REGISTRATION_FAILED
|
||||
@ -161,17 +173,17 @@ public class Account extends AbstractEntity {
|
||||
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 {
|
||||
jid = Jid.fromParts(jid.getLocalpart(), jid.getDomainpart(), resource);
|
||||
} catch (final InvalidJidException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public String getResource() {
|
||||
return jid.getResourcepart();
|
||||
}
|
||||
|
||||
public Jid getJid() {
|
||||
return jid.toBareJid();
|
||||
}
|
||||
@ -219,22 +231,6 @@ public class Account extends AbstractEntity {
|
||||
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) {
|
||||
if (otrEngine == null) {
|
||||
otrEngine = new OtrEngine(context, this);
|
||||
@ -251,7 +247,7 @@ public class Account extends AbstractEntity {
|
||||
}
|
||||
|
||||
public Jid getFullJid() {
|
||||
return this.getJid();
|
||||
return this.jid;
|
||||
}
|
||||
|
||||
public String getOtrFingerprint() {
|
||||
@ -328,14 +324,14 @@ public class Account extends AbstractEntity {
|
||||
return this.roster;
|
||||
}
|
||||
|
||||
public void setBookmarks(List<Bookmark> bookmarks) {
|
||||
this.bookmarks = bookmarks;
|
||||
}
|
||||
|
||||
public List<Bookmark> getBookmarks() {
|
||||
return this.bookmarks;
|
||||
}
|
||||
|
||||
public void setBookmarks(List<Bookmark> bookmarks) {
|
||||
this.bookmarks = bookmarks;
|
||||
}
|
||||
|
||||
public boolean hasBookmarkFor(final Jid conferenceJid) {
|
||||
for (Bookmark bmark : this.bookmarks) {
|
||||
if (bmark.getJid().equals(conferenceJid.toBareJid())) {
|
||||
|
Loading…
Reference in New Issue
Block a user