1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-01-11 13:49:15 -05:00

Renamed StorageExporter to SettingsExporter

This commit is contained in:
cketti 2011-10-14 05:58:15 +02:00
parent 0ae176bab3
commit cf8bdef0a8
4 changed files with 55 additions and 55 deletions

View File

@ -72,7 +72,7 @@ import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.store.StorageManager; import com.fsck.k9.mail.store.StorageManager;
import com.fsck.k9.view.ColorChip; import com.fsck.k9.view.ColorChip;
import com.fsck.k9.preferences.StorageExporter; import com.fsck.k9.preferences.SettingsExporter;
import com.fsck.k9.preferences.StorageImportExportException; import com.fsck.k9.preferences.StorageImportExportException;
import com.fsck.k9.preferences.StorageImporter; import com.fsck.k9.preferences.StorageImporter;
import com.fsck.k9.preferences.StorageImporter.AccountDescription; import com.fsck.k9.preferences.StorageImporter.AccountDescription;
@ -1320,7 +1320,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
@Override @Override
protected Boolean doInBackground(Void... params) { protected Boolean doInBackground(Void... params) {
try { try {
mFileName = StorageExporter.exportToFile(mContext, mIncludeGlobals, mFileName = SettingsExporter.exportToFile(mContext, mIncludeGlobals,
mAccountUuids); mAccountUuids);
} catch (StorageImportExportException e) { } catch (StorageImportExportException e) {
Log.w(K9.LOG_TAG, "Exception during export", e); Log.w(K9.LOG_TAG, "Exception during export", e);
@ -1449,7 +1449,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
ContentResolver resolver = mContext.getContentResolver(); ContentResolver resolver = mContext.getContentResolver();
InputStream is = resolver.openInputStream(mUri); InputStream is = resolver.openInputStream(mUri);
try { try {
mImportContents = StorageImporter.getImportStreamContents(mContext, is); mImportContents = StorageImporter.getImportStreamContents(is);
} finally { } finally {
try { try {
is.close(); is.close();

View File

@ -30,7 +30,7 @@ public class Settings {
* is changed (e.g. add a value to an enum). * is changed (e.g. add a value to an enum).
* </p> * </p>
* *
* @see StorageExporter * @see SettingsExporter
*/ */
public static final int VERSION = 1; public static final int VERSION = 1;

View File

@ -31,7 +31,7 @@ import com.fsck.k9.preferences.Settings.InvalidSettingValueException;
import com.fsck.k9.preferences.Settings.SettingsDescription; import com.fsck.k9.preferences.Settings.SettingsDescription;
public class StorageExporter { public class SettingsExporter {
private static final String EXPORT_FILENAME = "settings.k9s"; private static final String EXPORT_FILENAME = "settings.k9s";
/** /**

View File

@ -596,7 +596,7 @@ public class StorageImporter {
int eventType = xpp.getEventType(); int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) { while (eventType != XmlPullParser.END_DOCUMENT) {
if(eventType == XmlPullParser.START_TAG) { if(eventType == XmlPullParser.START_TAG) {
if (StorageExporter.ROOT_ELEMENT.equals(xpp.getName())) { if (SettingsExporter.ROOT_ELEMENT.equals(xpp.getName())) {
imported = parseRoot(xpp, globalSettings, accountUuids, overview); imported = parseRoot(xpp, globalSettings, accountUuids, overview);
} else { } else {
Log.w(K9.LOG_TAG, "Unexpected start tag: " + xpp.getName()); Log.w(K9.LOG_TAG, "Unexpected start tag: " + xpp.getName());
@ -645,28 +645,28 @@ public class StorageImporter {
int eventType = xpp.next(); int eventType = xpp.next();
while (!(eventType == XmlPullParser.END_TAG && while (!(eventType == XmlPullParser.END_TAG &&
StorageExporter.ROOT_ELEMENT.equals(xpp.getName()))) { SettingsExporter.ROOT_ELEMENT.equals(xpp.getName()))) {
if(eventType == XmlPullParser.START_TAG) { if(eventType == XmlPullParser.START_TAG) {
String element = xpp.getName(); String element = xpp.getName();
if (StorageExporter.GLOBAL_ELEMENT.equals(element)) { if (SettingsExporter.GLOBAL_ELEMENT.equals(element)) {
if (overview || globalSettings) { if (overview || globalSettings) {
if (result.globalSettings == null) { if (result.globalSettings == null) {
if (overview) { if (overview) {
result.globalSettings = new ImportedSettings(); result.globalSettings = new ImportedSettings();
skipToEndTag(xpp, StorageExporter.GLOBAL_ELEMENT); skipToEndTag(xpp, SettingsExporter.GLOBAL_ELEMENT);
} else { } else {
result.globalSettings = parseSettings(xpp, StorageExporter.GLOBAL_ELEMENT); result.globalSettings = parseSettings(xpp, SettingsExporter.GLOBAL_ELEMENT);
} }
} else { } else {
skipToEndTag(xpp, StorageExporter.GLOBAL_ELEMENT); skipToEndTag(xpp, SettingsExporter.GLOBAL_ELEMENT);
Log.w(K9.LOG_TAG, "More than one global settings element. Only using the first one!"); Log.w(K9.LOG_TAG, "More than one global settings element. Only using the first one!");
} }
} else { } else {
skipToEndTag(xpp, StorageExporter.GLOBAL_ELEMENT); skipToEndTag(xpp, SettingsExporter.GLOBAL_ELEMENT);
Log.i(K9.LOG_TAG, "Skipping global settings"); Log.i(K9.LOG_TAG, "Skipping global settings");
} }
} else if (StorageExporter.ACCOUNTS_ELEMENT.equals(element)) { } else if (SettingsExporter.ACCOUNTS_ELEMENT.equals(element)) {
if (result.accounts == null) { if (result.accounts == null) {
result.accounts = parseAccounts(xpp, accountUuids, overview); result.accounts = parseAccounts(xpp, accountUuids, overview);
} else { } else {
@ -692,8 +692,8 @@ public class StorageImporter {
if(eventType == XmlPullParser.START_TAG) { if(eventType == XmlPullParser.START_TAG) {
String element = xpp.getName(); String element = xpp.getName();
if (StorageExporter.VALUE_ELEMENT.equals(element)) { if (SettingsExporter.VALUE_ELEMENT.equals(element)) {
String key = xpp.getAttributeValue(null, StorageExporter.KEY_ATTRIBUTE); String key = xpp.getAttributeValue(null, SettingsExporter.KEY_ATTRIBUTE);
String value = getText(xpp); String value = getText(xpp);
if (result == null) { if (result == null) {
@ -723,11 +723,11 @@ public class StorageImporter {
int eventType = xpp.next(); int eventType = xpp.next();
while (!(eventType == XmlPullParser.END_TAG && while (!(eventType == XmlPullParser.END_TAG &&
StorageExporter.ACCOUNTS_ELEMENT.equals(xpp.getName()))) { SettingsExporter.ACCOUNTS_ELEMENT.equals(xpp.getName()))) {
if(eventType == XmlPullParser.START_TAG) { if(eventType == XmlPullParser.START_TAG) {
String element = xpp.getName(); String element = xpp.getName();
if (StorageExporter.ACCOUNT_ELEMENT.equals(element)) { if (SettingsExporter.ACCOUNT_ELEMENT.equals(element)) {
if (accounts == null) { if (accounts == null) {
accounts = new HashMap<String, ImportedAccount>(); accounts = new HashMap<String, ImportedAccount>();
} }
@ -756,45 +756,45 @@ public class StorageImporter {
ImportedAccount account = new ImportedAccount(); ImportedAccount account = new ImportedAccount();
String uuid = xpp.getAttributeValue(null, StorageExporter.UUID_ATTRIBUTE); String uuid = xpp.getAttributeValue(null, SettingsExporter.UUID_ATTRIBUTE);
account.uuid = uuid; account.uuid = uuid;
if (overview || accountUuids.contains(uuid)) { if (overview || accountUuids.contains(uuid)) {
int eventType = xpp.next(); int eventType = xpp.next();
while (!(eventType == XmlPullParser.END_TAG && while (!(eventType == XmlPullParser.END_TAG &&
StorageExporter.ACCOUNT_ELEMENT.equals(xpp.getName()))) { SettingsExporter.ACCOUNT_ELEMENT.equals(xpp.getName()))) {
if(eventType == XmlPullParser.START_TAG) { if(eventType == XmlPullParser.START_TAG) {
String element = xpp.getName(); String element = xpp.getName();
if (StorageExporter.NAME_ELEMENT.equals(element)) { if (SettingsExporter.NAME_ELEMENT.equals(element)) {
account.name = getText(xpp); account.name = getText(xpp);
} else if (StorageExporter.INCOMING_SERVER_ELEMENT.equals(element)) { } else if (SettingsExporter.INCOMING_SERVER_ELEMENT.equals(element)) {
if (overview) { if (overview) {
skipToEndTag(xpp, StorageExporter.INCOMING_SERVER_ELEMENT); skipToEndTag(xpp, SettingsExporter.INCOMING_SERVER_ELEMENT);
} else { } else {
account.incoming = parseServerSettings(xpp, StorageExporter.INCOMING_SERVER_ELEMENT); account.incoming = parseServerSettings(xpp, SettingsExporter.INCOMING_SERVER_ELEMENT);
} }
} else if (StorageExporter.OUTGOING_SERVER_ELEMENT.equals(element)) { } else if (SettingsExporter.OUTGOING_SERVER_ELEMENT.equals(element)) {
if (overview) { if (overview) {
skipToEndTag(xpp, StorageExporter.OUTGOING_SERVER_ELEMENT); skipToEndTag(xpp, SettingsExporter.OUTGOING_SERVER_ELEMENT);
} else { } else {
account.outgoing = parseServerSettings(xpp, StorageExporter.OUTGOING_SERVER_ELEMENT); account.outgoing = parseServerSettings(xpp, SettingsExporter.OUTGOING_SERVER_ELEMENT);
} }
} else if (StorageExporter.SETTINGS_ELEMENT.equals(element)) { } else if (SettingsExporter.SETTINGS_ELEMENT.equals(element)) {
if (overview) { if (overview) {
skipToEndTag(xpp, StorageExporter.SETTINGS_ELEMENT); skipToEndTag(xpp, SettingsExporter.SETTINGS_ELEMENT);
} else { } else {
account.settings = parseSettings(xpp, StorageExporter.SETTINGS_ELEMENT); account.settings = parseSettings(xpp, SettingsExporter.SETTINGS_ELEMENT);
} }
} else if (StorageExporter.IDENTITIES_ELEMENT.equals(element)) { } else if (SettingsExporter.IDENTITIES_ELEMENT.equals(element)) {
if (overview) { if (overview) {
skipToEndTag(xpp, StorageExporter.IDENTITIES_ELEMENT); skipToEndTag(xpp, SettingsExporter.IDENTITIES_ELEMENT);
} else { } else {
account.identities = parseIdentities(xpp); account.identities = parseIdentities(xpp);
} }
} else if (StorageExporter.FOLDERS_ELEMENT.equals(element)) { } else if (SettingsExporter.FOLDERS_ELEMENT.equals(element)) {
if (overview) { if (overview) {
skipToEndTag(xpp, StorageExporter.FOLDERS_ELEMENT); skipToEndTag(xpp, SettingsExporter.FOLDERS_ELEMENT);
} else { } else {
account.folders = parseFolders(xpp); account.folders = parseFolders(xpp);
} }
@ -805,7 +805,7 @@ public class StorageImporter {
eventType = xpp.next(); eventType = xpp.next();
} }
} else { } else {
skipToEndTag(xpp, StorageExporter.ACCOUNT_ELEMENT); skipToEndTag(xpp, SettingsExporter.ACCOUNT_ELEMENT);
Log.i(K9.LOG_TAG, "Skipping account with UUID " + uuid); Log.i(K9.LOG_TAG, "Skipping account with UUID " + uuid);
} }
@ -816,26 +816,26 @@ public class StorageImporter {
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
ImportedServer server = new ImportedServer(); ImportedServer server = new ImportedServer();
server.type = xpp.getAttributeValue(null, StorageExporter.TYPE_ATTRIBUTE); server.type = xpp.getAttributeValue(null, SettingsExporter.TYPE_ATTRIBUTE);
int eventType = xpp.next(); int eventType = xpp.next();
while (!(eventType == XmlPullParser.END_TAG && endTag.equals(xpp.getName()))) { while (!(eventType == XmlPullParser.END_TAG && endTag.equals(xpp.getName()))) {
if(eventType == XmlPullParser.START_TAG) { if(eventType == XmlPullParser.START_TAG) {
String element = xpp.getName(); String element = xpp.getName();
if (StorageExporter.HOST_ELEMENT.equals(element)) { if (SettingsExporter.HOST_ELEMENT.equals(element)) {
server.host = getText(xpp); server.host = getText(xpp);
} else if (StorageExporter.PORT_ELEMENT.equals(element)) { } else if (SettingsExporter.PORT_ELEMENT.equals(element)) {
server.port = getText(xpp); server.port = getText(xpp);
} else if (StorageExporter.CONNECTION_SECURITY_ELEMENT.equals(element)) { } else if (SettingsExporter.CONNECTION_SECURITY_ELEMENT.equals(element)) {
server.connectionSecurity = getText(xpp); server.connectionSecurity = getText(xpp);
} else if (StorageExporter.AUTHENTICATION_TYPE_ELEMENT.equals(element)) { } else if (SettingsExporter.AUTHENTICATION_TYPE_ELEMENT.equals(element)) {
server.authenticationType = getText(xpp); server.authenticationType = getText(xpp);
} else if (StorageExporter.USERNAME_ELEMENT.equals(element)) { } else if (SettingsExporter.USERNAME_ELEMENT.equals(element)) {
server.username = getText(xpp); server.username = getText(xpp);
} else if (StorageExporter.PASSWORD_ELEMENT.equals(element)) { } else if (SettingsExporter.PASSWORD_ELEMENT.equals(element)) {
server.password = getText(xpp); server.password = getText(xpp);
} else if (StorageExporter.EXTRA_ELEMENT.equals(element)) { } else if (SettingsExporter.EXTRA_ELEMENT.equals(element)) {
server.extras = parseSettings(xpp, StorageExporter.EXTRA_ELEMENT); server.extras = parseSettings(xpp, SettingsExporter.EXTRA_ELEMENT);
} else { } else {
Log.w(K9.LOG_TAG, "Unexpected start tag: " + xpp.getName()); Log.w(K9.LOG_TAG, "Unexpected start tag: " + xpp.getName());
} }
@ -852,11 +852,11 @@ public class StorageImporter {
int eventType = xpp.next(); int eventType = xpp.next();
while (!(eventType == XmlPullParser.END_TAG && while (!(eventType == XmlPullParser.END_TAG &&
StorageExporter.IDENTITIES_ELEMENT.equals(xpp.getName()))) { SettingsExporter.IDENTITIES_ELEMENT.equals(xpp.getName()))) {
if(eventType == XmlPullParser.START_TAG) { if(eventType == XmlPullParser.START_TAG) {
String element = xpp.getName(); String element = xpp.getName();
if (StorageExporter.IDENTITY_ELEMENT.equals(element)) { if (SettingsExporter.IDENTITY_ELEMENT.equals(element)) {
if (identities == null) { if (identities == null) {
identities = new ArrayList<ImportedIdentity>(); identities = new ArrayList<ImportedIdentity>();
} }
@ -879,18 +879,18 @@ public class StorageImporter {
int eventType = xpp.next(); int eventType = xpp.next();
while (!(eventType == XmlPullParser.END_TAG && while (!(eventType == XmlPullParser.END_TAG &&
StorageExporter.IDENTITY_ELEMENT.equals(xpp.getName()))) { SettingsExporter.IDENTITY_ELEMENT.equals(xpp.getName()))) {
if(eventType == XmlPullParser.START_TAG) { if(eventType == XmlPullParser.START_TAG) {
String element = xpp.getName(); String element = xpp.getName();
if (StorageExporter.NAME_ELEMENT.equals(element)) { if (SettingsExporter.NAME_ELEMENT.equals(element)) {
identity.name = getText(xpp); identity.name = getText(xpp);
} else if (StorageExporter.EMAIL_ELEMENT.equals(element)) { } else if (SettingsExporter.EMAIL_ELEMENT.equals(element)) {
identity.email = getText(xpp); identity.email = getText(xpp);
} else if (StorageExporter.DESCRIPTION_ELEMENT.equals(element)) { } else if (SettingsExporter.DESCRIPTION_ELEMENT.equals(element)) {
identity.description = getText(xpp); identity.description = getText(xpp);
} else if (StorageExporter.SETTINGS_ELEMENT.equals(element)) { } else if (SettingsExporter.SETTINGS_ELEMENT.equals(element)) {
identity.settings = parseSettings(xpp, StorageExporter.SETTINGS_ELEMENT); identity.settings = parseSettings(xpp, SettingsExporter.SETTINGS_ELEMENT);
} else { } else {
Log.w(K9.LOG_TAG, "Unexpected start tag: " + xpp.getName()); Log.w(K9.LOG_TAG, "Unexpected start tag: " + xpp.getName());
} }
@ -907,11 +907,11 @@ public class StorageImporter {
int eventType = xpp.next(); int eventType = xpp.next();
while (!(eventType == XmlPullParser.END_TAG && while (!(eventType == XmlPullParser.END_TAG &&
StorageExporter.FOLDERS_ELEMENT.equals(xpp.getName()))) { SettingsExporter.FOLDERS_ELEMENT.equals(xpp.getName()))) {
if(eventType == XmlPullParser.START_TAG) { if(eventType == XmlPullParser.START_TAG) {
String element = xpp.getName(); String element = xpp.getName();
if (StorageExporter.FOLDER_ELEMENT.equals(element)) { if (SettingsExporter.FOLDER_ELEMENT.equals(element)) {
if (folders == null) { if (folders == null) {
folders = new ArrayList<ImportedFolder>(); folders = new ArrayList<ImportedFolder>();
} }
@ -932,10 +932,10 @@ public class StorageImporter {
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
ImportedFolder folder = new ImportedFolder(); ImportedFolder folder = new ImportedFolder();
String name = xpp.getAttributeValue(null, StorageExporter.NAME_ATTRIBUTE); String name = xpp.getAttributeValue(null, SettingsExporter.NAME_ATTRIBUTE);
folder.name = name; folder.name = name;
folder.settings = parseSettings(xpp, StorageExporter.FOLDER_ELEMENT); folder.settings = parseSettings(xpp, SettingsExporter.FOLDER_ELEMENT);
return folder; return folder;
} }