aboutsummaryrefslogtreecommitdiff
path: root/libdino
diff options
context:
space:
mode:
authorMiquel Lionel <lionel@les-miquelots.net>2023-10-30 21:48:08 +0100
committerMiquel Lionel <lionel@les-miquelots.net>2023-10-30 21:48:08 +0100
commitd761e8ccd5293d2f30a889b0cbe302c985aee68c (patch)
tree922bb248a7fee4cdff3da114abc7d77200f3d0da /libdino
parent302e954c99c71d670201828c6746dfaa40276d6d (diff)
parent3de716446819550514d50a8112f5b6dd0c662702 (diff)
downloaddino-d761e8ccd5293d2f30a889b0cbe302c985aee68c.tar.gz
dino-d761e8ccd5293d2f30a889b0cbe302c985aee68c.zip
Show which account is currently used in conversation details in the about sectionadd_conversation_account_indicator
Diffstat (limited to 'libdino')
-rw-r--r--libdino/CMakeLists.txt8
-rw-r--r--libdino/dino.deps6
-rw-r--r--libdino/meson.build6
-rw-r--r--libdino/src/application.vala3
-rw-r--r--libdino/src/service/avatar_manager.vala6
-rw-r--r--libdino/src/service/calls.vala5
-rw-r--r--libdino/src/service/contact_model.vala58
-rw-r--r--libdino/src/service/conversation_manager.vala7
-rw-r--r--libdino/src/service/history_sync.vala3
-rw-r--r--libdino/src/service/message_processor.vala1
-rw-r--r--libdino/src/service/stream_interactor.vala5
11 files changed, 94 insertions, 14 deletions
diff --git a/libdino/CMakeLists.txt b/libdino/CMakeLists.txt
index 3c184cfd..d52f9184 100644
--- a/libdino/CMakeLists.txt
+++ b/libdino/CMakeLists.txt
@@ -6,6 +6,11 @@ find_packages(LIBDINO_PACKAGES REQUIRED
GObject
)
+set(LIBDINO_DEFINITIONS)
+if(LIBDINO_VERSION VERSION_EQUAL "0.56.11")
+ set(LIBDINO_DEFINITIONS ${LIBDINO_DEFINITIONS} VALA_0_56_11)
+endif()
+
vala_precompile(LIBDINO_VALA_C
SOURCES
src/application.vala
@@ -35,6 +40,7 @@ SOURCES
src/service/calls.vala
src/service/chat_interaction.vala
src/service/connection_manager.vala
+ src/service/contact_model.vala
src/service/content_item_store.vala
src/service/conversation_manager.vala
src/service/counterpart_interaction_manager.vala
@@ -76,6 +82,8 @@ GENERATE_VAPI
dino
GENERATE_HEADER
dino
+DEFINITIONS
+ ${LIBDINO_DEFINITIONS}
)
add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/exports/dino_i18n.h"
diff --git a/libdino/dino.deps b/libdino/dino.deps
new file mode 100644
index 00000000..c1146392
--- /dev/null
+++ b/libdino/dino.deps
@@ -0,0 +1,6 @@
+gdk-pixbuf-2.0
+gee-0.8
+glib-2.0
+gmodule-2.0
+qlite
+xmpp-vala
diff --git a/libdino/meson.build b/libdino/meson.build
index 0ebaff33..356c15d3 100644
--- a/libdino/meson.build
+++ b/libdino/meson.build
@@ -47,6 +47,7 @@ sources = files(
'src/service/calls.vala',
'src/service/chat_interaction.vala',
'src/service/connection_manager.vala',
+ 'src/service/contact_model.vala',
'src/service/content_item_store.vala',
'src/service/conversation_manager.vala',
'src/service/counterpart_interaction_manager.vala',
@@ -82,5 +83,8 @@ c_args = [
'-DDINO_SYSTEM_PLUGIN_DIR="@0@"'.format(get_option('prefix') / get_option('plugindir')),
'-DG_LOG_DOMAIN="libdino"',
]
-lib_dino = library('dino', sources, c_args: c_args, include_directories: include_directories('src'), dependencies: dependencies)
+lib_dino = library('dino', sources, c_args: c_args, include_directories: include_directories('src'), dependencies: dependencies, version: '0.0', install: true, install_dir: [true, true, true])
dep_dino = declare_dependency(link_with: lib_dino, include_directories: include_directories('.', 'src'))
+
+install_data('dino.deps', install_dir: get_option('datadir') / 'vala/vapi') # TODO: workaround for https://github.com/mesonbuild/meson/issues/9756
+install_headers('src/dino_i18n.h')
diff --git a/libdino/src/application.vala b/libdino/src/application.vala
index 5e58e364..0fcee731 100644
--- a/libdino/src/application.vala
+++ b/libdino/src/application.vala
@@ -39,12 +39,12 @@ public interface Application : GLib.Application {
PresenceManager.start(stream_interactor);
CounterpartInteractionManager.start(stream_interactor);
BlockingManager.start(stream_interactor);
+ Calls.start(stream_interactor, db);
ConversationManager.start(stream_interactor, db);
MucManager.start(stream_interactor);
AvatarManager.start(stream_interactor, db);
RosterManager.start(stream_interactor, db);
FileManager.start(stream_interactor, db);
- Calls.start(stream_interactor, db);
CallStore.start(stream_interactor, db);
ContentItemStore.start(stream_interactor, db);
ChatInteraction.start(stream_interactor);
@@ -57,6 +57,7 @@ public interface Application : GLib.Application {
Reactions.start(stream_interactor, db);
Replies.start(stream_interactor, db);
FallbackBody.start(stream_interactor, db);
+ ContactModels.start(stream_interactor);
create_actions();
diff --git a/libdino/src/service/avatar_manager.vala b/libdino/src/service/avatar_manager.vala
index 1296856b..3bd38e72 100644
--- a/libdino/src/service/avatar_manager.vala
+++ b/libdino/src/service/avatar_manager.vala
@@ -52,7 +52,7 @@ public class AvatarManager : StreamInteractionModule, Object {
if (hash == null) return null;
File file = File.new_for_path(Path.build_filename(folder, hash));
if (!file.query_exists()) {
- fetch_and_store_for_jid(account, jid_);
+ fetch_and_store_for_jid.begin(account, jid_);
return null;
} else {
return file;
@@ -169,7 +169,7 @@ public class AvatarManager : StreamInteractionModule, Object {
);
foreach (var entry in get_avatar_hashes(account, Source.USER_AVATARS).entries) {
- on_user_avatar_received(account, entry.key, entry.value);
+ on_user_avatar_received.begin(account, entry.key, entry.value);
}
foreach (var entry in get_avatar_hashes(account, Source.VCARD).entries) {
@@ -179,7 +179,7 @@ public class AvatarManager : StreamInteractionModule, Object {
continue;
}
- on_vcard_avatar_received(account, entry.key, entry.value);
+ on_vcard_avatar_received.begin(account, entry.key, entry.value);
}
}
diff --git a/libdino/src/service/calls.vala b/libdino/src/service/calls.vala
index ebaf8d03..eca7e223 100644
--- a/libdino/src/service/calls.vala
+++ b/libdino/src/service/calls.vala
@@ -61,8 +61,6 @@ namespace Dino {
call_state.initiate_groupchat_call.begin(conversation.counterpart);
}
- conversation.last_active = call.time;
-
call_outgoing(call, call_state, conversation);
return call_state;
@@ -221,7 +219,6 @@ namespace Dino {
Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(call.counterpart.bare_jid, account, Conversation.Type.CHAT);
stream_interactor.get_module(CallStore.IDENTITY).add_call(call, conversation);
- conversation.last_active = call.time;
var call_state = new CallState(call, stream_interactor);
connect_call_state_signals(call_state);
@@ -294,7 +291,6 @@ namespace Dino {
Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(inviter_jid.bare_jid, account);
if (conversation == null) return null;
stream_interactor.get_module(CallStore.IDENTITY).add_call(call, conversation);
- conversation.last_active = call.time;
CallState call_state = new CallState(call, stream_interactor);
connect_call_state_signals(call_state);
@@ -465,7 +461,6 @@ namespace Dino {
Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).approx_conversation_for_stanza(from_jid, to_jid, account, message_stanza.type_);
if (conversation == null) return;
- conversation.last_active = call_state.call.time;
if (call_state.call.direction == Call.DIRECTION_INCOMING) {
call_incoming(call_state.call, call_state, conversation, video_requested, multiparty);
diff --git a/libdino/src/service/contact_model.vala b/libdino/src/service/contact_model.vala
new file mode 100644
index 00000000..312df4f7
--- /dev/null
+++ b/libdino/src/service/contact_model.vala
@@ -0,0 +1,58 @@
+using Xmpp;
+using Gee;
+using Qlite;
+
+using Dino.Entities;
+
+public class Dino.Model.ConversationDisplayName : Object {
+ public string display_name { get; set; }
+}
+
+namespace Dino {
+ public class ContactModels : StreamInteractionModule, Object {
+ public static ModuleIdentity<ContactModels> IDENTITY = new ModuleIdentity<ContactModels>("contact_models");
+ public string id { get { return IDENTITY.id; } }
+
+ private StreamInteractor stream_interactor;
+ private HashMap<Conversation, Model.ConversationDisplayName> conversation_models = new HashMap<Conversation, Model.ConversationDisplayName>(Conversation.hash_func, Conversation.equals_func);
+
+ public static void start(StreamInteractor stream_interactor) {
+ ContactModels m = new ContactModels(stream_interactor);
+ stream_interactor.add_module(m);
+ }
+
+ private ContactModels(StreamInteractor stream_interactor) {
+ this.stream_interactor = stream_interactor;
+
+ stream_interactor.get_module(MucManager.IDENTITY).room_info_updated.connect((account, jid) => {
+ check_update_models(account, jid, Conversation.Type.GROUPCHAT);
+ });
+ stream_interactor.get_module(MucManager.IDENTITY).private_room_occupant_updated.connect((account, room, occupant) => {
+ check_update_models(account, room, Conversation.Type.GROUPCHAT);
+ });
+ stream_interactor.get_module(MucManager.IDENTITY).subject_set.connect((account, jid, subject) => {
+ check_update_models(account, jid, Conversation.Type.GROUPCHAT);
+ });
+ stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect((account, jid, roster_item) => {
+ check_update_models(account, jid, Conversation.Type.CHAT);
+ });
+ }
+
+ private void check_update_models(Account account, Jid jid, Conversation.Type conversation_ty) {
+ var conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jid, account, conversation_ty);
+ if (conversation == null) return;
+ var display_name_model = conversation_models[conversation];
+ if (display_name_model == null) return;
+ display_name_model.display_name = Dino.get_conversation_display_name(stream_interactor, conversation, "%s (%s)");
+ }
+
+ public Model.ConversationDisplayName get_display_name_model(Conversation conversation) {
+ if (conversation_models.has_key(conversation)) return conversation_models[conversation];
+
+ var model = new Model.ConversationDisplayName();
+ model.display_name = Dino.get_conversation_display_name(stream_interactor, conversation, "%s (%s)");
+ conversation_models[conversation] = model;
+ return model;
+ }
+ }
+} \ No newline at end of file
diff --git a/libdino/src/service/conversation_manager.vala b/libdino/src/service/conversation_manager.vala
index 59ccbac4..f966ccc7 100644
--- a/libdino/src/service/conversation_manager.vala
+++ b/libdino/src/service/conversation_manager.vala
@@ -29,6 +29,8 @@ public class ConversationManager : StreamInteractionModule, Object {
stream_interactor.account_removed.connect(on_account_removed);
stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(new MessageListener(stream_interactor));
stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect(handle_sent_message);
+ stream_interactor.get_module(Calls.IDENTITY).call_incoming.connect(handle_new_call);
+ stream_interactor.get_module(Calls.IDENTITY).call_outgoing.connect(handle_new_call);
}
public Conversation create_conversation(Jid jid, Account account, Conversation.Type? type = null) {
@@ -194,6 +196,11 @@ public class ConversationManager : StreamInteractionModule, Object {
}
}
+ private void handle_new_call(Call call, CallState state, Conversation conversation) {
+ conversation.last_active = call.time;
+ start_conversation(conversation);
+ }
+
private void add_conversation(Conversation conversation) {
if (!conversations[conversation.account].has_key(conversation.counterpart)) {
conversations[conversation.account][conversation.counterpart] = new ArrayList<Conversation>(Conversation.equals_func);
diff --git a/libdino/src/service/history_sync.vala b/libdino/src/service/history_sync.vala
index 0c0571bb..8ab6d7bb 100644
--- a/libdino/src/service/history_sync.vala
+++ b/libdino/src/service/history_sync.vala
@@ -388,9 +388,6 @@ public class Dino.HistorySync {
page_result = PageResult.NoMoreMessages;
}
- string selection = null;
- string[] selection_args = {};
-
string query_id = query_params.query_id;
string? after_id = query_params.start_id;
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala
index 01687083..baab37ce 100644
--- a/libdino/src/service/message_processor.vala
+++ b/libdino/src/service/message_processor.vala
@@ -167,7 +167,6 @@ public class MessageProcessor : StreamInteractionModule, Object {
new_message.counterpart = counterpart_override ?? (new_message.direction == Entities.Message.DIRECTION_SENT ? message.to : message.from);
new_message.ourpart = new_message.direction == Entities.Message.DIRECTION_SENT ? message.from : message.to;
- XmppStream? stream = stream_interactor.get_stream(account);
Xmpp.MessageArchiveManagement.MessageFlag? mam_message_flag = Xmpp.MessageArchiveManagement.MessageFlag.get_flag(message);
EntityInfo entity_info = stream_interactor.get_module(EntityInfo.IDENTITY);
if (mam_message_flag != null && mam_message_flag.mam_id != null) {
diff --git a/libdino/src/service/stream_interactor.vala b/libdino/src/service/stream_interactor.vala
index 192460d4..5d248327 100644
--- a/libdino/src/service/stream_interactor.vala
+++ b/libdino/src/service/stream_interactor.vala
@@ -89,7 +89,12 @@ public class ModuleIdentity<T> : Object {
}
public T? cast(StreamInteractionModule module) {
+#if VALA_0_56_11
+ // We can't typecheck due to compiler bug
+ return (T) module;
+#else
return module.get_type().is_a(typeof(T)) ? (T?) module : null;
+#endif
}
public bool matches(StreamInteractionModule module) {