From 37aacbeb74919524138e5ab0d25f656f9a9f1b7d Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sat, 20 Sep 2014 16:26:40 +0200 Subject: fixed presence splitting --- src/eu/siacs/conversations/entities/Conversation.java | 2 +- src/eu/siacs/conversations/entities/Message.java | 6 +++--- src/eu/siacs/conversations/entities/MucOptions.java | 8 ++++---- src/eu/siacs/conversations/entities/Roster.java | 4 ++-- .../siacs/conversations/generator/MessageGenerator.java | 8 ++++---- src/eu/siacs/conversations/parser/AbstractParser.java | 2 +- src/eu/siacs/conversations/parser/MessageParser.java | 16 ++++++++-------- src/eu/siacs/conversations/parser/PresenceParser.java | 4 ++-- src/eu/siacs/conversations/services/ImageProvider.java | 2 +- .../conversations/services/XmppConnectionService.java | 2 +- .../conversations/ui/ConferenceDetailsActivity.java | 2 +- src/eu/siacs/conversations/xmpp/XmppConnection.java | 2 +- .../conversations/xmpp/jingle/JingleConnection.java | 4 ++-- 13 files changed, 31 insertions(+), 31 deletions(-) (limited to 'src/eu/siacs') diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index 005b83db..8395449d 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -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 { diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java index ce496d27..9505c5cf 100644 --- a/src/eu/siacs/conversations/entities/Message.java +++ b/src/eu/siacs/conversations/entities/Message.java @@ -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 { diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java index e9ab6908..676fb4f4 100644 --- a/src/eu/siacs/conversations/entities/MucOptions.java +++ b/src/eu/siacs/conversations/entities/MucOptions.java @@ -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; } diff --git a/src/eu/siacs/conversations/entities/Roster.java b/src/eu/siacs/conversations/entities/Roster.java index c6212f77..f11f0250 100644 --- a/src/eu/siacs/conversations/entities/Roster.java +++ b/src/eu/siacs/conversations/entities/Roster.java @@ -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 { diff --git a/src/eu/siacs/conversations/generator/MessageGenerator.java b/src/eu/siacs/conversations/generator/MessageGenerator.java index 8c0d4e23..b6bb0bd8 100644 --- a/src/eu/siacs/conversations/generator/MessageGenerator.java +++ b/src/eu/siacs/conversations/generator/MessageGenerator.java @@ -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"); diff --git a/src/eu/siacs/conversations/parser/AbstractParser.java b/src/eu/siacs/conversations/parser/AbstractParser.java index 25fcd921..efbf5aef 100644 --- a/src/eu/siacs/conversations/parser/AbstractParser.java +++ b/src/eu/siacs/conversations/parser/AbstractParser.java @@ -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) { diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java index b9fe3c15..96f45542 100644 --- a/src/eu/siacs/conversations/parser/MessageParser.java +++ b/src/eu/siacs/conversations/parser/MessageParser.java @@ -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); diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java index 05ffa67e..e240a858 100644 --- a/src/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/eu/siacs/conversations/parser/PresenceParser.java @@ -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); diff --git a/src/eu/siacs/conversations/services/ImageProvider.java b/src/eu/siacs/conversations/services/ImageProvider.java index 15b86802..af8ab4b2 100644 --- a/src/eu/siacs/conversations/services/ImageProvider.java +++ b/src/eu/siacs/conversations/services/ImageProvider.java @@ -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(); } diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 0012713a..cc56a1ea 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -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; } } diff --git a/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 2cfa1635..76c12a47 100644 --- a/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -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()) { diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index e7b25e26..e02c772d 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -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); diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index f42482e8..4eac99e6 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -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(); -- cgit v1.2.3