proper error state for images

This commit is contained in:
iNPUTmice 2014-10-29 11:31:03 +01:00
parent 64209829f7
commit 03593ba56f
6 changed files with 17 additions and 20 deletions

View File

@ -281,5 +281,6 @@
<string name="message_text">Message text</string>
<string name="url_copied_to_clipboard">URL copied to clipboard</string>
<string name="message_copied_to_clipboard">Message copied to clipboard</string>
<string name="image_transmission_failed">Image transmission failed</string>
</resources>

View File

@ -16,7 +16,6 @@ public class Message extends AbstractEntity {
public static final int STATUS_UNSEND = 1;
public static final int STATUS_SEND = 2;
public static final int STATUS_SEND_FAILED = 3;
public static final int STATUS_SEND_REJECTED = 4;
public static final int STATUS_WAITING = 5;
public static final int STATUS_OFFERED = 6;
public static final int STATUS_SEND_RECEIVED = 7;

View File

@ -11,7 +11,6 @@ import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Downloadable;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.Presences;

View File

@ -100,6 +100,9 @@ public class MessageAdapter extends ArrayAdapter<Message> {
if (params.size != 0) {
filesize = params.size / 1024 + " KB";
}
if (message.getDownloadable() != null && message.getDownloadable().getStatus() == Downloadable.STATUS_FAILED) {
error = true;
}
}
switch (message.getMergedStatus()) {
case Message.STATUS_WAITING:
@ -125,10 +128,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
info = getContext().getString(R.string.send_failed);
error = true;
break;
case Message.STATUS_SEND_REJECTED:
info = getContext().getString(R.string.send_rejected);
error = true;
break;
default:
if (multiReceived) {
Contact contact = message.getContact();
@ -484,6 +483,8 @@ public class MessageAdapter extends ArrayAdapter<Message> {
&& d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) {
displayDownloadableMessage(viewHolder, item,
R.string.check_image_filesize);
} else if (d != null && d.getStatus() == Downloadable.STATUS_FAILED) {
displayInfoMessage(viewHolder, R.string.image_transmission_failed);
} else if ((item.getEncryption() == Message.ENCRYPTION_DECRYPTED)
|| (item.getEncryption() == Message.ENCRYPTION_NONE)
|| (item.getEncryption() == Message.ENCRYPTION_OTR)) {

View File

@ -73,11 +73,7 @@ public class JingleConnection implements Downloadable {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE_ERROR) {
if (initiator.equals(account.getFullJid())) {
mXmppConnectionService.markMessage(message,
Message.STATUS_SEND_FAILED);
}
mJingleStatus = JINGLE_STATUS_FAILED;
cancel();
}
}
};
@ -354,6 +350,7 @@ public class JingleConnection implements Downloadable {
}
private void sendInitRequest() {
this.mXmppConnectionService.markMessage(this.message, Message.STATUS_OFFERED);
JinglePacket packet = this.bootstrapPacket("session-initiate");
Content content = new Content(this.contentCreator, this.contentName);
if (message.getType() == Message.TYPE_IMAGE) {
@ -716,13 +713,8 @@ public class JingleConnection implements Downloadable {
this.mStatus = Downloadable.STATUS_FAILED;
this.mXmppConnectionService.updateConversationUi();
} else {
if (this.mJingleStatus == JINGLE_STATUS_INITIATED) {
this.mXmppConnectionService.markMessage(this.message,
Message.STATUS_SEND_REJECTED);
} else {
this.mXmppConnectionService.markMessage(this.message,
Message.STATUS_SEND_FAILED);
}
this.mXmppConnectionService.markMessage(this.message,
Message.STATUS_SEND_FAILED);
}
}
this.mJingleConnectionManager.finishConnection(this);

View File

@ -44,8 +44,13 @@ public class JingleConnectionManager extends AbstractConnectionManager {
return;
}
}
account.getXmppConnection().sendIqPacket(
packet.generateRespone(IqPacket.TYPE_ERROR), null);
IqPacket response = packet.generateRespone(IqPacket.TYPE_ERROR);
Element error = response.addChild("error");
error.setAttribute("type", "cancel");
error.addChild("item-not-found",
"urn:ietf:params:xml:ns:xmpp-stanzas");
error.addChild("unknown-session", "urn:xmpp:jingle:errors:1");
account.getXmppConnection().sendIqPacket(response, null);
}
}