Removed tabs

This commit is contained in:
Moxie Marlinspike 2012-09-30 19:56:29 -07:00
parent 030b39cd9c
commit 82f8ba3584
35 changed files with 635 additions and 649 deletions

View File

@ -36,6 +36,7 @@ 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;

View File

@ -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 {

View File

@ -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 = ?";

View File

@ -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();
@ -154,6 +155,5 @@ public class DatabaseFactory {
if (oldVersion < INTRODUCED_IDENTITIES_VERSION) if (oldVersion < INTRODUCED_IDENTITIES_VERSION)
db.execSQL(IdentityDatabase.CREATE_TABLE); db.execSQL(IdentityDatabase.CREATE_TABLE);
} }
} }
} }

View File

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

View File

@ -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 {

View File

@ -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) {

View File

@ -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,6 +23,12 @@ 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";
@ -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 "";
} }
} }
} }

View File

@ -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();
@ -538,7 +537,6 @@ public class MmsDatabase extends Database {
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;
} }
} }
} }

View File

@ -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";

View File

@ -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 {
@ -354,7 +355,4 @@ public class PartDatabase extends Database {
return ""; return "";
} }
} }
} }

View File

@ -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 {

View File

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

View File

@ -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"

View File

@ -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

View File

@ -223,5 +223,4 @@ public class SessionRecord extends Record {
return null; return null;
} }
} }

View File

@ -54,7 +54,6 @@ 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();
@ -273,12 +272,13 @@ 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();
@ -286,9 +286,4 @@ public class ThreadDatabase extends Database {
notifyConversationListListeners(); notifyConversationListListeners();
} }
} }

View File

@ -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.

View File

@ -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";
@ -134,7 +134,6 @@ public class PartProvider extends ContentProvider {
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;

View File

@ -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 {

View File

@ -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) {

View File

@ -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;
@ -49,5 +49,4 @@ public class NumberUtil {
return builder.toString(); return builder.toString();
} }
} }

View File

@ -40,6 +40,7 @@ public class WorkerThread extends Thread {
} }
} }
@Override
public void run() { public void run() {
for (;;) for (;;)
getWork().run(); getWork().run();