From 3ea00446fb5893804243f5b1a1aa89817b7bc19a Mon Sep 17 00:00:00 2001 From: bobufa Date: Tue, 19 Jun 2018 18:07:00 +0200 Subject: refactor conversation item management (accumulate them in libdino) --- plugins/http-files/src/manager.vala | 19 ++++++++----------- plugins/http-files/src/plugin.vala | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'plugins/http-files') diff --git a/plugins/http-files/src/manager.vala b/plugins/http-files/src/manager.vala index 7335b89a..78c244e3 100644 --- a/plugins/http-files/src/manager.vala +++ b/plugins/http-files/src/manager.vala @@ -81,22 +81,19 @@ 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; } } diff --git a/plugins/http-files/src/plugin.vala b/plugins/http-files/src/plugin.vala index 1fc0c9fd..c57ee3dc 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(ContentItemAccumulator.IDENTITY).add_filter(new FileMessageFilter(app.db)); } public void shutdown() { -- cgit v1.2.3-70-g09d2