fixed presence splitting
This commit is contained in:
parent
0b86f65bdc
commit
37aacbeb74
|
@ -230,7 +230,7 @@ public class Conversation extends AbstractEntity {
|
|||
return this.otrSession;
|
||||
} else {
|
||||
SessionID sessionId = new SessionID(
|
||||
this.getContactJid().split("/")[0], presence, "xmpp");
|
||||
this.getContactJid().split("/",2)[0], presence, "xmpp");
|
||||
this.otrSession = new SessionImpl(sessionId, getAccount()
|
||||
.getOtrEngine(service));
|
||||
try {
|
||||
|
|
|
@ -246,9 +246,9 @@ public class Message extends AbstractEntity {
|
|||
|
||||
public void setPresence(String presence) {
|
||||
if (presence == null) {
|
||||
this.counterpart = this.counterpart.split("/")[0];
|
||||
this.counterpart = this.counterpart.split("/",2)[0];
|
||||
} else {
|
||||
this.counterpart = this.counterpart.split("/")[0] + "/" + presence;
|
||||
this.counterpart = this.counterpart.split("/",2)[0] + "/" + presence;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ public class Message extends AbstractEntity {
|
|||
}
|
||||
|
||||
public String getPresence() {
|
||||
String[] counterparts = this.counterpart.split("/");
|
||||
String[] counterparts = this.counterpart.split("/",2);
|
||||
if (counterparts.length == 2) {
|
||||
return counterparts[1];
|
||||
} else {
|
||||
|
|
|
@ -134,7 +134,7 @@ public class MucOptions {
|
|||
}
|
||||
|
||||
public void processPacket(PresencePacket packet, PgpEngine pgp) {
|
||||
String[] fromParts = packet.getFrom().split("/");
|
||||
String[] fromParts = packet.getFrom().split("/",2);
|
||||
if (fromParts.length >= 2) {
|
||||
String name = fromParts[1];
|
||||
String type = packet.getAttribute("type");
|
||||
|
@ -180,7 +180,7 @@ public class MucOptions {
|
|||
}
|
||||
}
|
||||
} else if (type.equals("unavailable")) {
|
||||
deleteUser(packet.getAttribute("from").split("/")[1]);
|
||||
deleteUser(packet.getAttribute("from").split("/",2)[1]);
|
||||
} else if (type.equals("error")) {
|
||||
Element error = packet.findChild("error");
|
||||
if (error.hasChild("conflict")) {
|
||||
|
@ -209,7 +209,7 @@ public class MucOptions {
|
|||
}
|
||||
|
||||
public String getProposedNick() {
|
||||
String[] mucParts = conversation.getContactJid().split("/");
|
||||
String[] mucParts = conversation.getContactJid().split("/",2);
|
||||
if (conversation.getBookmark() != null
|
||||
&& conversation.getBookmark().getNick() != null) {
|
||||
return conversation.getBookmark().getNick();
|
||||
|
@ -309,7 +309,7 @@ public class MucOptions {
|
|||
}
|
||||
|
||||
public String getJoinJid() {
|
||||
return this.conversation.getContactJid().split("/")[0] + "/"
|
||||
return this.conversation.getContactJid().split("/",2)[0] + "/"
|
||||
+ this.joinnick;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@ public class Roster {
|
|||
}
|
||||
|
||||
public boolean hasContact(String jid) {
|
||||
String cleanJid = jid.split("/")[0];
|
||||
String cleanJid = jid.split("/",2)[0];
|
||||
return contacts.containsKey(cleanJid);
|
||||
}
|
||||
|
||||
public Contact getContact(String jid) {
|
||||
String cleanJid = jid.split("/")[0].toLowerCase(Locale.getDefault());
|
||||
String cleanJid = jid.split("/",2)[0].toLowerCase(Locale.getDefault());
|
||||
if (contacts.containsKey(cleanJid)) {
|
||||
return contacts.get(cleanJid);
|
||||
} else {
|
||||
|
|
|
@ -31,7 +31,7 @@ public class MessageGenerator extends AbstractGenerator {
|
|||
packet.setTo(message.getCounterpart());
|
||||
packet.setType(MessagePacket.TYPE_CHAT);
|
||||
} else {
|
||||
packet.setTo(message.getCounterpart().split("/")[0]);
|
||||
packet.setTo(message.getCounterpart().split("/",2)[0]);
|
||||
packet.setType(MessagePacket.TYPE_GROUPCHAT);
|
||||
}
|
||||
packet.setFrom(account.getFullJid());
|
||||
|
@ -131,7 +131,7 @@ public class MessageGenerator extends AbstractGenerator {
|
|||
String subject) {
|
||||
MessagePacket packet = new MessagePacket();
|
||||
packet.setType(MessagePacket.TYPE_GROUPCHAT);
|
||||
packet.setTo(conversation.getContactJid().split("/")[0]);
|
||||
packet.setTo(conversation.getContactJid().split("/",2)[0]);
|
||||
Element subjectChild = new Element("subject");
|
||||
subjectChild.setContent(subject);
|
||||
packet.addChild(subjectChild);
|
||||
|
@ -145,13 +145,13 @@ public class MessageGenerator extends AbstractGenerator {
|
|||
packet.setTo(contact);
|
||||
packet.setFrom(conversation.getAccount().getFullJid());
|
||||
Element x = packet.addChild("x", "jabber:x:conference");
|
||||
x.setAttribute("jid", conversation.getContactJid().split("/")[0]);
|
||||
x.setAttribute("jid", conversation.getContactJid().split("/",2)[0]);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public MessagePacket invite(Conversation conversation, String contact) {
|
||||
MessagePacket packet = new MessagePacket();
|
||||
packet.setTo(conversation.getContactJid().split("/")[0]);
|
||||
packet.setTo(conversation.getContactJid().split("/",2)[0]);
|
||||
packet.setFrom(conversation.getAccount().getFullJid());
|
||||
Element x = new Element("x");
|
||||
x.setAttribute("xmlns", "http://jabber.org/protocol/muc#user");
|
||||
|
|
|
@ -60,7 +60,7 @@ public abstract class AbstractParser {
|
|||
|
||||
protected void updateLastseen(Element packet, Account account,
|
||||
boolean presenceOverwrite) {
|
||||
String[] fromParts = packet.getAttribute("from").split("/");
|
||||
String[] fromParts = packet.getAttribute("from").split("/",2);
|
||||
String from = fromParts[0];
|
||||
String presence = null;
|
||||
if (fromParts.length >= 2) {
|
||||
|
|
|
@ -25,7 +25,7 @@ public class MessageParser extends AbstractParser implements
|
|||
}
|
||||
|
||||
private Message parseChat(MessagePacket packet, Account account) {
|
||||
String[] fromParts = packet.getFrom().split("/");
|
||||
String[] fromParts = packet.getFrom().split("/",2);
|
||||
Conversation conversation = mXmppConnectionService
|
||||
.findOrCreateConversation(account, fromParts[0], false);
|
||||
conversation.setLatestMarkableMessageId(getMarkableMessageId(packet));
|
||||
|
@ -57,9 +57,9 @@ public class MessageParser extends AbstractParser implements
|
|||
}
|
||||
|
||||
private Message parseOtrChat(MessagePacket packet, Account account) {
|
||||
boolean properlyAddressed = (packet.getTo().split("/").length == 2)
|
||||
boolean properlyAddressed = (packet.getTo().split("/",2).length == 2)
|
||||
|| (account.countPresences() == 1);
|
||||
String[] fromParts = packet.getFrom().split("/");
|
||||
String[] fromParts = packet.getFrom().split("/",2);
|
||||
Conversation conversation = mXmppConnectionService
|
||||
.findOrCreateConversation(account, fromParts[0], false);
|
||||
String presence;
|
||||
|
@ -132,7 +132,7 @@ public class MessageParser extends AbstractParser implements
|
|||
|
||||
private Message parseGroupchat(MessagePacket packet, Account account) {
|
||||
int status;
|
||||
String[] fromParts = packet.getFrom().split("/");
|
||||
String[] fromParts = packet.getFrom().split("/",2);
|
||||
if (mXmppConnectionService.find(account.pendingConferenceLeaves,
|
||||
account, fromParts[0]) != null) {
|
||||
return null;
|
||||
|
@ -221,7 +221,7 @@ public class MessageParser extends AbstractParser implements
|
|||
return null;
|
||||
}
|
||||
}
|
||||
String[] parts = fullJid.split("/");
|
||||
String[] parts = fullJid.split("/",2);
|
||||
Conversation conversation = mXmppConnectionService
|
||||
.findOrCreateConversation(account, parts[0], false);
|
||||
conversation.setLatestMarkableMessageId(getMarkableMessageId(packet));
|
||||
|
@ -253,7 +253,7 @@ public class MessageParser extends AbstractParser implements
|
|||
}
|
||||
|
||||
private void parseError(MessagePacket packet, Account account) {
|
||||
String[] fromParts = packet.getFrom().split("/");
|
||||
String[] fromParts = packet.getFrom().split("/",2);
|
||||
mXmppConnectionService.markMessage(account, fromParts[0],
|
||||
packet.getId(), Message.STATUS_SEND_FAILED);
|
||||
}
|
||||
|
@ -267,14 +267,14 @@ public class MessageParser extends AbstractParser implements
|
|||
String id = packet
|
||||
.findChild("displayed", "urn:xmpp:chat-markers:0")
|
||||
.getAttribute("id");
|
||||
String[] fromParts = packet.getAttribute("from").split("/");
|
||||
String[] fromParts = packet.getAttribute("from").split("/",2);
|
||||
updateLastseen(packet, account, true);
|
||||
mXmppConnectionService.markMessage(account, fromParts[0], id,
|
||||
Message.STATUS_SEND_DISPLAYED);
|
||||
} else if (packet.hasChild("received", "urn:xmpp:chat-markers:0")) {
|
||||
String id = packet.findChild("received", "urn:xmpp:chat-markers:0")
|
||||
.getAttribute("id");
|
||||
String[] fromParts = packet.getAttribute("from").split("/");
|
||||
String[] fromParts = packet.getAttribute("from").split("/",2);
|
||||
updateLastseen(packet, account, false);
|
||||
mXmppConnectionService.markMessage(account, fromParts[0], id,
|
||||
Message.STATUS_SEND_RECEIVED);
|
||||
|
|
|
@ -22,7 +22,7 @@ public class PresenceParser extends AbstractParser implements
|
|||
PgpEngine mPgpEngine = mXmppConnectionService.getPgpEngine();
|
||||
if (packet.hasChild("x", "http://jabber.org/protocol/muc#user")) {
|
||||
Conversation muc = mXmppConnectionService.find(account, packet
|
||||
.getAttribute("from").split("/")[0]);
|
||||
.getAttribute("from").split("/",2)[0]);
|
||||
if (muc != null) {
|
||||
boolean before = muc.getMucOptions().online();
|
||||
muc.getMucOptions().processPacket(packet, mPgpEngine);
|
||||
|
@ -32,7 +32,7 @@ public class PresenceParser extends AbstractParser implements
|
|||
}
|
||||
} else if (packet.hasChild("x", "http://jabber.org/protocol/muc")) {
|
||||
Conversation muc = mXmppConnectionService.find(account, packet
|
||||
.getAttribute("from").split("/")[0]);
|
||||
.getAttribute("from").split("/",2)[0]);
|
||||
if (muc != null) {
|
||||
boolean before = muc.getMucOptions().online();
|
||||
muc.getMucOptions().processPacket(packet, mPgpEngine);
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ImageProvider extends ContentProvider {
|
|||
if (uuids == null) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
String[] uuidsSplited = uuids.split("/");
|
||||
String[] uuidsSplited = uuids.split("/",2);
|
||||
if (uuidsSplited.length != 3) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
|
|
|
@ -847,7 +847,7 @@ public class XmppConnectionService extends Service {
|
|||
String jid) {
|
||||
for (Conversation conversation : haystack) {
|
||||
if ((conversation.getAccount().equals(account))
|
||||
&& (conversation.getContactJid().split("/")[0].equals(jid))) {
|
||||
&& (conversation.getContactJid().split("/",2)[0].equals(jid))) {
|
||||
return conversation;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ public class ConferenceDetailsActivity extends XmppActivity {
|
|||
private void populateView() {
|
||||
mYourPhoto.setImageBitmap(conversation.getAccount().getImage(this, 48));
|
||||
setTitle(conversation.getName());
|
||||
mFullJid.setText(conversation.getContactJid().split("/")[0]);
|
||||
mFullJid.setText(conversation.getContactJid().split("/",2)[0]);
|
||||
mYourNick.setText(conversation.getMucOptions().getActualNick());
|
||||
mRoleAffiliaton = (TextView) findViewById(R.id.muc_role);
|
||||
if (conversation.getMucOptions().online()) {
|
||||
|
|
|
@ -657,7 +657,7 @@ public class XmppConnection implements Runnable {
|
|||
if (bind != null) {
|
||||
Element jid = bind.findChild("jid");
|
||||
if (jid != null) {
|
||||
account.setResource(jid.getContent().split("/")[1]);
|
||||
account.setResource(jid.getContent().split("/",2)[1]);
|
||||
if (streamFeatures.hasChild("sm", "urn:xmpp:sm:3")) {
|
||||
smVersion = 3;
|
||||
EnablePacket enable = new EnablePacket(smVersion);
|
||||
|
|
|
@ -256,12 +256,12 @@ public class JingleConnection implements Downloadable {
|
|||
this.status = STATUS_INITIATED;
|
||||
Conversation conversation = this.mXmppConnectionService
|
||||
.findOrCreateConversation(account,
|
||||
packet.getFrom().split("/")[0], false);
|
||||
packet.getFrom().split("/",2)[0], false);
|
||||
this.message = new Message(conversation, "", Message.ENCRYPTION_NONE);
|
||||
this.message.setType(Message.TYPE_IMAGE);
|
||||
this.message.setStatus(Message.STATUS_RECEIVED_OFFER);
|
||||
this.message.setDownloadable(this);
|
||||
String[] fromParts = packet.getFrom().split("/");
|
||||
String[] fromParts = packet.getFrom().split("/",2);
|
||||
this.message.setPresence(fromParts[1]);
|
||||
this.account = account;
|
||||
this.initiator = packet.getFrom();
|
||||
|
|
Loading…
Reference in a new issue