diff --git a/src/matrix-event-receipt.vala b/src/matrix-event-receipt.vala index 89a4c51..3ec56e4 100644 --- a/src/matrix-event-receipt.vala +++ b/src/matrix-event-receipt.vala @@ -30,7 +30,7 @@ public class Matrix.Event.Receipt : Matrix.Event.Base { string user; } - private HashTable _receipt_data = null; + private Gee.HashMap _receipt_data = null; private static bool _rd_equal(ReceiptData k1, ReceiptData k2) @@ -43,8 +43,7 @@ public class Matrix.Event.Receipt : Matrix.Event.Base { private void _init_receipt_data() { - _receipt_data = new HashTable( - direct_hash, (EqualFunc)_rd_equal); + _receipt_data = new Gee.HashMap(null, (Gee.EqualDataFunc)_rd_equal); } protected override void @@ -76,9 +75,8 @@ public class Matrix.Event.Receipt : Matrix.Event.Base { user = r_user_id }; - _receipt_data.replace( - rd_key, - (ulong)r_content.get_object().get_member("ts").get_int()); + _receipt_data[rd_key] = + (ulong)r_content.get_object().get_member("ts").get_int(); }); } else { warning("content.$event-id.m.read is missing from a m.presence event"); @@ -103,57 +101,57 @@ public class Matrix.Event.Receipt : Matrix.Event.Base { var content_root = root.get_member("content").get_object(); int i = 0; - _receipt_data.foreach((key, value) => { - Json.Object event_object; - Json.Object type_object; - Json.Object user_object; + foreach (var entry in _receipt_data.entries) { + Json.Object event_object; + Json.Object type_object; + Json.Object user_object; - if (key.event_id == null) { - throw new Matrix.Error.INCOMPLETE( - "Won't generate a m.receipt event with an empty event ID"); - } + if (entry.key.event_id == null) { + throw new Matrix.Error.INCOMPLETE( + "Won't generate a m.receipt event with an empty event ID"); + } - if (key.typ == null) { - throw new Matrix.Error.INCOMPLETE( - "Won't generate a m.receipt event with an empty receipt type"); - } + if (entry.key.typ == null) { + throw new Matrix.Error.INCOMPLETE( + "Won't generate a m.receipt event with an empty receipt type"); + } - if (key.user == null) { - throw new Matrix.Error.INCOMPLETE( - "Won't generate a m.receipt event with an empty user ID"); - } + if (entry.key.user == null) { + throw new Matrix.Error.INCOMPLETE( + "Won't generate a m.receipt event with an empty user ID"); + } - i++; + i++; - if ((node = content_root.get_member(key.event_id)) == null) { - event_object = new Json.Object(); - node = new Json.Node(Json.NodeType.OBJECT); - node.set_object(event_object); - content_root.set_member(key.event_id, node); - } else { - event_object = node.get_object(); - } + if ((node = content_root.get_member(entry.key.event_id)) == null) { + event_object = new Json.Object(); + node = new Json.Node(Json.NodeType.OBJECT); + node.set_object(event_object); + content_root.set_member(entry.key.event_id, node); + } else { + event_object = node.get_object(); + } - if ((node = event_object.get_member(key.typ)) == null) { - type_object = new Json.Object(); - node = new Json.Node(Json.NodeType.OBJECT); - node.set_object(type_object); - event_object.set_member(key.typ, node); - } else { - type_object = node.get_object(); - } + if ((node = event_object.get_member(entry.key.typ)) == null) { + type_object = new Json.Object(); + node = new Json.Node(Json.NodeType.OBJECT); + node.set_object(type_object); + event_object.set_member(entry.key.typ, node); + } else { + type_object = node.get_object(); + } - if ((node = type_object.get_member(key.user)) == null) { - user_object = new Json.Object(); - node = new Json.Node(Json.NodeType.OBJECT); - node.set_object(user_object); - type_object.set_member(key.user, node); - } else { - user_object = node.get_object(); - } + if ((node = type_object.get_member(entry.key.user)) == null) { + user_object = new Json.Object(); + node = new Json.Node(Json.NodeType.OBJECT); + node.set_object(user_object); + type_object.set_member(entry.key.user, node); + } else { + user_object = node.get_object(); + } - user_object.set_int_member("ts", value); - }); + user_object.set_int_member("ts", entry.value); + } if (i == 0) { throw new Matrix.Error.INCOMPLETE(