From e0965a2bf2759c98eb5fe8afbd4185032d391aa8 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 28 Jan 2019 10:52:35 +0100 Subject: [PATCH] remove warning messages for kick after ban failing. on modern servers ban is enough to also kick --- .../services/XmppConnectionService.java | 24 +++++-------------- .../ui/ConferenceDetailsActivity.java | 12 +--------- .../ui/ConversationsActivity.java | 12 +--------- .../conversations/ui/MucUsersActivity.java | 11 +-------- .../ui/util/MucDetailsContextMenuHelper.java | 14 +++++------ 5 files changed, 15 insertions(+), 58 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index b32f2e38d..2ee0d6062 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2919,20 +2919,14 @@ public class XmppConnectionService extends Service { sendIqPacket(conference.getAccount(), request, mDefaultIqHandler); } - public void changeRoleInConference(final Conversation conference, final String nick, MucOptions.Role role, final OnRoleChanged callback) { + public void changeRoleInConference(final Conversation conference, final String nick, MucOptions.Role role) { IqPacket request = this.mIqGenerator.changeRole(conference, nick, role.toString()); Log.d(Config.LOGTAG, request.toString()); - sendIqPacket(conference.getAccount(), request, new OnIqPacketReceived() { - @Override - public void onIqPacketReceived(Account account, IqPacket packet) { - Log.d(Config.LOGTAG, packet.toString()); - if (packet.getType() == IqPacket.TYPE.RESULT) { - callback.onRoleChangedSuccessful(nick); - } else { - callback.onRoleChangeFailed(nick, R.string.could_not_change_role); - } - } - }); + sendIqPacket(conference.getAccount(), request, (account, packet) -> { + if (packet.getType() != IqPacket.TYPE.RESULT) { + Log.d(Config.LOGTAG,account.getJid().asBareJid()+" unable to change role of "+nick); + } + }); } public void destroyRoom(final Conversation conversation, final OnRoomDestroy callback) { @@ -4310,12 +4304,6 @@ public class XmppConnectionService extends Service { void onAffiliationChangeFailed(Jid jid, int resId); } - public interface OnRoleChanged { - void onRoleChangedSuccessful(String nick); - - void onRoleChangeFailed(String nick, int resid); - } - public interface OnConversationUpdate { void onConversationUpdate(); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 82fa7d2b2..adb36981c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -55,7 +55,7 @@ import rocks.xmpp.addr.Jid; import static eu.siacs.conversations.entities.Bookmark.printableValue; import static eu.siacs.conversations.utils.StringUtils.changed; -public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed, XmppConnectionService.OnRoomDestroy, TextWatcher, OnMediaLoaded { +public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnConfigurationPushed, XmppConnectionService.OnRoomDestroy, TextWatcher, OnMediaLoaded { public static final String ACTION_VIEW_MUC = "view_muc"; private Conversation mConversation; @@ -595,16 +595,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers displayToast(getString(resId, jid.asBareJid().toString())); } - @Override - public void onRoleChangedSuccessful(String nick) { - - } - - @Override - public void onRoleChangeFailed(String nick, int resId) { - displayToast(getString(resId, nick)); - } - @Override public void onRoomDestroySucceeded() { finish(); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java index bcd586d3f..815278420 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java @@ -88,7 +88,7 @@ import rocks.xmpp.addr.Jid; import static eu.siacs.conversations.ui.ConversationFragment.REQUEST_DECRYPT_PGP; -public class ConversationsActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged { +public class ConversationsActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast, XmppConnectionService.OnAffiliationChanged { public static final String ACTION_VIEW_CONVERSATION = "eu.siacs.conversations.action.VIEW"; public static final String EXTRA_CONVERSATION = "conversationUuid"; @@ -426,16 +426,6 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio displayToast(getString(resId, jid.asBareJid().toString())); } - @Override - public void onRoleChangedSuccessful(String nick) { - - } - - @Override - public void onRoleChangeFailed(String nick, int resId) { - displayToast(getString(resId, nick)); - } - private void openConversation(Conversation conversation, Bundle extras) { ConversationFragment conversationFragment = (ConversationFragment) getFragmentManager().findFragmentById(R.id.secondary_fragment); final boolean mainNeedsRefresh; diff --git a/src/main/java/eu/siacs/conversations/ui/MucUsersActivity.java b/src/main/java/eu/siacs/conversations/ui/MucUsersActivity.java index 86f099b7a..472b96c0b 100644 --- a/src/main/java/eu/siacs/conversations/ui/MucUsersActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/MucUsersActivity.java @@ -20,7 +20,7 @@ import eu.siacs.conversations.ui.adapter.UserAdapter; import eu.siacs.conversations.ui.util.MucDetailsContextMenuHelper; import rocks.xmpp.addr.Jid; -public class MucUsersActivity extends XmppActivity implements XmppConnectionService.OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged { +public class MucUsersActivity extends XmppActivity implements XmppConnectionService.OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged { private UserAdapter userAdapter; @@ -86,13 +86,4 @@ public class MucUsersActivity extends XmppActivity implements XmppConnectionServ displayToast(getString(resId, jid.asBareJid().toString())); } - @Override - public void onRoleChangedSuccessful(String nick) { - - } - - @Override - public void onRoleChangeFailed(String nick, int resId) { - displayToast(getString(resId, nick)); - } } diff --git a/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java b/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java index 747a11553..a021098e5 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java +++ b/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java @@ -1,7 +1,6 @@ package eu.siacs.conversations.ui.util; import android.app.Activity; -import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.v7.app.AlertDialog; import android.text.SpannableString; @@ -13,11 +12,11 @@ import android.view.MenuItem; import android.view.View; import eu.siacs.conversations.Config; +import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.MucOptions; import eu.siacs.conversations.entities.MucOptions.User; -import eu.siacs.conversations.R; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.ConferenceDetailsActivity; import eu.siacs.conversations.ui.ConversationFragment; @@ -108,7 +107,6 @@ public final class MucDetailsContextMenuHelper { public static boolean onContextItemSelected(MenuItem item, User user, XmppActivity activity, final String fingerprint) { final Conversation conversation = user.getConversation(); final XmppConnectionService.OnAffiliationChanged onAffiliationChanged = activity instanceof XmppConnectionService.OnAffiliationChanged ? (XmppConnectionService.OnAffiliationChanged) activity : null; - final XmppConnectionService.OnRoleChanged onRoleChanged = activity instanceof XmppConnectionService.OnRoleChanged ? (XmppConnectionService.OnRoleChanged) activity : null; Jid jid = user.getRealJid(); switch (item.getItemId()) { case R.id.action_contact_details: @@ -133,12 +131,12 @@ public final class MucDetailsContextMenuHelper { activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged); return true; case R.id.remove_from_room: - removeFromRoom(user, activity, onAffiliationChanged, onRoleChanged); + removeFromRoom(user, activity, onAffiliationChanged); return true; case R.id.ban_from_conference: activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.OUTCAST, onAffiliationChanged); if (user.getRole() != MucOptions.Role.NONE) { - activity.xmppConnectionService.changeRoleInConference(conversation, user.getName(), MucOptions.Role.NONE, onRoleChanged); + activity.xmppConnectionService.changeRoleInConference(conversation, user.getName(), MucOptions.Role.NONE); } return true; case R.id.send_private_message: @@ -159,12 +157,12 @@ public final class MucDetailsContextMenuHelper { } } - private static void removeFromRoom(final User user, XmppActivity activity, XmppConnectionService.OnAffiliationChanged onAffiliationChanged, XmppConnectionService.OnRoleChanged onRoleChanged) { + private static void removeFromRoom(final User user, XmppActivity activity, XmppConnectionService.OnAffiliationChanged onAffiliationChanged) { final Conversation conversation = user.getConversation(); if (conversation.getMucOptions().membersOnly()) { activity.xmppConnectionService.changeAffiliationInConference(conversation, user.getRealJid(), MucOptions.Affiliation.NONE, onAffiliationChanged); if (user.getRole() != MucOptions.Role.NONE) { - activity.xmppConnectionService.changeRoleInConference(conversation, user.getName(), MucOptions.Role.NONE, onRoleChanged); + activity.xmppConnectionService.changeRoleInConference(conversation, user.getName(), MucOptions.Role.NONE); } } else { AlertDialog.Builder builder = new AlertDialog.Builder(activity); @@ -180,7 +178,7 @@ public final class MucDetailsContextMenuHelper { builder.setPositiveButton(R.string.ban_now, (dialog, which) -> { activity.xmppConnectionService.changeAffiliationInConference(conversation, user.getRealJid(), MucOptions.Affiliation.OUTCAST, onAffiliationChanged); if (user.getRole() != MucOptions.Role.NONE) { - activity.xmppConnectionService.changeRoleInConference(conversation, user.getName(), MucOptions.Role.NONE, onRoleChanged); + activity.xmppConnectionService.changeRoleInConference(conversation, user.getName(), MucOptions.Role.NONE); } }); builder.create().show();