use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleFileTransferConnection method sendAcceptSocks.
private void sendAcceptSocks() {
gatherAndConnectDirectCandidates();
this.jingleConnectionManager.getPrimaryCandidate(this.id.account, isInitiator(), (success, candidate) -> {
final JinglePacket packet = bootstrapPacket(JinglePacket.Action.SESSION_ACCEPT);
final Content content = new Content(contentCreator, contentName);
content.setSenders(this.contentSenders);
content.setDescription(this.description);
if (success && candidate != null && !equalCandidateExists(candidate)) {
final JingleSocks5Transport socksConnection = new JingleSocks5Transport(this, candidate);
connections.put(candidate.getCid(), socksConnection);
socksConnection.connect(new OnTransportConnected() {
@Override
public void failed() {
Log.d(Config.LOGTAG, "connection to our own proxy65 candidate failed");
content.setTransport(new S5BTransportInfo(transportId, getOurCandidates()));
packet.addJingleContent(content);
sendJinglePacket(packet);
connectNextCandidate();
}
@Override
public void established() {
Log.d(Config.LOGTAG, "connected to proxy65 candidate");
mergeCandidate(candidate);
content.setTransport(new S5BTransportInfo(transportId, getOurCandidates()));
packet.addJingleContent(content);
sendJinglePacket(packet);
connectNextCandidate();
}
});
} else {
Log.d(Config.LOGTAG, "did not find a proxy65 candidate for ourselves");
content.setTransport(new S5BTransportInfo(transportId, getOurCandidates()));
packet.addJingleContent(content);
sendJinglePacket(packet);
connectNextCandidate();
}
});
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleFileTransferConnection method sendCandidateError.
private void sendCandidateError() {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": sending candidate error");
JinglePacket packet = bootstrapPacket(JinglePacket.Action.TRANSPORT_INFO);
Content content = new Content(this.contentCreator, this.contentName);
content.setSenders(this.contentSenders);
content.setTransport(new S5BTransportInfo(this.transportId, new Element("candidate-error")));
packet.addJingleContent(content);
this.sentCandidate = true;
this.sendJinglePacket(packet);
if (receivedCandidate && mJingleStatus == JINGLE_STATUS_ACCEPTED) {
connect();
}
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleRtpConnection method sendSessionAccept.
private void sendSessionAccept(final RtpContentMap rtpContentMap) {
if (isTerminated()) {
Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": preparing session accept was too slow. already terminated. nothing to do.");
return;
}
transitionOrThrow(State.SESSION_ACCEPTED);
final JinglePacket sessionAccept = rtpContentMap.toJinglePacket(JinglePacket.Action.SESSION_ACCEPT, id.sessionId);
send(sessionAccept);
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class RtpContentMap method toJinglePacket.
JinglePacket toJinglePacket(final JinglePacket.Action action, final String sessionId) {
final JinglePacket jinglePacket = new JinglePacket(action, sessionId);
if (this.group != null) {
jinglePacket.addGroup(this.group);
}
for (Map.Entry<String, DescriptionTransport> entry : this.contents.entrySet()) {
final Content content = new Content(Content.Creator.INITIATOR, entry.getKey());
if (entry.getValue().description != null) {
content.addChild(entry.getValue().description);
}
content.addChild(entry.getValue().transport);
jinglePacket.addJingleContent(content);
}
return jinglePacket;
}
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 IOException {
final IqPacket packet = (IqPacket) processPacket(currentTag, PACKET_IQ);
if (!packet.valid()) {
Log.e(Config.LOGTAG, "encountered invalid iq from='" + packet.getFrom() + "' to='" + packet.getTo() + "'");
return;
}
if (packet instanceof JinglePacket) {
if (this.jingleListener != null) {
this.jingleListener.onJinglePacketReceived(account, (JinglePacket) packet);
}
} else {
OnIqPacketReceived callback = null;
synchronized (this.packetCallbacks) {
final Pair<IqPacket, OnIqPacketReceived> packetCallbackDuple = packetCallbacks.get(packet.getId());
if (packetCallbackDuple != null) {
// 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().asBareJid().toString() + ": ignoring spoofed iq packet");
}
} else {
if (packet.getFrom() != null && packet.getFrom().equals(packetCallbackDuple.first.getTo())) {
callback = packetCallbackDuple.second;
packetCallbacks.remove(packet.getId());
} else {
Log.e(Config.LOGTAG, account.getJid().asBareJid().toString() + ": ignoring spoofed iq packet");
}
}
} else if (packet.getType() == IqPacket.TYPE.GET || packet.getType() == IqPacket.TYPE.SET) {
callback = this.unregisteredIqListener;
}
}
if (callback != null) {
try {
callback.onIqPacketReceived(account, packet);
} catch (StateChangingError error) {
throw new StateChangingException(error.state);
}
}
}
}
Aggregations