change affiliation for in memory users that are currently not joined in a conference
This commit is contained in:
parent
8d0693ed6a
commit
fc5304c6fe
|
@ -28,12 +28,14 @@ public class MucOptions {
|
||||||
|
|
||||||
public void changeAffiliation(Jid jid, Affiliation affiliation) {
|
public void changeAffiliation(Jid jid, Affiliation affiliation) {
|
||||||
User user = findUserByRealJid(jid);
|
User user = findUserByRealJid(jid);
|
||||||
if (user != null) {
|
if (user != null && user.getRole() == Role.NONE) {
|
||||||
users.remove(user);
|
users.remove(user);
|
||||||
|
if (affiliation.ranks(Affiliation.MEMBER)) {
|
||||||
user.affiliation = affiliation;
|
user.affiliation = affiliation;
|
||||||
users.add(user);
|
users.add(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public enum Affiliation {
|
public enum Affiliation {
|
||||||
OWNER("owner", 4, R.string.owner),
|
OWNER("owner", 4, R.string.owner),
|
||||||
|
|
|
@ -140,9 +140,11 @@ public class PresenceParser extends AbstractParser implements
|
||||||
} else if (error != null && error.hasChild("forbidden")) {
|
} else if (error != null && error.hasChild("forbidden")) {
|
||||||
mucOptions.setError(MucOptions.Error.BANNED);
|
mucOptions.setError(MucOptions.Error.BANNED);
|
||||||
} else if (error != null && error.hasChild("registration-required")) {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2198,6 +2198,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
conference.getMucOptions().changeAffiliation(jid, affiliation);
|
conference.getMucOptions().changeAffiliation(jid, affiliation);
|
||||||
|
getAvatarService().clear(conference);
|
||||||
callback.onAffiliationChangedSuccessful(jid);
|
callback.onAffiliationChangedSuccessful(jid);
|
||||||
} else {
|
} else {
|
||||||
callback.onAffiliationChangeFailed(jid, R.string.could_not_change_affiliation);
|
callback.onAffiliationChangeFailed(jid, R.string.could_not_change_affiliation);
|
||||||
|
|
|
@ -438,7 +438,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
return true;
|
return true;
|
||||||
case R.id.ban_from_conference:
|
case R.id.ban_from_conference:
|
||||||
xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getRealJid(), MucOptions.Affiliation.OUTCAST,this);
|
xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getRealJid(), MucOptions.Affiliation.OUTCAST,this);
|
||||||
|
if (mSelectedUser.getRole() != MucOptions.Role.NONE) {
|
||||||
xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, this);
|
xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, this);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.send_private_message:
|
case R.id.send_private_message:
|
||||||
privateMsgInMuc(mConversation,mSelectedUser.getName());
|
privateMsgInMuc(mConversation,mSelectedUser.getName());
|
||||||
|
@ -451,7 +453,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
private void removeFromRoom(final User user) {
|
private void removeFromRoom(final User user) {
|
||||||
if (mConversation.getMucOptions().membersOnly()) {
|
if (mConversation.getMucOptions().membersOnly()) {
|
||||||
xmppConnectionService.changeAffiliationInConference(mConversation,user.getRealJid(), MucOptions.Affiliation.NONE,this);
|
xmppConnectionService.changeAffiliationInConference(mConversation,user.getRealJid(), MucOptions.Affiliation.NONE,this);
|
||||||
|
if (user.getRole() != MucOptions.Role.NONE) {
|
||||||
xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, ConferenceDetailsActivity.this);
|
xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, ConferenceDetailsActivity.this);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.ban_from_conference);
|
builder.setTitle(R.string.ban_from_conference);
|
||||||
|
@ -461,8 +465,10 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
xmppConnectionService.changeAffiliationInConference(mConversation,user.getRealJid(), MucOptions.Affiliation.OUTCAST,ConferenceDetailsActivity.this);
|
xmppConnectionService.changeAffiliationInConference(mConversation,user.getRealJid(), MucOptions.Affiliation.OUTCAST,ConferenceDetailsActivity.this);
|
||||||
|
if (user.getRole() != MucOptions.Role.NONE) {
|
||||||
xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, ConferenceDetailsActivity.this);
|
xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, ConferenceDetailsActivity.this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue