From 97f493c8810a10893cb9fe1f32368b3d4fdc9b20 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 28 Mar 2011 07:18:47 +0200 Subject: [PATCH] Get rid of ExportListener --- src/com/fsck/k9/activity/Accounts.java | 2 +- src/com/fsck/k9/activity/ExportListener.java | 13 --------- .../fsck/k9/preferences/StorageExporter.java | 27 +++++-------------- 3 files changed, 8 insertions(+), 34 deletions(-) delete mode 100644 src/com/fsck/k9/activity/ExportListener.java diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 44caa4b2a..1f31be48f 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -1174,7 +1174,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC File file = Utility.createUniqueFile(dir, "settings.k9s"); mFileName = file.getAbsolutePath(); StorageExporter.exportPreferences(Accounts.this, StorageFormat.ENCRYPTED_XML_FILE, - mIncludeGlobals, mAccountUuids, mFileName, mEncryptionKey, null); + mIncludeGlobals, mAccountUuids, mFileName, mEncryptionKey); } catch (Exception e) { Log.w(K9.LOG_TAG, "Exception during export", e); return false; diff --git a/src/com/fsck/k9/activity/ExportListener.java b/src/com/fsck/k9/activity/ExportListener.java deleted file mode 100644 index 2ec062545..000000000 --- a/src/com/fsck/k9/activity/ExportListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.fsck.k9.activity; - -public interface ExportListener { - public void success(String fileName); - public void success(); - - public void failure(String message, Exception e); - - public void canceled(); - - public void started(); - -} diff --git a/src/com/fsck/k9/preferences/StorageExporter.java b/src/com/fsck/k9/preferences/StorageExporter.java index c7a879628..9535b990a 100644 --- a/src/com/fsck/k9/preferences/StorageExporter.java +++ b/src/com/fsck/k9/preferences/StorageExporter.java @@ -12,10 +12,9 @@ import android.util.Log; import com.fsck.k9.K9; import com.fsck.k9.R; -import com.fsck.k9.activity.ExportListener; public class StorageExporter { - private static void exportPreferences(Activity activity, String storageFormat, boolean includeGlobals, Set accountUuids, String fileName, OutputStream os, String encryptionKey, final ExportListener listener) { + private static void exportPreferences(Activity activity, String storageFormat, boolean includeGlobals, Set accountUuids, String fileName, OutputStream os, String encryptionKey) throws StorageImportExportException { try { IStorageExporter storageExporter = StorageFormat.createExporter(storageFormat); if (storageExporter == null) { @@ -24,26 +23,21 @@ public class StorageExporter { if (storageExporter.needsKey() && encryptionKey == null) { throw new StorageImportExportException("Encryption key required, but none supplied"); } else { - finishExport(activity, storageFormat, storageExporter, includeGlobals, accountUuids, fileName, os, encryptionKey, listener); + finishExport(activity, storageFormat, storageExporter, includeGlobals, accountUuids, fileName, os, encryptionKey); } } - catch (Exception e) { - if (listener != null) { - listener.failure(e.getLocalizedMessage(), e); - } + //FIXME: get this right + throw new StorageImportExportException(); } } - public static void exportPreferences(Activity activity, String storageFormat, boolean includeGlobals, Set accountUuids, String fileName, String encryptionKey, final ExportListener listener) throws StorageImportExportException { - exportPreferences(activity, storageFormat, includeGlobals, accountUuids, fileName, null, encryptionKey, listener); + public static void exportPreferences(Activity activity, String storageFormat, boolean includeGlobals, Set accountUuids, String fileName, String encryptionKey) throws StorageImportExportException { + exportPreferences(activity, storageFormat, includeGlobals, accountUuids, fileName, null, encryptionKey); } - private static void finishExport(Activity activity, String storageFormat, IStorageExporter storageExporter, boolean includeGlobals, Set accountUuids, String fileName, OutputStream os, String encryptionKey, ExportListener listener) throws StorageImportExportException { + private static void finishExport(Activity activity, String storageFormat, IStorageExporter storageExporter, boolean includeGlobals, Set accountUuids, String fileName, OutputStream os, String encryptionKey) throws StorageImportExportException { boolean needToClose = false; - if (listener != null) { - listener.started(); - } try { // This needs to be after the password prompt. If the user cancels the password, we do not want // to create the file needlessly @@ -65,13 +59,6 @@ public class StorageExporter { pf.println(""); pf.flush(); - if (listener != null) { - if (fileName != null) { - listener.success(fileName); - } else { - listener.success(); - } - } } else { throw new StorageImportExportException("Internal error; no fileName or OutputStream", null); }