2014-01-24 22:58:51 +00:00
|
|
|
package de.gultsch.chat.entities;
|
|
|
|
|
2014-01-25 18:33:12 +00:00
|
|
|
import android.content.ContentValues;
|
2014-01-28 18:21:54 +00:00
|
|
|
import android.database.Cursor;
|
|
|
|
import android.util.Log;
|
2014-01-24 22:58:51 +00:00
|
|
|
|
2014-01-25 18:33:12 +00:00
|
|
|
public class Account extends AbstractEntity{
|
2014-01-24 22:58:51 +00:00
|
|
|
|
2014-01-25 18:33:12 +00:00
|
|
|
private static final long serialVersionUID = 6174825093869578035L;
|
|
|
|
|
2014-01-28 18:21:54 +00:00
|
|
|
public static final String TABLENAME = "accounts";
|
|
|
|
|
|
|
|
public static final String USERNAME = "username";
|
|
|
|
public static final String SERVER = "server";
|
|
|
|
public static final String PASSWORD = "password";
|
2014-02-02 15:05:15 +00:00
|
|
|
public static final String OPTIONS = "options";
|
|
|
|
public static final String ROSTERVERSION = "rosterversion";
|
2014-01-28 18:21:54 +00:00
|
|
|
|
|
|
|
protected String username;
|
|
|
|
protected String server;
|
|
|
|
protected String password;
|
2014-02-02 15:05:15 +00:00
|
|
|
protected int options;
|
|
|
|
protected String rosterVersion;
|
2014-01-28 18:21:54 +00:00
|
|
|
|
|
|
|
protected boolean online = false;
|
|
|
|
|
2014-01-25 18:33:12 +00:00
|
|
|
public Account() {
|
2014-01-28 18:21:54 +00:00
|
|
|
this.uuid = "0";
|
|
|
|
}
|
|
|
|
|
|
|
|
public Account(String username, String server, String password) {
|
2014-02-02 15:05:15 +00:00
|
|
|
this(java.util.UUID.randomUUID().toString(),username,server,password,0,null);
|
2014-01-28 18:21:54 +00:00
|
|
|
}
|
2014-02-02 15:05:15 +00:00
|
|
|
public Account(String uuid, String username, String server,String password, int options, String rosterVersion) {
|
2014-01-28 18:21:54 +00:00
|
|
|
this.uuid = uuid;
|
|
|
|
this.username = username;
|
|
|
|
this.server = server;
|
|
|
|
this.password = password;
|
2014-02-02 15:05:15 +00:00
|
|
|
this.options = options;
|
|
|
|
this.rosterVersion = rosterVersion;
|
2014-01-28 18:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getUsername() {
|
|
|
|
return username;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUsername(String username) {
|
|
|
|
this.username = username;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getServer() {
|
|
|
|
return server;
|
2014-01-25 18:33:12 +00:00
|
|
|
}
|
2014-01-28 18:21:54 +00:00
|
|
|
|
|
|
|
public void setServer(String server) {
|
|
|
|
this.server = server;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getPassword() {
|
|
|
|
return password;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPassword(String password) {
|
|
|
|
this.password = password;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isOnline() {
|
|
|
|
return online;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getJid() {
|
|
|
|
return username+"@"+server;
|
|
|
|
}
|
|
|
|
|
2014-01-25 18:33:12 +00:00
|
|
|
@Override
|
|
|
|
public ContentValues getContentValues() {
|
2014-01-28 18:21:54 +00:00
|
|
|
ContentValues values = new ContentValues();
|
|
|
|
values.put(UUID,uuid);
|
|
|
|
values.put(USERNAME, username);
|
|
|
|
values.put(SERVER, server);
|
|
|
|
values.put(PASSWORD, password);
|
|
|
|
return values;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Account fromCursor(Cursor cursor) {
|
|
|
|
return new Account(cursor.getString(cursor.getColumnIndex(UUID)),
|
|
|
|
cursor.getString(cursor.getColumnIndex(USERNAME)),
|
|
|
|
cursor.getString(cursor.getColumnIndex(SERVER)),
|
2014-02-02 15:05:15 +00:00
|
|
|
cursor.getString(cursor.getColumnIndex(PASSWORD)),
|
|
|
|
cursor.getInt(cursor.getColumnIndex(OPTIONS)),
|
|
|
|
cursor.getString(cursor.getColumnIndex(ROSTERVERSION))
|
|
|
|
);
|
2014-01-24 22:58:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|