mime: return one OpenPgpMetadata object per body part
This commit is contained in:
@@ -37,6 +37,7 @@ import org.apache.james.mime4j.parser.MimeStreamParser;
|
|||||||
import org.apache.james.mime4j.stream.BodyDescriptor;
|
import org.apache.james.mime4j.stream.BodyDescriptor;
|
||||||
import org.apache.james.mime4j.stream.Field;
|
import org.apache.james.mime4j.stream.Field;
|
||||||
import org.apache.james.mime4j.stream.MimeConfig;
|
import org.apache.james.mime4j.stream.MimeConfig;
|
||||||
|
import org.openintents.openpgp.OpenPgpMetadata;
|
||||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.InputDataResult;
|
import org.sufficientlysecure.keychain.operations.results.InputDataResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
@@ -106,9 +107,11 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
|
|||||||
|
|
||||||
ArrayList<Uri> uris = new ArrayList<>();
|
ArrayList<Uri> uris = new ArrayList<>();
|
||||||
uris.add(currentUri);
|
uris.add(currentUri);
|
||||||
|
ArrayList<OpenPgpMetadata> metadatas = new ArrayList<>();
|
||||||
|
metadatas.add(decryptResult.getDecryptionMetadata());
|
||||||
|
|
||||||
log.add(LogType.MSG_DATA_OK, 1);
|
log.add(LogType.MSG_DATA_OK, 1);
|
||||||
return new InputDataResult(InputDataResult.RESULT_OK, log, decryptResult, uris);
|
return new InputDataResult(InputDataResult.RESULT_OK, log, decryptResult, uris, metadatas);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +127,7 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
|
|||||||
MimeStreamParser parser = new MimeStreamParser((MimeConfig) null);
|
MimeStreamParser parser = new MimeStreamParser((MimeConfig) null);
|
||||||
|
|
||||||
final ArrayList<Uri> outputUris = new ArrayList<>();
|
final ArrayList<Uri> outputUris = new ArrayList<>();
|
||||||
|
final ArrayList<OpenPgpMetadata> metadatas = new ArrayList<>();
|
||||||
|
|
||||||
parser.setContentDecoding(true);
|
parser.setContentDecoding(true);
|
||||||
parser.setRecurse();
|
parser.setRecurse();
|
||||||
@@ -166,8 +170,11 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
|
|||||||
out.write(buf, 0, len);
|
out.write(buf, 0, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OpenPgpMetadata metadata = new OpenPgpMetadata(mFilename, bd.getMimeType(), 0L, bd.getContentLength());
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
outputUris.add(uri);
|
outputUris.add(uri);
|
||||||
|
metadatas.add(metadata);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -178,7 +185,7 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
|
|||||||
log.add(LogType.MSG_DATA_MIME_OK, 2);
|
log.add(LogType.MSG_DATA_MIME_OK, 2);
|
||||||
|
|
||||||
log.add(LogType.MSG_DATA_OK, 1);
|
log.add(LogType.MSG_DATA_OK, 1);
|
||||||
return new InputDataResult(InputDataResult.RESULT_OK, log, decryptResult, outputUris);
|
return new InputDataResult(InputDataResult.RESULT_OK, log, decryptResult, outputUris, metadatas);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -17,38 +17,52 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.operations.results;
|
package org.sufficientlysecure.keychain.operations.results;
|
||||||
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.openintents.openpgp.OpenPgpMetadata;
|
||||||
|
|
||||||
|
|
||||||
public class InputDataResult extends InputPendingResult {
|
public class InputDataResult extends InputPendingResult {
|
||||||
|
|
||||||
public final ArrayList<Uri> mOutputUris;
|
public final ArrayList<Uri> mOutputUris;
|
||||||
final public DecryptVerifyResult mDecryptVerifyResult;
|
final public DecryptVerifyResult mDecryptVerifyResult;
|
||||||
|
public final ArrayList<OpenPgpMetadata> mMetadata;
|
||||||
|
|
||||||
public InputDataResult(OperationLog log, InputPendingResult result) {
|
public InputDataResult(OperationLog log, @NonNull InputPendingResult result) {
|
||||||
super(log, result);
|
super(log, result);
|
||||||
mOutputUris = null;
|
mOutputUris = null;
|
||||||
mDecryptVerifyResult = null;
|
mDecryptVerifyResult = null;
|
||||||
}
|
mMetadata = null;
|
||||||
|
|
||||||
public InputDataResult(int result, OperationLog log, DecryptVerifyResult decryptResult, ArrayList<Uri> temporaryUris) {
|
|
||||||
super(result, log);
|
|
||||||
mOutputUris = temporaryUris;
|
|
||||||
mDecryptVerifyResult = decryptResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputDataResult(int result, OperationLog log) {
|
public InputDataResult(int result, OperationLog log) {
|
||||||
super(result, log);
|
super(result, log);
|
||||||
mOutputUris = null;
|
mOutputUris = null;
|
||||||
mDecryptVerifyResult = null;
|
mDecryptVerifyResult = null;
|
||||||
|
mMetadata = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputDataResult(int result, OperationLog log, DecryptVerifyResult decryptResult,
|
||||||
|
@NonNull ArrayList<Uri> outputUris, @NonNull ArrayList<OpenPgpMetadata> metadata) {
|
||||||
|
super(result, log);
|
||||||
|
mDecryptVerifyResult = decryptResult;
|
||||||
|
if (outputUris.size() == metadata.size()) {
|
||||||
|
throw new AssertionError("number of output URIs must match metadata!");
|
||||||
|
}
|
||||||
|
mOutputUris = outputUris;
|
||||||
|
mMetadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InputDataResult(Parcel in) {
|
protected InputDataResult(Parcel in) {
|
||||||
super(in);
|
super(in);
|
||||||
mOutputUris = in.createTypedArrayList(Uri.CREATOR);
|
mOutputUris = in.createTypedArrayList(Uri.CREATOR);
|
||||||
mDecryptVerifyResult = in.readParcelable(DecryptVerifyResult.class.getClassLoader());
|
mDecryptVerifyResult = in.readParcelable(DecryptVerifyResult.class.getClassLoader());
|
||||||
|
mMetadata = in.createTypedArrayList(OpenPgpMetadata.CREATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Uri> getOutputUris() {
|
public ArrayList<Uri> getOutputUris() {
|
||||||
@@ -65,6 +79,7 @@ public class InputDataResult extends InputPendingResult {
|
|||||||
super.writeToParcel(dest, flags);
|
super.writeToParcel(dest, flags);
|
||||||
dest.writeTypedList(mOutputUris);
|
dest.writeTypedList(mOutputUris);
|
||||||
dest.writeParcelable(mDecryptVerifyResult, 0);
|
dest.writeParcelable(mDecryptVerifyResult, 0);
|
||||||
|
dest.writeTypedList(mMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<InputDataResult> CREATOR = new Creator<InputDataResult>() {
|
public static final Creator<InputDataResult> CREATOR = new Creator<InputDataResult>() {
|
||||||
|
|||||||
Reference in New Issue
Block a user