aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java23
-rw-r--r--src/main/java/de/pixart/messenger/entities/MucOptions.java10
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java4
-rw-r--r--src/main/java/de/pixart/messenger/parser/PresenceParser.java7
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java6
5 files changed, 44 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
index b444349b2..b3ceb3c55 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
@@ -210,7 +210,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
putDevicesForJid(account.getJid().toBareJid().toPreppedString(), deviceIds, store);
for (Contact contact : account.getRoster().getContacts()) {
Jid bareJid = contact.getJid().toBareJid();
- String address = bareJid.toString();
+ String address = bareJid.toPreppedString();
deviceIds = store.getSubDeviceSessions(address);
putDevicesForJid(address, deviceIds, store);
}
@@ -838,6 +838,27 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
}
}
+ public boolean hasEmptyDeviceList(Jid jid) {
+ return !hasAny(jid) && (!deviceIds.containsKey(jid) || deviceIds.get(jid).isEmpty());
+ }
+
+ public void fetchDeviceIds(final Jid jid) {
+ Log.d(Config.LOGTAG, "fetching device ids for " + jid);
+ IqPacket packet = mXmppConnectionService.getIqGenerator().retrieveDeviceIds(jid);
+ mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {
+ @Override
+ public void onIqPacketReceived(Account account, IqPacket packet) {
+ if (packet.getType() == IqPacket.TYPE.RESULT) {
+ Element item = mXmppConnectionService.getIqParser().getItem(packet);
+ Set<Integer> deviceIds = mXmppConnectionService.getIqParser().deviceIds(item);
+ registerDevices(jid, deviceIds);
+ } else {
+ Log.d(Config.LOGTAG, packet.toString());
+ }
+ }
+ });
+ }
+
private void buildSessionFromPEP(final SignalProtocolAddress address) {
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Building new session for " + address.toString());
if (address.equals(getOwnAxolotlAddress())) {
diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java
index ef2f4bee4..3e2349c9c 100644
--- a/src/main/java/de/pixart/messenger/entities/MucOptions.java
+++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java
@@ -448,13 +448,16 @@ public class MucOptions {
return user;
}
- public void updateUser(User user) {
+ //returns true if real jid was new;
+ public boolean updateUser(User user) {
User old;
+ boolean realJidFound = false;
if (user.fullJid == null && user.realJid != null) {
old = findUserByRealJid(user.realJid);
+ realJidFound = old != null;
if (old != null) {
if (old.fullJid != null) {
- return; //don't add. user already exists
+ return false; //don't add. user already exists
} else {
synchronized (users) {
users.remove(old);
@@ -463,6 +466,7 @@ public class MucOptions {
}
} else if (user.realJid != null) {
old = findUserByRealJid(user.realJid);
+ realJidFound = old != null;
synchronized (users) {
if (old != null && old.fullJid == null) {
users.remove(old);
@@ -479,8 +483,10 @@ public class MucOptions {
&& user.getAffiliation().outranks(Affiliation.OUTCAST)
&& !fullJidIsSelf) {
this.users.add(user);
+ return !realJidFound && user.realJid != null;
}
}
+ return false;
}
public User findUserByFullJid(Jid jid) {
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 9a8e005b8..25190b32d 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -654,7 +654,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
MucOptions.User user = AbstractParser.parseItem(conversation, child);
Log.d(Config.LOGTAG, account.getJid() + ": changing affiliation for " + user.getRealJid() + " to " + user.getAffiliation() + " in " + conversation.getJid().toBareJid());
if (!user.realJidMatchesAccount()) {
- conversation.getMucOptions().updateUser(user);
+ boolean isNew = conversation.getMucOptions().updateUser(user);
mXmppConnectionService.getAvatarService().clear(conversation);
mXmppConnectionService.updateMucRosterUi();
mXmppConnectionService.updateConversationUi();
@@ -665,6 +665,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": removed " + jid + " from crypto targets of " + conversation.getName());
conversation.setAcceptedCryptoTargets(cryptoTargets);
mXmppConnectionService.updateConversation(conversation);
+ } else if (isNew && user.getRealJid() != null && account.getAxolotlService().hasEmptyDeviceList(user.getRealJid())) {
+ account.getAxolotlService().fetchDeviceIds(user.getRealJid());
}
}
}
diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
index c95380085..37efcdc8b 100644
--- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java
+++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
@@ -8,6 +8,7 @@ import java.util.List;
import de.pixart.messenger.Config;
import de.pixart.messenger.crypto.PgpEngine;
+import de.pixart.messenger.crypto.axolotl.AxolotlService;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.entities.Conversation;
@@ -75,7 +76,11 @@ public class PresenceParser extends AbstractParser implements
mucOptions.onRenameListener = null;
}
}
- mucOptions.updateUser(user);
+ boolean isNew = mucOptions.updateUser(user);
+ final AxolotlService axolotlService = conversation.getAccount().getAxolotlService();
+ if (isNew && user.getRealJid() != null && mucOptions.membersOnly() && mucOptions.nonanonymous() && axolotlService.hasEmptyDeviceList(user.getRealJid())) {
+ axolotlService.fetchDeviceIds(user.getRealJid());
+ }
if (codes.contains(MucOptions.STATUS_CODE_ROOM_CREATED) && mucOptions.autoPushConfiguration()) {
Log.d(Config.LOGTAG, mucOptions.getAccount().getJid().toBareJid()
+ ": room '"
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 0be6c824a..737598cbb 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -2479,6 +2479,7 @@ public class XmppConnectionService extends Service {
private void fetchConferenceMembers(final Conversation conversation) {
final Account account = conversation.getAccount();
+ final AxolotlService axolotlService = account.getAxolotlService();
final String[] affiliations = {"member", "admin", "owner"};
OnIqPacketReceived callback = new OnIqPacketReceived() {
@@ -2494,7 +2495,10 @@ public class XmppConnectionService extends Service {
if ("item".equals(child.getName())) {
MucOptions.User user = AbstractParser.parseItem(conversation, child);
if (!user.realJidMatchesAccount()) {
- conversation.getMucOptions().updateUser(user);
+ boolean isNew = conversation.getMucOptions().updateUser(user);
+ if (isNew && user.getRealJid() != null && axolotlService.hasEmptyDeviceList(user.getRealJid())) {
+ axolotlService.fetchDeviceIds(user.getRealJid());
+ }
}
}
}