/* * Copyright (C) 2012 Openismus GmbH * * Author: Krzesimir Nowak * * Rygel is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Rygel is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ using GUPnP; using Gee; // Helper class for building ContentDirectory LastChange messages internal class Rygel.LastChange : Object { private const string HEADER = "" + ""; private const string FOOTER = ""; private LinkedList entries; private StringBuilder str; private bool update; private bool clear_on_add; public LastChange () { this.entries = new LinkedList (); this.str = new StringBuilder (); this.update = true; this.clear_on_add = false; } public void add_event (LastChangeEntry entry) { if (this.clear_on_add) { this.clear_on_add = false; this.entries.clear (); } this.entries.add (entry); this.update = true; } public void clear_on_new_event () { this.clear_on_add = true; } public string get_log () { if (this.update) { this.str.erase (); this.str.append (HEADER); foreach (LastChangeEntry entry in this.entries) { str.append (entry.to_string ()); } this.str.append (FOOTER); this.update = false; } return this.str.str; } }