muc options clean up

This commit is contained in:
iNPUTmice 2014-10-06 13:34:19 +02:00
parent b788b84c31
commit 16d5429f80
3 changed files with 31 additions and 30 deletions

View File

@ -262,8 +262,8 @@
<string name="pref_conference_name">Conference name</string> <string name="pref_conference_name">Conference name</string>
<string name="pref_conference_name_summary">Use rooms subject instead of JID to identify conferences</string> <string name="pref_conference_name_summary">Use rooms subject instead of JID to identify conferences</string>
<string name="toast_message_otr_fingerprint">OTR fingerprint copied to clipboard!</string> <string name="toast_message_otr_fingerprint">OTR fingerprint copied to clipboard!</string>
<string name="conference_banned">You were been banned from the conference room</string> <string name="conference_banned">You are banned from this conference</string>
<string name="conference_members_only">The conference room is only for members</string> <string name="conference_members_only">This conference is members only</string>
<string name="conference_kicked">You were been kicked from the conference room</string> <string name="conference_kicked">You have been kicked from this conference</string>
</resources> </resources>

View File

@ -115,7 +115,6 @@ public class MucOptions {
private String subject = null; private String subject = null;
private String joinnick; private String joinnick;
private String password = null; private String password = null;
private boolean passwordChanged = false;
public MucOptions(Account account) { public MucOptions(Account account) {
this.account = account; this.account = account;
@ -165,9 +164,6 @@ public class MucOptions {
} }
aboutToRename = false; aboutToRename = false;
} }
if (conversation.getBookmark() != null) {
this.passwordChanged = false;
}
} else { } else {
addUser(user); addUser(user);
} }
@ -186,22 +182,26 @@ public class MucOptions {
} }
} }
} else if (type.equals("unavailable") && name.equals(this.joinnick)) { } else if (type.equals("unavailable") && name.equals(this.joinnick)) {
Element status = packet.findChild("x", Element x = packet.findChild("x",
"http://jabber.org/protocol/muc#user").findChild( "http://jabber.org/protocol/muc#user");
"status"); if (x != null) {
String code = status.getAttribute("code"); Element status = x.findChild("status");
if (code.equals(STATUS_CODE_KICKED)) { if (status != null) {
this.isOnline = false; String code = status.getAttribute("code");
this.error = KICKED_FROM_ROOM; if (STATUS_CODE_KICKED.equals(code)) {
} else if (code.equals(STATUS_CODE_BANNED)) { this.isOnline = false;
this.isOnline = false; this.error = KICKED_FROM_ROOM;
this.error = ERROR_BANNED; } else if (STATUS_CODE_BANNED.equals(code)) {
this.isOnline = false;
this.error = ERROR_BANNED;
}
}
} }
} else if (type.equals("unavailable")) { } else if (type.equals("unavailable")) {
deleteUser(packet.getAttribute("from").split("/", 2)[1]); deleteUser(packet.getAttribute("from").split("/", 2)[1]);
} else if (type.equals("error")) { } else if (type.equals("error")) {
Element error = packet.findChild("error"); Element error = packet.findChild("error");
if (error.hasChild("conflict")) { if (error != null && error.hasChild("conflict")) {
if (aboutToRename) { if (aboutToRename) {
if (renameListener != null) { if (renameListener != null) {
renameListener.onRename(false); renameListener.onRename(false);
@ -211,14 +211,12 @@ public class MucOptions {
} else { } else {
this.error = ERROR_NICK_IN_USE; this.error = ERROR_NICK_IN_USE;
} }
} else if (error.hasChild("not-authorized")) { } else if (error != null && error.hasChild("not-authorized")) {
if (conversation.getBookmark() != null) {
this.passwordChanged = true;
}
this.error = ERROR_PASSWORD_REQUIRED; this.error = ERROR_PASSWORD_REQUIRED;
} else if (error.hasChild("forbidden")) { } else if (error != null && error.hasChild("forbidden")) {
this.error = ERROR_BANNED; this.error = ERROR_BANNED;
} else if (error.hasChild("registration-required")) { } else if (error != null
&& error.hasChild("registration-required")) {
this.error = ERROR_MEMBERS_ONLY; this.error = ERROR_MEMBERS_ONLY;
} }
} }
@ -363,9 +361,4 @@ public class MucOptions {
conversation conversation
.setAttribute(Conversation.ATTRIBUTE_MUC_PASSWORD, password); .setAttribute(Conversation.ATTRIBUTE_MUC_PASSWORD, password);
} }
public boolean isPasswordChanged2() {
return this.passwordChanged;
}
} }

View File

@ -132,6 +132,14 @@ public class ConversationFragment extends Fragment {
} }
}; };
private OnClickListener joinMuc = new OnClickListener() {
@Override
public void onClick(View v) {
activity.xmppConnectionService.joinMuc(conversation);
}
};
private OnClickListener enterPassword = new OnClickListener() { private OnClickListener enterPassword = new OnClickListener() {
@Override @Override
@ -495,7 +503,7 @@ public class ConversationFragment extends Fragment {
break; break;
case MucOptions.KICKED_FROM_ROOM: case MucOptions.KICKED_FROM_ROOM:
showSnackbar(R.string.conference_kicked, showSnackbar(R.string.conference_kicked,
R.string.leave, leaveMuc); R.string.join, joinMuc);
break; break;
default: default:
break; break;