aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/conversation_manager.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-31 01:17:01 +0200
committerfiaxh <git@mx.ax.lt>2017-03-31 16:39:28 +0200
commit22adbd38dca0868f0e10754314a3859bba0a7d87 (patch)
tree44ecf9cf8af6aef78030dade95aecb1de2b99873 /libdino/src/service/conversation_manager.vala
parent7d2f995a097086be01426cc79c9c801dabaf9e3b (diff)
downloaddino-22adbd38dca0868f0e10754314a3859bba0a7d87.tar.gz
dino-22adbd38dca0868f0e10754314a3859bba0a7d87.zip
Handle MUC private messages
Diffstat (limited to 'libdino/src/service/conversation_manager.vala')
-rw-r--r--libdino/src/service/conversation_manager.vala24
1 files changed, 22 insertions, 2 deletions
diff --git a/libdino/src/service/conversation_manager.vala b/libdino/src/service/conversation_manager.vala
index 25d355c4..ff4717ee 100644
--- a/libdino/src/service/conversation_manager.vala
+++ b/libdino/src/service/conversation_manager.vala
@@ -31,7 +31,7 @@ public class ConversationManager : StreamInteractionModule, Object {
stream_interactor.get_module(MessageManager.IDENTITY).message_sent.connect(on_message_sent);
}
- public Conversation create_conversation(Jid jid, Account account, Conversation.Type type) {
+ public Conversation create_conversation(Jid jid, Account account, Conversation.Type? type = null) {
assert(conversations.has_key(account));
if (conversations[account].has_key(jid)) {
return conversations[account][jid];
@@ -43,6 +43,26 @@ public class ConversationManager : StreamInteractionModule, Object {
}
}
+ public Conversation? get_conversation_for_message(Entities.Message message) {
+ if (message.type_ == Entities.Message.Type.CHAT) {
+ return create_conversation(message.counterpart.bare_jid, message.account, Conversation.Type.CHAT);
+ } else if (message.type_ == Entities.Message.Type.GROUPCHAT) {
+ return create_conversation(message.counterpart.bare_jid, message.account, Conversation.Type.GROUPCHAT);
+ } else if (message.type_ == Entities.Message.Type.GROUPCHAT_PM) {
+ return create_conversation(message.counterpart, message.account, Conversation.Type.GROUPCHAT_PM);
+ }
+ return null;
+ }
+
+ public Gee.List<Conversation> get_conversations_for_presence(Show show, Account account) {
+ Gee.List<Conversation> ret = new ArrayList<Conversation>(Conversation.equals_func);
+ Conversation? bare_conversation = get_conversation(show.jid, account);
+ if (bare_conversation != null) ret.add(bare_conversation);
+ Conversation? full_conversation = get_conversation(show.jid.bare_jid, account);
+ if (full_conversation != null) ret.add(full_conversation);
+ return ret;
+ }
+
public Conversation? get_conversation(Jid jid, Account account) {
if (conversations.has_key(account)) {
return conversations[account][jid];
@@ -77,7 +97,7 @@ public class ConversationManager : StreamInteractionModule, Object {
}
private void on_account_added(Account account) {
- conversations[account] = new HashMap<Jid, Conversation>(Jid.hash_bare_func, Jid.equals_bare_func);
+ conversations[account] = new HashMap<Jid, Conversation>(Jid.hash_func, Jid.equals_func);
foreach (Conversation conversation in db.get_conversations(account)) {
add_conversation(conversation);
}