mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 16:07:30 +00:00
Removed tabs
This commit is contained in:
parent
030b39cd9c
commit
82f8ba3584
@ -36,14 +36,15 @@ import org.thoughtcrime.securesms.util.MemoryCleaner;
|
|||||||
*
|
*
|
||||||
* @author Moxie Marlinspike
|
* @author Moxie Marlinspike
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PassphraseCreateActivity extends PassphraseActivity {
|
public class PassphraseCreateActivity extends PassphraseActivity {
|
||||||
|
|
||||||
private EditText passphraseEdit;
|
private EditText passphraseEdit;
|
||||||
private EditText passphraseRepeatEdit;
|
private EditText passphraseRepeatEdit;
|
||||||
private Button okButton;
|
private Button okButton;
|
||||||
private Button cancelButton;
|
private Button cancelButton;
|
||||||
|
|
||||||
public PassphraseCreateActivity() { }
|
public PassphraseCreateActivity() { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -177,11 +177,11 @@ public class ReviewIdentitiesActivity extends SherlockListActivity {
|
|||||||
boolean valid;
|
boolean valid;
|
||||||
|
|
||||||
String identityKeyString = cursor.getString(cursor.getColumnIndexOrThrow(IdentityDatabase.IDENTITY_KEY));
|
String identityKeyString = cursor.getString(cursor.getColumnIndexOrThrow(IdentityDatabase.IDENTITY_KEY));
|
||||||
String identityName = cursor.getString(cursor.getColumnIndexOrThrow(IdentityDatabase.IDENTITY_NAME));
|
String identityName = cursor.getString(cursor.getColumnIndexOrThrow(IdentityDatabase.IDENTITY_NAME));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String mac = cursor.getString(cursor.getColumnIndexOrThrow(IdentityDatabase.MAC));
|
String mac = cursor.getString(cursor.getColumnIndexOrThrow(IdentityDatabase.MAC));
|
||||||
valid = masterCipher.verifyMacFor(identityName + identityKeyString, Base64.decode(mac));
|
valid = masterCipher.verifyMacFor(identityName + identityKeyString, Base64.decode(mac));
|
||||||
identityKey = new IdentityKey(Base64.decode(identityKeyString), 0);
|
identityKey = new IdentityKey(Base64.decode(identityKeyString), 0);
|
||||||
} catch (InvalidKeyException ike) {
|
} catch (InvalidKeyException ike) {
|
||||||
Log.w("ReviewIdentitiesActivity",ike);
|
Log.w("ReviewIdentitiesActivity",ike);
|
||||||
|
@ -86,7 +86,7 @@ public class CanonicalAddressDatabase {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,12 +154,12 @@ public class CanonicalAddressDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
db.execSQL(DATABASE_CREATE);
|
db.execSQL(DATABASE_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import android.content.ContentValues;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import ws.com.google.android.mms.pdu.CharacterSets;
|
import ws.com.google.android.mms.pdu.CharacterSets;
|
||||||
import ws.com.google.android.mms.pdu.EncodedStringValue;
|
import ws.com.google.android.mms.pdu.EncodedStringValue;
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.util.Log;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
public class ContentValuesBuilder {
|
public class ContentValuesBuilder {
|
||||||
|
|
||||||
|
@ -16,13 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public abstract class Database {
|
public abstract class Database {
|
||||||
|
|
||||||
protected static final String ID_WHERE = "_id = ?";
|
protected static final String ID_WHERE = "_id = ?";
|
||||||
|
@ -16,17 +16,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
|
||||||
import android.database.sqlite.SQLiteDatabase.CursorFactory;
|
import android.database.sqlite.SQLiteDatabase.CursorFactory;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
|
|
||||||
public class DatabaseFactory {
|
public class DatabaseFactory {
|
||||||
|
|
||||||
private static final int INTRODUCED_IDENTITIES_VERSION = 2;
|
private static final int INTRODUCED_IDENTITIES_VERSION = 2;
|
||||||
private static final int DATABASE_VERSION = 2;
|
private static final int DATABASE_VERSION = 2;
|
||||||
|
|
||||||
private static final String DATABASE_NAME = "messages.db";
|
private static final String DATABASE_NAME = "messages.db";
|
||||||
private static final Object lock = new Object();
|
private static final Object lock = new Object();
|
||||||
|
|
||||||
@ -146,14 +147,13 @@ public class DatabaseFactory {
|
|||||||
db.execSQL(ThreadDatabase.CREATE_TABLE);
|
db.execSQL(ThreadDatabase.CREATE_TABLE);
|
||||||
db.execSQL(MmsAddressDatabase.CREATE_TABLE);
|
db.execSQL(MmsAddressDatabase.CREATE_TABLE);
|
||||||
db.execSQL(IdentityDatabase.CREATE_TABLE);
|
db.execSQL(IdentityDatabase.CREATE_TABLE);
|
||||||
// db.execSQL(CanonicalAddress.CREATE_TABLE);
|
// db.execSQL(CanonicalAddress.CREATE_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
if (oldVersion < INTRODUCED_IDENTITIES_VERSION)
|
if (oldVersion < INTRODUCED_IDENTITIES_VERSION)
|
||||||
db.execSQL(IdentityDatabase.CREATE_TABLE);
|
db.execSQL(IdentityDatabase.CREATE_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
|
|
||||||
public class EncryptingMmsDatabase extends MmsDatabase {
|
public class EncryptingMmsDatabase extends MmsDatabase {
|
||||||
|
|
||||||
private final MasterSecret masterSecret;
|
private final MasterSecret masterSecret;
|
||||||
@ -31,7 +31,7 @@ public class EncryptingMmsDatabase extends MmsDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PartDatabase getPartDatabase() {
|
protected PartDatabase getPartDatabase() {
|
||||||
return DatabaseFactory.getEncryptingPartDatabase(context, masterSecret);
|
return DatabaseFactory.getEncryptingPartDatabase(context, masterSecret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,19 +16,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import java.io.File;
|
import android.content.Context;
|
||||||
import java.io.FileInputStream;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import java.io.FileNotFoundException;
|
import android.util.Log;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream;
|
import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream;
|
||||||
import org.thoughtcrime.securesms.crypto.EncryptingPartOutputStream;
|
import org.thoughtcrime.securesms.crypto.EncryptingPartOutputStream;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
|
|
||||||
import ws.com.google.android.mms.pdu.PduPart;
|
import ws.com.google.android.mms.pdu.PduPart;
|
||||||
import android.content.Context;
|
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import java.io.File;
|
||||||
import android.util.Log;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
|
||||||
public class EncryptingPartDatabase extends PartDatabase {
|
public class EncryptingPartDatabase extends PartDatabase {
|
||||||
|
|
||||||
|
@ -16,16 +16,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import android.telephony.SmsMessage;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.AsymmetricMasterCipher;
|
import org.thoughtcrime.securesms.crypto.AsymmetricMasterCipher;
|
||||||
import org.thoughtcrime.securesms.crypto.AsymmetricMasterSecret;
|
import org.thoughtcrime.securesms.crypto.AsymmetricMasterSecret;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.protocol.Prefix;
|
import org.thoughtcrime.securesms.protocol.Prefix;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
|
||||||
import android.telephony.SmsMessage;
|
|
||||||
|
|
||||||
public class EncryptingSmsDatabase extends SmsDatabase {
|
public class EncryptingSmsDatabase extends SmsDatabase {
|
||||||
|
|
||||||
public EncryptingSmsDatabase(Context context, SQLiteOpenHelper databaseHelper) {
|
public EncryptingSmsDatabase(Context context, SQLiteOpenHelper databaseHelper) {
|
||||||
|
@ -16,11 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
import ws.com.google.android.mms.pdu.CharacterSets;
|
|
||||||
import ws.com.google.android.mms.pdu.EncodedStringValue;
|
|
||||||
import ws.com.google.android.mms.pdu.PduHeaders;
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@ -28,13 +23,19 @@ import android.database.sqlite.SQLiteDatabase;
|
|||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import ws.com.google.android.mms.pdu.CharacterSets;
|
||||||
|
import ws.com.google.android.mms.pdu.EncodedStringValue;
|
||||||
|
import ws.com.google.android.mms.pdu.PduHeaders;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
public class MmsAddressDatabase extends Database {
|
public class MmsAddressDatabase extends Database {
|
||||||
|
|
||||||
private static final String TABLE_NAME = "mms_addresses";
|
private static final String TABLE_NAME = "mms_addresses";
|
||||||
private static final String ID = "_id";
|
private static final String ID = "_id";
|
||||||
private static final String MMS_ID = "mms_id";
|
private static final String MMS_ID = "mms_id";
|
||||||
private static final String TYPE = "type";
|
private static final String TYPE = "type";
|
||||||
private static final String ADDRESS = "address";
|
private static final String ADDRESS = "address";
|
||||||
private static final String ADDRESS_CHARSET = "address_charset";
|
private static final String ADDRESS_CHARSET = "address_charset";
|
||||||
|
|
||||||
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" + ID + " INTEGER PRIMARY KEY, " +
|
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" + ID + " INTEGER PRIMARY KEY, " +
|
||||||
@ -97,7 +98,7 @@ public class MmsAddressDatabase extends Database {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +121,6 @@ public class MmsAddressDatabase extends Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String toIsoString(byte[] bytes) {
|
private String toIsoString(byte[] bytes) {
|
||||||
try {
|
try {
|
||||||
return new String(bytes, CharacterSets.MIMENAME_ISO_8859_1);
|
return new String(bytes, CharacterSets.MIMENAME_ISO_8859_1);
|
||||||
@ -129,7 +129,4 @@ public class MmsAddressDatabase extends Database {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -268,11 +268,11 @@ public class MmsDatabase extends Database {
|
|||||||
|
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
long messageId = cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
long messageId = cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
||||||
long outboxType = cursor.getLong(cursor.getColumnIndexOrThrow(MESSAGE_BOX));
|
long outboxType = cursor.getLong(cursor.getColumnIndexOrThrow(MESSAGE_BOX));
|
||||||
PduHeaders headers = getHeadersFromCursor(cursor);
|
PduHeaders headers = getHeadersFromCursor(cursor);
|
||||||
addr.getAddressesForId(messageId, headers);
|
addr.getAddressesForId(messageId, headers);
|
||||||
PduBody body = parts.getParts(messageId, true);
|
PduBody body = parts.getParts(messageId, true);
|
||||||
requests[i++] = new SendReq(headers, body, messageId, outboxType);
|
requests[i++] = new SendReq(headers, body, messageId, outboxType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requests;
|
return requests;
|
||||||
@ -342,7 +342,7 @@ public class MmsDatabase extends Database {
|
|||||||
ContentValues contentValues = getContentValuesFromHeader(headers);
|
ContentValues contentValues = getContentValuesFromHeader(headers);
|
||||||
|
|
||||||
if (!isSecure) contentValues.put(MESSAGE_BOX, Types.MESSAGE_BOX_OUTBOX);
|
if (!isSecure) contentValues.put(MESSAGE_BOX, Types.MESSAGE_BOX_OUTBOX);
|
||||||
else contentValues.put(MESSAGE_BOX, Types.MESSAGE_BOX_SECURE_OUTBOX);
|
else contentValues.put(MESSAGE_BOX, Types.MESSAGE_BOX_SECURE_OUTBOX);
|
||||||
|
|
||||||
contentValues.put(THREAD_ID, threadId);
|
contentValues.put(THREAD_ID, threadId);
|
||||||
contentValues.put(READ, 1);
|
contentValues.put(READ, 1);
|
||||||
@ -412,7 +412,6 @@ public class MmsDatabase extends Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void deleteAllThreads() {
|
public void deleteAllThreads() {
|
||||||
DatabaseFactory.getPartDatabase(context).deleteAllParts();
|
DatabaseFactory.getPartDatabase(context).deleteAllParts();
|
||||||
DatabaseFactory.getMmsAddressDatabase(context).deleteAllAddresses();
|
DatabaseFactory.getMmsAddressDatabase(context).deleteAllAddresses();
|
||||||
@ -448,7 +447,7 @@ public class MmsDatabase extends Database {
|
|||||||
return headers;
|
return headers;
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,9 +534,8 @@ public class MmsDatabase extends Database {
|
|||||||
public static final int DOWNLOAD_INITIALIZED = 1;
|
public static final int DOWNLOAD_INITIALIZED = 1;
|
||||||
public static final int DOWNLOAD_NO_CONNECTIVITY = 2;
|
public static final int DOWNLOAD_NO_CONNECTIVITY = 2;
|
||||||
public static final int DOWNLOAD_CONNECTING = 3;
|
public static final int DOWNLOAD_CONNECTING = 3;
|
||||||
public static final int DOWNLOAD_SOFT_FAILURE = 4;
|
public static final int DOWNLOAD_SOFT_FAILURE = 4;
|
||||||
public static final int DOWNLOAD_HARD_FAILURE = 5;
|
public static final int DOWNLOAD_HARD_FAILURE = 5;
|
||||||
|
|
||||||
|
|
||||||
public static boolean isSecureMmsBox(long mailbox) {
|
public static boolean isSecureMmsBox(long mailbox) {
|
||||||
return mailbox == Types.MESSAGE_BOX_SECURE_OUTBOX || mailbox == Types.MESSAGE_BOX_SECURE_SENT || mailbox == Types.MESSAGE_BOX_SECURE_INBOX;
|
return mailbox == Types.MESSAGE_BOX_SECURE_OUTBOX || mailbox == Types.MESSAGE_BOX_SECURE_SENT || mailbox == Types.MESSAGE_BOX_SECURE_INBOX;
|
||||||
@ -574,9 +572,5 @@ public class MmsDatabase extends Database {
|
|||||||
public static boolean isHardError(int status) {
|
public static boolean isHardError(int status) {
|
||||||
return status == DOWNLOAD_HARD_FAILURE;
|
return status == DOWNLOAD_HARD_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
@ -26,6 +23,9 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||||||
import android.database.sqlite.SQLiteQueryBuilder;
|
import android.database.sqlite.SQLiteQueryBuilder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MmsSmsDatabase extends Database {
|
public class MmsSmsDatabase extends Database {
|
||||||
|
|
||||||
public static final String TRANSPORT = "transport_type";
|
public static final String TRANSPORT = "transport_type";
|
||||||
|
@ -16,14 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import android.content.ContentUris;
|
||||||
import java.io.File;
|
import android.content.ContentValues;
|
||||||
import java.io.FileInputStream;
|
import android.content.Context;
|
||||||
import java.io.FileNotFoundException;
|
import android.database.Cursor;
|
||||||
import java.io.FileOutputStream;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import java.io.IOException;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import java.io.InputStream;
|
import android.util.Log;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.providers.PartProvider;
|
import org.thoughtcrime.securesms.providers.PartProvider;
|
||||||
|
|
||||||
@ -32,13 +31,15 @@ import ws.com.google.android.mms.MmsException;
|
|||||||
import ws.com.google.android.mms.pdu.CharacterSets;
|
import ws.com.google.android.mms.pdu.CharacterSets;
|
||||||
import ws.com.google.android.mms.pdu.PduBody;
|
import ws.com.google.android.mms.pdu.PduBody;
|
||||||
import ws.com.google.android.mms.pdu.PduPart;
|
import ws.com.google.android.mms.pdu.PduPart;
|
||||||
import android.content.ContentUris;
|
|
||||||
import android.content.ContentValues;
|
import java.io.ByteArrayOutputStream;
|
||||||
import android.content.Context;
|
import java.io.File;
|
||||||
import android.database.Cursor;
|
import java.io.FileInputStream;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import java.io.FileNotFoundException;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import java.io.FileOutputStream;
|
||||||
import android.util.Log;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
public class PartDatabase extends Database {
|
public class PartDatabase extends Database {
|
||||||
|
|
||||||
@ -123,7 +124,7 @@ public class PartDatabase extends Database {
|
|||||||
contentValues.put(CONTENT_TYPE, toIsoString(part.getContentType()));
|
contentValues.put(CONTENT_TYPE, toIsoString(part.getContentType()));
|
||||||
|
|
||||||
if (toIsoString(part.getContentType()).equals(ContentType.APP_SMIL))
|
if (toIsoString(part.getContentType()).equals(ContentType.APP_SMIL))
|
||||||
contentValues.put(SEQUENCE, -1);
|
contentValues.put(SEQUENCE, -1);
|
||||||
} else {
|
} else {
|
||||||
throw new MmsException("There is no content type for this part.");
|
throw new MmsException("There is no content type for this part.");
|
||||||
}
|
}
|
||||||
@ -172,7 +173,7 @@ public class PartDatabase extends Database {
|
|||||||
int read;
|
int read;
|
||||||
|
|
||||||
while ((read = fin.read(buffer)) != -1)
|
while ((read = fin.read(buffer)) != -1)
|
||||||
baos.write(buffer, 0, read);
|
baos.write(buffer, 0, read);
|
||||||
|
|
||||||
part.setData(baos.toByteArray());
|
part.setData(baos.toByteArray());
|
||||||
fin.close();
|
fin.close();
|
||||||
@ -189,23 +190,23 @@ public class PartDatabase extends Database {
|
|||||||
FileOutputStream fout = getPartOutputStream(dataFile, part);
|
FileOutputStream fout = getPartOutputStream(dataFile, part);
|
||||||
|
|
||||||
if (part.getData() != null) {
|
if (part.getData() != null) {
|
||||||
Log.w("PartDatabase", "Writing part data from buffer");
|
Log.w("PartDatabase", "Writing part data from buffer");
|
||||||
fout.write(part.getData());
|
fout.write(part.getData());
|
||||||
fout.close();
|
fout.close();
|
||||||
return dataFile;
|
return dataFile;
|
||||||
} else if (part.getDataUri() != null) {
|
} else if (part.getDataUri() != null) {
|
||||||
Log.w("PartDatabase", "Writing part dat from URI");
|
Log.w("PartDatabase", "Writing part dat from URI");
|
||||||
byte[] buf = new byte[512];
|
byte[] buf = new byte[512];
|
||||||
InputStream in = context.getContentResolver().openInputStream(part.getDataUri());
|
InputStream in = context.getContentResolver().openInputStream(part.getDataUri());
|
||||||
int read;
|
int read;
|
||||||
while ((read = in.read(buf)) != -1)
|
while ((read = in.read(buf)) != -1)
|
||||||
fout.write(buf, 0, read);
|
fout.write(buf, 0, read);
|
||||||
|
|
||||||
fout.close();
|
fout.close();
|
||||||
in.close();
|
in.close();
|
||||||
return dataFile;
|
return dataFile;
|
||||||
} else {
|
} else {
|
||||||
throw new MmsException("Part is empty!");
|
throw new MmsException("Part is empty!");
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
@ -249,16 +250,16 @@ public class PartDatabase extends Database {
|
|||||||
cursor = database.query(TABLE_NAME, new String[]{DATA, ENCRYPTED}, ID_WHERE, new String[] {partId+""}, null, null, null);
|
cursor = database.query(TABLE_NAME, new String[]{DATA, ENCRYPTED}, ID_WHERE, new String[] {partId+""}, null, null, null);
|
||||||
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
PduPart part = new PduPart();
|
PduPart part = new PduPart();
|
||||||
part.setEncrypted(cursor.getInt(1) == 1);
|
part.setEncrypted(cursor.getInt(1) == 1);
|
||||||
|
|
||||||
return getPartInputStream(new File(cursor.getString(0)), part);
|
return getPartInputStream(new File(cursor.getString(0)), part);
|
||||||
} else {
|
} else {
|
||||||
throw new FileNotFoundException("No part for id: " + partId);
|
throw new FileNotFoundException("No part for id: " + partId);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,12 +278,12 @@ public class PartDatabase extends Database {
|
|||||||
cursor = database.query(TABLE_NAME, null, ID_WHERE, new String[] {partId+""}, null, null, null);
|
cursor = database.query(TABLE_NAME, null, ID_WHERE, new String[] {partId+""}, null, null, null);
|
||||||
|
|
||||||
if (cursor != null && cursor.moveToFirst())
|
if (cursor != null && cursor.moveToFirst())
|
||||||
return getPart(cursor, includeData);
|
return getPart(cursor, includeData);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,14 +296,14 @@ public class PartDatabase extends Database {
|
|||||||
cursor = database.query(TABLE_NAME, null, MMS_ID + " = ?", new String[] {mmsId+""}, null, null, null);
|
cursor = database.query(TABLE_NAME, null, MMS_ID + " = ?", new String[] {mmsId+""}, null, null, null);
|
||||||
|
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
PduPart part = getPart(cursor, includeData);
|
PduPart part = getPart(cursor, includeData);
|
||||||
body.addPart(part);
|
body.addPart(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
return body;
|
return body;
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,11 +315,11 @@ public class PartDatabase extends Database {
|
|||||||
cursor = database.query(TABLE_NAME, new String[] {DATA}, MMS_ID + " = ?", new String[] {mmsId+""}, null, null, null);
|
cursor = database.query(TABLE_NAME, new String[] {DATA}, MMS_ID + " = ?", new String[] {mmsId+""}, null, null, null);
|
||||||
|
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
new File(cursor.getString(0)).delete();
|
new File(cursor.getString(0)).delete();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
database.delete(TABLE_NAME, MMS_ID + " = ?", new String[] {mmsId+""});
|
database.delete(TABLE_NAME, MMS_ID + " = ?", new String[] {mmsId+""});
|
||||||
@ -354,7 +355,4 @@ public class PartDatabase extends Database {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import android.database.Cursor;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import ws.com.google.android.mms.InvalidHeaderValueException;
|
import ws.com.google.android.mms.InvalidHeaderValueException;
|
||||||
import ws.com.google.android.mms.pdu.CharacterSets;
|
import ws.com.google.android.mms.pdu.CharacterSets;
|
||||||
import ws.com.google.android.mms.pdu.EncodedStringValue;
|
import ws.com.google.android.mms.pdu.EncodedStringValue;
|
||||||
import ws.com.google.android.mms.pdu.PduHeaders;
|
import ws.com.google.android.mms.pdu.PduHeaders;
|
||||||
import android.database.Cursor;
|
|
||||||
import android.util.Log;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
public class PduHeadersBuilder {
|
public class PduHeadersBuilder {
|
||||||
|
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.util.Conversions;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -24,10 +28,6 @@ import java.io.RandomAccessFile;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.util.Conversions;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
public abstract class Record {
|
public abstract class Record {
|
||||||
|
|
||||||
protected final String address;
|
protected final String address;
|
||||||
|
@ -16,19 +16,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import android.content.Context;
|
||||||
import java.io.FileNotFoundException;
|
import android.util.Log;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.RandomAccessFile;
|
|
||||||
import java.nio.channels.FileChannel;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.InvalidKeyException;
|
import org.thoughtcrime.securesms.crypto.InvalidKeyException;
|
||||||
import org.thoughtcrime.securesms.crypto.PublicKey;
|
import org.thoughtcrime.securesms.crypto.PublicKey;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.Hex;
|
import org.thoughtcrime.securesms.util.Hex;
|
||||||
|
|
||||||
import android.content.Context;
|
import java.io.FileInputStream;
|
||||||
import android.util.Log;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.RandomAccessFile;
|
||||||
|
import java.nio.channels.FileChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the current and last public key belonging to the "remote"
|
* Represents the current and last public key belonging to the "remote"
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.database;
|
package org.thoughtcrime.securesms.database;
|
||||||
|
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.crypto.SessionCipher;
|
import org.thoughtcrime.securesms.crypto.SessionCipher;
|
||||||
import org.thoughtcrime.securesms.util.Conversions;
|
import org.thoughtcrime.securesms.util.Conversions;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the currently negotiated session key for a given
|
* Represents the currently negotiated session key for a given
|
||||||
* local key id and remote key id. This is stored encrypted on
|
* local key id and remote key id. This is stored encrypted on
|
||||||
|
@ -208,8 +208,8 @@ public class SessionRecord extends Record {
|
|||||||
Log.w("SessionRecord", "No session information found.");
|
Log.w("SessionRecord", "No session information found.");
|
||||||
return;
|
return;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.w("keyrecord", ioe);
|
Log.w("keyrecord", ioe);
|
||||||
// XXX
|
// XXX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,5 +223,4 @@ public class SessionRecord extends Record {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -117,12 +117,12 @@ public class SmsDatabase extends Database {
|
|||||||
try {
|
try {
|
||||||
cursor = db.rawQuery(sql, sqlArgs);
|
cursor = db.rawQuery(sql, sqlArgs);
|
||||||
if (cursor != null && cursor.moveToFirst())
|
if (cursor != null && cursor.moveToFirst())
|
||||||
return cursor.getLong(0);
|
return cursor.getLong(0);
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,10 +134,10 @@ public class SmsDatabase extends Database {
|
|||||||
cursor = db.query(TABLE_NAME, new String[] {"COUNT(*)"}, THREAD_ID + " = ?", new String[] {threadId+""}, null, null, null);
|
cursor = db.query(TABLE_NAME, new String[] {"COUNT(*)"}, THREAD_ID + " = ?", new String[] {threadId+""}, null, null, null);
|
||||||
|
|
||||||
if (cursor != null && cursor.moveToFirst())
|
if (cursor != null && cursor.moveToFirst())
|
||||||
return cursor.getInt(0);
|
return cursor.getInt(0);
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -201,7 +201,7 @@ public class SmsDatabase extends Database {
|
|||||||
|
|
||||||
public long insertMessageSent(String address, long threadId, String body, long date, long type) {
|
public long insertMessageSent(String address, long threadId, String body, long date, long type) {
|
||||||
ContentValues contentValues = new ContentValues(6);
|
ContentValues contentValues = new ContentValues(6);
|
||||||
// contentValues.put(ADDRESS, NumberUtil.filterNumber(address));
|
// contentValues.put(ADDRESS, NumberUtil.filterNumber(address));
|
||||||
contentValues.put(ADDRESS, address);
|
contentValues.put(ADDRESS, address);
|
||||||
contentValues.put(THREAD_ID, threadId);
|
contentValues.put(THREAD_ID, threadId);
|
||||||
contentValues.put(BODY, body);
|
contentValues.put(BODY, body);
|
||||||
@ -292,7 +292,7 @@ public class SmsDatabase extends Database {
|
|||||||
|
|
||||||
/*package*/ SQLiteStatement createInsertStatement(SQLiteDatabase database) {
|
/*package*/ SQLiteStatement createInsertStatement(SQLiteDatabase database) {
|
||||||
return database.compileStatement("INSERT INTO " + TABLE_NAME + " (" + ADDRESS + ", " + PERSON + ", " + DATE + ", " + PROTOCOL + ", " + READ + ", " + STATUS + ", " + TYPE + ", " + REPLY_PATH_PRESENT + ", " + SUBJECT + ", " + BODY + ", " + SERVICE_CENTER + ", THREAD_ID) " +
|
return database.compileStatement("INSERT INTO " + TABLE_NAME + " (" + ADDRESS + ", " + PERSON + ", " + DATE + ", " + PROTOCOL + ", " + READ + ", " + STATUS + ", " + TYPE + ", " + REPLY_PATH_PRESENT + ", " + SUBJECT + ", " + BODY + ", " + SERVICE_CENTER + ", THREAD_ID) " +
|
||||||
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Types {
|
public static class Types {
|
||||||
|
@ -54,13 +54,12 @@ public class ThreadDatabase extends Database {
|
|||||||
super(context, databaseHelper);
|
super(context, databaseHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private long[] getRecipientIds(Recipients recipients) {
|
private long[] getRecipientIds(Recipients recipients) {
|
||||||
Set<Long> recipientSet = new HashSet<Long>();
|
Set<Long> recipientSet = new HashSet<Long>();
|
||||||
List<Recipient> recipientList = recipients.getRecipientsList();
|
List<Recipient> recipientList = recipients.getRecipientsList();
|
||||||
|
|
||||||
for (Recipient recipient : recipientList) {
|
for (Recipient recipient : recipientList) {
|
||||||
// String number = NumberUtil.filterNumber(recipient.getNumber());
|
// String number = NumberUtil.filterNumber(recipient.getNumber());
|
||||||
String number = recipient.getNumber();
|
String number = recipient.getNumber();
|
||||||
recipientSet.add(Long.valueOf(DatabaseFactory.getAddressDatabase(context).getCanonicalAddress(number)));
|
recipientSet.add(Long.valueOf(DatabaseFactory.getAddressDatabase(context).getCanonicalAddress(number)));
|
||||||
}
|
}
|
||||||
@ -229,12 +228,12 @@ public class ThreadDatabase extends Database {
|
|||||||
cursor = db.query(TABLE_NAME, new String[]{ID}, where, recipientsArg, null, null, null);
|
cursor = db.query(TABLE_NAME, new String[]{ID}, where, recipientsArg, null, null, null);
|
||||||
|
|
||||||
if (cursor != null && cursor.moveToFirst())
|
if (cursor != null && cursor.moveToFirst())
|
||||||
return cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
return cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
||||||
else
|
else
|
||||||
return -1L;
|
return -1L;
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,12 +249,12 @@ public class ThreadDatabase extends Database {
|
|||||||
cursor = db.query(TABLE_NAME, new String[]{ID}, where, recipientsArg, null, null, null);
|
cursor = db.query(TABLE_NAME, new String[]{ID}, where, recipientsArg, null, null, null);
|
||||||
|
|
||||||
if (cursor != null && cursor.moveToFirst())
|
if (cursor != null && cursor.moveToFirst())
|
||||||
return cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
return cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
||||||
else
|
else
|
||||||
return createThreadForRecipients(recipientsList, recipientIds.length);
|
return createThreadForRecipients(recipientsList, recipientIds.length);
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,22 +272,18 @@ public class ThreadDatabase extends Database {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
cursor = mmsSmsDatabase.getConversationSnippet(threadId);
|
cursor = mmsSmsDatabase.getConversationSnippet(threadId);
|
||||||
if (cursor != null && cursor.moveToFirst())
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
updateThread(threadId, count,
|
updateThread(threadId, count,
|
||||||
cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.BODY)),
|
cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.BODY)),
|
||||||
cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.DATE)));
|
cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.DATE)));
|
||||||
else
|
} else {
|
||||||
deleteThread(threadId);
|
deleteThread(threadId);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyConversationListListeners();
|
notifyConversationListListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.protocol;
|
package org.thoughtcrime.securesms.protocol;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.InvalidKeyException;
|
import org.thoughtcrime.securesms.crypto.InvalidKeyException;
|
||||||
import org.thoughtcrime.securesms.crypto.InvalidMessageException;
|
import org.thoughtcrime.securesms.crypto.InvalidMessageException;
|
||||||
import org.thoughtcrime.securesms.crypto.PublicKey;
|
import org.thoughtcrime.securesms.crypto.PublicKey;
|
||||||
import org.thoughtcrime.securesms.util.Conversions;
|
import org.thoughtcrime.securesms.util.Conversions;
|
||||||
|
|
||||||
import android.util.Log;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses and serializes the encrypted message format.
|
* Parses and serializes the encrypted message format.
|
||||||
|
@ -31,6 +31,6 @@ public class Prefix {
|
|||||||
public static final String ASYMMETRIC_ENCRYPT = "?TextSecureAsymmetricEncrypt";
|
public static final String ASYMMETRIC_ENCRYPT = "?TextSecureAsymmetricEncrypt";
|
||||||
public static final String ASYMMETRIC_LOCAL_ENCRYPT = "?TextSecureAsymmetricLocalEncrypt";
|
public static final String ASYMMETRIC_LOCAL_ENCRYPT = "?TextSecureAsymmetricLocalEncrypt";
|
||||||
public static final String PROCESSED_KEY_EXCHANGE = "?TextSecureKeyExchangd";
|
public static final String PROCESSED_KEY_EXCHANGE = "?TextSecureKeyExchangd";
|
||||||
public static final String STALE_KEY_EXCHANGE = "?TextSecureKeyExchangs";
|
public static final String STALE_KEY_EXCHANGE = "?TextSecureKeyExchangs";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,16 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.providers;
|
package org.thoughtcrime.securesms.providers;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
||||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.ContentProvider;
|
import android.content.ContentProvider;
|
||||||
@ -41,6 +31,16 @@ import android.os.IBinder;
|
|||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
public class PartProvider extends ContentProvider {
|
public class PartProvider extends ContentProvider {
|
||||||
|
|
||||||
private static final String CONTENT_URI_STRING = "content://org.thoughtcrime.provider.securesms/part";
|
private static final String CONTENT_URI_STRING = "content://org.thoughtcrime.provider.securesms/part";
|
||||||
@ -58,7 +58,7 @@ public class PartProvider extends ContentProvider {
|
|||||||
private NewKeyReceiver receiver;
|
private NewKeyReceiver receiver;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
initializeMasterSecret();
|
initializeMasterSecret();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -95,14 +95,14 @@ public class PartProvider extends ContentProvider {
|
|||||||
case SINGLE_ROW:
|
case SINGLE_ROW:
|
||||||
Log.w("PartProvider", "Parting out a single row...");
|
Log.w("PartProvider", "Parting out a single row...");
|
||||||
try {
|
try {
|
||||||
int partId = Integer.parseInt(uri.getPathSegments().get(1));
|
int partId = Integer.parseInt(uri.getPathSegments().get(1));
|
||||||
File tmpFile = copyPartToTemporaryFile(masterSecret, partId);
|
File tmpFile = copyPartToTemporaryFile(masterSecret, partId);
|
||||||
ParcelFileDescriptor pdf = ParcelFileDescriptor.open(tmpFile, ParcelFileDescriptor.MODE_READ_ONLY);
|
ParcelFileDescriptor pdf = ParcelFileDescriptor.open(tmpFile, ParcelFileDescriptor.MODE_READ_ONLY);
|
||||||
tmpFile.delete();
|
tmpFile.delete();
|
||||||
return pdf;
|
return pdf;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.w("PartProvider", ioe);
|
Log.w("PartProvider", ioe);
|
||||||
throw new FileNotFoundException("Error opening file");
|
throw new FileNotFoundException("Error opening file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,31 +110,30 @@ public class PartProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int delete(Uri arg0, String arg1, String[] arg2) {
|
public int delete(Uri arg0, String arg1, String[] arg2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType(Uri arg0) {
|
public String getType(Uri arg0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Uri insert(Uri arg0, ContentValues arg1) {
|
public Uri insert(Uri arg0, ContentValues arg1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor query(Uri arg0, String[] arg1, String arg2, String[] arg3, String arg4) {
|
public Cursor query(Uri arg0, String[] arg1, String arg2, String[] arg3, String arg4) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3) {
|
public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initializeWithMasterSecret(MasterSecret masterSecret) {
|
private void initializeWithMasterSecret(MasterSecret masterSecret) {
|
||||||
Log.w("PartProvider", "Got master secret: " + masterSecret);
|
Log.w("PartProvider", "Got master secret: " + masterSecret);
|
||||||
this.masterSecret = masterSecret;
|
this.masterSecret = masterSecret;
|
||||||
@ -151,12 +150,12 @@ public class PartProvider extends ContentProvider {
|
|||||||
|
|
||||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
private ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||||
KeyCachingService keyCachingService = ((KeyCachingService.KeyCachingBinder)service).getService();
|
KeyCachingService keyCachingService = ((KeyCachingService.KeyCachingBinder)service).getService();
|
||||||
MasterSecret masterSecret = keyCachingService.getMasterSecret();
|
MasterSecret masterSecret = keyCachingService.getMasterSecret();
|
||||||
|
|
||||||
initializeWithMasterSecret(masterSecret);
|
initializeWithMasterSecret(masterSecret);
|
||||||
|
|
||||||
PartProvider.this.getContext().unbindService(this);
|
PartProvider.this.getContext().unbindService(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {}
|
public void onServiceDisconnected(ComponentName name) {}
|
||||||
@ -164,7 +163,7 @@ public class PartProvider extends ContentProvider {
|
|||||||
|
|
||||||
private class NewKeyReceiver extends BroadcastReceiver {
|
private class NewKeyReceiver extends BroadcastReceiver {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
Log.w("SendReceiveService", "Got a MasterSecret broadcast...");
|
Log.w("SendReceiveService", "Got a MasterSecret broadcast...");
|
||||||
initializeWithMasterSecret((MasterSecret)intent.getParcelableExtra("master_secret"));
|
initializeWithMasterSecret((MasterSecret)intent.getParcelableExtra("master_secret"));
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.recipients;
|
package org.thoughtcrime.securesms.recipients;
|
||||||
|
|
||||||
|
import android.telephony.PhoneNumberUtils;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import android.telephony.PhoneNumberUtils;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
public class RecipientsFormatter {
|
public class RecipientsFormatter {
|
||||||
|
|
||||||
private static String parseBracketedNumber(String recipient) throws RecipientFormattingException {
|
private static String parseBracketedNumber(String recipient) throws RecipientFormattingException {
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.util;
|
package org.thoughtcrime.securesms.util;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.sms.SmsTransportDetails;
|
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.sms.SmsTransportDetails;
|
||||||
|
|
||||||
public class EncryptedCharacterCalculator extends CharacterCalculator {
|
public class EncryptedCharacterCalculator extends CharacterCalculator {
|
||||||
|
|
||||||
private CharacterState calculateSingleRecordCharacters(int charactersSpent) {
|
private CharacterState calculateSingleRecordCharacters(int charactersSpent) {
|
||||||
@ -32,23 +32,23 @@ public class EncryptedCharacterCalculator extends CharacterCalculator {
|
|||||||
int charactersInFirstRecord = SmsTransportDetails.ENCRYPTED_SINGLE_MESSAGE_BODY_MAX_SIZE;
|
int charactersInFirstRecord = SmsTransportDetails.ENCRYPTED_SINGLE_MESSAGE_BODY_MAX_SIZE;
|
||||||
int spillover = charactersSpent - charactersInFirstRecord;
|
int spillover = charactersSpent - charactersInFirstRecord;
|
||||||
Log.w("EncryptedCharacterCalculator", "Spillover: " + spillover);
|
Log.w("EncryptedCharacterCalculator", "Spillover: " + spillover);
|
||||||
// int maxMultiMessageSize = SessionCipher.getMaxBodySizePerMultiMessage(charactersSpent);
|
// int maxMultiMessageSize = SessionCipher.getMaxBodySizePerMultiMessage(charactersSpent);
|
||||||
// Log.w("EncryptedCharacterCalculator", "Maxmultimessagesize: " + maxMultiMessageSize);
|
// Log.w("EncryptedCharacterCalculator", "Maxmultimessagesize: " + maxMultiMessageSize);
|
||||||
// int spilloverMessagesSpent = spillover / maxMultiMessageSize;
|
// int spilloverMessagesSpent = spillover / maxMultiMessageSize;
|
||||||
int spilloverMessagesSpent = spillover / SmsTransportDetails.MULTI_MESSAGE_MAX_BYTES;
|
int spilloverMessagesSpent = spillover / SmsTransportDetails.MULTI_MESSAGE_MAX_BYTES;
|
||||||
Log.w("EncryptedCharacterCalculator", "Spillover messaegs spent: " + spilloverMessagesSpent);
|
Log.w("EncryptedCharacterCalculator", "Spillover messaegs spent: " + spilloverMessagesSpent);
|
||||||
|
|
||||||
// if ((spillover % maxMultiMessageSize) > 0)
|
// if ((spillover % maxMultiMessageSize) > 0)
|
||||||
if ((spillover % SmsTransportDetails.MULTI_MESSAGE_MAX_BYTES) > 0)
|
if ((spillover % SmsTransportDetails.MULTI_MESSAGE_MAX_BYTES) > 0)
|
||||||
spilloverMessagesSpent++;
|
spilloverMessagesSpent++;
|
||||||
|
|
||||||
Log.w("EncryptedCharacterCalculator", "Spillover messaegs spent: " + spilloverMessagesSpent);
|
Log.w("EncryptedCharacterCalculator", "Spillover messaegs spent: " + spilloverMessagesSpent);
|
||||||
|
|
||||||
// int charactersRemaining = (maxMultiMessageSize * spilloverMessagesSpent) - spillover;
|
// int charactersRemaining = (maxMultiMessageSize * spilloverMessagesSpent) - spillover;
|
||||||
int charactersRemaining = (SmsTransportDetails.MULTI_MESSAGE_MAX_BYTES * spilloverMessagesSpent) - spillover;
|
int charactersRemaining = (SmsTransportDetails.MULTI_MESSAGE_MAX_BYTES * spilloverMessagesSpent) - spillover;
|
||||||
Log.w("EncryptedCharacterCalculator", "charactersRemaining: " + charactersRemaining);
|
Log.w("EncryptedCharacterCalculator", "charactersRemaining: " + charactersRemaining);
|
||||||
|
|
||||||
// return new CharacterState(spilloverMessagesSpent+1, charactersRemaining, maxMultiMessageSize);
|
// return new CharacterState(spilloverMessagesSpent+1, charactersRemaining, maxMultiMessageSize);
|
||||||
return new CharacterState(spilloverMessagesSpent+1, charactersRemaining, SmsTransportDetails.MULTI_MESSAGE_MAX_BYTES);
|
return new CharacterState(spilloverMessagesSpent+1, charactersRemaining, SmsTransportDetails.MULTI_MESSAGE_MAX_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,12 +78,12 @@ public class Hex {
|
|||||||
int idx = i + lineOffset;
|
int idx = i + lineOffset;
|
||||||
if (i < lineLength) {
|
if (i < lineLength) {
|
||||||
int b = bytes[idx];
|
int b = bytes[idx];
|
||||||
appendHexChar(buf, b);
|
appendHexChar(buf, b);
|
||||||
} else {
|
} else {
|
||||||
buf.append(" ");
|
buf.append(" ");
|
||||||
}
|
}
|
||||||
if ((i % 2) == 1) {
|
if ((i % 2) == 1) {
|
||||||
buf.append(' ');
|
buf.append(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.util;
|
package org.thoughtcrime.securesms.util;
|
||||||
|
|
||||||
|
import android.telephony.PhoneNumberUtils;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import android.telephony.PhoneNumberUtils;
|
|
||||||
|
|
||||||
public class NumberUtil {
|
public class NumberUtil {
|
||||||
|
|
||||||
private static final Pattern emailPattern = android.util.Patterns.EMAIL_ADDRESS;
|
private static final Pattern emailPattern = android.util.Patterns.EMAIL_ADDRESS;
|
||||||
@ -44,10 +44,9 @@ public class NumberUtil {
|
|||||||
char character = number.charAt(i);
|
char character = number.charAt(i);
|
||||||
|
|
||||||
if (Character.isDigit(character) || character == '+')
|
if (Character.isDigit(character) || character == '+')
|
||||||
builder.append(character);
|
builder.append(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,28 +62,28 @@ public class Util {
|
|||||||
return splitString;
|
return splitString;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static Bitmap loadScaledBitmap(InputStream src, int targetWidth, int targetHeight) {
|
// public static Bitmap loadScaledBitmap(InputStream src, int targetWidth, int targetHeight) {
|
||||||
// return BitmapFactory.decodeStream(src);
|
// return BitmapFactory.decodeStream(src);
|
||||||
//// BitmapFactory.Options options = new BitmapFactory.Options();
|
//// BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
//// options.inJustDecodeBounds = true;
|
//// options.inJustDecodeBounds = true;
|
||||||
//// BitmapFactory.decodeStream(src, null, options);
|
//// BitmapFactory.decodeStream(src, null, options);
|
||||||
////
|
////
|
||||||
//// Log.w("Util", "Bitmap Origin Width: " + options.outWidth);
|
//// Log.w("Util", "Bitmap Origin Width: " + options.outWidth);
|
||||||
//// Log.w("Util", "Bitmap Origin Height: " + options.outHeight);
|
//// Log.w("Util", "Bitmap Origin Height: " + options.outHeight);
|
||||||
////
|
////
|
||||||
//// boolean scaleByHeight =
|
//// boolean scaleByHeight =
|
||||||
//// Math.abs(options.outHeight - targetHeight) >=
|
//// Math.abs(options.outHeight - targetHeight) >=
|
||||||
//// Math.abs(options.outWidth - targetWidth);
|
//// Math.abs(options.outWidth - targetWidth);
|
||||||
////
|
////
|
||||||
//// if (options.outHeight * options.outWidth >= targetWidth * targetHeight * 2) {
|
//// if (options.outHeight * options.outWidth >= targetWidth * targetHeight * 2) {
|
||||||
//// double sampleSize = scaleByHeight ? (double)options.outHeight / (double)targetHeight : (double)options.outWidth / (double)targetWidth;
|
//// double sampleSize = scaleByHeight ? (double)options.outHeight / (double)targetHeight : (double)options.outWidth / (double)targetWidth;
|
||||||
////// options.inSampleSize = (int)Math.pow(2d, Math.floor(Math.log(sampleSize) / Math.log(2d)));
|
////// options.inSampleSize = (int)Math.pow(2d, Math.floor(Math.log(sampleSize) / Math.log(2d)));
|
||||||
//// Log.w("Util", "Sampling by: " + options.inSampleSize);
|
//// Log.w("Util", "Sampling by: " + options.inSampleSize);
|
||||||
//// }
|
//// }
|
||||||
////
|
////
|
||||||
//// options.inJustDecodeBounds = false;
|
//// options.inJustDecodeBounds = false;
|
||||||
////
|
////
|
||||||
//// return BitmapFactory.decodeStream(src, null, options);
|
//// return BitmapFactory.decodeStream(src, null, options);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,16 +30,17 @@ public class WorkerThread extends Thread {
|
|||||||
private Runnable getWork() {
|
private Runnable getWork() {
|
||||||
synchronized (workQueue) {
|
synchronized (workQueue) {
|
||||||
try {
|
try {
|
||||||
while (workQueue.isEmpty())
|
while (workQueue.isEmpty())
|
||||||
workQueue.wait();
|
workQueue.wait();
|
||||||
|
|
||||||
return workQueue.remove(0);
|
return workQueue.remove(0);
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
throw new AssertionError(ie);
|
throw new AssertionError(ie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (;;)
|
for (;;)
|
||||||
getWork().run();
|
getWork().run();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user