1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Move local message code to local package

+ cut some helper dependencies
This commit is contained in:
Jan Berkel 2014-12-12 15:02:59 +00:00
parent 2e98ff56e5
commit 40041ac0e0
75 changed files with 352 additions and 420 deletions

View File

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

View File

@ -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();
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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()));
}
}

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ import android.widget.TextView;
* <li>{@link #actionUpgradeDatabases(Context, Intent)} will call {@link K9#areDatabasesUpToDate()}
* to check if we already know whether the databases have been upgraded.</li>
* <li>{@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.</li>
* <li>If there was an error reading the cached database version or if it shows the databases need

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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)}.<br/>
* An {@link com.fsck.k9.Account} is not
* {@link com.fsck.k9.Account#isAvailable(android.content.Context)}.<br/>
* The operation may be retried later.
*/
public class UnavailableAccountException extends RuntimeException {

View File

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

View File

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

View File

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

View File

@ -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$\\-_.+!*'(),%:@&=]*)?";
}

View File

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

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store.local;
package com.fsck.k9.local;
import java.io.IOException;
import java.io.InputStream;

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store.local;
package com.fsck.k9.local;
import java.io.IOException;
import java.io.InputStream;

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store.local;
package com.fsck.k9.local;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;

View File

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

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store.local;
package com.fsck.k9.local;
import java.io.IOException;
import java.io.OutputStream;

View File

@ -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<LocalMessage> implements Serializable {
@ -828,10 +827,10 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
* The messages whose headers should be loaded.
* @throws UnavailableStorageException
*/
void populateHeaders(final List<LocalMessage> messages) throws UnavailableStorageException {
void populateHeaders(final List<LocalMessage> messages) throws MessagingException {
this.localStore.database.execute(false, new DbCallback<Void>() {
@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<LocalMessage> implements Serializable {
private void saveHeaders(final long id, final MimeMessage message) throws MessagingException {
this.localStore.database.execute(true, new DbCallback<Void>() {
@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<LocalMessage> implements Serializable {
});
}
void deleteHeaders(final long id) throws UnavailableStorageException {
void deleteHeaders(final long id) throws MessagingException {
this.localStore.database.execute(false, new DbCallback<Void>() {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {

View File

@ -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<LocalMessage> messages = new ArrayList<LocalMessage>();
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<String> getHeaderNames() throws UnavailableStorageException {
public Set<String> getHeaderNames() throws MessagingException {
if (!mHeadersLoaded)
loadHeaders();
return super.getHeaderNames();

View File

@ -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<Void>() {
@ -499,7 +498,7 @@ public class LocalStore extends Store implements Serializable {
});
}
public List<PendingCommand> getPendingCommands() throws UnavailableStorageException {
public List<PendingCommand> getPendingCommands() throws MessagingException {
return database.execute(false, new DbCallback<List<PendingCommand>>() {
@Override
public List<PendingCommand> 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<Void>() {
@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<Void>() {
@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<AttachmentInfo>() {
@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<LocalFolder> foldersToCreate, final int visibleLimit) throws UnavailableStorageException {
public void createFolders(final List<LocalFolder> foldersToCreate, final int visibleLimit) throws MessagingException {
database.execute(true, new DbCallback<Void>() {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store.local;
package com.fsck.k9.local;
import com.fsck.k9.mail.internet.TextBody;

View File

@ -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 {
* <code>null</code>.
* @return Any relevant data. Can be <code>null</code>.
* @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> T execute(final boolean transactional, final DbCallback<T> callback) throws UnavailableStorageException {
public <T> T execute(final boolean transactional, final DbCallback<T> callback) throws MessagingException {
lockRead();
final boolean doTransaction = transactional && inTransaction.get() == null;
try {

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store.local;
package com.fsck.k9.local;
import com.fsck.k9.mail.Message;

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store;
package com.fsck.k9.local;
import java.io.File;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store.local;
package com.fsck.k9.local;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store.local;
package com.fsck.k9.local;
import java.io.ByteArrayInputStream;
import java.io.File;

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store.local;
package com.fsck.k9.local;
import java.io.IOException;
import java.io.OutputStream;

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store.local;
package com.fsck.k9.local;
class ThreadInfo {
public final long threadId;

View File

@ -1,4 +1,4 @@
package com.fsck.k9.mail.store;
package com.fsck.k9.local;
import com.fsck.k9.mail.MessagingException;

View File

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

View File

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

View File

@ -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<T extends Message> {
private String status = null;

View File

@ -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<String> getHeaderNames() throws UnavailableStorageException;
@Override
public abstract void removeHeader(String name) throws MessagingException;
@Override
public abstract void setBody(Body body) throws MessagingException;
public abstract Set<String> 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;
}

View File

@ -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<T extends Message> {
public void messageStarted(String uid, int number, int ofTotal);

View File

@ -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.
* </p>
*
* @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 {
/**

View File

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

View File

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

View File

@ -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, "<a href=\"$0\">$0</a>");
String prepared = text.replaceAll(BITCOIN_URI_PATTERN, "<a href=\"$0\">$0</a>");
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) != '@')) {

View File

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

View File

@ -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<String> getHeaderNames() throws UnavailableStorageException {
public Set<String> getHeaderNames() throws MessagingException {
return mHeader.getHeaderNames();
}

View File

@ -1,4 +1,4 @@
package com.fsck.k9.security;
package com.fsck.k9.mail.ssl;
import java.io.File;
import java.io.FileInputStream;

View File

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

View File

@ -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<ImapResponse> 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<ImapResponse> 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<ImapResponse> 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);
}
}

View File

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

View File

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

View File

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

View File

@ -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);
}
/**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <maxmuster@mann.com>");
Address[] addresses = Address.parse("Max Mustermann <maxmuster@mann.com>");
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());

View File

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

View File

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

View File

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