diff options
author | fiaxh <git@lightrise.org> | 2022-02-14 14:55:59 +0100 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2022-07-27 20:34:20 +0200 |
commit | 7e7dcedaf31ee35499875491c9f569c575d28435 (patch) | |
tree | 0c5fee2b28baf320775fbc92b3c252e97d9d054f /libdino | |
parent | f25bfb00969a7e09996da2d5500e6718f4cc0148 (diff) | |
download | dino-7e7dcedaf31ee35499875491c9f569c575d28435.tar.gz dino-7e7dcedaf31ee35499875491c9f569c575d28435.zip |
Port from GTK3 to GTK4
Diffstat (limited to 'libdino')
-rw-r--r-- | libdino/src/entity/encryption.vala | 10 | ||||
-rw-r--r-- | libdino/src/plugin/interfaces.vala | 25 | ||||
-rw-r--r-- | libdino/src/service/content_item_store.vala | 89 | ||||
-rw-r--r-- | libdino/src/service/counterpart_interaction_manager.vala | 2 | ||||
-rw-r--r-- | libdino/src/service/message_correction.vala | 2 |
5 files changed, 81 insertions, 47 deletions
diff --git a/libdino/src/entity/encryption.vala b/libdino/src/entity/encryption.vala index 193d741b..ab5a0ae0 100644 --- a/libdino/src/entity/encryption.vala +++ b/libdino/src/entity/encryption.vala @@ -1,12 +1,16 @@ namespace Dino.Entities { -public enum Encryption { + public enum Encryption { NONE, PGP, OMEMO, DTLS_SRTP, SRTP, - UNKNOWN, -} + UNKNOWN; + + public bool is_some() { + return this != NONE; + } + } }
\ No newline at end of file diff --git a/libdino/src/plugin/interfaces.vala b/libdino/src/plugin/interfaces.vala index c7c2c375..e4710732 100644 --- a/libdino/src/plugin/interfaces.vala +++ b/libdino/src/plugin/interfaces.vala @@ -12,7 +12,8 @@ public enum Priority { } public enum WidgetType { - GTK + GTK3, + GTK4 } public interface RootInterface : Object { @@ -27,6 +28,8 @@ public interface EncryptionListEntry : Object { public abstract void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus callback); public abstract Object? get_encryption_icon(Entities.Conversation conversation, ContentItem content_item); + public abstract string? get_encryption_icon_name(Entities.Conversation conversation, ContentItem content_item); + } public interface CallEncryptionEntry : Object { @@ -45,15 +48,11 @@ public abstract class AccountSettingsEntry : Object { public abstract string name { get; } public virtual int16 label_top_padding { get { return -1; } } - public abstract AccountSettingsWidget? get_widget(WidgetType type); -} - -public interface AccountSettingsWidget : Object { - public abstract void set_account(Account account); - public abstract signal void activated(); - public abstract void deactivate(); + + public abstract void set_account(Account account); + public abstract Object? get_widget(WidgetType type); } public interface ContactDetailsProvider : Object { @@ -76,10 +75,8 @@ public interface TextCommand : Object { public interface ConversationTitlebarEntry : Object { public abstract string id { get; } public abstract double order { get; } - public abstract ConversationTitlebarWidget? get_widget(WidgetType type); -} + public abstract Object? get_widget(WidgetType type); -public interface ConversationTitlebarWidget : Object { public abstract void set_conversation(Conversation conversation); public abstract void unset_conversation(); } @@ -146,10 +143,14 @@ public abstract class MetaConversationItem : Object { public bool requires_header { get; set; default=false; } public bool in_edit_mode { get; set; default=false; } - public abstract Object? get_widget(WidgetType type); + public abstract Object? get_widget(ConversationItemWidgetInterface outer, WidgetType type); public abstract Gee.List<MessageAction>? get_item_actions(WidgetType type); } +public interface ConversationItemWidgetInterface: Object { + public abstract void set_widget(Object object, WidgetType type); +} + public delegate void MessageActionEvoked(Object button, Plugins.MetaConversationItem evoked_on, Object widget); public class MessageAction : Object { public string icon_name; diff --git a/libdino/src/service/content_item_store.vala b/libdino/src/service/content_item_store.vala index c6c47af4..6371e00b 100644 --- a/libdino/src/service/content_item_store.vala +++ b/libdino/src/service/content_item_store.vala @@ -44,37 +44,11 @@ public class ContentItemStore : StreamInteractionModule, Object { Gee.TreeSet<ContentItem> items = new Gee.TreeSet<ContentItem>(ContentItem.compare_func); foreach (var row in select) { - int provider = row[db.content_item.content_type]; + int id = row[db.content_item.id]; + int content_type = row[db.content_item.content_type]; int foreign_id = row[db.content_item.foreign_id]; DateTime time = new DateTime.from_unix_utc(row[db.content_item.time]); - switch (provider) { - case 1: - Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(foreign_id, conversation); - if (message != null) { - var message_item = new MessageItem(message, conversation, row[db.content_item.id]); - message_item.time = time; // In case of message corrections, the original time should be used - items.add(message_item); - } - break; - case 2: - FileTransfer? file_transfer = stream_interactor.get_module(FileTransferStorage.IDENTITY).get_file_by_id(foreign_id, conversation); - if (file_transfer != null) { - Message? message = null; - if (file_transfer.provider == 0 && file_transfer.info != null) { - message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(int.parse(file_transfer.info), conversation); - } - var file_item = new FileItem(file_transfer, conversation, row[db.content_item.id], message); - items.add(file_item); - } - break; - case 3: - Call? call = stream_interactor.get_module(CallStore.IDENTITY).get_call_by_id(foreign_id, conversation); - if (call != null) { - var call_item = new CallItem(call, conversation, row[db.content_item.id]); - items.add(call_item); - } - break; - } + items.add(get_item(conversation, id, content_type, foreign_id, time)); } Gee.List<ContentItem> ret = new ArrayList<ContentItem>(); @@ -84,7 +58,42 @@ public class ContentItemStore : StreamInteractionModule, Object { return ret; } - public ContentItem? get_item(Conversation conversation, int type, int foreign_id) { + public ContentItem get_item(Conversation conversation, int id, int content_type, int foreign_id, DateTime time) throws Error { + switch (content_type) { + case 1: + Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(foreign_id, conversation); + if (message != null) { + var message_item = new MessageItem(message, conversation, id); + message_item.time = time; // In case of message corrections, the original time should be used + return message_item; + } + break; + case 2: + FileTransfer? file_transfer = stream_interactor.get_module(FileTransferStorage.IDENTITY).get_file_by_id(foreign_id, conversation); + if (file_transfer != null) { + Message? message = null; + if (file_transfer.provider == 0 && file_transfer.info != null) { + message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(int.parse(file_transfer.info), conversation); + } + var file_item = new FileItem(file_transfer, conversation, id, message); + return file_item; + } + break; + case 3: + Call? call = stream_interactor.get_module(CallStore.IDENTITY).get_call_by_id(foreign_id, conversation); + if (call != null) { + var call_item = new CallItem(call, conversation, id); + return call_item; + } + break; + default: + warning("Unknown content item type: %i", content_type); + break; + } + throw new Error(-1, 0, "Bad content type %i or non existing content item %i", content_type, foreign_id); + } + + public ContentItem? get_item_by_foreign(Conversation conversation, int type, int foreign_id) { QueryBuilder select = db.content_item.select() .with(db.content_item.content_type, "=", type) .with(db.content_item.foreign_id, "=", foreign_id); @@ -122,6 +131,26 @@ public class ContentItemStore : StreamInteractionModule, Object { return get_items_from_query(select, conversation); } +// public Gee.List<ContentItemMeta> get_latest_meta(Conversation conversation, int count) { +// QueryBuilder select = db.content_item.select() +// .with(db.content_item.conversation_id, "=", conversation.id) +// .with(db.content_item.hide, "=", false) +// .order_by(db.content_item.time, "DESC") +// .order_by(db.content_item.id, "DESC") +// .limit(count); +// +// var ret = new ArrayList<ContentItemMeta>(); +// foreach (var row in select) { +// var item_meta = new ContentItemMeta() { +// id = row[db.content_item.id], +// content_type = row[db.content_item.content_type], +// foreign_id = row[db.content_item.foreign_id], +// time = new DateTime.from_unix_utc(row[db.content_item.time]) +// }; +// } +// return ret; +// } + public Gee.List<ContentItem> get_before(Conversation conversation, ContentItem item, int count) { long time = (long) item.time.to_unix(); QueryBuilder select = db.content_item.select() diff --git a/libdino/src/service/counterpart_interaction_manager.vala b/libdino/src/service/counterpart_interaction_manager.vala index cc5489c3..23db5762 100644 --- a/libdino/src/service/counterpart_interaction_manager.vala +++ b/libdino/src/service/counterpart_interaction_manager.vala @@ -154,7 +154,7 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object { conversation.read_up_to = message; // TODO: This only marks messages as read, not http file transfers. - ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item(conversation, 1, message.id); + ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item_by_foreign(conversation, 1, message.id); if (content_item == null) return; ContentItem? read_up_to_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item_by_id(conversation, conversation.read_up_to_item); if (read_up_to_item != null && read_up_to_item.compare(content_item) > 0) return; diff --git a/libdino/src/service/message_correction.vala b/libdino/src/service/message_correction.vala index 322fa1c1..d5d15578 100644 --- a/libdino/src/service/message_correction.vala +++ b/libdino/src/service/message_correction.vala @@ -144,7 +144,7 @@ public class MessageCorrection : StreamInteractionModule, MessageListener { } private void on_received_correction(Conversation conversation, int message_id) { - ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item(conversation, 1, message_id); + ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item_by_foreign(conversation, 1, message_id); if (content_item != null) { received_correction(content_item); } |