diff options
Diffstat (limited to 'src/main/java/eu')
4 files changed, 18 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index a221c701..50641f5a 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -28,10 +28,12 @@ public class MucOptions { public void changeAffiliation(Jid jid, Affiliation affiliation) { User user = findUserByRealJid(jid); - if (user != null) { + if (user != null && user.getRole() == Role.NONE) { users.remove(user); - user.affiliation = affiliation; - users.add(user); + if (affiliation.ranks(Affiliation.MEMBER)) { + user.affiliation = affiliation; + users.add(user); + } } } diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java index 1f1e92ee..c82c83d1 100644 --- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java @@ -140,9 +140,11 @@ public class PresenceParser extends AbstractParser implements } else if (error != null && error.hasChild("forbidden")) { mucOptions.setError(MucOptions.Error.BANNED); } else if (error != null && error.hasChild("registration-required")) { - mucOptions.setError(MucOptions.Error.BANNED); + mucOptions.setError(MucOptions.Error.MEMBERS_ONLY); } } + } else { + Log.d(Config.LOGTAG,mucOptions.getAccount().getJid().toBareJid()+": "+packet); } } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index f88c0c9b..6b01261c 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2198,6 +2198,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa public void onIqPacketReceived(Account account, IqPacket packet) { if (packet.getType() == IqPacket.TYPE.RESULT) { conference.getMucOptions().changeAffiliation(jid, affiliation); + getAvatarService().clear(conference); callback.onAffiliationChangedSuccessful(jid); } else { callback.onAffiliationChangeFailed(jid, R.string.could_not_change_affiliation); diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index bca1c1ba..245dba15 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -438,7 +438,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers return true; case R.id.ban_from_conference: xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getRealJid(), MucOptions.Affiliation.OUTCAST,this); - xmppConnectionService.changeRoleInConference(mConversation,mSelectedUser.getName(), MucOptions.Role.NONE,this); + if (mSelectedUser.getRole() != MucOptions.Role.NONE) { + xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, this); + } return true; case R.id.send_private_message: privateMsgInMuc(mConversation,mSelectedUser.getName()); @@ -451,7 +453,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers private void removeFromRoom(final User user) { if (mConversation.getMucOptions().membersOnly()) { xmppConnectionService.changeAffiliationInConference(mConversation,user.getRealJid(), MucOptions.Affiliation.NONE,this); - xmppConnectionService.changeRoleInConference(mConversation,mSelectedUser.getName(), MucOptions.Role.NONE,ConferenceDetailsActivity.this); + if (user.getRole() != MucOptions.Role.NONE) { + xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, ConferenceDetailsActivity.this); + } } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.ban_from_conference); @@ -461,7 +465,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers @Override public void onClick(DialogInterface dialog, int which) { xmppConnectionService.changeAffiliationInConference(mConversation,user.getRealJid(), MucOptions.Affiliation.OUTCAST,ConferenceDetailsActivity.this); - xmppConnectionService.changeRoleInConference(mConversation,mSelectedUser.getName(), MucOptions.Role.NONE,ConferenceDetailsActivity.this); + if (user.getRole() != MucOptions.Role.NONE) { + xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, ConferenceDetailsActivity.this); + } } }); builder.create().show(); |