couple of bug fixes related to muc renaming
This commit is contained in:
parent
177e802a77
commit
9532a9889b
|
@ -7,7 +7,6 @@ import eu.siacs.conversations.crypto.PgpEngine;
|
|||
import eu.siacs.conversations.xml.Element;
|
||||
import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.util.Log;
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public class MucOptions {
|
||||
|
@ -147,7 +146,7 @@ public class MucOptions {
|
|||
}
|
||||
}
|
||||
} else if (type.equals("unavailable")) {
|
||||
if (name.equals(getJoinNick())) {
|
||||
if (name.equals(self.getName())) {
|
||||
Element item = packet.findChild("x","http://jabber.org/protocol/muc#user").findChild("item");
|
||||
String nick = item.getAttribute("nick");
|
||||
if (nick!=null) {
|
||||
|
@ -155,7 +154,6 @@ public class MucOptions {
|
|||
if (renameListener!=null) {
|
||||
renameListener.onRename(true);
|
||||
}
|
||||
this.setJoinNick(nick);
|
||||
}
|
||||
}
|
||||
deleteUser(packet.getAttribute("from").split("/")[1]);
|
||||
|
@ -167,6 +165,7 @@ public class MucOptions {
|
|||
renameListener.onRename(false);
|
||||
}
|
||||
aboutToRename = false;
|
||||
this.setJoinNick(getActualNick());
|
||||
} else {
|
||||
this.error = ERROR_NICK_IN_USE;
|
||||
}
|
||||
|
@ -196,6 +195,14 @@ public class MucOptions {
|
|||
return this.nick;
|
||||
}
|
||||
|
||||
public String getActualNick() {
|
||||
if (this.self.getName()!=null) {
|
||||
return this.self.getName();
|
||||
} else {
|
||||
return this.getProposedNick();
|
||||
}
|
||||
}
|
||||
|
||||
public void setJoinNick(String nick) {
|
||||
this.nick = nick;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class MessageParser extends AbstractParser implements
|
|||
return null;
|
||||
}
|
||||
String counterPart = fromParts[1];
|
||||
if (counterPart.equals(conversation.getMucOptions().getJoinNick())) {
|
||||
if (counterPart.equals(conversation.getMucOptions().getActualNick())) {
|
||||
if (mXmppConnectionService.markMessage(conversation,
|
||||
packet.getId(), Message.STATUS_SEND)) {
|
||||
return null;
|
||||
|
|
|
@ -964,6 +964,7 @@ public class XmppConnectionService extends Service {
|
|||
|
||||
public void renameInMuc(final Conversation conversation, final String nick) {
|
||||
final MucOptions options = conversation.getMucOptions();
|
||||
options.setJoinNick(nick);
|
||||
if (options.online()) {
|
||||
Account account = conversation.getAccount();
|
||||
options.setOnRenameListener(new OnRenameListener() {
|
||||
|
@ -974,7 +975,7 @@ public class XmppConnectionService extends Service {
|
|||
renameListener.onRename(success);
|
||||
}
|
||||
if (success) {
|
||||
conversation.setContactJid(conversation.getMucOptions().getJoinNick());
|
||||
conversation.setContactJid(conversation.getMucOptions().getJoinJid());
|
||||
databaseBackend.updateConversation(conversation);
|
||||
Bookmark bookmark = conversation.getBookmark();
|
||||
if (bookmark!=null) {
|
||||
|
@ -986,8 +987,7 @@ public class XmppConnectionService extends Service {
|
|||
});
|
||||
options.flagAboutToRename();
|
||||
PresencePacket packet = new PresencePacket();
|
||||
packet.setAttribute("to",
|
||||
conversation.getContactJid().split("/")[0] + "/" + nick);
|
||||
packet.setAttribute("to",options.getJoinJid());
|
||||
packet.setAttribute("from", conversation.getAccount().getFullJid());
|
||||
|
||||
String sig = account.getPgpSignature();
|
||||
|
@ -997,9 +997,7 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
sendPresencePacket(account,packet);
|
||||
} else {
|
||||
String jid = conversation.getContactJid().split("/")[0] + "/"
|
||||
+ nick;
|
||||
conversation.setContactJid(jid);
|
||||
conversation.setContactJid(options.getJoinJid());
|
||||
databaseBackend.updateConversation(conversation);
|
||||
if (conversation.getAccount().getStatus() == Account.STATUS_ONLINE) {
|
||||
Bookmark bookmark = conversation.getBookmark();
|
||||
|
|
|
@ -48,7 +48,7 @@ public class MucDetailsActivity extends XmppActivity {
|
|||
public void onClick(View arg0) {
|
||||
MucOptions options = conversation.getMucOptions();
|
||||
String nick = mYourNick.getText().toString();
|
||||
if (!options.getJoinNick().equals(nick)) {
|
||||
if (!options.getActualNick().equals(nick)) {
|
||||
xmppConnectionService.renameInMuc(conversation, nick);
|
||||
finish();
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class MucDetailsActivity extends XmppActivity {
|
|||
mSubject.setText(conversation.getMucOptions().getSubject());
|
||||
setTitle(conversation.getName(useSubject));
|
||||
mFullJid.setText(conversation.getContactJid().split("/")[0]);
|
||||
mYourNick.setText(conversation.getMucOptions().getJoinNick());
|
||||
mYourNick.setText(conversation.getMucOptions().getActualNick());
|
||||
mRoleAffiliaton = (TextView) findViewById(R.id.muc_role);
|
||||
if (conversation.getMucOptions().online()) {
|
||||
mMoreDetails.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -216,7 +216,7 @@ public class UIHelper {
|
|||
bgColor, fgColor);
|
||||
}
|
||||
String[] names = new String[members.size() + 1];
|
||||
names[0] = conversation.getMucOptions().getJoinNick();
|
||||
names[0] = conversation.getMucOptions().getActualNick();
|
||||
for (int i = 0; i < members.size(); ++i) {
|
||||
names[i + 1] = members.get(i).getName();
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ public class UIHelper {
|
|||
if ((currentCon != null)
|
||||
&& (currentCon.getMode() == Conversation.MODE_MULTI)
|
||||
&& (!alwaysNotify)) {
|
||||
String nick = currentCon.getMucOptions().getJoinNick();
|
||||
String nick = currentCon.getMucOptions().getActualNick();
|
||||
Pattern highlight = generateNickHighlightPattern(nick);
|
||||
Matcher m = highlight.matcher(currentCon.getLatestMessage()
|
||||
.getBody());
|
||||
|
@ -463,7 +463,7 @@ public class UIHelper {
|
|||
|
||||
private static boolean wasHighlighted(Conversation conversation) {
|
||||
List<Message> messages = conversation.getMessages();
|
||||
String nick = conversation.getMucOptions().getJoinNick();
|
||||
String nick = conversation.getMucOptions().getActualNick();
|
||||
Pattern highlight = generateNickHighlightPattern(nick);
|
||||
for (int i = messages.size() - 1; i >= 0; --i) {
|
||||
if (messages.get(i).isRead()) {
|
||||
|
|
Loading…
Reference in a new issue