fixes for previous commit
This commit is contained in:
parent
7ce7a505a0
commit
d6835101b9
|
@ -15,6 +15,7 @@ public interface Transferable {
|
||||||
int STATUS_DOWNLOADING = 0x204;
|
int STATUS_DOWNLOADING = 0x204;
|
||||||
int STATUS_OFFER_CHECK_FILESIZE = 0x206;
|
int STATUS_OFFER_CHECK_FILESIZE = 0x206;
|
||||||
int STATUS_UPLOADING = 0x207;
|
int STATUS_UPLOADING = 0x207;
|
||||||
|
int STATUS_CANCELLED = 0x208;
|
||||||
|
|
||||||
|
|
||||||
boolean start();
|
boolean start();
|
||||||
|
|
|
@ -188,7 +188,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
||||||
if (message.isFileOrImage() || transferable != null) {
|
if (message.isFileOrImage() || transferable != null) {
|
||||||
FileParams params = message.getFileParams();
|
FileParams params = message.getFileParams();
|
||||||
filesize = params.size > 0 ? UIHelper.filesizeToString(params.size) : null;
|
filesize = params.size > 0 ? UIHelper.filesizeToString(params.size) : null;
|
||||||
if (transferable != null && transferable.getStatus() == Transferable.STATUS_FAILED) {
|
if (transferable != null && (transferable.getStatus() == Transferable.STATUS_FAILED || transferable.getStatus() == Transferable.STATUS_CANCELLED)) {
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,10 +207,6 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
||||||
info = getContext().getString(R.string.offering);
|
info = getContext().getString(R.string.offering);
|
||||||
break;
|
break;
|
||||||
case Message.STATUS_SEND_RECEIVED:
|
case Message.STATUS_SEND_RECEIVED:
|
||||||
if (mIndicateReceived) {
|
|
||||||
viewHolder.indicatorReceived.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Message.STATUS_SEND_DISPLAYED:
|
case Message.STATUS_SEND_DISPLAYED:
|
||||||
if (mIndicateReceived) {
|
if (mIndicateReceived) {
|
||||||
viewHolder.indicatorReceived.setVisibility(View.VISIBLE);
|
viewHolder.indicatorReceived.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -274,6 +274,8 @@ public class UIHelper {
|
||||||
getFileDescriptionString(context, message)), true);
|
getFileDescriptionString(context, message)), true);
|
||||||
case Transferable.STATUS_FAILED:
|
case Transferable.STATUS_FAILED:
|
||||||
return new Pair<>(context.getString(R.string.file_transmission_failed), true);
|
return new Pair<>(context.getString(R.string.file_transmission_failed), true);
|
||||||
|
case Transferable.STATUS_CANCELLED:
|
||||||
|
return new Pair<>(context.getString(R.string.file_transmission_cancelled), true);
|
||||||
case Transferable.STATUS_UPLOADING:
|
case Transferable.STATUS_UPLOADING:
|
||||||
if (message.getStatus() == Message.STATUS_OFFERED) {
|
if (message.getStatus() == Message.STATUS_OFFERED) {
|
||||||
return new Pair<>(context.getString(R.string.offering_x_file,
|
return new Pair<>(context.getString(R.string.offering_x_file,
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class JingleConnection implements Transferable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFileTransferAborted() {
|
public void onFileTransferAborted() {
|
||||||
JingleConnection.this.sendCancel(); //TODO probably send connectivity error instead?
|
JingleConnection.this.sendSessionTerminate("connectivity-error");
|
||||||
JingleConnection.this.fail();
|
JingleConnection.this.fail();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -227,12 +227,12 @@ public class JingleConnection implements Transferable {
|
||||||
Reason reason = packet.getReason();
|
Reason reason = packet.getReason();
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
if (reason.hasChild("cancel")) {
|
if (reason.hasChild("cancel")) {
|
||||||
//TODO mark as 'cancelled'
|
this.cancelled = true;
|
||||||
this.fail();
|
this.fail();
|
||||||
} else if (reason.hasChild("success")) {
|
} else if (reason.hasChild("success")) {
|
||||||
this.receiveSuccess();
|
this.receiveSuccess();
|
||||||
} else {
|
} else {
|
||||||
this.fail();
|
this.fail(reason.getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.fail();
|
this.fail();
|
||||||
|
@ -411,8 +411,6 @@ public class JingleConnection implements Transferable {
|
||||||
this.contentName = content.getAttribute("name");
|
this.contentName = content.getAttribute("name");
|
||||||
this.transportId = content.getTransportId();
|
this.transportId = content.getTransportId();
|
||||||
|
|
||||||
//TODO change this to positive or negative response instead of fail directly
|
|
||||||
mXmppConnectionService.sendIqPacket(account, packet.generateResponse(IqPacket.TYPE.RESULT), null);
|
|
||||||
|
|
||||||
if (this.initialTransport == Transport.SOCKS) {
|
if (this.initialTransport == Transport.SOCKS) {
|
||||||
this.mergeCandidates(JingleCandidate.parse(content.socks5transport().getChildren()));
|
this.mergeCandidates(JingleCandidate.parse(content.socks5transport().getChildren()));
|
||||||
|
@ -423,20 +421,20 @@ public class JingleConnection implements Transferable {
|
||||||
this.ibbBlockSize = Math.min(Integer.parseInt(receivedBlockSize), this.ibbBlockSize);
|
this.ibbBlockSize = Math.min(Integer.parseInt(receivedBlockSize), this.ibbBlockSize);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.d(Config.LOGTAG, "number format exception " + e.getMessage());
|
Log.d(Config.LOGTAG, "number format exception " + e.getMessage());
|
||||||
this.sendCancel();
|
respondToIq(packet, false);
|
||||||
this.fail();
|
this.fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, "received block size was null");
|
Log.d(Config.LOGTAG, "received block size was null");
|
||||||
this.sendCancel();
|
respondToIq(packet, false);
|
||||||
this.fail();
|
this.fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.ftVersion = content.getVersion();
|
this.ftVersion = content.getVersion();
|
||||||
if (ftVersion == null) {
|
if (ftVersion == null) {
|
||||||
this.sendCancel();
|
respondToIq(packet, false);
|
||||||
this.fail();
|
this.fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -498,6 +496,9 @@ public class JingleConnection implements Transferable {
|
||||||
//JET reports the plain text size. however lower levels of our receiving code still
|
//JET reports the plain text size. however lower levels of our receiving code still
|
||||||
//expect the cipher text size. so we just + 16 bytes (auth tag size) here
|
//expect the cipher text size. so we just + 16 bytes (auth tag size) here
|
||||||
this.file.setExpectedSize(size + (remoteIsUsingJet ? 16 : 0));
|
this.file.setExpectedSize(size + (remoteIsUsingJet ? 16 : 0));
|
||||||
|
|
||||||
|
respondToIq(packet, true);
|
||||||
|
|
||||||
if (mJingleConnectionManager.hasStoragePermission()
|
if (mJingleConnectionManager.hasStoragePermission()
|
||||||
&& size < this.mJingleConnectionManager.getAutoAcceptFileSize()
|
&& size < this.mJingleConnectionManager.getAutoAcceptFileSize()
|
||||||
&& mXmppConnectionService.isDataSaverDisabled()) {
|
&& mXmppConnectionService.isDataSaverDisabled()) {
|
||||||
|
@ -515,13 +516,9 @@ public class JingleConnection implements Transferable {
|
||||||
this.mXmppConnectionService.getNotificationService().push(message);
|
this.mXmppConnectionService.getNotificationService().push(message);
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "receiving file: expecting size of " + this.file.getExpectedSize());
|
Log.d(Config.LOGTAG, "receiving file: expecting size of " + this.file.getExpectedSize());
|
||||||
} else {
|
return;
|
||||||
this.sendCancel();
|
|
||||||
this.fail();
|
|
||||||
}
|
}
|
||||||
} else {
|
respondToIq(packet, false);
|
||||||
this.sendCancel();
|
|
||||||
this.fail();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +566,7 @@ public class JingleConnection implements Transferable {
|
||||||
try {
|
try {
|
||||||
this.mFileInputStream = new FileInputStream(file);
|
this.mFileInputStream = new FileInputStream(file);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
abort();
|
fail(e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
content.setTransportId(this.transportId);
|
content.setTransportId(this.transportId);
|
||||||
|
@ -746,7 +743,7 @@ public class JingleConnection implements Transferable {
|
||||||
connection.setActivated(true);
|
connection.setActivated(true);
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, "activated connection not found");
|
Log.d(Config.LOGTAG, "activated connection not found");
|
||||||
this.sendCancel();
|
sendSessionTerminate("failed-transport");
|
||||||
this.fail();
|
this.fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -884,11 +881,7 @@ public class JingleConnection implements Transferable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendSuccess() {
|
private void sendSuccess() {
|
||||||
JinglePacket packet = bootstrapPacket("session-terminate");
|
sendSessionTerminate("success");
|
||||||
Reason reason = new Reason();
|
|
||||||
reason.addChild("success");
|
|
||||||
packet.setReason(reason);
|
|
||||||
this.sendJinglePacket(packet);
|
|
||||||
this.disconnectSocks5Connections();
|
this.disconnectSocks5Connections();
|
||||||
this.mJingleStatus = JINGLE_STATUS_FINISHED;
|
this.mJingleStatus = JINGLE_STATUS_FINISHED;
|
||||||
this.message.setStatus(Message.STATUS_RECEIVED);
|
this.message.setStatus(Message.STATUS_RECEIVED);
|
||||||
|
@ -999,18 +992,18 @@ public class JingleConnection implements Transferable {
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
this.cancelled = true;
|
this.cancelled = true;
|
||||||
abort();
|
abort("cancel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void abort() {
|
void abort(final String reason) {
|
||||||
this.disconnectSocks5Connections();
|
this.disconnectSocks5Connections();
|
||||||
if (this.transport instanceof JingleInbandTransport) {
|
if (this.transport instanceof JingleInbandTransport) {
|
||||||
this.transport.disconnect();
|
this.transport.disconnect();
|
||||||
}
|
}
|
||||||
this.sendCancel();
|
sendSessionTerminate(reason);
|
||||||
this.mJingleConnectionManager.finishConnection(this);
|
this.mJingleConnectionManager.finishConnection(this);
|
||||||
if (responding()) {
|
if (responding()) {
|
||||||
this.message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_FAILED));
|
this.message.setTransferable(new TransferablePlaceholder(cancelled ? Transferable.STATUS_CANCELLED : Transferable.STATUS_FAILED));
|
||||||
if (this.file != null) {
|
if (this.file != null) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
@ -1035,7 +1028,7 @@ public class JingleConnection implements Transferable {
|
||||||
FileBackend.close(mFileOutputStream);
|
FileBackend.close(mFileOutputStream);
|
||||||
if (this.message != null) {
|
if (this.message != null) {
|
||||||
if (responding()) {
|
if (responding()) {
|
||||||
this.message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_FAILED));
|
this.message.setTransferable(new TransferablePlaceholder(cancelled ? Transferable.STATUS_CANCELLED : Transferable.STATUS_FAILED));
|
||||||
if (this.file != null) {
|
if (this.file != null) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
@ -1050,11 +1043,11 @@ public class JingleConnection implements Transferable {
|
||||||
this.mJingleConnectionManager.finishConnection(this);
|
this.mJingleConnectionManager.finishConnection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendCancel() {
|
private void sendSessionTerminate(String reason) {
|
||||||
JinglePacket packet = bootstrapPacket("session-terminate");
|
final JinglePacket packet = bootstrapPacket("session-terminate");
|
||||||
Reason reason = new Reason();
|
final Reason r = new Reason();
|
||||||
reason.addChild("cancel");
|
r.addChild(reason);
|
||||||
packet.setReason(reason);
|
packet.setReason(r);
|
||||||
this.sendJinglePacket(packet);
|
this.sendJinglePacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
public void cancelInTransmission() {
|
public void cancelInTransmission() {
|
||||||
for (JingleConnection connection : this.connections) {
|
for (JingleConnection connection : this.connections) {
|
||||||
if (connection.getJingleStatus() == JingleConnection.JINGLE_STATUS_TRANSMITTING) {
|
if (connection.getJingleStatus() == JingleConnection.JINGLE_STATUS_TRANSMITTING) {
|
||||||
connection.abort();
|
connection.abort("connectivity-error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,15 @@ public class JingleInbandTransport extends JingleTransport {
|
||||||
private OnIqPacketReceived onAckReceived = new OnIqPacketReceived() {
|
private OnIqPacketReceived onAckReceived = new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
if (connected && packet.getType() == IqPacket.TYPE.RESULT) {
|
if (!connected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
if (remainingSize > 0) {
|
if (remainingSize > 0) {
|
||||||
sendNextBlock();
|
sendNextBlock();
|
||||||
}
|
}
|
||||||
|
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
|
||||||
|
onFileTransmissionStatusChanged.onFileTransferAborted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue