Autocrypt: refactoring

pull/200/head
M66B 4 years ago
parent 273d7e0dd2
commit d98ad1b5ac

@ -6650,24 +6650,20 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
byte[] keydata = null; byte[] keydata = null;
// https://autocrypt.org/level1.html#the-autocrypt-header // https://autocrypt.org/level1.html#the-autocrypt-header
String[] param = message.autocrypt.split(";"); Map<String, String> kv = MessageHelper.getKeyValues(message.autocrypt);
for (int i = 0; i < param.length; i++) { for (String key : kv.keySet()) {
int e = param[i].indexOf("="); String value = kv.get(key).toLowerCase(Locale.ROOT);
if (e > 0) { Log.i("Autocrypt " + key + "=" + value);
String key = param[i].substring(0, e).trim().toLowerCase(Locale.ROOT); switch (key) {
String value = param[i].substring(e + 1); case "addr":
Log.i("Autocrypt " + key + "=" + value); addr = value;
switch (key) { break;
case "addr": case "prefer-encrypt":
addr = value; mutual = value.trim().toLowerCase(Locale.ROOT).equals("mutual");
break; break;
case "prefer-encrypt": case "keydata":
mutual = value.trim().toLowerCase(Locale.ROOT).equals("mutual"); keydata = Base64.decode(value, Base64.DEFAULT);
break; break;
case "keydata":
keydata = Base64.decode(value, Base64.DEFAULT);
break;
}
} }
} }

Loading…
Cancel
Save