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; import org.spongycastle.bcpg.CompressionAlgorithmTags;
/** /**
*
* TODO: * TODO:
* * <p/>
* - refactor ids, some are not needed and can be done with xml * - refactor ids, some are not needed and can be done with xml
*
*/ */
public final class Id { public final class Id {
@ -34,7 +32,6 @@ public final class Id {
public static final int secret_key = 0x21070002; public static final int secret_key = 0x21070002;
public static final int user_id = 0x21070003; public static final int user_id = 0x21070003;
public static final int key = 0x21070004; public static final int key = 0x21070004;
public static final int public_secret_key = 0x21070005;
} }
public static final class choice { public static final class choice {
@ -50,19 +47,6 @@ public final class Id {
public static final int bzip2 = CompressionAlgorithmTags.BZIP2; public static final int bzip2 = CompressionAlgorithmTags.BZIP2;
public static final int zip = CompressionAlgorithmTags.ZIP; 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 { public static final class return_value {
@ -73,34 +57,9 @@ public final class Id {
public static final int bad = -3; 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 class key {
public static final int none = 0; public static final int none = 0;
public static final int symmetric = -1; 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); return "OpenPGP Keychain v" + getVersion(context);
} }
public static int getStreamContent(Context context, InputStream inStream) throws IOException { // public static final class content {
InputStream in = PGPUtil.getDecoderStream(inStream); // public static final int unknown = 0;
PGPObjectFactory pgpF = new PGPObjectFactory(in); // public static final int encrypted_data = 1;
Object object = pgpF.nextObject(); // public static final int keys = 2;
while (object != null) { // }
if (object instanceof PGPPublicKeyRing || object instanceof PGPSecretKeyRing) { //
return Id.content.keys; // public static int getStreamContent(Context context, InputStream inStream) throws IOException {
} else if (object instanceof PGPEncryptedDataList) { //
return Id.content.encrypted_data; // InputStream in = PGPUtil.getDecoderStream(inStream);
} // PGPObjectFactory pgpF = new PGPObjectFactory(in);
object = pgpF.nextObject(); // Object object = pgpF.nextObject();
} // while (object != null) {
// if (object instanceof PGPPublicKeyRing || object instanceof PGPSecretKeyRing) {
return Id.content.unknown; // 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 * Generate a random filename

View File

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