From 42d9ab7716e7aacead9618d19ff52e94215d974c Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 21 Mar 2016 17:25:48 +0100 Subject: [PATCH] tmp --- src/matrix-room.vala | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/matrix-room.vala b/src/matrix-room.vala index 25279ac..918cf0c 100644 --- a/src/matrix-room.vala +++ b/src/matrix-room.vala @@ -25,8 +25,12 @@ public class Matrix.Room : GLib.Object { /** * The ID of the room this object belongs to. + * + * If this property is null, then this object is acting as a + * temporary stash for another room object, which is used when + * calculating state events to be sent by apply_changes(). */ - public string room_id { get; construct; } + public string? room_id { get; construct; } /** * All the known room aliases. @@ -155,13 +159,22 @@ public class Matrix.Room : GLib.Object { private HashTable _members = new HashTable(str_hash, str_equal); + private Room _stash = null; + /** * Create a new Room object. + * + * @param room_id the ID of the room this object belongs to. For + * null values, see remark at the room_id property. */ public - Room(string room_id) + Room(string? room_id) { Object(room_id : room_id); + + if (room_id != null) { + _stash = new Room(null); + } } /** @@ -344,4 +357,26 @@ public class Matrix.Room : GLib.Object { { return _event_levels[event_type]; } + + /** + * Generate a set of events that can change the room state on the + * home server similar to what this object shows. + */ + public void + apply_changes() + { + Matrix.Event.Base[] ret = {}; + + foreach (var to_add in _aliases) { + if (!(to_add in _stash._aliases)) { + // add alias + } + } + + foreach (var to_remove in _stash._aliases) { + if (!(to_remove in _aliases)) { + // remove alias + } + } + } }