From e4862951eb1e7e7a9244f4064fdbca2f1df24ca9 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Fri, 12 Apr 2019 15:24:54 -0700 Subject: [PATCH] Update names --- app/build.gradle | 4 ++-- .../java/com/adityapk/zcash/zqwandroid/DataModel.kt | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 61e3d59..6d3f722 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.adityapk.zcash.zqwandroid" minSdkVersion 19 targetSdkVersion 28 - versionCode 4 - versionName "0.3.0" + versionCode 6 + versionName "0.3.2" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true } diff --git a/app/src/main/java/com/adityapk/zcash/zqwandroid/DataModel.kt b/app/src/main/java/com/adityapk/zcash/zqwandroid/DataModel.kt index d1796a7..99dbfc1 100644 --- a/app/src/main/java/com/adityapk/zcash/zqwandroid/DataModel.kt +++ b/app/src/main/java/com/adityapk/zcash/zqwandroid/DataModel.kt @@ -57,6 +57,7 @@ object DataModel { data class ParseResponse(val updateTxns: Boolean = false, val displayMsg: String? = null, val doDisconnect: Boolean = false) + // Parse the encrypted response string. This will decrypt it and pass it to parseDecryptedResponse() fun parseResponse(response: String) : ParseResponse { val json = Parser.default().parse(StringBuilder(response)) as JsonObject @@ -75,8 +76,16 @@ object DataModel { if (decrypted.startsWith("error")) { return ParseResponse(false, "Encryption Error: $decrypted", true) } - return parseResponse(decrypted) + return parseDecryptedResponse(decrypted) + } else { + // The input is unrecognized + return ParseResponse(false, "Unknown message received, JSON was missing a 'nonce'", true) } + } + + // Parse a decrypted response, which is expected to have a command's response + fun parseDecryptedResponse(response: String): ParseResponse { + val json = Parser.default().parse(StringBuilder(response)) as JsonObject return when (json.string("command")) { "getInfo" -> {