use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleConnection method sendSuccess.
private void sendSuccess() {
JinglePacket packet = bootstrapPacket("session-terminate");
Reason reason = new Reason();
reason.addChild("success");
packet.setReason(reason);
this.sendJinglePacket(packet);
this.disconnectSocks5Connections();
this.mJingleStatus = JINGLE_STATUS_FINISHED;
this.message.setStatus(Message.STATUS_RECEIVED);
this.message.setTransferable(null);
this.mXmppConnectionService.updateMessage(message);
this.mJingleConnectionManager.finishConnection(this);
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleConnection method receiveFallbackToIbb.
private boolean receiveFallbackToIbb(JinglePacket packet) {
Log.d(Config.LOGTAG, "receiving fallack to ibb");
String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size");
if (receivedBlockSize != null) {
int bs = Integer.parseInt(receivedBlockSize);
if (bs > this.ibbBlockSize) {
this.ibbBlockSize = bs;
}
}
this.transportId = packet.getJingleContent().getTransportId();
this.transport = new JingleInbandTransport(this, this.transportId, this.ibbBlockSize);
JinglePacket answer = bootstrapPacket("transport-accept");
Content content = new Content("initiator", "a-file-offer");
content.setTransportId(this.transportId);
content.ibbTransport().setAttribute("block-size", this.ibbBlockSize);
answer.setContent(content);
if (initiator.equals(account.getJid())) {
this.sendJinglePacket(answer, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + " recipient ACKed our transport-accept. creating ibb");
transport.connect(onIbbTransportConnected);
}
}
});
} else {
this.transport.receive(file, onFileTransmissionSatusChanged);
this.sendJinglePacket(answer);
}
return true;
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleConnection method sendProxyActivated.
private void sendProxyActivated(String cid) {
JinglePacket packet = bootstrapPacket("transport-info");
Content content = new Content(this.contentCreator, this.contentName);
content.setTransportId(this.transportId);
content.socks5transport().addChild("activated").setAttribute("cid", cid);
packet.setContent(content);
this.sendJinglePacket(packet);
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleConnection method sendAccept.
private void sendAccept() {
mJingleStatus = JINGLE_STATUS_ACCEPTED;
this.mStatus = Transferable.STATUS_DOWNLOADING;
this.mJingleConnectionManager.updateConversationUi(true);
this.mJingleConnectionManager.getPrimaryCandidate(this.account, new OnPrimaryCandidateFound() {
@Override
public void onPrimaryCandidateFound(boolean success, final JingleCandidate candidate) {
final JinglePacket packet = bootstrapPacket("session-accept");
final Content content = new Content(contentCreator, contentName);
content.setFileOffer(fileOffer, ftVersion);
content.setTransportId(transportId);
if (success && candidate != null && !equalCandidateExists(candidate)) {
final JingleSocks5Transport socksConnection = new JingleSocks5Transport(JingleConnection.this, candidate);
connections.put(candidate.getCid(), socksConnection);
socksConnection.connect(new OnTransportConnected() {
@Override
public void failed() {
Log.d(Config.LOGTAG, "connection to our own primary candidate failed");
content.socks5transport().setChildren(getCandidatesAsElements());
packet.setContent(content);
sendJinglePacket(packet);
connectNextCandidate();
}
@Override
public void established() {
Log.d(Config.LOGTAG, "connected to primary candidate");
mergeCandidate(candidate);
content.socks5transport().setChildren(getCandidatesAsElements());
packet.setContent(content);
sendJinglePacket(packet);
connectNextCandidate();
}
});
} else {
Log.d(Config.LOGTAG, "did not find a primary candidate for ourself");
content.socks5transport().setChildren(getCandidatesAsElements());
packet.setContent(content);
sendJinglePacket(packet);
connectNextCandidate();
}
}
});
}
use of eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket in project Conversations by siacs.
the class JingleConnectionManager method deliverPacket.
public void deliverPacket(final Account account, final JinglePacket packet) {
final String sessionId = packet.getSessionId();
if (sessionId == null) {
respondWithJingleError(account, packet, "unknown-session", "item-not-found", "cancel");
return;
}
final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(account, packet);
final AbstractJingleConnection existingJingleConnection = connections.get(id);
if (existingJingleConnection != null) {
existingJingleConnection.deliverPacket(packet);
} else if (packet.getAction() == JinglePacket.Action.SESSION_INITIATE) {
final Jid from = packet.getFrom();
final Content content = packet.getJingleContent();
final String descriptionNamespace = content == null ? null : content.getDescriptionNamespace();
final AbstractJingleConnection connection;
if (FileTransferDescription.NAMESPACES.contains(descriptionNamespace)) {
connection = new JingleFileTransferConnection(this, id, from);
} else if (Namespace.JINGLE_APPS_RTP.equals(descriptionNamespace) && isUsingClearNet(account)) {
final boolean sessionEnded = this.terminatedSessions.asMap().containsKey(PersistableSessionId.of(id));
final boolean stranger = isWithStrangerAndStrangerNotificationsAreOff(account, id.with);
if (isBusy() || sessionEnded || stranger) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": rejected session with " + id.with + " because busy. sessionEnded=" + sessionEnded + ", stranger=" + stranger);
mXmppConnectionService.sendIqPacket(account, packet.generateResponse(IqPacket.TYPE.RESULT), null);
final JinglePacket sessionTermination = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId);
sessionTermination.setTo(id.with);
sessionTermination.setReason(Reason.BUSY, null);
mXmppConnectionService.sendIqPacket(account, sessionTermination, null);
return;
}
connection = new JingleRtpConnection(this, id, from);
} else {
respondWithJingleError(account, packet, "unsupported-info", "feature-not-implemented", "cancel");
return;
}
connections.put(id, connection);
mXmppConnectionService.updateConversationUi();
connection.deliverPacket(packet);
} else {
Log.d(Config.LOGTAG, "unable to route jingle packet: " + packet);
respondWithJingleError(account, packet, "unknown-session", "item-not-found", "cancel");
}
}
Aggregations