sort file transfers into correct conversation

This commit is contained in:
bobufa 2018-08-13 15:50:50 +02:00
parent 2992a12f9f
commit 1d9ce7f471
4 changed files with 15 additions and 12 deletions

View file

@ -126,10 +126,9 @@ public class ContentItemStore : StreamInteractionModule, Object {
} }
} }
private void insert_file_transfer(FileTransfer file_transfer) { private void insert_file_transfer(FileTransfer file_transfer, Conversation conversation) {
FileItem item = new FileItem(file_transfer, -1); FileItem item = new FileItem(file_transfer, -1);
if (!discard(item)) { if (!discard(item)) {
Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(file_transfer.counterpart, file_transfer.account);
item.id = db.add_content_item(conversation, file_transfer.time, file_transfer.local_time, 2, file_transfer.id); item.id = db.add_content_item(conversation, file_transfer.time, file_transfer.local_time, 2, file_transfer.id);
if (collection_conversations.has_key(conversation)) { if (collection_conversations.has_key(conversation)) {

View file

@ -239,11 +239,15 @@ public class Database : Qlite.Database {
message.body not in (select info from file_transfer where info not null) and message.body not in (select info from file_transfer where info not null) and
message.id not in (select info from file_transfer where info not null) message.id not in (select info from file_transfer where info not null)
union union
select conversation.id, file_transfer.time, file_transfer.local_time, 2, file_transfer.id select conversation.id, message.time, message.local_time, 2, file_transfer.id
from file_transfer join conversation on from file_transfer
join message on
file_transfer.info=message.id
join conversation on
file_transfer.account_id=conversation.account_id and file_transfer.account_id=conversation.account_id and
file_transfer.counterpart_id=conversation.jid_id file_transfer.counterpart_id=conversation.jid_id and
order by message.local_time, message.time"""); message.type=conversation.type+1 and
(message.counterpart_resource=conversation.resource or message.type != 3)""");
} }
} }

View file

@ -11,7 +11,7 @@ public class FileManager : StreamInteractionModule, Object {
public string id { get { return IDENTITY.id; } } public string id { get { return IDENTITY.id; } }
public signal void upload_available(Account account); public signal void upload_available(Account account);
public signal void received_file(FileTransfer file_transfer); public signal void received_file(FileTransfer file_transfer, Conversation conversation);
private StreamInteractor stream_interactor; private StreamInteractor stream_interactor;
private Database db; private Database db;
@ -68,7 +68,7 @@ public class FileManager : StreamInteractionModule, Object {
file_sender.send_file(conversation, file_transfer); file_sender.send_file(conversation, file_transfer);
} }
} }
received_file(file_transfer); received_file(file_transfer, conversation);
} }
public bool is_upload_available(Conversation conversation) { public bool is_upload_available(Conversation conversation) {
@ -134,7 +134,7 @@ public class FileManager : StreamInteractionModule, Object {
outgoing_processors.add(processor); outgoing_processors.add(processor);
} }
private void handle_incomming_file(FileTransfer file_transfer) { private void handle_incomming_file(FileTransfer file_transfer, Conversation conversation) {
foreach (IncommingFileProcessor processor in incomming_processors) { foreach (IncommingFileProcessor processor in incomming_processors) {
if (processor.can_process(file_transfer)) { if (processor.can_process(file_transfer)) {
processor.process(file_transfer); processor.process(file_transfer);
@ -148,7 +148,7 @@ public class FileManager : StreamInteractionModule, Object {
} catch (Error e) { } } catch (Error e) { }
file_transfer.persist(db); file_transfer.persist(db);
received_file(file_transfer); received_file(file_transfer, conversation);
} }
private void save_file(FileTransfer file_transfer) { private void save_file(FileTransfer file_transfer) {
@ -169,7 +169,7 @@ public class FileManager : StreamInteractionModule, Object {
} }
public interface FileProvider : Object { public interface FileProvider : Object {
public signal void file_incoming(FileTransfer file_transfer); public signal void file_incoming(FileTransfer file_transfer, Conversation conversation);
} }
public interface FileSender : Object { public interface FileSender : Object {

View file

@ -90,7 +90,7 @@ public class FileProvider : Dino.FileProvider, Object {
file_transfer.state = FileTransfer.State.NOT_STARTED; file_transfer.state = FileTransfer.State.NOT_STARTED;
file_transfer.provider = 0; file_transfer.provider = 0;
file_transfer.info = message.id.to_string(); file_transfer.info = message.id.to_string();
file_incoming(file_transfer); file_incoming(file_transfer, conversation);
success = true; success = true;
Idle.add((owned)callback); Idle.add((owned)callback);
}); });