reset sending to waiting on every error

This commit is contained in:
Daniel Gultsch 2016-10-07 14:54:35 +02:00
parent 5a73a6b139
commit 9efef24a04
2 changed files with 11 additions and 2 deletions

View file

@ -343,6 +343,7 @@ public class XmppConnectionService extends Service {
reconnectAccount(account, true, false); reconnectAccount(account, true, false);
} else if ((account.getStatus() != Account.State.CONNECTING) } else if ((account.getStatus() != Account.State.CONNECTING)
&& (account.getStatus() != Account.State.NO_INTERNET)) { && (account.getStatus() != Account.State.NO_INTERNET)) {
resetSendingToWaiting(account);
if (connection != null) { if (connection != null) {
int next = connection.getTimeToNextAttempt(); int next = connection.getTimeToNextAttempt();
Log.d(Config.LOGTAG, account.getJid().toBareJid() Log.d(Config.LOGTAG, account.getJid().toBareJid()
@ -1312,6 +1313,13 @@ public class XmppConnectionService extends Service {
for (Conversation conversation : conversations) { for (Conversation conversation : conversations) {
conversation.addAll(0, databaseBackend.getMessages(conversation, Config.PAGE_SIZE)); conversation.addAll(0, databaseBackend.getMessages(conversation, Config.PAGE_SIZE));
checkDeletedFiles(conversation); checkDeletedFiles(conversation);
conversation.findUnsentTextMessages(new Conversation.OnMessageFound() {
@Override
public void onMessageFound(Message message) {
markMessage(message, Message.STATUS_WAITING);
}
});
conversation.findUnreadMessages(new Conversation.OnMessageFound() { conversation.findUnreadMessages(new Conversation.OnMessageFound() {
@Override @Override
public void onMessageFound(Message message) { public void onMessageFound(Message message) {
@ -2894,7 +2902,6 @@ public class XmppConnectionService extends Service {
} }
public void resetSendingToWaiting(Account account) { public void resetSendingToWaiting(Account account) {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": reset 'sending' messages to 'waiting'");
for (Conversation conversation : getConversations()) { for (Conversation conversation : getConversations()) {
if (conversation.getAccount() == account) { if (conversation.getAccount() == account) {
conversation.findUnsentTextMessages(new Conversation.OnMessageFound() { conversation.findUnsentTextMessages(new Conversation.OnMessageFound() {

View file

@ -244,6 +244,9 @@ public class XmppConnection implements Runnable {
} }
protected void connect() { protected void connect() {
if (mXmppConnectionService.areMessagesInitialized()) {
mXmppConnectionService.resetSendingToWaiting(account);
}
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": connecting"); Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": connecting");
features.encryptionEnabled = false; features.encryptionEnabled = false;
this.attempt++; this.attempt++;
@ -1069,7 +1072,6 @@ public class XmppConnection implements Runnable {
mStanzaQueue.clear(); mStanzaQueue.clear();
} }
} }
mXmppConnectionService.resetSendingToWaiting(account);
features.carbonsEnabled = false; features.carbonsEnabled = false;
features.blockListRequested = false; features.blockListRequested = false;
synchronized (this.disco) { synchronized (this.disco) {