From 782ae4c049e2b6fab13d7453cbb0e74610e7d200 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Fri, 12 Jan 2018 21:03:09 +0100 Subject: Move Jid class to xmpp-vala, partially refactor namespace --- libdino/src/entity/conversation.vala | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'libdino/src/entity/conversation.vala') diff --git a/libdino/src/entity/conversation.vala b/libdino/src/entity/conversation.vala index 83c5ac22..fe9cf9ad 100644 --- a/libdino/src/entity/conversation.vala +++ b/libdino/src/entity/conversation.vala @@ -1,3 +1,5 @@ +using Xmpp; + namespace Dino.Entities { public class Conversation : Object { @@ -11,6 +13,7 @@ public class Conversation : Object { } public int id { get; set; } + public Type type_ { get; set; } public Account account { get; private set; } public Jid counterpart { get; private set; } public bool active { get; set; default = false; } @@ -25,7 +28,6 @@ public class Conversation : Object { } } public Encryption encryption { get; set; default = Encryption.NONE; } - public Type type_ { get; set; } public Message? read_up_to { get; set; } public enum NotifySetting { DEFAULT, ON, OFF, HIGHLIGHT } @@ -48,14 +50,14 @@ public class Conversation : Object { this.db = db; id = row[db.conversation.id]; + type_ = (Conversation.Type) row[db.conversation.type_]; account = db.get_account_by_id(row[db.conversation.account_id]); string? resource = row[db.conversation.resource]; - string jid = db.get_jid_by_id(row[db.conversation.jid_id]); - counterpart = resource != null ? new Jid.with_resource(jid, resource) : new Jid(jid); + counterpart = Jid.parse(db.get_jid_by_id(row[db.conversation.jid_id])); + if (type_ == Conversation.Type.GROUPCHAT_PM) counterpart = counterpart.with_resource(resource); active = row[db.conversation.active]; int64? last_active = row[db.conversation.last_active]; if (last_active != null) this.last_active = new DateTime.from_unix_utc(last_active); - type_ = (Conversation.Type) row[db.conversation.type_]; encryption = (Encryption) row[db.conversation.encryption]; int? read_up_to = row[db.conversation.read_up_to]; if (read_up_to != null) this.read_up_to = db.get_message_by_id(read_up_to); @@ -95,10 +97,10 @@ public class Conversation : Object { } public NotifySetting get_notification_default_setting(StreamInteractor stream_interactor) { - Xmpp.Core.XmppStream? stream = stream_interactor.get_stream(account); + Xmpp.XmppStream? stream = stream_interactor.get_stream(account); if (!Application.get_default().settings.notifications) return NotifySetting.OFF; if (type_ == Type.GROUPCHAT) { - bool members_only = stream.get_flag(Xmpp.Xep.Muc.Flag.IDENTITY).has_room_feature(counterpart.bare_jid.to_string(), Xmpp.Xep.Muc.Feature.MEMBERS_ONLY); + bool members_only = stream.get_flag(Xmpp.Xep.Muc.Flag.IDENTITY).has_room_feature(counterpart.bare_jid, Xmpp.Xep.Muc.Feature.MEMBERS_ONLY); return members_only ? NotifySetting.ON : NotifySetting.HIGHLIGHT; } return NotifySetting.ON; -- cgit v1.2.3-54-g00ecf