diff options
Diffstat (limited to 'src/main')
4 files changed, 17 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index f4fe80b5..86b7a7dc 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -333,7 +333,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } if (timestamp == null) { - timestamp = AbstractParser.parseTimestamp(packet); + timestamp = AbstractParser.parseTimestamp(original,AbstractParser.parseTimestamp(packet)); } final String body = packet.getBody(); final Element mucUserElement = packet.findChild("x", "http://jabber.org/protocol/muc#user"); diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 215d2c09..650b7198 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -326,7 +326,7 @@ public class XmppConnectionService extends Service { } account.pendingConferenceJoins.clear(); scheduleWakeUpCall(Config.PUSH_MODE ? Config.PING_MIN_INTERVAL : Config.PING_MAX_INTERVAL, account.getUuid().hashCode()); - } else if (account.getStatus() == Account.State.OFFLINE) { + } else if (account.getStatus() == Account.State.OFFLINE || account.getStatus() == Account.State.DISABLED) { resetSendingToWaiting(account); final boolean disabled = account.isOptionSet(Account.OPTION_DISABLED); final boolean listeners = checkListeners(); @@ -529,6 +529,7 @@ public class XmppConnectionService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { final String action = intent == null ? null : intent.getAction(); + String pushedAccountHash = null; boolean interactive = false; if (action != null) { final Conversation c = findConversationByUuid(intent.getStringExtra("uuid")); @@ -596,6 +597,7 @@ public class XmppConnectionService extends Service { break; case ACTION_GCM_MESSAGE_RECEIVED: Log.d(Config.LOGTAG,"gcm push message arrived in service. extras="+intent.getExtras()); + pushedAccountHash = intent.getStringExtra("account"); break; } } @@ -634,7 +636,7 @@ public class XmppConnectionService extends Service { } } else { pingCandidates.add(account); - if (msToNextPing <= 0) { + if (msToNextPing <= 0 || CryptoHelper.getAccountFingerprint(account).equals(pushedAccountHash)) { pingNow = true; } else { this.scheduleWakeUpCall((int) (msToNextPing / 1000), account.getUuid().hashCode()); @@ -2891,6 +2893,7 @@ 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/utils/CryptoHelper.java b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java index 429c349a..f9d31241 100644 --- a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java @@ -25,6 +25,7 @@ import java.util.regex.Pattern; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; +import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; @@ -204,6 +205,15 @@ public final class CryptoHelper { return prettifyFingerprintCert(bytesToHex(fingerprint)); } + public static String getAccountFingerprint(Account account) { + try { + MessageDigest md = MessageDigest.getInstance("SHA256"); + return bytesToHex(md.digest(account.getJid().toBareJid().toString().getBytes("UTF-8"))); + } catch (Exception e) { + return ""; + } + } + public static int encryptionTypeToText(int encryption) { switch (encryption) { case Message.ENCRYPTION_OTR: diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 8675a2eb..397d2175 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -1066,6 +1066,7 @@ public class XmppConnection implements Runnable { mStanzaQueue.clear(); } } + mXmppConnectionService.resetSendingToWaiting(account); features.carbonsEnabled = false; features.blockListRequested = false; synchronized (this.disco) { |