Update more files to use JID objects
This commit is contained in:
parent
9053f4aca0
commit
f15900426d
|
@ -152,9 +152,9 @@ public class MucOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processPacket(PresencePacket packet, PgpEngine pgp) {
|
public void processPacket(PresencePacket packet, PgpEngine pgp) {
|
||||||
String[] fromParts = packet.getFrom().split("/", 2);
|
final Jid from = packet.getFrom();
|
||||||
if (fromParts.length >= 2) {
|
if (!from.isBareJid()) {
|
||||||
String name = fromParts[1];
|
final String name = from.getResourcepart();
|
||||||
String type = packet.getAttribute("type");
|
String type = packet.getAttribute("type");
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
User user = new User();
|
User user = new User();
|
||||||
|
|
|
@ -67,12 +67,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
if (packet.hasChild("query", "jabber:iq:roster")) {
|
if (packet.hasChild("query", "jabber:iq:roster")) {
|
||||||
Jid from = null;
|
final Jid from = packet.getFrom();
|
||||||
try {
|
|
||||||
from = Jid.fromString(packet.getFrom());
|
|
||||||
} catch (final InvalidJidException e) {
|
|
||||||
// TODO: Handle this?
|
|
||||||
}
|
|
||||||
if ((from == null) || (from.equals(account.getJid()))) {
|
if ((from == null) || (from.equals(account.getJid()))) {
|
||||||
Element query = packet.findChild("query");
|
Element query = packet.findChild("query");
|
||||||
this.rosterItems(account, query);
|
this.rosterItems(account, query);
|
||||||
|
|
|
@ -11,6 +11,8 @@ import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.utils.CryptoHelper;
|
import eu.siacs.conversations.utils.CryptoHelper;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xmpp.OnMessagePacketReceived;
|
import eu.siacs.conversations.xmpp.OnMessagePacketReceived;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
import eu.siacs.conversations.xmpp.pep.Avatar;
|
import eu.siacs.conversations.xmpp.pep.Avatar;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
|
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
|
||||||
|
|
||||||
|
@ -21,9 +23,9 @@ 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("/", 2);
|
final Jid jid = packet.getFrom().toBareJid();
|
||||||
Conversation conversation = mXmppConnectionService
|
Conversation conversation = mXmppConnectionService
|
||||||
.findOrCreateConversation(account, fromParts[0], false);
|
.findOrCreateConversation(account, jid.toBareJid(), false);
|
||||||
updateLastseen(packet, account, true);
|
updateLastseen(packet, account, true);
|
||||||
String pgpBody = getPgpBody(packet);
|
String pgpBody = getPgpBody(packet);
|
||||||
Message finishedMessage;
|
Message finishedMessage;
|
||||||
|
@ -38,11 +40,11 @@ public class MessageParser extends AbstractParser implements
|
||||||
finishedMessage.setRemoteMsgId(packet.getId());
|
finishedMessage.setRemoteMsgId(packet.getId());
|
||||||
finishedMessage.markable = isMarkable(packet);
|
finishedMessage.markable = isMarkable(packet);
|
||||||
if (conversation.getMode() == Conversation.MODE_MULTI
|
if (conversation.getMode() == Conversation.MODE_MULTI
|
||||||
&& fromParts.length >= 2) {
|
&& !jid.getResourcepart().isEmpty()) {
|
||||||
finishedMessage.setType(Message.TYPE_PRIVATE);
|
finishedMessage.setType(Message.TYPE_PRIVATE);
|
||||||
finishedMessage.setPresence(fromParts[1]);
|
finishedMessage.setPresence(jid.getResourcepart());
|
||||||
finishedMessage.setTrueCounterpart(conversation.getMucOptions()
|
finishedMessage.setTrueCounterpart(conversation.getMucOptions()
|
||||||
.getTrueCounterpart(fromParts[1]));
|
.getTrueCounterpart(jid.getResourcepart()));
|
||||||
if (conversation.hasDuplicateMessage(finishedMessage)) {
|
if (conversation.hasDuplicateMessage(finishedMessage)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -53,16 +55,16 @@ 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("/", 2).length == 2)
|
boolean properlyAddressed = (!packet.getTo().isBareJid())
|
||||||
|| (account.countPresences() == 1);
|
|| (account.countPresences() == 1);
|
||||||
String[] fromParts = packet.getFrom().split("/", 2);
|
final Jid from = packet.getFrom();
|
||||||
Conversation conversation = mXmppConnectionService
|
Conversation conversation = mXmppConnectionService
|
||||||
.findOrCreateConversation(account, fromParts[0], false);
|
.findOrCreateConversation(account, from.toBareJid(), false);
|
||||||
String presence;
|
String presence;
|
||||||
if (fromParts.length >= 2) {
|
if (from.isBareJid()) {
|
||||||
presence = fromParts[1];
|
presence = "";
|
||||||
} else {
|
} else {
|
||||||
presence = "";
|
presence = from.getResourcepart();
|
||||||
}
|
}
|
||||||
updateLastseen(packet, account, true);
|
updateLastseen(packet, account, true);
|
||||||
String body = packet.getBody();
|
String body = packet.getBody();
|
||||||
|
@ -127,24 +129,23 @@ 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("/", 2);
|
final Jid from = packet.getFrom();
|
||||||
if (mXmppConnectionService.find(account.pendingConferenceLeaves,
|
if (mXmppConnectionService.find(account.pendingConferenceLeaves,
|
||||||
account, fromParts[0]) != null) {
|
account, from.toBareJid()) != null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Conversation conversation = mXmppConnectionService
|
Conversation conversation = mXmppConnectionService
|
||||||
.findOrCreateConversation(account, fromParts[0], true);
|
.findOrCreateConversation(account, from.toBareJid(), true);
|
||||||
if (packet.hasChild("subject")) {
|
if (packet.hasChild("subject")) {
|
||||||
conversation.getMucOptions().setSubject(
|
conversation.getMucOptions().setSubject(
|
||||||
packet.findChild("subject").getContent());
|
packet.findChild("subject").getContent());
|
||||||
mXmppConnectionService.updateConversationUi();
|
mXmppConnectionService.updateConversationUi();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ((fromParts.length == 1)) {
|
if (from.isBareJid()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String counterPart = fromParts[1];
|
if (from.getResourcepart().equals(conversation.getMucOptions().getActualNick())) {
|
||||||
if (counterPart.equals(conversation.getMucOptions().getActualNick())) {
|
|
||||||
if (mXmppConnectionService.markMessage(conversation,
|
if (mXmppConnectionService.markMessage(conversation,
|
||||||
packet.getId(), Message.STATUS_SEND)) {
|
packet.getId(), Message.STATUS_SEND)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -157,17 +158,17 @@ public class MessageParser extends AbstractParser implements
|
||||||
String pgpBody = getPgpBody(packet);
|
String pgpBody = getPgpBody(packet);
|
||||||
Message finishedMessage;
|
Message finishedMessage;
|
||||||
if (pgpBody == null) {
|
if (pgpBody == null) {
|
||||||
finishedMessage = new Message(conversation, counterPart,
|
finishedMessage = new Message(conversation, from,
|
||||||
packet.getBody(), Message.ENCRYPTION_NONE, status);
|
packet.getBody(), Message.ENCRYPTION_NONE, status);
|
||||||
} else {
|
} else {
|
||||||
finishedMessage = new Message(conversation, counterPart, pgpBody,
|
finishedMessage = new Message(conversation, from, pgpBody,
|
||||||
Message.ENCRYPTION_PGP, status);
|
Message.ENCRYPTION_PGP, status);
|
||||||
}
|
}
|
||||||
finishedMessage.setRemoteMsgId(packet.getId());
|
finishedMessage.setRemoteMsgId(packet.getId());
|
||||||
finishedMessage.markable = isMarkable(packet);
|
finishedMessage.markable = isMarkable(packet);
|
||||||
if (status == Message.STATUS_RECEIVED) {
|
if (status == Message.STATUS_RECEIVED) {
|
||||||
finishedMessage.setTrueCounterpart(conversation.getMucOptions()
|
finishedMessage.setTrueCounterpart(conversation.getMucOptions()
|
||||||
.getTrueCounterpart(counterPart));
|
.getTrueCounterpart(from.getResourcepart()));
|
||||||
}
|
}
|
||||||
if (packet.hasChild("delay")
|
if (packet.hasChild("delay")
|
||||||
&& conversation.hasDuplicateMessage(finishedMessage)) {
|
&& conversation.hasDuplicateMessage(finishedMessage)) {
|
||||||
|
@ -177,9 +178,9 @@ public class MessageParser extends AbstractParser implements
|
||||||
return finishedMessage;
|
return finishedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Message parseCarbonMessage(MessagePacket packet, Account account) {
|
private Message parseCarbonMessage(final MessagePacket packet, final Account account) {
|
||||||
int status;
|
int status;
|
||||||
String fullJid;
|
final Jid fullJid;
|
||||||
Element forwarded;
|
Element forwarded;
|
||||||
if (packet.hasChild("received", "urn:xmpp:carbons:2")) {
|
if (packet.hasChild("received", "urn:xmpp:carbons:2")) {
|
||||||
forwarded = packet.findChild("received", "urn:xmpp:carbons:2")
|
forwarded = packet.findChild("received", "urn:xmpp:carbons:2")
|
||||||
|
@ -205,11 +206,11 @@ public class MessageParser extends AbstractParser implements
|
||||||
parseNonMessage(message, account);
|
parseNonMessage(message, account);
|
||||||
} else if (status == Message.STATUS_SEND
|
} else if (status == Message.STATUS_SEND
|
||||||
&& message.hasChild("displayed", "urn:xmpp:chat-markers:0")) {
|
&& message.hasChild("displayed", "urn:xmpp:chat-markers:0")) {
|
||||||
String to = message.getAttribute("to");
|
final Jid to = message.getTo();
|
||||||
if (to != null) {
|
if (to != null) {
|
||||||
Conversation conversation = mXmppConnectionService.find(
|
final Conversation conversation = mXmppConnectionService.find(
|
||||||
mXmppConnectionService.getConversations(), account,
|
mXmppConnectionService.getConversations(), account,
|
||||||
to.split("/")[0]);
|
to.toBareJid());
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
mXmppConnectionService.markRead(conversation, false);
|
mXmppConnectionService.markRead(conversation, false);
|
||||||
}
|
}
|
||||||
|
@ -218,21 +219,20 @@ public class MessageParser extends AbstractParser implements
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (status == Message.STATUS_RECEIVED) {
|
if (status == Message.STATUS_RECEIVED) {
|
||||||
fullJid = message.getAttribute("from");
|
fullJid = message.getFrom();
|
||||||
if (fullJid == null) {
|
if (fullJid == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
updateLastseen(message, account, true);
|
updateLastseen(message, account, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fullJid = message.getAttribute("to");
|
fullJid = message.getTo();
|
||||||
if (fullJid == null) {
|
if (fullJid == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String[] parts = fullJid.split("/", 2);
|
|
||||||
Conversation conversation = mXmppConnectionService
|
Conversation conversation = mXmppConnectionService
|
||||||
.findOrCreateConversation(account, parts[0], false);
|
.findOrCreateConversation(account, fullJid.toBareJid(), false);
|
||||||
String pgpBody = getPgpBody(message);
|
String pgpBody = getPgpBody(message);
|
||||||
Message finishedMessage;
|
Message finishedMessage;
|
||||||
if (pgpBody != null) {
|
if (pgpBody != null) {
|
||||||
|
@ -247,11 +247,11 @@ public class MessageParser extends AbstractParser implements
|
||||||
finishedMessage.setRemoteMsgId(message.getAttribute("id"));
|
finishedMessage.setRemoteMsgId(message.getAttribute("id"));
|
||||||
finishedMessage.markable = isMarkable(message);
|
finishedMessage.markable = isMarkable(message);
|
||||||
if (conversation.getMode() == Conversation.MODE_MULTI
|
if (conversation.getMode() == Conversation.MODE_MULTI
|
||||||
&& parts.length >= 2) {
|
&& !fullJid.isBareJid()) {
|
||||||
finishedMessage.setType(Message.TYPE_PRIVATE);
|
finishedMessage.setType(Message.TYPE_PRIVATE);
|
||||||
finishedMessage.setPresence(parts[1]);
|
finishedMessage.setPresence(fullJid.getResourcepart());
|
||||||
finishedMessage.setTrueCounterpart(conversation.getMucOptions()
|
finishedMessage.setTrueCounterpart(conversation.getMucOptions()
|
||||||
.getTrueCounterpart(parts[1]));
|
.getTrueCounterpart(fullJid.getResourcepart()));
|
||||||
if (conversation.hasDuplicateMessage(finishedMessage)) {
|
if (conversation.hasDuplicateMessage(finishedMessage)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -259,39 +259,39 @@ public class MessageParser extends AbstractParser implements
|
||||||
return finishedMessage;
|
return finishedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseError(MessagePacket packet, Account account) {
|
private void parseError(final MessagePacket packet, final Account account) {
|
||||||
String[] fromParts = packet.getFrom().split("/", 2);
|
final Jid from = packet.getFrom();
|
||||||
mXmppConnectionService.markMessage(account, fromParts[0],
|
mXmppConnectionService.markMessage(account, from.toBareJid(),
|
||||||
packet.getId(), Message.STATUS_SEND_FAILED);
|
packet.getId(), Message.STATUS_SEND_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseNonMessage(Element packet, Account account) {
|
private void parseNonMessage(Element packet, Account account) {
|
||||||
String from = packet.getAttribute("from");
|
final Jid from = packet.getFrom();
|
||||||
if (packet.hasChild("event", "http://jabber.org/protocol/pubsub#event")) {
|
if (packet.hasChild("event", "http://jabber.org/protocol/pubsub#event")) {
|
||||||
Element event = packet.findChild("event",
|
Element event = packet.findChild("event",
|
||||||
"http://jabber.org/protocol/pubsub#event");
|
"http://jabber.org/protocol/pubsub#event");
|
||||||
parseEvent(event, packet.getAttribute("from"), account);
|
parseEvent(event, from, account);
|
||||||
} else if (from != null
|
} else if (from != null
|
||||||
&& packet.hasChild("displayed", "urn:xmpp:chat-markers:0")) {
|
&& packet.hasChild("displayed", "urn:xmpp:chat-markers:0")) {
|
||||||
String id = packet
|
String id = packet
|
||||||
.findChild("displayed", "urn:xmpp:chat-markers:0")
|
.findChild("displayed", "urn:xmpp:chat-markers:0")
|
||||||
.getAttribute("id");
|
.getAttribute("id");
|
||||||
updateLastseen(packet, account, true);
|
updateLastseen(packet, account, true);
|
||||||
mXmppConnectionService.markMessage(account, from.split("/", 2)[0],
|
mXmppConnectionService.markMessage(account, from.toBareJid(),
|
||||||
id, Message.STATUS_SEND_DISPLAYED);
|
id, Message.STATUS_SEND_DISPLAYED);
|
||||||
} else if (from != null
|
} else if (from != null
|
||||||
&& packet.hasChild("received", "urn:xmpp:chat-markers:0")) {
|
&& 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");
|
||||||
updateLastseen(packet, account, false);
|
updateLastseen(packet, account, false);
|
||||||
mXmppConnectionService.markMessage(account, from.split("/", 2)[0],
|
mXmppConnectionService.markMessage(account, from.toBareJid(),
|
||||||
id, Message.STATUS_SEND_RECEIVED);
|
id, Message.STATUS_SEND_RECEIVED);
|
||||||
} else if (from != null
|
} else if (from != null
|
||||||
&& packet.hasChild("received", "urn:xmpp:receipts")) {
|
&& packet.hasChild("received", "urn:xmpp:receipts")) {
|
||||||
String id = packet.findChild("received", "urn:xmpp:receipts")
|
String id = packet.findChild("received", "urn:xmpp:receipts")
|
||||||
.getAttribute("id");
|
.getAttribute("id");
|
||||||
updateLastseen(packet, account, false);
|
updateLastseen(packet, account, false);
|
||||||
mXmppConnectionService.markMessage(account, from.split("/", 2)[0],
|
mXmppConnectionService.markMessage(account, from.toBareJid(),
|
||||||
id, Message.STATUS_SEND_RECEIVED);
|
id, Message.STATUS_SEND_RECEIVED);
|
||||||
} else if (packet.hasChild("x", "http://jabber.org/protocol/muc#user")) {
|
} else if (packet.hasChild("x", "http://jabber.org/protocol/muc#user")) {
|
||||||
Element x = packet.findChild("x",
|
Element x = packet.findChild("x",
|
||||||
|
@ -299,7 +299,7 @@ public class MessageParser extends AbstractParser implements
|
||||||
if (x.hasChild("invite")) {
|
if (x.hasChild("invite")) {
|
||||||
Conversation conversation = mXmppConnectionService
|
Conversation conversation = mXmppConnectionService
|
||||||
.findOrCreateConversation(account,
|
.findOrCreateConversation(account,
|
||||||
packet.getAttribute("from"), true);
|
packet.getFrom(), true);
|
||||||
if (!conversation.getMucOptions().online()) {
|
if (!conversation.getMucOptions().online()) {
|
||||||
if (x.hasChild("password")) {
|
if (x.hasChild("password")) {
|
||||||
Element password = x.findChild("password");
|
Element password = x.findChild("password");
|
||||||
|
@ -314,8 +314,13 @@ public class MessageParser extends AbstractParser implements
|
||||||
}
|
}
|
||||||
} else if (packet.hasChild("x", "jabber:x:conference")) {
|
} else if (packet.hasChild("x", "jabber:x:conference")) {
|
||||||
Element x = packet.findChild("x", "jabber:x:conference");
|
Element x = packet.findChild("x", "jabber:x:conference");
|
||||||
String jid = x.getAttribute("jid");
|
Jid jid;
|
||||||
String password = x.getAttribute("password");
|
try {
|
||||||
|
jid = Jid.fromString(x.getAttribute("jid"));
|
||||||
|
} catch (InvalidJidException e) {
|
||||||
|
jid = null;
|
||||||
|
}
|
||||||
|
String password = x.getAttribute("password");
|
||||||
if (jid != null) {
|
if (jid != null) {
|
||||||
Conversation conversation = mXmppConnectionService
|
Conversation conversation = mXmppConnectionService
|
||||||
.findOrCreateConversation(account, jid, true);
|
.findOrCreateConversation(account, jid, true);
|
||||||
|
@ -332,7 +337,7 @@ public class MessageParser extends AbstractParser implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseEvent(Element event, String from, Account account) {
|
private void parseEvent(final Element event, final Jid from, final Account account) {
|
||||||
Element items = event.findChild("items");
|
Element items = event.findChild("items");
|
||||||
String node = items.getAttribute("node");
|
String node = items.getAttribute("node");
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import eu.siacs.conversations.generator.PresenceGenerator;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xmpp.OnPresencePacketReceived;
|
import eu.siacs.conversations.xmpp.OnPresencePacketReceived;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
|
import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
|
||||||
|
|
||||||
public class PresenceParser extends AbstractParser implements
|
public class PresenceParser extends AbstractParser implements
|
||||||
|
@ -21,8 +22,8 @@ public class PresenceParser extends AbstractParser implements
|
||||||
public void parseConferencePresence(PresencePacket packet, Account account) {
|
public void parseConferencePresence(PresencePacket packet, Account account) {
|
||||||
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
|
final Conversation muc = mXmppConnectionService.find(account,
|
||||||
.getAttribute("from").split("/", 2)[0]);
|
packet.getFrom().toBareJid());
|
||||||
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,8 +33,8 @@ public class PresenceParser extends AbstractParser implements
|
||||||
mXmppConnectionService.getAvatarService().clear(muc);
|
mXmppConnectionService.getAvatarService().clear(muc);
|
||||||
}
|
}
|
||||||
} 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
|
final Conversation muc = mXmppConnectionService.find(account,
|
||||||
.getAttribute("from").split("/", 2)[0]);
|
packet.getFrom().toBareJid());
|
||||||
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);
|
||||||
|
@ -51,15 +52,15 @@ public class PresenceParser extends AbstractParser implements
|
||||||
if (packet.getFrom() == null) {
|
if (packet.getFrom() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String[] fromParts = packet.getFrom().split("/", 2);
|
final Jid from = packet.getFrom();
|
||||||
String type = packet.getAttribute("type");
|
String type = packet.getAttribute("type");
|
||||||
if (fromParts[0].equals(account.getJid())) {
|
if (from.toBareJid().equals(account.getJid())) {
|
||||||
if (fromParts.length == 2) {
|
if (!from.getResourcepart().isEmpty()) {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
account.updatePresence(fromParts[1],
|
account.updatePresence(from.getResourcepart(),
|
||||||
Presences.parseShow(packet.findChild("show")));
|
Presences.parseShow(packet.findChild("show")));
|
||||||
} else if (type.equals("unavailable")) {
|
} else if (type.equals("unavailable")) {
|
||||||
account.removePresence(fromParts[1]);
|
account.removePresence(from.getResourcepart());
|
||||||
account.deactivateGracePeriod();
|
account.deactivateGracePeriod();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,8 +68,8 @@ public class PresenceParser extends AbstractParser implements
|
||||||
Contact contact = account.getRoster().getContact(packet.getFrom());
|
Contact contact = account.getRoster().getContact(packet.getFrom());
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
String presence;
|
String presence;
|
||||||
if (fromParts.length >= 2) {
|
if (!from.getResourcepart().isEmpty()) {
|
||||||
presence = fromParts[1];
|
presence = from.getResourcepart();
|
||||||
} else {
|
} else {
|
||||||
presence = "";
|
presence = "";
|
||||||
}
|
}
|
||||||
|
@ -95,10 +96,10 @@ public class PresenceParser extends AbstractParser implements
|
||||||
mXmppConnectionService.onContactStatusChanged
|
mXmppConnectionService.onContactStatusChanged
|
||||||
.onContactStatusChanged(contact, online);
|
.onContactStatusChanged(contact, online);
|
||||||
} else if (type.equals("unavailable")) {
|
} else if (type.equals("unavailable")) {
|
||||||
if (fromParts.length != 2) {
|
if (from.isBareJid()) {
|
||||||
contact.clearPresences();
|
contact.clearPresences();
|
||||||
} else {
|
} else {
|
||||||
contact.removePresence(fromParts[1]);
|
contact.removePresence(from.getResourcepart());
|
||||||
}
|
}
|
||||||
mXmppConnectionService.onContactStatusChanged
|
mXmppConnectionService.onContactStatusChanged
|
||||||
.onContactStatusChanged(contact, false);
|
.onContactStatusChanged(contact, false);
|
||||||
|
|
|
@ -5,12 +5,14 @@ import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.utils.XmlHelper;
|
import eu.siacs.conversations.utils.XmlHelper;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
public class Element {
|
public class Element {
|
||||||
protected String name;
|
protected String name;
|
||||||
protected Hashtable<String, String> attributes = new Hashtable<String, String>();
|
protected Hashtable<String, String> attributes = new Hashtable<>();
|
||||||
protected String content;
|
protected String content;
|
||||||
protected List<Element> children = new ArrayList<Element>();
|
protected List<Element> children = new ArrayList<>();
|
||||||
|
|
||||||
public Element(String name) {
|
public Element(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -103,6 +105,42 @@ public class Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Jid getJid() {
|
||||||
|
final String jid = this.getAttribute("jid");
|
||||||
|
if (jid != null && !jid.isEmpty()) {
|
||||||
|
try {
|
||||||
|
return Jid.fromString(jid);
|
||||||
|
} catch (final InvalidJidException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Jid getTo() {
|
||||||
|
final String to = this.getAttribute("to");
|
||||||
|
if (to != null && !to.isEmpty()) {
|
||||||
|
try {
|
||||||
|
return Jid.fromString(to);
|
||||||
|
} catch (final InvalidJidException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Jid getFrom() {
|
||||||
|
final String from = this.getAttribute("from");
|
||||||
|
if (from != null && !from.isEmpty()) {
|
||||||
|
try {
|
||||||
|
return Jid.fromString(from);
|
||||||
|
} catch (final InvalidJidException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Hashtable<String, String> getAttributes() {
|
public Hashtable<String, String> getAttributes() {
|
||||||
return this.attributes;
|
return this.attributes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,4 +161,8 @@ public final class Jid {
|
||||||
result = 31 * result + resourcepart.hashCode();
|
result = 31 * result + resourcepart.hashCode();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBareJid() {
|
||||||
|
return this.resourcepart.isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
public class JingleCandidate {
|
public class JingleCandidate {
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ public class JingleCandidate {
|
||||||
private String host;
|
private String host;
|
||||||
private int port;
|
private int port;
|
||||||
private int type;
|
private int type;
|
||||||
private String jid;
|
private Jid jid;
|
||||||
private int priority;
|
private int priority;
|
||||||
|
|
||||||
public JingleCandidate(String cid, boolean ours) {
|
public JingleCandidate(String cid, boolean ours) {
|
||||||
|
@ -37,11 +38,11 @@ public class JingleCandidate {
|
||||||
return this.host;
|
return this.host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJid(String jid) {
|
public void setJid(final Jid jid) {
|
||||||
this.jid = jid;
|
this.jid = jid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJid() {
|
public Jid getJid() {
|
||||||
return this.jid;
|
return this.jid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,13 +59,17 @@ public class JingleCandidate {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
if ("proxy".equals(type)) {
|
switch (type) {
|
||||||
this.type = TYPE_PROXY;
|
case "proxy":
|
||||||
} else if ("direct".equals(type)) {
|
this.type = TYPE_PROXY;
|
||||||
this.type = TYPE_DIRECT;
|
break;
|
||||||
} else {
|
case "direct":
|
||||||
this.type = TYPE_UNKNOWN;
|
this.type = TYPE_DIRECT;
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
|
this.type = TYPE_UNKNOWN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPriority(int i) {
|
public void setPriority(int i) {
|
||||||
|
@ -93,7 +98,7 @@ public class JingleCandidate {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<JingleCandidate> parse(List<Element> canditates) {
|
public static List<JingleCandidate> parse(List<Element> canditates) {
|
||||||
List<JingleCandidate> parsedCandidates = new ArrayList<JingleCandidate>();
|
List<JingleCandidate> parsedCandidates = new ArrayList<>();
|
||||||
for (Element c : canditates) {
|
for (Element c : canditates) {
|
||||||
parsedCandidates.add(JingleCandidate.parse(c));
|
parsedCandidates.add(JingleCandidate.parse(c));
|
||||||
}
|
}
|
||||||
|
@ -104,7 +109,7 @@ public class JingleCandidate {
|
||||||
JingleCandidate parsedCandidate = new JingleCandidate(
|
JingleCandidate parsedCandidate = new JingleCandidate(
|
||||||
candidate.getAttribute("cid"), false);
|
candidate.getAttribute("cid"), false);
|
||||||
parsedCandidate.setHost(candidate.getAttribute("host"));
|
parsedCandidate.setHost(candidate.getAttribute("host"));
|
||||||
parsedCandidate.setJid(candidate.getAttribute("jid"));
|
parsedCandidate.setJid(candidate.getJid());
|
||||||
parsedCandidate.setType(candidate.getAttribute("type"));
|
parsedCandidate.setType(candidate.getAttribute("type"));
|
||||||
parsedCandidate.setPriority(Integer.parseInt(candidate
|
parsedCandidate.setPriority(Integer.parseInt(candidate
|
||||||
.getAttribute("priority")));
|
.getAttribute("priority")));
|
||||||
|
@ -118,7 +123,7 @@ public class JingleCandidate {
|
||||||
element.setAttribute("cid", this.getCid());
|
element.setAttribute("cid", this.getCid());
|
||||||
element.setAttribute("host", this.getHost());
|
element.setAttribute("host", this.getHost());
|
||||||
element.setAttribute("port", Integer.toString(this.getPort()));
|
element.setAttribute("port", Integer.toString(this.getPort()));
|
||||||
element.setAttribute("jid", this.getJid());
|
element.setAttribute("jid", this.getJid().toString());
|
||||||
element.setAttribute("priority", Integer.toString(this.getPriority()));
|
element.setAttribute("priority", Integer.toString(this.getPriority()));
|
||||||
if (this.getType() == TYPE_DIRECT) {
|
if (this.getType() == TYPE_DIRECT) {
|
||||||
element.setAttribute("type", "direct");
|
element.setAttribute("type", "direct");
|
||||||
|
|
|
@ -21,6 +21,7 @@ import eu.siacs.conversations.entities.Message;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
|
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
import eu.siacs.conversations.xmpp.jingle.stanzas.Content;
|
import eu.siacs.conversations.xmpp.jingle.stanzas.Content;
|
||||||
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
|
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
|
||||||
import eu.siacs.conversations.xmpp.jingle.stanzas.Reason;
|
import eu.siacs.conversations.xmpp.jingle.stanzas.Reason;
|
||||||
|
@ -49,10 +50,10 @@ public class JingleConnection implements Downloadable {
|
||||||
private Message message;
|
private Message message;
|
||||||
private String sessionId;
|
private String sessionId;
|
||||||
private Account account;
|
private Account account;
|
||||||
private String initiator;
|
private Jid initiator;
|
||||||
private String responder;
|
private Jid responder;
|
||||||
private List<JingleCandidate> candidates = new ArrayList<JingleCandidate>();
|
private List<JingleCandidate> candidates = new ArrayList<>();
|
||||||
private ConcurrentHashMap<String, JingleSocks5Transport> connections = new ConcurrentHashMap<String, JingleSocks5Transport>();
|
private ConcurrentHashMap<String, JingleSocks5Transport> connections = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private String transportId;
|
private String transportId;
|
||||||
private Element fileOffer;
|
private Element fileOffer;
|
||||||
|
@ -150,7 +151,7 @@ public class JingleConnection implements Downloadable {
|
||||||
return this.account;
|
return this.account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCounterPart() {
|
public Jid getCounterPart() {
|
||||||
return this.message.getCounterpart();
|
return this.message.getCounterpart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,14 +255,14 @@ public class JingleConnection implements Downloadable {
|
||||||
this.mJingleStatus = JINGLE_STATUS_INITIATED;
|
this.mJingleStatus = JINGLE_STATUS_INITIATED;
|
||||||
Conversation conversation = this.mXmppConnectionService
|
Conversation conversation = this.mXmppConnectionService
|
||||||
.findOrCreateConversation(account,
|
.findOrCreateConversation(account,
|
||||||
packet.getFrom().split("/", 2)[0], false);
|
packet.getFrom().toBareJid(), false);
|
||||||
this.message = new Message(conversation, "", Message.ENCRYPTION_NONE);
|
this.message = new Message(conversation, "", Message.ENCRYPTION_NONE);
|
||||||
this.message.setStatus(Message.STATUS_RECEIVED);
|
this.message.setStatus(Message.STATUS_RECEIVED);
|
||||||
this.message.setType(Message.TYPE_IMAGE);
|
this.message.setType(Message.TYPE_IMAGE);
|
||||||
this.mStatus = Downloadable.STATUS_OFFER;
|
this.mStatus = Downloadable.STATUS_OFFER;
|
||||||
this.message.setDownloadable(this);
|
this.message.setDownloadable(this);
|
||||||
String[] fromParts = packet.getFrom().split("/", 2);
|
final Jid from = packet.getFrom();
|
||||||
this.message.setPresence(fromParts[1]);
|
this.message.setPresence(from.isBareJid() ? "" : from.getResourcepart());
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.initiator = packet.getFrom();
|
this.initiator = packet.getFrom();
|
||||||
this.responder = this.account.getFullJid();
|
this.responder = this.account.getFullJid();
|
||||||
|
@ -375,7 +376,7 @@ public class JingleConnection implements Downloadable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Element> getCandidatesAsElements() {
|
private List<Element> getCandidatesAsElements() {
|
||||||
List<Element> elements = new ArrayList<Element>();
|
List<Element> elements = new ArrayList<>();
|
||||||
for (JingleCandidate c : this.candidates) {
|
for (JingleCandidate c : this.candidates) {
|
||||||
elements.add(c.toElement());
|
elements.add(c.toElement());
|
||||||
}
|
}
|
||||||
|
@ -547,7 +548,7 @@ public class JingleConnection implements Downloadable {
|
||||||
activation.query("http://jabber.org/protocol/bytestreams")
|
activation.query("http://jabber.org/protocol/bytestreams")
|
||||||
.setAttribute("sid", this.getSessionId());
|
.setAttribute("sid", this.getSessionId());
|
||||||
activation.query().addChild("activate")
|
activation.query().addChild("activate")
|
||||||
.setContent(this.getCounterPart());
|
.setContent(this.getCounterPart().toString());
|
||||||
this.account.getXmppConnection().sendIqPacket(activation,
|
this.account.getXmppConnection().sendIqPacket(activation,
|
||||||
new OnIqPacketReceived() {
|
new OnIqPacketReceived() {
|
||||||
|
|
||||||
|
@ -810,11 +811,11 @@ public class JingleConnection implements Downloadable {
|
||||||
this.sendJinglePacket(packet);
|
this.sendJinglePacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInitiator() {
|
public Jid getInitiator() {
|
||||||
return this.initiator;
|
return this.initiator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResponder() {
|
public Jid getResponder() {
|
||||||
return this.responder;
|
return this.responder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,15 @@ import eu.siacs.conversations.services.AbstractConnectionManager;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
|
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
|
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
|
|
||||||
public class JingleConnectionManager extends AbstractConnectionManager {
|
public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
private List<JingleConnection> connections = new CopyOnWriteArrayList<JingleConnection>();
|
private List<JingleConnection> connections = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
private HashMap<String, JingleCandidate> primaryCandidates = new HashMap<String, JingleCandidate>();
|
private HashMap<Jid, JingleCandidate> primaryCandidates = new HashMap<>();
|
||||||
|
|
||||||
@SuppressLint("TrulyRandom")
|
@SuppressLint("TrulyRandom")
|
||||||
private SecureRandom random = new SecureRandom();
|
private SecureRandom random = new SecureRandom();
|
||||||
|
@ -61,7 +63,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleConnection createNewConnection(JinglePacket packet) {
|
public JingleConnection createNewConnection(final JinglePacket packet) {
|
||||||
JingleConnection connection = new JingleConnection(this);
|
JingleConnection connection = new JingleConnection(this);
|
||||||
this.connections.add(connection);
|
this.connections.add(connection);
|
||||||
return connection;
|
return connection;
|
||||||
|
@ -79,7 +81,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
.findDiscoItemByFeature(xmlns);
|
.findDiscoItemByFeature(xmlns);
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
IqPacket iq = new IqPacket(IqPacket.TYPE_GET);
|
IqPacket iq = new IqPacket(IqPacket.TYPE_GET);
|
||||||
iq.setTo(proxy);
|
iq.setAttribute("to", proxy);
|
||||||
iq.query(xmlns);
|
iq.query(xmlns);
|
||||||
account.getXmppConnection().sendIqPacket(iq,
|
account.getXmppConnection().sendIqPacket(iq,
|
||||||
new OnIqPacketReceived() {
|
new OnIqPacketReceived() {
|
||||||
|
@ -101,8 +103,12 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
.getAttribute("port")));
|
.getAttribute("port")));
|
||||||
candidate
|
candidate
|
||||||
.setType(JingleCandidate.TYPE_PROXY);
|
.setType(JingleCandidate.TYPE_PROXY);
|
||||||
candidate.setJid(proxy);
|
try {
|
||||||
candidate.setPriority(655360 + 65535);
|
candidate.setJid(Jid.fromString(proxy));
|
||||||
|
} catch (final InvalidJidException e) {
|
||||||
|
candidate.setJid(null);
|
||||||
|
}
|
||||||
|
candidate.setPriority(655360 + 65535);
|
||||||
primaryCandidates.put(account.getJid(),
|
primaryCandidates.put(account.getJid(),
|
||||||
candidate);
|
candidate);
|
||||||
listener.onPrimaryCandidateFound(true,
|
listener.onPrimaryCandidateFound(true,
|
||||||
|
|
|
@ -13,12 +13,13 @@ import eu.siacs.conversations.entities.DownloadableFile;
|
||||||
import eu.siacs.conversations.utils.CryptoHelper;
|
import eu.siacs.conversations.utils.CryptoHelper;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
|
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
|
|
||||||
public class JingleInbandTransport extends JingleTransport {
|
public class JingleInbandTransport extends JingleTransport {
|
||||||
|
|
||||||
private Account account;
|
private Account account;
|
||||||
private String counterpart;
|
private Jid counterpart;
|
||||||
private int blockSize;
|
private int blockSize;
|
||||||
private int bufferSize;
|
private int bufferSize;
|
||||||
private int seq = 0;
|
private int seq = 0;
|
||||||
|
@ -44,8 +45,8 @@ public class JingleInbandTransport extends JingleTransport {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public JingleInbandTransport(Account account, String counterpart,
|
public JingleInbandTransport(final Account account, final Jid counterpart,
|
||||||
String sid, int blocksize) {
|
final String sid, final int blocksize) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.counterpart = counterpart;
|
this.counterpart = counterpart;
|
||||||
this.blockSize = blocksize;
|
this.blockSize = blocksize;
|
||||||
|
@ -92,12 +93,10 @@ public class JingleInbandTransport extends JingleTransport {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.remainingSize = file.getExpectedSize();
|
this.remainingSize = file.getExpectedSize();
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (final NoSuchAlgorithmException | IOException e) {
|
||||||
callback.onFileTransferAborted();
|
|
||||||
} catch (IOException e) {
|
|
||||||
callback.onFileTransferAborted();
|
callback.onFileTransferAborted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(DownloadableFile file,
|
public void send(DownloadableFile file,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.siacs.conversations.xmpp.jingle.stanzas;
|
package eu.siacs.conversations.xmpp.jingle.stanzas;
|
||||||
|
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
|
|
||||||
public class JinglePacket extends IqPacket {
|
public class JinglePacket extends IqPacket {
|
||||||
|
@ -85,8 +86,8 @@ public class JinglePacket extends IqPacket {
|
||||||
return this.jingle.getAttribute("action");
|
return this.jingle.getAttribute("action");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInitiator(String initiator) {
|
public void setInitiator(final Jid initiator) {
|
||||||
this.jingle.setAttribute("initiator", initiator);
|
this.jingle.setAttribute("initiator", initiator.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAction(String action) {
|
public boolean isAction(String action) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.siacs.conversations.xmpp.stanzas;
|
package eu.siacs.conversations.xmpp.stanzas;
|
||||||
|
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
public class AbstractStanza extends Element {
|
public class AbstractStanza extends Element {
|
||||||
|
@ -9,13 +10,21 @@ public class AbstractStanza extends Element {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTo() {
|
public Jid getTo() {
|
||||||
return getAttribute("to");
|
try {
|
||||||
}
|
return Jid.fromString(getAttribute("to"));
|
||||||
|
} catch (final InvalidJidException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getFrom() {
|
public Jid getFrom() {
|
||||||
return getAttribute("from");
|
try {
|
||||||
}
|
return Jid.fromString(getAttribute("from"));
|
||||||
|
} catch (final InvalidJidException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return this.getAttribute("id");
|
return this.getAttribute("id");
|
||||||
|
|
Loading…
Reference in a new issue