diff options
author | Dominik <dominik@dominikschuermann.de> | 2012-11-17 19:54:49 +0100 |
---|---|---|
committer | Dominik <dominik@dominikschuermann.de> | 2012-11-17 19:54:49 +0100 |
commit | 0123bef9ce622b5c86ed5cf5805131bedde008a6 (patch) | |
tree | 6eb9706d5e7c7bc994d12d5c33bc4b6f50cf62ca /org_apg/src/org/thialfihar/android/apg/ui | |
parent | 56cfb6bc5a5494cb31a3188d6bb4fa53074dbe6a (diff) | |
download | open-keychain-0123bef9ce622b5c86ed5cf5805131bedde008a6.tar.gz open-keychain-0123bef9ce622b5c86ed5cf5805131bedde008a6.tar.bz2 open-keychain-0123bef9ce622b5c86ed5cf5805131bedde008a6.zip |
fixed sql quieries in select pub/secret key
Diffstat (limited to 'org_apg/src/org/thialfihar/android/apg/ui')
4 files changed, 44 insertions, 28 deletions
diff --git a/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java index 8879034cb..482372c51 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java @@ -77,7 +77,7 @@ public class EncryptActivity extends SherlockFragmentActivity { public static final String ACTION_GENERATE_SIGNATURE_AND_RETURN = Constants.INTENT_PREFIX + "GENERATE_SIGNATURE"; - public static final String ACTION_ENCRYPT_STREAM = Constants.INTENT_PREFIX + "ENCRYPT_STREAM"; + public static final String ACTION_ENCRYPT_FILE = Constants.INTENT_PREFIX + "ENCRYPT_FILE"; public static final String ACTION_ENCRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX + "ENCRYPT_STREAM_AND_RETURN"; @@ -132,9 +132,9 @@ public class EncryptActivity extends SherlockFragmentActivity { private String mInputFilename = null; private String mOutputFilename = null; - private boolean mAsciiArmourDemand = false; + private boolean mAsciiArmorDemand = false; private boolean mOverrideAsciiArmour = false; - private Uri mIntentDataUri = null; + private Uri mStreamAndReturnUri = null; private byte[] mData = null; private boolean mGenerateSignature = false; @@ -265,7 +265,7 @@ public class EncryptActivity extends SherlockFragmentActivity { } else { // files via content provider, override uri and action uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); - action = ACTION_ENCRYPT_STREAM; + action = ACTION_ENCRYPT_FILE; } } @@ -277,13 +277,13 @@ public class EncryptActivity extends SherlockFragmentActivity { if (ACTION_GENERATE_SIGNATURE_AND_RETURN.equals(action)) { mGenerateSignature = true; mOverrideAsciiArmour = true; - mAsciiArmourDemand = false; + mAsciiArmorDemand = false; } if (extras.containsKey(EXTRA_ASCII_ARMOUR)) { - mAsciiArmourDemand = extras.getBoolean(EXTRA_ASCII_ARMOUR, true); + mAsciiArmorDemand = extras.getBoolean(EXTRA_ASCII_ARMOUR, true); mOverrideAsciiArmour = true; - mAsciiArmour.setChecked(mAsciiArmourDemand); + mAsciiArmour.setChecked(mAsciiArmorDemand); } mData = extras.getByteArray(EXTRA_DATA); @@ -309,7 +309,7 @@ public class EncryptActivity extends SherlockFragmentActivity { while (mSource.getCurrentView().getId() != R.id.sourceMessage) { mSource.showNext(); } - } else if (ACTION_ENCRYPT_STREAM.equals(action)) { + } else if (ACTION_ENCRYPT_FILE.equals(action)) { // get file path from uri String path = FileHelper.getPath(this, uri); @@ -324,7 +324,7 @@ public class EncryptActivity extends SherlockFragmentActivity { } } else { Log.e(Constants.TAG, - "Direct binary data without actual file in filesystem is not supported"); + "Direct binary data without actual file in filesystem is not supported. This is only supported by ACTION_ENCRYPT_STREAM_AND_RETURN."); Toast.makeText(this, R.string.error_onlyFilesAreSupported, Toast.LENGTH_LONG) .show(); // end activity @@ -334,6 +334,8 @@ public class EncryptActivity extends SherlockFragmentActivity { } else if (ACTION_ENCRYPT_STREAM_AND_RETURN.equals(action)) { // use mIntentDataUri to encrypt any stream and return // TODO + + mStreamAndReturnUri = null; } } @@ -687,9 +689,10 @@ public class EncryptActivity extends SherlockFragmentActivity { intent.putExtra(ApgIntentService.EXTRA_ACTION, ApgIntentService.ACTION_ENCRYPT_SIGN); // choose default settings, target and data bundle by target - if (mIntentDataUri != null) { + if (mStreamAndReturnUri != null) { + // mIntentDataUri is only defined when ACTION_ENCRYPT_STREAM_AND_RETURN is used data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM); - data.putParcelable(ApgIntentService.PROVIDER_URI, mIntentDataUri); + data.putParcelable(ApgIntentService.PROVIDER_URI, mStreamAndReturnUri); } else if (mEncryptTarget == Id.target.file) { useAsciiArmor = mAsciiArmour.isChecked(); @@ -721,7 +724,7 @@ public class EncryptActivity extends SherlockFragmentActivity { } if (mOverrideAsciiArmour) { - useAsciiArmor = mAsciiArmourDemand; + useAsciiArmor = mAsciiArmorDemand; } data.putLong(ApgIntentService.SECRET_KEY_ID, mSecretKeyId); diff --git a/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyFragment.java b/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyFragment.java index ff5e22035..744c3fa81 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyFragment.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/SelectPublicKeyFragment.java @@ -22,6 +22,7 @@ import java.util.Vector; import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.R; +import org.thialfihar.android.apg.provider.ApgDatabase; import org.thialfihar.android.apg.provider.ApgContract.KeyRings; import org.thialfihar.android.apg.provider.ApgContract.Keys; import org.thialfihar.android.apg.provider.ApgContract.UserIds; @@ -162,14 +163,19 @@ public class SelectPublicKeyFragment extends SherlockListFragment implements KeyRings._ID, KeyRings.MASTER_KEY_ID, UserIds.USER_ID, - "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp." - + Keys.IS_REVOKED + " = '0' AND tmp." + Keys.CAN_ENCRYPT + " = '1') AS " + "(SELECT COUNT(available_keys." + Keys._ID + ") FROM " + Tables.KEYS + + " AS available_keys WHERE available_keys." + Keys.KEY_RING_ROW_ID + " = " + + ApgDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + + " AND available_keys." + Keys.IS_REVOKED + " = '0' AND available_keys." + + Keys.CAN_ENCRYPT + " = '1') AS " + SelectKeyCursorAdapter.PROJECTION_ROW_AVAILABLE, - "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp." - + Keys.IS_REVOKED + " = '0' AND " + Keys.CAN_ENCRYPT + " = '1' AND tmp." - + Keys.CREATION + " <= '" + now + "' AND " + "(tmp." + Keys.EXPIRY - + " IS NULL OR tmp." + Keys.EXPIRY + " >= '" + now + "')) AS " - + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; + "(SELECT COUNT(valid_keys." + Keys._ID + ") FROM " + Tables.KEYS + + " AS valid_keys WHERE valid_keys." + Keys.KEY_RING_ROW_ID + " = " + + ApgDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + " AND valid_keys." + + Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_ENCRYPT + + " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND " + + "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY + + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; String inMasterKeyList = null; if (mSelectedMasterKeyIds != null && mSelectedMasterKeyIds.length > 0) { diff --git a/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyFragment.java b/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyFragment.java index 6bb0eb014..1f3fcb816 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyFragment.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/SelectSecretKeyFragment.java @@ -21,6 +21,7 @@ import java.util.Date; import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.R; +import org.thialfihar.android.apg.provider.ApgDatabase; import org.thialfihar.android.apg.provider.ApgContract.KeyRings; import org.thialfihar.android.apg.provider.ApgContract.Keys; import org.thialfihar.android.apg.provider.ApgContract.UserIds; @@ -96,14 +97,19 @@ public class SelectSecretKeyFragment extends SherlockListFragment implements KeyRings._ID, KeyRings.MASTER_KEY_ID, UserIds.USER_ID, - "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp." - + Keys.IS_REVOKED + " = '0' AND tmp." + Keys.CAN_SIGN + " = '1') AS " + "(SELECT COUNT(available_keys." + Keys._ID + ") FROM " + Tables.KEYS + + " AS available_keys WHERE available_keys." + Keys.KEY_RING_ROW_ID + " = " + + ApgDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + + " AND available_keys." + Keys.IS_REVOKED + " = '0' AND available_keys." + + Keys.CAN_SIGN + " = '1') AS " + SelectKeyCursorAdapter.PROJECTION_ROW_AVAILABLE, - "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Tables.KEYS + " AS tmp WHERE tmp." - + Keys.IS_REVOKED + " = '0' AND " + Keys.CAN_SIGN + " = '1' AND tmp." - + Keys.CREATION + " <= '" + now + "' AND " + "(tmp." + Keys.EXPIRY - + " IS NULL OR tmp." + Keys.EXPIRY + " >= '" + now + "')) AS " - + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; + "(SELECT COUNT(valid_keys." + Keys._ID + ") FROM " + Tables.KEYS + + " AS valid_keys WHERE valid_keys." + Keys.KEY_RING_ROW_ID + " = " + + ApgDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + " AND valid_keys." + + Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN + + " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND " + + "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY + + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; // if (searchString != null && searchString.trim().length() > 0) { // String[] chunks = searchString.trim().split(" +"); diff --git a/org_apg/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java b/org_apg/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java index 87d715fd9..f8adc3b72 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java @@ -140,15 +140,16 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { Vector<Choice> choices = new Vector<Choice>(); boolean isElGamalKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT); + boolean isDSAKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.DSA); if (!isElGamalKey) { choices.add(new Choice(Id.choice.usage.sign_only, getResources().getString( R.string.choice_signOnly))); } - if (!mIsMasterKey) { + if (!mIsMasterKey && !isDSAKey) { choices.add(new Choice(Id.choice.usage.encrypt_only, getResources().getString( R.string.choice_encryptOnly))); } - if (!isElGamalKey) { + if (!isElGamalKey && !isDSAKey) { choices.add(new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString( R.string.choice_signAndEncrypt))); } |