mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 04:22:18 -05:00
Merge pull request #1117 from danielnelz/development
#1042: Replaced ints with enums
This commit is contained in:
commit
183457334f
@ -60,6 +60,7 @@ import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
|||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler.MessageStatus;
|
||||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||||
import org.sufficientlysecure.keychain.util.InputData;
|
import org.sufficientlysecure.keychain.util.InputData;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@ -126,8 +127,21 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
public static final String SOURCE = "source";
|
public static final String SOURCE = "source";
|
||||||
|
|
||||||
// possible targets:
|
// possible targets:
|
||||||
public static final int IO_BYTES = 1;
|
public static enum IOType {
|
||||||
public static final int IO_URI = 2;
|
UNKNOWN,
|
||||||
|
BYTES,
|
||||||
|
URI;
|
||||||
|
|
||||||
|
private static final IOType[] values = values();
|
||||||
|
|
||||||
|
public static IOType fromInt(int n) {
|
||||||
|
if(n < 0 || n >= values.length) {
|
||||||
|
return UNKNOWN;
|
||||||
|
} else {
|
||||||
|
return values[n];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
public static final String ENCRYPT_DECRYPT_INPUT_URI = "input_uri";
|
public static final String ENCRYPT_DECRYPT_INPUT_URI = "input_uri";
|
||||||
@ -244,7 +258,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
CertifyResult result = op.certify(parcel, keyServerUri);
|
CertifyResult result = op.certify(parcel, keyServerUri);
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(MessageStatus.OKAY, result);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -259,7 +273,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(MessageStatus.OKAY, result);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -288,7 +302,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
|
|
||||||
DecryptVerifyResult decryptVerifyResult = builder.build().execute();
|
DecryptVerifyResult decryptVerifyResult = builder.build().execute();
|
||||||
|
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, decryptVerifyResult);
|
sendMessageToHandler(MessageStatus.OKAY, decryptVerifyResult);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
}
|
}
|
||||||
@ -349,7 +363,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
}
|
}
|
||||||
|
|
||||||
// kind of awkward, but this whole class wants to pull bytes out of “data”
|
// kind of awkward, but this whole class wants to pull bytes out of “data”
|
||||||
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.IO_BYTES);
|
data.putInt(KeychainIntentService.TARGET, IOType.BYTES.ordinal());
|
||||||
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, messageBytes);
|
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, messageBytes);
|
||||||
|
|
||||||
InputData inputData = createDecryptInputData(data);
|
InputData inputData = createDecryptInputData(data);
|
||||||
@ -386,7 +400,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
resultData.putString(KeychainIntentServiceHandler.KEYBASE_PROOF_URL, prover.getProofUrl());
|
resultData.putString(KeychainIntentServiceHandler.KEYBASE_PROOF_URL, prover.getProofUrl());
|
||||||
resultData.putString(KeychainIntentServiceHandler.KEYBASE_PRESENCE_URL, prover.getPresenceUrl());
|
resultData.putString(KeychainIntentServiceHandler.KEYBASE_PRESENCE_URL, prover.getPresenceUrl());
|
||||||
resultData.putString(KeychainIntentServiceHandler.KEYBASE_PRESENCE_LABEL, prover.getPresenceLabel());
|
resultData.putString(KeychainIntentServiceHandler.KEYBASE_PRESENCE_LABEL, prover.getPresenceLabel());
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, resultData);
|
sendMessageToHandler(MessageStatus.OKAY, resultData);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
}
|
}
|
||||||
@ -429,7 +443,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
|
|
||||||
Log.logDebugBundle(resultData, "resultData");
|
Log.logDebugBundle(resultData, "resultData");
|
||||||
|
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, resultData);
|
sendMessageToHandler(MessageStatus.OKAY, resultData);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
}
|
}
|
||||||
@ -447,7 +461,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
DeleteResult result = op.execute(masterKeyIds, isSecret);
|
DeleteResult result = op.execute(masterKeyIds, isSecret);
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(MessageStatus.OKAY, result);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -462,7 +476,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
EditKeyResult result = op.execute(saveParcel, passphrase);
|
EditKeyResult result = op.execute(saveParcel, passphrase);
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(MessageStatus.OKAY, result);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -476,7 +490,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
PromoteKeyResult result = op.execute(keyRingId);
|
PromoteKeyResult result = op.execute(keyRingId);
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(MessageStatus.OKAY, result);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -500,7 +514,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(MessageStatus.OKAY, result);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -521,7 +535,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
: importExportOperation.importKeyRings(cache, keyServer);
|
: importExportOperation.importKeyRings(cache, keyServer);
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(MessageStatus.OKAY, result);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -537,7 +551,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
SignEncryptResult result = op.execute(inputParcel);
|
SignEncryptResult result = op.execute(inputParcel);
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(MessageStatus.OKAY, result);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -560,7 +574,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
throw new PgpGeneralException("Unable to export key to selected server");
|
throw new PgpGeneralException("Unable to export key to selected server");
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY);
|
sendMessageToHandler(MessageStatus.OKAY);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
}
|
}
|
||||||
@ -582,7 +596,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
private void sendProofError(String msg) {
|
private void sendProofError(String msg) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(KeychainIntentServiceHandler.DATA_ERROR, msg);
|
bundle.putString(KeychainIntentServiceHandler.DATA_ERROR, msg);
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, bundle);
|
sendMessageToHandler(MessageStatus.OKAY, bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendErrorToHandler(Exception e) {
|
private void sendErrorToHandler(Exception e) {
|
||||||
@ -599,14 +613,14 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
|
|
||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
data.putString(KeychainIntentServiceHandler.DATA_ERROR, message);
|
data.putString(KeychainIntentServiceHandler.DATA_ERROR, message);
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_EXCEPTION, null, data);
|
sendMessageToHandler(MessageStatus.EXCEPTION, null, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessageToHandler(Integer arg1, Integer arg2, Bundle data) {
|
private void sendMessageToHandler(MessageStatus status, Integer arg2, Bundle data) {
|
||||||
|
|
||||||
Message msg = Message.obtain();
|
Message msg = Message.obtain();
|
||||||
assert msg != null;
|
assert msg != null;
|
||||||
msg.arg1 = arg1;
|
msg.arg1 = status.ordinal();
|
||||||
if (arg2 != null) {
|
if (arg2 != null) {
|
||||||
msg.arg2 = arg2;
|
msg.arg2 = arg2;
|
||||||
}
|
}
|
||||||
@ -623,18 +637,18 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessageToHandler(Integer arg1, OperationResult data) {
|
private void sendMessageToHandler(MessageStatus status, OperationResult data) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putParcelable(OperationResult.EXTRA_RESULT, data);
|
bundle.putParcelable(OperationResult.EXTRA_RESULT, data);
|
||||||
sendMessageToHandler(arg1, null, bundle);
|
sendMessageToHandler(status, null, bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessageToHandler(Integer arg1, Bundle data) {
|
private void sendMessageToHandler(MessageStatus status, Bundle data) {
|
||||||
sendMessageToHandler(arg1, null, data);
|
sendMessageToHandler(status, null, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessageToHandler(Integer arg1) {
|
private void sendMessageToHandler(MessageStatus status) {
|
||||||
sendMessageToHandler(arg1, null, null);
|
sendMessageToHandler(status, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -651,7 +665,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
data.putInt(KeychainIntentServiceHandler.DATA_PROGRESS, progress);
|
data.putInt(KeychainIntentServiceHandler.DATA_PROGRESS, progress);
|
||||||
data.putInt(KeychainIntentServiceHandler.DATA_PROGRESS_MAX, max);
|
data.putInt(KeychainIntentServiceHandler.DATA_PROGRESS_MAX, max);
|
||||||
|
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_UPDATE_PROGRESS, null, data);
|
sendMessageToHandler(MessageStatus.UPDATE_PROGRESS, null, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgress(int resourceId, int progress, int max) {
|
public void setProgress(int resourceId, int progress, int max) {
|
||||||
@ -664,7 +678,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPreventCancel() {
|
public void setPreventCancel() {
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_PREVENT_CANCEL);
|
sendMessageToHandler(MessageStatus.PREVENT_CANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputData createDecryptInputData(Bundle data) throws IOException, PgpGeneralException {
|
private InputData createDecryptInputData(Bundle data) throws IOException, PgpGeneralException {
|
||||||
@ -673,35 +687,37 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
|
|
||||||
private InputData createCryptInputData(Bundle data, String bytesName) throws PgpGeneralException, IOException {
|
private InputData createCryptInputData(Bundle data, String bytesName) throws PgpGeneralException, IOException {
|
||||||
int source = data.get(SOURCE) != null ? data.getInt(SOURCE) : data.getInt(TARGET);
|
int source = data.get(SOURCE) != null ? data.getInt(SOURCE) : data.getInt(TARGET);
|
||||||
switch (source) {
|
IOType type = IOType.fromInt(source);
|
||||||
case IO_BYTES: /* encrypting bytes directly */
|
switch (type) {
|
||||||
|
case BYTES: /* encrypting bytes directly */
|
||||||
byte[] bytes = data.getByteArray(bytesName);
|
byte[] bytes = data.getByteArray(bytesName);
|
||||||
return new InputData(new ByteArrayInputStream(bytes), bytes.length);
|
return new InputData(new ByteArrayInputStream(bytes), bytes.length);
|
||||||
|
|
||||||
case IO_URI: /* encrypting content uri */
|
case URI: /* encrypting content uri */
|
||||||
Uri providerUri = data.getParcelable(ENCRYPT_DECRYPT_INPUT_URI);
|
Uri providerUri = data.getParcelable(ENCRYPT_DECRYPT_INPUT_URI);
|
||||||
|
|
||||||
// InputStream
|
// InputStream
|
||||||
return new InputData(getContentResolver().openInputStream(providerUri), FileHelper.getFileSize(this, providerUri, 0));
|
return new InputData(getContentResolver().openInputStream(providerUri), FileHelper.getFileSize(this, providerUri, 0));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new PgpGeneralException("No target choosen!");
|
throw new PgpGeneralException("No target chosen!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private OutputStream createCryptOutputStream(Bundle data) throws PgpGeneralException, FileNotFoundException {
|
private OutputStream createCryptOutputStream(Bundle data) throws PgpGeneralException, FileNotFoundException {
|
||||||
int target = data.getInt(TARGET);
|
int target = data.getInt(TARGET);
|
||||||
switch (target) {
|
IOType type = IOType.fromInt(target);
|
||||||
case IO_BYTES:
|
switch (type) {
|
||||||
|
case BYTES:
|
||||||
return new ByteArrayOutputStream();
|
return new ByteArrayOutputStream();
|
||||||
|
|
||||||
case IO_URI:
|
case URI:
|
||||||
Uri providerUri = data.getParcelable(ENCRYPT_DECRYPT_OUTPUT_URI);
|
Uri providerUri = data.getParcelable(ENCRYPT_DECRYPT_OUTPUT_URI);
|
||||||
|
|
||||||
return getContentResolver().openOutputStream(providerUri);
|
return getContentResolver().openOutputStream(providerUri);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new PgpGeneralException("No target choosen!");
|
throw new PgpGeneralException("No target chosen!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -711,12 +727,13 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
|
|
||||||
private void finalizeCryptOutputStream(Bundle data, Bundle resultData, OutputStream outStream, String bytesName) {
|
private void finalizeCryptOutputStream(Bundle data, Bundle resultData, OutputStream outStream, String bytesName) {
|
||||||
int target = data.getInt(TARGET);
|
int target = data.getInt(TARGET);
|
||||||
switch (target) {
|
IOType type = IOType.fromInt(target);
|
||||||
case IO_BYTES:
|
switch (type) {
|
||||||
|
case BYTES:
|
||||||
byte output[] = ((ByteArrayOutputStream) outStream).toByteArray();
|
byte output[] = ((ByteArrayOutputStream) outStream).toByteArray();
|
||||||
resultData.putByteArray(bytesName, output);
|
resultData.putByteArray(bytesName, output);
|
||||||
break;
|
break;
|
||||||
case IO_URI:
|
case URI:
|
||||||
// nothing, output was written, just send okay and verification bundle
|
// nothing, output was written, just send okay and verification bundle
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -32,11 +32,25 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
|
|
||||||
public class KeychainIntentServiceHandler extends Handler {
|
public class KeychainIntentServiceHandler extends Handler {
|
||||||
|
|
||||||
// possible messages send from this service to handler on ui
|
// possible messages sent from this service to handler on ui
|
||||||
public static final int MESSAGE_OKAY = 1;
|
public static enum MessageStatus{
|
||||||
public static final int MESSAGE_EXCEPTION = 2;
|
UNKNOWN,
|
||||||
public static final int MESSAGE_UPDATE_PROGRESS = 3;
|
OKAY,
|
||||||
public static final int MESSAGE_PREVENT_CANCEL = 4;
|
EXCEPTION,
|
||||||
|
UPDATE_PROGRESS,
|
||||||
|
PREVENT_CANCEL;
|
||||||
|
|
||||||
|
private static final MessageStatus[] values = values();
|
||||||
|
|
||||||
|
public static MessageStatus fromInt(int n)
|
||||||
|
{
|
||||||
|
if(n < 0 || n >= values.length) {
|
||||||
|
return UNKNOWN;
|
||||||
|
} else {
|
||||||
|
return values[n];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// possible data keys for messages
|
// possible data keys for messages
|
||||||
public static final String DATA_ERROR = "error";
|
public static final String DATA_ERROR = "error";
|
||||||
@ -103,13 +117,14 @@ public class KeychainIntentServiceHandler extends Handler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (message.arg1) {
|
MessageStatus status = MessageStatus.fromInt(message.arg1);
|
||||||
case MESSAGE_OKAY:
|
switch (status) {
|
||||||
|
case OKAY:
|
||||||
mProgressDialogFragment.dismissAllowingStateLoss();
|
mProgressDialogFragment.dismissAllowingStateLoss();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESSAGE_EXCEPTION:
|
case EXCEPTION:
|
||||||
mProgressDialogFragment.dismissAllowingStateLoss();
|
mProgressDialogFragment.dismissAllowingStateLoss();
|
||||||
|
|
||||||
// show error from service
|
// show error from service
|
||||||
@ -121,7 +136,7 @@ public class KeychainIntentServiceHandler extends Handler {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESSAGE_UPDATE_PROGRESS:
|
case UPDATE_PROGRESS:
|
||||||
if (data.containsKey(DATA_PROGRESS) && data.containsKey(DATA_PROGRESS_MAX)) {
|
if (data.containsKey(DATA_PROGRESS) && data.containsKey(DATA_PROGRESS_MAX)) {
|
||||||
|
|
||||||
// update progress from service
|
// update progress from service
|
||||||
@ -139,7 +154,7 @@ public class KeychainIntentServiceHandler extends Handler {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESSAGE_PREVENT_CANCEL:
|
case PREVENT_CANCEL:
|
||||||
mProgressDialogFragment.setPreventCancel(true);
|
mProgressDialogFragment.setPreventCancel(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ public class CertifyKeyFragment extends LoaderFragment
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
Bundle data = message.getData();
|
Bundle data = message.getData();
|
||||||
CertifyResult result = data.getParcelable(CertifyResult.EXTRA_RESULT);
|
CertifyResult result = data.getParcelable(CertifyResult.EXTRA_RESULT);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class ConsolidateDialogActivity extends FragmentActivity {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
/* don't care about the results (for now?)
|
/* don't care about the results (for now?)
|
||||||
|
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
|
@ -214,7 +214,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
if (returnData == null) {
|
if (returnData == null) {
|
||||||
@ -284,7 +284,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// TODO: upload operation needs a result!
|
// TODO: upload operation needs a result!
|
||||||
// TODO: then combine these results
|
// TODO: then combine these results
|
||||||
//if (result.getResult() == OperationResultParcel.RESULT_OK) {
|
//if (result.getResult() == OperationResultParcel.RESULT_OK) {
|
||||||
|
@ -37,6 +37,7 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
|
import org.sufficientlysecure.keychain.service.KeychainIntentService.IOType;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
@ -182,10 +183,10 @@ public class DecryptFilesFragment extends DecryptFragment {
|
|||||||
// data
|
// data
|
||||||
Log.d(Constants.TAG, "mInputUri=" + mInputUri + ", mOutputUri=" + mOutputUri);
|
Log.d(Constants.TAG, "mInputUri=" + mInputUri + ", mOutputUri=" + mOutputUri);
|
||||||
|
|
||||||
data.putInt(KeychainIntentService.SOURCE, KeychainIntentService.IO_URI);
|
data.putInt(KeychainIntentService.SOURCE, IOType.URI.ordinal());
|
||||||
data.putParcelable(KeychainIntentService.ENCRYPT_DECRYPT_INPUT_URI, mInputUri);
|
data.putParcelable(KeychainIntentService.ENCRYPT_DECRYPT_INPUT_URI, mInputUri);
|
||||||
|
|
||||||
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.IO_URI);
|
data.putInt(KeychainIntentService.TARGET, IOType.URI.ordinal());
|
||||||
data.putParcelable(KeychainIntentService.ENCRYPT_DECRYPT_OUTPUT_URI, mOutputUri);
|
data.putParcelable(KeychainIntentService.ENCRYPT_DECRYPT_OUTPUT_URI, mOutputUri);
|
||||||
|
|
||||||
data.putString(KeychainIntentService.DECRYPT_PASSPHRASE, mPassphrase);
|
data.putString(KeychainIntentService.DECRYPT_PASSPHRASE, mPassphrase);
|
||||||
@ -200,7 +201,7 @@ public class DecryptFilesFragment extends DecryptFragment {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
|
|
||||||
@ -256,10 +257,10 @@ public class DecryptFilesFragment extends DecryptFragment {
|
|||||||
// data
|
// data
|
||||||
Log.d(Constants.TAG, "mInputUri=" + mInputUri + ", mOutputUri=" + mOutputUri);
|
Log.d(Constants.TAG, "mInputUri=" + mInputUri + ", mOutputUri=" + mOutputUri);
|
||||||
|
|
||||||
data.putInt(KeychainIntentService.SOURCE, KeychainIntentService.IO_URI);
|
data.putInt(KeychainIntentService.SOURCE, IOType.URI.ordinal());
|
||||||
data.putParcelable(KeychainIntentService.ENCRYPT_DECRYPT_INPUT_URI, mInputUri);
|
data.putParcelable(KeychainIntentService.ENCRYPT_DECRYPT_INPUT_URI, mInputUri);
|
||||||
|
|
||||||
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.IO_URI);
|
data.putInt(KeychainIntentService.TARGET, IOType.URI.ordinal());
|
||||||
data.putParcelable(KeychainIntentService.ENCRYPT_DECRYPT_OUTPUT_URI, mOutputUri);
|
data.putParcelable(KeychainIntentService.ENCRYPT_DECRYPT_OUTPUT_URI, mOutputUri);
|
||||||
|
|
||||||
data.putString(KeychainIntentService.DECRYPT_PASSPHRASE, mPassphrase);
|
data.putString(KeychainIntentService.DECRYPT_PASSPHRASE, mPassphrase);
|
||||||
@ -274,7 +275,7 @@ public class DecryptFilesFragment extends DecryptFragment {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import org.sufficientlysecure.keychain.R;
|
|||||||
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
||||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
|
import org.sufficientlysecure.keychain.service.KeychainIntentService.IOType;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@ -158,7 +159,7 @@ public class DecryptTextFragment extends DecryptFragment {
|
|||||||
intent.setAction(KeychainIntentService.ACTION_DECRYPT_VERIFY);
|
intent.setAction(KeychainIntentService.ACTION_DECRYPT_VERIFY);
|
||||||
|
|
||||||
// data
|
// data
|
||||||
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.IO_BYTES);
|
data.putInt(KeychainIntentService.TARGET, IOType.BYTES.ordinal());
|
||||||
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, mCiphertext.getBytes());
|
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, mCiphertext.getBytes());
|
||||||
data.putString(KeychainIntentService.DECRYPT_PASSPHRASE, mPassphrase);
|
data.putString(KeychainIntentService.DECRYPT_PASSPHRASE, mPassphrase);
|
||||||
data.putByteArray(KeychainIntentService.DECRYPT_NFC_DECRYPTED_SESSION_KEY, mNfcDecryptedSessionKey);
|
data.putByteArray(KeychainIntentService.DECRYPT_NFC_DECRYPTED_SESSION_KEY, mNfcDecryptedSessionKey);
|
||||||
@ -172,7 +173,7 @@ public class DecryptTextFragment extends DecryptFragment {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
|
|
||||||
|
@ -605,7 +605,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
|
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
|
@ -128,7 +128,7 @@ public abstract class EncryptActivity extends BaseActivity {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
SignEncryptResult result =
|
SignEncryptResult result =
|
||||||
message.getData().getParcelable(SignEncryptResult.EXTRA_RESULT);
|
message.getData().getParcelable(SignEncryptResult.EXTRA_RESULT);
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ public class ImportKeysActivity extends BaseActivity {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
if (returnData == null) {
|
if (returnData == null) {
|
||||||
|
@ -222,7 +222,7 @@ public class ImportKeysProxyActivity extends FragmentActivity {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
if (returnData == null) {
|
if (returnData == null) {
|
||||||
|
@ -552,7 +552,7 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
if (returnData == null) {
|
if (returnData == null) {
|
||||||
|
@ -132,7 +132,7 @@ public class SafeSlingerActivity extends BaseActivity {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
if (returnData == null) {
|
if (returnData == null) {
|
||||||
|
@ -113,7 +113,7 @@ public class UploadKeyActivity extends BaseActivity {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
|
|
||||||
Toast.makeText(UploadKeyActivity.this, R.string.msg_crt_upload_success,
|
Toast.makeText(UploadKeyActivity.this, R.string.msg_crt_upload_success,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
|
@ -72,6 +72,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
|
|||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler.MessageStatus;
|
||||||
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;
|
||||||
@ -429,7 +430,7 @@ public class ViewKeyActivity extends BaseActivity implements
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
Bundle data = message.getData();
|
Bundle data = message.getData();
|
||||||
CertifyResult result = data.getParcelable(CertifyResult.EXTRA_RESULT);
|
CertifyResult result = data.getParcelable(CertifyResult.EXTRA_RESULT);
|
||||||
|
|
||||||
@ -486,7 +487,7 @@ public class ViewKeyActivity extends BaseActivity implements
|
|||||||
Handler returnHandler = new Handler() {
|
Handler returnHandler = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message message) {
|
public void handleMessage(Message message) {
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -595,7 +596,7 @@ public class ViewKeyActivity extends BaseActivity implements
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
String msg = returnData.getString(KeychainIntentServiceHandler.DATA_MESSAGE);
|
String msg = returnData.getString(KeychainIntentServiceHandler.DATA_MESSAGE);
|
||||||
SpannableStringBuilder ssb = new SpannableStringBuilder();
|
SpannableStringBuilder ssb = new SpannableStringBuilder();
|
||||||
|
@ -142,7 +142,7 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
public void handleMessage(Message message) {
|
public void handleMessage(Message message) {
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
if (message.arg1 == MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
try {
|
try {
|
||||||
Message msg = Message.obtain();
|
Message msg = Message.obtain();
|
||||||
msg.copyFrom(message);
|
msg.copyFrom(message);
|
||||||
|
@ -124,7 +124,7 @@ public class ExportHelper {
|
|||||||
// handle messages by standard KeychainIntentServiceHandler first
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle data = message.getData();
|
Bundle data = message.getData();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user