use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class XmppConnection method processIq.
private void processIq(final Tag currentTag) throws XmlPullParserException, IOException {
final IqPacket packet = (IqPacket) processPacket(currentTag, PACKET_IQ);
if (packet.getId() == null) {
// an iq packet without id is definitely invalid
return;
}
if (packet instanceof JinglePacket) {
if (this.jingleListener != null) {
this.jingleListener.onJinglePacketReceived(account, (JinglePacket) packet);
}
} else {
OnIqPacketReceived callback = null;
synchronized (this.packetCallbacks) {
if (packetCallbacks.containsKey(packet.getId())) {
final Pair<IqPacket, OnIqPacketReceived> packetCallbackDuple = packetCallbacks.get(packet.getId());
// Packets to the server should have responses from the server
if (packetCallbackDuple.first.toServer(account)) {
if (packet.fromServer(account)) {
callback = packetCallbackDuple.second;
packetCallbacks.remove(packet.getId());
} else {
Log.e(Config.LOGTAG, account.getJid().toBareJid().toString() + ": ignoring spoofed iq packet");
}
} else {
if (packet.getFrom().equals(packetCallbackDuple.first.getTo())) {
callback = packetCallbackDuple.second;
packetCallbacks.remove(packet.getId());
} else {
Log.e(Config.LOGTAG, account.getJid().toBareJid().toString() + ": ignoring spoofed iq packet");
}
}
} else if (packet.getType() == IqPacket.TYPE.GET || packet.getType() == IqPacket.TYPE.SET) {
callback = this.unregisteredIqListener;
}
}
if (callback != null) {
callback.onIqPacketReceived(account, packet);
}
}
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleConnection method sendInitRequest.
private void sendInitRequest() {
JinglePacket packet = this.bootstrapPacket("session-initiate");
Content content = new Content(this.contentCreator, this.contentName);
if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE) {
content.setTransportId(this.transportId);
this.file = this.mXmppConnectionService.getFileBackend().getFile(message, false);
Pair<InputStream, Integer> pair;
try {
if (message.getEncryption() == Message.ENCRYPTION_OTR) {
Conversation conversation = this.message.getConversation();
if (!this.mXmppConnectionService.renewSymmetricKey(conversation)) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not set symmetric key");
cancel();
}
this.file.setKeyAndIv(conversation.getSymmetricKey());
pair = AbstractConnectionManager.createInputStream(this.file, false);
this.file.setExpectedSize(pair.second);
content.setFileOffer(this.file, true, this.ftVersion);
} else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
this.file.setKey(mXmppAxolotlMessage.getInnerKey());
this.file.setIv(mXmppAxolotlMessage.getIV());
pair = AbstractConnectionManager.createInputStream(this.file, true);
this.file.setExpectedSize(pair.second);
content.setFileOffer(this.file, false, this.ftVersion).addChild(mXmppAxolotlMessage.toElement());
} else {
pair = AbstractConnectionManager.createInputStream(this.file, false);
this.file.setExpectedSize(pair.second);
content.setFileOffer(this.file, false, this.ftVersion);
}
} catch (FileNotFoundException e) {
cancel();
return;
}
this.mFileInputStream = pair.first;
content.setTransportId(this.transportId);
content.socks5transport().setChildren(getCandidatesAsElements());
packet.setContent(content);
this.sendJinglePacket(packet, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": other party received offer");
mJingleStatus = JINGLE_STATUS_INITIATED;
mXmppConnectionService.markMessage(message, Message.STATUS_OFFERED);
} else {
fail(IqParser.extractErrorMessage(packet));
}
}
});
}
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleConnection method sendCandidateUsed.
private void sendCandidateUsed(final String cid) {
JinglePacket packet = bootstrapPacket("transport-info");
Content content = new Content(this.contentCreator, this.contentName);
content.setTransportId(this.transportId);
content.socks5transport().addChild("candidate-used").setAttribute("cid", cid);
packet.setContent(content);
this.sentCandidate = true;
if ((receivedCandidate) && (mJingleStatus == JINGLE_STATUS_ACCEPTED)) {
connect();
}
this.sendJinglePacket(packet);
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleConnection method bootstrapPacket.
private JinglePacket bootstrapPacket(String action) {
JinglePacket packet = new JinglePacket();
packet.setAction(action);
packet.setFrom(account.getJid());
packet.setTo(this.message.getCounterpart());
packet.setSessionId(this.sessionId);
packet.setInitiator(this.initiator);
return packet;
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleConnection method sendCancel.
private void sendCancel() {
JinglePacket packet = bootstrapPacket("session-terminate");
Reason reason = new Reason();
reason.addChild("cancel");
packet.setReason(reason);
this.sendJinglePacket(packet);
}
Aggregations