aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-03-08 11:19:34 +0100
committerVincent Breitmoser <valodim@mugenguild.com>2014-03-08 11:19:34 +0100
commit8c6cb8b0ab9e89f9d575af829e0dd1dd9e82e401 (patch)
tree2f68c772756535527b30cb629af87fabbf0afacc /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
parent4851f7f8fc5ca82d60a55e95730bf6c11675979c (diff)
downloadopen-keychain-8c6cb8b0ab9e89f9d575af829e0dd1dd9e82e401.tar.gz
open-keychain-8c6cb8b0ab9e89f9d575af829e0dd1dd9e82e401.tar.bz2
open-keychain-8c6cb8b0ab9e89f9d575af829e0dd1dd9e82e401.zip
working unified list (no actions yet)
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
index 781f36758..85e01ae53 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
@@ -81,6 +81,8 @@ public class KeychainProvider extends ContentProvider {
private static final int API_APPS_BY_ROW_ID = 302;
private static final int API_APPS_BY_PACKAGE_NAME = 303;
+ private static final int UNIFIED_KEY_RING = 401;
+
// private static final int DATA_STREAM = 401;
protected UriMatcher mUriMatcher;
@@ -227,6 +229,16 @@ public class KeychainProvider extends ContentProvider {
+ KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_APPS_BY_PACKAGE_NAME);
/**
+ * unified key rings
+ * <pre>
+ *
+ * key_rings/unified
+ *
+ */
+ matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/"
+ + KeychainContract.PATH_UNIFIED, UNIFIED_KEY_RING);
+
+ /**
* data stream
*
* <pre>
@@ -455,6 +467,69 @@ public class KeychainProvider extends ContentProvider {
int match = mUriMatcher.match(uri);
+ // screw that switch
+ if(match == UNIFIED_KEY_RING) {
+
+ // join keyrings with keys and userIds
+ // Only get user id and key with rank 0 (main user id and main key)
+ qb.setTables(Tables.KEY_RINGS + " INNER JOIN " + Tables.KEYS + " ON " + "("
+ + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.KEYS + "."
+ + KeysColumns.KEY_RING_ROW_ID + " AND " + Tables.KEYS + "."
+ + KeysColumns.RANK + " = '0') " + " INNER JOIN " + Tables.USER_IDS + " ON "
+ + "(" + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.USER_IDS + "."
+ + UserIdsColumns.KEY_RING_ROW_ID + " AND " + Tables.USER_IDS + "."
+ + UserIdsColumns.RANK + " = '0')");
+
+ {
+ HashMap<String, String> projectionMap = new HashMap<String, String>();
+
+ projectionMap.put(KeyRingsColumns.TYPE, "MAX(" + Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + ")");
+
+ projectionMap.put(BaseColumns._ID, Tables.KEY_RINGS + "." + BaseColumns._ID);
+ projectionMap.put(KeyRingsColumns.KEY_RING_DATA, Tables.KEY_RINGS + "."
+ + KeyRingsColumns.KEY_RING_DATA);
+ projectionMap.put(KeyRingsColumns.MASTER_KEY_ID, Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID);
+ // TODO: deprecated master key id
+ //projectionMap.put(KeyRingsColumns.MASTER_KEY_ID, Tables.KEYS + "." + KeysColumns.KEY_ID);
+
+ projectionMap.put(KeysColumns.FINGERPRINT, Tables.KEYS + "." + KeysColumns.FINGERPRINT);
+ projectionMap.put(KeysColumns.IS_REVOKED, Tables.KEYS + "." + KeysColumns.IS_REVOKED);
+
+ projectionMap.put(UserIdsColumns.USER_ID, Tables.USER_IDS + "." + UserIdsColumns.USER_ID);
+
+ qb.setProjectionMap(projectionMap);
+ }
+
+ if (TextUtils.isEmpty(sortOrder)) {
+ sortOrder = Tables.USER_IDS + "." + UserIdsColumns.USER_ID + " ASC";
+ }
+
+ // If no sort order is specified use the default
+ String orderBy;
+ if (TextUtils.isEmpty(sortOrder)) {
+ orderBy = Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + " DESC";
+ } else {
+ orderBy = Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + " DESC, " + sortOrder;
+ }
+
+ Cursor c = qb.query(db, projection, selection, selectionArgs,
+ Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID,
+ null, orderBy);
+
+ // Tell the cursor what uri to watch, so it knows when its source data changes
+ c.setNotificationUri(getContext().getContentResolver(), uri);
+
+ if (Constants.DEBUG) {
+ Log.d(Constants.TAG,
+ "Query: "
+ + qb.buildQuery(projection, selection, selectionArgs, Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID, null,
+ orderBy, null));
+ Log.d(Constants.TAG, "Cursor: " + DatabaseUtils.dumpCursorToString(c));
+ }
+
+ return c;
+ }
+
switch (match) {
case PUBLIC_KEY_RING:
case SECRET_KEY_RING: