Commit c6bc9ed0 authored by Grigory Fedorov's avatar Grigory Fedorov

Smack: MUCManager and RoomChat migration completed. #502

parent e3b0f3d2
......@@ -40,6 +40,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.muc.MultiUserChatManager;
import org.jivesoftware.smackx.muc.packet.MUCUser;
......@@ -335,13 +336,15 @@ public class MUCManager implements OnLoadListener, OnPacketListener {
roomChat.setState(RoomState.error);
addAuthorizationError(account, room);
// if (e.getXMPPError() != null && e.getXMPPError().getCode() == 409) {
// Application.getInstance().onError(R.string.NICK_ALREADY_USED);
// } else if (e.getXMPPError() != null && e.getXMPPError().getCode() == 401) {
// Application.getInstance().onError(R.string.AUTHENTICATION_FAILED);
// } else {
// Application.getInstance().onError(R.string.NOT_CONNECTED);
// }
XMPPError xmppError = e.getXMPPError();
if (xmppError != null && xmppError.getCondition() == XMPPError.Condition.conflict) {
Application.getInstance().onError(R.string.NICK_ALREADY_USED);
} else if (xmppError != null && xmppError.getCondition() == XMPPError.Condition.not_authorized) {
Application.getInstance().onError(R.string.AUTHENTICATION_FAILED);
} else {
Application.getInstance().onError(R.string.NOT_CONNECTED);
}
RosterManager.getInstance().onContactChanged(account, room);
}
});
......
......@@ -279,22 +279,21 @@ public class RoomChat extends AbstractChat {
occupants.remove(stringPrep);
MUCUser mucUser = MUC.getMUCUserExtension(presence);
if (mucUser != null && mucUser.getStatus() != null) {
// String code = mucUser.getStatus().getCode();
// if ("307".equals(code)) {
// onKick(resource, mucUser.getItem().getActor());
// } else if ("301".equals(code)) {
// onBan(resource, mucUser.getItem().getActor());
// } else if ("303".equals(code)) {
// String newNick = mucUser.getItem().getNick();
// if (newNick == null) {
// return true;
// }
// onRename(resource, newNick);
// Occupant occupant = createOccupant(newNick, presence);
// occupants.put(Jid.getStringPrep(newNick), occupant);
// } else if ("321".equals(code)) {
// onRevoke(resource, mucUser.getItem().getActor());
// }
if (mucUser.getStatus().contains(MUCUser.Status.KICKED_307)) {
onKick(resource, mucUser.getItem().getActor());
} else if (mucUser.getStatus().contains(MUCUser.Status.BANNED_301)){
onBan(resource, mucUser.getItem().getActor());
} else if (mucUser.getStatus().contains(MUCUser.Status.NEW_NICKNAME_303)) {
String newNick = mucUser.getItem().getNick();
if (newNick == null) {
return true;
}
onRename(resource, newNick);
Occupant occupant = createOccupant(newNick, presence);
occupants.put(Jid.getStringPrep(newNick), occupant);
} else if (mucUser.getStatus().contains(MUCUser.Status.REMOVED_AFFIL_CHANGE_321)) {
onRevoke(resource, mucUser.getItem().getActor());
}
} else {
onLeave(resource);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment