kick after ban
This commit is contained in:
parent
f8dc59be81
commit
f8aa1bfec4
|
@ -159,4 +159,14 @@ public class IqGenerator extends AbstractGenerator {
|
||||||
item.setAttribute("affiliation", affiliation);
|
item.setAttribute("affiliation", affiliation);
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IqPacket changeRole(Conversation conference, String nick, String role) {
|
||||||
|
IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
|
||||||
|
packet.setTo(conference.getJid().toBareJid());
|
||||||
|
packet.setFrom(conference.getAccount().getJid());
|
||||||
|
Element item = packet.query("http://jabber.org/protocol/muc#admin").addChild("item");
|
||||||
|
item.setAttribute("nick", nick);
|
||||||
|
item.setAttribute("role", role);
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1562,6 +1562,27 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
public void onAffiliationChangeFailed(Jid jid, int resId);
|
public void onAffiliationChangeFailed(Jid jid, int resId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void changeRoleInConference(final Conversation conference, final String nick, MucOptions.Role role, final OnRoleChanged callback) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnRoleChanged{
|
||||||
|
public void onRoleChangedSuccessful(String nick);
|
||||||
|
public void onRoleChangeFailed(String nick, int resid);
|
||||||
|
}
|
||||||
|
|
||||||
public void disconnect(Account account, boolean force) {
|
public void disconnect(Account account, boolean force) {
|
||||||
if ((account.getStatus() == Account.State.ONLINE)
|
if ((account.getStatus() == Account.State.ONLINE)
|
||||||
|| (account.getStatus() == Account.State.DISABLED)) {
|
|| (account.getStatus() == Account.State.DISABLED)) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdat
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
|
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
|
||||||
|
|
||||||
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged {
|
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged {
|
||||||
public static final String ACTION_VIEW_MUC = "view_muc";
|
public static final String ACTION_VIEW_MUC = "view_muc";
|
||||||
private Conversation mConversation;
|
private Conversation mConversation;
|
||||||
private OnClickListener inviteListener = new OnClickListener() {
|
private OnClickListener inviteListener = new OnClickListener() {
|
||||||
|
@ -294,6 +294,7 @@ 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.getJid(), MucOptions.Affiliation.OUTCAST,this);
|
xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getJid(), MucOptions.Affiliation.OUTCAST,this);
|
||||||
|
xmppConnectionService.changeRoleInConference(mConversation,mSelectedUser.getName(), MucOptions.Role.NONE,this);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onContextItemSelected(item);
|
return super.onContextItemSelected(item);
|
||||||
|
@ -303,6 +304,7 @@ 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.getJid(), MucOptions.Affiliation.NONE,this);
|
xmppConnectionService.changeAffiliationInConference(mConversation,user.getJid(), MucOptions.Affiliation.NONE,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);
|
||||||
|
@ -312,6 +314,7 @@ 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.getJid(), MucOptions.Affiliation.OUTCAST,ConferenceDetailsActivity.this);
|
xmppConnectionService.changeAffiliationInConference(mConversation,user.getJid(), MucOptions.Affiliation.OUTCAST,ConferenceDetailsActivity.this);
|
||||||
|
xmppConnectionService.changeRoleInConference(mConversation,mSelectedUser.getName(), MucOptions.Role.NONE,ConferenceDetailsActivity.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
|
@ -480,4 +483,14 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
public void onAffiliationChangeFailed(Jid jid, int resId) {
|
public void onAffiliationChangeFailed(Jid jid, int resId) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRoleChangedSuccessful(String nick) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRoleChangeFailed(String nick, int resid) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,4 +420,5 @@
|
||||||
<string name="ban_from_conference">Ban from conference</string>
|
<string name="ban_from_conference">Ban from conference</string>
|
||||||
<string name="removing_from_public_conference">You are trying to remove %s from a public conference. The only way to do that is to ban that user for ever.</string>
|
<string name="removing_from_public_conference">You are trying to remove %s from a public conference. The only way to do that is to ban that user for ever.</string>
|
||||||
<string name="ban_now">Ban now</string>
|
<string name="ban_now">Ban now</string>
|
||||||
|
<string name="could_not_change_role">Could not change role</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue