aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/services
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2016-02-20 15:28:01 +0100
committerChristian S <christian@pix-art.de>2016-02-20 15:28:01 +0100
commitfe52f30c5bbd6f4403b1fe97964488611a3c7276 (patch)
tree562388d395f2547b85c49d8979dbab6193d08199 /src/main/java/eu/siacs/conversations/services
parent2879ddadca409d05eb71ca0863980ed0ec6b1023 (diff)
parent3bde4dbedb80a8e1de89c09f58d842d7382598e8 (diff)
Merge branch 'siacs/master' into development
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services')
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java56
1 files changed, 40 insertions, 16 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 16d7f139c..b836e780a 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -287,8 +287,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
List<Conversation> conversations = getConversations();
for (Conversation conversation : conversations) {
- if (conversation.getAccount() == account && conversation.getMode() == Conversation.MODE_SINGLE) {
- conversation.startOtrIfNeeded();
+ if (conversation.getAccount() == account
+ && !account.pendingConferenceJoins.contains(conversation)) {
+ if (!conversation.startOtrIfNeeded()) {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": couldn't start OTR with "+conversation.getContact().getJid()+" when needed");
+ }
sendUnsentMessages(conversation);
}
}
@@ -474,7 +477,6 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
final String action = intent == null ? null : intent.getAction();
boolean interactive = false;
if (action != null) {
- Log.d(Config.LOGTAG,"start reason: "+action);
switch (action) {
case ConnectivityManager.CONNECTIVITY_ACTION:
if (hasInternetConnection() && Config.RESET_ATTEMPT_COUNT_ON_NETWORK_CHANGE) {
@@ -841,8 +843,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
final Conversation conversation = message.getConversation();
account.deactivateGracePeriod();
MessagePacket packet = null;
- final boolean addToConversation = conversation.getMode() != Conversation.MODE_MULTI
- || account.getServerIdentity() != XmppConnection.Identity.SLACK;
+ final boolean addToConversation = (conversation.getMode() != Conversation.MODE_MULTI
+ || account.getServerIdentity() != XmppConnection.Identity.SLACK)
+ && !message.edited();
boolean saveInDb = addToConversation;
message.setStatus(Message.STATUS_WAITING);
@@ -899,8 +902,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (message.fixCounterpart()) {
conversation.startOtrSession(message.getCounterpart().getResourcepart(), true);
} else {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not fix counterpart for OTR message to contact "+message.getContact().getJid());
break;
}
+ } else {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+" OTR session with "+message.getContact()+" is in wrong state: "+otrSession.getSessionStatus().toString());
}
break;
case Message.ENCRYPTION_AXOLOTL:
@@ -945,6 +951,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
break;
case Message.ENCRYPTION_OTR:
if (!conversation.hasValidOtrSession() && message.getCounterpart() != null) {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": create otr session without starting for "+message.getContact().getJid());
conversation.startOtrSession(message.getCounterpart().getResourcepart(), false);
}
break;
@@ -966,8 +973,12 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (addToConversation) {
conversation.add(message);
}
- if (saveInDb && (message.getEncryption() == Message.ENCRYPTION_NONE || saveEncryptedMessages())) {
- databaseBackend.createMessage(message);
+ if (message.getEncryption() == Message.ENCRYPTION_NONE || saveEncryptedMessages()) {
+ if (saveInDb) {
+ databaseBackend.createMessage(message);
+ } else if (message.edited()) {
+ databaseBackend.updateMessage(message, message.getEditedId());
+ }
}
updateConversationUi();
}
@@ -1746,20 +1757,20 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
List<Conversation> conversations = getConversations();
for (Conversation conversation : conversations) {
if (conversation.getMode() == Conversation.MODE_MULTI && conversation.getAccount() == account) {
- joinMuc(conversation, true, null);
+ joinMuc(conversation);
}
}
}
public void joinMuc(Conversation conversation) {
- joinMuc(conversation, false, null);
+ joinMuc(conversation, null);
}
- private void joinMuc(Conversation conversation, boolean now, final OnConferenceJoined onConferenceJoined) {
+ private void joinMuc(Conversation conversation, final OnConferenceJoined onConferenceJoined) {
Account account = conversation.getAccount();
account.pendingConferenceJoins.remove(conversation);
account.pendingConferenceLeaves.remove(conversation);
- if (account.getStatus() == Account.State.ONLINE || now) {
+ if (account.getStatus() == Account.State.ONLINE) {
conversation.resetMucOptions();
fetchConferenceConfiguration(conversation, new OnConferenceConfigurationFetched() {
@@ -1938,7 +1949,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
String name = new BigInteger(75, getRNG()).toString(32);
Jid jid = Jid.fromParts(name, server, null);
final Conversation conversation = findOrCreateConversation(account, jid, true);
- joinMuc(conversation, true, new OnConferenceJoined() {
+ joinMuc(conversation, new OnConferenceJoined() {
@Override
public void onConferenceJoined(final Conversation conversation) {
Bundle options = new Bundle();
@@ -2148,6 +2159,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
updateConversationUi();
}
+ public void updateMessage(Message message, String uuid) {
+ databaseBackend.updateMessage(message, uuid);
+ updateConversationUi();
+ }
+
protected void syncDirtyContacts(Account account) {
for (Contact contact : account.getRoster().getContacts()) {
if (contact.getOption(Contact.Options.DIRTY_PUSH)) {
@@ -2604,6 +2620,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
return getPreferences().getBoolean("confirm_messages", true);
}
+ public boolean allowMessageCorrection() {
+ return getPreferences().getBoolean("allow_message_correction", true);
+ }
+
public boolean sendChatStates() {
return getPreferences().getBoolean("chat_states", false);
}
@@ -2711,7 +2731,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
return null;
}
- public void markRead(final Conversation conversation) {
+ public boolean markRead(final Conversation conversation) {
mNotificationService.clear(conversation);
final List<Message> readMessages = conversation.markRead();
if (readMessages.size() > 0) {
@@ -2724,8 +2744,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
};
mDatabaseExecutor.execute(runnable);
+ updateUnreadCountBadge();
+ return true;
+ } else {
+ return false;
}
- updateUnreadCountBadge();
}
public synchronized void updateUnreadCountBadge() {
@@ -2743,7 +2766,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public void sendReadMarker(final Conversation conversation) {
final Message markable = conversation.getLatestMarkableMessage();
- this.markRead(conversation);
+ if (this.markRead(conversation)) {
+ updateConversationUi();
+ }
if (confirmMessages() && markable != null && markable.getRemoteMsgId() != null) {
Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": sending read marker to " + markable.getCounterpart().toString());
Account account = conversation.getAccount();
@@ -2751,7 +2776,6 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
MessagePacket packet = mMessageGenerator.confirm(account, to, markable.getRemoteMsgId());
this.sendMessagePacket(conversation.getAccount(), packet);
}
- updateConversationUi();
}
public SecureRandom getRNG() {