diff options
Diffstat (limited to 'libdino')
-rw-r--r-- | libdino/src/entity/conversation.vala | 7 | ||||
-rw-r--r-- | libdino/src/service/conversation_manager.vala | 6 | ||||
-rw-r--r-- | libdino/src/service/muc_manager.vala | 15 |
3 files changed, 17 insertions, 11 deletions
diff --git a/libdino/src/entity/conversation.vala b/libdino/src/entity/conversation.vala index a3a28618..9026e33f 100644 --- a/libdino/src/entity/conversation.vala +++ b/libdino/src/entity/conversation.vala @@ -16,7 +16,7 @@ public class Conversation : Object { public Type type_ { get; set; } public Account account { get; private set; } public Jid counterpart { get; private set; } - public string? nickname { get; private set; } + public string? nickname { get; set; } public bool active { get; set; default = false; } private DateTime? _last_active; public DateTime? last_active { @@ -84,6 +84,9 @@ public class Conversation : Object { if (read_up_to != null) { insert.value(db.conversation.read_up_to, read_up_to.id); } + if (nickname != null) { + insert.value(db.conversation.resource, nickname); + } if (counterpart.is_full()) { insert.value(db.conversation.resource, counterpart.resourcepart); } @@ -145,6 +148,8 @@ public class Conversation : Object { update.set_null(db.conversation.read_up_to); } break; + case "nickname": + update.set(db.conversation.resource, nickname); break; case "active": update.set(db.conversation.active, active); break; case "last-active": diff --git a/libdino/src/service/conversation_manager.vala b/libdino/src/service/conversation_manager.vala index f6e3553d..c72500b4 100644 --- a/libdino/src/service/conversation_manager.vala +++ b/libdino/src/service/conversation_manager.vala @@ -26,7 +26,6 @@ public class ConversationManager : StreamInteractionModule, Object { this.stream_interactor = stream_interactor; stream_interactor.add_module(this); stream_interactor.account_added.connect(on_account_added); - stream_interactor.get_module(MucManager.IDENTITY).joined.connect(on_groupchat_joined); stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(new MessageListener(stream_interactor)); stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect(handle_new_message); } @@ -155,11 +154,6 @@ public class ConversationManager : StreamInteractionModule, Object { start_conversation(conversation); } - private void on_groupchat_joined(Account account, Jid jid, string nick) { - Conversation conversation = create_conversation(jid, account, Conversation.Type.GROUPCHAT); - start_conversation(conversation); - } - private void add_conversation(Conversation conversation) { conversations[conversation.account][conversation.counterpart] = conversation; if (conversation.active) { diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala index f224a8ec..696f304c 100644 --- a/libdino/src/service/muc_manager.vala +++ b/libdino/src/service/muc_manager.vala @@ -208,10 +208,7 @@ public class MucManager : StreamInteractionModule, Object { private void on_account_added(Account account) { stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).room_entered.connect( (stream, jid, nick) => { - enter_errors.unset(jid); - set_autojoin(stream, jid, nick, null); // TODO password - joined(account, jid, nick); - stream_interactor.get_module(MessageProcessor.IDENTITY).send_unsent_messages(account, jid); + on_room_entred(account, stream, jid, nick); }); stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).room_enter_error.connect( (stream, jid, error) => { enter_errors[jid] = error; @@ -243,6 +240,16 @@ public class MucManager : StreamInteractionModule, Object { }); } + private void on_room_entred(Account account, XmppStream stream, Jid jid, string nick) { + enter_errors.unset(jid); + set_autojoin(stream, jid, nick, null); // TODO password + joined(account, jid, nick); + stream_interactor.get_module(MessageProcessor.IDENTITY).send_unsent_messages(account, jid); + Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.GROUPCHAT); + stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation); + conversation.nickname = nick; + } + private void join_all_active(Account account) { Gee.List<Conversation> conversations = stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations(account); foreach (Conversation conversation in conversations) { |