aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-01-27 21:43:09 +0100
committerChristian Schneppe <christian@pix-art.de>2018-01-27 21:43:09 +0100
commit97504840d176c2b2dbd51e23d3c2b47c61d1331c (patch)
tree4008545eb4bb76e85d707674b8e9486c0696d0ab /src
parent3d18291b6ef0df2f693efb872bc9bfddec9a864a (diff)
make chat markers opportunistic in private mucs
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java4
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java28
-rw-r--r--src/main/java/de/pixart/messenger/entities/MucOptions.java4
-rw-r--r--src/main/java/de/pixart/messenger/generator/MessageGenerator.java3
-rw-r--r--src/main/java/de/pixart/messenger/parser/PresenceParser.java2
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java10
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java2
7 files changed, 31 insertions, 22 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 ce5f1e4bb..6970109b8 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
@@ -787,11 +787,11 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
}
public boolean isConversationAxolotlCapable(Conversation conversation) {
- return conversation.getMode() == Conversation.MODE_SINGLE || (conversation.getMucOptions().nonanonymous() && conversation.getMucOptions().membersOnly());
+ return conversation.isSingleOrPrivateAndNonAnonymous();
}
public Pair<AxolotlCapability, Jid> isConversationAxolotlCapableDetailed(Conversation conversation) {
- if (conversation.getMode() == Conversation.MODE_SINGLE || (conversation.getMucOptions().membersOnly() && conversation.getMucOptions().nonanonymous())) {
+ if (conversation.isSingleOrPrivateAndNonAnonymous()) {
final List<Jid> jids = getCryptoTargets(conversation);
for (Jid jid : jids) {
if (!hasAny(jid) && (!deviceIds.containsKey(jid) || deviceIds.get(jid).isEmpty())) {
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index 1bfb50034..5c5f5634c 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -208,15 +208,13 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
public boolean setOutgoingChatState(ChatState state) {
- if (mode == MODE_MULTI && (getNextCounterpart() != null || !isPnNA())) {
- return false;
- }
- if (this.mOutgoingChatState != state) {
- this.mOutgoingChatState = state;
- return true;
- } else {
- return false;
+ if (mode == MODE_SINGLE || (isPrivateAndNonAnonymous() && getNextCounterpart() == null)) {
+ if (this.mOutgoingChatState != state) {
+ this.mOutgoingChatState = state;
+ return true;
+ }
}
+ return false;
}
public ChatState getOutgoingChatState() {
@@ -480,12 +478,12 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
return unread;
}
- public Message getLatestMarkableMessage() {
+ public Message getLatestMarkableMessage(boolean isPrivateAndNonAnonymousMuc) {
synchronized (this.messages) {
for (int i = this.messages.size() - 1; i >= 0; --i) {
final Message message = this.messages.get(i);
if (message.getStatus() <= Message.STATUS_RECEIVED
- && message.markable
+ && (message.markable || isPrivateAndNonAnonymousMuc)
&& message.getType() != Message.TYPE_PRIVATE) {
return message.isRead() ? null : message;
}
@@ -733,8 +731,12 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
/**
* short for is Private and Non-anonymous
*/
- private boolean isPnNA() {
- return mode == MODE_SINGLE || (getMucOptions().membersOnly() && getMucOptions().nonanonymous());
+ public boolean isSingleOrPrivateAndNonAnonymous() {
+ return mode == MODE_SINGLE || isPrivateAndNonAnonymous();
+ }
+
+ public boolean isPrivateAndNonAnonymous() {
+ return getMucOptions().isPrivateAndNonAnonymous();
}
public synchronized MucOptions getMucOptions() {
@@ -902,7 +904,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
public boolean alwaysNotify() {
- return mode == MODE_SINGLE || getBooleanAttribute(ATTRIBUTE_ALWAYS_NOTIFY, Config.ALWAYS_NOTIFY_BY_DEFAULT || isPnNA());
+ return mode == MODE_SINGLE || getBooleanAttribute(ATTRIBUTE_ALWAYS_NOTIFY, Config.ALWAYS_NOTIFY_BY_DEFAULT || isPrivateAndNonAnonymous());
}
public boolean setAttribute(String key, String value) {
diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java
index 12987cfc9..d4ba4e9f8 100644
--- a/src/main/java/de/pixart/messenger/entities/MucOptions.java
+++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java
@@ -424,6 +424,10 @@ public class MucOptions {
return hasFeature("muc_nonanonymous");
}
+ public boolean isPrivateAndNonAnonymous() {
+ return membersOnly() && nonanonymous();
+ }
+
public boolean persistent() {
return hasFeature("muc_persistent");
}
diff --git a/src/main/java/de/pixart/messenger/generator/MessageGenerator.java b/src/main/java/de/pixart/messenger/generator/MessageGenerator.java
index 0c91302c7..4be56b79f 100644
--- a/src/main/java/de/pixart/messenger/generator/MessageGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/MessageGenerator.java
@@ -53,8 +53,7 @@ public class MessageGenerator extends AbstractGenerator {
packet.setTo(message.getCounterpart().toBareJid());
packet.setType(MessagePacket.TYPE_GROUPCHAT);
}
- if (conversation.getMode() == Conversation.MODE_SINGLE ||
- (conversation.getMucOptions().nonanonymous() && conversation.getMucOptions().membersOnly() && message.getType() != Message.TYPE_PRIVATE)) {
+ if (conversation.isSingleOrPrivateAndNonAnonymous() && message.getType() != Message.TYPE_PRIVATE) {
packet.addChild("markable", "urn:xmpp:chat-markers:0");
}
packet.setFrom(account.getJid());
diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
index e50c1f3a7..13dd70106 100644
--- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java
+++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
@@ -76,7 +76,7 @@ public class PresenceParser extends AbstractParser implements
}
boolean isNew = mucOptions.updateUser(user);
final AxolotlService axolotlService = conversation.getAccount().getAxolotlService();
- if (isNew && user.getRealJid() != null && mucOptions.membersOnly() && mucOptions.nonanonymous() && axolotlService.hasEmptyDeviceList(user.getRealJid())) {
+ if (isNew && user.getRealJid() != null && mucOptions.isPrivateAndNonAnonymous() && axolotlService.hasEmptyDeviceList(user.getRealJid())) {
axolotlService.fetchDeviceIds(user.getRealJid());
}
if (codes.contains(MucOptions.STATUS_CODE_ROOM_CREATED) && mucOptions.autoPushConfiguration()) {
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index f110b5fa8..f3d93cbc0 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -2455,7 +2455,7 @@ public class XmppConnectionService extends Service {
if (mucOptions.mamSupport()) {
getMessageArchiveService().catchupMUC(conversation);
}
- if (mucOptions.membersOnly() && mucOptions.nonanonymous()) {
+ if (mucOptions.isPrivateAndNonAnonymous()) {
fetchConferenceMembers(conversation);
if (followedInvite && conversation.getBookmark() == null) {
saveConversationAsBookmark(conversation, null);
@@ -3657,11 +3657,15 @@ public class XmppConnectionService extends Service {
}
public void sendReadMarker(final Conversation conversation) {
- final Message markable = conversation.getLatestMarkableMessage();
+ final boolean isPrivateAndNonAnonymousMuc = conversation.getMode() == Conversation.MODE_MULTI && conversation.isPrivateAndNonAnonymous();
+ final Message markable = conversation.getLatestMarkableMessage(isPrivateAndNonAnonymousMuc);
if (this.markRead(conversation)) {
updateConversationUi();
}
- if (confirmMessages() && markable != null && markable.trusted() && markable.getRemoteMsgId() != null && markable.getType() != Message.TYPE_PRIVATE) {
+ if (confirmMessages()
+ && markable != null
+ && (markable.trusted() || isPrivateAndNonAnonymousMuc)
+ && markable.getRemoteMsgId() != null) {
Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": sending read marker to " + markable.getCounterpart().toString());
Account account = conversation.getAccount();
final Jid to = markable.getCounterpart();
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index edd88d58a..00e2f6b12 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -1421,7 +1421,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
state = ChatState.PAUSED;
users = conversation.getMucOptions().getUsersWithChatState(state, 5);
}
- if (mucOptions.membersOnly() && mucOptions.nonanonymous()) {
+ if (mucOptions.isPrivateAndNonAnonymous()) {
for (int i = this.messageList.size() - 1; i >= 0; --i) {
final Set<ReadByMarker> markersForMessage = messageList.get(i).getReadByMarkers();
final List<MucOptions.User> shownMarkers = new ArrayList<>();