From ce34700a00a8818d45ef3c0515fe9fae6da229fa Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 29 May 2023 18:58:09 -0500 Subject: [PATCH] Get full list of gateway types Still just use first on the label for now --- .../siacs/conversations/ui/EnterJidDialog.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java b/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java index 10f598e6993d81f9471a7d81d225c3788c2ccb95..dcf67f97b14b34f516b047d12f09f167aeca54da 100644 --- a/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java +++ b/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java @@ -516,14 +516,22 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected } public String getType(Contact gateway) { + List types = getTypes(gateway); + return types.isEmpty() ? null : types.get(0); + } + + public List getTypes(Contact gateway) { + List types = new ArrayList<>(); + for(Presence p : gateway.getPresences().getPresences()) { - ServiceDiscoveryResult.Identity id; - if(p.getServiceDiscoveryResult() != null && (id = p.getServiceDiscoveryResult().getIdentity("gateway", null)) != null) { - return id.getType(); + if(p.getServiceDiscoveryResult() != null) { + for (ServiceDiscoveryResult.Identity id : p.getServiceDiscoveryResult().getIdentities()) { + if ("gateway".equals(id.getCategory())) types.add(id.getType()); + } } } - return null; + return types; } public String getSelectedType() {