From 1a1bfb324672994daceacbe468d84cae4dfe4077 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 9 Dec 2018 18:25:11 +0100 Subject: [PATCH] show warning snackbar before joining anon-non-private room. fixes #3306 --- .../eu/siacs/conversations/entities/MucOptions.java | 3 ++- .../services/XmppConnectionService.java | 7 +++++++ .../conversations/ui/ConversationFragment.java | 13 +++++++++++++ src/main/res/values/strings.xml | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 2a751d95e..f2231178e 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -676,7 +676,8 @@ public class MucOptions { SHUTDOWN, DESTROYED, INVALID_NICK, - UNKNOWN + UNKNOWN, + NON_ANONYMOUS } private interface OnEventListener { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index dad6c558f..f045f0bfa 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2298,6 +2298,13 @@ public class XmppConnectionService extends Service { private void join(Conversation conversation) { Account account = conversation.getAccount(); final MucOptions mucOptions = conversation.getMucOptions(); + + if (mucOptions.nonanonymous() && !mucOptions.membersOnly() && !conversation.getBooleanAttribute("accept_non_anonymous", false)) { + mucOptions.setError(MucOptions.Error.NON_ANONYMOUS); + updateConversationUi(); + return; + } + final Jid joinJid = mucOptions.getSelf().getFullJid(); Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": joining conversation " + joinJid.toString()); PresencePacket packet = mPresenceGenerator.selfPresence(account, Presence.Status.ONLINE, mucOptions.nonanonymous() || onConferenceJoined != null); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 57af66a9e..60bd52c76 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -187,6 +187,16 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke activity.xmppConnectionService.joinMuc(conversation); } }; + + private OnClickListener acceptJoin = new OnClickListener() { + @Override + public void onClick(View v) { + conversation.setAttribute("accept_non_anonymous",true); + activity.xmppConnectionService.updateConversation(conversation); + activity.xmppConnectionService.joinMuc(conversation); + } + }; + private OnClickListener enterPassword = new OnClickListener() { @Override @@ -2119,6 +2129,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke case DESTROYED: showSnackbar(R.string.conference_destroyed, R.string.leave, leaveMuc); break; + case NON_ANONYMOUS: + showSnackbar(R.string.group_chat_will_make_your_jabber_id_public, R.string.join, acceptJoin); + break; default: hideSnackbar(); break; diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 0c279142c..e7d2513a7 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -803,4 +803,5 @@ Install Orbot Start Orbot No market app installed. + This group chat will make your Jabber ID public