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