aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/parser
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-06-29 14:18:11 +0200
committerAndreas Straub <andy@strb.org>2015-07-19 21:32:26 +0200
commitc1d23b2395bfc9570aed07ba3413f988f08d84f5 (patch)
tree9dc5a3ec5fa69981bb9416f445a80a3261c12b63 /src/main/java/eu/siacs/conversations/parser
parent6492801b89cea496b41fe77e6b2a9be18abb2081 (diff)
Migrate to new PEP layout
Merge prekeys into bundle node
Diffstat (limited to 'src/main/java/eu/siacs/conversations/parser')
-rw-r--r--src/main/java/eu/siacs/conversations/parser/IqParser.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/IqParser.java b/src/main/java/eu/siacs/conversations/parser/IqParser.java
index df143a41..93551787 100644
--- a/src/main/java/eu/siacs/conversations/parser/IqParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/IqParser.java
@@ -12,8 +12,10 @@ import org.whispersystems.libaxolotl.state.PreKeyBundle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
@@ -94,8 +96,8 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
return items.findChild("item");
}
- public List<Integer> deviceIds(final Element item) {
- List<Integer> deviceIds = new ArrayList<>();
+ public Set<Integer> deviceIds(final Element item) {
+ Set<Integer> deviceIds = new HashSet<>();
if (item == null) {
return null;
}
@@ -165,14 +167,18 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
public Map<Integer, ECPublicKey> preKeyPublics(final IqPacket packet) {
Map<Integer, ECPublicKey> preKeyRecords = new HashMap<>();
- Element prekeysItem = getItem(packet);
- if (prekeysItem == null) {
- Log.d(Config.LOGTAG, "Couldn't find <item> in preKeyPublic IQ packet: " + packet);
+ Element item = getItem(packet);
+ if (item == null) {
+ Log.d(Config.LOGTAG, "Couldn't find <item> in bundle IQ packet: " + packet);
+ return null;
+ }
+ final Element bundleElement = item.findChild("bundle");
+ if(bundleElement == null) {
return null;
}
- final Element prekeysElement = prekeysItem.findChild("prekeys");
+ final Element prekeysElement = bundleElement.findChild("prekeys");
if(prekeysElement == null) {
- Log.d(Config.LOGTAG, "Couldn't find <prekeys> in preKeyPublic IQ packet: " + packet);
+ Log.d(Config.LOGTAG, "Couldn't find <prekeys> in bundle IQ packet: " + packet);
return null;
}
for(Element preKeyPublicElement : prekeysElement.getChildren()) {