mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 03:32:15 -05:00
fixes for offline otr
This commit is contained in:
parent
2a8f9642d5
commit
6ef9421d35
@ -64,6 +64,8 @@ public class Conversation extends AbstractEntity {
|
|||||||
|
|
||||||
private byte[] symmetricKey;
|
private byte[] symmetricKey;
|
||||||
|
|
||||||
|
private boolean otrSessionNeedsStarting = false;
|
||||||
|
|
||||||
public Conversation(String name, Account account, String contactJid,
|
public Conversation(String name, Account account, String contactJid,
|
||||||
int mode) {
|
int mode) {
|
||||||
this(java.util.UUID.randomUUID().toString(), name, null, account
|
this(java.util.UUID.randomUUID().toString(), name, null, account
|
||||||
@ -237,7 +239,10 @@ public class Conversation extends AbstractEntity {
|
|||||||
try {
|
try {
|
||||||
if (sendStart) {
|
if (sendStart) {
|
||||||
this.otrSession.startSession();
|
this.otrSession.startSession();
|
||||||
|
this.otrSessionNeedsStarting = false;
|
||||||
return this.otrSession;
|
return this.otrSession;
|
||||||
|
} else {
|
||||||
|
this.otrSessionNeedsStarting = true;
|
||||||
}
|
}
|
||||||
return this.otrSession;
|
return this.otrSession;
|
||||||
} catch (OtrException e) {
|
} catch (OtrException e) {
|
||||||
@ -252,9 +257,20 @@ public class Conversation extends AbstractEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resetOtrSession() {
|
public void resetOtrSession() {
|
||||||
|
this.otrSessionNeedsStarting = false;
|
||||||
this.otrSession = null;
|
this.otrSession = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startOtrIfNeeded() {
|
||||||
|
if (this.otrSession != null && this.otrSessionNeedsStarting) {
|
||||||
|
try {
|
||||||
|
this.otrSession.startSession();
|
||||||
|
} catch (OtrException e) {
|
||||||
|
this.resetOtrSession();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void endOtrIfNeeded() {
|
public void endOtrIfNeeded() {
|
||||||
if (this.otrSession != null) {
|
if (this.otrSession != null) {
|
||||||
if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) {
|
if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) {
|
||||||
|
@ -235,7 +235,7 @@ public class XmppConnectionService extends Service {
|
|||||||
List<Conversation> conversations = getConversations();
|
List<Conversation> conversations = getConversations();
|
||||||
for (int i = 0; i < conversations.size(); ++i) {
|
for (int i = 0; i < conversations.size(); ++i) {
|
||||||
if (conversations.get(i).getAccount() == account) {
|
if (conversations.get(i).getAccount() == account) {
|
||||||
conversations.get(i).endOtrIfNeeded();
|
conversations.get(i).startOtrIfNeeded();
|
||||||
sendUnsendMessages(conversations.get(i));
|
sendUnsendMessages(conversations.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user