diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java
index ac61af945..46f5c5d62 100644
--- a/src/com/fsck/k9/Account.java
+++ b/src/com/fsck/k9/Account.java
@@ -29,11 +29,12 @@ import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Store;
import com.fsck.k9.mail.Folder.FolderClass;
+import com.fsck.k9.mail.filter.Base64;
import com.fsck.k9.mail.store.RemoteStore;
import com.fsck.k9.mail.store.StoreConfig;
-import com.fsck.k9.mail.store.StorageManager;
-import com.fsck.k9.mail.store.StorageManager.StorageProvider;
-import com.fsck.k9.mail.store.local.LocalStore;
+import com.fsck.k9.local.StorageManager;
+import com.fsck.k9.local.StorageManager.StorageProvider;
+import com.fsck.k9.local.LocalStore;
import com.fsck.k9.provider.EmailProvider;
import com.fsck.k9.provider.EmailProvider.StatsColumns;
import com.fsck.k9.search.ConditionsTreeNode;
@@ -42,7 +43,7 @@ import com.fsck.k9.search.SqlQueryBuilder;
import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchCondition;
import com.fsck.k9.search.SearchSpecification.Searchfield;
-import com.fsck.k9.security.LocalKeyStore;
+import com.fsck.k9.mail.ssl.LocalKeyStore;
import com.fsck.k9.view.ColorChip;
import com.larswerkman.colorpicker.ColorPicker;
@@ -363,9 +364,9 @@ public class Account implements BaseAccount, StoreConfig {
SharedPreferences prefs = preferences.getPreferences();
- mStoreUri = Utility.base64Decode(prefs.getString(mUuid + ".storeUri", null));
+ mStoreUri = Base64.decode(prefs.getString(mUuid + ".storeUri", null));
mLocalStorageProviderId = prefs.getString(mUuid + ".localStorageProvider", StorageManager.getInstance(K9.app).getDefaultProviderId());
- mTransportUri = Utility.base64Decode(prefs.getString(mUuid + ".transportUri", null));
+ mTransportUri = Base64.decode(prefs.getString(mUuid + ".transportUri", null));
mDescription = prefs.getString(mUuid + ".description", null);
mAlwaysBcc = prefs.getString(mUuid + ".alwaysBcc", mAlwaysBcc);
mAutomaticCheckIntervalMinutes = prefs.getInt(mUuid + ".automaticCheckIntervalMinutes", -1);
@@ -691,9 +692,9 @@ public class Account implements BaseAccount, StoreConfig {
editor.putString("accountUuids", accountUuids);
}
- editor.putString(mUuid + ".storeUri", Utility.base64Encode(mStoreUri));
+ editor.putString(mUuid + ".storeUri", Base64.encode(mStoreUri));
editor.putString(mUuid + ".localStorageProvider", mLocalStorageProviderId);
- editor.putString(mUuid + ".transportUri", Utility.base64Encode(mTransportUri));
+ editor.putString(mUuid + ".transportUri", Base64.encode(mTransportUri));
editor.putString(mUuid + ".description", mDescription);
editor.putString(mUuid + ".alwaysBcc", mAlwaysBcc);
editor.putInt(mUuid + ".automaticCheckIntervalMinutes", mAutomaticCheckIntervalMinutes);
diff --git a/src/com/fsck/k9/EmailAddressValidator.java b/src/com/fsck/k9/EmailAddressValidator.java
index 957a1384b..211d99220 100644
--- a/src/com/fsck/k9/EmailAddressValidator.java
+++ b/src/com/fsck/k9/EmailAddressValidator.java
@@ -4,7 +4,19 @@ package com.fsck.k9;
import android.text.util.Rfc822Tokenizer;
import android.widget.AutoCompleteTextView.Validator;
+import java.util.regex.Pattern;
+
public class EmailAddressValidator implements Validator {
+ private static final Pattern EMAIL_ADDRESS_PATTERN = Pattern.compile(
+ "[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" +
+ "\\@" +
+ "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +
+ "(" +
+ "\\." +
+ "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +
+ ")+"
+ );
+
public CharSequence fixText(CharSequence invalidText) {
return "";
}
@@ -14,6 +26,6 @@ public class EmailAddressValidator implements Validator {
}
public boolean isValidAddressOnly(CharSequence text) {
- return com.fsck.k9.helper.Regex.EMAIL_ADDRESS_PATTERN.matcher(text).matches();
+ return EMAIL_ADDRESS_PATTERN.matcher(text).matches();
}
}
diff --git a/src/com/fsck/k9/K9.java b/src/com/fsck/k9/K9.java
index 08c49c5ed..7e062d5f9 100644
--- a/src/com/fsck/k9/K9.java
+++ b/src/com/fsck/k9/K9.java
@@ -36,9 +36,9 @@ import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.BinaryTempFileBody;
-import com.fsck.k9.mail.store.local.LocalStore;
+import com.fsck.k9.local.LocalStore;
import com.fsck.k9.provider.UnreadWidgetProvider;
-import com.fsck.k9.security.LocalKeyStore;
+import com.fsck.k9.mail.ssl.LocalKeyStore;
import com.fsck.k9.service.BootReceiver;
import com.fsck.k9.service.MailService;
import com.fsck.k9.service.ShutdownReceiver;
diff --git a/src/com/fsck/k9/Preferences.java b/src/com/fsck/k9/Preferences.java
index 04754af97..a5c0cd4bc 100644
--- a/src/com/fsck/k9/Preferences.java
+++ b/src/com/fsck/k9/Preferences.java
@@ -13,7 +13,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
-import com.fsck.k9.mail.store.local.LocalStore;
+import com.fsck.k9.local.LocalStore;
import com.fsck.k9.preferences.Editor;
import com.fsck.k9.preferences.Storage;
diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java
index 5b7a757ae..c2a0ec21b 100644
--- a/src/com/fsck/k9/activity/Accounts.java
+++ b/src/com/fsck/k9/activity/Accounts.java
@@ -80,7 +80,7 @@ import com.fsck.k9.mail.ServerSettings;
import com.fsck.k9.mail.Transport;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.store.RemoteStore;
-import com.fsck.k9.mail.store.StorageManager;
+import com.fsck.k9.local.StorageManager;
import com.fsck.k9.mail.store.WebDavStore;
import com.fsck.k9.preferences.SettingsExporter;
import com.fsck.k9.preferences.SettingsImportExportException;
diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java
index 2316b364f..d1d7c17e4 100644
--- a/src/com/fsck/k9/activity/FolderList.java
+++ b/src/com/fsck/k9/activity/FolderList.java
@@ -55,8 +55,7 @@ import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;
-import com.fsck.k9.mail.MessagingException;
-import com.fsck.k9.mail.store.local.LocalFolder;
+import com.fsck.k9.local.LocalFolder;
import com.fsck.k9.search.LocalSearch;
import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.Searchfield;
diff --git a/src/com/fsck/k9/activity/MessageCompose.java b/src/com/fsck/k9/activity/MessageCompose.java
index 076ee4fa6..d9f489052 100644
--- a/src/com/fsck/k9/activity/MessageCompose.java
+++ b/src/com/fsck/k9/activity/MessageCompose.java
@@ -89,6 +89,7 @@ import com.fsck.k9.crypto.PgpData;
import com.fsck.k9.fragment.ProgressDialogFragment;
import com.fsck.k9.helper.ContactItem;
import com.fsck.k9.helper.Contacts;
+import com.fsck.k9.mail.filter.Base64;
import com.fsck.k9.mail.internet.HtmlConverter;
import com.fsck.k9.helper.IdentityHelper;
import com.fsck.k9.helper.Utility;
@@ -108,10 +109,10 @@ import com.fsck.k9.mail.internet.MimeMultipart;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.internet.TextBody;
import com.fsck.k9.mail.internet.TextBodyBuilder;
-import com.fsck.k9.mail.store.local.LocalAttachmentBody;
-import com.fsck.k9.mail.store.local.LocalMessage;
-import com.fsck.k9.mail.store.local.TempFileBody;
-import com.fsck.k9.mail.store.local.TempFileMessageBody;
+import com.fsck.k9.local.LocalAttachmentBody;
+import com.fsck.k9.local.LocalMessage;
+import com.fsck.k9.local.TempFileBody;
+import com.fsck.k9.local.TempFileMessageBody;
import com.fsck.k9.view.MessageWebView;
import org.apache.james.mime4j.codec.EncoderUtil;
@@ -1655,7 +1656,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
// First item is the body length. We use this to separate the composed reply from the quoted text.
if (tokenizer.hasMoreTokens()) {
- String bodyLengthS = Utility.base64Decode(tokenizer.nextToken());
+ String bodyLengthS = Base64.decode(tokenizer.nextToken());
try {
identity.put(IdentityField.LENGTH, Integer.valueOf(bodyLengthS).toString());
} catch (Exception e) {
@@ -1663,16 +1664,16 @@ public class MessageCompose extends K9Activity implements OnClickListener,
}
}
if (tokenizer.hasMoreTokens()) {
- identity.put(IdentityField.SIGNATURE, Utility.base64Decode(tokenizer.nextToken()));
+ identity.put(IdentityField.SIGNATURE, Base64.decode(tokenizer.nextToken()));
}
if (tokenizer.hasMoreTokens()) {
- identity.put(IdentityField.NAME, Utility.base64Decode(tokenizer.nextToken()));
+ identity.put(IdentityField.NAME, Base64.decode(tokenizer.nextToken()));
}
if (tokenizer.hasMoreTokens()) {
- identity.put(IdentityField.EMAIL, Utility.base64Decode(tokenizer.nextToken()));
+ identity.put(IdentityField.EMAIL, Base64.decode(tokenizer.nextToken()));
}
if (tokenizer.hasMoreTokens()) {
- identity.put(IdentityField.QUOTED_TEXT_MODE, Utility.base64Decode(tokenizer.nextToken()));
+ identity.put(IdentityField.QUOTED_TEXT_MODE, Base64.decode(tokenizer.nextToken()));
}
}
diff --git a/src/com/fsck/k9/activity/MessageInfoHolder.java b/src/com/fsck/k9/activity/MessageInfoHolder.java
index e217a0f78..379543525 100644
--- a/src/com/fsck/k9/activity/MessageInfoHolder.java
+++ b/src/com/fsck/k9/activity/MessageInfoHolder.java
@@ -1,8 +1,8 @@
package com.fsck.k9.activity;
import java.util.Date;
-import com.fsck.k9.mail.Message;
-import com.fsck.k9.mail.store.local.LocalMessage;
+
+import com.fsck.k9.local.LocalMessage;
public class MessageInfoHolder {
public String date;
diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java
index 604c1a166..ebfb3ef3b 100644
--- a/src/com/fsck/k9/activity/MessageList.java
+++ b/src/com/fsck/k9/activity/MessageList.java
@@ -42,8 +42,8 @@ import com.fsck.k9.fragment.MessageListFragment;
import com.fsck.k9.fragment.MessageListFragment.MessageListFragmentListener;
import com.fsck.k9.fragment.MessageViewFragment;
import com.fsck.k9.fragment.MessageViewFragment.MessageViewFragmentListener;
-import com.fsck.k9.mail.store.StorageManager;
-import com.fsck.k9.mail.store.local.LocalMessage;
+import com.fsck.k9.local.StorageManager;
+import com.fsck.k9.local.LocalMessage;
import com.fsck.k9.search.LocalSearch;
import com.fsck.k9.search.SearchAccount;
import com.fsck.k9.search.SearchSpecification;
diff --git a/src/com/fsck/k9/activity/MessageReference.java b/src/com/fsck/k9/activity/MessageReference.java
index bb2d6264d..0ba73a0c2 100644
--- a/src/com/fsck/k9/activity/MessageReference.java
+++ b/src/com/fsck/k9/activity/MessageReference.java
@@ -8,13 +8,11 @@ import android.util.Log;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
-import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.Flag;
-import com.fsck.k9.mail.Folder;
-import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
-import com.fsck.k9.mail.store.local.LocalFolder;
-import com.fsck.k9.mail.store.local.LocalMessage;
+import com.fsck.k9.local.LocalFolder;
+import com.fsck.k9.local.LocalMessage;
+import com.fsck.k9.mail.filter.Base64;
import java.util.StringTokenizer;
@@ -51,9 +49,9 @@ public class MessageReference implements Parcelable {
// Split the identity, stripping away the first two characters representing the version and delimiter.
StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false);
if (tokens.countTokens() >= 3) {
- accountUuid = Utility.base64Decode(tokens.nextToken());
- folderName = Utility.base64Decode(tokens.nextToken());
- uid = Utility.base64Decode(tokens.nextToken());
+ accountUuid = Base64.decode(tokens.nextToken());
+ folderName = Base64.decode(tokens.nextToken());
+ uid = Base64.decode(tokens.nextToken());
if (tokens.hasMoreTokens()) {
final String flagString = tokens.nextToken();
@@ -82,11 +80,11 @@ public class MessageReference implements Parcelable {
refString.append(IDENTITY_VERSION_1);
refString.append(IDENTITY_SEPARATOR);
- refString.append(Utility.base64Encode(accountUuid));
+ refString.append(Base64.encode(accountUuid));
refString.append(IDENTITY_SEPARATOR);
- refString.append(Utility.base64Encode(folderName));
+ refString.append(Base64.encode(folderName));
refString.append(IDENTITY_SEPARATOR);
- refString.append(Utility.base64Encode(uid));
+ refString.append(Base64.encode(uid));
if (flag != null) {
refString.append(IDENTITY_SEPARATOR);
refString.append(flag.name());
diff --git a/src/com/fsck/k9/activity/UpgradeDatabases.java b/src/com/fsck/k9/activity/UpgradeDatabases.java
index b0cf3587a..f5b2b9754 100644
--- a/src/com/fsck/k9/activity/UpgradeDatabases.java
+++ b/src/com/fsck/k9/activity/UpgradeDatabases.java
@@ -30,7 +30,7 @@ import android.widget.TextView;
*
{@link #actionUpgradeDatabases(Context, Intent)} will call {@link K9#areDatabasesUpToDate()}
* to check if we already know whether the databases have been upgraded.
* {@link K9#areDatabasesUpToDate()} will compare the last known database version stored in a
- * {@link SharedPreferences} file to {@link com.fsck.k9.mail.store.local.LocalStore#DB_VERSION}. This
+ * {@link SharedPreferences} file to {@link com.fsck.k9.local.LocalStore#DB_VERSION}. This
* is done as an optimization because it's faster than opening all of the accounts' databases
* one by one.
* If there was an error reading the cached database version or if it shows the databases need
diff --git a/src/com/fsck/k9/activity/setup/AccountSettings.java b/src/com/fsck/k9/activity/setup/AccountSettings.java
index ba4a82658..2eac23514 100644
--- a/src/com/fsck/k9/activity/setup/AccountSettings.java
+++ b/src/com/fsck/k9/activity/setup/AccountSettings.java
@@ -36,8 +36,8 @@ import com.fsck.k9.activity.K9PreferenceActivity;
import com.fsck.k9.activity.ManageIdentities;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Store;
-import com.fsck.k9.mail.store.local.LocalFolder;
-import com.fsck.k9.mail.store.StorageManager;
+import com.fsck.k9.local.LocalFolder;
+import com.fsck.k9.local.StorageManager;
import com.fsck.k9.service.MailService;
import org.openintents.openpgp.util.OpenPgpListPreference;
diff --git a/src/com/fsck/k9/activity/setup/FolderSettings.java b/src/com/fsck/k9/activity/setup/FolderSettings.java
index 31bb8e95c..af9ab8b67 100644
--- a/src/com/fsck/k9/activity/setup/FolderSettings.java
+++ b/src/com/fsck/k9/activity/setup/FolderSettings.java
@@ -16,8 +16,8 @@ import com.fsck.k9.mail.Folder.FolderClass;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Store;
-import com.fsck.k9.mail.store.local.LocalFolder;
-import com.fsck.k9.mail.store.local.LocalStore;
+import com.fsck.k9.local.LocalFolder;
+import com.fsck.k9.local.LocalStore;
import com.fsck.k9.service.MailService;
public class FolderSettings extends K9PreferenceActivity {
diff --git a/src/com/fsck/k9/cache/EmailProviderCache.java b/src/com/fsck/k9/cache/EmailProviderCache.java
index ccd712d12..a37f66acd 100644
--- a/src/com/fsck/k9/cache/EmailProviderCache.java
+++ b/src/com/fsck/k9/cache/EmailProviderCache.java
@@ -11,8 +11,8 @@ import android.support.v4.content.LocalBroadcastManager;
import com.fsck.k9.fragment.MessageListFragment;
import com.fsck.k9.mail.Message;
-import com.fsck.k9.mail.store.local.LocalFolder;
-import com.fsck.k9.mail.store.local.LocalMessage;
+import com.fsck.k9.local.LocalFolder;
+import com.fsck.k9.local.LocalMessage;
import com.fsck.k9.provider.EmailProvider;
/**
diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java
index d52c24183..a955c9199 100644
--- a/src/com/fsck/k9/controller/MessagingController.java
+++ b/src/com/fsck/k9/controller/MessagingController.java
@@ -81,15 +81,14 @@ import com.fsck.k9.mail.Transport;
import com.fsck.k9.mail.internet.MimeMessage;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.internet.TextBody;
-import com.fsck.k9.mail.store.local.MessageRemovalListener;
-import com.fsck.k9.mail.store.local.MessageRetrievalListener;
-import com.fsck.k9.mail.store.local.LocalFolder;
-import com.fsck.k9.mail.store.local.LocalMessage;
-import com.fsck.k9.mail.store.local.LocalStore;
-import com.fsck.k9.mail.store.local.LocalStore.PendingCommand;
+import com.fsck.k9.local.MessageRemovalListener;
+import com.fsck.k9.mail.MessageRetrievalListener;
+import com.fsck.k9.local.LocalFolder;
+import com.fsck.k9.local.LocalMessage;
+import com.fsck.k9.local.LocalStore;
+import com.fsck.k9.local.LocalStore.PendingCommand;
import com.fsck.k9.mail.store.Pop3Store;
-import com.fsck.k9.mail.store.UnavailableAccountException;
-import com.fsck.k9.mail.store.UnavailableStorageException;
+import com.fsck.k9.local.UnavailableStorageException;
import com.fsck.k9.provider.EmailProvider;
import com.fsck.k9.provider.EmailProvider.StatsColumns;
import com.fsck.k9.search.ConditionsTreeNode;
diff --git a/src/com/fsck/k9/controller/MessagingControllerPushReceiver.java b/src/com/fsck/k9/controller/MessagingControllerPushReceiver.java
index ccd13a59f..d99f5feb1 100644
--- a/src/com/fsck/k9/controller/MessagingControllerPushReceiver.java
+++ b/src/com/fsck/k9/controller/MessagingControllerPushReceiver.java
@@ -11,8 +11,8 @@ import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.PushReceiver;
-import com.fsck.k9.mail.store.local.LocalFolder;
-import com.fsck.k9.mail.store.local.LocalStore;
+import com.fsck.k9.local.LocalFolder;
+import com.fsck.k9.local.LocalStore;
import com.fsck.k9.service.SleepService;
import java.util.List;
diff --git a/src/com/fsck/k9/controller/MessagingListener.java b/src/com/fsck/k9/controller/MessagingListener.java
index 470cc6387..a0396b535 100644
--- a/src/com/fsck/k9/controller/MessagingListener.java
+++ b/src/com/fsck/k9/controller/MessagingListener.java
@@ -11,7 +11,7 @@ import com.fsck.k9.BaseAccount;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.Part;
-import com.fsck.k9.mail.store.local.LocalMessage;
+import com.fsck.k9.local.LocalMessage;
/**
* Defines the interface that {@link MessagingController} will use to callback to requesters.
diff --git a/src/com/fsck/k9/mail/store/UnavailableAccountException.java b/src/com/fsck/k9/controller/UnavailableAccountException.java
similarity index 83%
rename from src/com/fsck/k9/mail/store/UnavailableAccountException.java
rename to src/com/fsck/k9/controller/UnavailableAccountException.java
index 26e66b1be..55533828e 100644
--- a/src/com/fsck/k9/mail/store/UnavailableAccountException.java
+++ b/src/com/fsck/k9/controller/UnavailableAccountException.java
@@ -1,10 +1,8 @@
-package com.fsck.k9.mail.store;
-
-import com.fsck.k9.Account;
+package com.fsck.k9.controller;
/**
- * An {@link Account} is not
- * {@link Account#isAvailable(android.content.Context)}.
+ * An {@link com.fsck.k9.Account} is not
+ * {@link com.fsck.k9.Account#isAvailable(android.content.Context)}.
* The operation may be retried later.
*/
public class UnavailableAccountException extends RuntimeException {
diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java
index fa70da72c..dae7ec49d 100644
--- a/src/com/fsck/k9/fragment/MessageListFragment.java
+++ b/src/com/fsck/k9/fragment/MessageListFragment.java
@@ -88,9 +88,9 @@ import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
-import com.fsck.k9.mail.store.local.LocalFolder;
-import com.fsck.k9.mail.store.local.LocalMessage;
-import com.fsck.k9.mail.store.local.LocalStore;
+import com.fsck.k9.local.LocalFolder;
+import com.fsck.k9.local.LocalMessage;
+import com.fsck.k9.local.LocalStore;
import com.fsck.k9.provider.EmailProvider;
import com.fsck.k9.provider.EmailProvider.MessageColumns;
import com.fsck.k9.provider.EmailProvider.SpecialColumns;
diff --git a/src/com/fsck/k9/fragment/MessageViewFragment.java b/src/com/fsck/k9/fragment/MessageViewFragment.java
index 5945957e3..5ffee961a 100644
--- a/src/com/fsck/k9/fragment/MessageViewFragment.java
+++ b/src/com/fsck/k9/fragment/MessageViewFragment.java
@@ -38,7 +38,7 @@ import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Part;
-import com.fsck.k9.mail.store.local.LocalMessage;
+import com.fsck.k9.local.LocalMessage;
import com.fsck.k9.view.AttachmentView;
import com.fsck.k9.view.AttachmentView.AttachmentFileDownloadCallback;
import com.fsck.k9.view.MessageHeader;
diff --git a/src/com/fsck/k9/helper/MessageHelper.java b/src/com/fsck/k9/helper/MessageHelper.java
index 5df0161b8..4cde05621 100644
--- a/src/com/fsck/k9/helper/MessageHelper.java
+++ b/src/com/fsck/k9/helper/MessageHelper.java
@@ -11,10 +11,9 @@ import com.fsck.k9.activity.FolderInfoHolder;
import com.fsck.k9.activity.MessageInfoHolder;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Flag;
-import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Message.RecipientType;
-import com.fsck.k9.mail.store.local.LocalMessage;
+import com.fsck.k9.local.LocalMessage;
public class MessageHelper {
diff --git a/src/com/fsck/k9/helper/Regex.java b/src/com/fsck/k9/helper/Regex.java
deleted file mode 100644
index dd60134a0..000000000
--- a/src/com/fsck/k9/helper/Regex.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Imported from AOSP on 2011-01-12 by JRV.
- * Domain patterns updated from IANA on 2010-01-12
- *
- *
- */
-
-package com.fsck.k9.helper;
-
-import java.util.regex.Pattern;
-
-/**
- * Commonly used regular expression patterns.
- */
-public class Regex {
-
- /**
- * Goegular expression to match all IANA top-level domains for WEB_URL.
- * List accurate as of 2011/01/12. List taken from:
- * http://data.iana.org/TLD/tlds-alpha-by-domain.txt
- * This pattern is auto-generated by frameworks/base/common/tools/make-iana-tld-pattern.py
- */
- public static final String TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL =
- "(?:"
- + "(?:aero|arpa|asia|a[cdefgilmnoqrstuwxz])"
- + "|(?:biz|b[abdefghijmnorstvwyz])"
- + "|(?:cat|com|coop|c[acdfghiklmnoruvxyz])"
- + "|d[ejkmoz]"
- + "|(?:edu|e[cegrstu])"
- + "|f[ijkmor]"
- + "|(?:gov|g[abdefghilmnpqrstuwy])"
- + "|h[kmnrtu]"
- + "|(?:info|int|i[delmnoqrst])"
- + "|(?:jobs|j[emop])"
- + "|k[eghimnprwyz]"
- + "|l[abcikrstuvy]"
- + "|(?:mil|mobi|museum|m[acdeghklmnopqrstuvwxyz])"
- + "|(?:name|net|n[acefgilopruz])"
- + "|(?:org|om)"
- + "|(?:pro|p[aefghklmnrstwy])"
- + "|qa"
- + "|r[eosuw]"
- + "|s[abcdeghijklmnortuvyz]"
- + "|(?:tel|travel|t[cdfghjklmnoprtvwz])"
- + "|u[agksyz]"
- + "|v[aceginu]"
- + "|w[fs]"
- + "|(?:xn\\-\\-0zwm56d|xn\\-\\-11b5bs3a9aj6g|xn\\-\\-80akhbyknj4f|xn\\-\\-9t4b11yi5a|xn\\-\\-deba0ad|xn\\-\\-fiqs8s|xn\\-\\-fiqz9s|xn\\-\\-fzc2c9e2c|xn\\-\\-g6w251d|xn\\-\\-hgbk6aj7f53bba|xn\\-\\-hlcj6aya9esc7a|xn\\-\\-j6w193g|xn\\-\\-jxalpdlp|xn\\-\\-kgbechtv|xn\\-\\-kprw13d|xn\\-\\-kpry57d|xn\\-\\-mgbaam7a8h|xn\\-\\-mgbayh7gpa|xn\\-\\-mgberp4a5d4ar|xn\\-\\-o3cw4h|xn\\-\\-p1ai|xn\\-\\-pgbs0dh|xn\\-\\-wgbh1c|xn\\-\\-wgbl6a|xn\\-\\-xkc2al3hye2a|xn\\-\\-ygbi2ammx|xn\\-\\-zckzah)"
- + "|y[et]"
- + "|z[amw]))";
-
- /* This comprises most common used Unicode characters allowed in IRI
- * as detailed in RFC 3987.
- * Specifically, those two byte Unicode characters are not included.
- */
- public static final String GOOD_IRI_CHAR =
- "a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
-
- /**
- * Regular expression pattern to match most part of RFC 3987
- * Internationalized URLs, aka IRIs. Commonly used Unicode characters are
- * added.
- */
- public static final Pattern WEB_URL_PATTERN = Pattern.compile(
- "((?:(http|https|Http|Https|rtsp|Rtsp):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
- + "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
- + "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
- + "((?:(?:[" + GOOD_IRI_CHAR + "][" + GOOD_IRI_CHAR + "\\-]{0,64}\\.)+" // named host
- + TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL
- + "|(?:(?:25[0-5]|2[0-4]" // or ip address
- + "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(?:25[0-5]|2[0-4][0-9]"
- + "|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1]"
- + "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}"
- + "|[1-9][0-9]|[0-9])))"
- + "(?:\\:\\d{1,5})?)" // plus option port number
- + "(\\/(?:(?:[" + GOOD_IRI_CHAR + "\\;\\/\\?\\:\\@\\&\\=\\#\\~" // plus option query params
- + "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?"
- + "(?:\\b|$)"); // and finally, a word boundary or end of
- // input. This is to stop foo.sure from
- // matching as foo.su
-
- public static final Pattern EMAIL_ADDRESS_PATTERN
- = Pattern.compile(
- "[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" +
- "\\@" +
- "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +
- "(" +
- "\\." +
- "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +
- ")+"
- );
-
- public static final String BITCOIN_URI_PATTERN =
- "bitcoin:[1-9a-km-zA-HJ-NP-Z]{27,34}(\\?[a-zA-Z0-9$\\-_.+!*'(),%:@&=]*)?";
-}
diff --git a/src/com/fsck/k9/helper/Utility.java b/src/com/fsck/k9/helper/Utility.java
index 50ca99e3a..ffd6270a2 100644
--- a/src/com/fsck/k9/helper/Utility.java
+++ b/src/com/fsck/k9/helper/Utility.java
@@ -15,7 +15,6 @@ import android.widget.EditText;
import android.widget.TextView;
import com.fsck.k9.K9;
-import com.fsck.k9.mail.filter.Base64;
import java.nio.charset.Charset;
import java.util.ArrayList;
@@ -91,22 +90,6 @@ public class Utility {
return TextUtils.join(String.valueOf(separator), parts);
}
- public static String base64Decode(String encoded) {
- if (encoded == null) {
- return null;
- }
- byte[] decoded = new Base64().decode(encoded.getBytes());
- return new String(decoded);
- }
-
- public static String base64Encode(String s) {
- if (s == null) {
- return s;
- }
- byte[] encoded = new Base64().encode(s.getBytes());
- return new String(encoded);
- }
-
public static boolean requiredFieldValid(TextView view) {
return view.getText() != null && view.getText().length() > 0;
}
@@ -130,48 +113,6 @@ public class Utility {
return false;
}
- private static final Pattern ATOM = Pattern.compile("^(?:[a-zA-Z0-9!#$%&'*+\\-/=?^_`{|}~]|\\s)+$");
-
- /**
- * Quote a string, if necessary, based upon the definition of an "atom," as defined by RFC2822
- * (http://tools.ietf.org/html/rfc2822#section-3.2.4). Strings that consist purely of atoms are
- * left unquoted; anything else is returned as a quoted string.
- * @param text String to quote.
- * @return Possibly quoted string.
- */
- public static String quoteAtoms(final String text) {
- if (ATOM.matcher(text).matches()) {
- return text;
- } else {
- return quoteString(text);
- }
- }
-
- /**
- * Ensures that the given string starts and ends with the double quote character. The string is not modified in any way except to add the
- * double quote character to start and end if it's not already there.
- * sample -> "sample"
- * "sample" -> "sample"
- * ""sample"" -> "sample"
- * "sample"" -> "sample"
- * sa"mp"le -> "sa"mp"le"
- * "sa"mp"le" -> "sa"mp"le"
- * (empty string) -> ""
- * " -> ""
- * @param s
- * @return
- */
- public static String quoteString(String s) {
- if (s == null) {
- return null;
- }
- if (!s.matches("^\".*\"$")) {
- return "\"" + s + "\"";
- } else {
- return s;
- }
- }
-
/**
* A fast version of URLDecoder.decode() that works only with UTF-8 and does only two
* allocations. This version is around 3x as fast as the standard one and I'm using it
diff --git a/src/com/fsck/k9/mail/store/local/AttachmentMessageBodyUtil.java b/src/com/fsck/k9/local/AttachmentMessageBodyUtil.java
similarity index 96%
rename from src/com/fsck/k9/mail/store/local/AttachmentMessageBodyUtil.java
rename to src/com/fsck/k9/local/AttachmentMessageBodyUtil.java
index a1f4d5b3b..97a8a2394 100644
--- a/src/com/fsck/k9/mail/store/local/AttachmentMessageBodyUtil.java
+++ b/src/com/fsck/k9/local/AttachmentMessageBodyUtil.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import java.io.IOException;
import java.io.InputStream;
diff --git a/src/com/fsck/k9/mail/store/local/BinaryAttachmentBody.java b/src/com/fsck/k9/local/BinaryAttachmentBody.java
similarity index 97%
rename from src/com/fsck/k9/mail/store/local/BinaryAttachmentBody.java
rename to src/com/fsck/k9/local/BinaryAttachmentBody.java
index 8efcf8992..466f6e57f 100644
--- a/src/com/fsck/k9/mail/store/local/BinaryAttachmentBody.java
+++ b/src/com/fsck/k9/local/BinaryAttachmentBody.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import java.io.IOException;
import java.io.InputStream;
diff --git a/src/com/fsck/k9/mail/store/local/LocalAttachmentBody.java b/src/com/fsck/k9/local/LocalAttachmentBody.java
similarity index 96%
rename from src/com/fsck/k9/mail/store/local/LocalAttachmentBody.java
rename to src/com/fsck/k9/local/LocalAttachmentBody.java
index 7efdf949c..acfbe7980 100644
--- a/src/com/fsck/k9/mail/store/local/LocalAttachmentBody.java
+++ b/src/com/fsck/k9/local/LocalAttachmentBody.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
diff --git a/src/com/fsck/k9/mail/store/local/LocalAttachmentBodyPart.java b/src/com/fsck/k9/local/LocalAttachmentBodyPart.java
similarity index 95%
rename from src/com/fsck/k9/mail/store/local/LocalAttachmentBodyPart.java
rename to src/com/fsck/k9/local/LocalAttachmentBodyPart.java
index e72d3b493..7d5a19798 100644
--- a/src/com/fsck/k9/mail/store/local/LocalAttachmentBodyPart.java
+++ b/src/com/fsck/k9/local/LocalAttachmentBodyPart.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.MessagingException;
diff --git a/src/com/fsck/k9/mail/store/local/LocalAttachmentMessageBody.java b/src/com/fsck/k9/local/LocalAttachmentMessageBody.java
similarity index 97%
rename from src/com/fsck/k9/mail/store/local/LocalAttachmentMessageBody.java
rename to src/com/fsck/k9/local/LocalAttachmentMessageBody.java
index d953bfc73..6dc632495 100644
--- a/src/com/fsck/k9/mail/store/local/LocalAttachmentMessageBody.java
+++ b/src/com/fsck/k9/local/LocalAttachmentMessageBody.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import java.io.IOException;
import java.io.OutputStream;
diff --git a/src/com/fsck/k9/mail/store/local/LocalFolder.java b/src/com/fsck/k9/local/LocalFolder.java
similarity index 99%
rename from src/com/fsck/k9/mail/store/local/LocalFolder.java
rename to src/com/fsck/k9/local/LocalFolder.java
index e68d7d684..33e177f9a 100644
--- a/src/com/fsck/k9/mail/store/local/LocalFolder.java
+++ b/src/com/fsck/k9/local/LocalFolder.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import java.io.File;
import java.io.FileOutputStream;
@@ -32,6 +32,7 @@ import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.Account.MessageFormat;
import com.fsck.k9.activity.Search;
+import com.fsck.k9.mail.MessageRetrievalListener;
import com.fsck.k9.mail.internet.HtmlConverter;
import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.Address;
@@ -51,10 +52,8 @@ import com.fsck.k9.mail.internet.MimeMultipart;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.internet.TextBody;
import com.fsck.k9.mail.internet.MimeUtility.ViewableContainer;
-import com.fsck.k9.mail.store.StorageManager;
-import com.fsck.k9.mail.store.UnavailableStorageException;
-import com.fsck.k9.mail.store.local.LockableDatabase.DbCallback;
-import com.fsck.k9.mail.store.local.LockableDatabase.WrappedException;
+import com.fsck.k9.local.LockableDatabase.DbCallback;
+import com.fsck.k9.local.LockableDatabase.WrappedException;
import com.fsck.k9.provider.AttachmentProvider;
public class LocalFolder extends Folder implements Serializable {
@@ -828,10 +827,10 @@ public class LocalFolder extends Folder implements Serializable {
* The messages whose headers should be loaded.
* @throws UnavailableStorageException
*/
- void populateHeaders(final List messages) throws UnavailableStorageException {
+ void populateHeaders(final List messages) throws MessagingException {
this.localStore.database.execute(false, new DbCallback() {
@Override
- public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
+ public Void doDbWork(final SQLiteDatabase db) throws WrappedException, MessagingException {
Cursor cursor = null;
if (messages.isEmpty()) {
return null;
@@ -1488,7 +1487,7 @@ public class LocalFolder extends Folder implements Serializable {
private void saveHeaders(final long id, final MimeMessage message) throws MessagingException {
this.localStore.database.execute(true, new DbCallback() {
@Override
- public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
+ public Void doDbWork(final SQLiteDatabase db) throws WrappedException, MessagingException {
deleteHeaders(id);
for (String name : message.getHeaderNames()) {
@@ -1517,7 +1516,7 @@ public class LocalFolder extends Folder implements Serializable {
});
}
- void deleteHeaders(final long id) throws UnavailableStorageException {
+ void deleteHeaders(final long id) throws MessagingException {
this.localStore.database.execute(false, new DbCallback() {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
diff --git a/src/com/fsck/k9/mail/store/local/LocalMessage.java b/src/com/fsck/k9/local/LocalMessage.java
similarity index 96%
rename from src/com/fsck/k9/mail/store/local/LocalMessage.java
rename to src/com/fsck/k9/local/LocalMessage.java
index 7391a8646..ac3aa5918 100644
--- a/src/com/fsck/k9/mail/store/local/LocalMessage.java
+++ b/src/com/fsck/k9/local/LocalMessage.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import java.io.IOException;
import java.io.OutputStream;
@@ -22,9 +22,8 @@ import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.internet.MimeMessage;
import com.fsck.k9.mail.internet.MimeUtility;
-import com.fsck.k9.mail.store.UnavailableStorageException;
-import com.fsck.k9.mail.store.local.LockableDatabase.DbCallback;
-import com.fsck.k9.mail.store.local.LockableDatabase.WrappedException;
+import com.fsck.k9.local.LockableDatabase.DbCallback;
+import com.fsck.k9.local.LockableDatabase.WrappedException;
public class LocalMessage extends MimeMessage {
protected MessageReference mReference;
@@ -499,44 +498,44 @@ public class LocalMessage extends MimeMessage {
db.delete("threads", "message_id = ?", idArg);
}
- private void loadHeaders() throws UnavailableStorageException {
+ private void loadHeaders() throws MessagingException {
List messages = new ArrayList();
messages.add(this);
mHeadersLoaded = true; // set true before calling populate headers to stop recursion
- ((LocalFolder) mFolder).populateHeaders(messages);
+ getFolder().populateHeaders(messages);
}
@Override
- public void addHeader(String name, String value) throws UnavailableStorageException {
+ public void addHeader(String name, String value) throws MessagingException {
if (!mHeadersLoaded)
loadHeaders();
super.addHeader(name, value);
}
@Override
- public void setHeader(String name, String value) throws UnavailableStorageException {
+ public void setHeader(String name, String value) throws MessagingException {
if (!mHeadersLoaded)
loadHeaders();
super.setHeader(name, value);
}
@Override
- public String[] getHeader(String name) throws UnavailableStorageException {
+ public String[] getHeader(String name) throws MessagingException {
if (!mHeadersLoaded)
loadHeaders();
return super.getHeader(name);
}
@Override
- public void removeHeader(String name) throws UnavailableStorageException {
+ public void removeHeader(String name) throws MessagingException {
if (!mHeadersLoaded)
loadHeaders();
super.removeHeader(name);
}
@Override
- public Set getHeaderNames() throws UnavailableStorageException {
+ public Set getHeaderNames() throws MessagingException {
if (!mHeadersLoaded)
loadHeaders();
return super.getHeaderNames();
diff --git a/src/com/fsck/k9/mail/store/local/LocalStore.java b/src/com/fsck/k9/local/LocalStore.java
similarity index 98%
rename from src/com/fsck/k9/mail/store/local/LocalStore.java
rename to src/com/fsck/k9/local/LocalStore.java
index 64bacb2ef..a7ec36f51 100644
--- a/src/com/fsck/k9/mail/store/local/LocalStore.java
+++ b/src/com/fsck/k9/local/LocalStore.java
@@ -1,5 +1,5 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import android.app.Application;
import android.content.ContentResolver;
@@ -18,15 +18,14 @@ import com.fsck.k9.helper.UrlEncodingHelper;
import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
+import com.fsck.k9.mail.MessageRetrievalListener;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Store;
import com.fsck.k9.mail.store.RemoteStore;
-import com.fsck.k9.mail.store.StorageManager;
-import com.fsck.k9.mail.store.StorageManager.StorageProvider;
+import com.fsck.k9.local.StorageManager.StorageProvider;
import com.fsck.k9.mail.store.StoreConfig;
-import com.fsck.k9.mail.store.UnavailableStorageException;
-import com.fsck.k9.mail.store.local.LockableDatabase.DbCallback;
-import com.fsck.k9.mail.store.local.LockableDatabase.WrappedException;
+import com.fsck.k9.local.LockableDatabase.DbCallback;
+import com.fsck.k9.local.LockableDatabase.WrappedException;
import com.fsck.k9.provider.EmailProvider;
import com.fsck.k9.provider.EmailProvider.MessageColumns;
import com.fsck.k9.search.LocalSearch;
@@ -244,7 +243,7 @@ public class LocalStore extends Store implements Serializable {
return Preferences.getPreferences(mApplication).getPreferences();
}
- public long getSize() throws UnavailableStorageException {
+ public long getSize() throws MessagingException {
final StorageManager storageManager = StorageManager.getInstance(mApplication);
@@ -487,7 +486,7 @@ public class LocalStore extends Store implements Serializable {
});
}
- public void resetVisibleLimits(int visibleLimit) throws UnavailableStorageException {
+ public void resetVisibleLimits(int visibleLimit) throws MessagingException {
final ContentValues cv = new ContentValues();
cv.put("visible_limit", Integer.toString(visibleLimit));
database.execute(false, new DbCallback() {
@@ -499,7 +498,7 @@ public class LocalStore extends Store implements Serializable {
});
}
- public List getPendingCommands() throws UnavailableStorageException {
+ public List getPendingCommands() throws MessagingException {
return database.execute(false, new DbCallback>() {
@Override
public List doDbWork(final SQLiteDatabase db) throws WrappedException {
@@ -532,7 +531,7 @@ public class LocalStore extends Store implements Serializable {
});
}
- public void addPendingCommand(PendingCommand command) throws UnavailableStorageException {
+ public void addPendingCommand(PendingCommand command) throws MessagingException {
for (int i = 0; i < command.arguments.length; i++) {
command.arguments[i] = UrlEncodingHelper.encodeUtf8(command.arguments[i]);
}
@@ -548,7 +547,7 @@ public class LocalStore extends Store implements Serializable {
});
}
- public void removePendingCommand(final PendingCommand command) throws UnavailableStorageException {
+ public void removePendingCommand(final PendingCommand command) throws MessagingException {
database.execute(false, new DbCallback() {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
@@ -558,7 +557,7 @@ public class LocalStore extends Store implements Serializable {
});
}
- public void removePendingCommands() throws UnavailableStorageException {
+ public void removePendingCommands() throws MessagingException {
database.execute(false, new DbCallback() {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
@@ -690,7 +689,7 @@ public class LocalStore extends Store implements Serializable {
return searchForMessages(null, search);
}
- public AttachmentInfo getAttachmentInfo(final String attachmentId) throws UnavailableStorageException {
+ public AttachmentInfo getAttachmentInfo(final String attachmentId) throws MessagingException {
return database.execute(false, new DbCallback() {
@Override
public AttachmentInfo doDbWork(final SQLiteDatabase db) throws WrappedException {
@@ -731,7 +730,7 @@ public class LocalStore extends Store implements Serializable {
public String type;
}
- public void createFolders(final List foldersToCreate, final int visibleLimit) throws UnavailableStorageException {
+ public void createFolders(final List foldersToCreate, final int visibleLimit) throws MessagingException {
database.execute(true, new DbCallback() {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
diff --git a/src/com/fsck/k9/mail/store/local/LocalTextBody.java b/src/com/fsck/k9/local/LocalTextBody.java
similarity index 92%
rename from src/com/fsck/k9/mail/store/local/LocalTextBody.java
rename to src/com/fsck/k9/local/LocalTextBody.java
index 3d83c6eb9..b40d79b8e 100644
--- a/src/com/fsck/k9/mail/store/local/LocalTextBody.java
+++ b/src/com/fsck/k9/local/LocalTextBody.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import com.fsck.k9.mail.internet.TextBody;
diff --git a/src/com/fsck/k9/mail/store/local/LockableDatabase.java b/src/com/fsck/k9/local/LockableDatabase.java
similarity index 97%
rename from src/com/fsck/k9/mail/store/local/LockableDatabase.java
rename to src/com/fsck/k9/local/LockableDatabase.java
index 57cae16ef..62f013953 100644
--- a/src/com/fsck/k9/mail/store/local/LockableDatabase.java
+++ b/src/com/fsck/k9/local/LockableDatabase.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import java.io.File;
import java.util.concurrent.locks.Lock;
@@ -16,8 +16,6 @@ import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.helper.FileHelper;
import com.fsck.k9.mail.MessagingException;
-import com.fsck.k9.mail.store.StorageManager;
-import com.fsck.k9.mail.store.UnavailableStorageException;
public class LockableDatabase {
@@ -35,9 +33,10 @@ public class LockableDatabase {
* null
.
* @return Any relevant data. Can be null
.
* @throws WrappedException
- * @throws com.fsck.k9.mail.store.UnavailableStorageException
+ * @throws com.fsck.k9.mail.MessagingException
+ * @throws com.fsck.k9.local.UnavailableStorageException
*/
- T doDbWork(SQLiteDatabase db) throws WrappedException, UnavailableStorageException;
+ T doDbWork(SQLiteDatabase db) throws WrappedException, MessagingException;
}
public static interface SchemaDefinition {
@@ -272,7 +271,7 @@ public class LockableDatabase {
* @return Whatever {@link DbCallback#doDbWork(SQLiteDatabase)} returns.
* @throws UnavailableStorageException
*/
- public T execute(final boolean transactional, final DbCallback callback) throws UnavailableStorageException {
+ public T execute(final boolean transactional, final DbCallback callback) throws MessagingException {
lockRead();
final boolean doTransaction = transactional && inTransaction.get() == null;
try {
diff --git a/src/com/fsck/k9/mail/store/local/MessageRemovalListener.java b/src/com/fsck/k9/local/MessageRemovalListener.java
similarity index 77%
rename from src/com/fsck/k9/mail/store/local/MessageRemovalListener.java
rename to src/com/fsck/k9/local/MessageRemovalListener.java
index 95e35fd22..3f4d47d0e 100644
--- a/src/com/fsck/k9/mail/store/local/MessageRemovalListener.java
+++ b/src/com/fsck/k9/local/MessageRemovalListener.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import com.fsck.k9.mail.Message;
diff --git a/src/com/fsck/k9/mail/store/StorageManager.java b/src/com/fsck/k9/local/StorageManager.java
similarity index 99%
rename from src/com/fsck/k9/mail/store/StorageManager.java
rename to src/com/fsck/k9/local/StorageManager.java
index 68cc216df..20676d720 100644
--- a/src/com/fsck/k9/mail/store/StorageManager.java
+++ b/src/com/fsck/k9/local/StorageManager.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store;
+package com.fsck.k9.local;
import java.io.File;
import java.io.IOException;
diff --git a/src/com/fsck/k9/mail/store/local/StoreSchemaDefinition.java b/src/com/fsck/k9/local/StoreSchemaDefinition.java
similarity index 99%
rename from src/com/fsck/k9/mail/store/local/StoreSchemaDefinition.java
rename to src/com/fsck/k9/local/StoreSchemaDefinition.java
index aec7390fc..c893e5888 100644
--- a/src/com/fsck/k9/mail/store/local/StoreSchemaDefinition.java
+++ b/src/com/fsck/k9/local/StoreSchemaDefinition.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/com/fsck/k9/mail/store/local/TempFileBody.java b/src/com/fsck/k9/local/TempFileBody.java
similarity index 94%
rename from src/com/fsck/k9/mail/store/local/TempFileBody.java
rename to src/com/fsck/k9/local/TempFileBody.java
index 9b7916b5a..c687d6082 100644
--- a/src/com/fsck/k9/mail/store/local/TempFileBody.java
+++ b/src/com/fsck/k9/local/TempFileBody.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import java.io.ByteArrayInputStream;
import java.io.File;
diff --git a/src/com/fsck/k9/mail/store/local/TempFileMessageBody.java b/src/com/fsck/k9/local/TempFileMessageBody.java
similarity index 96%
rename from src/com/fsck/k9/mail/store/local/TempFileMessageBody.java
rename to src/com/fsck/k9/local/TempFileMessageBody.java
index 5cd5e207b..55f6b76e4 100644
--- a/src/com/fsck/k9/mail/store/local/TempFileMessageBody.java
+++ b/src/com/fsck/k9/local/TempFileMessageBody.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
import java.io.IOException;
import java.io.OutputStream;
diff --git a/src/com/fsck/k9/mail/store/local/ThreadInfo.java b/src/com/fsck/k9/local/ThreadInfo.java
similarity index 92%
rename from src/com/fsck/k9/mail/store/local/ThreadInfo.java
rename to src/com/fsck/k9/local/ThreadInfo.java
index 4115c16d6..cf72dddc1 100644
--- a/src/com/fsck/k9/mail/store/local/ThreadInfo.java
+++ b/src/com/fsck/k9/local/ThreadInfo.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.local;
class ThreadInfo {
public final long threadId;
diff --git a/src/com/fsck/k9/mail/store/UnavailableStorageException.java b/src/com/fsck/k9/local/UnavailableStorageException.java
similarity index 96%
rename from src/com/fsck/k9/mail/store/UnavailableStorageException.java
rename to src/com/fsck/k9/local/UnavailableStorageException.java
index 90974161b..d6e1cd69d 100644
--- a/src/com/fsck/k9/mail/store/UnavailableStorageException.java
+++ b/src/com/fsck/k9/local/UnavailableStorageException.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.mail.store;
+package com.fsck.k9.local;
import com.fsck.k9.mail.MessagingException;
diff --git a/src/com/fsck/k9/mail/Address.java b/src/com/fsck/k9/mail/Address.java
index 25929e94e..9702c1c8d 100644
--- a/src/com/fsck/k9/mail/Address.java
+++ b/src/com/fsck/k9/mail/Address.java
@@ -3,6 +3,7 @@ package com.fsck.k9.mail;
import java.util.ArrayList;
import java.util.List;
+import java.util.regex.Pattern;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.codec.EncoderUtil;
@@ -20,7 +21,6 @@ import android.text.util.Rfc822Tokenizer;
import android.util.Log;
import com.fsck.k9.K9;
-import com.fsck.k9.helper.Utility;
public class Address {
@@ -28,6 +28,8 @@ public class Address {
String getNameForAddress(String address);
}
+ private static final Pattern ATOM = Pattern.compile("^(?:[a-zA-Z0-9!#$%&'*+\\-/=?^_`{|}~]|\\s)+$");
+
/**
* If the number of addresses exceeds this value the addresses aren't
* resolved to the names of Android contacts.
@@ -201,7 +203,7 @@ public class Address {
@Override
public String toString() {
if (!TextUtils.isEmpty(mPersonal)) {
- return Utility.quoteAtoms(mPersonal) + " <" + mAddress + ">";
+ return quoteAtoms(mPersonal) + " <" + mAddress + ">";
} else {
return mAddress;
}
@@ -367,4 +369,44 @@ public class Address {
}
return sb.toString();
}
+
+ /**
+ * Quote a string, if necessary, based upon the definition of an "atom," as defined by RFC2822
+ * (http://tools.ietf.org/html/rfc2822#section-3.2.4). Strings that consist purely of atoms are
+ * left unquoted; anything else is returned as a quoted string.
+ * @param text String to quote.
+ * @return Possibly quoted string.
+ */
+ public static String quoteAtoms(final String text) {
+ if (ATOM.matcher(text).matches()) {
+ return text;
+ } else {
+ return quoteString(text);
+ }
+ }
+
+ /**
+ * Ensures that the given string starts and ends with the double quote character. The string is not modified in any way except to add the
+ * double quote character to start and end if it's not already there.
+ * sample -> "sample"
+ * "sample" -> "sample"
+ * ""sample"" -> "sample"
+ * "sample"" -> "sample"
+ * sa"mp"le -> "sa"mp"le"
+ * "sa"mp"le" -> "sa"mp"le"
+ * (empty string) -> ""
+ * " -> ""
+ * @param s
+ * @return
+ */
+ private static String quoteString(String s) {
+ if (s == null) {
+ return null;
+ }
+ if (!s.matches("^\".*\"$")) {
+ return "\"" + s + "\"";
+ } else {
+ return s;
+ }
+ }
}
diff --git a/src/com/fsck/k9/mail/Body.java b/src/com/fsck/k9/mail/Body.java
index 93960892c..d86746d66 100644
--- a/src/com/fsck/k9/mail/Body.java
+++ b/src/com/fsck/k9/mail/Body.java
@@ -5,8 +5,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import com.fsck.k9.mail.store.UnavailableStorageException;
-
public interface Body {
/**
* Returns the raw data of the body, without transfer encoding etc applied.
@@ -18,7 +16,7 @@ public interface Body {
/**
* Sets the content transfer encoding (7bit, 8bit, quoted-printable or base64).
*/
- public void setEncoding(String encoding) throws UnavailableStorageException, MessagingException;
+ public void setEncoding(String encoding) throws MessagingException;
/**
* Writes the body's data to the given {@link OutputStream}.
diff --git a/src/com/fsck/k9/mail/Folder.java b/src/com/fsck/k9/mail/Folder.java
index c4f1a3998..a11e7dd32 100644
--- a/src/com/fsck/k9/mail/Folder.java
+++ b/src/com/fsck/k9/mail/Folder.java
@@ -8,7 +8,6 @@ import java.util.Set;
import android.util.Log;
import com.fsck.k9.K9;
-import com.fsck.k9.mail.store.local.MessageRetrievalListener;
public abstract class Folder {
private String status = null;
diff --git a/src/com/fsck/k9/mail/Message.java b/src/com/fsck/k9/mail/Message.java
index d97982a4d..b0bfe12af 100644
--- a/src/com/fsck/k9/mail/Message.java
+++ b/src/com/fsck/k9/mail/Message.java
@@ -12,7 +12,6 @@ import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.mail.filter.CountingOutputStream;
import com.fsck.k9.mail.filter.EOLConvertingOutputStream;
-import com.fsck.k9.mail.store.UnavailableStorageException;
public abstract class Message implements Part, CompositeBody {
@@ -117,28 +116,7 @@ public abstract class Message implements Part, CompositeBody {
public abstract void setReferences(String references) throws MessagingException;
- @Override
- public abstract Body getBody();
-
- @Override
- public abstract String getContentType() throws MessagingException;
-
- @Override
- public abstract void addHeader(String name, String value) throws MessagingException;
-
- @Override
- public abstract void setHeader(String name, String value) throws MessagingException;
-
- @Override
- public abstract String[] getHeader(String name) throws MessagingException;
-
- public abstract Set getHeaderNames() throws UnavailableStorageException;
-
- @Override
- public abstract void removeHeader(String name) throws MessagingException;
-
- @Override
- public abstract void setBody(Body body) throws MessagingException;
+ public abstract Set getHeaderNames() throws MessagingException;
public abstract long getId();
@@ -287,6 +265,4 @@ public abstract class Message implements Part, CompositeBody {
*/
@Override
public abstract Message clone();
- @Override
- public abstract void setUsing7bitTransport() throws MessagingException;
}
diff --git a/src/com/fsck/k9/mail/store/local/MessageRetrievalListener.java b/src/com/fsck/k9/mail/MessageRetrievalListener.java
similarity index 85%
rename from src/com/fsck/k9/mail/store/local/MessageRetrievalListener.java
rename to src/com/fsck/k9/mail/MessageRetrievalListener.java
index 12679b4e5..0d6b4fff1 100644
--- a/src/com/fsck/k9/mail/store/local/MessageRetrievalListener.java
+++ b/src/com/fsck/k9/mail/MessageRetrievalListener.java
@@ -1,7 +1,6 @@
-package com.fsck.k9.mail.store.local;
+package com.fsck.k9.mail;
-import com.fsck.k9.mail.Message;
public interface MessageRetrievalListener {
public void messageStarted(String uid, int number, int ofTotal);
diff --git a/src/com/fsck/k9/mail/ServerSettings.java b/src/com/fsck/k9/mail/ServerSettings.java
index 43e16847b..59633ffdd 100644
--- a/src/com/fsck/k9/mail/ServerSettings.java
+++ b/src/com/fsck/k9/mail/ServerSettings.java
@@ -3,7 +3,6 @@ package com.fsck.k9.mail;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import com.fsck.k9.Account;
/**
* This is an abstraction to get rid of the store- and transport-specific URIs.
@@ -13,8 +12,8 @@ import com.fsck.k9.Account;
* store/transport URIs altogether.
*
*
- * @see Account#getStoreUri()
- * @see Account#getTransportUri()
+ * @see com.fsck.k9.mail.store.StoreConfig#getStoreUri()
+ * @see com.fsck.k9.mail.store.StoreConfig#getTransportUri()
*/
public class ServerSettings {
/**
diff --git a/src/com/fsck/k9/mail/Transport.java b/src/com/fsck/k9/mail/Transport.java
index 28011dacd..97e4ada1d 100644
--- a/src/com/fsck/k9/mail/Transport.java
+++ b/src/com/fsck/k9/mail/Transport.java
@@ -1,7 +1,7 @@
package com.fsck.k9.mail;
-import com.fsck.k9.Account;
+import com.fsck.k9.mail.store.StoreConfig;
import com.fsck.k9.mail.transport.SmtpTransport;
import com.fsck.k9.mail.transport.WebDavTransport;
@@ -11,12 +11,12 @@ public abstract class Transport {
// RFC 1047
protected static final int SOCKET_READ_TIMEOUT = 300000;
- public synchronized static Transport getInstance(Account account) throws MessagingException {
- String uri = account.getTransportUri();
+ public synchronized static Transport getInstance(StoreConfig storeConfig) throws MessagingException {
+ String uri = storeConfig.getTransportUri();
if (uri.startsWith("smtp")) {
- return new SmtpTransport(account);
+ return new SmtpTransport(storeConfig);
} else if (uri.startsWith("webdav")) {
- return new WebDavTransport(account);
+ return new WebDavTransport(storeConfig);
} else {
throw new MessagingException("Unable to locate an applicable Transport for " + uri);
}
diff --git a/src/com/fsck/k9/mail/filter/Base64.java b/src/com/fsck/k9/mail/filter/Base64.java
index 934c3b222..9f7cadfa5 100644
--- a/src/com/fsck/k9/mail/filter/Base64.java
+++ b/src/com/fsck/k9/mail/filter/Base64.java
@@ -34,6 +34,22 @@ import java.nio.charset.Charset;
* @version $Id$
*/
public class Base64 {
+ public static String decode(String encoded) {
+ if (encoded == null) {
+ return null;
+ }
+ byte[] decoded = new Base64().decode(encoded.getBytes());
+ return new String(decoded);
+ }
+
+ public static String encode(String s) {
+ if (s == null) {
+ return null;
+ }
+ byte[] encoded = new Base64().encode(s.getBytes());
+ return new String(encoded);
+ }
+
/**
* Chunk size per RFC 2045 section 6.8.
*
diff --git a/src/com/fsck/k9/mail/internet/HtmlConverter.java b/src/com/fsck/k9/mail/internet/HtmlConverter.java
index a217d5b81..8d28085c1 100644
--- a/src/com/fsck/k9/mail/internet/HtmlConverter.java
+++ b/src/com/fsck/k9/mail/internet/HtmlConverter.java
@@ -4,7 +4,6 @@ import android.text.*;
import android.text.Html.TagHandler;
import android.util.Log;
import com.fsck.k9.K9;
-import com.fsck.k9.helper.Regex;
import org.xml.sax.XMLReader;
@@ -15,11 +14,75 @@ import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Contains common routines to convert html to text and vice versa.
*/
public class HtmlConverter {
+ /* This comprises most common used Unicode characters allowed in IRI
+ * as detailed in RFC 3987.
+ * Specifically, those two byte Unicode characters are not included.
+ */
+ private static final String GOOD_IRI_CHAR =
+ "a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
+ /**
+ * Goegular expression to match all IANA top-level domains for WEB_URL.
+ * List accurate as of 2011/01/12. List taken from:
+ * http://data.iana.org/TLD/tlds-alpha-by-domain.txt
+ * This pattern is auto-generated by frameworks/base/common/tools/make-iana-tld-pattern.py
+ */
+ private static final String TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL =
+ "(?:"
+ + "(?:aero|arpa|asia|a[cdefgilmnoqrstuwxz])"
+ + "|(?:biz|b[abdefghijmnorstvwyz])"
+ + "|(?:cat|com|coop|c[acdfghiklmnoruvxyz])"
+ + "|d[ejkmoz]"
+ + "|(?:edu|e[cegrstu])"
+ + "|f[ijkmor]"
+ + "|(?:gov|g[abdefghilmnpqrstuwy])"
+ + "|h[kmnrtu]"
+ + "|(?:info|int|i[delmnoqrst])"
+ + "|(?:jobs|j[emop])"
+ + "|k[eghimnprwyz]"
+ + "|l[abcikrstuvy]"
+ + "|(?:mil|mobi|museum|m[acdeghklmnopqrstuvwxyz])"
+ + "|(?:name|net|n[acefgilopruz])"
+ + "|(?:org|om)"
+ + "|(?:pro|p[aefghklmnrstwy])"
+ + "|qa"
+ + "|r[eosuw]"
+ + "|s[abcdeghijklmnortuvyz]"
+ + "|(?:tel|travel|t[cdfghjklmnoprtvwz])"
+ + "|u[agksyz]"
+ + "|v[aceginu]"
+ + "|w[fs]"
+ + "|(?:xn\\-\\-0zwm56d|xn\\-\\-11b5bs3a9aj6g|xn\\-\\-80akhbyknj4f|xn\\-\\-9t4b11yi5a|xn\\-\\-deba0ad|xn\\-\\-fiqs8s|xn\\-\\-fiqz9s|xn\\-\\-fzc2c9e2c|xn\\-\\-g6w251d|xn\\-\\-hgbk6aj7f53bba|xn\\-\\-hlcj6aya9esc7a|xn\\-\\-j6w193g|xn\\-\\-jxalpdlp|xn\\-\\-kgbechtv|xn\\-\\-kprw13d|xn\\-\\-kpry57d|xn\\-\\-mgbaam7a8h|xn\\-\\-mgbayh7gpa|xn\\-\\-mgberp4a5d4ar|xn\\-\\-o3cw4h|xn\\-\\-p1ai|xn\\-\\-pgbs0dh|xn\\-\\-wgbh1c|xn\\-\\-wgbl6a|xn\\-\\-xkc2al3hye2a|xn\\-\\-ygbi2ammx|xn\\-\\-zckzah)"
+ + "|y[et]"
+ + "|z[amw]))";
+ private static final String BITCOIN_URI_PATTERN =
+ "bitcoin:[1-9a-km-zA-HJ-NP-Z]{27,34}(\\?[a-zA-Z0-9$\\-_.+!*'(),%:@&=]*)?";
+ /**
+ * Regular expression pattern to match most part of RFC 3987
+ * Internationalized URLs, aka IRIs. Commonly used Unicode characters are
+ * added.
+ */
+ private static final Pattern WEB_URL_PATTERN = Pattern.compile(
+ "((?:(http|https|Http|Https|rtsp|Rtsp):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
+ + "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
+ + "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
+ + "((?:(?:[" + GOOD_IRI_CHAR + "][" + GOOD_IRI_CHAR + "\\-]{0,64}\\.)+" // named host
+ + TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL
+ + "|(?:(?:25[0-5]|2[0-4]" // or ip address
+ + "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(?:25[0-5]|2[0-4][0-9]"
+ + "|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1]"
+ + "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}"
+ + "|[1-9][0-9]|[0-9])))"
+ + "(?:\\:\\d{1,5})?)" // plus option port number
+ + "(\\/(?:(?:[" + GOOD_IRI_CHAR + "\\;\\/\\?\\:\\@\\&\\=\\#\\~" // plus option query params
+ + "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?"
+ + "(?:\\b|$)"); // and finally, a word boundary or end of
+
/**
* When generating previews, Spannable objects that can't be converted into a String are
* represented as 0xfffc. When displayed, these show up as undisplayed squares. These constants
@@ -383,9 +446,9 @@ public class HtmlConverter {
* @param outputBuffer Buffer to append linked text to.
*/
protected static void linkifyText(final String text, final StringBuffer outputBuffer) {
- String prepared = text.replaceAll(Regex.BITCOIN_URI_PATTERN, "$0");
+ String prepared = text.replaceAll(BITCOIN_URI_PATTERN, "$0");
- Matcher m = Regex.WEB_URL_PATTERN.matcher(prepared);
+ Matcher m = WEB_URL_PATTERN.matcher(prepared);
while (m.find()) {
int start = m.start();
if (start == 0 || (start != 0 && prepared.charAt(start - 1) != '@')) {
diff --git a/src/com/fsck/k9/mail/internet/MimeHeader.java b/src/com/fsck/k9/mail/internet/MimeHeader.java
index 12bd5fd31..7c9569df0 100644
--- a/src/com/fsck/k9/mail/internet/MimeHeader.java
+++ b/src/com/fsck/k9/mail/internet/MimeHeader.java
@@ -1,8 +1,6 @@
package com.fsck.k9.mail.internet;
-import com.fsck.k9.helper.Utility;
-
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
@@ -97,7 +95,7 @@ public class MimeHeader {
public void writeTo(OutputStream out) throws IOException {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024);
for (Field field : mFields) {
- if (!Utility.arrayContains(writeOmitFields, field.name)) {
+ if (!Arrays.asList(writeOmitFields).contains(field.name)) {
String v = field.value;
if (hasToBeEncoded(v)) {
diff --git a/src/com/fsck/k9/mail/internet/MimeMessage.java b/src/com/fsck/k9/mail/internet/MimeMessage.java
index 0d7bb8bab..02c028edf 100644
--- a/src/com/fsck/k9/mail/internet/MimeMessage.java
+++ b/src/com/fsck/k9/mail/internet/MimeMessage.java
@@ -33,7 +33,6 @@ import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;
-import com.fsck.k9.mail.store.UnavailableStorageException;
import com.fsck.k9.K9;
/**
@@ -333,7 +332,7 @@ public class MimeMessage extends Message {
return "<" + UUID.randomUUID().toString().toUpperCase(Locale.US) + "@" + hostname + ">";
}
- public void setMessageId(String messageId) throws UnavailableStorageException {
+ public void setMessageId(String messageId) throws MessagingException {
setHeader("Message-ID", messageId);
mMessageId = messageId;
}
@@ -419,27 +418,27 @@ public class MimeMessage extends Message {
}
@Override
- public void addHeader(String name, String value) throws UnavailableStorageException {
+ public void addHeader(String name, String value) throws MessagingException {
mHeader.addHeader(name, value);
}
@Override
- public void setHeader(String name, String value) throws UnavailableStorageException {
+ public void setHeader(String name, String value) throws MessagingException {
mHeader.setHeader(name, value);
}
@Override
- public String[] getHeader(String name) throws UnavailableStorageException {
+ public String[] getHeader(String name) throws MessagingException {
return mHeader.getHeader(name);
}
@Override
- public void removeHeader(String name) throws UnavailableStorageException {
+ public void removeHeader(String name) throws MessagingException {
mHeader.removeHeader(name);
}
@Override
- public Set getHeaderNames() throws UnavailableStorageException {
+ public Set getHeaderNames() throws MessagingException {
return mHeader.getHeaderNames();
}
diff --git a/src/com/fsck/k9/security/LocalKeyStore.java b/src/com/fsck/k9/mail/ssl/LocalKeyStore.java
similarity index 99%
rename from src/com/fsck/k9/security/LocalKeyStore.java
rename to src/com/fsck/k9/mail/ssl/LocalKeyStore.java
index d432ab294..7133be7b0 100644
--- a/src/com/fsck/k9/security/LocalKeyStore.java
+++ b/src/com/fsck/k9/mail/ssl/LocalKeyStore.java
@@ -1,4 +1,4 @@
-package com.fsck.k9.security;
+package com.fsck.k9.mail.ssl;
import java.io.File;
import java.io.FileInputStream;
diff --git a/src/com/fsck/k9/mail/ssl/TrustManagerFactory.java b/src/com/fsck/k9/mail/ssl/TrustManagerFactory.java
index c1956011c..f6841a2e3 100644
--- a/src/com/fsck/k9/mail/ssl/TrustManagerFactory.java
+++ b/src/com/fsck/k9/mail/ssl/TrustManagerFactory.java
@@ -4,7 +4,6 @@ package com.fsck.k9.mail.ssl;
import android.util.Log;
import com.fsck.k9.mail.CertificateChainException;
-import com.fsck.k9.security.LocalKeyStore;
import javax.net.ssl.SSLException;
import javax.net.ssl.TrustManager;
diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java
index b8be10039..051c29f2d 100644
--- a/src/com/fsck/k9/mail/store/ImapStore.java
+++ b/src/com/fsck/k9/mail/store/ImapStore.java
@@ -58,7 +58,6 @@ import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.R;
import com.fsck.k9.helper.UrlEncodingHelper;
-import com.fsck.k9.helper.Utility;
import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.AuthType;
@@ -71,7 +70,7 @@ import com.fsck.k9.mail.FetchProfile;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;
-import com.fsck.k9.mail.store.local.MessageRetrievalListener;
+import com.fsck.k9.mail.MessageRetrievalListener;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.PushReceiver;
@@ -88,7 +87,6 @@ import com.fsck.k9.mail.internet.MimeMultipart;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.store.ImapResponseParser.ImapList;
import com.fsck.k9.mail.store.ImapResponseParser.ImapResponse;
-import com.fsck.k9.mail.store.imap.ImapUtility;
import com.fsck.k9.mail.transport.imap.ImapSettings;
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
@@ -246,7 +244,7 @@ public class ImapStore extends RemoteStore {
*
* @return An ImapStore URI that holds the same information as the {@code server} parameter.
*
- * @see Account#getStoreUri()
+ * @see com.fsck.k9.mail.store.StoreConfig#getStoreUri()
* @see ImapStore#decodeUri(String)
*/
public static String createUri(ServerSettings server) {
@@ -1125,7 +1123,7 @@ public class ImapStore extends RemoteStore {
//TODO: Split this into multiple commands if the command exceeds a certain length.
List responses = executeSimpleCommand(String.format("UID COPY %s %s",
- Utility.combine(uids, ','),
+ combine(uids, ','),
remoteDestName));
// Get the tagged response for the UID COPY command
@@ -1332,7 +1330,7 @@ public class ImapStore extends RemoteStore {
ImapSearcher searcher = new ImapSearcher() {
@Override
public List search() throws IOException, MessagingException {
- return executeSimpleCommand(String.format("UID SEARCH %s%s", Utility.combine(mesgSeqs.toArray(), ','), includeDeleted ? "" : " NOT DELETED"));
+ return executeSimpleCommand(String.format("UID SEARCH %s%s", combine(mesgSeqs.toArray(), ','), includeDeleted ? "" : " NOT DELETED"));
}
};
return search(searcher, listener);
@@ -1343,7 +1341,7 @@ public class ImapStore extends RemoteStore {
ImapSearcher searcher = new ImapSearcher() {
@Override
public List search() throws IOException, MessagingException {
- return executeSimpleCommand(String.format("UID SEARCH UID %s%s", Utility.combine(mesgUids.toArray(), ','), includeDeleted ? "" : " NOT DELETED"));
+ return executeSimpleCommand(String.format("UID SEARCH UID %s%s", combine(mesgUids.toArray(), ','), includeDeleted ? "" : " NOT DELETED"));
}
};
return search(searcher, listener);
@@ -1483,8 +1481,8 @@ public class ImapStore extends RemoteStore {
try {
mConnection.sendCommand(String.format("UID FETCH %s (%s)",
- Utility.combine(uidWindow.toArray(new String[uidWindow.size()]), ','),
- Utility.combine(fetchFields.toArray(new String[fetchFields.size()]), ' ')
+ combine(uidWindow.toArray(new String[uidWindow.size()]), ','),
+ combine(fetchFields.toArray(new String[fetchFields.size()]), ' ')
), false);
ImapResponse response;
int messageNumber = 0;
@@ -2101,7 +2099,7 @@ public class ImapStore extends RemoteStore {
}
}
- return Utility.combine(flagNames.toArray(new String[flagNames.size()]), ' ');
+ return combine(flagNames.toArray(new String[flagNames.size()]), ' ');
}
@@ -2151,7 +2149,7 @@ public class ImapStore extends RemoteStore {
}
try {
executeSimpleCommand(String.format("UID STORE %s %sFLAGS.SILENT (%s)",
- Utility.combine(uids, ','),
+ combine(uids, ','),
value ? "+" : "-",
combineFlags(flags)));
} catch (IOException ioe) {
@@ -2701,7 +2699,7 @@ public class ImapStore extends RemoteStore {
try {
receiveCapabilities(executeSimpleCommand(
String.format("AUTHENTICATE EXTERNAL %s",
- Utility.base64Encode(mSettings.getUsername())), false));
+ Base64.encode(mSettings.getUsername())), false));
} catch (ImapException e) {
/*
* Provide notification to the user of a problem authenticating
@@ -3599,4 +3597,11 @@ public class ImapStore extends RemoteStore {
return null;
}
}
+
+ private static String combine(Object[] parts, char separator) {
+ if (parts == null) {
+ return null;
+ }
+ return TextUtils.join(String.valueOf(separator), parts);
+ }
}
diff --git a/src/com/fsck/k9/mail/store/imap/ImapUtility.java b/src/com/fsck/k9/mail/store/ImapUtility.java
similarity index 98%
rename from src/com/fsck/k9/mail/store/imap/ImapUtility.java
rename to src/com/fsck/k9/mail/store/ImapUtility.java
index 51d1aa070..971f098cd 100644
--- a/src/com/fsck/k9/mail/store/imap/ImapUtility.java
+++ b/src/com/fsck/k9/mail/store/ImapUtility.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.fsck.k9.mail.store.imap;
+package com.fsck.k9.mail.store;
import android.util.Log;
@@ -27,7 +27,7 @@ import java.util.List;
/**
* Utility methods for use with IMAP.
*/
-public class ImapUtility {
+class ImapUtility {
/**
* Gets all of the values in a sequence set per RFC 3501.
*
diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java
index 0871579b1..85c73f0f0 100644
--- a/src/com/fsck/k9/mail/store/Pop3Store.java
+++ b/src/com/fsck/k9/mail/store/Pop3Store.java
@@ -6,13 +6,12 @@ import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.R;
import com.fsck.k9.helper.UrlEncodingHelper;
-import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.*;
import com.fsck.k9.mail.filter.Base64;
import com.fsck.k9.mail.filter.Hex;
import com.fsck.k9.mail.internet.MimeMessage;
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
-import com.fsck.k9.mail.store.local.MessageRetrievalListener;
+import com.fsck.k9.mail.MessageRetrievalListener;
import javax.net.ssl.SSLException;
@@ -459,7 +458,7 @@ public class Pop3Store extends RemoteStore {
try {
executeSimpleCommand(
String.format("AUTH EXTERNAL %s",
- Utility.base64Encode(mUsername)), false);
+ Base64.encode(mUsername)), false);
} catch (Pop3ErrorResponse e) {
/*
* Provide notification to the user of a problem authenticating
diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java
index 300a68d18..a08d11cbe 100644
--- a/src/com/fsck/k9/mail/store/WebDavStore.java
+++ b/src/com/fsck/k9/mail/store/WebDavStore.java
@@ -5,11 +5,11 @@ import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.helper.UrlEncodingHelper;
-import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.*;
+import com.fsck.k9.mail.filter.Base64;
import com.fsck.k9.mail.filter.EOLConvertingOutputStream;
import com.fsck.k9.mail.internet.MimeMessage;
-import com.fsck.k9.mail.store.local.MessageRetrievalListener;
+import com.fsck.k9.mail.MessageRetrievalListener;
import org.apache.commons.io.IOUtils;
import org.apache.http.*;
@@ -339,7 +339,7 @@ public class WebDavStore extends RemoteStore {
// The inbox path would look like: "https://mail.domain.com/Exchange/alias/Inbox".
mUrl = getRoot() + mPath + mMailboxPath;
- mAuthString = "Basic " + Utility.base64Encode(mUsername + ":" + mPassword);
+ mAuthString = "Basic " + Base64.encode(mUsername + ":" + mPassword);
}
private String getRoot() {
diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java
index 4e7959f7f..6e30eab20 100644
--- a/src/com/fsck/k9/mail/transport/SmtpTransport.java
+++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java
@@ -3,20 +3,18 @@ package com.fsck.k9.mail.transport;
import android.util.Log;
-import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.R;
import com.fsck.k9.helper.UrlEncodingHelper;
-import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.*;
import com.fsck.k9.mail.Message.RecipientType;
+import com.fsck.k9.mail.filter.Base64;
import com.fsck.k9.mail.filter.EOLConvertingOutputStream;
import com.fsck.k9.mail.filter.LineWrapOutputStream;
import com.fsck.k9.mail.filter.PeekableInputStream;
import com.fsck.k9.mail.filter.SmtpDataStuffing;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.store.StoreConfig;
-import com.fsck.k9.mail.store.local.LocalMessage;
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
import javax.net.ssl.SSLException;
@@ -125,7 +123,7 @@ public class SmtpTransport extends Transport {
*
* @return A SmtpTransport URI that holds the same information as the {@code server} parameter.
*
- * @see Account#getTransportUri()
+ * @see com.fsck.k9.mail.store.StoreConfig#getTransportUri()
* @see SmtpTransport#decodeUri(String)
*/
public static String createUri(ServerSettings server) {
@@ -150,7 +148,7 @@ public class SmtpTransport extends Transport {
break;
}
- String userInfo = null;
+ String userInfo;
AuthType authType = server.authenticationType;
// NOTE: authType is append at last item, in contrast to ImapStore and Pop3Store!
if (authType != null) {
@@ -184,10 +182,10 @@ public class SmtpTransport extends Transport {
private boolean m8bitEncodingAllowed;
private int mLargestAcceptableMessage;
- public SmtpTransport(StoreConfig account) throws MessagingException {
+ public SmtpTransport(StoreConfig storeConfig) throws MessagingException {
ServerSettings settings;
try {
- settings = decodeUri(account.getTransportUri());
+ settings = decodeUri(storeConfig.getTransportUri());
} catch (IllegalArgumentException e) {
throw new MessagingException("Error while decoding transport URI", e);
}
@@ -496,7 +494,7 @@ public class SmtpTransport extends Transport {
}
// If the message has attachments and our server has told us about a limit on
// the size of messages, count the message's size before sending it
- if (mLargestAcceptableMessage > 0 && ((LocalMessage)message).hasAttachments()) {
+ if (mLargestAcceptableMessage > 0 && message.hasAttachments()) {
if (message.calculateSize() > mLargestAcceptableMessage) {
MessagingException me = new MessagingException("Message too large for server");
//TODO this looks rather suspicious... shouldn't it be true?
@@ -702,8 +700,8 @@ public class SmtpTransport extends Transport {
AuthenticationFailedException, IOException {
try {
executeSimpleCommand("AUTH LOGIN");
- executeSimpleCommand(Utility.base64Encode(username), true);
- executeSimpleCommand(Utility.base64Encode(password), true);
+ executeSimpleCommand(Base64.encode(username), true);
+ executeSimpleCommand(Base64.encode(password), true);
} catch (NegativeSmtpReplyException exception) {
if (exception.getReplyCode() == 535) {
// Authentication credentials invalid
@@ -717,7 +715,7 @@ public class SmtpTransport extends Transport {
private void saslAuthPlain(String username, String password) throws MessagingException,
AuthenticationFailedException, IOException {
- String data = Utility.base64Encode("\000" + username + "\000" + password);
+ String data = Base64.encode("\000" + username + "\000" + password);
try {
executeSimpleCommand("AUTH PLAIN " + data, true);
} catch (NegativeSmtpReplyException exception) {
@@ -757,7 +755,7 @@ public class SmtpTransport extends Transport {
private void saslAuthExternal(String username) throws MessagingException, IOException {
executeSimpleCommand(
String.format("AUTH EXTERNAL %s",
- Utility.base64Encode(username)), false);
+ Base64.encode(username)), false);
}
/**
diff --git a/src/com/fsck/k9/preferences/AccountSettings.java b/src/com/fsck/k9/preferences/AccountSettings.java
index c2b6b4983..327ff38b2 100644
--- a/src/com/fsck/k9/preferences/AccountSettings.java
+++ b/src/com/fsck/k9/preferences/AccountSettings.java
@@ -13,7 +13,7 @@ import com.fsck.k9.Account.SortType;
import com.fsck.k9.K9;
import com.fsck.k9.R;
import com.fsck.k9.Account.FolderMode;
-import com.fsck.k9.mail.store.StorageManager;
+import com.fsck.k9.local.StorageManager;
import com.fsck.k9.preferences.Settings.*;
public class AccountSettings {
diff --git a/src/com/fsck/k9/preferences/SettingsImporter.java b/src/com/fsck/k9/preferences/SettingsImporter.java
index 1a7af8d26..1d05cf9dc 100644
--- a/src/com/fsck/k9/preferences/SettingsImporter.java
+++ b/src/com/fsck/k9/preferences/SettingsImporter.java
@@ -22,11 +22,11 @@ import com.fsck.k9.Account;
import com.fsck.k9.Identity;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
-import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.ServerSettings;
import com.fsck.k9.mail.Transport;
+import com.fsck.k9.mail.filter.Base64;
import com.fsck.k9.mail.store.RemoteStore;
import com.fsck.k9.mail.store.WebDavStore;
import com.fsck.k9.preferences.Settings.InvalidSettingValueException;
@@ -377,7 +377,7 @@ public class SettingsImporter {
// Write incoming server settings (storeUri)
ServerSettings incoming = new ImportedServerSettings(account.incoming);
String storeUri = RemoteStore.createStoreUri(incoming);
- putString(editor, accountKeyPrefix + Account.STORE_URI_KEY, Utility.base64Encode(storeUri));
+ putString(editor, accountKeyPrefix + Account.STORE_URI_KEY, Base64.encode(storeUri));
// Mark account as disabled if the AuthType isn't EXTERNAL and the
// settings file didn't contain a password
@@ -393,7 +393,7 @@ public class SettingsImporter {
// Write outgoing server settings (transportUri)
ServerSettings outgoing = new ImportedServerSettings(account.outgoing);
String transportUri = Transport.createTransportUri(outgoing);
- putString(editor, accountKeyPrefix + Account.TRANSPORT_URI_KEY, Utility.base64Encode(transportUri));
+ putString(editor, accountKeyPrefix + Account.TRANSPORT_URI_KEY, Base64.encode(transportUri));
/*
* Mark account as disabled if the settings file contained a
diff --git a/src/com/fsck/k9/preferences/Storage.java b/src/com/fsck/k9/preferences/Storage.java
index 88260f7ff..1303fc8e9 100644
--- a/src/com/fsck/k9/preferences/Storage.java
+++ b/src/com/fsck/k9/preferences/Storage.java
@@ -11,9 +11,9 @@ import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.helper.UrlEncodingHelper;
import com.fsck.k9.helper.Utility;
+import com.fsck.k9.mail.filter.Base64;
import java.net.URI;
-import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -54,8 +54,8 @@ public class Storage implements SharedPreferences {
String[] uuids = accountUuids.split(",");
for (String uuid : uuids) {
try {
- String storeUriStr = Utility.base64Decode(readValue(mDb, uuid + ".storeUri"));
- String transportUriStr = Utility.base64Decode(readValue(mDb, uuid + ".transportUri"));
+ String storeUriStr = Base64.decode(readValue(mDb, uuid + ".storeUri"));
+ String transportUriStr = Base64.decode(readValue(mDb, uuid + ".transportUri"));
URI uri = new URI(transportUriStr);
String newUserInfo = null;
@@ -77,7 +77,7 @@ public class Storage implements SharedPreferences {
if (newUserInfo != null) {
URI newUri = new URI(uri.getScheme(), newUserInfo, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
- String newTransportUriStr = Utility.base64Encode(newUri.toString());
+ String newTransportUriStr = Base64.encode(newUri.toString());
writeValue(mDb, uuid + ".transportUri", newTransportUriStr);
}
@@ -121,7 +121,7 @@ public class Storage implements SharedPreferences {
if (newUserInfo != null) {
URI newUri = new URI(uri.getScheme(), newUserInfo, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
- String newStoreUriStr = Utility.base64Encode(newUri.toString());
+ String newStoreUriStr = Base64.encode(newUri.toString());
writeValue(mDb, uuid + ".storeUri", newStoreUriStr);
}
} catch (Exception e) {
diff --git a/src/com/fsck/k9/provider/AttachmentProvider.java b/src/com/fsck/k9/provider/AttachmentProvider.java
index bfcdaac9b..792c8885f 100644
--- a/src/com/fsck/k9/provider/AttachmentProvider.java
+++ b/src/com/fsck/k9/provider/AttachmentProvider.java
@@ -15,9 +15,9 @@ import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.MimeUtility;
-import com.fsck.k9.mail.store.local.LocalStore;
-import com.fsck.k9.mail.store.local.LocalStore.AttachmentInfo;
-import com.fsck.k9.mail.store.StorageManager;
+import com.fsck.k9.local.LocalStore;
+import com.fsck.k9.local.LocalStore.AttachmentInfo;
+import com.fsck.k9.local.StorageManager;
import java.io.*;
import java.util.List;
diff --git a/src/com/fsck/k9/provider/EmailProvider.java b/src/com/fsck/k9/provider/EmailProvider.java
index 0164ce4ec..fb025f46c 100644
--- a/src/com/fsck/k9/provider/EmailProvider.java
+++ b/src/com/fsck/k9/provider/EmailProvider.java
@@ -10,11 +10,11 @@ import com.fsck.k9.Preferences;
import com.fsck.k9.cache.EmailProviderCacheCursor;
import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.MessagingException;
-import com.fsck.k9.mail.store.local.LockableDatabase;
-import com.fsck.k9.mail.store.local.LockableDatabase.DbCallback;
-import com.fsck.k9.mail.store.local.LockableDatabase.WrappedException;
-import com.fsck.k9.mail.store.UnavailableStorageException;
-import com.fsck.k9.mail.store.local.LocalStore;
+import com.fsck.k9.local.LockableDatabase;
+import com.fsck.k9.local.LockableDatabase.DbCallback;
+import com.fsck.k9.local.LockableDatabase.WrappedException;
+import com.fsck.k9.local.UnavailableStorageException;
+import com.fsck.k9.local.LocalStore;
import com.fsck.k9.search.SqlQueryBuilder;
import android.content.ContentProvider;
@@ -357,6 +357,8 @@ public class EmailProvider extends ContentProvider {
});
} catch (UnavailableStorageException e) {
throw new RuntimeException("Storage not available", e);
+ } catch (MessagingException e) {
+ throw new RuntimeException("messaging exception", e);
}
}
@@ -427,6 +429,8 @@ public class EmailProvider extends ContentProvider {
});
} catch (UnavailableStorageException e) {
throw new RuntimeException("Storage not available", e);
+ } catch (MessagingException e) {
+ throw new RuntimeException("messaging exception", e);
}
}
@@ -532,7 +536,10 @@ public class EmailProvider extends ContentProvider {
});
} catch (UnavailableStorageException e) {
throw new RuntimeException("Storage not available", e);
+ } catch (MessagingException e) {
+ throw new RuntimeException("messaging exception", e);
}
+
}
private Cursor getAccountStats(String accountUuid, String[] columns,
@@ -594,7 +601,10 @@ public class EmailProvider extends ContentProvider {
});
} catch (UnavailableStorageException e) {
throw new RuntimeException("Storage not available", e);
+ } catch (MessagingException e) {
+ throw new RuntimeException("messaging exception", e);
}
+
}
private Account getAccount(String accountUuid) {
diff --git a/src/com/fsck/k9/provider/MessageProvider.java b/src/com/fsck/k9/provider/MessageProvider.java
index c75f017df..a02bf5520 100644
--- a/src/com/fsck/k9/provider/MessageProvider.java
+++ b/src/com/fsck/k9/provider/MessageProvider.java
@@ -32,9 +32,9 @@ import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
-import com.fsck.k9.mail.store.local.LocalFolder;
-import com.fsck.k9.mail.store.local.LocalMessage;
-import com.fsck.k9.mail.store.local.LocalStore;
+import com.fsck.k9.local.LocalFolder;
+import com.fsck.k9.local.LocalMessage;
+import com.fsck.k9.local.LocalStore;
import com.fsck.k9.search.SearchAccount;
import java.lang.ref.WeakReference;
diff --git a/src/com/fsck/k9/search/SqlQueryBuilder.java b/src/com/fsck/k9/search/SqlQueryBuilder.java
index 1b6ecf6a2..8286f5d9e 100644
--- a/src/com/fsck/k9/search/SqlQueryBuilder.java
+++ b/src/com/fsck/k9/search/SqlQueryBuilder.java
@@ -5,8 +5,8 @@ import java.util.List;
import com.fsck.k9.Account;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Folder;
-import com.fsck.k9.mail.store.local.LocalFolder;
-import com.fsck.k9.mail.store.local.LocalStore;
+import com.fsck.k9.local.LocalFolder;
+import com.fsck.k9.local.LocalStore;
import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchCondition;
import com.fsck.k9.search.SearchSpecification.Searchfield;
diff --git a/src/com/fsck/k9/service/DatabaseUpgradeService.java b/src/com/fsck/k9/service/DatabaseUpgradeService.java
index ee5b9b26b..15f0e16f1 100644
--- a/src/com/fsck/k9/service/DatabaseUpgradeService.java
+++ b/src/com/fsck/k9/service/DatabaseUpgradeService.java
@@ -17,7 +17,7 @@ import com.fsck.k9.Preferences;
import com.fsck.k9.activity.UpgradeDatabases;
import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
-import com.fsck.k9.mail.store.UnavailableStorageException;
+import com.fsck.k9.local.UnavailableStorageException;
/**
* Service used to upgrade the accounts' databases and/or track the progress of the upgrade.
diff --git a/src/com/fsck/k9/service/NotificationActionService.java b/src/com/fsck/k9/service/NotificationActionService.java
index 079222e69..96d3cf705 100644
--- a/src/com/fsck/k9/service/NotificationActionService.java
+++ b/src/com/fsck/k9/service/NotificationActionService.java
@@ -11,8 +11,7 @@ import com.fsck.k9.activity.MessageCompose;
import com.fsck.k9.activity.MessageReference;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.mail.Flag;
-import com.fsck.k9.mail.Message;
-import com.fsck.k9.mail.store.local.LocalMessage;
+import com.fsck.k9.local.LocalMessage;
import android.app.PendingIntent;
import android.content.Context;
diff --git a/src/com/fsck/k9/service/StorageGoneReceiver.java b/src/com/fsck/k9/service/StorageGoneReceiver.java
index 43f9e49d7..022ae9b9c 100644
--- a/src/com/fsck/k9/service/StorageGoneReceiver.java
+++ b/src/com/fsck/k9/service/StorageGoneReceiver.java
@@ -7,7 +7,7 @@ import android.net.Uri;
import android.util.Log;
import com.fsck.k9.K9;
-import com.fsck.k9.mail.store.StorageManager;
+import com.fsck.k9.local.StorageManager;
/**
* That BroadcastReceiver is only interested in UNMOUNT events.
diff --git a/src/com/fsck/k9/service/StorageReceiver.java b/src/com/fsck/k9/service/StorageReceiver.java
index 515750be4..1cf116dd6 100644
--- a/src/com/fsck/k9/service/StorageReceiver.java
+++ b/src/com/fsck/k9/service/StorageReceiver.java
@@ -7,7 +7,7 @@ import android.net.Uri;
import android.util.Log;
import com.fsck.k9.K9;
-import com.fsck.k9.mail.store.StorageManager;
+import com.fsck.k9.local.StorageManager;
/**
* That BroadcastReceiver is only interested in MOUNT events.
diff --git a/src/com/fsck/k9/view/AttachmentView.java b/src/com/fsck/k9/view/AttachmentView.java
index ea917f334..84d0d9ff8 100644
--- a/src/com/fsck/k9/view/AttachmentView.java
+++ b/src/com/fsck/k9/view/AttachmentView.java
@@ -43,7 +43,7 @@ import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.internet.MimeHeader;
import com.fsck.k9.mail.internet.MimeUtility;
-import com.fsck.k9.mail.store.local.LocalAttachmentBodyPart;
+import com.fsck.k9.local.LocalAttachmentBodyPart;
import com.fsck.k9.provider.AttachmentProvider;
import org.apache.commons.io.IOUtils;
diff --git a/src/com/fsck/k9/view/SingleMessageView.java b/src/com/fsck/k9/view/SingleMessageView.java
index a351e7921..4747415ef 100644
--- a/src/com/fsck/k9/view/SingleMessageView.java
+++ b/src/com/fsck/k9/view/SingleMessageView.java
@@ -56,8 +56,8 @@ import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.internet.MimeUtility;
-import com.fsck.k9.mail.store.local.LocalAttachmentBodyPart;
-import com.fsck.k9.mail.store.local.LocalMessage;
+import com.fsck.k9.local.LocalAttachmentBodyPart;
+import com.fsck.k9.local.LocalMessage;
import com.fsck.k9.provider.AttachmentProvider.AttachmentProviderColumns;
import org.apache.commons.io.IOUtils;
diff --git a/tests/src/com/fsck/k9/helper/Address.java b/tests/src/com/fsck/k9/mail/AddressTest.java
similarity index 74%
rename from tests/src/com/fsck/k9/helper/Address.java
rename to tests/src/com/fsck/k9/mail/AddressTest.java
index 250cad347..e1a3778e1 100644
--- a/tests/src/com/fsck/k9/helper/Address.java
+++ b/tests/src/com/fsck/k9/mail/AddressTest.java
@@ -1,14 +1,14 @@
-package com.fsck.k9.helper;
+package com.fsck.k9.mail;
import junit.framework.TestCase;
-public class Address extends TestCase {
+public class AddressTest extends TestCase {
/**
* test the possibility to parse "From:" fields with no email.
* for example: From: News for Vector Limited - Google Finance
* http://code.google.com/p/k9mail/issues/detail?id=3814
*/
public void testParseWithMissingEmail() {
- com.fsck.k9.mail.Address[] addresses = com.fsck.k9.mail.Address.parse("NAME ONLY");
+ Address[] addresses = Address.parse("NAME ONLY");
assertEquals(1, addresses.length);
assertEquals(null, addresses[0].getAddress());
assertEquals("NAME ONLY", addresses[0].getPersonal());
@@ -18,7 +18,7 @@ public class Address extends TestCase {
* test name + valid email
*/
public void testPraseWithValidEmail() {
- com.fsck.k9.mail.Address[] addresses = com.fsck.k9.mail.Address.parse("Max Mustermann ");
+ Address[] addresses = Address.parse("Max Mustermann ");
assertEquals(1, addresses.length);
assertEquals("maxmuster@mann.com", addresses[0].getAddress());
assertEquals("Max Mustermann", addresses[0].getPersonal());
@@ -27,7 +27,7 @@ public class Address extends TestCase {
* test with multi email addresses
*/
public void testPraseWithValidEmailMulti() {
- com.fsck.k9.mail.Address[] addresses = com.fsck.k9.mail.Address.parse("lorem@ipsum.us,mark@twain.com");
+ Address[] addresses = Address.parse("lorem@ipsum.us,mark@twain.com");
assertEquals(2, addresses.length);
assertEquals("lorem@ipsum.us", addresses[0].getAddress());
assertEquals(null, addresses[0].getPersonal());
diff --git a/tests/src/com/fsck/k9/helper/Utility_quoteAtoms.java b/tests/src/com/fsck/k9/mail/Address_quoteAtoms.java
similarity index 87%
rename from tests/src/com/fsck/k9/helper/Utility_quoteAtoms.java
rename to tests/src/com/fsck/k9/mail/Address_quoteAtoms.java
index 372c5c0f4..0ea553b2e 100644
--- a/tests/src/com/fsck/k9/helper/Utility_quoteAtoms.java
+++ b/tests/src/com/fsck/k9/mail/Address_quoteAtoms.java
@@ -1,8 +1,8 @@
-package com.fsck.k9.helper;
+package com.fsck.k9.mail;
import junit.framework.TestCase;
-public class Utility_quoteAtoms extends TestCase
+public class Address_quoteAtoms extends TestCase
{
public void testNoQuote() {
// Alpha
@@ -53,10 +53,10 @@ public class Utility_quoteAtoms extends TestCase
}
private void noQuote(final String s) {
- assertEquals(s, Utility.quoteAtoms(s));
+ assertEquals(s, Address.quoteAtoms(s));
}
private String quote(final String s) {
- return Utility.quoteAtoms(s);
+ return Address.quoteAtoms(s);
}
}
diff --git a/tests/src/com/fsck/k9/mail/ssl/TrustManagerFactoryTest.java b/tests/src/com/fsck/k9/mail/ssl/TrustManagerFactoryTest.java
index 14da17b7f..1574aaf03 100644
--- a/tests/src/com/fsck/k9/mail/ssl/TrustManagerFactoryTest.java
+++ b/tests/src/com/fsck/k9/mail/ssl/TrustManagerFactoryTest.java
@@ -2,9 +2,6 @@ package com.fsck.k9.mail.ssl;
import javax.net.ssl.X509TrustManager;
-import com.fsck.k9.mail.ssl.TrustManagerFactory;
-import com.fsck.k9.security.LocalKeyStore;
-
import java.io.ByteArrayInputStream;
import java.io.File;
import java.security.cert.CertificateException;
diff --git a/tests/src/com/fsck/k9/mail/store/imap/ImapUtilityTest.java b/tests/src/com/fsck/k9/mail/store/ImapUtilityTest.java
similarity index 99%
rename from tests/src/com/fsck/k9/mail/store/imap/ImapUtilityTest.java
rename to tests/src/com/fsck/k9/mail/store/ImapUtilityTest.java
index feaef05e8..392fdc554 100644
--- a/tests/src/com/fsck/k9/mail/store/imap/ImapUtilityTest.java
+++ b/tests/src/com/fsck/k9/mail/store/ImapUtilityTest.java
@@ -15,10 +15,11 @@
* limitations under the License.
*/
-package com.fsck.k9.mail.store.imap;
+package com.fsck.k9.mail.store;
import java.util.List;
import android.test.MoreAsserts;
+
import junit.framework.TestCase;
public class ImapUtilityTest extends TestCase {