From 3cd54581c33b20a9bfa55f767b245fc6e56e83ef Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Tue, 15 Sep 2015 03:02:05 +0200 Subject: mime: create more general InputDataOperation, which for now and does basic mime parsing --- .../operations/results/InputDataResult.java | 71 ++++++++++++++++++++++ .../operations/results/InputPendingResult.java | 9 +++ .../operations/results/MimeParsingResult.java | 65 -------------------- 3 files changed, 80 insertions(+), 65 deletions(-) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputDataResult.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/MimeParsingResult.java (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputDataResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputDataResult.java new file mode 100644 index 000000000..908636ca7 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputDataResult.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2015 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.operations.results; + +import android.net.Uri; +import android.os.Parcel; + +import java.util.ArrayList; + +public class InputDataResult extends InputPendingResult { + + public final ArrayList mOutputUris; + public DecryptVerifyResult mDecryptVerifyResult; + + public InputDataResult(OperationLog log, InputPendingResult result) { + super(log, result); + mOutputUris = null; + } + + public InputDataResult(int result, OperationLog log, ArrayList temporaryUris) { + super(result, log); + mOutputUris = temporaryUris; + } + + protected InputDataResult(Parcel in) { + super(in); + mOutputUris = in.createTypedArrayList(Uri.CREATOR); + } + + public ArrayList getOutputUris() { + return mOutputUris; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + super.writeToParcel(dest, flags); + dest.writeTypedList(mOutputUris); + } + + public static final Creator CREATOR = new Creator() { + @Override + public InputDataResult createFromParcel(Parcel in) { + return new InputDataResult(in); + } + + @Override + public InputDataResult[] newArray(int size) { + return new InputDataResult[size]; + } + }; +} \ No newline at end of file diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java index d767382ae..0a8c1f653 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java @@ -38,6 +38,15 @@ public class InputPendingResult extends OperationResult { mCryptoInputParcel = null; } + public InputPendingResult(OperationLog log, InputPendingResult result) { + super(RESULT_PENDING, log); + if (!result.isPending()) { + throw new AssertionError("sub result must be pending!"); + } + mRequiredInput = result.mRequiredInput; + mCryptoInputParcel = result.mCryptoInputParcel; + } + public InputPendingResult(OperationLog log, RequiredInputParcel requiredInput, CryptoInputParcel cryptoInputParcel) { super(RESULT_PENDING, log); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/MimeParsingResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/MimeParsingResult.java deleted file mode 100644 index 05f5125cb..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/MimeParsingResult.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2015 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.operations.results; - -import android.net.Uri; -import android.os.Parcel; - -import java.util.ArrayList; - -public class MimeParsingResult extends OperationResult { - - public final ArrayList mTemporaryUris; - - public ArrayList getTemporaryUris() { - return mTemporaryUris; - } - - public MimeParsingResult(int result, OperationLog log, ArrayList temporaryUris) { - super(result, log); - mTemporaryUris = temporaryUris; - } - - protected MimeParsingResult(Parcel in) { - super(in); - mTemporaryUris = in.createTypedArrayList(Uri.CREATOR); - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - super.writeToParcel(dest, flags); - dest.writeTypedList(mTemporaryUris); - } - - public static final Creator CREATOR = new Creator() { - @Override - public MimeParsingResult createFromParcel(Parcel in) { - return new MimeParsingResult(in); - } - - @Override - public MimeParsingResult[] newArray(int size) { - return new MimeParsingResult[size]; - } - }; -} \ No newline at end of file -- cgit v1.2.3