aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/entities
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-01-28 19:21:54 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-01-28 19:21:54 +0100
commit52da0fe7c9c68d4545f068fb84efbf0854c37392 (patch)
tree4c6bfae86fc90274b26e0c18ebd7793040663759 /src/de/gultsch/chat/entities
parent4f902d8210d50a586c7ece1bb7da2ab26fd18da5 (diff)
account management
Diffstat (limited to 'src/de/gultsch/chat/entities')
-rw-r--r--src/de/gultsch/chat/entities/Account.java74
-rw-r--r--src/de/gultsch/chat/entities/Message.java2
2 files changed, 72 insertions, 4 deletions
diff --git a/src/de/gultsch/chat/entities/Account.java b/src/de/gultsch/chat/entities/Account.java
index 5b83ca799..5f95af638 100644
--- a/src/de/gultsch/chat/entities/Account.java
+++ b/src/de/gultsch/chat/entities/Account.java
@@ -1,18 +1,86 @@
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";
+
+ protected String username;
+ protected String server;
+ protected String password;
+
+ protected boolean online = false;
+
public Account() {
- this.uuid = "";
+ this.uuid = "0";
+ }
+
+ public Account(String username, String server, String password) {
+ this(java.util.UUID.randomUUID().toString(),username,server,password);
+ }
+ public Account(String uuid, String username, String server,String password) {
+ this.uuid = uuid;
+ this.username = username;
+ this.server = server;
+ this.password = password;
+ }
+
+ 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() {
- // TODO Auto-generated method stub
- return null;
+ 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)));
}
}
diff --git a/src/de/gultsch/chat/entities/Message.java b/src/de/gultsch/chat/entities/Message.java
index b52e44b4e..130435b92 100644
--- a/src/de/gultsch/chat/entities/Message.java
+++ b/src/de/gultsch/chat/entities/Message.java
@@ -54,7 +54,7 @@ public class Message extends AbstractEntity {
@Override
public ContentValues getContentValues() {
ContentValues values = new ContentValues();
- values.put(UUID, this.uuid);
+ values.put(UUID, uuid);
values.put(CONVERSATION, conversationUuid);
values.put(COUNTERPART, counterpart);
values.put(BODY, body);