aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eu/siacs/conversations/generator/MessageGenerator.java14
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java24
2 files changed, 24 insertions, 14 deletions
diff --git a/src/eu/siacs/conversations/generator/MessageGenerator.java b/src/eu/siacs/conversations/generator/MessageGenerator.java
index 77ac55f1..b9728952 100644
--- a/src/eu/siacs/conversations/generator/MessageGenerator.java
+++ b/src/eu/siacs/conversations/generator/MessageGenerator.java
@@ -46,17 +46,21 @@ public class MessageGenerator {
return generateOtrChat(message, false);
}
- public MessagePacket generateOtrChat(Message message, boolean addDelay) throws OtrException {
+ public MessagePacket generateOtrChat(Message message, boolean addDelay) {
Session otrSession = message.getConversation().getOtrSession();
if (otrSession==null) {
- throw new OtrException(null);
+ return null;
}
MessagePacket packet = preparePacket(message,addDelay);
packet.addChild("private", "urn:xmpp:carbons:2");
packet.addChild("no-copy", "urn:xmpp:hints");
- packet.setBody(otrSession.transformSending(message
- .getBody()));
- return packet;
+ try {
+ packet.setBody(otrSession.transformSending(message
+ .getBody()));
+ return packet;
+ } catch (OtrException e) {
+ return null;
+ }
}
public MessagePacket generateChat(Message message) {
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 35bc2603..51192432 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -760,6 +760,7 @@ public class XmppConnectionService extends Service {
private void resendMessage(Message message) {
Account account = message.getConversation().getAccount();
+ MessagePacket packet = null;
if (message.getEncryption() == Message.ENCRYPTION_OTR) {
Presences presences = message.getConversation().getContact()
.getPresences();
@@ -776,18 +777,21 @@ public class XmppConnectionService extends Service {
getApplicationContext(), presence, true);
}
}
+ } else {
+ if (message.getConversation().getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) {
+ if (message.getType() == Message.TYPE_TEXT) {
+ packet = mMessageGenerator.generateOtrChat(message,true);
+ } else if (message.getType() == Message.TYPE_IMAGE) {
+ mJingleConnectionManager.createNewConnection(message);
+ }
+ }
}
} else if (message.getType() == Message.TYPE_TEXT) {
- MessagePacket packet = null;
if (message.getEncryption() == Message.ENCRYPTION_NONE) {
packet = mMessageGenerator.generateChat(message,true);
} else if ((message.getEncryption() == Message.ENCRYPTION_DECRYPTED)||(message.getEncryption() == Message.ENCRYPTION_PGP)) {
packet = mMessageGenerator.generatePgpChat(message,true);
}
- if (packet != null) {
- account.getXmppConnection().sendMessagePacket(packet);
- markMessage(message, Message.STATUS_SEND);
- }
} else if (message.getType() == Message.TYPE_IMAGE) {
Presences presences = message.getConversation().getContact()
.getPresences();
@@ -804,6 +808,10 @@ public class XmppConnectionService extends Service {
}
}
}
+ if (packet != null) {
+ account.getXmppConnection().sendMessagePacket(packet);
+ markMessage(message, Message.STATUS_SEND);
+ }
}
public void fetchRosterFromServer(Account account) {
@@ -1206,13 +1214,11 @@ public class XmppConnectionService extends Service {
&& (msg.getEncryption() == Message.ENCRYPTION_OTR)) {
msg.setPresence(otrSession.getSessionID().getUserID());
if (msg.getType() == Message.TYPE_TEXT) {
- try {
- MessagePacket outPacket = mMessageGenerator.generateOtrChat(msg,true);
+ MessagePacket outPacket = mMessageGenerator.generateOtrChat(msg,true);
+ if (outPacket!=null) {
msg.setStatus(Message.STATUS_SEND);
databaseBackend.updateMessage(msg);
account.getXmppConnection().sendMessagePacket(outPacket);
- } catch (OtrException e) {
- Log.e(LOGTAG,"error creating otr packet");
}
} else if (msg.getType() == Message.TYPE_IMAGE) {
mJingleConnectionManager.createNewConnection(msg);