This commit is contained in:
Moxie Marlinspike
2014-01-14 00:26:43 -08:00
parent 4851a555e7
commit 49daa45dca
19 changed files with 1674 additions and 244 deletions
@@ -18,12 +18,11 @@ public class PushDatabase extends Database {
public static final String ID = "_id";
public static final String TYPE = "type";
public static final String SOURCE = "source";
public static final String DESTINATIONS = "destinations";
public static final String BODY = "body";
public static final String TIMESTAMP = "timestamp";
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" + ID + " INTEGER PRIMARY KEY, " +
TYPE + " INTEGER, " + SOURCE + " TEXT, " + DESTINATIONS + " TEXT, " + BODY + " TEXT, " + TIMESTAMP + " INTEGER);";
TYPE + " INTEGER, " + SOURCE + " TEXT, " + BODY + " TEXT, " + TIMESTAMP + " INTEGER);";
public PushDatabase(Context context, SQLiteOpenHelper databaseHelper) {
super(context, databaseHelper);
@@ -33,7 +32,6 @@ public class PushDatabase extends Database {
ContentValues values = new ContentValues();
values.put(TYPE, message.getType());
values.put(SOURCE, message.getSource());
values.put(DESTINATIONS, Util.join(message.getDestinations(), ","));
values.put(BODY, Base64.encodeBytes(message.getBody()));
values.put(TIMESTAMP, message.getTimestampMillis());
@@ -66,11 +64,10 @@ public class PushDatabase extends Database {
int type = cursor.getInt(cursor.getColumnIndexOrThrow(TYPE));
String source = cursor.getString(cursor.getColumnIndexOrThrow(SOURCE));
List<String> destinations = Util.split(cursor.getString(cursor.getColumnIndexOrThrow(DESTINATIONS)), ",");
byte[] body = Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(BODY)));
long timestamp = cursor.getLong(cursor.getColumnIndexOrThrow(TIMESTAMP));
return new IncomingPushMessage(type, source, destinations, body, timestamp);
return new IncomingPushMessage(type, source, body, timestamp);
} catch (IOException e) {
throw new AssertionError(e);
}