aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eu/siacs/conversations/entities/MucOptions.java13
-rw-r--r--src/eu/siacs/conversations/parser/MessageParser.java2
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java10
-rw-r--r--src/eu/siacs/conversations/ui/MucDetailsActivity.java4
-rw-r--r--src/eu/siacs/conversations/utils/UIHelper.java6
5 files changed, 20 insertions, 15 deletions
diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java
index d8c8b2a3..3c5190de 100644
--- a/src/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/eu/siacs/conversations/entities/MucOptions.java
@@ -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;
}
diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java
index dcc57762..d4e1e08d 100644
--- a/src/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/eu/siacs/conversations/parser/MessageParser.java
@@ -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;
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 770f9c86..abcb1f97 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -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();
diff --git a/src/eu/siacs/conversations/ui/MucDetailsActivity.java b/src/eu/siacs/conversations/ui/MucDetailsActivity.java
index 9ff83f82..a81e49d6 100644
--- a/src/eu/siacs/conversations/ui/MucDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/MucDetailsActivity.java
@@ -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);
diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java
index 5c7ae56f..4e902817 100644
--- a/src/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/eu/siacs/conversations/utils/UIHelper.java
@@ -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()) {