aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-07-07 19:27:12 +0200
committerAndreas Straub <andy@strb.org>2015-07-19 21:32:27 +0200
commit491f623708437f418497ecace2876e9c81708e72 (patch)
treeb4105023c411984e481fd90c9f307b6acc181893 /src/main/java/eu/siacs
parent0cf64857cfa8d42b8759ca2934af91d6060c55a5 (diff)
Fix displaying Contact IdentityKeys
Migrate ContactDetailsActivity to use new SQL IdentityKeys storage, remove dead code from Contact class.
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Contact.java64
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java3
2 files changed, 2 insertions, 65 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java
index 240d5223..fdb5f932 100644
--- a/src/main/java/eu/siacs/conversations/entities/Contact.java
+++ b/src/main/java/eu/siacs/conversations/entities/Contact.java
@@ -350,70 +350,6 @@ public class Contact implements ListItem, Blockable {
}
}
- public List<IdentityKey> getAxolotlIdentityKeys() {
- synchronized (this.keys) {
- JSONArray serializedKeyItems = this.keys.optJSONArray("axolotl_identity_key");
- List<IdentityKey> identityKeys = new ArrayList<>();
- List<Integer> toDelete = new ArrayList<>();
- if(serializedKeyItems != null) {
- for(int i = 0; i<serializedKeyItems.length();++i) {
- try {
- String serializedKeyItem = serializedKeyItems.getString(i);
- IdentityKey identityKey = new IdentityKey(Base64.decode(serializedKeyItem, Base64.DEFAULT), 0);
- identityKeys.add(identityKey);
- } catch (InvalidKeyException e) {
- Log.e(Config.LOGTAG, "Invalid axolotl identity key encountered at contact" + this.getJid() + ": " + e.getMessage() + ", marking for deletion...");
- toDelete.add(i);
- } catch (JSONException e) {
- Log.e(Config.LOGTAG, "Error retrieving axolotl identity key at contact " + this.getJid() + ": " + e.getMessage());
- } catch (IllegalArgumentException e) {
- Log.e(Config.LOGTAG, "Encountered malformed identity key for contact" + this.getJid() + ": " + e.getMessage() + ", marking for deletion... ");
- toDelete.add(i);
- }
- }
- if(!toDelete.isEmpty()) {
- try {
- JSONArray filteredKeyItems = new JSONArray();
- for (int i = 0; i < serializedKeyItems.length(); ++i) {
- if (!toDelete.contains(i)) {
- filteredKeyItems.put(serializedKeyItems.get(i));
- }
- }
- this.keys.put("axolotl_identity_key", filteredKeyItems);
- } catch (JSONException e) {
- //should never happen
- }
- }
- }
- return identityKeys;
- }
- }
-
- public boolean addAxolotlIdentityKey(IdentityKey identityKey) {
- synchronized (this.keys) {
- if(!getAxolotlIdentityKeys().contains(identityKey)) {
- JSONArray keysList;
- try {
- keysList = this.keys.getJSONArray("axolotl_identity_key");
- } catch (JSONException e) {
- keysList = new JSONArray();
- }
-
- keysList.put(Base64.encodeToString(identityKey.serialize(), Base64.DEFAULT));
- try {
- this.keys.put("axolotl_identity_key", keysList);
- } catch (JSONException e) {
- Log.e(Config.LOGTAG, "Error adding Identity Key to Contact " + this.getJid() + ": " + e.getMessage());
- return false;
- }
- return true;
- } else {
- return false;
- }
- }
- }
-
-
public void setOption(int option) {
this.subscription |= 1 << option;
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
index fb04946a..2777b814 100644
--- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -377,7 +377,8 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
}
});
}
- for(final IdentityKey identityKey:contact.getAxolotlIdentityKeys()) {
+ for(final IdentityKey identityKey : xmppConnectionService.databaseBackend.loadIdentityKeys(
+ contact.getAccount(), contact.getJid().toBareJid().toString())) {
hasKeys = true;
View view = inflater.inflate(R.layout.contact_key, keys, false);
TextView key = (TextView) view.findViewById(R.id.key);