parent
57c72d2818
commit
bec810e234
|
@ -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":
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -48,6 +48,9 @@ public class MetaMessageItem : Plugins.MetaConversationItem {
|
|||
public override Object? get_widget(Plugins.WidgetType widget_type) {
|
||||
MessageTextView text_view = new MessageTextView() { visible = true };
|
||||
text_view.add_text(message.body);
|
||||
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
|
||||
text_view.highlight_word(conversation.nickname);
|
||||
}
|
||||
return text_view;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,13 @@ namespace Dino.Ui.ConversationSummary {
|
|||
public class MessageTextView : TextView {
|
||||
|
||||
private TextTag link_tag;
|
||||
private TextTag bold_tag;
|
||||
|
||||
public MessageTextView() {
|
||||
Object(editable:false, hexpand:true, wrap_mode:WrapMode.WORD_CHAR);
|
||||
|
||||
link_tag = buffer.create_tag("url", underline: Pango.Underline.SINGLE, foreground: "blue");
|
||||
bold_tag = buffer.create_tag("semibold", weight: Pango.Weight.SEMIBOLD);
|
||||
button_release_event.connect((event_button) => {
|
||||
if (event_button.button == 1) {
|
||||
open_url(event_button);
|
||||
|
@ -44,6 +46,24 @@ public class MessageTextView : TextView {
|
|||
format_suffix_urls(text);
|
||||
}
|
||||
|
||||
public void highlight_word(string word) {
|
||||
Regex word_regex = new Regex("""\b""" + Regex.escape_string(word) + """\b""");
|
||||
MatchInfo match_info;
|
||||
word_regex.match(buffer.text, 0, out match_info);
|
||||
for (; match_info.matches(); match_info.next()) {
|
||||
int start;
|
||||
int end;
|
||||
match_info.fetch_pos(0, out start, out end);
|
||||
start = buffer.text[0:start].char_count();
|
||||
end = buffer.text[0:end].char_count();
|
||||
TextIter start_iter;
|
||||
TextIter end_iter;
|
||||
buffer.get_iter_at_offset(out start_iter, start);
|
||||
buffer.get_iter_at_offset(out end_iter, end);
|
||||
buffer.apply_tag_by_name("semibold", start_iter, end_iter);
|
||||
}
|
||||
}
|
||||
|
||||
private void update_display_style() {
|
||||
LinkButton lnk = new LinkButton("http://example.com");
|
||||
RGBA link_color = lnk.get_style_context().get_color(StateFlags.LINK);
|
||||
|
|
|
@ -53,6 +53,9 @@ public class MetaSlashmeItem : Plugins.MetaConversationItem {
|
|||
|
||||
public override Object? get_widget(Plugins.WidgetType widget_type) {
|
||||
text_view = new MessageTextView() { valign=Align.CENTER, vexpand=true, visible = true };
|
||||
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
|
||||
text_view.highlight_word(conversation.nickname);
|
||||
}
|
||||
|
||||
string display_name = Util.get_message_display_name(stream_interactor, message, conversation.account);
|
||||
string color = Util.get_name_hex_color(stream_interactor, conversation.account, conversation.counterpart, Util.is_dark_theme(text_view));
|
||||
|
|
Loading…
Reference in a new issue