From 8c30e0cfdb1df984c5f62bf620ae2934b8287f87 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Sat, 29 Jan 2011 09:41:40 +0000 Subject: [PATCH] Added database support for repo public key --- src/org/fdroid/fdroid/DB.java | 13 ++++++++++--- src/org/fdroid/fdroid/ManageRepo.java | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 78534d678..fc64eea89 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -182,6 +182,7 @@ public class DB { public String address; public boolean inuse; public int priority; + public String pubkey; // null for an unsigned repo } // SQL to update the database to versions beyond the first. Here is @@ -215,8 +216,10 @@ public class DB { { "alter table " + TABLE_APP + " add antiFeatures string" }, // Version 6... - { "alter table " + TABLE_APK + " add sig string" } + { "alter table " + TABLE_APK + " add sig string" }, + // Version 7... + { "alter table " + TABLE_REPO + " add pubkey string" } }; private class DBHelper extends SQLiteOpenHelper { @@ -234,6 +237,8 @@ public class DB { values.put("address", "http://f-droid.org/repo"); values.put("inuse", 1); values.put("priority", 10); + String pubkey = null; + values.put("pubkey", pubkey); db.insert(TABLE_REPO, null, values); onUpgrade(db, 1, DB_UPGRADES.length + 1); } @@ -624,7 +629,7 @@ public class DB { Vector repos = new Vector(); Cursor c = null; try { - c = db.rawQuery("select address, inuse, priority from " + c = db.rawQuery("select address, inuse, priority, pubkey from " + TABLE_REPO + " order by priority", null); c.moveToFirst(); while (!c.isAfterLast()) { @@ -632,6 +637,7 @@ public class DB { repo.address = c.getString(0); repo.inuse = (c.getInt(1) == 1); repo.priority = c.getInt(2); + repo.pubkey = c.getString(3); repos.add(repo); c.moveToNext(); } @@ -650,11 +656,12 @@ public class DB { new String[] { address }); } - public void addServer(String address, int priority) { + public void addServer(String address, int priority, String pubkey) { ContentValues values = new ContentValues(); values.put("address", address); values.put("inuse", 1); values.put("priority", priority); + values.put("pubkey", pubkey); db.insert(TABLE_REPO, null, values); } diff --git a/src/org/fdroid/fdroid/ManageRepo.java b/src/org/fdroid/fdroid/ManageRepo.java index c83ea9b73..f121871b6 100644 --- a/src/org/fdroid/fdroid/ManageRepo.java +++ b/src/org/fdroid/fdroid/ManageRepo.java @@ -131,7 +131,7 @@ public class ManageRepo extends ListActivity { EditText uri = (EditText) alrt .findViewById(R.id.edit_uri); String uri_str = uri.getText().toString(); - db.addServer(uri_str, 10); + db.addServer(uri_str, 10, null); changed = true; redraw(); }