From 9efef24a04d3ba9802bef191e6b7dc739785ebad Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 7 Oct 2016 14:54:35 +0200 Subject: [PATCH] reset sending to waiting on every error --- .../conversations/services/XmppConnectionService.java | 9 ++++++++- .../java/eu/siacs/conversations/xmpp/XmppConnection.java | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index e8b13ddea..f6298ea27 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -343,6 +343,7 @@ public class XmppConnectionService extends Service { reconnectAccount(account, true, false); } else if ((account.getStatus() != Account.State.CONNECTING) && (account.getStatus() != Account.State.NO_INTERNET)) { + resetSendingToWaiting(account); if (connection != null) { int next = connection.getTimeToNextAttempt(); Log.d(Config.LOGTAG, account.getJid().toBareJid() @@ -1312,6 +1313,13 @@ public class XmppConnectionService extends Service { for (Conversation conversation : conversations) { conversation.addAll(0, databaseBackend.getMessages(conversation, Config.PAGE_SIZE)); checkDeletedFiles(conversation); + conversation.findUnsentTextMessages(new Conversation.OnMessageFound() { + + @Override + public void onMessageFound(Message message) { + markMessage(message, Message.STATUS_WAITING); + } + }); conversation.findUnreadMessages(new Conversation.OnMessageFound() { @Override public void onMessageFound(Message message) { @@ -2894,7 +2902,6 @@ public class XmppConnectionService extends Service { } public void resetSendingToWaiting(Account account) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": reset 'sending' messages to 'waiting'"); for (Conversation conversation : getConversations()) { if (conversation.getAccount() == account) { conversation.findUnsentTextMessages(new Conversation.OnMessageFound() { diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index c8f98a346..ab92535af 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -244,6 +244,9 @@ public class XmppConnection implements Runnable { } protected void connect() { + if (mXmppConnectionService.areMessagesInitialized()) { + mXmppConnectionService.resetSendingToWaiting(account); + } Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": connecting"); features.encryptionEnabled = false; this.attempt++; @@ -1069,7 +1072,6 @@ public class XmppConnection implements Runnable { mStanzaQueue.clear(); } } - mXmppConnectionService.resetSendingToWaiting(account); features.carbonsEnabled = false; features.blockListRequested = false; synchronized (this.disco) {