aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/services
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2018-05-05 20:28:04 +0200
committersteckbrief <steckbrief@chefmail.de>2018-05-05 20:28:04 +0200
commitb0780224b5bdd68d74ef514e64e14ce9d37d7b90 (patch)
tree04311ea20090216b4897bcb507d79c7e02f76eae /src/main/java/de/thedevstack/conversationsplus/services
parent853f50e43f68599774469dd12240f35800144991 (diff)
introduces new message state model
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/services')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/ExportLogsService.java8
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java48
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java76
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/avatar/AvatarCache.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/filetransfer/FileTransferManager.java9
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/AutomaticFileDownload.java8
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/HttpRetrieveHead.java8
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/upload/HttpUploadFileTransferEntity.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/upload/HttpUploadFileTransferService.java3
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/mam/MessageArchiveService.java10
10 files changed, 81 insertions, 97 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/ExportLogsService.java b/src/main/java/de/thedevstack/conversationsplus/services/ExportLogsService.java
index 0dcfa05e..4dd0a714 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/ExportLogsService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/ExportLogsService.java
@@ -92,13 +92,11 @@ public class ExportLogsService extends Service {
new File(dir, contactJid.toBareJid().toString() + ".txt")));
}
String jid = null;
- switch (message.getStatus()) {
- case Message.STATUS_RECEIVED:
+ switch (message.getDirection()) {
+ case IN:
jid = getMessageCounterpart(message);
break;
- case Message.STATUS_SEND:
- case Message.STATUS_SEND_RECEIVED:
- case Message.STATUS_SEND_DISPLAYED:
+ case OUT:
jid = accountJid.toBareJid().toString();
break;
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java b/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java
index c21c90d1..c5ada873 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java
@@ -29,9 +29,12 @@ import java.util.List;
import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.thedevstack.conversationsplus.ConversationsPlusColors;
import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
+import de.thedevstack.conversationsplus.enums.MessageDirection;
import de.thedevstack.conversationsplus.services.avatar.AvatarCache;
import de.thedevstack.conversationsplus.utils.ImageUtil;
import de.thedevstack.conversationsplus.utils.MessageUtil;
+import de.thedevstack.conversationsplus.utils.XmppSendUtil;
+import de.thedevstack.conversationsplus.xmpp.stanzas.MessagePacket;
import de.tzur.conversations.Settings;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.R;
@@ -62,7 +65,7 @@ public class NotificationService {
}
public boolean notify(final Message message) {
- return (message.getStatus() == Message.STATUS_RECEIVED)
+ return MessageUtil.isIncomingMessage(message)
&& !message.isRead()
&& ConversationsPlusPreferences.showNotification()
&& !message.getConversation().isMuted()
@@ -133,25 +136,28 @@ public class NotificationService {
}
public void push(final Message message) {
- if (!notify(message)) {
- return;
- }
- mXmppConnectionService.updateUnreadCountBadge();
- final boolean isScreenOn = mXmppConnectionService.isInteractive();
- if (this.mIsInForeground && isScreenOn && this.mOpenConversation == message.getConversation()) {
- return;
- }
- synchronized (notifications) {
- pushToStack(message);
- final Account account = message.getConversation().getAccount();
- final boolean doNotify = (!(this.mIsInForeground && this.mOpenConversation == null) || !isScreenOn)
- && !account.inGracePeriod()
- && !this.inMiniGracePeriod(account);
- updateNotification(doNotify);
- if (doNotify) {
- notifyPebble(message);
+ if (message.isMamReceived()) {
+ return;
+ }
+ if (notify(message)) {
+ mXmppConnectionService.updateUnreadCountBadge();
+ final boolean isScreenOn = mXmppConnectionService.isInteractive();
+ if (this.mIsInForeground && isScreenOn && this.mOpenConversation == message.getConversation()) {
+ return;
+ }
+ synchronized (notifications) {
+ pushToStack(message);
+ final Account account = message.getConversation().getAccount();
+ final boolean doNotify = (!(this.mIsInForeground && this.mOpenConversation == null) || !isScreenOn)
+ && !account.inGracePeriod()
+ && !this.inMiniGracePeriod(account);
+ updateNotification(doNotify);
+ if (doNotify) {
+ notifyPebble(message);
+ }
}
}
+
}
public void clear() {
@@ -354,11 +360,9 @@ public class NotificationService {
private Message getImage(final Iterable<Message> messages) {
for (final Message message : messages) {
- if (message.getType() != Message.TYPE_TEXT
- && message.getTransferable() == null
+ if (message.getTransferable() == null
&& message.getEncryption() != Message.ENCRYPTION_PGP
- && message.getFileParams() != null
- && message.getFileParams().getHeight() > 0) { // TODO Use FileParams.getMimeType()
+ && MessageUtil.isAttachedFileAnImage(message)) { // TODO Use FileParams.getMimeType()
return message;
}
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java b/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java
index bad0415f..2285a29d 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java
@@ -55,6 +55,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
+import de.thedevstack.conversationsplus.enums.MessageDirection;
+import de.thedevstack.conversationsplus.enums.MessageStatus;
import de.thedevstack.conversationsplus.services.avatar.AvatarCache;
import de.thedevstack.conversationsplus.services.avatar.AvatarService;
import de.thedevstack.conversationsplus.services.filetransfer.FileTransferManager;
@@ -71,6 +73,7 @@ import de.thedevstack.conversationsplus.utils.XmppConnectionServiceAccessor;
import de.thedevstack.conversationsplus.utils.XmppSendUtil;
import de.thedevstack.conversationsplus.services.muc.listener.ConferenceServiceDiscoveryReceived;
import de.thedevstack.conversationsplus.xmpp.XepRegistry;
+import de.thedevstack.conversationsplus.xmpp.chatmarkers.ChatMarkersXep;
import de.thedevstack.conversationsplus.xmpp.disco.ServiceDiscoveryIqPacketGenerator;
import de.thedevstack.conversationsplus.xmpp.disco.ServiceDiscoveryIqPacketParser;
import de.thedevstack.conversationsplus.xmpp.disco.ServiceDiscoveryXep;
@@ -97,8 +100,6 @@ import de.thedevstack.conversationsplus.entities.MucOptions.OnRenameListener;
import de.thedevstack.conversationsplus.entities.Presence;
import de.thedevstack.conversationsplus.entities.Roster;
import de.thedevstack.conversationsplus.entities.ServiceDiscoveryResult;
-import de.thedevstack.conversationsplus.entities.Transferable;
-import de.thedevstack.conversationsplus.entities.TransferablePlaceholder;
import de.thedevstack.conversationsplus.generator.IqGenerator;
import de.thedevstack.conversationsplus.generator.MessageGenerator;
import de.thedevstack.conversationsplus.generator.PresenceGenerator;
@@ -224,7 +225,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (conversation.getAccount() == account) {
Message message = conversation.findUnsentMessageWithUuid(uuid);
if (message != null) {
- MessageUtil.markMessage(message, Message.STATUS_SEND);
+ MessageUtil.setAndSaveMessageStatus(message, MessageStatus.TRANSMITTED);
}
}
}
@@ -717,6 +718,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
XepRegistry.add(new ServiceDiscoveryXep());
XepRegistry.add(new PingXep());
XepRegistry.add(new OpenPgpXep());
+ XepRegistry.add(new ChatMarkersXep(Settings.CONFIRM_MESSAGE_RECEIVED));
final XmppConnection connection = new XmppConnection(account, this);
connection.setOnMessagePacketReceivedListener(this.mMessageParser);
@@ -752,10 +754,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
account.deactivateGracePeriod();
MessagePacket packet = null;
final boolean addToConversation = (conversation.getMode() != Conversation.MODE_MULTI
- || account.getServerIdentity() != XmppConnection.Identity.SLACK)
- && !message.edited();
+ || account.getServerIdentity() != XmppConnection.Identity.SLACK);
boolean saveInDb = addToConversation;
- message.setStatus(Message.STATUS_WAITING);
+ MessageUtil.setMessageStatus(message, MessageStatus.WAITING);
if (!resend && message.getEncryption() != Message.ENCRYPTION_OTR) {
message.getConversation().endOtrIfNeeded();
@@ -763,7 +764,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
new Conversation.OnMessageFound() {
@Override
public void onMessageFound(Message message) {
- MessageUtil.markMessage(message, Message.STATUS_SEND_FAILED);
+ MessageUtil.setAndSaveMessageStatus(message, MessageStatus.FAILED);
}
});
}
@@ -833,9 +834,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
if (packet != null) {
if (account.getXmppConnection().getFeatures().sm() || conversation.getMode() == Conversation.MODE_MULTI) {
- message.setStatus(Message.STATUS_UNSEND);
+ MessageUtil.setMessageStatus(message, MessageStatus.TRANSMITTING);
} else {
- message.setStatus(Message.STATUS_SEND);
+ MessageUtil.setMessageStatus(message, MessageStatus.TRANSMITTED);
}
}
} else {
@@ -867,9 +868,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (resend) {
if (packet != null && addToConversation) {
if (account.getXmppConnection().getFeatures().sm() || conversation.getMode() == Conversation.MODE_MULTI) {
- MessageUtil.markMessage(message, Message.STATUS_UNSEND);
+ MessageUtil.setAndSaveMessageStatus(message, MessageStatus.TRANSMITTING);
} else {
- MessageUtil.markMessage(message, Message.STATUS_SEND);
+ MessageUtil.setAndSaveMessageStatus(message, MessageStatus.TRANSMITTED);
}
}
} else {
@@ -879,8 +880,6 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (message.getEncryption() == Message.ENCRYPTION_NONE || !ConversationsPlusPreferences.dontSaveEncrypted()) {
if (saveInDb) {
databaseBackend.createMessage(message);
- } else if (message.edited()) {
- databaseBackend.updateMessage(message, message.getEditedId());
}
}
updateConversationUi();
@@ -1085,11 +1084,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
@Override
public void onMessageFound(Message message) {
if (!FileBackend.isFileAvailable(message)) {
- message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
- final int s = message.getStatus();
- if (s == Message.STATUS_WAITING || s == Message.STATUS_OFFERED || s == Message.STATUS_UNSEND) {
- MessageUtil.markMessage(message, Message.STATUS_SEND_FAILED);
- }
+ MessageUtil.setAndSaveStatusForFileDeleted(message);
}
}
});
@@ -2017,8 +2012,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
MessagePacket outPacket = mMessageGenerator.generateOtrChat(message);
if (outPacket != null) {
mMessageGenerator.addDelay(outPacket, message.getTimeSent());
- message.setStatus(Message.STATUS_SEND);
- databaseBackend.updateMessage(message);
+ MessageUtil.setMessageStatus(message, MessageStatus.TRANSMITTED);
+ DatabaseBackend.getInstance().updateMessage(message);
sendMessagePacket(account, outPacket);
}
}
@@ -2140,32 +2135,28 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public void resetSendingToWaiting(Account account) {
for (Conversation conversation : getConversations()) {
if (conversation.getAccount() == account) {
- conversation.findUnsentTextMessages(new Conversation.OnMessageFound() {
+ conversation.findOugoingTextMessagesInTransmission(new Conversation.OnMessageFound() {
@Override
public void onMessageFound(Message message) {
- MessageUtil.markMessage(message, Message.STATUS_WAITING);
+ MessageUtil.setAndSaveMessageStatus(message, MessageStatus.WAITING);
}
});
}
}
}
- public Message markMessage(final Account account, final Jid recipient, final String uuid, final int status) {
- if (uuid == null) {
- return null;
- }
- for (Conversation conversation : getConversations()) {
- if (conversation.getJid().toBareJid().equals(recipient) && conversation.getAccount() == account) {
- final Message message = conversation.findSentMessageWithUuidOrRemoteId(uuid);
- if (message != null) {
- MessageUtil.markMessage(message, status);
- }
- return message;
- }
- }
- return null;
- }
+ public Message getMessage(final Account account, final Jid recipient, final String uuid) {
+ if (uuid == null) {
+ return null;
+ }
+ for (Conversation conversation : getConversations()) {
+ if (conversation.getJid().toBareJid().equals(recipient) && conversation.getAccount() == account) {
+ return conversation.findSentMessageWithUuidOrRemoteId(uuid);
+ }
+ }
+ return null;
+ }
public int unreadCount() {
int count = 0;
@@ -2258,7 +2249,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
@Override
public void run() {
for (Message message : readMessages) {
- databaseBackend.updateMessage(message);
+ DatabaseBackend.getInstance().updateMessage(message);
}
}
};
@@ -2414,11 +2405,12 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
return this.mNotificationService;
}
- public void resendFailedMessages(final Message message) {
- if (message.getStatus() == Message.STATUS_SEND_FAILED
- || message.getStatus() == Message.STATUS_SEND_CANCELED) {
+ public void resendFailedOrCanceledMessages(final Message message) {
+ if (MessageUtil.isOutgoingMessage(message)
+ && (MessageStatus.FAILED == message.getMessageStatus()
+ || MessageStatus.CANCELED == message.getMessageStatus())) {
message.setTime(System.currentTimeMillis());
- MessageUtil.markMessage(message, Message.STATUS_WAITING);
+ MessageUtil.setAndSaveMessageStatus(message, MessageStatus.WAITING);
this.resendMessage(message, false);
}
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/avatar/AvatarCache.java b/src/main/java/de/thedevstack/conversationsplus/services/avatar/AvatarCache.java
index a4def149..5e10f27c 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/avatar/AvatarCache.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/avatar/AvatarCache.java
@@ -12,8 +12,10 @@ import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.entities.ListItem;
import de.thedevstack.conversationsplus.entities.Message;
import de.thedevstack.conversationsplus.entities.MucOptions;
+import de.thedevstack.conversationsplus.enums.MessageDirection;
import de.thedevstack.conversationsplus.utils.AvatarUtil;
import de.thedevstack.conversationsplus.utils.ImageUtil;
+import de.thedevstack.conversationsplus.utils.MessageUtil;
import de.thedevstack.conversationsplus.utils.UIHelper;
/**
@@ -177,7 +179,7 @@ public final class AvatarCache {
public static Bitmap get(Message message, int size, boolean cachedOnly) {
final Conversation conversation = message.getConversation();
- if (message.getStatus() == Message.STATUS_RECEIVED) {
+ if (MessageUtil.isIncomingMessage(message)) {
Contact c = message.getContact();
if (c != null && (c.getProfilePhoto() != null || c.getAvatar() != null)) {
return get(c, size, cachedOnly);
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/FileTransferManager.java b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/FileTransferManager.java
index 63f1547f..62fed29b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/FileTransferManager.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/FileTransferManager.java
@@ -9,6 +9,7 @@ import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.entities.Message;
import de.thedevstack.conversationsplus.enums.FileStatus;
+import de.thedevstack.conversationsplus.enums.MessageStatus;
import de.thedevstack.conversationsplus.services.FileTransferService;
import de.thedevstack.conversationsplus.services.filetransfer.http.upload.HttpUploadFileTransferEntity;
import de.thedevstack.conversationsplus.utils.MessageUtil;
@@ -124,9 +125,8 @@ public class FileTransferManager implements FileTransferStatusListener {
}
}
}
- if (!retransferStarted) {
- entity.getMessage().getFileParams().setFileStatus(FileStatus.UPLOAD_FAILED);
- MessageUtil.markMessage(entity.getMessage(), Message.STATUS_SEND_FAILED);
+ if (!retransferStarted && (entity instanceof HttpUploadFileTransferEntity)) {
+ MessageUtil.setAndSaveFileStatus(entity.getMessage(), FileStatus.UPLOAD_FAILED);
}
}
}
@@ -134,12 +134,13 @@ public class FileTransferManager implements FileTransferStatusListener {
@Override
public void onCancel(FileTransferEntity entity) {
this.activeTransfers.remove(entity.getMessage().getUuid());
- MessageUtil.markMessage(entity.getMessage(), Message.STATUS_SEND_CANCELED);
+ MessageUtil.setAndSaveMessageStatus(entity.getMessage(), MessageStatus.CANCELED);
}
@Override
public void onSuccess(FileTransferEntity entity) {
this.activeTransfers.remove(entity.getMessage().getUuid());
+ MessageUtil.setAndSaveMessageStatus(entity.getMessage(), MessageStatus.TRANSMITTED);
}
private boolean startFileTransfer(Message message, boolean delayed, WeightedTransferService wts) {
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/AutomaticFileDownload.java b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/AutomaticFileDownload.java
index 5885e2e1..4401fb06 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/AutomaticFileDownload.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/AutomaticFileDownload.java
@@ -12,20 +12,12 @@ import de.thedevstack.conversationsplus.utils.XmppConnectionServiceAccessor;
*
*/
public class AutomaticFileDownload implements HttpHeadRetrievedListener {
- private boolean notify;
-
- public AutomaticFileDownload(boolean notify) {
- this.notify = notify;
- }
@Override
public void onFileSizeRetrieved(long size, Message message) {
if (!this.transferFile(message)) {
}
- if (this.notify) {
- XmppConnectionServiceAccessor.xmppConnectionService.getNotificationService().push(message);
- }
}
/**
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/HttpRetrieveHead.java b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/HttpRetrieveHead.java
index 1313bcca..62c1af59 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/HttpRetrieveHead.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/HttpRetrieveHead.java
@@ -10,6 +10,7 @@ import de.thedevstack.conversationsplus.http.Http;
import de.thedevstack.conversationsplus.http.HttpClient;
import de.thedevstack.conversationsplus.http.HttpHeadRetrievedListener;
import de.thedevstack.conversationsplus.persistance.DatabaseBackend;
+import de.thedevstack.conversationsplus.utils.MessageParserUtil;
import de.thedevstack.conversationsplus.utils.MessageUtil;
import de.thedevstack.conversationsplus.utils.UiUpdateHelper;
import okhttp3.Call;
@@ -36,12 +37,11 @@ public class HttpRetrieveHead implements Http, Callback {
* If this code is reached and the URL is null something went wrong.
* Try again to extract the file parameters from the message.
*/
- MessageUtil.extractFileParamsFromBody(message);
+ MessageParserUtil.extractFileParamsFromBody(message);
this.url = (null != message.getFileParams()) ? message.getFileParams().getUrl() : null;
if (null == this.url) {
- message.setTreatAsDownloadable(Message.Decision.NEVER); // TODO find sth better
if (null != message.getFileParams()) {
- MessageUtil.setAndSaveFileStatus(message, FileStatus.UNDEFINED);
+ MessageUtil.setAndSaveFileStatus(message, FileStatus.NOT_FOUND);
}
}
}
@@ -89,7 +89,7 @@ public class HttpRetrieveHead implements Http, Callback {
fileParams.setSize(size);
fileParams.setMimeType(contentType);
if (0 < size) {
- fileParams.setFileStatus(FileStatus.NEEDS_DOWNLOAD);
+ MessageUtil.setFileStatus(message, FileStatus.NEEDS_DOWNLOAD);
}
DatabaseBackend.getInstance().updateMessage(message);
UiUpdateHelper.updateConversationUi();
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/upload/HttpUploadFileTransferEntity.java b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/upload/HttpUploadFileTransferEntity.java
index 54186983..19c965e2 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/upload/HttpUploadFileTransferEntity.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/upload/HttpUploadFileTransferEntity.java
@@ -32,7 +32,7 @@ public class HttpUploadFileTransferEntity extends FileTransferEntity {
fileParams = new FileParams();
this.getMessage().setFileParams(fileParams);
}
- fileParams.setFileStatus(FileStatus.NEEDS_UPLOAD);
+ MessageUtil.setFileStatus(this.getMessage(), FileStatus.NEEDS_DOWNLOAD);
if (Config.ENCRYPT_ON_HTTP_UPLOADED
|| message.getEncryption() == Message.ENCRYPTION_AXOLOTL
|| message.getEncryption() == Message.ENCRYPTION_OTR) {
@@ -96,7 +96,7 @@ public class HttpUploadFileTransferEntity extends FileTransferEntity {
getUrl = new URL(getUrl.toString() + "#" + CryptoHelper.bytesToHex(this.getKey()));
}
- this.getMessage().getFileParams().setFileStatus(FileStatus.UPLOADED);
+ MessageUtil.setFileStatus(getMessage(), FileStatus.UPLOADED);
MessageUtil.updateFileParams(this.getMessage(), getUrl);
} catch (MalformedURLException e) {
Logging.e("httpupload", "Not a valid get url");
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/upload/HttpUploadFileTransferService.java b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/upload/HttpUploadFileTransferService.java
index 28bb3a1c..b901ae4b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/upload/HttpUploadFileTransferService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/upload/HttpUploadFileTransferService.java
@@ -9,6 +9,7 @@ import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.entities.Account;
import de.thedevstack.conversationsplus.entities.DownloadableFile;
import de.thedevstack.conversationsplus.entities.Message;
+import de.thedevstack.conversationsplus.enums.MessageStatus;
import de.thedevstack.conversationsplus.services.AbstractConnectionManager;
import de.thedevstack.conversationsplus.services.FileTransferService;
import de.thedevstack.conversationsplus.services.filetransfer.AbstractFileTransferService;
@@ -62,7 +63,7 @@ public class HttpUploadFileTransferService extends AbstractFileTransferService i
Logging.d("httpupload", "Requesting upload slot for file upload");
IqPacket request = HttpUploadRequestSlotPacketGenerator.generate(account, message.getContact().getJid(), file.getName(), file.getSize(), file.getMimeType());
XmppSendUtil.sendIqPacket(account, request, new HttpUploadSlotRequestReceived(entity));
- MessageUtil.markMessage(message, Message.STATUS_UNSEND);
+ MessageUtil.setAndSaveMessageStatus(message, MessageStatus.TRANSMITTING);
Logging.d("httpupload", "Upload slot for file upload requested");
started = true;
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/mam/MessageArchiveService.java b/src/main/java/de/thedevstack/conversationsplus/services/mam/MessageArchiveService.java
index 6ad413b4..34620808 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/mam/MessageArchiveService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/mam/MessageArchiveService.java
@@ -15,6 +15,7 @@ import de.thedevstack.conversationsplus.R;
import de.thedevstack.conversationsplus.entities.Account;
import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.generator.AbstractGenerator;
+import de.thedevstack.conversationsplus.persistance.DatabaseBackend;
import de.thedevstack.conversationsplus.services.XmppConnectionService;
import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.OnAdvancedStreamFeaturesLoaded;
@@ -47,7 +48,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
}
}
}
- Pair<Long,String> pair = mXmppConnectionService.databaseBackend.getLastMessageReceived(account);
+ Pair<Long,String> pair = DatabaseBackend.getInstance().getLastMessageReceived(account);
long startCatchup = pair == null ? 0 : pair.first;
long endCatchup = account.getXmppConnection().getLastSessionEstablished();
final Query query;
@@ -168,14 +169,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
}
final Conversation conversation = query.getConversation();
if (conversation != null) {
- conversation.sort();
conversation.setHasMessagesLeftOnServer(!done);
- } else {
- for(Conversation tmp : this.mXmppConnectionService.getConversations()) {
- if (tmp.getAccount() == query.getAccount()) {
- tmp.sort();
- }
- }
}
if (query.hasCallback()) {
query.callback();