aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-07-19 18:36:28 +0200
committerAndreas Straub <andy@strb.org>2015-07-19 22:27:26 +0200
commit14010bf5a6198e4e53ba3f86328d061cf20b8da1 (patch)
tree160046518af40585887479d9b0821d60175b5cd6 /src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
parentec0aff4ed7982cc6db43cb6337f828f732429fd2 (diff)
Ask for key trust when sending messages
If the contact (or the own account) has keys that have UNDECIDED trust, we now drop the user into the new TrustKeysActivity, where they have to decide for each new key whether it should be TRUSTED or UNTRUSTED.
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services/XmppConnectionService.java')
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java46
1 files changed, 40 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 08c0b3fa5..cc113cefa 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -85,6 +85,7 @@ import eu.siacs.conversations.xmpp.OnContactStatusChanged;
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
import eu.siacs.conversations.xmpp.OnMessageAcknowledged;
import eu.siacs.conversations.xmpp.OnMessagePacketReceived;
+import eu.siacs.conversations.xmpp.OnNewKeysAvailable;
import eu.siacs.conversations.xmpp.OnPresencePacketReceived;
import eu.siacs.conversations.xmpp.OnStatusChanged;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
@@ -307,6 +308,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
private int rosterChangedListenerCount = 0;
private OnMucRosterUpdate mOnMucRosterUpdate = null;
private int mucRosterChangedListenerCount = 0;
+ private OnNewKeysAvailable mOnNewKeysAvailable = null;
+ private int newKeysAvailableListenerCount = 0;
private SecureRandom mRandom;
private OpenPgpServiceConnection pgpServiceConnection;
private PgpEngine mPgpEngine = null;
@@ -1344,17 +1347,17 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
switchToForeground();
}
this.mOnUpdateBlocklist = listener;
- if (this.updateBlocklistListenerCount < 2) {
- this.updateBlocklistListenerCount++;
+ if (this.newKeysAvailableListenerCount < 2) {
+ this.newKeysAvailableListenerCount++;
}
}
}
public void removeOnUpdateBlocklistListener() {
synchronized (this) {
- this.updateBlocklistListenerCount--;
- if (this.updateBlocklistListenerCount <= 0) {
- this.updateBlocklistListenerCount = 0;
+ this.newKeysAvailableListenerCount--;
+ if (this.newKeysAvailableListenerCount <= 0) {
+ this.newKeysAvailableListenerCount = 0;
this.mOnUpdateBlocklist = null;
if (checkListeners()) {
switchToBackground();
@@ -1363,6 +1366,30 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
}
+ public void setOnNewKeysAvailableListener(final OnNewKeysAvailable listener) {
+ synchronized (this) {
+ if (checkListeners()) {
+ switchToForeground();
+ }
+ this.mOnNewKeysAvailable = listener;
+ if (this.newKeysAvailableListenerCount < 2) {
+ this.newKeysAvailableListenerCount++;
+ }
+ }
+ }
+
+ public void removeOnNewKeysAvailableListener() {
+ synchronized (this) {
+ this.newKeysAvailableListenerCount--;
+ if (this.newKeysAvailableListenerCount <= 0) {
+ this.newKeysAvailableListenerCount = 0;
+ this.mOnNewKeysAvailable = null;
+ if (checkListeners()) {
+ switchToBackground();
+ }
+ }
+ }
+ }
public void setOnMucRosterUpdateListener(OnMucRosterUpdate listener) {
synchronized (this) {
if (checkListeners()) {
@@ -1393,7 +1420,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
&& this.mOnConversationUpdate == null
&& this.mOnRosterUpdate == null
&& this.mOnUpdateBlocklist == null
- && this.mOnShowErrorToast == null);
+ && this.mOnShowErrorToast == null
+ && this.mOnNewKeysAvailable == null);
}
private void switchToForeground() {
@@ -2281,6 +2309,12 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
}
+ public void newKeysAvailable() {
+ if(mOnNewKeysAvailable != null) {
+ mOnNewKeysAvailable.onNewKeysAvailable();
+ }
+ }
+
public Account findAccountByJid(final Jid accountJid) {
for (Account account : this.accounts) {
if (account.getJid().toBareJid().equals(accountJid.toBareJid())) {