aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/content_item_store.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-05-11 12:57:02 +0200
committerfiaxh <git@lightrise.org>2021-05-11 12:57:02 +0200
commitd71604913dd5b3372a823320db83c37c845fac5c (patch)
tree2ffbff97a02c81d48d8aef4a4b7ee870507236e9 /libdino/src/service/content_item_store.vala
parente92ed27317ae398c867c946cf7206b1f0b32f3b4 (diff)
parent90f9ecf62b2ebfef14de2874e7942552409632bf (diff)
downloaddino-d71604913dd5b3372a823320db83c37c845fac5c.tar.gz
dino-d71604913dd5b3372a823320db83c37c845fac5c.zip
Merge remote-tracking branch 'origin/feature/calls'
Diffstat (limited to 'libdino/src/service/content_item_store.vala')
-rw-r--r--libdino/src/service/content_item_store.vala35
1 files changed, 34 insertions, 1 deletions
diff --git a/libdino/src/service/content_item_store.vala b/libdino/src/service/content_item_store.vala
index 632918f2..60b05a8b 100644
--- a/libdino/src/service/content_item_store.vala
+++ b/libdino/src/service/content_item_store.vala
@@ -29,6 +29,8 @@ public class ContentItemStore : StreamInteractionModule, Object {
stream_interactor.get_module(FileManager.IDENTITY).received_file.connect(insert_file_transfer);
stream_interactor.get_module(MessageProcessor.IDENTITY).message_received.connect(announce_message);
stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect(announce_message);
+ stream_interactor.get_module(Calls.IDENTITY).call_incoming.connect(insert_call);
+ stream_interactor.get_module(Calls.IDENTITY).call_outgoing.connect(insert_call);
}
public void init(Conversation conversation, ContentItemCollection item_collection) {
@@ -51,7 +53,6 @@ public class ContentItemStore : StreamInteractionModule, Object {
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;
items.add(message_item);
}
break;
@@ -66,6 +67,13 @@ public class ContentItemStore : StreamInteractionModule, Object {
items.add(file_item);
}
break;
+ case 3:
+ Call? call = stream_interactor.get_module(CallStore.IDENTITY).get_call_by_id(foreign_id);
+ if (call != null) {
+ var call_item = new CallItem(call, conversation, row[db.content_item.id]);
+ items.add(call_item);
+ }
+ break;
}
}
@@ -177,6 +185,15 @@ public class ContentItemStore : StreamInteractionModule, Object {
}
}
+ private void insert_call(Call call, Conversation conversation) {
+ CallItem item = new CallItem(call, conversation, -1);
+ item.id = db.add_content_item(conversation, call.time, call.local_time, 3, call.id, false);
+ if (collection_conversations.has_key(conversation)) {
+ collection_conversations.get(conversation).insert_item(item);
+ }
+ new_item(item, conversation);
+ }
+
public bool get_item_hide(ContentItem content_item) {
return db.content_item.row_with(db.content_item.id, content_item.id)[db.content_item.hide, false];
}
@@ -296,4 +313,20 @@ public class FileItem : ContentItem {
}
}
+public class CallItem : ContentItem {
+ public const string TYPE = "call";
+
+ public Call call;
+ public Conversation conversation;
+
+ public CallItem(Call call, Conversation conversation, int id) {
+ base(id, TYPE, call.from, call.time, call.encryption, Message.Marked.NONE);
+
+ this.call = call;
+ this.conversation = conversation;
+
+ call.bind_property("encryption", this, "encryption");
+ }
+}
+
}