diff options
Diffstat (limited to 'libdino/src/plugin')
-rw-r--r-- | libdino/src/plugin/interfaces.vala | 37 | ||||
-rw-r--r-- | libdino/src/plugin/registry.vala | 22 |
2 files changed, 59 insertions, 0 deletions
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<AccountSettingsEntry> account_settings_entries = new ArrayList<AccountSettingsEntry>(); internal ArrayList<ContactDetailsProvider> contact_details_entries = new ArrayList<ContactDetailsProvider>(); internal Map<string, TextCommand> text_commands = new HashMap<string, TextCommand>(); + internal Gee.List<MessageDisplayProvider> message_displays = new ArrayList<MessageDisplayProvider>(); + internal Gee.List<ConversationItemPopulator> conversation_item_populators = new ArrayList<ConversationItemPopulator>(); internal Gee.Collection<ConversationTitlebarEntry> conversation_titlebar_entries = new Gee.TreeSet<ConversationTitlebarEntry>((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; + } + } } } |