aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/entities/Account.java
blob: dcb5516a43cabe6029c8f130a753ae9876645f16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package de.gultsch.chat.entities;

import android.content.ContentValues;
import android.database.Cursor;
import android.util.Log;

public class Account  extends AbstractEntity{

	private static final long serialVersionUID = 6174825093869578035L;
	
	public static final String TABLENAME = "accounts";
	
	public static final String USERNAME = "username";
	public static final String SERVER = "server";
	public static final String PASSWORD = "password";
	public static final String OPTIONS = "options";
	public static final String ROSTERVERSION = "rosterversion";
	
	protected String username;
	protected String server;
	protected String password;
	protected int options;
	protected String rosterVersion;
	
	protected boolean online = false;
	
	public Account() {
		this.uuid = "0";
	}
	
	public Account(String username, String server, String password) {
		this(java.util.UUID.randomUUID().toString(),username,server,password,0,null);
	}
	public Account(String uuid, String username, String server,String password, int options, String rosterVersion) {
		this.uuid = uuid;
		this.username = username;
		this.server = server;
		this.password = password;
		this.options = options;
		this.rosterVersion = rosterVersion;
	}
	
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getServer() {
		return server;
	}

	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;
	}

	@Override
	public ContentValues getContentValues() {
		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)),
				cursor.getString(cursor.getColumnIndex(PASSWORD)),
				cursor.getInt(cursor.getColumnIndex(OPTIONS)),
				cursor.getString(cursor.getColumnIndex(ROSTERVERSION))
				);
	}

}