aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/services
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-07-15 17:11:43 +0200
committeriNPUTmice <daniel@gultsch.de>2014-07-15 17:11:43 +0200
commit2a82f23f36e56fa18c59d48231b886edd26a3425 (patch)
treebcc5d33454aef065a831309c93923be184923493 /src/eu/siacs/conversations/services
parent2ebd92b7a7b97c7ecca43eb1e3c7d408508aadb2 (diff)
use nick from bookmark if available
Diffstat (limited to 'src/eu/siacs/conversations/services')
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index c43a34b78..3b1cec628 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -691,6 +691,7 @@ public class XmppConnectionService extends Service {
if (bookmark.autojoin()) {
conversation = findOrCreateConversation(account, bookmark.getJid(), true);
conversation.setBookmark(bookmark);
+ joinMuc(conversation);
}
}
}
@@ -840,10 +841,6 @@ public class XmppConnectionService extends Service {
this.databaseBackend.createConversation(conversation);
}
this.conversations.add(conversation);
- if ((account.getStatus() == Account.STATUS_ONLINE)
- && (conversation.getMode() == Conversation.MODE_MULTI)) {
- joinMuc(conversation);
- }
updateConversationUi();
return conversation;
}
@@ -933,19 +930,12 @@ public class XmppConnectionService extends Service {
}
public void joinMuc(Conversation conversation) {
+ Log.d(LOGTAG,"joining conversation "+conversation.getContactJid());
Account account = conversation.getAccount();
- String[] mucParts = conversation.getContactJid().split("/");
- String muc;
- String nick;
- if (mucParts.length == 2) {
- muc = mucParts[0];
- nick = mucParts[1];
- } else {
- muc = mucParts[0];
- nick = account.getUsername();
- }
+ String nick = conversation.getMucOptions().getProposedNick();
+ conversation.getMucOptions().setJoinNick(nick);
PresencePacket packet = new PresencePacket();
- packet.setAttribute("to", muc + "/" + nick);
+ packet.setAttribute("to",conversation.getMucOptions().getJoinJid());
Element x = new Element("x");
x.setAttribute("xmlns", "http://jabber.org/protocol/muc");
String sig = account.getPgpSignature();
@@ -963,6 +953,7 @@ public class XmppConnectionService extends Service {
mDateFormat.format(date));
}
packet.addChild(x);
+ Log.d(LOGTAG,packet.toString());
sendPresencePacket(account, packet);
}
@@ -984,10 +975,13 @@ public class XmppConnectionService extends Service {
renameListener.onRename(success);
}
if (success) {
- String jid = conversation.getContactJid().split("/")[0]
- + "/" + nick;
- conversation.setContactJid(jid);
+ conversation.setContactJid(conversation.getMucOptions().getJoinNick());
databaseBackend.updateConversation(conversation);
+ Bookmark bookmark = conversation.getBookmark();
+ if (bookmark!=null) {
+ bookmark.setNick(nick);
+ pushBookmarks(bookmark.getAccount());
+ }
}
}
});
@@ -1009,6 +1003,11 @@ public class XmppConnectionService extends Service {
conversation.setContactJid(jid);
databaseBackend.updateConversation(conversation);
if (conversation.getAccount().getStatus() == Account.STATUS_ONLINE) {
+ Bookmark bookmark = conversation.getBookmark();
+ if (bookmark!=null) {
+ bookmark.setNick(nick);
+ pushBookmarks(bookmark.getAccount());
+ }
joinMuc(conversation);
}
}
@@ -1016,8 +1015,7 @@ public class XmppConnectionService extends Service {
public void leaveMuc(Conversation conversation) {
PresencePacket packet = new PresencePacket();
- packet.setAttribute("to", conversation.getContactJid().split("/")[0]
- + "/" + conversation.getMucOptions().getNick());
+ packet.setAttribute("to", conversation.getMucOptions().getJoinJid());
packet.setAttribute("from", conversation.getAccount().getFullJid());
packet.setAttribute("type", "unavailable");
sendPresencePacket(conversation.getAccount(),packet);