From c87898579680a35709c7e98944c06dcffb014317 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 8 May 2023 12:35:19 -0500 Subject: [PATCH] Once you have really entered an onboarding flow, don't bail out Going back in and pushing cancel should not bail you out anymore, you're waiting for the onboarding to finish somehow. --- .../conversations/entities/Conversation.java | 27 ++++++++++++++----- .../services/XmppConnectionService.java | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index ed312cb71de0259bc178a3abd07116e5de5d7b9d..ac35f7faf01037df31f5283efd40c9f9710da8f0 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -2578,6 +2578,10 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl xmppConnectionService.createContact(getAccount().getRoster().getContact(iq.getFrom()), true); } + if (xmppConnectionService.isOnboarding() && mNode.equals("jabber:iq:register") && !"canceled".equals(command.getAttribute("status")) && xmppConnectionService.getPreferences().contains("onboarding_action")) { + xmppConnectionService.getPreferences().edit().putBoolean("onboarding_continued", true).commit(); + } + for (Element el : command.getChildren()) { if (el.getName().equals("actions") && el.getNamespace().equals("http://jabber.org/protocol/commands")) { for (Element action : el.getChildren()) { @@ -2650,12 +2654,19 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } if (responseElement == null && command.getAttribute("status") != null && (command.getAttribute("status").equals("completed") || command.getAttribute("status").equals("canceled"))) { - if (mNode.equals("jabber:iq:register") && command.getAttribute("status").equals("canceled")) { + if ("jabber:iq:register".equals(mNode) && "canceled".equals(command.getAttribute("status"))) { if (xmppConnectionService.isOnboarding()) { - if (!xmppConnectionService.getPreferences().contains("onboarding_action")) { - xmppConnectionService.getPreferences().edit().putString("onboarding_action", "cancel").commit(); + if (xmppConnectionService.getPreferences().contains("onboarding_action")) { + xmppConnectionService.deleteAccount(getAccount()); + } else { + if (xmppConnectionService.getPreferences().getBoolean("onboarding_continued", false)) { + removeSession(this); + return; + } else { + xmppConnectionService.getPreferences().edit().putString("onboarding_action", "cancel").commit(); + xmppConnectionService.deleteAccount(getAccount()); + } } - xmppConnectionService.deleteAccount(getAccount()); } xmppConnectionService.archiveConversation(Conversation.this); } @@ -2945,8 +2956,12 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl c.setAttribute("action", "execute"); } - if (mNode.equals("jabber:iq:register") && xmppConnectionService.isOnboarding() && form.getValue("gateway-jid") != null) { - xmppConnectionService.getPreferences().edit().putString("onboarding_action", form.getValue("gateway-jid")).commit(); + if (mNode.equals("jabber:iq:register") && xmppConnectionService.isOnboarding() && form.getFieldByName("gateway-jid") != null) { + if (form.getValue("gateway-jid") == null) { + xmppConnectionService.getPreferences().edit().remove("onboarding_action").commit(); + } else { + xmppConnectionService.getPreferences().edit().putString("onboarding_action", form.getValue("gateway-jid")).commit(); + } } responseElement.setAttribute("type", "submit"); diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 1c420325c922356ad46b3557bcc0972c54d27ba9..160c0853aecba74c0ad85d41b966a0e8a3a9a0d4 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2607,6 +2607,7 @@ public class XmppConnectionService extends Service { } public void deleteAccount(final Account account) { + getPreferences().edit().remove("onboarding_continued").commit(); final boolean connected = account.getStatus() == Account.State.ONLINE; synchronized (this.conversations) { if (connected) {