use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.
the class JingleConnectionManager method deliverIbbPacket.
public void deliverIbbPacket(Account account, IqPacket packet) {
String sid = null;
Element payload = null;
if (packet.hasChild("open", "http://jabber.org/protocol/ibb")) {
payload = packet.findChild("open", "http://jabber.org/protocol/ibb");
sid = payload.getAttribute("sid");
} else if (packet.hasChild("data", "http://jabber.org/protocol/ibb")) {
payload = packet.findChild("data", "http://jabber.org/protocol/ibb");
sid = payload.getAttribute("sid");
} else if (packet.hasChild("close", "http://jabber.org/protocol/ibb")) {
payload = packet.findChild("close", "http://jabber.org/protocol/ibb");
sid = payload.getAttribute("sid");
}
if (sid != null) {
for (JingleConnection connection : connections) {
if (connection.getAccount() == account && connection.hasTransportId(sid)) {
JingleTransport transport = connection.getTransport();
if (transport instanceof JingleInbandTransport) {
JingleInbandTransport inbandTransport = (JingleInbandTransport) transport;
inbandTransport.deliverPayload(packet, payload);
return;
}
}
}
Log.d(Config.LOGTAG, "couldn't deliver payload: " + payload.toString());
} else {
Log.d(Config.LOGTAG, "no sid found in incoming ibb packet");
}
}
use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.
the class JingleInbandTransport method sendNextBlock.
private void sendNextBlock() {
byte[] buffer = new byte[this.blockSize];
try {
int count = fileInputStream.read(buffer);
if (count == -1) {
sendClose();
file.setSha1Sum(digest.digest());
this.onFileTransmissionStatusChanged.onFileTransmitted(file);
fileInputStream.close();
return;
} else if (count != buffer.length) {
int rem = fileInputStream.read(buffer, count, buffer.length - count);
if (rem > 0) {
count += rem;
}
}
this.remainingSize -= count;
this.digest.update(buffer, 0, count);
String base64 = Base64.encodeToString(buffer, 0, count, Base64.NO_WRAP);
IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
iq.setTo(this.counterpart);
Element data = iq.addChild("data", "http://jabber.org/protocol/ibb");
data.setAttribute("seq", Integer.toString(this.seq));
data.setAttribute("block-size", Integer.toString(this.blockSize));
data.setAttribute("sid", this.sessionId);
data.setContent(base64);
this.account.getXmppConnection().sendIqPacket(iq, this.onAckReceived);
// don't fill up stanza queue too much
this.account.getXmppConnection().r();
this.seq++;
if (this.remainingSize > 0) {
connection.updateProgress((int) ((((double) (this.fileSize - this.remainingSize)) / this.fileSize) * 100));
} else {
sendClose();
file.setSha1Sum(digest.digest());
this.onFileTransmissionStatusChanged.onFileTransmitted(file);
fileInputStream.close();
}
} catch (IOException e) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": io exception during sendNextBlock() " + e.getMessage());
FileBackend.close(fileInputStream);
this.onFileTransmissionStatusChanged.onFileTransferAborted();
}
}
use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.
the class JingleInbandTransport method sendClose.
private void sendClose() {
IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
iq.setTo(this.counterpart);
Element close = iq.addChild("close", "http://jabber.org/protocol/ibb");
close.setAttribute("sid", this.sessionId);
this.account.getXmppConnection().sendIqPacket(iq, null);
}
use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.
the class Content method ibbTransport.
public Element ibbTransport() {
Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:ibb:1");
if (transport == null) {
transport = this.addChild("transport", "urn:xmpp:jingle:transports:ibb:1");
transport.setAttribute("sid", this.transportId);
}
return transport;
}
use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.
the class Content method socks5transport.
public Element socks5transport() {
Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1");
if (transport == null) {
transport = this.addChild("transport", "urn:xmpp:jingle:transports:s5b:1");
transport.setAttribute("sid", this.transportId);
}
return transport;
}
Aggregations