status waiting for images sent offline

This commit is contained in:
iNPUTmice 2014-06-13 15:05:35 +02:00
parent eb7ed78605
commit 76f3894107
2 changed files with 41 additions and 24 deletions

View file

@ -650,7 +650,13 @@ public class XmppConnectionService extends Service {
boolean send = false; boolean send = false;
if (account.getStatus() == Account.STATUS_ONLINE) { if (account.getStatus() == Account.STATUS_ONLINE) {
if (message.getType() == Message.TYPE_IMAGE) { if (message.getType() == Message.TYPE_IMAGE) {
mJingleConnectionManager.createNewConnection(message); if (message.getPresence() !=null ) {
mJingleConnectionManager.createNewConnection(message);
} else {
message.setStatus(Message.STATUS_WAITING);
saveInDb = true;
addToConversation = true;
}
} else { } else {
if (message.getEncryption() == Message.ENCRYPTION_OTR) { if (message.getEncryption() == Message.ENCRYPTION_OTR) {
if (!conv.hasValidOtrSession()&&(message.getPresence() != null)) { if (!conv.hasValidOtrSession()&&(message.getPresence() != null)) {
@ -693,29 +699,35 @@ public class XmppConnectionService extends Service {
} }
} }
} else { } else {
if (message.getEncryption() == Message.ENCRYPTION_PGP) { if (message.getType() == Message.TYPE_IMAGE) {
String pgpBody = message.getEncryptedBody(); message.setStatus(Message.STATUS_WAITING);
String decryptedBody = message.getBody();
message.setBody(pgpBody);
databaseBackend.createMessage(message);
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
message.setBody(decryptedBody);
addToConversation = true;
} else if (message.getEncryption() == Message.ENCRYPTION_OTR) {
if (conv.hasValidOtrSession()) {
message.setPresence(conv.getOtrSession().getSessionID()
.getUserID());
} else if (!conv.hasValidOtrSession() && message.getPresence() != null) {
conv.startOtrSession(getApplicationContext(),
message.getPresence(), false);
} else if (message.getPresence() == null) {
message.setStatus(Message.STATUS_WAITING);
}
saveInDb = true; saveInDb = true;
addToConversation = true; addToConversation = true;
} else { } else {
saveInDb = true; if (message.getEncryption() == Message.ENCRYPTION_PGP) {
addToConversation = true; String pgpBody = message.getEncryptedBody();
String decryptedBody = message.getBody();
message.setBody(pgpBody);
databaseBackend.createMessage(message);
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
message.setBody(decryptedBody);
addToConversation = true;
} else if (message.getEncryption() == Message.ENCRYPTION_OTR) {
if (conv.hasValidOtrSession()) {
message.setPresence(conv.getOtrSession().getSessionID()
.getUserID());
} else if (!conv.hasValidOtrSession() && message.getPresence() != null) {
conv.startOtrSession(getApplicationContext(),
message.getPresence(), false);
} else if (message.getPresence() == null) {
message.setStatus(Message.STATUS_WAITING);
}
saveInDb = true;
addToConversation = true;
} else {
saveInDb = true;
addToConversation = true;
}
} }
} }

View file

@ -193,6 +193,8 @@ public class ConversationFragment extends Fragment {
String filesize = null; String filesize = null;
String info = null; String info = null;
boolean error = false; boolean error = false;
boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI
&& message.getStatus() <= Message.STATUS_RECIEVED;
if (message.getType() == Message.TYPE_IMAGE) { if (message.getType() == Message.TYPE_IMAGE) {
String[] fileParams = message.getBody().split(","); String[] fileParams = message.getBody().split(",");
try { try {
@ -221,8 +223,7 @@ public class ConversationFragment extends Fragment {
error = true; error = true;
break; break;
default: default:
if ((message.getConversation().getMode() == Conversation.MODE_MULTI) if (multiReceived) {
&& (message.getStatus() <= Message.STATUS_RECIEVED)) {
info = message.getCounterpart(); info = message.getCounterpart();
} }
break; break;
@ -256,8 +257,12 @@ public class ConversationFragment extends Fragment {
if ((filesize != null) && (info != null)) { if ((filesize != null) && (info != null)) {
viewHolder.time.setText(filesize + " \u00B7 " + info); viewHolder.time.setText(filesize + " \u00B7 " + info);
} else if ((filesize == null) && (info != null)) { } else if ((filesize == null) && (info != null)) {
viewHolder.time.setText(info + " \u00B7 " if (error) {
viewHolder.time.setText(info + " \u00B7 "
+ formatedTime); + formatedTime);
} else {
viewHolder.time.setText(info);
}
} else if ((filesize != null) && (info == null)) { } else if ((filesize != null) && (info == null)) {
viewHolder.time.setText(filesize + " \u00B7 " viewHolder.time.setText(filesize + " \u00B7 "
+ formatedTime); + formatedTime);