use of org.openintents.openpgp.OpenPgpError in project k-9 by k9mail.
the class OpenPgpApi method executeApi.
public Intent executeApi(Intent data, OpenPgpDataSource dataSource, OutputStream os) {
ParcelFileDescriptor input = null;
ParcelFileDescriptor output;
try {
if (dataSource != null) {
Long expectedSize = dataSource.getSizeForProgress();
if (expectedSize != null) {
data.putExtra(EXTRA_DATA_LENGTH, (long) expectedSize);
} else {
data.removeExtra(EXTRA_PROGRESS_MESSENGER);
}
input = dataSource.startPumpThread();
}
Thread pumpThread = null;
int outputPipeId = 0;
if (os != null) {
outputPipeId = mPipeIdGen.incrementAndGet();
output = mService.createOutputPipe(outputPipeId);
pumpThread = ParcelFileDescriptorUtil.pipeTo(os, output);
}
Intent result = executeApi(data, input, outputPipeId);
// wait for ALL data being pumped from remote side
if (pumpThread != null) {
pumpThread.join();
}
return result;
} catch (Exception e) {
Timber.e(e, "Exception in executeApi call");
Intent result = new Intent();
result.putExtra(RESULT_CODE, RESULT_CODE_ERROR);
result.putExtra(RESULT_ERROR, new OpenPgpError(OpenPgpError.CLIENT_SIDE_ERROR, e.getMessage()));
return result;
}
}
Aggregations