More ids removed

This commit is contained in:
Dominik Schürmann 2014-04-11 20:23:46 +02:00
parent 89cf46bbd7
commit 12b8282d9b
3 changed files with 28 additions and 60 deletions

View File

@ -20,11 +20,9 @@ package org.sufficientlysecure.keychain;
import org.spongycastle.bcpg.CompressionAlgorithmTags;
/**
*
* TODO:
*
* <p/>
* - refactor ids, some are not needed and can be done with xml
*
*/
public final class Id {
@ -34,7 +32,6 @@ public final class Id {
public static final int secret_key = 0x21070002;
public static final int user_id = 0x21070003;
public static final int key = 0x21070004;
public static final int public_secret_key = 0x21070005;
}
public static final class choice {
@ -50,19 +47,6 @@ public final class Id {
public static final int bzip2 = CompressionAlgorithmTags.BZIP2;
public static final int zip = CompressionAlgorithmTags.ZIP;
}
public static final class usage {
public static final int sign_only = 0x21070001;
public static final int encrypt_only = 0x21070002;
public static final int sign_and_encrypt = 0x21070003;
}
public static final class action {
public static final int encrypt = 0x21070001;
public static final int decrypt = 0x21070002;
public static final int import_public = 0x21070003;
public static final int import_secret = 0x21070004;
}
}
public static final class return_value {
@ -73,34 +57,9 @@ public final class Id {
public static final int bad = -3;
}
public static final class target {
public static final int clipboard = 0x21070001;
public static final int email = 0x21070002;
public static final int file = 0x21070003;
public static final int message = 0x21070004;
}
public static final class mode {
public static final int undefined = 0x21070001;
public static final int byte_array = 0x21070002;
public static final int file = 0x21070003;
public static final int stream = 0x21070004;
}
public static final class key {
public static final int none = 0;
public static final int symmetric = -1;
}
public static final class content {
public static final int unknown = 0;
public static final int encrypted_data = 1;
public static final int keys = 2;
}
public static final class keyserver {
public static final int search = 0x21070001;
public static final int get = 0x21070002;
public static final int add = 0x21070003;
}
}

View File

@ -71,21 +71,28 @@ public class PgpHelper {
return "OpenPGP Keychain v" + getVersion(context);
}
public static int getStreamContent(Context context, InputStream inStream) throws IOException {
InputStream in = PGPUtil.getDecoderStream(inStream);
PGPObjectFactory pgpF = new PGPObjectFactory(in);
Object object = pgpF.nextObject();
while (object != null) {
if (object instanceof PGPPublicKeyRing || object instanceof PGPSecretKeyRing) {
return Id.content.keys;
} else if (object instanceof PGPEncryptedDataList) {
return Id.content.encrypted_data;
}
object = pgpF.nextObject();
}
return Id.content.unknown;
}
// public static final class content {
// public static final int unknown = 0;
// public static final int encrypted_data = 1;
// public static final int keys = 2;
// }
//
// public static int getStreamContent(Context context, InputStream inStream) throws IOException {
//
// InputStream in = PGPUtil.getDecoderStream(inStream);
// PGPObjectFactory pgpF = new PGPObjectFactory(in);
// Object object = pgpF.nextObject();
// while (object != null) {
// if (object instanceof PGPPublicKeyRing || object instanceof PGPSecretKeyRing) {
// return Id.content.keys;
// } else if (object instanceof PGPEncryptedDataList) {
// return Id.content.encrypted_data;
// }
// object = pgpF.nextObject();
// }
//
// return Id.content.unknown;
// }
/**
* Generate a random filename

View File

@ -24,7 +24,9 @@ import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.beardedhen.androidbootstrap.BootstrapButton;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R;
@ -79,7 +81,7 @@ public class ImportKeysFileFragment extends Fragment {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode & 0xFFFF) {
switch (requestCode) {
case REQUEST_CODE_FILE: {
if (resultCode == Activity.RESULT_OK && data != null) {