diff options
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/provider/ProviderHelper.java')
-rw-r--r-- | OpenPGP-Keychain/src/org/sufficientlysecure/keychain/provider/ProviderHelper.java | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 60aa0542e..42210db6a 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -36,6 +36,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables; +import org.sufficientlysecure.keychain.remote_api.AppSettings; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; @@ -739,12 +740,50 @@ public class ProviderHelper { return packageNames; } - public static void addCryptoConsumer(Context context, String packageName, long keyId, - boolean asciiArmor) { + private static void contentValueForApiApps() { + + } + + public static void insertApiApp(Context context, AppSettings appSettings) { ContentValues values = new ContentValues(); - values.put(ApiApps.PACKAGE_NAME, packageName); - values.put(ApiApps.KEY_ID, keyId); - values.put(ApiApps.ASCII_ARMOR, asciiArmor); + values.put(ApiApps.PACKAGE_NAME, appSettings.getPackageName()); + values.put(ApiApps.KEY_ID, appSettings.getKeyId()); + values.put(ApiApps.ASCII_ARMOR, appSettings.isAsciiArmor()); + // TODO: other parameters context.getContentResolver().insert(ApiApps.CONTENT_URI, values); } + + public static void updateApiApp(Context context, AppSettings appSettings, Uri uri) { + final ContentValues cv = new ContentValues(); + cv.put(KeychainContract.ApiApps.KEY_ID, appSettings.getKeyId()); + + cv.put(KeychainContract.ApiApps.ASCII_ARMOR, appSettings.isAsciiArmor()); + // TODO: other parameters + + if (context.getContentResolver().update(uri, cv, null, null) <= 0) { + throw new RuntimeException(); + } + } + + public static AppSettings getApiAppSettings(Context context, Uri uri) { + AppSettings settings = new AppSettings(); + Cursor cur = context.getContentResolver().query(uri, null, null, null, null); + if (cur.moveToFirst()) { + settings.setPackageName(cur.getString(cur + .getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME))); + + settings.setKeyId(cur.getLong(cur.getColumnIndex(KeychainContract.ApiApps.KEY_ID))); + + settings.setAsciiArmor(cur.getInt(cur + .getColumnIndexOrThrow(KeychainContract.ApiApps.ASCII_ARMOR)) == 1); + + settings.setPackageName(cur.getString(cur + .getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME))); + + settings.setPackageName(cur.getString(cur + .getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME))); + } + + return settings; + } } |