aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-13 21:54:12 +0100
committerMarvin W <git@larma.de>2017-03-13 22:00:17 +0100
commit2d6f580c871df055ca79b8a8be53e53e62aa155c (patch)
tree9c69f7c7e6a4f4ae2a3137fc580dbb507abf2ad4
parent1a4cd2508bfc71801d9a1f7029580cc9e4fdf659 (diff)
downloaddino-2d6f580c871df055ca79b8a8be53e53e62aa155c.tar.gz
dino-2d6f580c871df055ca79b8a8be53e53e62aa155c.zip
correctly bootstrap omemo when there is no devicelist on server yet + concurrency bug fixes
-rw-r--r--libdino/src/service/message_manager.vala6
-rw-r--r--plugins/omemo/src/manager.vala10
-rw-r--r--plugins/omemo/src/stream_module.vala11
3 files changed, 22 insertions, 5 deletions
diff --git a/libdino/src/service/message_manager.vala b/libdino/src/service/message_manager.vala
index 9f87c932..d159158b 100644
--- a/libdino/src/service/message_manager.vala
+++ b/libdino/src/service/message_manager.vala
@@ -85,8 +85,10 @@ public class MessageManager : StreamInteractionModule, Object {
private void send_unsent_messages(Account account) {
Gee.List<Entities.Message> unsend_messages = db.get_unsend_messages(account);
foreach (Entities.Message message in unsend_messages) {
- Conversation conversation = ConversationManager.get_instance(stream_interactor).get_conversation(message.counterpart, account);
- send_xmpp_message(message, conversation, true);
+ Conversation? conversation = ConversationManager.get_instance(stream_interactor).get_conversation(message.counterpart, account);
+ if (conversation != null) {
+ send_xmpp_message(message, conversation, true);
+ }
}
}
diff --git a/plugins/omemo/src/manager.vala b/plugins/omemo/src/manager.vala
index b2226e2a..197ba021 100644
--- a/plugins/omemo/src/manager.vala
+++ b/plugins/omemo/src/manager.vala
@@ -11,13 +11,14 @@ public class Manager : StreamInteractionModule, Object {
private StreamInteractor stream_interactor;
private Database db;
- private ArrayList<Entities.Message> to_send_after_devicelist = new ArrayList<Entities.Message>();
- private ArrayList<Entities.Message> to_send_after_session = new ArrayList<Entities.Message>();
+ private ConcurrentList<Entities.Message> to_send_after_devicelist = new ConcurrentList<Entities.Message>();
+ private ConcurrentList<Entities.Message> to_send_after_session = new ConcurrentList<Entities.Message>();
private Manager(StreamInteractor stream_interactor, Database db) {
this.stream_interactor = stream_interactor;
this.db = db;
+ stream_interactor.stream_negotiated.connect(on_stream_negotiated);
stream_interactor.account_added.connect(on_account_added);
MessageManager.get_instance(stream_interactor).pre_message_received.connect(on_pre_message_received);
MessageManager.get_instance(stream_interactor).pre_message_send.connect(on_pre_message_send);
@@ -68,6 +69,11 @@ public class Manager : StreamInteractionModule, Object {
stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).session_started.connect((jid, device_id) => on_session_started(account, jid));
}
+ private void on_stream_negotiated(Account account) {
+ Core.XmppStream stream = stream_interactor.get_stream(account);
+ stream_interactor.module_manager.get_module(account, StreamModule.IDENTITY).request_user_devicelist(stream, account.bare_jid.to_string());
+ }
+
private void on_session_started(Account account, string jid) {
lock(to_send_after_session) {
Iterator<Entities.Message> iter = to_send_after_session.iterator();
diff --git a/plugins/omemo/src/stream_module.vala b/plugins/omemo/src/stream_module.vala
index 86a9225d..4283fd74 100644
--- a/plugins/omemo/src/stream_module.vala
+++ b/plugins/omemo/src/stream_module.vala
@@ -176,8 +176,17 @@ public class StreamModule : XmppStreamModule {
return (string)rarr;
}
- public void on_devicelist(XmppStream stream, string jid, string id, StanzaNode node) {
+ public void request_user_devicelist(XmppStream stream, string jid) {
+ stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NODE_DEVICELIST, (stream, jid, id, node, obj) => (obj as StreamModule).on_devicelist(stream, jid, id ?? "", node), this);
+ }
+
+ public void on_devicelist(XmppStream stream, string jid, string id, StanzaNode? node_) {
+ StanzaNode? node = node_;
if (jid == get_bare_jid(Bind.Flag.get_flag(stream).my_jid) && store.local_registration_id != 0) {
+ if (node == null) {
+ node = new StanzaNode.build("list", NS_URI).add_self_xmlns().put_node(new StanzaNode.build("device", NS_URI));
+ }
+
lock (device_list_loading) {
if (!device_list_loading) {
device_list_loading = true;