diff options
Diffstat (limited to 'plugins/http-files')
-rw-r--r-- | plugins/http-files/src/file_provider.vala | 12 | ||||
-rw-r--r-- | plugins/http-files/src/manager.vala | 28 | ||||
-rw-r--r-- | plugins/http-files/src/plugin.vala | 2 |
3 files changed, 25 insertions, 17 deletions
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala index b647cdbb..6f4b19f4 100644 --- a/plugins/http-files/src/file_provider.vala +++ b/plugins/http-files/src/file_provider.vala @@ -26,8 +26,8 @@ public class FileProvider : Dino.FileProvider, Object { private class ReceivedMessageListener : MessageListener { - public string[] after_actions_const = new string[]{ }; - public override string action_group { get { return "DECRYPT"; } } + public string[] after_actions_const = new string[]{ "STORE" }; + public override string action_group { get { return ""; } } public override string[] after_actions { get { return after_actions_const; } } private FileProvider outer; @@ -90,7 +90,13 @@ public class FileProvider : Dino.FileProvider, Object { file_transfer.state = FileTransfer.State.NOT_STARTED; file_transfer.provider = 0; file_transfer.info = message.id.to_string(); - file_incoming(file_transfer); + file_incoming(file_transfer, conversation); + + ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item(conversation, 1, message.id); + if (content_item != null) { + stream_interactor.get_module(ContentItemStore.IDENTITY).set_item_hide(content_item, true); + } + success = true; Idle.add((owned)callback); }); diff --git a/plugins/http-files/src/manager.vala b/plugins/http-files/src/manager.vala index 7335b89a..78697f9c 100644 --- a/plugins/http-files/src/manager.vala +++ b/plugins/http-files/src/manager.vala @@ -40,6 +40,11 @@ public class Manager : StreamInteractionModule, FileSender, Object { message.encryption = Encryption.NONE; stream_interactor.get_module(MessageProcessor.IDENTITY).send_message(message, conversation); file_transfer.info = message.id.to_string(); + + ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item(conversation, 1, message.id); + if (content_item != null) { + stream_interactor.get_module(ContentItemStore.IDENTITY).set_item_hide(content_item, true); + } }, (stream, error_str) => { print(@"Failed getting upload url + $error_str\n"); @@ -81,28 +86,25 @@ public class Manager : StreamInteractionModule, FileSender, Object { } } -public class FileMessageFilterDisplay : Plugins.MessageDisplayProvider, Object { - public string id { get; set; default="file_message_filter"; } - public double priority { get; set; default=10; } - +public class FileMessageFilter : ContentFilter, Object { public Database db; - public FileMessageFilterDisplay(Dino.Database db) { + public FileMessageFilter(Dino.Database db) { this.db = db; } - public bool can_display(Entities.Message? message) { - return message_is_file(db, message); - } - - public Plugins.MetaConversationItem? get_item(Entities.Message message, Conversation conversation) { - return null; + public bool discard(ContentItem content_item) { + if (content_item.type_ == MessageItem.TYPE) { + MessageItem message_item = content_item as MessageItem; + return message_is_file(db, message_item.message); + } + return false; } } private bool message_is_file(Database db, Entities.Message message) { - Qlite.QueryBuilder builder = db.file_transfer.select().with(db.file_transfer.info, "=", message.id.to_string()); - Qlite.QueryBuilder builder2 = db.file_transfer.select().with(db.file_transfer.info, "=", message.body); + Qlite.QueryBuilder builder = db.file_transfer.select({db.file_transfer.id}).with(db.file_transfer.info, "=", message.id.to_string()); + Qlite.QueryBuilder builder2 = db.file_transfer.select({db.file_transfer.id}).with(db.file_transfer.info, "=", message.body); return builder.count() > 0 || builder2.count() > 0; } diff --git a/plugins/http-files/src/plugin.vala b/plugins/http-files/src/plugin.vala index 1fc0c9fd..bd136f31 100644 --- a/plugins/http-files/src/plugin.vala +++ b/plugins/http-files/src/plugin.vala @@ -19,7 +19,7 @@ public class Plugin : RootInterface, Object { }); app.stream_interactor.get_module(FileManager.IDENTITY).add_provider(file_provider); - app.plugin_registry.register_message_display(new FileMessageFilterDisplay(app.db)); + app.stream_interactor.get_module(ContentItemStore.IDENTITY).add_filter(new FileMessageFilter(app.db)); } public void shutdown() { |