Skip to content

Commit

Permalink
Update names
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapk00 committed Apr 12, 2019
1 parent 43b00b0 commit e486295
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/com/adityapk/zcash/zqwandroid/DataModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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" -> {
Expand Down

0 comments on commit e486295

Please sign in to comment.