aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/entity/conversation.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-10 19:53:24 +0100
committerfiaxh <git@mx.ax.lt>2017-03-10 19:53:24 +0100
commit24b55d83a1f9e21b028c8d5ac9778e75565f417d (patch)
tree195b0f332e32d08e1a18fc3d8a5a6725c5ed11d7 /libdino/src/entity/conversation.vala
parent4c48c5c16d5f5b010c2e5dfb1affcb59f937510c (diff)
parent29ca70a6d534e1cd79963718c793ae740318cff1 (diff)
downloaddino-24b55d83a1f9e21b028c8d5ac9778e75565f417d.tar.gz
dino-24b55d83a1f9e21b028c8d5ac9778e75565f417d.zip
Merge branch 'master' of github.com:dino/dino
Diffstat (limited to 'libdino/src/entity/conversation.vala')
-rw-r--r--libdino/src/entity/conversation.vala52
1 files changed, 52 insertions, 0 deletions
diff --git a/libdino/src/entity/conversation.vala b/libdino/src/entity/conversation.vala
new file mode 100644
index 00000000..2da6dce3
--- /dev/null
+++ b/libdino/src/entity/conversation.vala
@@ -0,0 +1,52 @@
+namespace Dino.Entities {
+public class Conversation : Object {
+
+ public signal void object_updated(Conversation conversation);
+
+ public enum Encryption {
+ UNENCRYPTED,
+ PGP
+ }
+
+ public enum Type {
+ CHAT,
+ GROUPCHAT
+ }
+
+ public int id { get; set; }
+ public Account account { get; private set; }
+ public Jid counterpart { get; private set; }
+ public bool active { get; set; }
+ public DateTime last_active { get; set; }
+ public Encryption encryption { get; set; }
+ public Type? type_ { get; set; }
+ public Message read_up_to { get; set; }
+
+ public Conversation(Jid jid, Account account) {
+ this.counterpart = jid;
+ this.account = account;
+ this.active = false;
+ this.last_active = new DateTime.from_unix_utc(0);
+ this.encryption = Encryption.UNENCRYPTED;
+ }
+
+ public Conversation.with_id(Jid jid, Account account, int id) {
+ this.counterpart = jid;
+ this.account = account;
+ this.id = id;
+ }
+
+ public bool equals(Conversation? conversation) {
+ if (conversation == null) return false;
+ return equals_func(this, conversation);
+ }
+
+ public static bool equals_func(Conversation conversation1, Conversation conversation2) {
+ return conversation1.counterpart.equals(conversation2.counterpart) && conversation1.account.equals(conversation2.account);
+ }
+
+ public static uint hash_func(Conversation conversation) {
+ return conversation.counterpart.to_string().hash() ^ conversation.account.bare_jid.to_string().hash();
+ }
+}
+} \ No newline at end of file