diff options
Diffstat (limited to 'libdino/src')
-rw-r--r-- | libdino/src/service/muc_manager.vala | 4 | ||||
-rw-r--r-- | libdino/src/service/search_processor.vala | 23 | ||||
-rw-r--r-- | libdino/src/service/stream_interactor.vala | 7 |
3 files changed, 22 insertions, 12 deletions
diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala index c1ef2d80..2c4512e6 100644 --- a/libdino/src/service/muc_manager.vala +++ b/libdino/src/service/muc_manager.vala @@ -142,8 +142,8 @@ public class MucManager : StreamInteractionModule, Object { } public bool is_groupchat(Jid jid, Account account) { - Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jid, account); - return !jid.is_full() && conversation != null && conversation.type_ == Conversation.Type.GROUPCHAT; + Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jid, account, Conversation.Type.GROUPCHAT); + return !jid.is_full() && conversation != null; } public bool is_groupchat_occupant(Jid jid, Account account) { diff --git a/libdino/src/service/search_processor.vala b/libdino/src/service/search_processor.vala index 6a08d6b8..37f524ac 100644 --- a/libdino/src/service/search_processor.vala +++ b/libdino/src/service/search_processor.vala @@ -133,27 +133,29 @@ public class SearchProcessor : StreamInteractionModule, Object { .order_by(db.conversation.last_active, "DESC"); foreach(Row chat in chats) { if (suggestions.size == 0) { - suggestions.add(new SearchSuggestion(new Account.from_row(db, chat), new Jid(chat[db.jid.bare_jid]), "from:"+chat[db.jid.bare_jid], after_prev_space, next_space)); + suggestions.add(new SearchSuggestion(new Conversation.from_row(db, chat), new Jid(chat[db.jid.bare_jid]), "from:"+chat[db.jid.bare_jid], after_prev_space, next_space)); } - suggestions.add(new SearchSuggestion(new Account.from_row(db, chat), new Jid(chat[db.account.bare_jid]), "from:"+chat[db.account.bare_jid], after_prev_space, next_space)); + suggestions.add(new SearchSuggestion(new Conversation.from_row(db, chat), new Jid(chat[db.account.bare_jid]), "from:"+chat[db.account.bare_jid], after_prev_space, next_space)); } return suggestions; } if (current_in != null) { // All members of the MUC with history QueryBuilder msgs = db.message.select() - .select_string(@"account.*, $(db.message.counterpart_resource)") + .select_string(@"account.*, $(db.message.counterpart_resource), conversation.*") .join_with(db.jid, db.jid.id, db.message.counterpart_id) .join_with(db.account, db.account.id, db.message.account_id) + .join_on(db.conversation, @"$(db.conversation.account_id)=$(db.account.id) AND $(db.conversation.jid_id)=$(db.jid.id)") .with(db.jid.bare_jid, "=", current_in) .with(db.account.enabled, "=", true) .with(db.message.type_, "=", Message.Type.GROUPCHAT) + .with(db.conversation.type_, "=", Conversation.Type.GROUPCHAT) .with(db.message.counterpart_resource, "LIKE", @"%$current_from%") .group_by({db.message.counterpart_resource}) .order_by_name(@"MAX($(db.message.time))", "DESC") .limit(5); foreach(Row msg in msgs) { - suggestions.add(new SearchSuggestion(new Account.from_row(db, msg), new Jid(current_in).with_resource(msg[db.message.counterpart_resource]), "from:"+msg[db.message.counterpart_resource], after_prev_space, next_space)); + suggestions.add(new SearchSuggestion(new Conversation.from_row(db, msg), new Jid(current_in).with_resource(msg[db.message.counterpart_resource]), "from:"+msg[db.message.counterpart_resource], after_prev_space, next_space)); } } // TODO: auto complete from @@ -179,7 +181,7 @@ public class SearchProcessor : StreamInteractionModule, Object { .order_by(db.conversation.last_active, "DESC") .limit(limit); foreach(Row chat in chats) { - suggestions.add(new SearchSuggestion(new Account.from_row(db, chat), new Jid(chat[db.jid.bare_jid]), "with:"+chat[db.jid.bare_jid], after_prev_space, next_space) { order = chat[db.conversation.last_active]}); + suggestions.add(new SearchSuggestion(new Conversation.from_row(db, chat), new Jid(chat[db.jid.bare_jid]), "with:"+chat[db.jid.bare_jid], after_prev_space, next_space) { order = chat[db.conversation.last_active]}); } // Groupchat PM @@ -193,7 +195,7 @@ public class SearchProcessor : StreamInteractionModule, Object { .order_by(db.conversation.last_active, "DESC") .limit(limit - suggestions.size); foreach(Row chat in chats) { - suggestions.add(new SearchSuggestion(new Account.from_row(db, chat), new Jid(chat[db.jid.bare_jid]).with_resource(chat[db.conversation.resource]), "with:"+chat[db.jid.bare_jid]+"/"+chat[db.conversation.resource], after_prev_space, next_space) { order = chat[db.conversation.last_active]}); + suggestions.add(new SearchSuggestion(new Conversation.from_row(db, chat), new Jid(chat[db.jid.bare_jid]).with_resource(chat[db.conversation.resource]), "with:"+chat[db.jid.bare_jid]+"/"+chat[db.conversation.resource], after_prev_space, next_space) { order = chat[db.conversation.last_active]}); } suggestions.sort((a, b) => (int)(b.order - a.order)); } @@ -216,7 +218,7 @@ public class SearchProcessor : StreamInteractionModule, Object { .order_by(db.conversation.last_active, "DESC") .limit(limit); foreach(Row chat in groupchats) { - suggestions.add(new SearchSuggestion(new Account.from_row(db, chat), new Jid(chat[db.jid.bare_jid]), "in:"+chat[db.jid.bare_jid], after_prev_space, next_space)); + suggestions.add(new SearchSuggestion(new Conversation.from_row(db, chat), new Jid(chat[db.jid.bare_jid]), "in:"+chat[db.jid.bare_jid], after_prev_space, next_space)); } } else { // Other auto complete? @@ -244,15 +246,16 @@ public class SearchProcessor : StreamInteractionModule, Object { } public class SearchSuggestion : Object { - public Account account { get; private set; } + public Account account { get { return conversation.account; } } + public Conversation conversation { get; private set; } public Jid? jid { get; private set; } public string completion { get; private set; } public int start_index { get; private set; } public int end_index { get; private set; } public long order { get; set; } - public SearchSuggestion(Account account, Jid? jid, string completion, int start_index, int end_index) { - this.account = account; + public SearchSuggestion(Conversation conversation, Jid? jid, string completion, int start_index, int end_index) { + this.conversation = conversation; this.jid = jid; this.completion = completion; this.start_index = start_index; diff --git a/libdino/src/service/stream_interactor.vala b/libdino/src/service/stream_interactor.vala index ab4a4a93..91707996 100644 --- a/libdino/src/service/stream_interactor.vala +++ b/libdino/src/service/stream_interactor.vala @@ -58,6 +58,13 @@ public class StreamInteractor : Object { return null; } + public T? get<T>() { + foreach (StreamInteractionModule module in modules) { + if (module.get_type() == typeof(T)) return (T?) module; + } + return null; + } + private void on_stream_opened(Account account, XmppStream stream) { stream.stream_negotiated.connect( (stream) => { stream_negotiated(account, stream); |