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