From 0c22a8d1c6a984ccd0080d74a07d500879ee8242 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 25 Dec 2014 22:08:13 +0100 Subject: added callback to change account password to notify UI on success / failure --- .../services/XmppConnectionService.java | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/services/XmppConnectionService.java') diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 640074ba..dc895e5b 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1100,19 +1100,25 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa getNotificationService().updateErrorNotification(); } - public void updateAccountPasswordOnServer(final Account account, final String newPassword) { - if (account.isOnlineAndConnected()) { - final IqPacket iq = getIqGenerator().generateSetPassword(account, newPassword); - sendIqPacket(account, iq, new OnIqPacketReceived() { - @Override - public void onIqPacketReceived(final Account account, final IqPacket packet) { - if (packet.getType() == IqPacket.TYPE_RESULT) { - account.setPassword(newPassword); - updateAccount(account); - } + public void updateAccountPasswordOnServer(final Account account, final String newPassword, final OnAccountPasswordChanged callback) { + final IqPacket iq = getIqGenerator().generateSetPassword(account, newPassword); + sendIqPacket(account, iq, new OnIqPacketReceived() { + @Override + public void onIqPacketReceived(final Account account, final IqPacket packet) { + if (packet.getType() == IqPacket.TYPE_RESULT) { + account.setPassword(newPassword); + databaseBackend.updateAccount(account); + callback.onPasswordChangeSucceeded(); + } else { + callback.onPasswordChangeFailed(); } - }); - } + } + }); + } + + public interface OnAccountPasswordChanged { + public void onPasswordChangeSucceeded(); + public void onPasswordChangeFailed(); } public void deleteAccount(final Account account) { -- cgit v1.2.3