aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-06-20 20:54:50 +0200
committerChristian Schneppe <christian@pix-art.de>2019-06-20 20:54:50 +0200
commit0f6623888a091563a200f7e8351268bc4c597f58 (patch)
tree027a1a2337431a63355ce192b395c7b509f0e837
parentf09d784928e7852c72cda7859be0cd366c679ac0 (diff)
attempt to keep messages waiting until muc is connected
-rw-r--r--src/main/java/de/pixart/messenger/entities/Account.java1
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java25
2 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Account.java b/src/main/java/de/pixart/messenger/entities/Account.java
index 3ebb1fafa..c2c5e90c8 100644
--- a/src/main/java/de/pixart/messenger/entities/Account.java
+++ b/src/main/java/de/pixart/messenger/entities/Account.java
@@ -72,6 +72,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
private final Collection<Jid> blocklist = new CopyOnWriteArraySet<>();
public List<Conversation> pendingConferenceJoins = new CopyOnWriteArrayList<>();
public List<Conversation> pendingConferenceLeaves = new CopyOnWriteArrayList<>();
+ public final Set<Conversation> inProgressConferenceJoins = new HashSet<>();
protected Jid jid;
protected String password;
protected int options = 0;
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index ec46a91f1..0dc298fd6 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -380,8 +380,13 @@ public class XmppConnectionService extends Service {
}
List<Conversation> conversations = getConversations();
for (Conversation conversation : conversations) {
+ final boolean inProgressJoin;
+ synchronized (account.inProgressConferenceJoins) {
+ inProgressJoin = account.inProgressConferenceJoins.contains(conversation);
+ }
if (conversation.getAccount() == account
- && !account.pendingConferenceJoins.contains(conversation)) {
+ && !account.pendingConferenceJoins.contains(conversation)
+ && !inProgressJoin) {
if (!conversation.startOtrIfNeeded()) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": couldn't start OTR with " + conversation.getContact().getJid() + " when needed");
}
@@ -1504,7 +1509,12 @@ public class XmppConnectionService extends Service {
message1 -> markMessage(message1, Message.STATUS_SEND_FAILED));
}
- if (account.isOnlineAndConnected()) {
+ final boolean inProgressJoin;
+ synchronized (account.inProgressConferenceJoins) {
+ inProgressJoin = conversation.getMode() == Conversational.MODE_MULTI && account.inProgressConferenceJoins.contains(conversation);
+ }
+
+ if (account.isOnlineAndConnected() && !inProgressJoin) {
switch (message.getEncryption()) {
case Message.ENCRYPTION_NONE:
if (message.needsUploading()) {
@@ -2712,6 +2722,9 @@ public class XmppConnectionService extends Service {
account.pendingConferenceJoins.remove(conversation);
account.pendingConferenceLeaves.remove(conversation);
if (account.getStatus() == Account.State.ONLINE) {
+ synchronized (account.inProgressConferenceJoins) {
+ account.inProgressConferenceJoins.add(conversation);
+ }
sendPresencePacket(account, mPresenceGenerator.leave(conversation.getMucOptions()));
conversation.resetMucOptions();
if (onConferenceJoined != null) {
@@ -2765,7 +2778,10 @@ public class XmppConnectionService extends Service {
saveConversationAsBookmark(conversation, null);
}
}
- sendUnsentMessages(conversation);
+ synchronized (account.inProgressConferenceJoins) {
+ account.inProgressConferenceJoins.remove(conversation);
+ sendUnsentMessages(conversation);
+ }
}
@Override
@@ -2784,6 +2800,9 @@ public class XmppConnectionService extends Service {
return;
}
if (error != null && "remote-server-not-found".equals(error.getName())) {
+ synchronized (account.inProgressConferenceJoins) {
+ account.inProgressConferenceJoins.remove(conversation);
+ }
conversation.getMucOptions().setError(MucOptions.Error.SERVER_NOT_FOUND);
updateConversationUi();
} else {