aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/entity/conversation.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2018-01-12 21:03:09 +0100
committerfiaxh <git@mx.ax.lt>2018-01-28 00:38:47 +0100
commit782ae4c049e2b6fab13d7453cbb0e74610e7d200 (patch)
tree1b4cd0a1689cee0c2e2cac2ae9a5fb8ebbe63621 /libdino/src/entity/conversation.vala
parentd46d071e57e599e8cfb1780597cbecb36881c4d8 (diff)
downloaddino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.tar.gz
dino-782ae4c049e2b6fab13d7453cbb0e74610e7d200.zip
Move Jid class to xmpp-vala, partially refactor namespace
Diffstat (limited to 'libdino/src/entity/conversation.vala')
-rw-r--r--libdino/src/entity/conversation.vala14
1 files changed, 8 insertions, 6 deletions
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;