From 8bc0d107e740be468ee0c9dcd253de36355088d3 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 27 Aug 2017 23:55:49 +0200 Subject: Plugins providing conversation items for ConversationView --- libdino/CMakeLists.txt | 2 +- libdino/src/plugin/interfaces.vala | 37 ++++ libdino/src/plugin/registry.vala | 22 +++ libdino/src/service/database.vala | 4 +- libdino/src/service/message_storage.vala | 2 +- main/CMakeLists.txt | 12 +- main/data/conversation_summary/message_item.ui | 9 +- main/data/conversation_summary/view.ui | 2 +- .../conversation_summary/chat_state_populator.vala | 116 +++++++++++ .../ui/conversation_summary/conversation_item.vala | 32 --- .../conversation_item_skeleton.vala | 142 ++++++++++++++ .../ui/conversation_summary/conversation_view.vala | 173 +++++++++++++++++ .../default_message_display.vala | 53 +++++ .../conversation_summary/merged_message_item.vala | 59 ------ main/src/ui/conversation_summary/message_item.vala | 122 ------------ .../ui/conversation_summary/message_populator.vala | 66 +++++++ .../ui/conversation_summary/message_textview.vala | 8 +- main/src/ui/conversation_summary/slashme_item.vala | 44 ----- .../slashme_message_display.vala | 75 +++++++ main/src/ui/conversation_summary/status_item.vala | 30 --- main/src/ui/conversation_summary/view.vala | 216 --------------------- main/src/ui/unified_window.vala | 4 +- main/src/ui/util/helper.vala | 4 +- xmpp-vala/src/module/xep/0054_vcard/module.vala | 2 +- .../src/module/xep/0198_stream_management.vala | 2 +- 25 files changed, 713 insertions(+), 525 deletions(-) create mode 100644 main/src/ui/conversation_summary/chat_state_populator.vala delete mode 100644 main/src/ui/conversation_summary/conversation_item.vala create mode 100644 main/src/ui/conversation_summary/conversation_item_skeleton.vala create mode 100644 main/src/ui/conversation_summary/conversation_view.vala create mode 100644 main/src/ui/conversation_summary/default_message_display.vala delete mode 100644 main/src/ui/conversation_summary/merged_message_item.vala delete mode 100644 main/src/ui/conversation_summary/message_item.vala create mode 100644 main/src/ui/conversation_summary/message_populator.vala delete mode 100644 main/src/ui/conversation_summary/slashme_item.vala create mode 100644 main/src/ui/conversation_summary/slashme_message_display.vala delete mode 100644 main/src/ui/conversation_summary/status_item.vala delete mode 100644 main/src/ui/conversation_summary/view.vala diff --git a/libdino/CMakeLists.txt b/libdino/CMakeLists.txt index 68ac8e5b..22dab2d8 100644 --- a/libdino/CMakeLists.txt +++ b/libdino/CMakeLists.txt @@ -16,8 +16,8 @@ SOURCES src/dbus/upower.vala src/entity/account.vala - src/entity/encryption.vala src/entity/conversation.vala + src/entity/encryption.vala src/entity/jid.vala src/entity/message.vala src/entity/settings.vala diff --git a/libdino/src/plugin/interfaces.vala b/libdino/src/plugin/interfaces.vala index 729f7b26..5ffd491f 100644 --- a/libdino/src/plugin/interfaces.vala +++ b/libdino/src/plugin/interfaces.vala @@ -71,4 +71,41 @@ public interface ConversationTitlebarWidget : Object { public abstract void set_conversation(Conversation conversation); } +public abstract interface ConversationItemPopulator : Object { + public abstract string id { get; } + public abstract void init(Conversation conversation, ConversationItemCollection summary, WidgetType type); + public virtual void populate_timespan(Conversation conversation, DateTime from, DateTime to) { } + public virtual void populate_between_widgets(Conversation conversation, DateTime from, DateTime to) { } + public abstract void close(Conversation conversation); +} + +public abstract class MetaConversationItem : Object { + public virtual Jid? jid { get; set; default=null; } + public virtual string color { get; set; default=null; } + public virtual string display_name { get; set; default=null; } + public virtual bool dim { get; set; default=false; } + public virtual DateTime? sort_time { get; set; default=null; } + public virtual DateTime? display_time { get; set; default=null; } + public virtual Encryption? encryption { get; set; default=null; } + public virtual Entities.Message.Marked? mark { get; set; default=null; } + + public abstract bool can_merge { get; set; } + public abstract bool requires_avatar { get; set; } + public abstract bool requires_header { get; set; } + + public abstract Object get_widget(WidgetType type); +} + +public interface ConversationItemCollection : Object { + public abstract void insert_item(MetaConversationItem item); + public abstract void remove_item(MetaConversationItem item); +} + +public interface MessageDisplayProvider : Object { + public abstract string id { get; set; } + public abstract double priority { get; set; } + public abstract bool can_display(Entities.Message? message); + public abstract MetaConversationItem? get_item(Entities.Message message, Entities.Conversation conversation); +} + } diff --git a/libdino/src/plugin/registry.vala b/libdino/src/plugin/registry.vala index 6284269b..7b4410aa 100644 --- a/libdino/src/plugin/registry.vala +++ b/libdino/src/plugin/registry.vala @@ -7,6 +7,8 @@ public class Registry { internal ArrayList account_settings_entries = new ArrayList(); internal ArrayList contact_details_entries = new ArrayList(); internal Map text_commands = new HashMap(); + internal Gee.List message_displays = new ArrayList(); + internal Gee.List conversation_item_populators = new ArrayList(); internal Gee.Collection conversation_titlebar_entries = new Gee.TreeSet((a, b) => { if (a.order < b.order) { return -1; @@ -67,6 +69,26 @@ public class Registry { return true; } } + + public bool register_message_display(MessageDisplayProvider provider) { + lock (message_displays) { + foreach(MessageDisplayProvider p in message_displays) { + if (p.id == provider.id) return false; + } + message_displays.add(provider); + return true; + } + } + + public bool register_conversation_item_populator(ConversationItemPopulator populator) { + lock (conversation_item_populators) { + foreach(ConversationItemPopulator p in conversation_item_populators) { + if (p.id == populator.id) return false; + } + conversation_item_populators.add(populator); + return true; + } + } } } diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala index 91a62cce..51d16e59 100644 --- a/libdino/src/service/database.vala +++ b/libdino/src/service/database.vala @@ -201,7 +201,7 @@ public class Database : Qlite.Database { } } - public Gee.List get_messages(Jid jid, Account account, Message.Type? type, int count, Message? before) { + public Gee.List get_messages(Jid jid, Account account, Message.Type? type, int count, DateTime? before) { QueryBuilder select = message.select() .with(message.counterpart_id, "=", get_jid_id(jid)) .with(message.account_id, "=", account.id) @@ -214,7 +214,7 @@ public class Database : Qlite.Database { select.with(message.type_, "=", (int) type); } if (before != null) { - select.with(message.time, "<", (long) before.time.to_unix()); + select.with(message.time, "<", (long) before.to_unix()); } LinkedList ret = new LinkedList(); diff --git a/libdino/src/service/message_storage.vala b/libdino/src/service/message_storage.vala index 1cde1a95..76a8e60d 100644 --- a/libdino/src/service/message_storage.vala +++ b/libdino/src/service/message_storage.vala @@ -47,7 +47,7 @@ public class MessageStorage : StreamInteractionModule, Object { return null; } - public Gee.List? get_messages_before(Conversation? conversation, Message before, int count = 20) { + public Gee.List? get_messages_before(Conversation? conversation, DateTime before, int count = 20) { Gee.List db_messages = db.get_messages(conversation.counterpart, conversation.account, Util.get_message_type_for_conversation(conversation), count, before); return db_messages; } diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 83c7a6d5..cebd6d4c 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -96,13 +96,13 @@ SOURCES src/ui/conversation_selector/groupchat_row.vala src/ui/conversation_selector/list.vala src/ui/conversation_selector/view.vala - src/ui/conversation_summary/conversation_item.vala - src/ui/conversation_summary/merged_message_item.vala - src/ui/conversation_summary/message_item.vala + src/ui/conversation_summary/chat_state_populator.vala + src/ui/conversation_summary/conversation_item_skeleton.vala + src/ui/conversation_summary/conversation_view.vala + src/ui/conversation_summary/default_message_display.vala + src/ui/conversation_summary/message_populator.vala src/ui/conversation_summary/message_textview.vala - src/ui/conversation_summary/slashme_item.vala - src/ui/conversation_summary/status_item.vala - src/ui/conversation_summary/view.vala + src/ui/conversation_summary/slashme_message_display.vala src/ui/conversation_titlebar/encryption_entry.vala src/ui/conversation_titlebar/menu_entry.vala src/ui/conversation_titlebar/occupants_entry.vala diff --git a/main/data/conversation_summary/message_item.ui b/main/data/conversation_summary/message_item.ui index e7b4f46f..8d53a691 100644 --- a/main/data/conversation_summary/message_item.ui +++ b/main/data/conversation_summary/message_item.ui @@ -1,6 +1,6 @@ -