diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-04-29 14:02:22 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-04-29 14:02:22 +0200 |
commit | 30d3c33be971aecaf590b762d2ed45b981fb9096 (patch) | |
tree | 0f1b603449729f96f3dc54423dd560eac1067688 /OpenKeychain/src/main/java | |
parent | bb0fe2a23720a44651834db80f17d12e1dd96f39 (diff) | |
download | open-keychain-30d3c33be971aecaf590b762d2ed45b981fb9096.tar.gz open-keychain-30d3c33be971aecaf590b762d2ed45b981fb9096.tar.bz2 open-keychain-30d3c33be971aecaf590b762d2ed45b981fb9096.zip |
Formatting KeychainDatabase
Diffstat (limited to 'OpenKeychain/src/main/java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java index 0ff53b763..061f91176 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java @@ -224,10 +224,10 @@ public class KeychainDatabase extends SQLiteOpenHelper { { // It's the Java way =( String[] dbs = context.databaseList(); - for(String db : dbs) { - if(db.equals("apg.db")) { + for (String db : dbs) { + if (db.equals("apg.db")) { hasApgDb = true; - } else if(db.equals("apg_old.db")) { + } else if (db.equals("apg_old.db")) { Log.d(Constants.TAG, "Found apg_old.db"); } } @@ -262,14 +262,14 @@ public class KeychainDatabase extends SQLiteOpenHelper { + " SELECT 1 FROM key_rings d2 WHERE key_rings.master_key_id = d2.master_key_id" + " AND d2.type = 1) ORDER BY type ASC", null); Log.d(Constants.TAG, "Importing " + c.getCount() + " secret keyrings from apg.db..."); - for(int i = 0; i < c.getCount(); i++) { + for (int i = 0; i < c.getCount(); i++) { c.moveToPosition(i); byte[] data = c.getBlob(0); PGPKeyRing ring = PgpConversionHelper.BytesToPGPKeyRing(data); ProviderHelper providerHelper = new ProviderHelper(context); - if(ring instanceof PGPPublicKeyRing) + if (ring instanceof PGPPublicKeyRing) providerHelper.saveKeyRing((PGPPublicKeyRing) ring); - else if(ring instanceof PGPSecretKeyRing) + else if (ring instanceof PGPSecretKeyRing) providerHelper.saveKeyRing((PGPSecretKeyRing) ring); else { Log.e(Constants.TAG, "Unknown blob data type!"); @@ -284,14 +284,14 @@ public class KeychainDatabase extends SQLiteOpenHelper { + " d2.type = 1)) DESC, type DESC", null); // import from old database Log.d(Constants.TAG, "Importing " + c.getCount() + " keyrings from apg.db..."); - for(int i = 0; i < c.getCount(); i++) { + for (int i = 0; i < c.getCount(); i++) { c.moveToPosition(i); byte[] data = c.getBlob(0); PGPKeyRing ring = PgpConversionHelper.BytesToPGPKeyRing(data); ProviderHelper providerHelper = new ProviderHelper(context); if (ring instanceof PGPPublicKeyRing) { providerHelper.saveKeyRing((PGPPublicKeyRing) ring); - } else if(ring instanceof PGPSecretKeyRing) { + } else if (ring instanceof PGPSecretKeyRing) { providerHelper.saveKeyRing((PGPSecretKeyRing) ring); } else { Log.e(Constants.TAG, "Unknown blob data type!"); @@ -300,10 +300,10 @@ public class KeychainDatabase extends SQLiteOpenHelper { } catch (IOException e) { Log.e(Constants.TAG, "Error importing apg.db!", e); } finally { - if(c != null) { + if (c != null) { c.close(); } - if(db != null) { + if (db != null) { db.close(); } } @@ -317,37 +317,37 @@ public class KeychainDatabase extends SQLiteOpenHelper { FileInputStream ss = new FileInputStream(in); FileOutputStream ds = new FileOutputStream(out); byte[] buf = new byte[512]; - while(ss.available() > 0) { + while (ss.available() > 0) { int count = ss.read(buf, 0, 512); ds.write(buf, 0, count); } } public static void debugRead(Context context) throws IOException { - if(!Constants.DEBUG) { + if (!Constants.DEBUG) { return; } File in = context.getDatabasePath("debug.db"); File out = context.getDatabasePath("openkeychain.db"); - if(!in.canRead()) { + if (!in.canRead()) { throw new IOException("Cannot read " + in.getName()); } - if(!out.canRead()) { + if (!out.canRead()) { throw new IOException("Cannot write " + out.getName()); } copy(in, out); } public static void debugWrite(Context context) throws IOException { - if(!Constants.DEBUG) { + if (!Constants.DEBUG) { return; } File in = context.getDatabasePath("openkeychain.db"); File out = context.getDatabasePath("debug.db"); - if(!in.canRead()) { + if (!in.canRead()) { throw new IOException("Cannot read " + in.getName()); } - if(!out.canRead()) { + if (!out.canRead()) { throw new IOException("Cannot write " + out.getName()); } copy(in, out); |