remove warning messages for kick after ban failing. on modern servers ban is enough to also kick

This commit is contained in:
Daniel Gultsch 2019-01-28 10:52:35 +01:00
parent b30fb46c85
commit e0965a2bf2
5 changed files with 15 additions and 58 deletions

View File

@ -2919,18 +2919,12 @@ public class XmppConnectionService extends Service {
sendIqPacket(conference.getAccount(), request, mDefaultIqHandler); 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()); IqPacket request = this.mIqGenerator.changeRole(conference, nick, role.toString());
Log.d(Config.LOGTAG, request.toString()); Log.d(Config.LOGTAG, request.toString());
sendIqPacket(conference.getAccount(), request, new OnIqPacketReceived() { sendIqPacket(conference.getAccount(), request, (account, packet) -> {
@Override if (packet.getType() != IqPacket.TYPE.RESULT) {
public void onIqPacketReceived(Account account, IqPacket packet) { Log.d(Config.LOGTAG,account.getJid().asBareJid()+" unable to change role of "+nick);
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);
}
} }
}); });
} }
@ -4310,12 +4304,6 @@ public class XmppConnectionService extends Service {
void onAffiliationChangeFailed(Jid jid, int resId); void onAffiliationChangeFailed(Jid jid, int resId);
} }
public interface OnRoleChanged {
void onRoleChangedSuccessful(String nick);
void onRoleChangeFailed(String nick, int resid);
}
public interface OnConversationUpdate { public interface OnConversationUpdate {
void onConversationUpdate(); void onConversationUpdate();
} }

View File

@ -55,7 +55,7 @@ import rocks.xmpp.addr.Jid;
import static eu.siacs.conversations.entities.Bookmark.printableValue; import static eu.siacs.conversations.entities.Bookmark.printableValue;
import static eu.siacs.conversations.utils.StringUtils.changed; 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"; public static final String ACTION_VIEW_MUC = "view_muc";
private Conversation mConversation; private Conversation mConversation;
@ -595,16 +595,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
displayToast(getString(resId, jid.asBareJid().toString())); 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 @Override
public void onRoomDestroySucceeded() { public void onRoomDestroySucceeded() {
finish(); finish();

View File

@ -88,7 +88,7 @@ import rocks.xmpp.addr.Jid;
import static eu.siacs.conversations.ui.ConversationFragment.REQUEST_DECRYPT_PGP; 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 ACTION_VIEW_CONVERSATION = "eu.siacs.conversations.action.VIEW";
public static final String EXTRA_CONVERSATION = "conversationUuid"; public static final String EXTRA_CONVERSATION = "conversationUuid";
@ -426,16 +426,6 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
displayToast(getString(resId, jid.asBareJid().toString())); 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) { private void openConversation(Conversation conversation, Bundle extras) {
ConversationFragment conversationFragment = (ConversationFragment) getFragmentManager().findFragmentById(R.id.secondary_fragment); ConversationFragment conversationFragment = (ConversationFragment) getFragmentManager().findFragmentById(R.id.secondary_fragment);
final boolean mainNeedsRefresh; final boolean mainNeedsRefresh;

View File

@ -20,7 +20,7 @@ import eu.siacs.conversations.ui.adapter.UserAdapter;
import eu.siacs.conversations.ui.util.MucDetailsContextMenuHelper; import eu.siacs.conversations.ui.util.MucDetailsContextMenuHelper;
import rocks.xmpp.addr.Jid; 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; private UserAdapter userAdapter;
@ -86,13 +86,4 @@ public class MucUsersActivity extends XmppActivity implements XmppConnectionServ
displayToast(getString(resId, jid.asBareJid().toString())); displayToast(getString(resId, jid.asBareJid().toString()));
} }
@Override
public void onRoleChangedSuccessful(String nick) {
}
@Override
public void onRoleChangeFailed(String nick, int resId) {
displayToast(getString(resId, nick));
}
} }

View File

@ -1,7 +1,6 @@
package eu.siacs.conversations.ui.util; package eu.siacs.conversations.ui.util;
import android.app.Activity; import android.app.Activity;
import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.text.SpannableString; import android.text.SpannableString;
@ -13,11 +12,11 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.MucOptions; import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.MucOptions.User; import eu.siacs.conversations.entities.MucOptions.User;
import eu.siacs.conversations.R;
import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.ConferenceDetailsActivity; import eu.siacs.conversations.ui.ConferenceDetailsActivity;
import eu.siacs.conversations.ui.ConversationFragment; 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) { public static boolean onContextItemSelected(MenuItem item, User user, XmppActivity activity, final String fingerprint) {
final Conversation conversation = user.getConversation(); final Conversation conversation = user.getConversation();
final XmppConnectionService.OnAffiliationChanged onAffiliationChanged = activity instanceof XmppConnectionService.OnAffiliationChanged ? (XmppConnectionService.OnAffiliationChanged) activity : null; 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(); Jid jid = user.getRealJid();
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_contact_details: case R.id.action_contact_details:
@ -133,12 +131,12 @@ public final class MucDetailsContextMenuHelper {
activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged); activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged);
return true; return true;
case R.id.remove_from_room: case R.id.remove_from_room:
removeFromRoom(user, activity, onAffiliationChanged, onRoleChanged); removeFromRoom(user, activity, onAffiliationChanged);
return true; return true;
case R.id.ban_from_conference: case R.id.ban_from_conference:
activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.OUTCAST, onAffiliationChanged); activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.OUTCAST, onAffiliationChanged);
if (user.getRole() != MucOptions.Role.NONE) { 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; return true;
case R.id.send_private_message: 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(); final Conversation conversation = user.getConversation();
if (conversation.getMucOptions().membersOnly()) { if (conversation.getMucOptions().membersOnly()) {
activity.xmppConnectionService.changeAffiliationInConference(conversation, user.getRealJid(), MucOptions.Affiliation.NONE, onAffiliationChanged); activity.xmppConnectionService.changeAffiliationInConference(conversation, user.getRealJid(), MucOptions.Affiliation.NONE, onAffiliationChanged);
if (user.getRole() != MucOptions.Role.NONE) { 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 { } else {
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
@ -180,7 +178,7 @@ public final class MucDetailsContextMenuHelper {
builder.setPositiveButton(R.string.ban_now, (dialog, which) -> { builder.setPositiveButton(R.string.ban_now, (dialog, which) -> {
activity.xmppConnectionService.changeAffiliationInConference(conversation, user.getRealJid(), MucOptions.Affiliation.OUTCAST, onAffiliationChanged); activity.xmppConnectionService.changeAffiliationInConference(conversation, user.getRealJid(), MucOptions.Affiliation.OUTCAST, onAffiliationChanged);
if (user.getRole() != MucOptions.Role.NONE) { 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(); builder.create().show();