aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/services
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-06-29 14:22:26 +0200
committerAndreas Straub <andy@strb.org>2015-07-19 21:32:26 +0200
commit3815d4efa378846c8aef840ad659268a0bef1536 (patch)
treeb13fffaeb22e0b4fcfb3b362319569f89fd6641d /src/main/java/eu/siacs/conversations/services
parentcb7980c65ed5d91296e3ad571298dbed434707c0 (diff)
Fetch bundles on-demand, encrypt in background
Bundles are now fetched on demand when a session needs to be established. This should lessen the chance of changes to the bundles occuring before they're used, as well as lessen the load of fetching bundles. Also, the message encryption is now done in a background thread, as this can be somewhat costly if many sessions are present. This is probably not going to be an issue in real use, but it's good practice anyway.
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services')
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index f96e5d7e..8b716121 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -703,7 +703,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (!resend && message.getEncryption() != Message.ENCRYPTION_OTR) {
message.getConversation().endOtrIfNeeded();
- message.getConversation().findUnsentMessagesWithOtrEncryption(new Conversation.OnMessageFound() {
+ message.getConversation().findUnsentMessagesWithEncryption(Message.ENCRYPTION_OTR,
+ new Conversation.OnMessageFound() {
@Override
public void onMessageFound(Message message) {
markMessage(message,Message.STATUS_SEND_FAILED);
@@ -758,12 +759,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
break;
case Message.ENCRYPTION_AXOLOTL:
- try {
- packet = mMessageGenerator.generateAxolotlChat(message);
- Log.d(Config.LOGTAG, "Succeeded generating axolotl chat message!");
- } catch (NoSessionsCreatedException e) {
- message.setStatus(Message.STATUS_WAITING);
- }
+ message.setStatus(Message.STATUS_WAITING);
+ account.getAxolotlService().sendMessage(message);
break;
}
@@ -1797,7 +1794,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
account.getJid().toBareJid() + " otr session established with "
+ conversation.getJid() + "/"
+ otrSession.getSessionID().getUserID());
- conversation.findUnsentMessagesWithOtrEncryption(new Conversation.OnMessageFound() {
+ conversation.findUnsentMessagesWithEncryption(Message.ENCRYPTION_OTR, new Conversation.OnMessageFound() {
@Override
public void onMessageFound(Message message) {