preliminary working mime parsing in DecryptListFragment! (beware WIP, here be dragons!)

This commit is contained in:
Vincent Breitmoser
2015-09-16 00:05:21 +02:00
parent 326834fd58
commit 99fd1f4c22
4 changed files with 66 additions and 50 deletions

View File

@@ -70,6 +70,8 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
Uri currentUri;
DecryptVerifyResult decryptResult = null;
PgpDecryptVerifyInputParcel decryptInput = input.getDecryptInput();
if (decryptInput != null) {
@@ -83,11 +85,11 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
currentUri = TemporaryStorageProvider.createFile(mContext);
decryptInput.setOutputUri(currentUri);
DecryptVerifyResult result = op.execute(decryptInput, cryptoInput);
if (result.isPending()) {
return new InputDataResult(log, result);
decryptResult = op.execute(decryptInput, cryptoInput);
if (decryptResult.isPending()) {
return new InputDataResult(log, decryptResult);
}
log.addByMerge(result, 2);
log.addByMerge(decryptResult, 2);
} else {
currentUri = input.getInputUri();
@@ -106,7 +108,7 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
uris.add(currentUri);
log.add(LogType.MSG_DATA_OK, 1);
return new InputDataResult(InputDataResult.RESULT_OK, log, uris);
return new InputDataResult(InputDataResult.RESULT_OK, log, decryptResult, uris);
}
@@ -117,7 +119,7 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
in = mContext.getContentResolver().openInputStream(currentUri);
} catch (FileNotFoundException e) {
log.add(LogType.MSG_DATA_ERROR_IO, 2);
return new InputDataResult(InputDataResult.RESULT_ERROR, log, null);
return new InputDataResult(InputDataResult.RESULT_ERROR, log);
}
MimeStreamParser parser = new MimeStreamParser((MimeConfig) null);
@@ -176,16 +178,16 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
log.add(LogType.MSG_DATA_MIME_OK, 2);
log.add(LogType.MSG_DATA_OK, 1);
return new InputDataResult(InputDataResult.RESULT_OK, log, outputUris);
return new InputDataResult(InputDataResult.RESULT_OK, log, decryptResult, outputUris);
} catch (IOException e) {
e.printStackTrace();
log.add(LogType.MSG_DATA_MIME_ERROR, 2);
return new InputDataResult(InputDataResult.RESULT_ERROR, log, null);
return new InputDataResult(InputDataResult.RESULT_ERROR, log);
} catch (MimeException e) {
e.printStackTrace();
log.add(LogType.MSG_DATA_MIME_ERROR, 2);
return new InputDataResult(InputDataResult.RESULT_ERROR, log, outputUris);
return new InputDataResult(InputDataResult.RESULT_ERROR, log);
}
}

View File

@@ -25,21 +25,30 @@ import java.util.ArrayList;
public class InputDataResult extends InputPendingResult {
public final ArrayList<Uri> mOutputUris;
public DecryptVerifyResult mDecryptVerifyResult;
final public DecryptVerifyResult mDecryptVerifyResult;
public InputDataResult(OperationLog log, InputPendingResult result) {
super(log, result);
mOutputUris = null;
mDecryptVerifyResult = null;
}
public InputDataResult(int result, OperationLog log, ArrayList<Uri> temporaryUris) {
public InputDataResult(int result, OperationLog log, DecryptVerifyResult decryptResult, ArrayList<Uri> temporaryUris) {
super(result, log);
mOutputUris = temporaryUris;
mDecryptVerifyResult = decryptResult;
}
public InputDataResult(int result, OperationLog log) {
super(result, log);
mOutputUris = null;
mDecryptVerifyResult = null;
}
protected InputDataResult(Parcel in) {
super(in);
mOutputUris = in.createTypedArrayList(Uri.CREATOR);
mDecryptVerifyResult = in.readParcelable(DecryptVerifyResult.class.getClassLoader());
}
public ArrayList<Uri> getOutputUris() {
@@ -55,6 +64,7 @@ public class InputDataResult extends InputPendingResult {
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeTypedList(mOutputUris);
dest.writeParcelable(mDecryptVerifyResult, 0);
}
public static final Creator<InputDataResult> CREATOR = new Creator<InputDataResult>() {