don't fail displayed or received messages

This commit is contained in:
iNPUTmice 2014-09-08 12:51:01 +02:00
parent 19f98f5143
commit 3b9fd28ef4
1 changed files with 17 additions and 15 deletions

View File

@ -516,8 +516,8 @@ public class XmppConnectionService extends Service {
if (message.getEncryption() == Message.ENCRYPTION_OTR) { if (message.getEncryption() == Message.ENCRYPTION_OTR) {
if (!conv.hasValidOtrSession() if (!conv.hasValidOtrSession()
&& (message.getPresence() != null)) { && (message.getPresence() != null)) {
conv.startOtrSession(this, conv.startOtrSession(this, message.getPresence(),
message.getPresence(), true); true);
message.setStatus(Message.STATUS_WAITING); message.setStatus(Message.STATUS_WAITING);
} else if (conv.hasValidOtrSession() } else if (conv.hasValidOtrSession()
&& conv.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) { && conv.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) {
@ -536,8 +536,7 @@ public class XmppConnectionService extends Service {
if (message.getEncryption() == Message.ENCRYPTION_OTR) { if (message.getEncryption() == Message.ENCRYPTION_OTR) {
if (!conv.hasValidOtrSession() if (!conv.hasValidOtrSession()
&& (message.getPresence() != null)) { && (message.getPresence() != null)) {
conv.startOtrSession(this, conv.startOtrSession(this, message.getPresence(), true);
message.getPresence(), true);
message.setStatus(Message.STATUS_WAITING); message.setStatus(Message.STATUS_WAITING);
} else if (conv.hasValidOtrSession() } else if (conv.hasValidOtrSession()
&& conv.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) { && conv.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) {
@ -577,8 +576,7 @@ public class XmppConnectionService extends Service {
.getUserID()); .getUserID());
} else if (!conv.hasValidOtrSession() } else if (!conv.hasValidOtrSession()
&& message.getPresence() != null) { && message.getPresence() != null) {
conv.startOtrSession(this, conv.startOtrSession(this, message.getPresence(), false);
message.getPresence(), false);
} }
} }
} }
@ -616,14 +614,13 @@ public class XmppConnectionService extends Service {
if (!message.getConversation().hasValidOtrSession()) { if (!message.getConversation().hasValidOtrSession()) {
if ((message.getPresence() != null) if ((message.getPresence() != null)
&& (presences.has(message.getPresence()))) { && (presences.has(message.getPresence()))) {
message.getConversation().startOtrSession( message.getConversation().startOtrSession(this,
this, message.getPresence(), message.getPresence(), true);
true);
} else { } else {
if (presences.size() == 1) { if (presences.size() == 1) {
String presence = presences.asStringArray()[0]; String presence = presences.asStringArray()[0];
message.getConversation().startOtrSession( message.getConversation().startOtrSession(this,
this, presence, true); presence, true);
} }
} }
} else { } else {
@ -1099,8 +1096,8 @@ public class XmppConnectionService extends Service {
public void providePasswordForMuc(Conversation conversation, String password) { public void providePasswordForMuc(Conversation conversation, String password) {
if (conversation.getMode() == Conversation.MODE_MULTI) { if (conversation.getMode() == Conversation.MODE_MULTI) {
conversation.getMucOptions().setPassword(password); conversation.getMucOptions().setPassword(password);
if (conversation.getBookmark() != null && if (conversation.getBookmark() != null
conversation.getMucOptions().isPasswordChanged()) { && conversation.getMucOptions().isPasswordChanged()) {
if (!conversation.getBookmark().autojoin()) { if (!conversation.getBookmark().autojoin()) {
conversation.getBookmark().setAutojoin(true); conversation.getBookmark().setAutojoin(true);
} }
@ -1531,6 +1528,11 @@ public class XmppConnectionService extends Service {
} }
public void markMessage(Message message, int status) { public void markMessage(Message message, int status) {
if (status == Message.STATUS_SEND_FAILED
&& (message.getStatus() == Message.STATUS_SEND_RECEIVED || message
.getStatus() == Message.STATUS_SEND_DISPLAYED)) {
return;
}
message.setStatus(status); message.setStatus(status);
databaseBackend.updateMessage(message); databaseBackend.updateMessage(message);
updateConversationUi(); updateConversationUi();