diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-03-18 21:12:31 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-03-18 21:12:31 +0100 |
commit | d46fc3740bbfc3bac0b1133a3e9d47c7ce3e06e2 (patch) | |
tree | 034ef267e71613dedfd74183a1ac7d7f4414813c /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java | |
parent | aca54e31eae450e7deec54cca6654ee202c7a90f (diff) | |
download | open-keychain-d46fc3740bbfc3bac0b1133a3e9d47c7ce3e06e2.tar.gz open-keychain-d46fc3740bbfc3bac0b1133a3e9d47c7ce3e06e2.tar.bz2 open-keychain-d46fc3740bbfc3bac0b1133a3e9d47c7ce3e06e2.zip |
yubikey certifications!
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java | 76 |
1 files changed, 76 insertions, 0 deletions
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 new file mode 100644 index 000000000..b681aba60 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java @@ -0,0 +1,76 @@ +package org.sufficientlysecure.keychain.operations.results; + + +import android.os.Parcel; + +import org.sufficientlysecure.keychain.service.input.NfcOperationsParcel; + + +public class InputPendingResult extends OperationResult { + + // the fourth bit indicates a "data pending" result! (it's also a form of non-success) + public static final int RESULT_PENDING = RESULT_ERROR + 8; + + public static final int RESULT_PENDING_PASSPHRASE = RESULT_PENDING + 16; + public static final int RESULT_PENDING_NFC = RESULT_PENDING + 32; + + final NfcOperationsParcel mRequiredInput; + final Long mKeyIdPassphraseNeeded; + + public InputPendingResult(int result, OperationLog log) { + super(result, log); + mRequiredInput = null; + mKeyIdPassphraseNeeded = null; + } + + public InputPendingResult(OperationLog log, NfcOperationsParcel requiredInput) { + super(RESULT_PENDING_NFC, log); + mRequiredInput = requiredInput; + mKeyIdPassphraseNeeded = null; + } + + public InputPendingResult(OperationLog log, long keyIdPassphraseNeeded) { + super(RESULT_PENDING_PASSPHRASE, log); + mRequiredInput = null; + mKeyIdPassphraseNeeded = keyIdPassphraseNeeded; + } + + public InputPendingResult(Parcel source) { + super(source); + mRequiredInput = source.readParcelable(getClass().getClassLoader()); + mKeyIdPassphraseNeeded = source.readInt() != 0 ? source.readLong() : null; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + super.writeToParcel(dest, flags); + dest.writeParcelable(mRequiredInput, 0); + if (mKeyIdPassphraseNeeded != null) { + dest.writeInt(1); + dest.writeLong(mKeyIdPassphraseNeeded); + } else { + dest.writeInt(0); + } + } + + public boolean isPending() { + return (mResult & RESULT_PENDING) == RESULT_PENDING; + } + + public boolean isNfcPending() { + return (mResult & RESULT_PENDING_NFC) == RESULT_PENDING_NFC; + } + + public boolean isPassphrasePending() { + return (mResult & RESULT_PENDING_PASSPHRASE) == RESULT_PENDING_PASSPHRASE; + } + + public NfcOperationsParcel getNfcOperationsParcel() { + return mRequiredInput; + } + + public long getPassphraseKeyId() { + return mKeyIdPassphraseNeeded; + } + +} |